Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/electromagnetic/TestEm5/src/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 // $Id: DetectorConstruction.cc 109000 2018-03-21 09:25:56Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4Material.hh"
38 #include "G4Box.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4UniformMagField.hh"
42 
43 #include "G4GeometryManager.hh"
44 #include "G4PhysicalVolumeStore.hh"
45 #include "G4LogicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 
48 #include "G4UnitsTable.hh"
49 #include "G4NistManager.hh"
50 #include "G4RunManager.hh"
51 
52 #include "G4PhysicalConstants.hh"
53 #include "G4SystemOfUnits.hh"
54 
56 #include "G4AutoDelete.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62  fAbsorberMaterial(nullptr),fWorldMaterial(nullptr),fDefaultWorld(true),
63  fSolidWorld(nullptr),fLogicWorld(nullptr),fPhysiWorld(nullptr),
64  fSolidAbsorber(nullptr),fLogicAbsorber(nullptr),fPhysiAbsorber(nullptr),
65  fDetectorMessenger(nullptr)
66 {
67  // default parameter values of the calorimeter
69  fAbsorberSizeYZ = 2.*cm;
70  fXposAbs = 0.*cm;
72 
73  // materials
75  SetWorldMaterial ("G4_Galactic");
76  SetAbsorberMaterial("G4_Si");
77 
78  // create commands for interactive definition of the calorimeter
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  delete fDetectorMessenger;
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  //This function illustrates the possible ways to define materials
94 
95  G4String symbol; //a=mass of a mole;
96  G4double a, z, density; //z=mean number of protons;
97 
98  G4int ncomponents, natoms;
99  G4double fractionmass;
100  G4double temperature, pressure;
101 
102  //
103  // define Elements
104  //
105 
106  G4Element* H = new G4Element("Hydrogen",symbol="H", z= 1, a= 1.01*g/mole);
107  G4Element* C = new G4Element("Carbon", symbol="C", z= 6, a= 12.01*g/mole);
108  G4Element* N = new G4Element("Nitrogen",symbol="N", z= 7, a= 14.01*g/mole);
109  G4Element* O = new G4Element("Oxygen", symbol="O", z= 8, a= 16.00*g/mole);
110  G4Element* Na = new G4Element("Sodium", symbol="Na", z=11, a= 22.99*g/mole);
111  G4Element* Ar = new G4Element("Argon", symbol="Ar", z=18, a= 39.95*g/mole);
112  G4Element* I = new G4Element("Iodine", symbol="I" , z=53, a= 126.90*g/mole);
113  G4Element* Xe = new G4Element("Xenon", symbol="Xe", z=54, a= 131.29*g/mole);
114 
115  //
116  // define simple materials
117  //
118 
119  new G4Material("H2Liq" , z= 1, a= 1.01*g/mole, density= 70.8*mg/cm3);
120  new G4Material("Beryllium", z= 4, a= 9.01*g/mole, density= 1.848*g/cm3);
121  new G4Material("Aluminium", z=13, a=26.98*g/mole, density= 2.700*g/cm3);
122  new G4Material("Silicon" , z=14, a=28.09*g/mole, density= 2.330*g/cm3);
123 
124  G4Material* lAr =
125  new G4Material("liquidArgon", density= 1.390*g/cm3, ncomponents=1);
126  lAr->AddElement(Ar, natoms=1);
127 
128  new G4Material("Iron", z=26, a= 55.85*g/mole, density= 7.870*g/cm3);
129  new G4Material("Copper", z=29, a= 63.55*g/mole, density= 8.960*g/cm3);
130  new G4Material("Germanium",z=32, a= 72.61*g/mole, density= 5.323*g/cm3);
131  new G4Material("Silver", z=47, a=107.87*g/mole, density= 10.50*g/cm3);
132  new G4Material("Tungsten", z=74, a=183.85*g/mole, density= 19.30*g/cm3);
133  new G4Material("Gold", z=79, a=196.97*g/mole, density= 19.32*g/cm3);
134  new G4Material("Lead", z=82, a=207.19*g/mole, density= 11.35*g/cm3);
135 
136  //
137  // define a material from elements. case 1: chemical molecule
138  //
139 
140  G4Material* H2O = new G4Material("Water",density= 1.000*g/cm3,ncomponents=2);
141  H2O->AddElement(H, natoms=2);
142  H2O->AddElement(O, natoms=1);
144 
145  G4Material* CH = new G4Material("Plastic",density= 1.04*g/cm3,ncomponents=2);
146  CH->AddElement(C, natoms=1);
147  CH->AddElement(H, natoms=1);
148 
149  G4Material* NaI = new G4Material("NaI", density= 3.67*g/cm3, ncomponents=2);
150  NaI->AddElement(Na, natoms=1);
151  NaI->AddElement(I , natoms=1);
153 
154  //
155  // define a material from elements. case 2: mixture by fractional mass
156  //
157 
158  G4Material* Air = new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
159  Air->AddElement(N, fractionmass=0.7);
160  Air->AddElement(O, fractionmass=0.3);
161 
162  G4Material* Air20 =
163  new G4Material("Air20", density= 1.205*mg/cm3, ncomponents=2,
164  kStateGas, 293.*kelvin, 1.*atmosphere);
165  Air20->AddElement(N, fractionmass=0.7);
166  Air20->AddElement(O, fractionmass=0.3);
167 
168  //Graphite
169  //
170  G4Material* Graphite =
171  new G4Material("Graphite", density= 1.7*g/cm3, ncomponents=1);
172  Graphite->AddElement(C, fractionmass=1.);
173 
174  //Havar
175  //
176  G4Element* Cr = new G4Element("Chrome", "Cr", z=24, a= 51.996*g/mole);
177  G4Element* Fe = new G4Element("Iron" , "Fe", z=26, a= 55.845*g/mole);
178  G4Element* Co = new G4Element("Cobalt", "Co", z=27, a= 58.933*g/mole);
179  G4Element* Ni = new G4Element("Nickel", "Ni", z=28, a= 58.693*g/mole);
180  G4Element* W = new G4Element("Tungsten","W", z=74, a= 183.850*g/mole);
181 
182  G4Material* Havar =
183  new G4Material("Havar", density= 8.3*g/cm3, ncomponents=5);
184  Havar->AddElement(Cr, fractionmass=0.1785);
185  Havar->AddElement(Fe, fractionmass=0.1822);
186  Havar->AddElement(Co, fractionmass=0.4452);
187  Havar->AddElement(Ni, fractionmass=0.1310);
188  Havar->AddElement(W , fractionmass=0.0631);
189 
190  //
191  // examples of gas
192  //
193  new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
194  kStateGas, 273.15*kelvin, 1*atmosphere);
195 
196  new G4Material("XenonGas", z=54, a=131.29*g/mole, density= 5.458*mg/cm3,
197  kStateGas, 293.15*kelvin, 1*atmosphere);
198 
199  G4Material* CO2 =
200  new G4Material("CarbonicGas", density= 1.977*mg/cm3, ncomponents=2);
201  CO2->AddElement(C, natoms=1);
202  CO2->AddElement(O, natoms=2);
203 
204  G4Material* ArCO2 =
205  new G4Material("ArgonCO2", density= 1.8223*mg/cm3, ncomponents=2);
206  ArCO2->AddElement (Ar, fractionmass=0.7844);
207  ArCO2->AddMaterial(CO2, fractionmass=0.2156);
208 
209  //another way to define mixture of gas per volume
210  G4Material* NewArCO2 =
211  new G4Material("NewArgonCO2", density= 1.8223*mg/cm3, ncomponents=3);
212  NewArCO2->AddElement (Ar, natoms=8);
213  NewArCO2->AddElement (C, natoms=2);
214  NewArCO2->AddElement (O, natoms=4);
215 
216  G4Material* ArCH4 =
217  new G4Material("ArgonCH4", density= 1.709*mg/cm3, ncomponents=3);
218  ArCH4->AddElement (Ar, natoms=93);
219  ArCH4->AddElement (C, natoms=7);
220  ArCH4->AddElement (H, natoms=28);
221 
222  G4Material* XeCH =
223  new G4Material("XenonMethanePropane", density= 4.9196*mg/cm3, ncomponents=3,
224  kStateGas, 293.15*kelvin, 1*atmosphere);
225  XeCH->AddElement (Xe, natoms=875);
226  XeCH->AddElement (C, natoms=225);
227  XeCH->AddElement (H, natoms=700);
228 
229  G4Material* steam =
230  new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1);
231  steam->AddMaterial(H2O, fractionmass=1.);
232  steam->GetIonisation()->SetMeanExcitationEnergy(71.6*eV);
233 
234  G4Material* rock1 = new G4Material("StandardRock",
235  2.65*CLHEP::g/CLHEP::cm3, 1, kStateSolid);
236  rock1->AddElement(Na, 1);
237 
238  //
239  // example of vacuum
240  //
241  density = universe_mean_density; //from PhysicalConstants.h
242  pressure = 3.e-18*pascal;
243  temperature = 2.73*kelvin;
244  new G4Material("Galactic", z=1, a=1.01*g/mole,density,
245  kStateGas,temperature,pressure);
246 }
247 
248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
249 
251 {
252  // Compute derived parameters of the calorimeter
255 
256  G4double xmax = std::max(std::abs(fXstartAbs), std::abs(fXendAbs));
257 
258  // change world size by the flag or if the absorber is large
259  if (fDefaultWorld || 2*xmax >= fWorldSizeX ||
261  {
262  fWorldSizeX = 3*xmax;
264  }
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
270 {
271  if(fPhysiWorld) { return fPhysiWorld; }
272  // World
273  //
274  fSolidWorld = new G4Box("World", //its name
275  fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
276 
277  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
278  fWorldMaterial, //its material
279  "World"); //its name
280 
281  fPhysiWorld = new G4PVPlacement(0, //no rotation
282  G4ThreeVector(0.,0.,0.), //at (0,0,0)
283  fLogicWorld, //its logical volume
284  "World", //its name
285  0, //its mother volume
286  false, //no boolean operation
287  0); //copy number
288 
289  // Absorber
290  //
291  fSolidAbsorber = new G4Box("Absorber",
293 
295  fAbsorberMaterial, //its material
296  "Absorber"); //its name
297 
298  fPhysiAbsorber = new G4PVPlacement(0, //no rotation
299  G4ThreeVector(fXposAbs,0.,0.), //its position
300  fLogicAbsorber, //its logical volume
301  "Absorber", //its name
302  fLogicWorld, //its mother
303  false, //no boulean operat
304  0); //copy number
305 
307 
308  //always return the physical World
309  //
310  return fPhysiWorld;
311 }
312 
313 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
314 
316 {
317  G4cout << "\n" << fWorldMaterial << G4endl;
318  G4cout << "\n" << fAbsorberMaterial << G4endl;
319 
320  G4cout << "\n The WORLD is made of " << G4BestUnit(fWorldSizeX,"Length")
321  << " of " << fWorldMaterial->GetName();
322  G4cout << ". The transverse size (YZ) of the world is "
323  << G4BestUnit(fWorldSizeYZ,"Length") << G4endl;
324  G4cout << " The ABSORBER is made of "
325  <<G4BestUnit(fAbsorberThickness,"Length")
326  << " of " << fAbsorberMaterial->GetName();
327  G4cout << ". The transverse size (YZ) is "
328  << G4BestUnit(fAbsorberSizeYZ,"Length") << G4endl;
329  G4cout << " X position of the middle of the absorber "
330  << G4BestUnit(fXposAbs,"Length");
331  G4cout << G4endl;
332 }
333 
334 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
335 
337 {
338  // search the material by its name
339  G4Material* pttoMaterial =
340  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
341 
342  if (pttoMaterial && fAbsorberMaterial != pttoMaterial) {
343  fAbsorberMaterial = pttoMaterial;
346  }
347 }
348 
349 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
350 
351 void DetectorConstruction::SetWorldMaterial(const G4String& materialChoice)
352 {
353  // search the material by its name
354  G4Material* pttoMaterial =
355  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
356 
357  if (pttoMaterial && fWorldMaterial != pttoMaterial) {
358  fWorldMaterial = pttoMaterial;
361  }
362 }
363 
364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
365 
367 {
368  fAbsorberThickness = val;
370  if(fPhysiWorld) { ChangeGeometry(); }
371 }
372 
373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
374 
376 {
377  fAbsorberSizeYZ = val;
379  if(fPhysiWorld) { ChangeGeometry(); }
380 }
381 
382 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
383 
385 {
386  fWorldSizeX = val;
387  fDefaultWorld = false;
389  if(fPhysiWorld) { ChangeGeometry(); }
390 }
391 
392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
393 
395 {
396  fWorldSizeYZ = val;
397  fDefaultWorld = false;
399  if(fPhysiWorld) { ChangeGeometry(); }
400 }
401 
402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
403 
405 {
406  if(!fPhysiWorld) { fXposAbs = val; }
407 }
408 
409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
410 
412 {
413  if ( fFieldMessenger.Get() == 0 ) {
414  // Create global magnetic field messenger.
415  // Uniform magnetic field is then created automatically if
416  // the field value is not zero.
417  G4ThreeVector fieldValue = G4ThreeVector();
419  new G4GlobalMagFieldMessenger(fieldValue);
420  //msg->SetVerboseLevel(1);
422  fFieldMessenger.Put( msg );
423  }
424 }
425 
426 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
427 
429 {
433 
437 }
438 
439 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
440 
static constexpr double kelvin
Definition: G4SIunits.hh:281
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:136
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static constexpr double atmosphere
Definition: G4SIunits.hh:237
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
static constexpr double cm3
static constexpr double g
#define G4endl
Definition: G4ios.hh:61
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:183
Double_t z
void SetMeanExcitationEnergy(G4double value)
static constexpr double universe_mean_density
void Register(T *inst)
Definition: G4AutoDelete.hh:65
const G4String & GetName() const
Definition: G4Material.hh:179
void SetWorldMaterial(const G4String &materialName)
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
**D E S C R I P T I O N
static constexpr double mg
Definition: G4SIunits.hh:184
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static constexpr double eV
Definition: G4SIunits.hh:215
value_type & Get() const
Definition: G4Cache.hh:314
void Put(const value_type &val) const
Definition: G4Cache.hh:318
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:160
int G4int
Definition: G4Types.hh:78
double C(double temp)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:227
void PhysicsHasBeenModified()
G4Cache< G4GlobalMagFieldMessenger * > fFieldMessenger
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
static constexpr double mole
Definition: G4SIunits.hh:286
#define pascal
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:473
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4NistManager * Instance()