FairRoot/PandaRoot
createRootGeoFileFwEnd_changed.C
Go to the documentation of this file.
1 {
2  // FwEndCap geometry parameters
3  //-----------------------------
4  const Double_t kSpaceInBox = 0.06; // Space in Box (cm)
5  const Double_t kSpaceInSub = 0.024; // Space in Subunit (cm)
6  const Double_t kSpaceSubGlue = 0.036; // Thickness of glued alveole
7  // between Boxes in Subunit (cm)
8  const Double_t kAlveoleThickness = 0.018;// Thickness of alveole between Subunits (cm)
9 
10  const Int_t kNumOfQuarters = 1;
11  const Int_t kNumOfBoxes = 4;
12  const Int_t kNumOfCrystals = 4;
13 
14  Double_t tr = 2.51875; // Size of the Crystal in its center (cm)
15 
16  Double_t b1 = 2.6000-0.5*tr; // Back-tilted part (-Z direction) of the Crystal center (cm)
17  Double_t b2 = 2.4375-0.5*tr; // Front-tilted part (+Z direction) of the Crystal center (cm)
18 
19  Double_t dz,vert[20]; // Parameters for TGeoArb8 shape of crystal (cm)
21 
22  // Parameters for crystal shape: front size: 24.375(mm) x 24.375(mm)
23  // back size: 26.0(mm) x 26.0(mm)
24  dz = 10.000;
25  // first four vertices - in -Z direction
26  vert[0] = -0.5*tr;
27  vert[1] = -0.5*tr;
28  vert[2] = -0.5*tr;
29  vert[3] = +b1;
30  vert[4] = +b1;
31  vert[5] = +b1;
32  vert[6] = +b1;
33  vert[7] = -0.5*tr;
34 
35  // second four vertices - in +Z direction
36  vert[8] = -0.5*tr;
37  vert[9] = -0.5*tr;
38  vert[10] = -0.5*tr;
39  vert[11] = +b2;
40  vert[12] = +b2; // Tapered right side the front face
41  vert[13] = +b2; // of the crystal (upper corner)
42  vert[14] = +b2; // Tapered right side the front face
43  vert[15] = -0.5*tr; // of the crystal (lower corner)
44 
45  // Box size (4 crystals) - creation a SIZE for BOX shape
46  for (Int_t i=0; i< 16; i++){
47  Double_t spaces = 0.5*kSpaceInBox + kSpaceInSub;
48  if (i==0 || i==1)
49  {
50  vertBox[i] = (-vert[3] - spaces); // lower-left corner back-side
51  }
52  else if (i==8 || i==9)
53  {
54  vertBox[i] = (-vert[11] - spaces); // lower-left corner front-side
55  }
56  else if (i==7 || i==15)
57  {
58  vertBox[i] = (-vert[i-1] - spaces); // lower-right points (front & back sides)
59  }
60  else if (i==2 || i==10) // upper-left points (front & back sides)
61  {
62  vertBox[i] = (-vert[i+1] - spaces);
63  }
64  else
65  {
66  vertBox[i] = (vert[i] + spaces); // rest of those points
67  }
68  }
69 
70  // Subunit size (16 crystals, 4 boxes) - creation a SIZE for SUBUNIT shape
71  for (Int_t i=0; i< 16; i++){
72  Double_t spacesSub = 0.5*kSpaceSubGlue + kAlveoleThickness;
73  if (i==0 || i==1)
74  {
75  vertSub[i] = (vertBox[i]*2 - spacesSub); // lower-left corner back-side
76  }
77  else if (i==8 || i==9)
78  {
79  vertSub[i] = (vertBox[i]*2 - spacesSub); // lower-left corner front-side
80  }
81  else if (i==7 || i==15)
82  {
83  vertSub[i] = (vertBox[i]*2 - spacesSub);
84  }
85  else if (i==2 || i==10)
86  {
87  vertSub[i] = (vertBox[i]*2 - spacesSub);
88  }
89  else
90  {
91  vertSub[i] = (vertBox[i]*2 + spacesSub);
92  }
93  }
94 
95  // Quarter size (Max is: 9X9 Subunits)
97  for (Int_t i=0; i< 16; i++){
98  if (i==0 || i==1)
99  {
100  vertQuar[i] = (vertSub[i]*9 - spacesQuar); // lower-left corner back-side
101  }
102  else if (i==8 || i==9)
103  {
104  vertQuar[i] = (vertSub[i]*9 - spacesQuar); // lower-left corner front-side
105  }
106  else if (i==7 || i==15)
107  {
108  vertQuar[i] = (vertSub[i]*9 - spacesSub);
109  }
110  else if (i==2 || i==10)
111  {
112  vertQuar[i] = (vertSub[i]*9 - spacesQuar);
113  }
114  else
115  {
116  vertQuar[i] = (vertSub[i]*9 + spacesQuar);
117  }
118  }
119 
120  //--------------------------------------------------------------------
121  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
122 
123  // Load this example libraries
124  gSystem->Load("libGeoBase");
125  gSystem->Load("libParBase");
126  gSystem->Load("libBase");
127  gSystem->Load("libPndData");
128  gSystem->Load("libPassive");
129 
130  TString outfile= "../../geometry/emc_module3new.root";
131  TFile* fi = new TFile(outfile,"RECREATE");
132 
133  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
134  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
135  geoFace->setMediaFile("../../geometry/media_pnd.geo");
136  geoFace->readMedia();
137  geoFace->print();
138 
139  FairGeoMedia *Media = geoFace->getMedia();
140  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
141 
142  FairGeoMedium *CbmMediumAir = Media->getMedium("air");
143  FairGeoMedium *CbmMediumPWO = Media->getMedium("PWO");
144  FairGeoMedium *CbmMediumCarbon = Media->getMedium("carbon");
145  FairGeoMedium *CbmMediumAluminium = Media->getMedium("aluminium");
146 
147  Int_t nmed=geobuild->createMedium(CbmMediumAir);
148  nmed=geobuild->createMedium(CbmMediumPWO);
149  nmed=geobuild->createMedium(CbmMediumCarbon);
150  nmed=geobuild->createMedium(CbmMediumAluminium);
151 
152  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
153 
154  //construct the overall box
155  Double_t sizeOfQuar = 96.192; // size of one Quarter (the same in X and Y direction)
156  // size of one Subunit (back side): 10.688*9 = 96.192 (cm)
157 // TGeoVolume *top = gGeoMan->MakeTube("top",gGeoMan->GetMedium("air"),0,98,22.5);//cm
158 
159  TGeoVolume *top = new TGeoVolumeAssembly("Emc3");
160 
161  gGeoMan->SetTopVolume(top);
162 
163  TGeoTranslation trQuar;
164  TGeoTranslation trSub;
165  TGeoTranslation trBox;
166  TGeoTranslation trCrystal;
167 
168  TGeoRotation rotQuar;
169  TGeoRotation rotSub;
170  TGeoRotation rotBox;
171  TGeoRotation rotCrystal;
172 
173  TGeoShape* QuarterShape;
174  TGeoShape* SubunitShape;
175  TGeoShape* BoxShape;
176  TGeoShape* CrystalShape;
177 
178  TGeoVolume* QuarterVol;
179  TGeoVolume* SubunitVol;
180  TGeoVolume* BoxVol;
181  TGeoVolume* CrystalVol;
182 
184 
185  // ========== QUARTER (55 subunits) ===================
186  cout<< "-----------------------------------------------> Quarter VOLUME " <<endl;
187  name = "QuarterShape";
188  QuarterShape = new TGeoArb8(name,dz,vertQuar);
189 
190  name = "QuarterVol";
191  TString medium="air";
192 
193 // QuarterVol = new TGeoVolume(name,QuarterShape,gGeoMan->GetMedium(medium));
194  QuarterVol = new TGeoVolumeAssembly(name);
195 
196  cout << "Quarter Medium ==== "<< gGeoMan->GetMedium(medium)->GetName()<< endl;
197 
198  // ========== SUBUNIT (16 crystals) ===================
199  name = "SubunitShape";
200  SubunitShape = new TGeoArb8(name,dz,vertSub);
201 
202  //TString medium="carbon";
203  TString medium="air";
204  name = "SubunitVol";
205  // SubunitVol = new TGeoVolume(name,SubunitShape,gGeoMan->GetMedium(medium));
206  SubunitVol = new TGeoVolumeAssembly(name);
207 
208  // ========== BOX (4 crystals) ========================
209  name = "BoxShape";
210  BoxShape = new TGeoArb8(name,dz,vertBox);
211 
212  //TString medium="carbon";
213  TString medium="air";
214  name="BoxVol";
215  //BoxVol = new TGeoVolume(name,BoxShape,gGeoMan->GetMedium(medium));
216  BoxVol = new TGeoVolumeAssembly(name);
217 
218  // Translations and Rotations for Boxes are according to co-ordinate system
219  // which is in the center of the Subunit
220  for(Int_t b=0; b<kNumOfBoxes; b++){
221  cout << " " << endl;
222  cout << "----------------> BOX number: " << b <<endl;
223  if (b==0) {
224  trBox = new TGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox, 0.);
225  rotBox = new TGeoRotation();
226  rotBox.RotateX(0.465518); // rotation in "up" direction
227  rotBox.RotateY(-0.465518); // rotation in "right" direction
228  }
229  if (b==1) {
230  trBox = new TGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox, 0.);
231  rotBox = new TGeoRotation();
232  rotBox.RotateX(-0.465518); // rotation in "down" direction
233  rotBox.RotateY(0.465518); // rotation in "left" direction
234  }
235  if (b==2) {
236  trBox = new TGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox, 0.);
237  rotBox = new TGeoRotation();
238  rotBox.RotateX(-0.465518); // rotation in "down" direction
239  rotBox.RotateY(-0.465518); // rotation in "right" direction
240  }
241  if (b==3) {
242  trBox = new TGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox, 0.);
243  rotBox = new TGeoRotation();
244  rotBox.RotateX(0.465518); // rotation in "up" direction
245  rotBox.RotateY(0.465518); // rotation in "left" direction
246  }
247  TGeoCombiTrans* trrotBox= new TGeoCombiTrans(trBox,rotBox);
248 
249  name="BoxVol";
250  name+=b;
251  trrotBox->SetName(name);
252  trrotBox->RegisterYourself();
253 
254  SubunitVol->AddNode(BoxVol,b,trrotBox);
255  }
256 
257  // ========== CRYSTAL (TGeoArb8 shape)=================
258  name = "CrystalShape";
259  CrystalShape = new TGeoArb8(name,dz,vert);
260 
261  TString medium="PWO";
262  name = "CrystalVol";
263  CrystalVol = new TGeoVolume(name,CrystalShape,gGeoMan->GetMedium(medium));
264 
265  // Translation and Rotation for each Crystal are according to
266  // co-ordinate system in the center of the Box.
267  // Crystals arrangement: right angle of each Crystal is in the middle of the box.
268  CrystalVol->SetLineColor(5);
269  for(Int_t k=0; k<kNumOfCrystals; k++){
270  cout << " " << endl;
271  cout << " -----> CRYSTAL number: "<< k << endl;
272  if (k==0){
273  trCrystal = new TGeoTranslation(tr/2.+0.5*kSpaceInBox,tr/2.+0.5*kSpaceInBox,0.);
274  rotCrystal = new TGeoRotation() ; // "right-upper" Crystal
275  }else if (k==1){
276  trCrystal= new TGeoTranslation(-tr/2.-0.5*kSpaceInBox,-tr/2.-0.5*kSpaceInBox,0.);
277  rotCrystal = new TGeoRotation(); // "left-lower" Crystal
278  rotCrystal.RotateZ(180.);
279  }else if (k==2){
280  trCrystal= new TGeoTranslation(-tr/2.-0.5*kSpaceInBox,tr/2.+0.5*kSpaceInBox,0.);
281  rotCrystal = new TGeoRotation(); // "left-upper" Crystal
282  rotCrystal.RotateZ(90.);
283  }else if (k==3){
284  trCrystal= new TGeoTranslation(tr/2.+0.5*kSpaceInBox,-tr/2.-0.5*kSpaceInBox,0.);
285  rotCrystal = new TGeoRotation() ; // "right-lower" Crystal
286  rotCrystal.RotateZ(270.);
287  }
288  TGeoCombiTrans* trrotCrystal= new TGeoCombiTrans(trCrystal,rotCrystal);
289  name = "CrystalVol";
290  name+=k;
291  trrotCrystal->SetName(name);
292  trrotCrystal->RegisterYourself();
293 
294  BoxVol->AddNode(CrystalVol,k,trrotCrystal);
295  }
296 
298  Double_t kSubShift=10.363; // size of 1 Subunit (cm) in its half Z-distance
299  Double_t FrontFaceToOffPoint=295; // Off_point -> front_face_of_crystals distance (cm)
300  Int_t jj=0;
301  for (Int_t row=0; row<9; row++){
302  for (Int_t col=0; col<9; col++){
303 
304  Int_t flag=1;
305 
306  if (row<3 && col <2) flag=0;
307  if (row==3 && col==0) flag=0;
308  if (col>1 && row >7) flag=0;
309  if (col>4 && row >6) flag=0;
310  if (col>5 && row >5) flag=0;
311  if (col>6 && row >4) flag=0;
312  if (col>7 && row >1) flag=0;
313 
314  if (flag){
315 
316  jj++;
317  cout<< "----------------------------> 16 CRYSTALS SUBUNIT No: " << jj <<endl;
318 
319  rotSub = new TGeoRotation();
320  Int_t n=2*row+1; // fixed angle for each Subunit
321  Int_t m=2*col+1;
322 
323  Double_t RotToZeroSubX= 0.931*m; // 0.931 (deg) -> rotation along X and Y
324  Double_t RotToZeroSubY= -0.931*n; // axis to have "right angle" between Quarters
325 
326  rotSub.RotateX(RotToZeroSubX);
327  rotSub.RotateY(RotToZeroSubY);
328 
329  Double_t tan_alpha1=tan(n*(TMath::Pi()/180.));
330  Double_t addShiftX=FrontFaceToOffPoint*tan_alpha1;
331 
332  Double_t tan_alpha2=tan(m*(TMath::Pi()/180.));
333  Double_t addShiftY=FrontFaceToOffPoint*tan_alpha2;
334 
335  Double_t ShiftX=(ShiftToZeroSub + addShiftX -0.5*sizeOfQuar);
336  Double_t ShiftY=(ShiftToZeroSub + addShiftY -0.5*sizeOfQuar);
337 
338  trSub = new TGeoTranslation(ShiftX, ShiftY, 0.);
339 
340  TGeoCombiTrans* thAngle= new TGeoCombiTrans(trSub,rotSub);
341 
342  name="SubunitVol";
343  name+=jj;
344  thAngle->SetName(name);
345  thAngle->RegisterYourself();
346 
347  QuarterVol->AddNode(SubunitVol,jj,thAngle); // right-upper Quarter
348  }
349  }
350  }
351 
352  trQuar = new TGeoTranslation(0.5*sizeOfQuar,0.5*sizeOfQuar,0.);
353  rotQuar = new TGeoRotation();
354 
355  TGeoCombiTrans* trrotQuar= new TGeoCombiTrans(trQuar,rotQuar);
356  name="QuarterVol";
357  trrotQuar->SetName(name);
358  trrotQuar->RegisterYourself();
359 
360  top->AddNode(QuarterVol,1,trrotQuar); //Quarter of EMC
361 
362  for (Int_t q=1; q<=3; q++){
363  TGeoCombiTrans reflection;
364  TGeoTranslation ttt;
365  if (q==3){
366  reflection.ReflectX(1); // left-upper Quarter
367  ttt = new TGeoTranslation(-0.5*sizeOfQuar,0.5*sizeOfQuar,0.);
368  }
369  if (q==1){
370  reflection.ReflectY(1); // right-lower Quarter
371  ttt = new TGeoTranslation(0.5*sizeOfQuar,-0.5*sizeOfQuar,0.);
372  }
373  if (q==2){
374  reflection.ReflectY(1);
375  reflection.ReflectX(1); // left-lower Quarter
376  ttt = new TGeoTranslation(-0.5*sizeOfQuar,-0.5*sizeOfQuar,0.);
377  }
378 
379  top->AddNode(QuarterVol,q+1,new TGeoCombiTrans(ttt,reflection));
380  }
381 
382  cout <<" "<< endl;
383  cout <<"*************************************** "<< endl;
384  TString nameBoxVol = BoxVol->GetName();
385  cout << "Checking overlaps for --------->>>> "<< nameBoxVol <<endl ;
386  gGeoManager->GetVolume(nameBoxVol)->CheckOverlaps(0.001);
387  cout << "And printing..." <<gGeoManager->PrintOverlaps()<<endl;
388 
389  cout <<" "<< endl;
390  cout <<"*************************************** "<< endl;
391  TString nameSubVol = SubunitVol->GetName();
392  cout << "Checking overlaps for --------->>>> "<< nameSubVol <<endl ;
393  gGeoManager->GetVolume(nameSubVol)->CheckOverlaps(0.001);
394  cout << "And printing..." <<gGeoManager->PrintOverlaps()<<endl;
395 
396  cout <<" "<< endl;
397  cout <<"*************************************** "<< endl;
398  TString nameQuarVol = QuarterVol->GetName();
399  cout << "Checking overlaps for --------->>>> "<< nameQuarVol <<endl ;
400  gGeoManager->GetVolume(nameQuarVol)->CheckOverlaps(0.001);
401  cout << "And printing..." <<gGeoManager->PrintOverlaps()<<endl ;
402 
403  cout <<" "<< endl;
404  cout <<"*************************************** "<< endl;
405  TString nameTopVol = top->GetName();
406  cout << "Checking overlaps for --------->>>> "<< nameTopVol <<endl ;
407  gGeoManager->GetVolume(nameTopVol)->CheckOverlaps(0.001);
408  cout << "And printing..." <<gGeoManager->PrintOverlaps()<<endl;
409 
410  cout <<" "<< endl;
411  cout <<"*************************************** "<< endl;
412  Int_t NoOfNodesInTop = top->GetNdaughters();
413  cout << "Number of GetNdaughters() == "<< NoOfNodesInTop <<endl ;
414 
415 
416 
417 
418  gGeoMan->CloseGeometry();
419  top->Write();
420  fi->Close();
421  //gGeoManager->Export(outfile);//
422  //top->Draw();//
423 }
int row
Definition: anaLmdDigi.C:67
const Double_t kSpaceInSub
TGeoVolume * QuarterVol
TGeoShape * QuarterShape
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoMedia * Media
__m128 m
Definition: P4_F32vec4.h:28
TTree * b
TGeoShape * CrystalShape
TGeoTranslation trCrystal
const Double_t kSpaceSubGlue
TGeoManager * gGeoMan
FairGeoMedium * CbmMediumCarbon
int col
Definition: anaLmdDigi.C:67
Double_t FrontFaceToOffPoint
int n
TGeoTranslation trSub
Double_t vertBox[20]
TGeoManager * gGeoManager
Double_t vert0[20]
TGeoVolume * top
FairGeoMedium * CbmMediumAluminium
TGeoTranslation trQuar
TGeoVolume * SubunitVol
TGeoRotation rotBox
Double_t vertSub[20]
FairGeoBuilder * geobuild
TFile * fi
Double_t
TString medium
Double_t vert[20]
TGeoCombiTrans reflection
TGeoVolume * BoxVol
TGeoRotation rotQuar
TGeoShape * BoxShape
TString name
FairGeoMedium * CbmMediumAir
const Double_t kAlveoleThickness
TGeoVolume * CrystalVol
Double_t vertQuar[20]
TGeoRotation rotCrystal
TGeoCombiTrans * trrotQuar
TGeoRotation rotSub
TGeoShape * SubunitShape
FairGeoMedium * CbmMediumPWO
FairGeoInterface * geoFace
TGeoTranslation trBox
Double_t Pi
const Int_t kNumOfBoxes
const Int_t kNumOfCrystals
TString outfile
const Int_t kNumOfQuarters