Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
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 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 :fAbsorberMaterial(0),fWorldMaterial(0),fDefaultWorld(true),
59  fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
60  fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0),
61  fMagField(0)
62 {
63  // default parameter values of the calorimeter
64  fAbsorberThickness = 1.*cm;
65  fAbsorberSizeYZ = 2.*cm;
66  fXposAbs = 0.*cm;
67  ComputeCalorParameters();
68 
69  // materials
70  DefineMaterials();
71  SetWorldMaterial ("Galactic");
72  SetAbsorberMaterial("Silicon");
73 
74  // create commands for interactive definition of the calorimeter
75  fDetectorMessenger = new DetectorMessenger(this);
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  delete fDetectorMessenger;
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
89  return ConstructCalorimeter();
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
94 void DetectorConstruction::DefineMaterials()
95 {
96  //This function illustrates the possible ways to define materials
97 
98  G4String symbol; //a=mass of a mole;
99  G4double a, z, density; //z=mean number of protons;
100 
101  G4int ncomponents, natoms;
102  G4double fractionmass;
103  G4double temperature, pressure;
104 
105  //
106  // define Elements
107  //
108 
109  G4Element* H = new G4Element("Hydrogen",symbol="H", z= 1, a= 1.01*g/mole);
110  G4Element* C = new G4Element("Carbon", symbol="C", z= 6, a= 12.01*g/mole);
111  G4Element* N = new G4Element("Nitrogen",symbol="N", z= 7, a= 14.01*g/mole);
112  G4Element* O = new G4Element("Oxygen", symbol="O", z= 8, a= 16.00*g/mole);
113  G4Element* Na = new G4Element("Sodium", symbol="Na", z=11, a= 22.99*g/mole);
114  G4Element* Ar = new G4Element("Argon", symbol="Ar", z=18, a= 39.95*g/mole);
115  G4Element* I = new G4Element("Iodine", symbol="I" , z=53, a= 126.90*g/mole);
116  G4Element* Xe = new G4Element("Xenon", symbol="Xe", z=54, a= 131.29*g/mole);
117 
118  //
119  // define simple materials
120  //
121 
122  new G4Material("H2Liq" , z= 1, a= 1.01*g/mole, density= 70.8*mg/cm3);
123  new G4Material("Beryllium", z= 4, a= 9.01*g/mole, density= 1.848*g/cm3);
124  new G4Material("Aluminium", z=13, a=26.98*g/mole, density= 2.700*g/cm3);
125  new G4Material("Silicon" , z=14, a=28.09*g/mole, density= 2.330*g/cm3);
126 
127  G4Material* lAr =
128  new G4Material("liquidArgon", density= 1.390*g/cm3, ncomponents=1);
129  lAr->AddElement(Ar, natoms=1);
130 
131  new G4Material("Iron", z=26, a= 55.85*g/mole, density= 7.870*g/cm3);
132  new G4Material("Copper", z=29, a= 63.55*g/mole, density= 8.960*g/cm3);
133  new G4Material("Germanium",z=32, a= 72.61*g/mole, density= 5.323*g/cm3);
134  new G4Material("Silver", z=47, a=107.87*g/mole, density= 10.50*g/cm3);
135  new G4Material("Tungsten", z=74, a=183.85*g/mole, density= 19.30*g/cm3);
136  new G4Material("Gold", z=79, a=196.97*g/mole, density= 19.32*g/cm3);
137  new G4Material("Lead", z=82, a=207.19*g/mole, density= 11.35*g/cm3);
138 
139  //
140  // define a material from elements. case 1: chemical molecule
141  //
142 
143  G4Material* H2O = new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
144  H2O->AddElement(H, natoms=2);
145  H2O->AddElement(O, natoms=1);
147 
148  G4Material* CH = new G4Material("Plastic", density= 1.04*g/cm3, ncomponents=2);
149  CH->AddElement(C, natoms=1);
150  CH->AddElement(H, natoms=1);
151 
152  G4Material* NaI = new G4Material("NaI", density= 3.67*g/cm3, ncomponents=2);
153  NaI->AddElement(Na, natoms=1);
154  NaI->AddElement(I , natoms=1);
156 
157  //
158  // define a material from elements. case 2: mixture by fractional mass
159  //
160 
161  G4Material* Air = new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
162  Air->AddElement(N, fractionmass=0.7);
163  Air->AddElement(O, fractionmass=0.3);
164 
165  G4Material* Air20 =
166  new G4Material("Air20", density= 1.205*mg/cm3, ncomponents=2,
167  kStateGas, 293.*kelvin, 1.*atmosphere);
168  Air20->AddElement(N, fractionmass=0.7);
169  Air20->AddElement(O, fractionmass=0.3);
170 
171  //Graphite
172  //
173  G4Material* Graphite =
174  new G4Material("Graphite", density= 1.7*g/cm3, ncomponents=1);
175  Graphite->AddElement(C, fractionmass=1.);
176 
177  //Havar
178  //
179  G4Element* Cr = new G4Element("Chrome", "Cr", z=25, a= 51.996*g/mole);
180  G4Element* Fe = new G4Element("Iron" , "Fe", z=26, a= 55.845*g/mole);
181  G4Element* Co = new G4Element("Cobalt", "Co", z=27, a= 58.933*g/mole);
182  G4Element* Ni = new G4Element("Nickel", "Ni", z=28, a= 58.693*g/mole);
183  G4Element* W = new G4Element("Tungsten","W", z=74, a= 183.850*g/mole);
184 
185  G4Material* Havar =
186  new G4Material("Havar", density= 8.3*g/cm3, ncomponents=5);
187  Havar->AddElement(Cr, fractionmass=0.1785);
188  Havar->AddElement(Fe, fractionmass=0.1822);
189  Havar->AddElement(Co, fractionmass=0.4452);
190  Havar->AddElement(Ni, fractionmass=0.1310);
191  Havar->AddElement(W , fractionmass=0.0631);
192 
193  //
194  // examples of gas
195  //
196  new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
197  kStateGas, 273.15*kelvin, 1*atmosphere);
198 
199  new G4Material("XenonGas", z=54, a=131.29*g/mole, density= 5.458*mg/cm3,
200  kStateGas, 293.15*kelvin, 1*atmosphere);
201 
202  G4Material* CO2 =
203  new G4Material("CarbonicGas", density= 1.977*mg/cm3, ncomponents=2);
204  CO2->AddElement(C, natoms=1);
205  CO2->AddElement(O, natoms=2);
206 
207  G4Material* ArCO2 =
208  new G4Material("ArgonCO2", density= 1.8223*mg/cm3, ncomponents=2);
209  ArCO2->AddElement (Ar, fractionmass=0.7844);
210  ArCO2->AddMaterial(CO2, fractionmass=0.2156);
211 
212  //another way to define mixture of gas per volume
213  G4Material* NewArCO2 =
214  new G4Material("NewArgonCO2", density= 1.8223*mg/cm3, ncomponents=3);
215  NewArCO2->AddElement (Ar, natoms=8);
216  NewArCO2->AddElement (C, natoms=2);
217  NewArCO2->AddElement (O, natoms=4);
218 
219  G4Material* ArCH4 =
220  new G4Material("ArgonCH4", density= 1.709*mg/cm3, ncomponents=3);
221  ArCH4->AddElement (Ar, natoms=93);
222  ArCH4->AddElement (C, natoms=7);
223  ArCH4->AddElement (H, natoms=28);
224 
225  G4Material* XeCH =
226  new G4Material("XenonMethanePropane", density= 4.9196*mg/cm3, ncomponents=3,
227  kStateGas, 293.15*kelvin, 1*atmosphere);
228  XeCH->AddElement (Xe, natoms=875);
229  XeCH->AddElement (C, natoms=225);
230  XeCH->AddElement (H, natoms=700);
231 
232  G4Material* steam =
233  new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1);
234  steam->AddMaterial(H2O, fractionmass=1.);
235  steam->GetIonisation()->SetMeanExcitationEnergy(71.6*eV);
236 
237  //
238  // example of vacuum
239  //
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 
250 void DetectorConstruction::ComputeCalorParameters()
251 {
252  // Compute derived parameters of the calorimeter
253  fXstartAbs = fXposAbs-0.5*fAbsorberThickness;
254  fXendAbs = fXposAbs+0.5*fAbsorberThickness;
255 
256  if (fDefaultWorld) {
257  fWorldSizeX = 1.5*fAbsorberThickness; fWorldSizeYZ= 1.2*fAbsorberSizeYZ;
258  }
259 }
260 
261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
262 
263 G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
264 {
265  // Cleanup old geometry
266  //
271 
272  // complete the Calor parameters definition
273  ComputeCalorParameters();
274 
275  // World
276  //
277  fSolidWorld = new G4Box("World", //its name
278  fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
279 
280  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
281  fWorldMaterial, //its material
282  "World"); //its name
283 
284  fPhysiWorld = new G4PVPlacement(0, //no rotation
285  G4ThreeVector(), //at (0,0,0)
286  fLogicWorld, //its logical volume
287  "World", //its name
288  0, //its mother volume
289  false, //no boolean operation
290  0); //copy number
291 
292  // Absorber
293  //
294  fSolidAbsorber = new G4Box("Absorber",
295  fAbsorberThickness/2,fAbsorberSizeYZ/2,fAbsorberSizeYZ/2);
296 
297  fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, //its solid
298  fAbsorberMaterial, //its material
299  "Absorber"); //its name
300 
301  fPhysiAbsorber = new G4PVPlacement(0, //no rotation
302  G4ThreeVector(fXposAbs,0.,0.), //its position
303  fLogicAbsorber, //its logical volume
304  "Absorber", //its name
305  fLogicWorld, //its mother
306  false, //no boulean operat
307  0); //copy number
308 
310 
311  //always return the physical World
312  //
313  return fPhysiWorld;
314 }
315 
316 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
317 
319 {
320  G4cout << "\n" << fWorldMaterial << G4endl;
321  G4cout << "\n" << fAbsorberMaterial << G4endl;
322 
323  G4cout << "\n The WORLD is made of " << G4BestUnit(fWorldSizeX,"Length")
324  << " of " << fWorldMaterial->GetName();
325  G4cout << ". The transverse size (YZ) of the world is "
326  << G4BestUnit(fWorldSizeYZ,"Length") << G4endl;
327  G4cout << " The ABSORBER is made of "
328  <<G4BestUnit(fAbsorberThickness,"Length")
329  << " of " << fAbsorberMaterial->GetName();
330  G4cout << ". The transverse size (YZ) is "
331  << G4BestUnit(fAbsorberSizeYZ,"Length") << G4endl;
332  G4cout << " X position of the middle of the absorber "
333  << G4BestUnit(fXposAbs,"Length");
334  G4cout << G4endl;
335 }
336 
337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
338 
340 {
341  // search the material by its name
342  G4Material* pttoMaterial =
343  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
344 
345  if (pttoMaterial && fAbsorberMaterial != pttoMaterial) {
346  fAbsorberMaterial = pttoMaterial;
347  if(fLogicAbsorber) fLogicAbsorber->SetMaterial(fAbsorberMaterial);
349  }
350 }
351 
352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
353 
355 {
356  // search the material by its name
357  G4Material* pttoMaterial =
358  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
359 
360  if (pttoMaterial && fWorldMaterial != pttoMaterial) {
361  fWorldMaterial = pttoMaterial;
362  if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial);
364  }
365 }
366 
367 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
368 
370 {
371  fAbsorberThickness = val;
373 }
374 
375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
376 
378 {
379  fAbsorberSizeYZ = val;
381 }
382 
383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
384 
386 {
387  fWorldSizeX = val;
388  fDefaultWorld = false;
390 }
391 
392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
393 
395 {
396  fWorldSizeYZ = val;
397  fDefaultWorld = false;
399 }
400 
401 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
402 
404 {
405  fXposAbs = val;
407 }
408 
409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
410 
411 #include "G4FieldManager.hh"
413 
415 {
416  //apply a global uniform magnetic field along Z axis
417  G4FieldManager* fieldMgr
419 
420  if(fMagField) delete fMagField; //delete the existing magn field
421 
422  if(fieldValue!=0.) // create a new one if non nul
423  { fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
424  fieldMgr->SetDetectorField(fMagField);
425  fieldMgr->CreateChordFinder(fMagField);
426  } else {
427  fMagField = NULL;
428  fieldMgr->SetDetectorField(fMagField);
429  }
430 }
431 
432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
433 
435 {
437  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
438 }
439 
440 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
441