FairRoot/PandaRoot
createRootGeoFileBwEnd_Str24.4_fixed.C
Go to the documentation of this file.
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  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
40 
41  // Load this example libraries
42  gSystem->Load("libGeoBase");
43  gSystem->Load("libParBase");
44  gSystem->Load("libBase");
45  gSystem->Load("libPndData");
46  gSystem->Load("libPassive");
47 
48  TString outfile= "./emc_module4_StraightGeo24.4.root";
49  TFile* fi = new TFile(outfile,"RECREATE");
50 
51  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
52  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
53  geoFace->setMediaFile("/home/dkhaneft/PANDA/pandaroot/trunk_25544/geometry/media_pnd.geo");
54  geoFace->readMedia();
55  geoFace->print();
56 
57  FairGeoMedia *Media = geoFace->getMedia();
58  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
59 
60  FairGeoMedium *CbmMediumAir = Media->getMedium("air");
61  FairGeoMedium *CbmMediumPWO = Media->getMedium("PWO");
62  FairGeoMedium *CbmMediumCarbon = Media->getMedium("carbon");
63  FairGeoMedium *CbmMediumAluminium = Media->getMedium("aluminium");
64 
65  Int_t nmed=geobuild->createMedium(CbmMediumAir);
66  nmed=geobuild->createMedium(CbmMediumPWO);
67  nmed=geobuild->createMedium(CbmMediumCarbon);
68  nmed=geobuild->createMedium(CbmMediumAluminium);
69 
70  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
71 
72  //construct the overall box
73  Double_t sizeOfQuar = 37.644; // size of one Quarter (the same in X and Y direction)
74 
75  TGeoVolume *top = new TGeoVolumeAssembly("Emc4");
76 
77  gGeoMan->SetTopVolume(top);
78 
79  TGeoTranslation trQuar;
80  TGeoTranslation trSub;
81  TGeoTranslation trBox;
82  TGeoTranslation trCrystal;
83 
84  TGeoRotation rotQuar;
85  TGeoRotation rotSub;
86  TGeoRotation rotBox;
87  TGeoRotation rotCrystal;
88 
89  TGeoShape* CrystalShape;
90  TGeoVolume* CrystalVol;
91 
93 
94  // ========== QUARTER (14 subunits) ===================
95  TGeoVolume* QuarterVol = new TGeoVolumeAssembly("QuarterNewVol");
96 
97  // ========== SUBUNIT (up to 16 crystals) =============
98  TGeoVolume* SubunitVol = new TGeoVolumeAssembly("SubunitVol");
99  TGeoVolume* SubunitVol1 = new TGeoVolumeAssembly("SubunitVol1");
100  TGeoVolume* SubunitVol2 = new TGeoVolumeAssembly("SubunitVol2");
101  TGeoVolume* SubunitVol3 = new TGeoVolumeAssembly("SubunitVol3");
102  TGeoVolume* SubunitVol4 = new TGeoVolumeAssembly("SubunitVol4");
103  TGeoVolume* SubunitVol5 = new TGeoVolumeAssembly("SubunitVol5");
104  TGeoVolume* SubunitVol6 = new TGeoVolumeAssembly("SubunitVol6");
105  TGeoVolume* SubunitVol7 = new TGeoVolumeAssembly("SubunitVol7");
106  TGeoVolume* SubunitVol8 = new TGeoVolumeAssembly("SubunitVol8");
107  TGeoVolume* SubunitVol9 = new TGeoVolumeAssembly("SubunitVol9");
108 
109  // ========== BOX (up to 4 crystals) ==================
110  TGeoVolume* BoxVol = new TGeoVolumeAssembly("BoxVol");
111  TGeoVolume* BoxVol1 = new TGeoVolumeAssembly("BoxVol1");
112  TGeoVolume* BoxVol2 = new TGeoVolumeAssembly("BoxVol2");
113  TGeoVolume* BoxVol3 = new TGeoVolumeAssembly("BoxVol3");
114  TGeoVolume* BoxVol4 = new TGeoVolumeAssembly("BoxVol4");
115  TGeoVolume* BoxVol5 = new TGeoVolumeAssembly("BoxVol5");
116  TGeoVolume* BoxVol6 = new TGeoVolumeAssembly("BoxVol6");
117 
118  /*************************************************
119 
120  1. Add crystals into boxes
121  2. Add boxes into subunits
122  3. Add subunits into quarter
123  4. Add quarters into top
124 
125  *************************************************/
126 
127  // ********************************** //
128  // *** 1. Add crystals into boxes *** //
129  // ********************************** //
130  name = "CrystalShape";
131  CrystalShape = new TGeoBBox(name,0.5*kWidth,0.5*kHeight,0.5*kLength,0);
132 
134  name = "CrystalVol";
135  CrystalVol = new TGeoVolume(name,CrystalShape,gGeoMan->GetMedium(medium));
136 
137  // Translation and Rotation for each Crystal are according to
138  // co-ordinate system in the center of the Box.
139  // Crystals arrangement: right angle of each Crystal is in the middle of the box.
140  CrystalVol->SetLineColor(4);
141  for(Int_t k=0; k<kNumOfCrystals; k++){
142  cout << " " << endl;
143  cout << " -----> CRYSTAL number: "<< k << endl;
144  if (k==0){
145  trCrystal = new TGeoTranslation(0.5*kSizeOfCrys + 0.5*kCrystalCrystal,0.5*kSizeOfCrys + 0.5*kCrystalCrystal,0.);
146  rotCrystal = new TGeoRotation(); // "right-upper" Crystal
147  rotCrystal.RotateZ(0.);
148  }else if (k==1){
149  trCrystal= new TGeoTranslation(-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,0.);
150  rotCrystal = new TGeoRotation(); // "left-lower" Crystal
151  rotCrystal.RotateZ(180.);
152  }else if (k==2){
153  trCrystal= new TGeoTranslation(-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,0.5*kSizeOfCrys + 0.5*kCrystalCrystal,0.);
154  rotCrystal = new TGeoRotation(); // "left-upper" Crystal
155  rotCrystal.RotateZ(90.);
156  }else if (k==3){
157  trCrystal= new TGeoTranslation(0.5*kSizeOfCrys + 0.5*kCrystalCrystal,-0.5*kSizeOfCrys - 0.5*kCrystalCrystal,0.);
158  rotCrystal = new TGeoRotation(); // "right-lower" Crystal
159  rotCrystal.RotateZ(270.);
160  }
161 
162  TGeoCombiTrans* trrotCrystal= new TGeoCombiTrans(trCrystal,rotCrystal);
163 
164  name = "CrystalVol";
165  name+=k;
166  trrotCrystal->SetName(name);
167  trrotCrystal->RegisterYourself();
168 
169  //cout << "name = " << name << " k = " << k << endl;
170 
171  BoxVol->AddNode(CrystalVol,k,trrotCrystal);
172 
173  if (k==0) {
174  name+=k;
175  trrotCrystal->SetName(name);
176  trrotCrystal->RegisterYourself();
177 cout << "name = " << name << " k = " << k << endl;
178  BoxVol4->AddNode(CrystalVol,k,trrotCrystal);
179  BoxVol5->AddNode(CrystalVol,k,trrotCrystal);
180  }
181  if (k==1) {
182  name+=k;
183  trrotCrystal->SetName(name);
184  trrotCrystal->RegisterYourself();
185 cout << "name = " << name << " k = " << k << endl;
186  BoxVol1->AddNode(CrystalVol,k,trrotCrystal);
187  BoxVol2->AddNode(CrystalVol,k,trrotCrystal);
188  BoxVol3->AddNode(CrystalVol,k,trrotCrystal);
189  BoxVol6->AddNode(CrystalVol,k,trrotCrystal);
190  }
191  if (k==2) {
192  name+=k;
193  trrotCrystal->SetName(name);
194  trrotCrystal->RegisterYourself();
195 cout << "name = " << name << " k = " << k << endl;
196  BoxVol3->AddNode(CrystalVol,k,trrotCrystal);
197  BoxVol4->AddNode(CrystalVol,k,trrotCrystal);
198  BoxVol6->AddNode(CrystalVol,k,trrotCrystal);
199  }
200  if (k==3) {
201  name+=k;
202  trrotCrystal->SetName(name);
203  trrotCrystal->RegisterYourself();
204 cout << "name = " << name << " k = " << k << endl;
205  BoxVol1->AddNode(CrystalVol,k,trrotCrystal);
206  BoxVol3->AddNode(CrystalVol,k,trrotCrystal);
207  BoxVol5->AddNode(CrystalVol,k,trrotCrystal);
208  }
209  }
210 
211  // ********************************** //
212  // *** 2. Add boxes into subunits *** //
213  // ********************************** //
214  for(Int_t b=0; b<kNumOfBoxes; b++){
215  cout << "*** BOX number: " << b <<endl;
216  if (b==0) {
217  trBox = new TGeoTranslation(kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
218  kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
219  0.);
220  }
221  if (b==1) {
222  trBox = new TGeoTranslation(-kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
223  -kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
224  0.);
225  }
226  if (b==2) {
227  trBox = new TGeoTranslation(kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
228  -kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
229  0.);
230  }
231  if (b==3) {
232  trBox = new TGeoTranslation(-kSizeOfCrys - kAlveoleThickness - 0.5*kCrystalCrystal - kCrystalAlveole,
233  kSizeOfCrys + kAlveoleThickness + 0.5*kCrystalCrystal + kCrystalAlveole,
234  0.);
235  }
236 
237  rotBox = new TGeoRotation();
238  rotBox.RotateX(0.); // rotation in "up" direction
239  rotBox.RotateY(0.); // rotation in "right" direction
240 
241  TGeoCombiTrans* trrotBox= new TGeoCombiTrans(trBox,rotBox);
242 
243  name="BoxVol";
244 
245  name+=b;
246  trrotBox->SetName(name);
247  trrotBox->RegisterYourself();
248 
249  SubunitVol->AddNode(BoxVol,b,trrotBox);
250 
251  //differentc conditions: depends on combination of crystals in Box
252  if (b==0){
253  name+=b;
254  trrotBox->SetName(name);
255  trrotBox->RegisterYourself();
256 
257  SubunitVol1->AddNode(BoxVol1,b,trrotBox);
258  SubunitVol4->AddNode(BoxVol2,b,trrotBox);
259  SubunitVol6->AddNode(BoxVol6,b,trrotBox);
260  SubunitVol7->AddNode(BoxVol4,b,trrotBox);
261  SubunitVol8->AddNode(BoxVol,b,trrotBox);
262  SubunitVol9->AddNode(BoxVol5,b,trrotBox);
263  }
264  if (b==1){
265  name+=b;
266  trrotBox->SetName(name);
267  trrotBox->RegisterYourself();
268 
269  SubunitVol1->AddNode(BoxVol,b,trrotBox);
270  SubunitVol2->AddNode(BoxVol,b,trrotBox);
271  SubunitVol3->AddNode(BoxVol2,b,trrotBox);
272  SubunitVol4->AddNode(BoxVol,b,trrotBox);
273  SubunitVol5->AddNode(BoxVol,b,trrotBox);
274  SubunitVol6->AddNode(BoxVol,b,trrotBox);
275  }
276  if (b==2){
277  name+=b;
278  trrotBox->SetName(name);
279  trrotBox->RegisterYourself();
280 
281  SubunitVol1->AddNode(BoxVol,b,trrotBox);
282  SubunitVol2->AddNode(BoxVol3,b,trrotBox);
283  SubunitVol4->AddNode(BoxVol,b,trrotBox);
284  SubunitVol5->AddNode(BoxVol2,b,trrotBox);
285  SubunitVol6->AddNode(BoxVol6,b,trrotBox);
286  SubunitVol8->AddNode(BoxVol,b,trrotBox);
287  }
288  if (b==3){
289  name+=b;
290  trrotBox->SetName(name);
291  trrotBox->RegisterYourself();
292 
293  SubunitVol1->AddNode(BoxVol1,b,trrotBox);
294  SubunitVol2->AddNode(BoxVol2,b,trrotBox);
295  SubunitVol4->AddNode(BoxVol,b,trrotBox);
296  SubunitVol5->AddNode(BoxVol3,b,trrotBox);
297  SubunitVol6->AddNode(BoxVol,b,trrotBox);
298  SubunitVol8->AddNode(BoxVol,b,trrotBox);
299  }
300  }
301 
302  // ************************************ //
303  // *** 3. Add subunits into quarter *** //
304  // ************************************ //
305  Int_t jj = 0;
306  for (Int_t row=0; row<4; row++){
307  for (Int_t col=0; col<4; col++){
308  Int_t flag=1;
309 
310  // *** 2 Subunits are fully disables
311  if (row==3 && col==3) flag=0; // outer
312  if (row==0 && col==0) flag=0; // inner
313 
314  // *** Subunits with disabled crystals
315  if (row==0 && col==1) flag=-1; // middle subunit
316  if (row==0 && col==3) flag=-2; // here: row==column => 1st col, 4th Subunit (top)
317  if (row==1 && col==0) flag=-3; // here: row==column => 1st col, 4th Subunit (top)
318  if (row==1 && col==1) flag=-4; // here: row==column => 2st col, 4th Subunit (top)
319  if (row==1 && col==3) flag=-5; // here: row==column => 3st col, 3rd Subunit
320  if (row==2 && col==2) flag=-6; // here: row==column => 4st col, 1st Subunit
321  if (row==2 && col==3) flag=-7; // here: row==column => 4st col, 2st Subunit
322  if (row==3 && col==0) flag=-8; // here: row==column => 3st col, 3rd Subunit
323  if (row==3 && col==1) flag=-9; // here: row==column => 4st col, 1st Subunit
324  if (row==3 && col==2) flag=-10; // here: row==column => 4st col, 2st Subunit
325 
326  Double_t ShiftX = row*(sizeOfSubunit + kAlveoleAlveole) + 0.5*sizeOfSubunit + 0.5*kAlveoleAlveole;// - 2*sizeOfSubunit - 2*kAlveoleAlveole;
327  Double_t ShiftY = col*(sizeOfSubunit + kAlveoleAlveole) + 0.5*sizeOfSubunit + 0.5*kAlveoleAlveole;// - 2*sizeOfSubunit - 2*kAlveoleAlveole;
328 
329  trSub = new TGeoTranslation(ShiftX, ShiftY, 0.);
330 
331  TGeoCombiTrans* thAngle= new TGeoCombiTrans(trSub,rotSub);
332 
333  //cout << "flag = " << flag << " jj = " << jj << endl;
334 
335  if (flag==1){jj++;
336  QuarterVol->AddNode(SubunitVol,jj,thAngle);
337  }
338  else if (flag==-1){jj++;
339  QuarterVol->AddNode(SubunitVol7,jj,thAngle);
340  }
341  else if (flag==-2){jj++;
342  QuarterVol->AddNode(SubunitVol1,jj,thAngle);
343  }
344  else if (flag==-3){jj++;
345  QuarterVol->AddNode(SubunitVol9,jj,thAngle);
346  }
347  else if (flag==-4){jj++;
348  QuarterVol->AddNode(SubunitVol8,jj,thAngle);
349  }
350  else if (flag==-5){jj++;
351  QuarterVol->AddNode(SubunitVol2,jj,thAngle);
352  }
353  else if (flag==-6){jj++;
354  QuarterVol->AddNode(SubunitVol4,jj,thAngle);
355  }
356  else if (flag==-7){jj++;
357  QuarterVol->AddNode(SubunitVol3,jj,thAngle);
358  }
359  else if (flag==-8){jj++;
360  QuarterVol->AddNode(SubunitVol6,jj,thAngle);
361  }
362  else if (flag==-9){jj++;
363  QuarterVol->AddNode(SubunitVol5,jj,thAngle);
364  }
365  else if (flag==-10){jj++;
366  QuarterVol->AddNode(SubunitVol3,jj,thAngle);
367  }
368  }
369  }
370 
371  // ******************************* //
372  // ***4. Add quarters into top *** //
373  // ******************************* //
374  TGeoCombiTrans reflection;
375  trQuar = new TGeoTranslation(0.,0.,0.);
376 
377  for (Int_t q=1; q<=4; q++){
378  if (q==1){ // first copy: -X +Y
379  reflection.ReflectX(1);
380  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
381  }
382  if (q==2){ // second copy: -X -Y
383  reflection.ReflectX(1);
384  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
385  }
386  if (q==3){ // third copy: +X -Y
387  reflection.ReflectX(1);
388  reflection.ReflectY(1);
389  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
390  }
391  if (q==4){ // fourth copy: +X +Y
392  reflection.ReflectX(1);
393  top->AddNode(QuarterVol,q,new TGeoCombiTrans(trQuar,reflection) );
394  }
395  }
396 
397  // *** Check for overlaps
398  cout << "********************************** \n";
399  cout << "*** Checking overlaps for Emc4 *** \n";
400  cout << "********************************** \n";
401  gGeoMan->CheckOverlaps(0.001);
402  /*cout << "********************************** \n";
403  cout << "*** Checking FULLGeom for Emc4 *** \n";
404  cout << "********************************** \n";
405  gGeoMan->CheckGeometryFull();
406  cout << "********************************** \n";*/
407 
408  gGeoMan->CloseGeometry();
409  top->Write();
410  fi->Close();
411 
412  /*gGeoManager->Export(outfile);
413  top->Draw();
414  gGeoManager->SetVisLevel(10);*/
415 }
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