ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorConstruction.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "DetectorConstruction.hh"
34 #include "DetectorMessenger.hh"
35 
36 #include "G4Material.hh"
37 #include "G4Tubs.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4PVPlacement.hh"
40 
41 #include "G4GeometryManager.hh"
42 #include "G4PhysicalVolumeStore.hh"
43 #include "G4LogicalVolumeStore.hh"
44 #include "G4SolidStore.hh"
45 
46 #include "G4UnitsTable.hh"
47 #include "G4PhysicalConstants.hh"
48 #include "G4SystemOfUnits.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 :fMaterial_World(0), fMaterial_Frame(0),
54  fMaterial_ExitWindow(0), fMaterial_ScatterFoil(0), fMaterial_MonitorChbr(0),
55  fMaterial_Bag(0), fMaterial_Gas(0), fMaterial_Ring(0),
56  fPvol_World(0), fPvol_Frame(0), fDetectorMessenger(0)
57 {
58  // materials
60 
61  // geometry
63 
64  // create commands for interactive definition of the calorimeter
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 {
72  delete fDetectorMessenger;
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  return ConstructVolumes();
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86 G4double a, z, density;
87 G4int ncomponents, natoms;
88 G4double fractionmass;
89 G4double temperature, pressure;
90 
91 // define Elements
92 //
93 G4Element* H = new G4Element("Hydrogen", "H", z= 1, a= 1.0079*g/mole);
94 G4Element* He = new G4Element("Helium", "He", z= 2, a= 4.0026*g/mole);
95 G4Element* Be = new G4Element("Beryllium","Be", z= 4, a= 9.1218*g/mole);
96 G4Element* C = new G4Element("Carbon", "C", z= 6, a= 12.0107*g/mole);
97 G4Element* N = new G4Element("Nitrogen", "N", z= 7, a= 14.0067*g/mole);
98 G4Element* O = new G4Element("Oxygen", "O", z= 8, a= 15.9994*g/mole);
99 G4Element* Al = new G4Element("Aluminium","Al", z=13, a= 26.9815*g/mole);
100 G4Element* Ar = new G4Element("Argon", "Ar", z=18, a= 39.9480*g/mole);
101 G4Element* Ti = new G4Element("Titanium", "Ti", z=22, a= 47.8670*g/mole);
102 G4Element* Va = new G4Element("Vanadium", "Va", z=23, a= 50.9415*g/mole);
103 G4Element* Cu = new G4Element("Copper", "Cu", z=29, a= 63.5460*g/mole);
104 G4Element* Ta = new G4Element("Tantalum", "Ta", z=73, a= 180.9479*g/mole);
105 G4Element* Au = new G4Element("Gold", "Au", z=79, a= 196.9666*g/mole);
106 
107 // Air
108 //
109 G4Material* Air =
110 new G4Material("Air", density= 1.205*mg/cm3, ncomponents=4,
111  kStateGas, 293.*kelvin, 1.*atmosphere);
112 Air->AddElement(C, fractionmass=0.000124);
113 Air->AddElement(N, fractionmass=0.755267);
114 Air->AddElement(O, fractionmass=0.231782);
115 Air->AddElement(Ar,fractionmass=0.012827);
116 
117 // Titanium
118 //
119 G4Material* Titanium =
120 new G4Material("Titanium", density= 4.42*g/cm3, ncomponents=3);
121 Titanium->AddElement(Ti, fractionmass=0.90);
122 Titanium->AddElement(Al, fractionmass=0.06);
123 Titanium->AddElement(Va, fractionmass=0.04);
124 
125 // Mylar
126 //
127 G4Material* Mylar =
128 new G4Material("Mylar", density= 1.40*g/cm3, ncomponents=3);
129 Mylar->AddElement(H, natoms=4);
130 Mylar->AddElement(C, natoms=5);
131 Mylar->AddElement(O, natoms=2);
132 
133 // Helium
134 //
135 G4Material* Helium =
136 new G4Material("Helium", density= 0.166*mg/cm3, ncomponents=1,
137  kStateGas, 293.*kelvin, 1.*atmosphere);
138 Helium->AddElement(He, fractionmass=1.0);
139 
140 // Aluminium
141 //
142 G4Material* Aluminium =
143 new G4Material("Aluminium", density= 2.7*g/cm3, ncomponents=1);
144 Aluminium->AddElement(Al, fractionmass=1.0);
145 
146 // Beryllium
147 //
148 G4Material* Beryllium =
149 new G4Material("Beryllium", density= 1.85*g/cm3, ncomponents=1);
150 Beryllium->AddElement(Be, fractionmass=1.0);
151 
152 //Graphite
153 //
154 G4Material* Graphite =
155 new G4Material("Graphite", density= 2.18*g/cm3, ncomponents=1);
156 Graphite->AddElement(C, fractionmass=1.0);
157 
158 // Copper
159 //
160 G4Material* Copper =
161 new G4Material("Copper", density= 8.92*g/cm3, ncomponents=1);
162 Copper->AddElement(Cu, fractionmass=1.0);
163 
164 // Tantalum
165 //
166 G4Material* Tantalum =
167 new G4Material("Tantalum", density= 16.65*g/cm3, ncomponents=1);
168 Tantalum->AddElement(Ta, fractionmass=1.0);
169 
170 // Gold
171 //
172 G4Material* Gold =
173 new G4Material("Gold", density= 19.30*g/cm3, ncomponents=1);
174 Gold->AddElement(Au, fractionmass=1.0);
175 
176 // example of vacuum
177 //
178 density = universe_mean_density; //from PhysicalConstants.h
179 pressure = 3.e-18*pascal;
180 temperature = 2.73*kelvin;
181 G4Material* Vacuum =
182 new G4Material("Galactic", z=1, a=1.01*g/mole,density,
183  kStateGas,temperature,pressure);
184 
185 //print
186 //
188 
189 
190 // assign materials
191 //
192 fMaterial_World = Vacuum;
193 fMaterial_Frame = Air;
194 fMaterial_ExitWindow = Titanium;
196 fMaterial_MonitorChbr = Mylar;
197 fMaterial_Bag = Mylar;
198 fMaterial_Gas = Helium;
199 fMaterial_Ring = Aluminium;
200 }
201 
202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203 
205 {
206  fZfront_ExitWindow = 0.0*um;
207  fThickness_ExitWindow = 41.2*um;
208 
209  fZfront_ScatterFoil = 2.65*cm;
211 
212  fZfront_MonitorChbr = 50.*mm;
213  fThickness_MonitorChbr = 112.7*um;
214 
215  fZfront_Bag = 64.975*mm;
216  fThickness_Bag = 110.0050*cm;
217 
218  fThickness_Gas = 110.*cm;
219 
220  fThickness_Ring = 14.*mm;
221  fInnerRadius_Ring = 20.*cm;
222 
223  fZfront_Frame = 2.0*um;
224  fThickness_Frame = 118.2*cm;
225 
227  fRadius_World = 23.3*cm;
228 }
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
231 
233 {
234  // Cleanup old geometry
235  //
240 
241  // World
242  //
243  G4Tubs*
244  svol_World = new G4Tubs("World", //name
245  0*cm, fRadius_World, //r1, r2
246  0.5*fThickness_World, //half-length
247  0., twopi); //theta1, theta2
248 
250  lvol_World = new G4LogicalVolume(svol_World, //its solid
251  fMaterial_World, //its material
252  "World"); //its name
253 
254  fPvol_World = new G4PVPlacement(0, //no rotation
255  G4ThreeVector(), //no translation
256  lvol_World, //its logical volume
257  "World", //its name
258  0, //its mother volume
259  false, //no boolean operation
260  0); //copy number
261 
262  // Frame
263  //
264  G4Tubs*
265  svol_Frame = new G4Tubs("Frame", //name
266  0*cm, fRadius_World, //r1, r2
267  0.5*fThickness_Frame, //half-length
268  0., twopi); //theta1, theta2
269 
271  lvol_Frame = new G4LogicalVolume(svol_Frame, //its solid
272  fMaterial_Frame, //its material
273  "Frame"); //its name
274 
275  G4double
277 
278  fPvol_Frame = new G4PVPlacement(0, //no rotation
279  G4ThreeVector(0,0,zpos), //translation
280  lvol_Frame, //its logical volume
281  "Frame", //its name
282  lvol_World, //its mother volume
283  false, //no boolean operation
284  0); //copy number
285 
286 
287  // ExitWindow
288  //
289  G4Tubs*
290  svol_ExitWindow = new G4Tubs("ExitWindow", //name
291  0*cm, fRadius_World, //r1, r2
292  0.5*fThickness_ExitWindow, //half-length
293  0., twopi); //theta1, theta2
294 
296  lvol_ExitWindow = new G4LogicalVolume(svol_ExitWindow, //solid
297  fMaterial_ExitWindow, //material
298  "ExitWindow"); //name
299 
301 
302  new G4PVPlacement(0, //no rotation
303  G4ThreeVector(0,0,zpos), //translation
304  lvol_ExitWindow, //logical volume
305  "ExitWindow", //name
306  lvol_Frame, //mother volume
307  false, //no boolean operation
308  0); //copy number
309 
310  // Monitor Chamber
311  //
312  G4Tubs*
313  svol_MonitorChbr = new G4Tubs("MonitorChbr", //name
314  0*cm, fRadius_World, //r1, r2
315  0.5*fThickness_MonitorChbr, //half-length
316  0., twopi); //theta1, theta2
317 
319  lvol_MonitorChbr = new G4LogicalVolume(svol_MonitorChbr,//solid
320  fMaterial_MonitorChbr, //material
321  "MonitorChbr"); //name
322 
324 
325  new G4PVPlacement(0, //no rotation
326  G4ThreeVector(0,0,zpos), //translation
327  lvol_MonitorChbr, //logical volume
328  "MonitorChbr", //name
329  lvol_Frame, //mother volume
330  false, //no boolean operation
331  0); //copy number
332 
333 
334  // Bag
335  //
336  G4Tubs*
337  svol_Bag = new G4Tubs("Bag", //name
338  0*cm, fRadius_World, //r1, r2
339  0.5*fThickness_Bag, //half-length
340  0., twopi); //theta1, theta2
341 
343  lvol_Bag = new G4LogicalVolume(svol_Bag, //solid
344  fMaterial_Bag, //material
345  "Bag"); //name
346 
347  zpos = fZfront_Bag + 0.5*fThickness_Bag - 0.5*fThickness_Frame;
348 
349  new G4PVPlacement(0, //no rotation
350  G4ThreeVector(0,0,zpos), //translation
351  lvol_Bag, //logical volume
352  "Bag", //name
353  lvol_Frame, //mother volume
354  false, //no boolean operation
355  0); //copy number
356 
357 
358  // Gas
359  //
360  G4Tubs*
361  svol_Gas = new G4Tubs("Gas", //name
362  0*cm, fRadius_World, //r1, r2
363  0.5*fThickness_Gas, //half-length
364  0., twopi); //theta1, theta2
365 
367  lvol_Gas = new G4LogicalVolume(svol_Gas, //solid
368  fMaterial_Gas, //material
369  "Gas"); //name
370 
371 
372  new G4PVPlacement(0, //no rotation
373  G4ThreeVector(), //no translation
374  lvol_Gas, //logical volume
375  "Gas", //name
376  lvol_Bag, //mother volume
377  false, //no boolean operation
378  0); //copy number
379 
380 
381  // Rings
382  //
383  G4Tubs*
384  svol_Ring = new G4Tubs("Ring", //name
386  0.5*fThickness_Ring, //half-length
387  0., twopi); //theta1, theta2
388 
390  lvol_Ring = new G4LogicalVolume(svol_Ring, //solid
391  fMaterial_Ring, //material
392  "Ring"); //name
393 
394  zpos = 0.5*(fThickness_Gas - fThickness_Ring);
395 
396  new G4PVPlacement(0, //no rotation
397  G4ThreeVector(0,0,zpos), //translation
398  lvol_Ring, //logical volume
399  "Ring", //name
400  lvol_Gas, //mother volume
401  false, //no boolean operation
402  1); //copy number
403 
404  new G4PVPlacement(0, //no rotation
405  G4ThreeVector(0,0,-zpos), //translation
406  lvol_Ring, //logical volume
407  "Ring", //name
408  lvol_Gas, //mother volume
409  false, //no boolean operation
410  2); //copy number
411 
412 
413  // ScatterFoil (only if it is not Air)
414  //
416  {
417  G4Tubs*
418  svol_ScatterFoil = new G4Tubs("ScatterFoil", //name
419  0*cm, fRadius_World, //r1, r2
420  0.5*fThickness_ScatterFoil, //half-length
421  0., twopi); //theta1, theta2
422 
424  lvol_ScatterFoil = new G4LogicalVolume(svol_ScatterFoil,//solid
425  fMaterial_ScatterFoil, //material
426  "ScatterFoil"); //name
427 
429 
430  new G4PVPlacement(0, //no rotation
431  G4ThreeVector(0,0,zpos), //translation
432  lvol_ScatterFoil, //logical volume
433  "ScatterFoil", //name
434  lvol_Frame, //mother volume
435  false, //no boolean operation
436  0); //copy number
437  }
438 
439  PrintGeometry();
440 
441  //always return the physical World
442  //
443  return fPvol_World;
444 }
445 
446 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
447 
449 {
450 
451  // choose printing format
452  std::ios::fmtflags mode = G4cout.flags();
453  G4cout.setf(std::ios::fixed,std::ios::floatfield);
454  G4int prec = G4cout.precision(6);
455 
456  G4cout << "\n \t \t" << "Material \t" << "Z_front \t" << "Thickness \n";
457 
458  G4cout << "\n ExitWindow \t" << fMaterial_ExitWindow->GetName()
459  << "\t" << G4BestUnit(fZfront_ExitWindow,"Length")
460  << "\t" << G4BestUnit(fThickness_ExitWindow,"Length");
461 
463  G4cout << "\n ScatterFoil \t" << fMaterial_ScatterFoil->GetName() << "\t"
464  << "\t" << G4BestUnit(fZfront_ScatterFoil,"Length")
465  << "\t" << G4BestUnit(fThickness_ScatterFoil,"Length");
466  }
467 
468  G4cout << "\n MonitorChbr \t" << fMaterial_MonitorChbr->GetName() << "\t"
469  << "\t" << G4BestUnit(fZfront_MonitorChbr,"Length")
470  << "\t" << G4BestUnit(fThickness_MonitorChbr,"Length");
471 
472  G4double thickBagWindow = 0.5*(fThickness_Bag - fThickness_Gas);
473  G4double zfrontGas = fZfront_Bag + thickBagWindow;
474  G4double zfrontBagWindow2 = zfrontGas + fThickness_Gas;
475 
476  G4cout << "\n BagWindow1 \t" << fMaterial_Bag->GetName() << "\t"
477  << "\t" << G4BestUnit(fZfront_Bag,"Length")
478  << "\t" << G4BestUnit(thickBagWindow,"Length");
479 
480  G4cout << "\n Gas \t" << fMaterial_Gas->GetName() << "\t"
481  << "\t" << G4BestUnit(zfrontGas,"Length")
482  << "\t" << G4BestUnit(fThickness_Gas,"Length");
483 
484  G4cout << "\n BagWindow2 \t" << fMaterial_Bag->GetName() << "\t"
485  << "\t" << G4BestUnit(zfrontBagWindow2,"Length")
486  << "\t" << G4BestUnit(thickBagWindow,"Length");
487 
488  G4cout << "\n ScoringPlane \t" << fMaterial_Frame->GetName() << "\t"
489  << "\t" << G4BestUnit(fThickness_Frame,"Length") << "\n" << G4endl;
490 
491  // restaure default formats
492  G4cout.setf(mode,std::ios::floatfield);
493  G4cout.precision(prec);
494 }
495 
496 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
497 
499 {
500  // search the material by its name
501  G4Material* pMaterial = G4Material::GetMaterial(material);
502 
503  if (pMaterial) fMaterial_ScatterFoil = pMaterial;
504 }
505 
506 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
507 
509 {
511 }
512 
513 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
514 
515 #include "G4RunManager.hh"
516 
518 {
520 }
521 
522 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
523