FairRoot/PandaRoot
Functions
create1StationGem_firstStation_v2.C File Reference

Go to the source code of this file.

Functions

Int_t create1StationGem_firstStation_v2 ()
 

Function Documentation

Int_t create1StationGem_firstStation_v2 ( )

Definition at line 3 of file create1StationGem_firstStation_v2.C.

References CbmMediumAir, CbmMediumAluminium, CbmMediumCarbon, CbmMediumPWO, Double_t, dummyrot, fi, geobuild, geoFace, geoLoad, gGeoMan, Media, medium, nmed, outfile, Pi, SetLineColor(), SubunitVol, top, and TString.

4 {
5  // create only GEM with one station (v2)
6  //----------------------------------------------------------------------------------------------------------------------------------------------
7  // Gem disk geometry parameters (R.Karabowicz)
8  //----------------------------------------------------------------------------------------------------------------------------------------------
9  // Done Some Changes By Nazila Divani ( since May 2015 ... ) (v2)---> updated 1Station GEM geometry (April 2017)
10  //----------------------------------------------------------------------------------------------------------------------------------------------
11  // created GEM first station at the ZPosition=119.40cm , (This is the smallest GEM station)
12  //----------------------------------------------------------------------------------------------------------------------------------------------
13  // Tried to get close to the CAD Geometry as the realistic one ( After could not use CadConverter to convert CAD to ROOT ) //Some parameters from DL.
14  //----------------------------------------------------------------------------------------------------------------------------------------------
15  // Units are in [cm]
16  //---------------------------------------------------------------------------------------------------------------------------------------------
17  const Int_t NofDisks = 1; //number of GEM station in form of disk
18 
19  const Double_t DiskVolInnerRadius[NofDisks] = { 4.50 }; // InnerRadius for 1 Station in form of disk
20  const Double_t DiskVolOuterRadius[NofDisks] = { 45.06 }; // OuterRadius for 1 Station in form of disk
21  const Double_t DiskZPosition [NofDisks] = { 119.40 }; // ZPosition for 1 Station in form of disk
22 
23 
24  const Int_t DiskNFoils [NofDisks] = { 2 }; // For modifying misalignment
25  const Double_t MiddleROBarHfTh[NofDisks] = { 2.35 }; // half thickness of space in the middle of foils [cm]
26  const Double_t HalfStationThickness = 8.003;
27 
28  const Double_t carbonRingInnerRadius[NofDisks] = { 39.97 };
29  const Double_t carbonRingOuterRadius[NofDisks] = { 40.17 };
30  const Double_t carbonRingHalfThickness = 1.50;
31 
32  const Double_t copperRingInnerRadius[NofDisks] = { 39.47 };
33  const Double_t copperRingOuterRadius[NofDisks] = { 39.67 };
34  const Double_t copperRingHalfThickness = 3.75;
35 
36  const Double_t AlRingInnerRadius[NofDisks] = { 39.70 };
37  const Double_t AlRingOuterRadius[NofDisks] = { 44.70 };
38  const Double_t AlRingHalfThickness = 3.75;
39 
40  const Double_t SegmentHalfThickness = 0.25;
41  const Int_t NofSegments = 24;
42  const Double_t SegmentDeltaAngle = 360./(Double_t(NofSegments));
43  const Double_t FirstSegmentAngle = 7.5;
44  const TString newsegment [NofSegments] = { "seg1" ,"seg2" ,"seg3" ,"seg4" ,"seg5" ,"seg6" ,"seg7" ,"seg8" ,
45  "seg9" ,"seg10","seg11","seg12","seg13","seg14","seg15","seg16",
46  "seg17","seg18","seg19","seg20","seg21","seg22","seg23","seg24" };
47 
48  const Double_t moduleRingInnerRadius[NofDisks] = { 39.70 };
49  const Double_t moduleRingOuterRadius[NofDisks] = { 44.65 };
50  const Double_t moduleRingHalfThickness = 3.75;
51 
52  const Double_t moduleSegmentHalfThickness = 1.30;
53  const Int_t NofmoduleSegments = 24;
54  const Double_t moduleSegmentDeltaAngle = 360./(Double_t(NofmoduleSegments));
55  const Double_t FirstmoduleSegmentAngle = 0.0 ;
56  const TString newmodulesegment [NofmoduleSegments] = { "moduleseg1" ,"moduleseg2" ,"moduleseg3" ,"moduleseg4" ,"moduleseg5" ,"moduleseg6" ,"moduleseg7" ,"moduleseg8" ,
57  "moduleseg9" ,"moduleseg10","moduleseg11","moduleseg12","moduleseg13","moduleseg14","moduleseg15","moduleseg16",
58  "moduleseg17","moduleseg18","moduleseg19","moduleseg20","moduleseg21","moduleseg22","moduleseg23","moduleseg24" };
59 
60  const Double_t AlumiRingInnerRadius[NofDisks] = { 44.7 };
61  const Double_t AlumiRingOuterRadius[NofDisks] = { 45.0 };
62  const Double_t AlumiRingHalfThickness = 3.75;
63 
64  const Double_t coverRingInnerRadius[NofDisks] = { 39.70 };
65  const Double_t coverRingOuterRadius[NofDisks] = { 45.00 };
66  const Double_t coverRingHalfThickness = 0.2;
67 
68  const Double_t rcopperbarx = 1.90;
69  const Double_t rcopperbary = 5.50;
70  const Double_t rcopperbarHalfThickness = 8.40;
71 
72  const Double_t lcopperbarx = 0.95;
73  const Double_t lcopperbary = 5.50;
74  const Double_t lcopperbarHalfThickness = 13.80;
75 
76  //------------------------------------------------------------ main layers in shape of Disk----------------------------------------------------------------------
77  const Int_t NofLayers = 49+48; //51+48;
78 
79  const TString LayerName [NofLayers] = {"space", // these "spaces" belong to holding structure layers
80  "gap_air", "window1_foil_out_aluminium", "gap_air", "WindowF_kapton", "gap_air", "window2_foil_out_aluminium", "gap_air",
81  "space", // these "spaces" belong to holding structure layers
82  "gap_air", "WindowF_aluminium", "gap_air", "CathodeF_kapton", "gap_air", "CathodeF_aluminium", "gap_air",
83  "space", //
84  //"Gem1_Sensor_GEMmixture", // sensitive layer
85  "gap_air",
86  "space", //
87  "gap_air", "Gem1F_copper", "gap_air", "Gem1_kapton", "gap_air", "Gem1B_copper", "gap_air",
88  "space", //
89  "gap_air", "Gem2F_copper", "gap_air", "Gem2_kapton", "gap_air", "Gem2B_copper", "gap_air",
90  "space", //
91  "gap_air", "Gem3F_copper", "gap_air", "Gem3_kapton", "gap_air", "Gem3B_copper", "gap_air",
92  "space", //
93  "gap_air",
94  "space", //
95  "gap_air", "PadF_copper", "gap_air", "Pad_kapton", "gap_air", "PadB_copper", "gap_air",
96  "space", //
97  "gap_air",
98  "space", //
99  "gap_air", "Gem4F_copper", "gap_air", "Gem4_kapton", "gap_air", "Gem4B_copper", "gap_air",
100  "space", //
101  "gap_air", "Gem5F_copper", "gap_air", "Gem5_kapton", "gap_air", "Gem5B_copper", "gap_air",
102  "space", //
103  "gap_air", "Gem6F_copper", "gap_air", "Gem6_kapton", "gap_air", "Gem6B_copper", "gap_air",
104  "space", //
105  //"Gem6_Sensor_GEMmixture", // sensitive layer
106  "gap_air",
107  "space", //
108  "gap_air", "CathodeB_aluminium", "gap_air", "CathodeB_kapton", "gap_air", "WindowB_aluminium", "gap_air",
109  "space", //
110  "gap_air", "window1_foil_in_aluminium", "gap_air", "WindowB_kapton", "gap_air", "window2_foil_in_aluminium", "gap_air",
111  "space" };
112 
113 
114  const Double_t LayerThick[NofLayers] = { 1.0, // windowF1_ring_carbon=holding structure // 1 = 1 space
115  0.00001, 0.0001, 0.00001, 0.0007, 0.00001, 0.0001, 0.00001, // +3 = 4 window + 4 gap_air
116  1.00, // windowF2_ring_carbon=holding structure // +1 = 5 space
117  0.00001, 0.0001, 0.00001, 0.0007, 0.00001, 0.0001, 0.00001, // +3 = 8 cathode + 4 gap_air
118  0.80, // cathodeF_ring_GlassFiber=holding structure // +1 = 9 space
119  //1.0020, //Sens // +1 = 10 SENSOR
120  0.00001, // +0 = 10 + 1 gap_air
121  0.050, // gem_ring1_GlassFiber=holding structure // +1 = 11 space
122  0.00001, 0.0005, 0.00001, 0.0050, 0.00001, 0.0005, 0.00001, // +3 = 14 GEM Foil + 4 gap_air
123  0.050, // gem_ring2_GlassFiber=holding structure // +1 = 15 space
124  0.00001, 0.0005, 0.00001, 0.0050, 0.00001, 0.0005, 0.00001, // +3 = 18 GEM Foil + 4 gap_air
125  0.050, // gem_ring3_GlassFiber=holding structure // +1 = 19 space
126  0.00001, 0.0005, 0.00001, 0.0050, 0.00001, 0.0005, 0.00001, // +3 = 22 GEM Foil + 4 gap_air
127  0.050, // gem_ring4_GlassFiber=holding structure // +1 = 23 space
128  0.00001, // +0 = 23 + 1 gap_air
129  0.10, // padplaneF_support_GlassFiber=holding structure // +1 = 24 space
130  0.00001, 0.001, 0.00001, 0.001, 0.00001, 0.001, 0.00001, // +3 = 27 PAD plane + 4 gap_air
131  0.10, // padplaneB_support_GlassFiber=holding structure // +1 = 28 space
132  0.00001, // +0 = 28 + 1 gap_air
133  0.050, // gem_ring5_GlassFiber=holding structure // +1 = 29 space
134  0.00001, 0.0005, 0.00001, 0.0050, 0.00001, 0.0005, 0.00001, // +3 = 32 GEM Foil + 4 gap_air
135  0.050, // gem_ring6_GlassFiber=holding structure // +1 = 33 space
136  0.00001, 0.0005, 0.00001, 0.0050, 0.00001, 0.0005, 0.00001, // +3 = 36 GEM Foil + 4 gap_air
137  0.050, // gem_ring7_GlassFiber=holding structure // +1 = 37 space
138  0.00001, 0.0005, 0.00001, 0.0050, 0.00001, 0.0005, 0.00001, // +3 = 40 GEM Foil + 4 gap_air
139  0.050, // gem_ring8_GlassFiber=holding structure // +1 = 41 space
140  //1.0020, //Sens // +1 = 42 SENSOR
141  0.00001, // +0 = 42 + 1 gap_air
142  0.80, // cathodeB_ring_GlassFiber=holding structure // +1 = 43 space
143  0.00001, 0.0001, 0.00001, 0.0007, 0.00001, 0.0001, 0.00001, // +3 = 46 cathode + 4 gap_air
144  1.00, // windowB1_ring_carbon=holding structure // +1 = 47 space
145  0.00001, 0.0001, 0.00001, 0.0007, 0.00001, 0.0001, 0.00001, // +3 = 50 window + 4 gap_air
146  1.0 }; // windowB2_ring_carbon=holding structure // +3 = 51 space
147  // 51 layers + 48 gap_air
148 
149 
150  const Double_t DiskOuterRadius[NofLayers][NofDisks] = { 39.90,
151  38.95, 38.95, 39.40, 39.40, 38.95, 38.95, 38.95,
152  39.90,
153  38.45, 38.45, 39.40, 39.40, 38.45, 38.45, 38.45,
154  39.40,
155  //38.00,
156  39.05,
157  39.05,
158  38.10, 38.10, 39.05, 39.05, 38.10, 38.10, 38.10,
159  39.05,
160  38.10, 38.10, 39.05, 39.05, 38.10, 38.10, 38.10,
161  39.05,
162  38.10, 38.10, 39.05, 39.05, 38.10, 38.10, 38.10,
163  39.05,
164  39.05,
165  45.00,
166  44.90, 44.90, 44.90, 44.90, 44.90, 44.90, 39.05,
167  45.00,
168  39.05,
169  39.05,
170  38.10, 38.10, 39.05, 39.05, 38.10, 38.10, 38.10,
171  39.05,
172  38.10, 38.10, 39.05, 39.05, 38.10, 38.10, 38.10,
173  39.05,
174  38.10, 38.10, 39.05, 39.05, 38.10, 38.10, 38.10,
175  39.05,
176  //38.00,
177  39.40,
178  39.40,
179  38.45, 38.45, 39.40, 39.40, 38.45, 38.45, 38.45,
180  39.40,
181  39.40, 39.40, 38.95, 38.95, 39.40, 39.40, 39.40,
182  39.40 };
183 
184 
185  const Double_t DiskInnerRadius[NofLayers][NofDisks] = { 4.50,
186  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
187  4.50,
188  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
189  4.50,
190  //4.50,
191  38.50,
192  4.50,
193  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
194  4.50,
195  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
196  4.50,
197  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
198  4.50,
199  4.50,
200  4.50,
201  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
202  4.50,
203  4.50,
204  4.50,
205  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
206  4.50,
207  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
208  4.50,
209  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
210  4.50,
211  //4.50,
212  38.50,
213  4.50,
214  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
215  4.50,
216  4.50, 4.50, 4.50, 4.50, 4.50, 4.50, 4.50,
217  4.50 };
218 
219 
220  const Double_t HoleTZ = 0.0; // (top and down) holes Translation parameters
221  const Double_t HoleTX = 0.0;
222  const Double_t HoleTY = 33.00;
223 //------------------------------------ sensitive layers ---------------------------------------------------------------------------------------
224 
225  const Int_t NofSensLayers = 2;
226 
227  const Double_t sMiddleROBarHfTh[NofDisks] = { 2.35 }; // half thickness of space in the middle of Sens [cm]
228 
229  const TString SensLayerName[NofSensLayers] = { "Gem1_Sensor_GEMmixture", // drift layers
230  "Gem6_Sensor_GEMmixture" };
231 
232  const Double_t SensLayerThick[NofSensLayers] = { 0.85,
233  0.85 };
234 
235  const Double_t SensZPosition[NofSensLayers][NofDisks] = { -0.69412,
236  0.69520 };
237 
238  const Double_t SensOuterRadius[NofSensLayers][NofDisks] = { 38.15,
239  38.15 };
240 
241  const Double_t SensInnerRadius[NofSensLayers][NofDisks] = { 5.00,
242  5.00 };
243 
244  const Double_t sHoleTZ = 0.0; // (top and down) holes Translation parameters
245  const Double_t sHoleTX = 0.0;
246  const Double_t sHoleTY = 33.00;
247 
248 //----------------------- holding structure layers ------------------------------------------------------------------------------------------------
249  const Int_t NofHLayers = 16;
250 
251  const TString HLayersName [NofHLayers] = { "windowF1_ring_carbon",
252  //"space",
253  "windowF2_ring_carbon",
254  //"space",
255  "cathodeF_ring_GlassFiber",
256  //"space",
257  "gem_ring1_GlassFiber",
258  //"space",
259  "gem_ring2_GlassFiber",
260  //"space",
261  "gem_ring3_GlassFiber",
262  //"space",
263  "gem_ring4_GlassFiber",
264  "padplaneF_support_GlassFiber",
265  //"space",
266  "padplaneB_support_GlassFiber",
267  "gem_ring5_GlassFiber",
268  //"space",
269  "gem_ring6_GlassFiber",
270  //"space",
271  "gem_ring7_GlassFiber",
272  //"space",
273  "gem_ring8_GlassFiber",
274  //"space",
275  "cathodeB_ring_GlassFiber",
276  //"space",
277  "windowB1_ring_carbon",
278  //"space",
279  "windowB2_ring_carbon" };
280 
281  const Double_t HLayersThick[NofHLayers] = { 1.00,
282  1.00,
283  0.80,
284  0.050,
285  0.050,
286  0.050,
287  0.050,
288  0.10,
289  0.10,
290  0.050,
291  0.050,
292  0.050,
293  0.050,
294  0.80,
295  1.00,
296  1.00 };
297 
298 
299  const Double_t HZPosition[NofHLayers][NofDisks] = { -2.62100,
300  -1.62006,
301  -0.71912,
302  -0.29411,
303  -0.23807,
304  -0.18203,
305  -0.12599,
306  -0.05098,
307  0.05206,
308  0.12707,
309  0.18311,
310  0.23915,
311  0.29519,
312  0.72020,
313  1.62114,
314  2.62208 };
315 
316 
317  const Double_t HOuterRadius[NofHLayers][NofDisks] = { 39.90,
318  39.90,
319  39.40,
320  39.05,
321  39.05,
322  39.05,
323  39.05,
324  45.00,
325  45.00,
326  39.05,
327  39.05,
328  39.05,
329  39.05,
330  39.40,
331  39.40,
332  39.40 };
333 
334  const Double_t HInnerRadius[NofHLayers][NofDisks] = { 38.50,
335  38.50,
336  38.50,
337  38.15,
338  38.15,
339  38.15,
340  38.15,
341  38.50,
342  38.50,
343  38.15,
344  38.15,
345  38.15,
346  38.15,
347  38.50,
348  38.00,
349  38.00 };
350 
351  const Double_t HXBoxWidth = 2.30; // Using to define holes for the holding structure layers
352  const Double_t HXPlateWidth = 1.90;
353  const Double_t HYPlateWidth = 9.30;
354 
355  const Double_t HTZ = 0.0; // Translation parameters for vertical holes
356  const Double_t HTX = 0.0;
357  const Double_t HTY[NofHLayers][NofDisks] = { 25.0,
358  25.0,
359  25.0,
360  25.0,
361  25.0,
362  25.0,
363  25.0,
364  25.0,
365  25.0,
366  25.0,
367  25.0,
368  25.0,
369  25.0,
370  25.0,
371  25.0,
372  25.0 };
373 
374 
375 //-------------------------------------------------------------------------------------------------------------------------------------------------
376  const Int_t SensorStripType [2] = { 3 , 2 };
377 
378  const Double_t SensorStripAngle[2][2] = { 0. , 0. , 0. , 0. };
379  const Double_t SensorStripPitch[2][2] = { 0.04, 0.04, 0.04, 0.04};
380 
381  Double_t firstLayerOffset = 0.;
382 
383  for ( Int_t ilayer = 0 ; ilayer < NofLayers ; ilayer++ ) {
384  cout << LayerName[ilayer].Data() << " -> " << LayerThick[ilayer] << endl;
385  firstLayerOffset += LayerThick[ilayer];
386  }
387 
388  cout << "total thickness is " << firstLayerOffset << endl;
389  firstLayerOffset = firstLayerOffset/2.;
390  firstLayerOffset = -0.001*(TMath::Floor(1000.*firstLayerOffset));
391  cout << "first layer offset is " << firstLayerOffset << endl;
392  //-----------------------------------------------------------------------------------------------
393 
394  TString vmcWorkdir = getenv("VMCWORKDIR");
395 
396  TString outfile= "../../geometry/gem_1Station_first_realistic_v2.root"; //v2
397 
398 
399  TFile* fi = new TFile(outfile,"RECREATE");
400 
401  cout << "created output file" << endl;
402  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
403  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
404  cout << "geoface setmediafile" << endl;
405  geoFace->setMediaFile("../../geometry/media_pnd.geo");
406  cout << "geoface readmedia" << endl;
407  geoFace->readMedia();
408  cout << "geoface print" << endl;
409  geoFace->print();
410  cout << "geoface done" << endl;
411 
412  FairGeoMedia *Media = geoFace->getMedia();
413  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
414 
415  FairGeoMedium *CbmMediumAir = Media->getMedium("air");
416  FairGeoMedium *CbmMediumPWO = Media->getMedium("PWO");
417  FairGeoMedium *CbmMediumCarbon = Media->getMedium("carbon");
418  FairGeoMedium *CbmMediumAluminium = Media->getMedium("aluminium");
419  FairGeoMedium *CbmMediumCopper = Media->getMedium("copper");
420  FairGeoMedium *CbmMediumKapton = Media->getMedium("kapton");
421  FairGeoMedium *CbmMediumArCO2 = Media->getMedium("GEMmixture");
422  FairGeoMedium *CbmMediumUranium = Media->getMedium("uranium");
423  FairGeoMedium *CbmMediumGlassFiber= Media->getMedium("GlassFiber");
424 
425  Int_t nmed=geobuild->createMedium(CbmMediumAir);
426  nmed=geobuild->createMedium(CbmMediumPWO);
427  nmed=geobuild->createMedium(CbmMediumCarbon);
428  nmed=geobuild->createMedium(CbmMediumAluminium);
429  nmed=geobuild->createMedium(CbmMediumCopper);
430  nmed=geobuild->createMedium(CbmMediumKapton);
431  nmed=geobuild->createMedium(CbmMediumArCO2);
432  nmed=geobuild->createMedium(CbmMediumUranium);
433  nmed=geobuild->createMedium(CbmMediumGlassFiber);
434 
435 
436  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
437 
438  TGeoVolume *top = new TGeoVolumeAssembly("Gem");
439 
440  gGeoMan->SetTopVolume(top);
441 
442  cout << "-------------------------------------------------------------------" << endl;
443  TList* mediaList = (TList*)gGeoMan->GetListOfMedia();
444 
445  cout << "media known: " << mediaList->GetEntries() << "." << endl;
446  for ( Int_t itemp = 0 ; itemp < mediaList->GetEntries() ; itemp++ ) {
447  TGeoMedium* medium = (TGeoMedium*)mediaList->At(itemp);
448  cout << "medium " << itemp << " name is " << medium->GetName() << endl;
449  }
450  cout << "-------------------------------------------------------------------" << endl;
451 
452  TGeoRotation* dummyrot = new TGeoRotation();
453 
454  TGeoVolumeAssembly* SubunitVol = new TGeoVolumeAssembly("Gem_Disks");
455 
456  //----------------------------------------------------------------------------------------
457  TGeoShape *DiskShape[NofDisks];
458  TGeoVolume *DiskVol [NofDisks];
459  TGeoRotation *DiskRotat[NofDisks];
460  TGeoTranslation *DiskTrans[NofDisks];
461  TGeoCombiTrans *DiskCombi[NofDisks];
462  //--------------------------------------------------------------------------------------------
463  TGeoShape *carbonRingShape[NofDisks];
464  TGeoVolume *carbonRingVol [NofDisks];
465  TGeoTranslation *carbonRingTrans[NofDisks];
466  TGeoCombiTrans *carbonRingCombi[NofDisks];
467  //------------------------------------------------------------------------------------------
468  TGeoShape *copperRingShape[NofDisks];
469  TGeoVolume *copperRingVol [NofDisks];
470  TGeoTranslation *copperRingTrans[NofDisks];
471  TGeoCombiTrans *copperRingCombi[NofDisks];
472  //-----------------------------------------------------------------------------------------
473  TGeoShape *coverRingShape[NofDisks];
474  TGeoVolume *coverRingVol [NofDisks];
475  TGeoTranslation *coverRingTrans[NofDisks];
476  TGeoCombiTrans *coverRingCombi[NofDisks];
477  //-------------------------------------------------------------------------------------------
478  TGeoShape *tAcopperbarShape;
479  TGeoVolume *tAcopperbarVol ;
480  TGeoTranslation *tAcopperbarTrans;
481  TGeoRotation *tAcopperbarRot;
482  TGeoCombiTrans *tAcopperbarCombi;
483  //-----------------------------------------------------------------------------------------
484  TGeoShape *tBcopperbarShape;
485  TGeoVolume *tBcopperbarVol ;
486  TGeoTranslation *tBcopperbarTrans;
487  TGeoRotation *tBcopperbarRot;
488  TGeoCombiTrans *tBcopperbarCombi;
489  //-----------------------------------------------------------------------------------------
490  TGeoShape *dAcopperbarShape;
491  TGeoVolume *dAcopperbarVol ;
492  TGeoTranslation *dAcopperbarTrans;
493  TGeoRotation *dAcopperbarRot;
494  TGeoCombiTrans *dAcopperbarCombi;
495  //-----------------------------------------------------------------------------------------
496  TGeoShape *dBcopperbarShape;
497  TGeoVolume *dBcopperbarVol ;
498  TGeoTranslation *dBcopperbarTrans;
499  TGeoRotation *dBcopperbarRot;
500  TGeoCombiTrans *dBcopperbarCombi;
501  //-----------------------------------------------------------------------------------------
502  TGeoShape *AlRingShape[NofDisks][NofSegments];
503  TGeoVolume *AlRingVol [NofDisks][NofSegments];
504  TGeoTranslation *AlRingTrans[NofDisks][NofSegments];
505  TGeoCombiTrans *AlRingCombi[NofDisks][NofSegments];
506  //-----------------------------------------------------------------------------------------
507  TGeoShape *moduleRingShape[NofDisks][NofmoduleSegments];
508  TGeoVolume *moduleRingVol [NofDisks][NofmoduleSegments];
509  TGeoTranslation *moduleRingTrans[NofDisks][NofmoduleSegments];
510  TGeoCombiTrans *moduleRingCombi[NofDisks][NofmoduleSegments];
511  //-----------------------------------------------------------------------------------------
512  TGeoShape *AlumiRingShape[NofDisks];
513  TGeoVolume *AlumiRingVol [NofDisks];
514  TGeoTranslation *AlumiRingTrans[NofDisks];
515  TGeoCombiTrans *AlumiRingCombi[NofDisks];
516  //----------------------------------------------------------------------------------------------
517  TGeoShape *DiskLayersShapeA [NofLayers][NofDisks][4]; // 4 is number of seg
518  TGeoShape *DiskLayersShapeB [NofLayers][NofDisks][4];
519  TGeoSubtraction *DiskLayersSubtr [NofLayers][NofDisks][4];
520  TGeoShape *DiskLayersShapeC [NofLayers][NofDisks][4]; // final, C = A-B
521  TGeoShape *DiskLayersShapeHole [NofLayers][NofDisks][4];
522  TGeoCompositeShape *DiskLayersShapecompos[NofLayers][NofDisks][4];
523  TGeoVolume *DiskLayersVol [NofLayers][NofDisks][4];
524  TGeoTranslation *DiskLayersTranshA [NofLayers][NofDisks][4];
525  TGeoTranslation *DiskLayersTranshB [NofLayers][NofDisks][4];
526  TGeoTranslation *DiskLayersTrans [NofLayers][NofDisks][4];
527  TGeoCombiTrans *DiskLayersCombi [NofLayers][NofDisks][4];
528  //---------------------------------------------------------------------------------------------------
529  TGeoShape *SensDiskLayersShapeA [NofSensLayers][NofDisks][4]; // 4 is number of seg
530  TGeoShape *SensDiskLayersShapeB [NofSensLayers][NofDisks][4];
531  TGeoSubtraction *SensDiskLayersSubtr [NofSensLayers][NofDisks][4];
532  TGeoShape *SensDiskLayersShapeC [NofSensLayers][NofDisks][4]; // final, C = A-B
533  TGeoShape *SensDiskLayersShapeHole [NofSensLayers][NofDisks][4];
534  TGeoCompositeShape *SensDiskLayersShapecompos[NofSensLayers][NofDisks][4];
535  TGeoVolume *SensDiskLayersVol [NofSensLayers][NofDisks][4];
536  TGeoTranslation *SensDiskLayersTranshA [NofSensLayers][NofDisks][4];
537  TGeoTranslation *SensDiskLayersTranshB [NofSensLayers][NofDisks][4];
538  TGeoTranslation *SensDiskLayersTrans [NofSensLayers][NofDisks][4];
539  TGeoCombiTrans *SensDiskLayersCombi [NofSensLayers][NofDisks][4];
540  //------------------------------------------------------------------------------------------------
541  TGeoShape *HLayersShapeTube [NofHLayers][NofDisks];
542  TGeoShape *HLayersShapeBox [NofHLayers][NofDisks];
543  TGeoShape *HLayersShapePlate [NofHLayers][NofDisks];
544  TGeoShape *HLayersShapeHT [NofHLayers][NofDisks];
545  TGeoShape *HLayersShapeHTM [NofHLayers][NofDisks];
546  TGeoShape *HLayersShapeHTD [NofHLayers][NofDisks];
547  TGeoCompositeShape *HLayersShapecompos[NofHLayers][NofDisks];
548  TGeoVolume *HLayersVolcomp [NofHLayers][NofDisks];
549  TGeoTranslation *HLayersTranstA [NofHLayers][NofDisks];
550  TGeoTranslation *HLayersTranstB [NofHLayers][NofDisks];
551  TGeoTranslation *HLayersTranstC [NofHLayers][NofDisks];
552  TGeoTranslation *HLayersTranstD [NofHLayers][NofDisks];
553  TGeoTranslation *HLayersTranstE [NofHLayers][NofDisks];
554  TGeoTranslation *HLayersTranstF [NofHLayers][NofDisks];
555  TGeoRotation *HLayersRotrA [NofHLayers][NofDisks];
556  TGeoShape *HLayersShape [NofHLayers][NofDisks];
557  TGeoVolume *HLayersVol [NofHLayers][NofDisks];
558  TGeoTranslation *HLayersTrans [NofHLayers][NofDisks];
559  TGeoCombiTrans *HLayersCombi [NofHLayers][NofDisks];
560  //------------------------------------------------------------------------------------------------
561  TGeoShape *RiddleShapeTubeA ;
562  TGeoShape *RiddleShapeTubeB ;
563  TGeoShape *RiddleShapeCone ;
564  TGeoShape *RiddleShapeTubeC ;
565  TGeoShape *RiddleShapeTubeD ;
566  TGeoShape *RiddleShapeTubeE ;
567  TGeoShape *RiddleShapeTubeF ;
568  TGeoSubtraction *RiddleSubtr ;
569  TGeoCompositeShape *RiddleShapecompos;
570  TGeoVolume *RiddleVolcomp ;
571  TGeoTranslation *RiddleTrans ;
572  TGeoTranslation *RiddleTransTubeA ;
573  TGeoTranslation *RiddleTransCone ;
574  TGeoTranslation *RiddleTransTubeC ;
575  TGeoTranslation *RiddleTransTubeD ;
576  TGeoTranslation *RiddleTransTubeE ;
577  TGeoCombiTrans *RiddleCombi ;
578  TGeoTranslation *RiddleTransTubeF[4][100] ;
579  TGeoCombiTrans *RiddleCombiTranshole[4][100] ;
580  TGeoRotation *RiddleRothole[4][100] ;
581  //----------------------------------------------------------------------------------------------
582  TString outParFileName = Form("%s/macro/params/gem_1Station_first_realistic_v2.digi.par",vmcWorkdir.Data()); //v2
583 
584 
585  cout << "parameter file = \"" << outParFileName.Data() << "\"" << endl;
586 
587  ofstream pout(outParFileName.Data());
588  pout.setf(ios::fixed);
589 
590  pout << "#################################################################" << endl;
591  pout << "# Digitization parameters for GEM " << endl;
592  pout << "# with 1 Station " << endl;
593  pout << "# Format: " << endl;
594  pout << "# Description of parameters: " << endl;
595  pout << "# [PndGemDetectors] " << endl;
596  pout << "# parameters:d station_number, ZPos, rotation_angle, number_of_sensors, \\" << endl;
597  pout << "# sensor_number, sensor_type, pos_x, pos_y, pos_z, rotAngle, inn_rad, out_rad, thick, str_ang_0, str_ang_1, barWidth, pitch_0, pitch_1, \\" << endl;
598  pout << "# sensor_number, ...." << endl;
599  pout << "# station_number, ..." << endl;
600  pout << "#################################################################" << endl;
601  pout << "[PndGemDetectors]" << setprecision(4) << endl;
602 
603  pout << "parameters:Double_t \\" << endl;
604 
605  for ( Int_t istat = 0 ; istat < NofDisks ; istat++ ) {
606 
607  pout << " " << istat+1 << ", "
608  << setw(9) << DiskZPosition[istat]
609  << ", 0.0, " << 2 << ", \\" << endl;
610 
611  //-----------------------------------GEM Disk------------------------------------------------------------------------------------------------------
612  DiskShape[istat] = new TGeoTube (Form("disk%dshape",istat+1),DiskVolInnerRadius[istat],DiskVolOuterRadius[istat],HalfStationThickness);
613  DiskVol [istat] = new TGeoVolume(Form("Gem_Disk%d_Volume",istat+1),DiskShape[istat],gGeoMan->GetMedium("GEMmixture"));
614  DiskTrans[istat] = new TGeoTranslation(0.,0.,DiskZPosition[istat]);
615  cout << "station " << DiskVolInnerRadius[istat] << " " << DiskVolOuterRadius[istat] << " at " << DiskZPosition[istat] << endl;
616  if(istat<2)
617  DiskCombi[istat] = new TGeoCombiTrans(*DiskTrans[istat],*dummyrot);
618  else
619  {
620  DiskRotat[istat] = new TGeoRotation(Form("disk%drotat"), 0.0, 180.0, 0.0); //turned over the 3rd station because of the position of the electronic devices
621  DiskCombi[istat] = new TGeoCombiTrans(*DiskTrans[istat],*DiskRotat[istat]);
622  }
623  //DiskCombi[istat] = new TGeoCombiTrans(*DiskTrans[istat],*dummyrot);
624  DiskCombi[istat]->SetName(Form("Gem_Disk%d_Volume",istat+1));
625  DiskCombi[istat]->RegisterYourself();
626  DiskVol[istat]->SetLineColor(kYellow);
627  //--------------------------------------------------------------------------------------------------------------------------------------------------------------------
628  //------------------------- Gas container Ring Bottom -------------------------------------------------------------------------------------
629  carbonRingShape[istat] = new TGeoTube (Form("carbonRing%dshape",istat+1),carbonRingInnerRadius[istat],carbonRingOuterRadius[istat],carbonRingHalfThickness);
630  carbonRingVol [istat] = new TGeoVolume(Form("Gem_carbonRing%d_Volume",istat+1),carbonRingShape[istat],gGeoMan->GetMedium("carbon"));
631  carbonRingTrans[istat] = new TGeoTranslation(0.,0.,-1.61);
632  cout << "carbonRing " << carbonRingInnerRadius[istat] << " " << carbonRingOuterRadius[istat] << endl;
633  carbonRingCombi[istat] = new TGeoCombiTrans(*carbonRingTrans[istat],*dummyrot);
634  carbonRingCombi[istat]->SetName(Form("Gem_carbonRing%d_Volume",istat+1));
635  carbonRingCombi[istat]->RegisterYourself();
636  carbonRingVol[istat]->SetLineColor(kMagenta);
637  //----------------------------------------------------------------------------------------------------------------------------------------
638  DiskVol[istat]->AddNode(carbonRingVol[istat],0,carbonRingCombi[istat]);
639  //------------------------------------------------------------------------------------------------------------------------------------------
640  //------------------------- Gas container Ring top -----------------------------------------------------------------------------------------
641  copperRingShape[istat] = new TGeoTube (Form("copperRing%dshape",istat+1),copperRingInnerRadius[istat],copperRingOuterRadius[istat],copperRingHalfThickness);
642  copperRingVol [istat] = new TGeoVolume(Form("Gem_copperRing%d_Volume",istat+1),copperRingShape[istat],gGeoMan->GetMedium("copper"));
643  copperRingTrans[istat] = new TGeoTranslation(0.,0.,3.853);
644  cout << "copperRing " << copperRingInnerRadius[istat] << " " << copperRingOuterRadius[istat] << endl;
645  copperRingCombi[istat] = new TGeoCombiTrans(*copperRingTrans[istat],*dummyrot);
646  copperRingCombi[istat]->SetName(Form("Gem_copperRing%d_Volume",istat+1));
647  copperRingCombi[istat]->RegisterYourself();
648  copperRingVol[istat]->SetLineColor(kYellow-5);
649  //----------------------------------------------------------------------------------------------------------------------------------------
650  DiskVol[istat]->AddNode(copperRingVol[istat],0,copperRingCombi[istat]);
651  //----------------------------------------------------------------------------------------------------------------------------------------
652  //----------------------segments for electronics --------------------------------------------------------------------------------------------------------
653  Double_t segmentAngularSize = SegmentHalfThickness/AlRingInnerRadius[istat]*360.;
654  for ( Int_t isegm = 0 ; isegm < NofSegments ; isegm++ ) {
655  cout << " Segment " << isegm << " with name " << newsegment[isegm] << " will be put at " << FirstSegmentAngle+isegm*SegmentDeltaAngle << " (in fact from " << FirstSegmentAngle+isegm*SegmentDeltaAngle-segmentAngularSize/2. << " to " << FirstSegmentAngle+isegm*SegmentDeltaAngle+segmentAngularSize/2. << ")" << endl;
656  AlRingShape[istat][isegm] = new TGeoTubeSeg (Form("AlRing%dshape",istat+1,isegm+1),AlRingInnerRadius[istat],AlRingOuterRadius[istat],AlRingHalfThickness,FirstSegmentAngle+isegm*SegmentDeltaAngle-segmentAngularSize/2.,FirstSegmentAngle+isegm*SegmentDeltaAngle+segmentAngularSize/2. );
657  AlRingVol[istat][isegm] = new TGeoVolume (Form("Gem_AlRing%d_Volume",istat+1,isegm+1),AlRingShape[istat][isegm],gGeoMan->GetMedium("aluminium"));
658  AlRingTrans[istat][isegm] = new TGeoTranslation (0.,0.,3.853);
659  cout << "AlRing " << AlRingInnerRadius[istat] << " " << AlRingOuterRadius[istat] << endl;
660  AlRingCombi[istat][isegm] = new TGeoCombiTrans (*AlRingTrans[istat][isegm],*dummyrot);
661  AlRingCombi[istat][isegm]->SetName(Form("Gem_AlRing%d_Volume",istat+1,isegm+1));
662  AlRingCombi[istat][isegm]->RegisterYourself();
663  AlRingVol[istat][isegm]->SetLineColor(kCyan-9);
664  //-----------------------------------------------------------------------------------------------------------------------------------------
665  DiskVol[istat]->AddNode(AlRingVol[istat][isegm],0,AlRingCombi[istat][isegm]);
666  //------------------------------------------------------------------------------------------------------------------------------------------
667  }
668  //----------------------------------------------------------------------------------------------------------------------------------------
669  //---------------------- electronic module --------------------------------------------------------------------------------------------------------
670  Double_t modulesegmentAngularSize = moduleSegmentHalfThickness/moduleRingInnerRadius[istat]*360.;
671  for ( Int_t imodulesegm = 0 ; imodulesegm < NofmoduleSegments ; imodulesegm++ ) {
672  cout << " moduleSegment " << imodulesegm << " with name " << newmodulesegment[imodulesegm] << " will be put at " << FirstmoduleSegmentAngle+imodulesegm*moduleSegmentDeltaAngle << " (in fact from " << FirstmoduleSegmentAngle+imodulesegm*moduleSegmentDeltaAngle-modulesegmentAngularSize/2. << " to " << FirstmoduleSegmentAngle+imodulesegm*moduleSegmentDeltaAngle+modulesegmentAngularSize/2. << ")" << endl;
673  moduleRingShape[istat][imodulesegm] = new TGeoTubeSeg (Form("moduleRing%dshape",istat+1,imodulesegm+1),moduleRingInnerRadius[istat],moduleRingOuterRadius[istat],moduleRingHalfThickness,FirstmoduleSegmentAngle+imodulesegm*moduleSegmentDeltaAngle-modulesegmentAngularSize/2.,FirstmoduleSegmentAngle+imodulesegm*moduleSegmentDeltaAngle+modulesegmentAngularSize/2. );
674  moduleRingVol[istat][imodulesegm] = new TGeoVolume (Form("Gem_moduleRing%d_Volume",istat+1,imodulesegm+1),moduleRingShape[istat][imodulesegm],gGeoMan->GetMedium("copper"));
675  moduleRingTrans[istat][imodulesegm] = new TGeoTranslation (0.,0.,3.853);
676  cout << "moduleRing " << moduleRingInnerRadius[istat] << " " << moduleRingOuterRadius[istat] << endl;
677  moduleRingCombi[istat][imodulesegm] = new TGeoCombiTrans (*moduleRingTrans[istat][imodulesegm],*dummyrot);
678  moduleRingCombi[istat][imodulesegm]->SetName(Form("Gem_moduleRing%d_Volume",istat+1,imodulesegm+1));
679  moduleRingCombi[istat][imodulesegm]->RegisterYourself();
680  moduleRingVol[istat][imodulesegm]->SetLineColor(kGreen);
681  //-----------------------------------------------------------------------------------------------------------------------------------------
682  DiskVol[istat]->AddNode(moduleRingVol[istat][imodulesegm],0,moduleRingCombi[istat][imodulesegm]);
683  //------------------------------------------------------------------------------------------------------------------------------------------
684  }
685  //---------------------------------Cooling Ring-------------------------------------------------------------------------------------------------------------
686  AlumiRingShape[istat] = new TGeoTube (Form("AlumiRing%dshape",istat+1),AlumiRingInnerRadius[istat],AlumiRingOuterRadius[istat],AlumiRingHalfThickness);
687  AlumiRingVol [istat] = new TGeoVolume(Form("Gem_AlumiRing%d_Volume",istat+1),AlumiRingShape[istat],gGeoMan->GetMedium("aluminium"));
688  AlumiRingTrans[istat] = new TGeoTranslation(0.,0.,3.853);
689  cout << "AlumiRing " << AlumiRingInnerRadius[istat] << " " << AlumiRingOuterRadius[istat] << endl;
690  AlumiRingCombi[istat] = new TGeoCombiTrans(*AlumiRingTrans[istat],*dummyrot);
691  AlumiRingCombi[istat]->SetName(Form("Gem_AlumiRing%d_Volume",istat+1));
692  AlumiRingCombi[istat]->RegisterYourself();
693  AlumiRingVol[istat]->SetLineColor(kCyan-9);
694  //----------------------------------------------------------------------------------------------------------------------------------------
695  DiskVol[istat]->AddNode(AlumiRingVol[istat],0,AlumiRingCombi[istat]);
696  //----------------------------------------------------------------------------------------------------------------------------------------
697  //------------------------- GEM tracker cover electronic module -----------------------------------------------------------------------------------------
698  coverRingShape[istat] = new TGeoTube (Form("coverRing%dshape",istat+1),coverRingInnerRadius[istat],coverRingOuterRadius[istat],coverRingHalfThickness);
699  coverRingVol [istat] = new TGeoVolume(Form("Gem_coverRing%d_Volume",istat+1),coverRingShape[istat],gGeoMan->GetMedium("GlassFiber"));
700  coverRingTrans[istat] = new TGeoTranslation(0.,0.,7.803);
701  cout << "coverRing " << coverRingInnerRadius[istat] << " " << coverRingOuterRadius[istat] << endl;
702  coverRingCombi[istat] = new TGeoCombiTrans(*coverRingTrans[istat],*dummyrot);
703  coverRingCombi[istat]->SetName(Form("Gem_coverRing%d_Volume",istat+1));
704  coverRingCombi[istat]->RegisterYourself();
705  coverRingVol[istat]->SetLineColor(kGreen+3);
706  //----------------------------------------------------------------------------------------------------------------------------------------
707  DiskVol[istat]->AddNode(coverRingVol[istat],0,coverRingCombi[istat]);
708  //----------------------------------------------------------------------------------------------------------------------------------------
710  //Double_t firstHLayersOffset = 0.;
711 
712  // for ( Int_t jlay = 0 ; jlay < NofHLayers ; jlay++ ) {
713  // cout << HLayersName[jlay].Data() << " -> " << HLayersThick[jlay] << endl;
714  // firstHLayersOffset += HLayersThick[jlay];
715  // }
716 
717  // cout << "total Hlayers thickness is " << firstHLayersOffset << endl;
718  // firstHLayersOffset = firstHLayersOffset/2.;
719  // firstHLayersOffset = -0.001*(TMath::Floor(1000.*firstHLayersOffset)); //floor: round to nearest integer
720  // cout << "first Hlayer offset is " << firstHLayersOffset << endl;
721 
722  // Double_t HZPosition = firstHLayersOffset;
723 
724  for ( Int_t jlay = 0 ; jlay < NofHLayers ; jlay++ ) {
725  // for ( Int_t jlay = 7 ; jlay < 8 ; jlay++ ) {
726  cout << "doing Hlayers " << jlay << endl;
727 
728  // HZPosition += HLayersThick[jlay]/2.;
729 
730  // if ( HLayersName[jlay].Contains("space") && HLayersThick[jlay] > 0.001 ) {
731  // cout << "***** THE THICK SPACE HLAYER IS AT " << HZPosition << endl;
732  // }
733  // if ( HLayersName[jlay].Contains("space") && HLayersName[jlay].Length() == 5 ) {
734  // HZPosition += LayerThick[jlay]/2.;
735  // continue;
736  // }
737 
738  cout << " got Hlayer " << HLayersName[jlay].Data() << endl;
739 
740  HLayersShapeTube[jlay][istat] = new TGeoTube (Form("T%dT%s",istat+1,HLayersName[jlay].Data()),HInnerRadius[jlay][istat],HOuterRadius[jlay][istat],HLayersThick[jlay]/2.);
741  HLayersShapeHT[jlay][istat] = new TGeoTube (Form("H%dH%s",istat+1,HLayersName[jlay].Data()),0.0,5.00,HLayersThick[jlay]/2.);
742  HLayersShapeHTM[jlay][istat] = new TGeoTube (Form("HTM%dHTM%s",istat+1,HLayersName[jlay].Data()),0.0,4.50,HLayersThick[jlay]/2.+0.0002);
743  HLayersShapeHTD[jlay][istat] = new TGeoTube (Form("HTD%dHTD%s",istat+1,HLayersName[jlay].Data()),0.0,1.90,HLayersThick[jlay]/2.+0.0001);
744  cout << "Tube name is " << HLayersShapeTube[jlay][istat]->GetName() << endl;
745  // cout << "TubeHTM name is " << HLayersShapeHTM[jlay][istat]->GetName() << endl;
746  HLayersShapeBox[jlay][istat] = new TGeoBBox(Form("B%dB%s",istat+1,HLayersName[jlay].Data()),HXBoxWidth,HOuterRadius[jlay][istat],HLayersThick[jlay]/2.);
747  HLayersShapePlate[jlay][istat] = new TGeoBBox(Form("P%dP%s",istat+1,HLayersName[jlay].Data()),HXPlateWidth,HYPlateWidth,HLayersThick[jlay]/2.+0.0001);
748 
749  HLayersTranstA[jlay][istat] = new TGeoTranslation("tA",HTX,HTY[jlay][istat],HTZ);
750  HLayersTranstA[jlay][istat] ->RegisterYourself();
751  HLayersTranstB[jlay][istat] = new TGeoTranslation("tB",HTX,-HTY[jlay][istat],HTZ);
752  HLayersTranstB[jlay][istat] ->RegisterYourself();
753  HLayersTranstC[jlay][istat] = new TGeoTranslation("tC",HTX,HTY[jlay][istat]+9.0,HTZ);
754  HLayersTranstC[jlay][istat] ->RegisterYourself();
755  HLayersTranstD[jlay][istat] = new TGeoTranslation("tD",HTX,HTY[jlay][istat]-9.0,HTZ);
756  HLayersTranstD[jlay][istat] ->RegisterYourself();
757  HLayersTranstE[jlay][istat] = new TGeoTranslation("tE",HTX,-HTY[jlay][istat]+9.0,HTZ);
758  HLayersTranstE[jlay][istat] ->RegisterYourself();
759  HLayersTranstF[jlay][istat] = new TGeoTranslation("tF",HTX,-HTY[jlay][istat]-9.0,HTZ);
760  HLayersTranstF[jlay][istat] ->RegisterYourself();
761 
762  HLayersShapecompos[jlay][istat] = new TGeoCompositeShape(Form("compos%dcompos%s",istat+1,HLayersName[jlay].Data()),
763  Form("T%dT%s+B%dB%s+H%dH%s-HTM%dHTM%s-(P%dP%s:tA)-(HTD%dHTD%s:tC)-(HTD%dHTD%s:tD)-(P%dP%s:tB)-(HTD%dHTD%s:tE)-(HTD%dHTD%s:tF)",
764  istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data(),
765  istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data(),
766  istat+1,HLayersName[jlay].Data(),istat+1,HLayersName[jlay].Data()));
767 
768  cout << "composite name is " << HLayersShapecompos[jlay][istat] -> GetName() << endl;
769 
770  TString HlayersMaterial = HLayersName[jlay].Data();
771  HlayersMaterial.Remove(0,HlayersMaterial.Last('_')+1);
772  cout << "THE HMATERIAL IS \"" << HlayersMaterial.Data() << "\"" << endl;
773  HLayersVolcomp[jlay][istat] = new TGeoVolume(Form("GEMHLayersCOMP%dGEMHLayersCOMP%s",istat+1,HLayersName[jlay].Data()),HLayersShapecompos[jlay][istat],gGeoMan->GetMedium(HlayersMaterial.Data()));
774  cout << "COMP name is " << HLayersVolcomp[jlay][istat] -> GetName() << endl;
775  cout << "Hlayersmaterial = " << HlayersMaterial.Data() << endl;
776 
777  if ( HlayersMaterial.Contains("carbon" ) )
778  HLayersVolcomp[jlay][istat]->SetLineColor(kPink);
779  if ( HlayersMaterial.Contains("GlassFiber" ) )
780  HLayersVolcomp[jlay][istat]->SetLineColor(kGreen+3);
781 
782  cout << "STATION " << istat << " LAYER " << jlay << " POSITION " << HZPosition[jlay][istat] << endl;
783 
784  HLayersTrans[jlay][istat] = new TGeoTranslation(0.0,0.0,HZPosition[jlay][istat]);
785  HLayersCombi[jlay][istat] = new TGeoCombiTrans(*HLayersTrans[jlay][istat],*dummyrot);
786  HLayersCombi[jlay][istat]->SetName(Form("GEMHLayersCOMP%dGEMHLayersCOMP%s",istat+1,HLayersName[jlay].Data()));
787  HLayersCombi[jlay][istat]->RegisterYourself();
788  DiskVol[istat]->AddNode( HLayersVolcomp[jlay][istat],0,HLayersCombi[jlay][istat] );
789  }
791  //--------------------------------------------------- drift layers-----------------------------------------------------------------------------------------
792 
793  Int_t sensorNumber = 0;
794 
795  for ( Int_t slay = 0 ; slay < NofSensLayers ; slay++ ) {
796  cout << "doing Senslayer " << slay << endl;
797  //SensZPosition[slay][istat] ++ ;
798  if ( SensLayerName[slay].Contains("space") && SensLayerThick[slay] > 0.0 ) {
799  cout << "***** THE THICK SPACE SensLAYER IS AT " << SensZPosition[slay][istat] << endl;
800  }
801  if ( SensLayerName[slay].Contains("space") && SensLayerName[slay].Length() == 5 ) {
802  //SensZPosition[slay][istat] ++ ;
803  continue;
804  }
805 
806  cout << " got layer : " << SensLayerName[slay].Data() << endl;
807 
808 
809  Double_t segPhiSpan = 360./(Double_t(DiskNFoils[istat]));
810  Double_t segBegin = 90.;
811  cout << "will do loop over segments" << endl;
812 
813  for ( Int_t iseg = 0 ; iseg < 1 ; iseg++ ) {
814  cout << "segment " << iseg << endl;
815  SensDiskLayersShapeA[slay][istat][iseg] = new TGeoTube(Form("sdisk%dseg%d%sshape",istat+1,iseg+1,SensLayerName[slay].Data()),
816  SensInnerRadius[slay][istat],SensOuterRadius[slay][istat],
817  SensLayerThick[slay]/2.);
818  SensDiskLayersShapeB[slay][istat][iseg] = new TGeoBBox(Form("srobo%dseg%d%sshape",istat+1,iseg+1,SensLayerName[slay].Data()),
819  sMiddleROBarHfTh[istat],
820  SensOuterRadius[slay][istat],
821  SensLayerThick[slay]);
822  SensDiskLayersSubtr[slay][istat][iseg] = new TGeoSubtraction(SensDiskLayersShapeA[slay][istat][iseg],
823  SensDiskLayersShapeB[slay][istat][iseg]);
824 
825  SensDiskLayersShapeC[slay][istat][iseg] = new TGeoCompositeShape(Form("scomp%dseg%d%sshape",istat+1,iseg+1,SensLayerName[slay].Data()),
826  SensDiskLayersSubtr[slay][istat][iseg]);
827  segBegin += segPhiSpan;
828  cout << " segBegin " << segBegin << endl;
829 
830  SensDiskLayersShapeHole[slay][istat][iseg] = new TGeoTube(Form("sHole%dseg%d%sshape",istat+1,iseg+1,SensLayerName[slay].Data()),0.0,3.80,SensLayerThick[slay]+0.01);
831 
832  SensDiskLayersTranshA[slay][istat][iseg] = new TGeoTranslation("shA",sHoleTX,sHoleTY,sHoleTZ);
833  SensDiskLayersTranshA[slay][istat][iseg] ->RegisterYourself();
834  SensDiskLayersTranshB[slay][istat][iseg] = new TGeoTranslation("shB",sHoleTX,-sHoleTY,sHoleTZ);
835  SensDiskLayersTranshB[slay][istat][iseg] ->RegisterYourself();
836 
837  SensDiskLayersShapecompos[slay][istat][iseg] = new TGeoCompositeShape(Form("scompos%dseg%d%sshape",istat+1,iseg+1,SensLayerName[slay].Data()),
838  Form("scomp%dseg%d%sshape-(sHole%dseg%d%sshape:shA)-(sHole%dseg%d%sshape:shB)",
839  istat+1,iseg+1,SensLayerName[slay].Data(),istat+1,iseg+1,SensLayerName[slay].Data(),istat+1,iseg+1,SensLayerName[slay].Data()));
840  TString SenslayerMaterial = SensLayerName[slay].Data();
841  SenslayerMaterial.Remove(0,SenslayerMaterial.Last('_')+1);
842  cout << "THE MATERIAL IS \"" << SenslayerMaterial.Data() << "\"" << endl;
843  SensDiskLayersVol[slay][istat][iseg] = new TGeoVolume(Form("GemSen_Disk%d_Seg%d_%s",istat+1,iseg+1,SensLayerName[slay].Data()),
844  SensDiskLayersShapecompos[slay][istat][iseg],
845  gGeoMan->GetMedium(SenslayerMaterial.Data()));
846 
847  cout << "Senslayer material = " << SenslayerMaterial.Data() << endl;
848  if ( SenslayerMaterial.Contains("GEMmixture" ) )
849  SensDiskLayersVol[slay][istat][iseg]->SetLineColor(kYellow);
850 
851  SensDiskLayersTrans[slay][istat][iseg] = new TGeoTranslation(0.,0.,SensZPosition[slay][istat]);
852  SensDiskLayersCombi[slay][istat][iseg] = new TGeoCombiTrans(*SensDiskLayersTrans[slay][istat][iseg],*dummyrot);
853  SensDiskLayersCombi[slay][istat][iseg]->SetName(Form("GemSen_Disk%d_Seg%d_%s",istat+1,iseg+1,SensLayerName[slay].Data()));
854  SensDiskLayersCombi[slay][istat][iseg]->RegisterYourself();
855  DiskVol[istat]->AddNode(SensDiskLayersVol[slay][istat][iseg],0,SensDiskLayersCombi[slay][istat][iseg]);
856  }
857 //-------------------------------------------------------------------------------------------------------------------------------------------------------
858  cout << "Svolume " << SensLayerName[slay] << " from "
859  << setprecision(10) << DiskZPosition[istat]+SensZPosition[slay][istat]-SensLayerThick[slay]/2. << " to "
860  << setprecision(10) << DiskZPosition[istat]+SensZPosition[slay][istat]+SensLayerThick[slay]/2. << endl;
861 
862  if ( SensLayerName[slay].Contains("Gem") && SensLayerName[slay].Contains("Sensor") ) {
863  Double_t newRadius = SensInnerRadius[slay][istat];
864  Double_t nofStrips = 0;
865 
866  cout << "srad = " << SensInnerRadius[slay][istat] << " pitch = " << SensorStripPitch[sensorNumber][0] << " for sensor " << sensorNumber << endl;
867  if ( SensorStripType[sensorNumber] != 2 ) {
868  nofStrips = TMath::Ceil(2.*TMath::Pi()*SensInnerRadius[slay][istat]/SensorStripPitch[sensorNumber][0]);
869  newRadius = nofStrips*SensorStripPitch[sensorNumber][0]/2./TMath::Pi();
870  }
871  cout << "!!!! " << istat << " " << slay << " > there shall be " << nofStrips << " strips here so the radius should be " << newRadius << endl;
872  pout << " " << sensorNumber+1 << ", " << SensorStripType[sensorNumber] << ", "
873  << setw(9) << 0. << ", "
874  << setw(9) << 0. << ", "
875  << setw(9) << DiskZPosition[istat]+SensZPosition[slay][istat] << ", "
876  << setw(9) << 0. << ", "
877  << setw(9) << newRadius << ", "
878  << setw(9) << SensOuterRadius[slay][istat] << ", "
879  << setw(9) << SensLayerThick[slay] << ", "
880  << setw(9) << SensorStripAngle[sensorNumber][0] << ", "
881  //<< setw(9) << SensorStripAngle[sensorNumber][1] << ", "
882  << setw(9) << sMiddleROBarHfTh[istat] << ", "
883  << setw(9) << SensorStripPitch[sensorNumber][0] << ", "
884  << setw(9) << SensorStripPitch[sensorNumber][1] << ((istat==NofDisks-1 && sensorNumber==1)?"":", \\")
885  << endl;
886  sensorNumber++;
887  }
888 
889  SensZPosition[slay][istat] ++ ;
890 
891  }
893 
894  Double_t layerPosition = firstLayerOffset;//-LayerThick[0]/2.;
895 
896  Int_t msensorNumber = 0;
897 
898  for ( Int_t ilay = 0 ; ilay < NofLayers ; ilay++ ) {
899  cout << "doing layer " << ilay << endl;
900  layerPosition += LayerThick[ilay]/2.;
901  if ( LayerName[ilay].Contains("space") && LayerThick[ilay] > 0.0 ) {
902  cout << "***** THE THICK SPACE LAYER IS AT " << layerPosition << endl;
903  }
904  if ( LayerName[ilay].Contains("space") && LayerName[ilay].Length() == 5 ) {
905  layerPosition += LayerThick[ilay]/2.;
906  continue;
907  }
908 
909  cout << " got layer : " << LayerName[ilay].Data() << endl;
910 
911  Double_t msegPhiSpan = 360./(Double_t(DiskNFoils[istat]));
912  Double_t msegBegin = 90.;
913  cout << "will do loop over segments" << endl;
914  for ( Int_t miseg = 0 ; miseg < 1 ; miseg++ ) {
915  cout << "segment " << miseg << endl;
916  DiskLayersShapeA[ilay][istat][miseg] = new TGeoTube(Form("disk%dseg%d%sshape",istat+1,miseg+1,LayerName[ilay].Data()),
917  DiskInnerRadius[ilay][istat],DiskOuterRadius[ilay][istat],
918  LayerThick[ilay]/2.);
919  DiskLayersShapeB[ilay][istat][miseg] = new TGeoBBox (Form("robo%dseg%d%sshape",istat+1,miseg+1,LayerName[ilay].Data()),
920  MiddleROBarHfTh[istat],
921  DiskOuterRadius[ilay][istat],
922  LayerThick[ilay]);
923  DiskLayersSubtr[ilay][istat][miseg] = new TGeoSubtraction(DiskLayersShapeA[ilay][istat][miseg],
924  DiskLayersShapeB[ilay][istat][miseg]);
925 
926  DiskLayersShapeC[ilay][istat][miseg] = new TGeoCompositeShape(Form("comp%dseg%d%sshape",istat+1,miseg+1,LayerName[ilay].Data()),
927  DiskLayersSubtr[ilay][istat][miseg]);
928  msegBegin += msegPhiSpan;
929  cout << " msegBegin " << msegBegin << endl;
930 
931  DiskLayersShapeHole[ilay][istat][miseg] = new TGeoTube(Form("Hole%dseg%d%sshape",istat+1,miseg+1,LayerName[ilay].Data()),0.0,3.80,LayerThick[ilay]+0.01);
932 
933  DiskLayersTranshA[ilay][istat][miseg] = new TGeoTranslation("hA",HoleTX,HoleTY,HoleTZ);
934  DiskLayersTranshA[ilay][istat][miseg] ->RegisterYourself();
935  DiskLayersTranshB[ilay][istat][miseg] = new TGeoTranslation("hB",HoleTX,-HoleTY,HoleTZ);
936  DiskLayersTranshB[ilay][istat][miseg] ->RegisterYourself();
937 
938  DiskLayersShapecompos[ilay][istat][miseg] = new TGeoCompositeShape(Form("compos%dseg%d%sshape",istat+1,miseg+1,LayerName[ilay].Data()),
939  Form("comp%dseg%d%sshape-(Hole%dseg%d%sshape:hA)-(Hole%dseg%d%sshape:hB)",
940  istat+1,miseg+1,LayerName[ilay].Data(),istat+1,miseg+1,LayerName[ilay].Data(),istat+1,miseg+1,LayerName[ilay].Data()));
941 
942 
943  TString layerMaterial = LayerName[ilay].Data();
944  layerMaterial.Remove(0,layerMaterial.Last('_')+1);
945  cout << "THE MATERIAL IS \"" << layerMaterial.Data() << "\"" << endl;
946  DiskLayersVol[ilay][istat][miseg] = new TGeoVolume(Form("Gem_Disk%d_Seg%d_%s",istat+1,miseg+1,LayerName[ilay].Data()),
947  DiskLayersShapecompos[ilay][istat][miseg],
948  gGeoMan->GetMedium(layerMaterial.Data()));
949 
950  cout << "layer material = " << layerMaterial.Data() << endl;
951  if ( layerMaterial.Contains("air" ) )
952  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kWhite);kGray+1);
953  if ( layerMaterial.Contains("copper" ) )
954  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kOrange+1);
955  if ( layerMaterial.Contains("kapton" ) )
956  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kOrange+2);
957  if ( layerMaterial.Contains("aluminium" ) )
958  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kCyan-9);
959  if ( layerMaterial.Contains("GEMmixture" ) )
960  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kYellow);
961  if ( layerMaterial.Contains("carbon" ) )
962  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kPink);
963  if ( layerMaterial.Contains("GlassFiber" ) )
964  DiskLayersVol[ilay][istat][miseg]->SetLineColor(kGreen+3);
965 
966  DiskLayersTrans[ilay][istat][miseg] = new TGeoTranslation(0.,0.,layerPosition);
967  DiskLayersCombi[ilay][istat][miseg] = new TGeoCombiTrans(*DiskLayersTrans[ilay][istat][miseg],*dummyrot);
968  DiskLayersCombi[ilay][istat][miseg]->SetName(Form("Gem_Disk%d_Seg%d_%s",istat+1,miseg+1,LayerName[ilay].Data()));
969  DiskLayersCombi[ilay][istat][miseg]->RegisterYourself();
970  DiskVol[istat]->AddNode(DiskLayersVol[ilay][istat][miseg],0,DiskLayersCombi[ilay][istat][miseg]);
971 
972  }
973  //-----------------------------------------------------------------------------------------------------------------------------------------------------------
974  cout << "mvolume " << LayerName[ilay] << " from "
975  << setprecision(10) << DiskZPosition[istat]+layerPosition-LayerThick[ilay]/2. << " to "
976  << setprecision(10) << DiskZPosition[istat]+layerPosition+LayerThick[ilay]/2. << endl;
977 
978  if ( LayerName[ilay].Contains("Gem") && LayerName[ilay].Contains("Sensor") ) {
979  Double_t mnewRadius = DiskInnerRadius[ilay][istat];
980  Double_t mnofStrips = 0;
981 
982  cout << "mrad = " << DiskInnerRadius[ilay][istat] << " pitch = " << SensorStripPitch[msensorNumber][0] << " for sensor " << msensorNumber << endl;
983  if ( SensorStripType[msensorNumber] != 2 ) {
984  mnofStrips = TMath::Ceil(2.*TMath::Pi()*DiskInnerRadius[ilay][istat]/SensorStripPitch[msensorNumber][0]);
985  mnewRadius = mnofStrips*SensorStripPitch[msensorNumber][0]/2./TMath::Pi();
986  }
987  cout << "!!!! " << istat << " " << ilay << " > there shall be " << mnofStrips << " strips here so the radius should be " << mnewRadius << endl;
988  pout << " " << msensorNumber+1 << ", " << SensorStripType[msensorNumber] << ", "
989  << setw(9) << 0. << ", " // setw:sets the field width to be used on output operations
990  << setw(9) << 0. << ", "
991  << setw(9) << DiskZPosition[istat]+layerPosition << ", "
992  << setw(9) << 0. << ", "
993  << setw(9) << mnewRadius << ", "
994  << setw(9) << DiskOuterRadius[ilay][istat] << ", "
995  << setw(9) << LayerThick[ilay] << ", "
996  << setw(9) << SensorStripAngle[msensorNumber][0] << ", "
997  // << setw(9) << SensorStripAngle[msensorNumber][1] << ", "
998  << setw(9) << MiddleROBarHfTh[istat] << ", "
999  << setw(9) << SensorStripPitch[msensorNumber][0] << ", "
1000  << setw(9) << SensorStripPitch[msensorNumber][1] << ((istat==NofDisks-1&&msensorNumber==1)?"":", \\")
1001  << endl;
1002  msensorNumber++;
1003  }
1004 
1005  layerPosition += LayerThick[ilay]/2.;
1006  }
1007 //---------------------------------------------------------------------------------------------------------------------------------------------------------------
1008  SubunitVol->AddNode(DiskVol[istat],0,DiskCombi[istat]);
1009 
1010  }
1012  pout << "TrackFinderOnHits_ParThetaA: Double_t 59.4" << endl
1013  << "TrackFinderOnHits_ParThetaB: Double_t -0.02" << endl
1014  << "TrackFinderOnHits_ParTheta0: Double_t 56.1372" << endl
1015  << "TrackFinderOnHits_ParTheta1: Double_t -0.000564362" << endl
1016  << "TrackFinderOnHits_ParTheta2: Double_t -0.181828" << endl
1017  << "TrackFinderOnHits_ParTheta3: Double_t 0.284289" << endl
1018  << "TrackFinderOnHits_ParRadPhi0:Double_t 0.9944432" << endl
1019  << "TrackFinderOnHits_ParRadPhi2:Double_t -0.000590706" << endl
1020  << "TrackFinderOnHits_ParMat0: Double_t \\" << endl
1021  // << " -2.31333e-6, 0.00067035, 0.10173" << endl
1022  << " -2.35034328e-6, 0.0006810756, 0.10335768" << endl
1023  << "TrackFinderOnHits_ParMat1: Double_t \\" << endl
1024  // << " -7.46844e-10, -6.6696e-7, 0.000736672" << endl
1025  << " -7.58793504e-10, -6.7763136e-7, 0.000748458752" << endl
1026  << "##########################################################################################" << flush;
1028  top->AddNode(SubunitVol,0,new TGeoCombiTrans());
1029 
1030  // top->CheckOverlaps(0.0001, "");
1031  // gGeoManager->CheckOverlaps(0.0001,""); // [cm]
1032  // gGeoManager->CheckGeometryFull();
1033 
1034  // TObjArray *listOfOverlaps = gGeoManager->GetListOfOverlaps();
1035  // cout << "************************************************" << endl;
1036  // cout<<listOfOverlaps->GetEntries()<<endl;
1037  // listOfOverlaps->Print();
1038  // cout << "************************************************" << endl;
1039 
1040  // gGeoManager->CheckOverlaps();
1041  // gGeoManager->PrintOverlaps();
1042 
1043  gGeoMan->CloseGeometry();
1044  top->Write();
1045  fi->Close();
1046  //gGeoManager->Export(outfile);
1047 
1048  //top->Raytrace();
1049  top->Draw("ogl");
1050  //top->Draw();
1051 
1052  pout.close();
1053 
1054 return 0;
1055 }
TGeoRotation * dummyrot
FairGeoLoader * geoLoad
FairGeoMedia * Media
TGeoManager * gGeoMan
FairGeoMedium * CbmMediumCarbon
TGeoVolume * top
FairGeoMedium * CbmMediumAluminium
TGeoVolume * SubunitVol
FairGeoBuilder * geobuild
TFile * fi
Double_t
TString medium
FairGeoMedium * CbmMediumAir
FairGeoMedium * CbmMediumPWO
FairGeoInterface * geoFace
vDisk SetLineColor(colYellow)
Double_t Pi
TString outfile