Geant4  10.03
DetectorConstruction.cc
Go to the documentation of this file.
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 // $Id: DetectorConstruction.cc 70755 2013-06-05 12:17:48Z ihrivnac $
30 //
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "DetectorConstruction.hh"
36 #include "DetectorMessenger.hh"
37 #include "G4Material.hh"
38 #include "G4NistManager.hh"
39 
40 #include "G4Box.hh"
41 #include "G4Tubs.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4PVPlacement.hh"
44 
45 #include "G4GeometryManager.hh"
46 #include "G4PhysicalVolumeStore.hh"
47 #include "G4LogicalVolumeStore.hh"
48 #include "G4SolidStore.hh"
49 #include "G4RunManager.hh"
50 
51 #include "G4UnitsTable.hh"
52 #include "G4SystemOfUnits.hh"
53 #include "G4PhysicalConstants.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
59  fAbsorMaterial(0), fLAbsor(0), fContainMaterial(0), fLContain(0),
60  fWorldMaterial(0), fPWorld(0), fDetectorMessenger(0)
61 {
62  fAbsorRadius = 15*mm;
63  fAbsorLength = 60*mm;
64  fContainThickness = 2.4*mm;
66  SetAbsorMaterial ("BeO");
67  SetContainMaterial("Stainless-Steel");
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 { delete fDetectorMessenger;}
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 {
80  return ConstructVolumes();
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  G4int ncomponents, natoms;
88 
89  G4Element* Be = new G4Element("Beryllium","Be" , 4., 9.01*g/mole);
90  G4Element* N = new G4Element("Nitrogen" ,"N" , 7., 14.01*g/mole);
91  G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole);
92  G4Element* Cr = new G4Element("Chromium" ,"Cr" , 24., 51.99*g/mole);
93  G4Element* Fe = new G4Element("Iron" ,"Fe" , 26., 55.84*g/mole);
94  G4Element* Ni = new G4Element("Nickel" ,"Ni" , 28., 58.69*g/mole);
95 
96  G4Material* BeO =
97  new G4Material("BeO", 3.05*g/cm3, ncomponents=2);
98  BeO->AddElement(Be, natoms=1);
99  BeO->AddElement( O, natoms=1);
100 
101  G4Material* inox =
102  new G4Material("Stainless-Steel", 8*g/cm3, ncomponents=3);
103  inox->AddElement(Fe, 74*perCent);
104  inox->AddElement(Cr, 18*perCent);
105  inox->AddElement(Ni, 8*perCent);
106 
107  G4Material* Air =
108  new G4Material("Air", 1.290*mg/cm3, ncomponents=2);
109  Air->AddElement(N, 70.*perCent);
110  Air->AddElement(O, 30.*perCent);
111 
112  fWorldMaterial = Air;
113 
115 }
116 
117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
118 
120  G4String symbol, G4double density, G4int Z, G4int A)
121 {
122  // define a material from an isotope
123  //
124  G4int ncomponents;
125  G4double abundance, massfraction;
126 
127  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
128 
129  G4Element* element = new G4Element(name, symbol, ncomponents=1);
130  element->AddIsotope(isotope, abundance= 100.*perCent);
131 
132  G4Material* material = new G4Material(name, density, ncomponents=1);
133  material->AddElement(element, massfraction=100.*perCent);
134 
135  return material;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  // Cleanup old geometry
147 
148  // compute dimensions
149  G4double ContainRadius = fAbsorRadius + fContainThickness;
150  G4double ContainLength = fAbsorLength + 2*fContainThickness;
151 
152  G4double WorldSizeXY = 2.4*ContainRadius;
153  G4double WorldSizeZ = 1.2*ContainLength;
154 
155  // World
156  //
157  G4Box*
158  sWorld = new G4Box("World", //name
159  0.5*WorldSizeXY,0.5*WorldSizeXY,0.5*WorldSizeZ); //dimensions
160 
162  lWorld = new G4LogicalVolume(sWorld, //shape
163  fWorldMaterial, //material
164  "World"); //name
165 
166  fPWorld = new G4PVPlacement(0, //no rotation
167  G4ThreeVector(), //at (0,0,0)
168  lWorld, //logical volume
169  "World", //name
170  0, //mother volume
171  false, //no boolean operation
172  0); //copy number
173 
174  // Container
175  //
176  G4Tubs*
177  sContain = new G4Tubs("Container", //name
178  0., ContainRadius, 0.5*ContainLength, 0., twopi); //dimensions
179 
180  fLContain = new G4LogicalVolume(sContain, //shape
181  fContainMaterial, //material
182  fContainMaterial->GetName()); //name
183 
184  new G4PVPlacement(0, //no rotation
185  G4ThreeVector(), //at (0,0,0)
186  fLContain, //logical volume
187  fContainMaterial->GetName(), //name
188  lWorld, //mother volume
189  false, //no boolean operation
190  0); //copy number
191 
192  // Absorber
193  //
194  G4Tubs*
195  sAbsor = new G4Tubs("Absorber", //name
196  0., fAbsorRadius, 0.5*fAbsorLength, 0., twopi); //dimensions
197 
198  fLAbsor = new G4LogicalVolume(sAbsor, //shape
199  fAbsorMaterial, //material
200  fAbsorMaterial->GetName()); //name
201 
202  new G4PVPlacement(0, //no rotation
203  G4ThreeVector(), //at (0,0,0)
204  fLAbsor, //logical volume
205  fAbsorMaterial->GetName(), //name
206  fLContain, //mother volume
207  false, //no boolean operation
208  0); //copy number
209 
210  PrintParameters();
211 
212  //always return the root volume
213  //
214  return fPWorld;
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
218 
220 {
221  G4cout << "\n The Absorber is a cylinder of " << fAbsorMaterial->GetName()
222  << " radius = " << G4BestUnit(fAbsorRadius,"Length")
223  << " length = " << G4BestUnit(fAbsorLength,"Length") << G4endl;
224  G4cout << " The Container is a cylinder of " << fContainMaterial->GetName()
225  << " thickness = " << G4BestUnit(fContainThickness,"Length") << G4endl;
226 
227  G4cout << "\n" << fAbsorMaterial << G4endl;
228  G4cout << "\n" << fContainMaterial << G4endl;
229 }
230 
231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232 
234 {
235  // search the material by its name
236  G4Material* pttoMaterial =
237  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
238 
239  if (pttoMaterial) {
240  fAbsorMaterial = pttoMaterial;
243  } else {
244  G4cout << "\n--> warning from DetectorConstruction::SetAbsorMaterial : "
245  << materialChoice << " not found" << G4endl;
246  }
247 }
248 
249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
250 
252 {
253  // search the material by its name
254  G4Material* pttoMaterial =
255  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
256 
257  if (pttoMaterial) {
258  fContainMaterial = pttoMaterial;
261  } else {
262  G4cout << "\n--> warning from DetectorConstruction::SetContainMaterial : "
263  << materialChoice << " not found" << G4endl;
264  }
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
270 {
271  fAbsorRadius = value;
273 }
274 
275 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
276 
278 {
279  fAbsorLength = value;
281 }
282 
283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
284 
286 {
287  fContainThickness = value;
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292 
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double mm
Definition: G4SIunits.hh:115
static constexpr double mg
Definition: G4SIunits.hh:184
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:64
static constexpr double perCent
Definition: G4SIunits.hh:332
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
Definition: G4Tubs.hh:85
G4LogicalVolume * fLAbsor
static void Clean()
Definition: G4SolidStore.cc:79
const char * name(G4int ptype)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static constexpr double g
Definition: G4SIunits.hh:183
G4Material * fAbsorMaterial[kMaxAbsor]
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static constexpr double twopi
Definition: G4SIunits.hh:76
static G4PhysicalVolumeStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
void PhysicsHasBeenModified()
void SetAbsorMaterial(G4int, const G4String &)
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
G4LogicalVolume * fLContain
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
static constexpr double cm3
Definition: G4SIunits.hh:121
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)
void SetContainMaterial(G4String)
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:362
void SetContainThickness(G4double)
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * ConstructVolumes()
void SetMaterial(G4Material *pMaterial)
static constexpr double mole
Definition: G4SIunits.hh:286
Messenger class that defines commands for DetectorConstruction.
G4VPhysicalVolume * fPWorld
DetectorMessenger * fDetectorMessenger