FairRoot/PandaRoot
Functions
emc_module4_StraightGeo24_ste.C File Reference

Go to the source code of this file.

Functions

int emc_module4_StraightGeo24_ste ()
 

Function Documentation

int emc_module4_StraightGeo24_ste ( )

Definition at line 1 of file emc_module4_StraightGeo24_ste.C.

References b, BoxVol, BoxVol1, BoxVol2, BoxVol3, BoxVol4, BoxVol5, BoxVol6, CbmMediumAir, CbmMediumAluminium, CbmMediumCarbon, CbmMediumPWO, col, CrystalShape, CrystalVol, Double_t, fi, geobuild, geoFace, geoLoad, gGeoMan, jj, kAlveoleAlveole, kAlveoleThickness, kCrystalAlveole, kCrystalCrystal, kGluedAlveoleThickness, kHeight, kLength, kNumOfBoxes, kNumOfBoxes1, kNumOfBoxes2, kNumOfBoxes4, kNumOfBoxes4InSubunit, kNumOfCrystals, kNumOfCrystalsInBox2, kNumOfCrystalsInBox4, kNumOfQuarters, kNumOfSubunit, kSizeOfCrys, Media, medium, name, nmed, outfile, QuarterVol, reflection, rotBox, rotCrystal, rotQuar, rotSub, row, sizeOfBox1, sizeOfBox2, sizeOfBox4, sizeOfQuar, sizeOfSubunit, SubunitVol, SubunitVol1, SubunitVol2, SubunitVol3, SubunitVol4, SubunitVol5, SubunitVol6, SubunitVol7, SubunitVol8, SubunitVol9, top, trBox, trCrystal, trQuar, trSub, and TString.

1  {
2  // This macro creates the Backward EndCap (BwEndCap) geometry
3  // of the EMC detector for PANDA.
4  // The straight crystals with the size of 24.4x24.4x200 mm^3 are used
5  //
6  // Autor: Dmitry Khaneft, Uni Minaz/GSI (10.05.2009)
7 
8  //-----------------------------
9  const Double_t kWidth = 2.44; // Width of crystal (cm)
10  const Double_t kHeight = 2.44; // Height of crystal (cm)
11  const Double_t kLength = 20.0; // Length of Crystal (cm)
12  const Double_t kSizeOfCrys = 2.44;
13 
14  const Double_t kAlveoleThickness = 0.02; // Thickness of alveole between Subunits (cm)
15  const Double_t kGluedAlveoleThickness = 0.04; // Thickness of glued alveole between boxes4 inside Subunits (cm)
16  const Double_t kCrystalCrystal = 0.06; // Distance Crystal-Crystal (cm)
17  const Double_t kAlveoleAlveole = 0.08; // Distance Alveole-Alveole (cm)
18  const Double_t kCrystalAlveole = 0.024; // Distance Crystal-Alveole (cm)
19 
20  //const Int_t kNumOfQuarters = 4;
21  const Int_t kNumOfSubunit = 4;
22  const Int_t kNumOfBoxes4InSubunit = 4;
23  const Int_t kNumOfBoxes4 = 12;
24  const Int_t kNumOfBoxes2 = 10;
25  const Int_t kNumOfBoxes1 = 3;
26  const Int_t kNumOfCrystalsInBox4 = 4;
27  const Int_t kNumOfCrystalsInBox2 = 2;
28 
29  const Int_t kNumOfQuarters = 1; // Number of Quarter - only 1 is created, next 3 are copied at the end of the file
30  const Int_t kNumOfBoxes = 4; // Numbers of Boxes in one Subunit
31  const Int_t kNumOfCrystals = 4; // Numbers of Crystals in one Box
32 
33  Double_t sizeOfBox1 = kWidth + 2*kAlveoleThickness + 2*kCrystalAlveole;
34  Double_t sizeOfBox2 = 2*kWidth + 2*kAlveoleThickness + 2*kCrystalAlveole + kCrystalCrystal; // Longer side
37 
38 
39  TString outfile= "emc_module4_StraightGeo24.4.root";
40  TFile* fi = new TFile(outfile,"RECREATE");
41 
42  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
43  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
44  TString workDir = gSystem->Getenv("VMCWORKDIR");
45  workDir+="/geometry/media_pnd.geo";
46  geoFace->setMediaFile(workDir);
47  geoFace->readMedia();
48  geoFace->print();
49 
50  FairGeoMedia *Media = geoFace->getMedia();
51  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
52 
53  FairGeoMedium *CbmMediumAir = Media->getMedium("air");
54  FairGeoMedium *CbmMediumPWO = Media->getMedium("PWO");
55  FairGeoMedium *CbmMediumCarbon = Media->getMedium("carbon");
56  FairGeoMedium *CbmMediumAluminium = Media->getMedium("aluminium");
57 
58  Int_t nmed=geobuild->createMedium(CbmMediumAir);
59  nmed=geobuild->createMedium(CbmMediumPWO);
60  nmed=geobuild->createMedium(CbmMediumCarbon);
61  nmed=geobuild->createMedium(CbmMediumAluminium);
62 
63  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
64 
65  //construct the overall box
66  Double_t sizeOfQuar = 37.644; // size of one Quarter (the same in X and Y direction)
67 
68  TGeoVolume *top = new TGeoVolumeAssembly("Emc4");
69 
70  gGeoMan->SetTopVolume(top);
71 
72  TGeoTranslation trQuar;
73  TGeoTranslation trSub;
74  TGeoTranslation trBox;
75  TGeoTranslation trCrystal;
76 
77  TGeoRotation rotQuar;
78  TGeoRotation rotSub;
79  TGeoRotation rotBox;
80  TGeoRotation rotCrystal;
81 
82  TGeoShape* CrystalShape;
83  TGeoVolume* CrystalVol;
84 
85  TString name;
86 
87  // ========== QUARTER (14 subunits) ===================
88  TGeoVolume* QuarterVol = new TGeoVolumeAssembly("QuarterNewVol");
89 
90  // ========== SUBUNIT (up to 16 crystals) =============
91  TGeoVolume* SubunitVol = new TGeoVolumeAssembly("SubunitVol");
92  TGeoVolume* SubunitVol1 = new TGeoVolumeAssembly("SubunitVol1");
93  TGeoVolume* SubunitVol2 = new TGeoVolumeAssembly("SubunitVol2");
94  TGeoVolume* SubunitVol3 = new TGeoVolumeAssembly("SubunitVol3");
95  TGeoVolume* SubunitVol4 = new TGeoVolumeAssembly("SubunitVol4");
96  TGeoVolume* SubunitVol5 = new TGeoVolumeAssembly("SubunitVol5");
97  TGeoVolume* SubunitVol6 = new TGeoVolumeAssembly("SubunitVol6");
98  TGeoVolume* SubunitVol7 = new TGeoVolumeAssembly("SubunitVol7");
99  TGeoVolume* SubunitVol8 = new TGeoVolumeAssembly("SubunitVol8");
100  TGeoVolume* SubunitVol9 = new TGeoVolumeAssembly("SubunitVol9");
101 
102  // ========== BOX (up to 4 crystals) ==================
103  TGeoVolume* BoxVol = new TGeoVolumeAssembly("BoxVol");
104  TGeoVolume* BoxVol1 = new TGeoVolumeAssembly("BoxVol1");
105  TGeoVolume* BoxVol2 = new TGeoVolumeAssembly("BoxVol2");
106  TGeoVolume* BoxVol3 = new TGeoVolumeAssembly("BoxVol3");
107  TGeoVolume* BoxVol4 = new TGeoVolumeAssembly("BoxVol4");
108  TGeoVolume* BoxVol5 = new TGeoVolumeAssembly("BoxVol5");
109  TGeoVolume* BoxVol6 = new TGeoVolumeAssembly("BoxVol6");
110 
111  /*************************************************
112 
113  1. Add crystals into boxes
114  2. Add boxes into subunits
115  3. Add subunits into quarter
116  4. Add quarters into top
117 
118  *************************************************/
119 
120  // ********************************** //
121  // *** 1. Add crystals into boxes *** //
122  // ********************************** //
123  name = "CrystalShape";
124  CrystalShape = new TGeoBBox(name,0.5*kWidth,0.5*kHeight,0.5*kLength,0);
125 
126  TString medium="PWO";
127  name = "CrystalVol";
128  CrystalVol = new TGeoVolume(name,CrystalShape,gGeoMan->GetMedium(medium));
129 
130  // Translation and Rotation for each Crystal are according to
131  // co-ordinate system in the center of the Box.
132  // Crystals arrangement: right angle of each Crystal is in the middle of the box.
133  CrystalVol->SetLineColor(4);
134  for(Int_t k=0; k<kNumOfCrystals; k++){
135  cout << " " << endl;
136  cout << " -----> CRYSTAL number: "<< k << endl;
137  if (k==0){
138  trCrystal = TGeoTranslation(0.5*kSizeOfCrys + 0.5*kCrystalCrystal,0.5*kSizeOfCrys + 0.5*kCrystalCrystal,0.);
139  rotCrystal = TGeoRotation(); // "right-upper" Crystal
140  rotCrystal.RotateZ(0.);
141  }else if (k==1){
142  trCrystal= TGeoTranslation(-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,0.);
143  rotCrystal = TGeoRotation(); // "left-lower" Crystal
144  rotCrystal.RotateZ(180.);
145  }else if (k==2){
146  trCrystal= TGeoTranslation(-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,0.5*kSizeOfCrys + 0.5*kCrystalCrystal,0.);
147  rotCrystal = TGeoRotation(); // "left-upper" Crystal
148  rotCrystal.RotateZ(90.);
149  }else if (k==3){
150  trCrystal= TGeoTranslation(0.5*kSizeOfCrys + 0.5*kCrystalCrystal,-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,0.);
151  rotCrystal = TGeoRotation(); // "right-lower" Crystal
152  rotCrystal.RotateZ(270.);
153  }
154 
155  //cout << "name = " << name << " k = " << k << endl;
156 
157  BoxVol->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
158 
159  if (k==0) {
160  BoxVol4->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
161  BoxVol5->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
162  }
163  if (k==1) {
164  BoxVol1->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
165  BoxVol2->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
166  BoxVol3->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
167  BoxVol6->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
168  }
169  if (k==2) {
170  BoxVol3->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
171  BoxVol4->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
172  BoxVol6->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
173  }
174  if (k==3) {
175  BoxVol1->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
176  BoxVol3->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
177  BoxVol5->AddNode(CrystalVol,k,new TGeoCombiTrans(trCrystal,rotCrystal));
178  }
179  }
180 
181  // ********************************** //
182  // *** 2. Add boxes into subunits *** //
183  // ********************************** //
184  for(Int_t b=0; b<kNumOfBoxes; b++){
185  cout << "*** BOX number: " << b <<endl;
186  if (b==0) {
187  trBox = TGeoTranslation(kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
188  kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
189  0.);
190  }
191  if (b==1) {
192  trBox = TGeoTranslation(-kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
193  -kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
194  0.);
195  }
196  if (b==2) {
197  trBox = TGeoTranslation(kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
198  -kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
199  0.);
200  }
201  if (b==3) {
202  trBox = TGeoTranslation(-kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
203  kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
204  0.);
205  }
206 
207  rotBox = TGeoRotation();
208  rotBox.RotateX(0.); // rotation in "up" direction
209  rotBox.RotateY(0.); // rotation in "right" direction
210 
211  SubunitVol->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
212 
213  //differentc conditions: depends on combination of crystals in Box
214  if (b==0){
215  SubunitVol1->AddNode(BoxVol1,b,new TGeoCombiTrans(trBox,rotBox));
216  SubunitVol4->AddNode(BoxVol2,b,new TGeoCombiTrans(trBox,rotBox));
217  SubunitVol6->AddNode(BoxVol6,b,new TGeoCombiTrans(trBox,rotBox));
218  SubunitVol7->AddNode(BoxVol4,b,new TGeoCombiTrans(trBox,rotBox));
219  SubunitVol8->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
220  SubunitVol9->AddNode(BoxVol5,b,new TGeoCombiTrans(trBox,rotBox));
221  }
222  if (b==1){
223  SubunitVol1->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
224  SubunitVol2->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
225  SubunitVol3->AddNode(BoxVol2,b,new TGeoCombiTrans(trBox,rotBox));
226  SubunitVol4->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
227  SubunitVol5->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
228  SubunitVol6->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
229  }
230  if (b==2){
231  SubunitVol1->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
232  SubunitVol2->AddNode(BoxVol3,b,new TGeoCombiTrans(trBox,rotBox));
233  SubunitVol4->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
234  SubunitVol5->AddNode(BoxVol2,b,new TGeoCombiTrans(trBox,rotBox));
235  SubunitVol6->AddNode(BoxVol6,b,new TGeoCombiTrans(trBox,rotBox));
236  SubunitVol8->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
237  }
238  if (b==3){
239  SubunitVol1->AddNode(BoxVol1,b,new TGeoCombiTrans(trBox,rotBox));
240  SubunitVol2->AddNode(BoxVol2,b,new TGeoCombiTrans(trBox,rotBox));
241  SubunitVol4->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
242  SubunitVol5->AddNode(BoxVol3,b,new TGeoCombiTrans(trBox,rotBox));
243  SubunitVol6->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
244  SubunitVol8->AddNode(BoxVol,b,new TGeoCombiTrans(trBox,rotBox));
245  }
246  }
247 
248  // ************************************ //
249  // *** 3. Add subunits into quarter *** //
250  // ************************************ //
251  Int_t jj = 0;
252  for (Int_t row=0; row<4; row++){
253  for (Int_t col=0; col<4; col++){
254  Int_t flag=1;
255 
256  // *** 2 Subunits are fully disables
257  if (row==3 && col==3) flag=0; // outer
258  if (row==0 && col==0) flag=0; // inner
259 
260  // *** Subunits with disabled crystals
261  if (row==0 && col==1) flag=-1; // middle subunit
262  if (row==0 && col==3) flag=-2; // here: row==column => 1st col, 4th Subunit (top)
263  if (row==1 && col==0) flag=-3; // here: row==column => 1st col, 4th Subunit (top)
264  if (row==1 && col==1) flag=-4; // here: row==column => 2st col, 4th Subunit (top)
265  if (row==1 && col==3) flag=-5; // here: row==column => 3st col, 3rd Subunit
266  if (row==2 && col==2) flag=-6; // here: row==column => 4st col, 1st Subunit
267  if (row==2 && col==3) flag=-7; // here: row==column => 4st col, 2st Subunit
268  if (row==3 && col==0) flag=-8; // here: row==column => 3st col, 3rd Subunit
269  if (row==3 && col==1) flag=-9; // here: row==column => 4st col, 1st Subunit
270  if (row==3 && col==2) flag=-10; // here: row==column => 4st col, 2st Subunit
271 
272  Double_t ShiftX = row*(sizeOfSubunit + kAlveoleAlveole) + 0.5*sizeOfSubunit + 0.5*kAlveoleAlveole;// - 2*sizeOfSubunit - 2*kAlveoleAlveole;
273  Double_t ShiftY = col*(sizeOfSubunit + kAlveoleAlveole) + 0.5*sizeOfSubunit + 0.5*kAlveoleAlveole;// - 2*sizeOfSubunit - 2*kAlveoleAlveole;
274 
275  trSub = TGeoTranslation(ShiftX, ShiftY, 0.);
276 
277  //cout << "flag = " << flag << " jj = " << jj << endl;
278 
279  if (flag==1){jj++;
280  QuarterVol->AddNode(SubunitVol,jj,new TGeoCombiTrans(trSub,rotSub));
281  }
282  else if (flag==-1){jj++;
283  QuarterVol->AddNode(SubunitVol7,jj,new TGeoCombiTrans(trSub,rotSub));
284  }
285  else if (flag==-2){jj++;
286  QuarterVol->AddNode(SubunitVol1,jj,new TGeoCombiTrans(trSub,rotSub));
287  }
288  else if (flag==-3){jj++;
289  QuarterVol->AddNode(SubunitVol9,jj,new TGeoCombiTrans(trSub,rotSub));
290  }
291  else if (flag==-4){jj++;
292  QuarterVol->AddNode(SubunitVol8,jj,new TGeoCombiTrans(trSub,rotSub));
293  }
294  else if (flag==-5){jj++;
295  QuarterVol->AddNode(SubunitVol2,jj,new TGeoCombiTrans(trSub,rotSub));
296  }
297  else if (flag==-6){jj++;
298  QuarterVol->AddNode(SubunitVol4,jj,new TGeoCombiTrans(trSub,rotSub));
299  }
300  else if (flag==-7){jj++;
301  QuarterVol->AddNode(SubunitVol3,jj,new TGeoCombiTrans(trSub,rotSub));
302  }
303  else if (flag==-8){jj++;
304  QuarterVol->AddNode(SubunitVol6,jj,new TGeoCombiTrans(trSub,rotSub));
305  }
306  else if (flag==-9){jj++;
307  QuarterVol->AddNode(SubunitVol5,jj,new TGeoCombiTrans(trSub,rotSub));
308  }
309  else if (flag==-10){jj++;
310  QuarterVol->AddNode(SubunitVol3,jj,new TGeoCombiTrans(trSub,rotSub));
311  }
312  }
313  }
314 
315  // ******************************* //
316  // ***4. Add quarters into top *** //
317  // ******************************* //
318  TGeoCombiTrans reflection;
319  trQuar = TGeoTranslation(0.,0.,0.);
320 
321  for (Int_t q=1; q<=4; q++){
322  if (q==1){ // first copy: -X +Y
323  reflection.ReflectX(1);
324  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
325  }
326  if (q==2){ // second copy: -X -Y
327  reflection.ReflectX(1);
328  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
329  }
330  if (q==3){ // third copy: +X -Y
331  reflection.ReflectX(1);
332  reflection.ReflectY(1);
333  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
334  }
335  if (q==4){ // fourth copy: +X +Y
336  reflection.ReflectX(1);
337  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
338  }
339  }
340 
341  gGeoMan->CloseGeometry();
342  // *** Check for overlaps
343  cout << "********************************** \n";
344  cout << "*** Checking overlaps for Emc4 *** \n";
345  cout << "********************************** \n";
346  gGeoMan->CheckOverlaps(0.001);
347  /*cout << "********************************** \n";
348  cout << "*** Checking FULLGeom for Emc4 *** \n";
349  cout << "********************************** \n";
350  gGeoMan->CheckGeometryFull();
351  cout << "********************************** \n";*/
352 
353 
354  top->Write();
355  fi->Close();
356 
357  /*gGeoManager->Export(outfile);
358  top->Draw();
359  gGeoManager->SetVisLevel(10);*/
360  return 0;
361 }
int row
Definition: anaLmdDigi.C:67
TGeoVolume * SubunitVol6
TGeoVolume * QuarterVol
TGeoVolume * BoxVol3
FairGeoLoader * geoLoad
const Double_t kAlveoleAlveole
FairGeoMedia * Media
TTree * b
const Int_t kNumOfBoxes1
TGeoShape * CrystalShape
const Double_t kGluedAlveoleThickness
const Double_t kHeight
TGeoTranslation trCrystal
TGeoManager * gGeoMan
FairGeoMedium * CbmMediumCarbon
TGeoVolume * BoxVol5
TGeoVolume * SubunitVol5
int col
Definition: anaLmdDigi.C:67
const Double_t kSizeOfCrys
TGeoTranslation trSub
Double_t sizeOfBox4
const Double_t kCrystalCrystal
TGeoVolume * SubunitVol8
TGeoVolume * top
FairGeoMedium * CbmMediumAluminium
TGeoTranslation trQuar
TGeoVolume * SubunitVol
TGeoVolume * BoxVol1
TGeoRotation rotBox
FairGeoBuilder * geobuild
TFile * fi
Double_t
TString medium
TGeoCombiTrans reflection
TGeoVolume * BoxVol4
TGeoVolume * BoxVol
const Double_t kLength
TGeoRotation rotQuar
TGeoVolume * SubunitVol2
Double_t sizeOfBox1
const Int_t kNumOfBoxes4InSubunit
TString name
FairGeoMedium * CbmMediumAir
const Double_t kAlveoleThickness
TGeoVolume * CrystalVol
TGeoVolume * SubunitVol7
TGeoRotation rotCrystal
const Int_t kNumOfCrystalsInBox2
TGeoVolume * SubunitVol4
TGeoVolume * SubunitVol9
TGeoRotation rotSub
Double_t sizeOfBox2
const Int_t kNumOfBoxes4
TGeoVolume * BoxVol2
TGeoVolume * BoxVol6
FairGeoMedium * CbmMediumPWO
const Int_t kNumOfBoxes2
Double_t sizeOfSubunit
FairGeoInterface * geoFace
const Int_t kNumOfSubunit
TGeoTranslation trBox
TGeoVolume * SubunitVol3
const Double_t kCrystalAlveole
const Int_t kNumOfCrystalsInBox4
const Int_t kNumOfBoxes
const Int_t kNumOfCrystals
TString outfile
TGeoVolume * SubunitVol1
const Int_t kNumOfQuarters