FairRoot/PandaRoot
Functions
create1StationGem_lastStation_v2.C File Reference

Go to the source code of this file.

Functions

Int_t create1StationGem_lastStation_v2 ()
 

Function Documentation

Int_t create1StationGem_lastStation_v2 ( )

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