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