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 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 #include "G4Material.hh"
37 #include "G4NistManager.hh"
38 
39 #include "G4Box.hh"
40 #include "G4Tubs.hh"
41 #include "G4LogicalVolume.hh"
42 #include "G4PVPlacement.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 #include "G4RunManager.hh"
49 
50 #include "G4UnitsTable.hh"
51 #include "G4SystemOfUnits.hh"
52 #include "G4PhysicalConstants.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58  fAbsorMaterial(0), fLAbsor(0), fContainMaterial(0), fLContain(0),
59  fWorldMaterial(0), fPWorld(0), fDetectorMessenger(0)
60 {
61  fAbsorRadius = 15*mm;
62  fAbsorLength = 60*mm;
63  fContainThickness = 2.4*mm;
65  SetAbsorMaterial ("BeO");
66  SetContainMaterial("Stainless-Steel");
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 { delete fDetectorMessenger;}
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  return ConstructVolumes();
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  G4int ncomponents, natoms;
87 
88  G4Element* Be = new G4Element("Beryllium","Be" , 4., 9.01*g/mole);
89  G4Element* N = new G4Element("Nitrogen" ,"N" , 7., 14.01*g/mole);
90  G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole);
91  G4Element* Cr = new G4Element("Chromium" ,"Cr" , 24., 51.99*g/mole);
92  G4Element* Fe = new G4Element("Iron" ,"Fe" , 26., 55.84*g/mole);
93  G4Element* Ni = new G4Element("Nickel" ,"Ni" , 28., 58.69*g/mole);
94 
95  G4Material* BeO =
96  new G4Material("BeO", 3.05*g/cm3, ncomponents=2);
97  BeO->AddElement(Be, natoms=1);
98  BeO->AddElement( O, natoms=1);
99 
100  G4Material* inox =
101  new G4Material("Stainless-Steel", 8*g/cm3, ncomponents=3);
102  inox->AddElement(Fe, 74*perCent);
103  inox->AddElement(Cr, 18*perCent);
104  inox->AddElement(Ni, 8*perCent);
105 
106  G4Material* Air =
107  new G4Material("Air", 1.290*mg/cm3, ncomponents=2);
108  Air->AddElement(N, 70.*perCent);
109  Air->AddElement(O, 30.*perCent);
110 
111  fWorldMaterial = Air;
112 
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
119  G4String symbol, G4double density, G4int Z, G4int A)
120 {
121  // define a material from an isotope
122  //
123  G4int ncomponents;
124  G4double abundance, massfraction;
125 
126  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
127 
128  G4Element* element = new G4Element(name, symbol, ncomponents=1);
129  element->AddIsotope(isotope, abundance= 100.*perCent);
130 
131  G4Material* material = new G4Material(name, density, ncomponents=1);
132  material->AddElement(element, massfraction=100.*perCent);
133 
134  return material;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138 
140 {
141  // Cleanup old geometry
146 
147  // compute dimensions
148  G4double ContainRadius = fAbsorRadius + fContainThickness;
149  G4double ContainLength = fAbsorLength + 2*fContainThickness;
150 
151  G4double WorldSizeXY = 2.4*ContainRadius;
152  G4double WorldSizeZ = 1.2*ContainLength;
153 
154  // World
155  //
156  G4Box*
157  sWorld = new G4Box("World", //name
158  0.5*WorldSizeXY,0.5*WorldSizeXY,0.5*WorldSizeZ); //dimensions
159 
161  lWorld = new G4LogicalVolume(sWorld, //shape
162  fWorldMaterial, //material
163  "World"); //name
164 
165  fPWorld = new G4PVPlacement(0, //no rotation
166  G4ThreeVector(), //at (0,0,0)
167  lWorld, //logical volume
168  "World", //name
169  0, //mother volume
170  false, //no boolean operation
171  0); //copy number
172 
173  // Container
174  //
175  G4Tubs*
176  sContain = new G4Tubs("Container", //name
177  0., ContainRadius, 0.5*ContainLength, 0., twopi); //dimensions
178 
179  fLContain = new G4LogicalVolume(sContain, //shape
180  fContainMaterial, //material
181  fContainMaterial->GetName()); //name
182 
183  new G4PVPlacement(0, //no rotation
184  G4ThreeVector(), //at (0,0,0)
185  fLContain, //logical volume
186  fContainMaterial->GetName(), //name
187  lWorld, //mother volume
188  false, //no boolean operation
189  0); //copy number
190 
191  // Absorber
192  //
193  G4Tubs*
194  sAbsor = new G4Tubs("Absorber", //name
195  0., fAbsorRadius, 0.5*fAbsorLength, 0., twopi); //dimensions
196 
197  fLAbsor = new G4LogicalVolume(sAbsor, //shape
198  fAbsorMaterial, //material
199  fAbsorMaterial->GetName()); //name
200 
201  new G4PVPlacement(0, //no rotation
202  G4ThreeVector(), //at (0,0,0)
203  fLAbsor, //logical volume
204  fAbsorMaterial->GetName(), //name
205  fLContain, //mother volume
206  false, //no boolean operation
207  0); //copy number
208 
209  PrintParameters();
210 
211  //always return the root volume
212  //
213  return fPWorld;
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
219 {
220  G4cout << "\n The Absorber is a cylinder of " << fAbsorMaterial->GetName()
221  << " radius = " << G4BestUnit(fAbsorRadius,"Length")
222  << " length = " << G4BestUnit(fAbsorLength,"Length") << G4endl;
223  G4cout << " The Container is a cylinder of " << fContainMaterial->GetName()
224  << " thickness = " << G4BestUnit(fContainThickness,"Length") << G4endl;
225 
226  G4cout << "\n" << fAbsorMaterial << G4endl;
227  G4cout << "\n" << fContainMaterial << G4endl;
228 }
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
231 
233 {
234  // search the material by its name
235  G4Material* pttoMaterial =
236  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
237 
238  if (pttoMaterial) {
239  fAbsorMaterial = pttoMaterial;
242  } else {
243  G4cout << "\n--> warning from DetectorConstruction::SetAbsorMaterial : "
244  << materialChoice << " not found" << G4endl;
245  }
246 }
247 
248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
249 
251 {
252  // search the material by its name
253  G4Material* pttoMaterial =
254  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
255 
256  if (pttoMaterial) {
257  fContainMaterial = pttoMaterial;
260  } else {
261  G4cout << "\n--> warning from DetectorConstruction::SetContainMaterial : "
262  << materialChoice << " not found" << G4endl;
263  }
264 }
265 
266 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
267 
269 {
272 }
273 
274 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
275 
277 {
280 }
281 
282 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
283 
285 {
286  fContainThickness = value;
288 }
289 
290 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
291