Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExN03DetectorConstruction.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 //
26 //
27 // $Id: ExN03DetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $
28 //
29 //
30 
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
36 
37 #include "G4Material.hh"
38 #include "G4Box.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4PVReplica.hh"
42 #include "G4UniformMagField.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 
49 #include "G4VisAttributes.hh"
50 #include "G4Colour.hh"
51 #include "G4SystemOfUnits.hh"
52 #include "G4PhysicalConstants.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 :AbsorberMaterial(0),GapMaterial(0),defaultMaterial(0),
58  solidWorld(0),logicWorld(0),physiWorld(0),
59  solidCalor(0),logicCalor(0),physiCalor(0),
60  solidLayer(0),logicLayer(0),physiLayer(0),
61  solidAbsorber(0),logicAbsorber(0),physiAbsorber(0),
62  solidGap (0),logicGap (0),physiGap (0),
63  magField(0)
64 {
65  // default parameter values of the calorimeter
66  AbsorberThickness = 10.*mm;
67  GapThickness = 5.*mm;
68  NbOfLayers = 10;
69  CalorSizeYZ = 10.*cm;
70  ComputeCalorParameters();
71 
72  // materials
73  DefineMaterials();
74  SetAbsorberMaterial("Lead");
75  SetGapMaterial("liquidArgon");
76 
77  // create commands for interactive definition of the calorimeter
78  detectorMessenger = new ExN03DetectorMessenger(this);
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 { delete detectorMessenger;}
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 {
90  return ConstructCalorimeter();
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
95 void ExN03DetectorConstruction::DefineMaterials()
96 {
97  //This function illustrates the possible ways to define materials
98 
99 G4String symbol; //a=mass of a mole;
100 G4double a, z, density; //z=mean number of protons;
101 G4int iz, n; //iz=number of protons in an isotope;
102  // n=number of nucleons in an isotope;
103 
104 G4int ncomponents, natoms;
105 G4double abundance, fractionmass;
106 
107 //
108 // define Elements
109 //
110 
111 G4Element* H = new G4Element("Hydrogen",symbol="H" , z= 1., a= 1.01*g/mole);
112 G4Element* C = new G4Element("Carbon" ,symbol="C" , z= 6., a= 12.01*g/mole);
113 G4Element* N = new G4Element("Nitrogen",symbol="N" , z= 7., a= 14.01*g/mole);
114 G4Element* O = new G4Element("Oxygen" ,symbol="O" , z= 8., a= 16.00*g/mole);
115 G4Element* Si = new G4Element("Silicon",symbol="Si" , z= 14., a= 28.09*g/mole);
116 
117 //
118 // define an Element from isotopes, by relative abundance
119 //
120 
121 G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole);
122 G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole);
123 
124 G4Element* U = new G4Element("enriched Uranium",symbol="U",ncomponents=2);
125 U->AddIsotope(U5, abundance= 90.*perCent);
126 U->AddIsotope(U8, abundance= 10.*perCent);
127 
128 //
129 // define simple materials
130 //
131 
132 new G4Material("Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
133 new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*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 =
141 new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
142 H2O->AddElement(H, natoms=2);
143 H2O->AddElement(O, natoms=1);
144 // overwrite computed meanExcitationEnergy with ICRU recommended value
146 
147 G4Material* Sci =
148 new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
149 Sci->AddElement(C, natoms=9);
150 Sci->AddElement(H, natoms=10);
151 
152 G4Material* Myl =
153 new G4Material("Mylar", density= 1.397*g/cm3, ncomponents=3);
154 Myl->AddElement(C, natoms=10);
155 Myl->AddElement(H, natoms= 8);
156 Myl->AddElement(O, natoms= 4);
157 
158 G4Material* SiO2 =
159 new G4Material("quartz",density= 2.200*g/cm3, ncomponents=2);
160 SiO2->AddElement(Si, natoms=1);
161 SiO2->AddElement(O , natoms=2);
162 
163 //
164 // define a material from elements. case 2: mixture by fractional mass
165 //
166 
167 G4Material* Air =
168 new G4Material("Air" , density= 1.290*mg/cm3, ncomponents=2);
169 Air->AddElement(N, fractionmass=0.7);
170 Air->AddElement(O, fractionmass=0.3);
171 
172 //
173 // define a material from elements and/or others materials (mixture of mixtures)
174 //
175 
176 G4Material* Aerog =
177 new G4Material("Aerogel", density= 0.200*g/cm3, ncomponents=3);
178 Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent);
179 Aerog->AddMaterial(H2O , fractionmass=37.4*perCent);
180 Aerog->AddElement (C , fractionmass= 0.1*perCent);
181 
182 //
183 // examples of gas in non STP conditions
184 //
185 
186 G4Material* CO2 =
187 new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
188  kStateGas, 325.*kelvin, 50.*atmosphere);
189 CO2->AddElement(C, natoms=1);
190 CO2->AddElement(O, natoms=2);
191 
192 G4Material* steam =
193 new G4Material("WaterSteam", density= 0.3*mg/cm3, ncomponents=1,
194  kStateGas, 500.*kelvin, 2.*atmosphere);
195 steam->AddMaterial(H2O, fractionmass=1.);
196 
197 //
198 // examples of vacuum
199 //
200 
201 G4Material* Vacuum =
202 new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
203  kStateGas, 2.73*kelvin, 3.e-18*pascal);
204 
205 G4Material* beam =
206 new G4Material("Beam", density= 1.e-5*g/cm3, ncomponents=1,
207  kStateGas, STP_Temperature, 2.e-2*bar);
208 beam->AddMaterial(Air, fractionmass=1.);
209 
211 
212 //default materials of the World
213 defaultMaterial = Vacuum;
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
218 G4VPhysicalVolume* ExN03DetectorConstruction::ConstructCalorimeter()
219 {
220 
221  // Clean old geometry, if any
222  //
227 
228  // complete the Calor parameters definition
229  ComputeCalorParameters();
230 
231  //
232  // World
233  //
234  solidWorld = new G4Box("World", //its name
235  WorldSizeX/2,WorldSizeYZ/2,WorldSizeYZ/2); //its size
236 
237  logicWorld = new G4LogicalVolume(solidWorld, //its solid
238  defaultMaterial, //its material
239  "World"); //its name
240 
241  physiWorld = new G4PVPlacement(0, //no rotation
242  G4ThreeVector(), //at (0,0,0)
243  logicWorld, //its logical volume
244  "World", //its name
245  0, //its mother volume
246  false, //no boolean operation
247  0); //copy number
248 
249  //
250  // Calorimeter
251  //
252  solidCalor=0; logicCalor=0; physiCalor=0;
253  solidLayer=0; logicLayer=0; physiLayer=0;
254 
255  if (CalorThickness > 0.)
256  { solidCalor = new G4Box("Calorimeter", //its name
257  CalorThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);//size
258 
259  logicCalor = new G4LogicalVolume(solidCalor, //its solid
260  defaultMaterial, //its material
261  "Calorimeter"); //its name
262 
263  physiCalor = new G4PVPlacement(0, //no rotation
264  G4ThreeVector(), //at (0,0,0)
265  logicCalor, //its logical volume
266  "Calorimeter", //its name
267  logicWorld, //its mother volume
268  false, //no boolean operation
269  0); //copy number
270 
271  //
272  // Layer
273  //
274  solidLayer = new G4Box("Layer", //its name
275  LayerThickness/2,CalorSizeYZ/2,CalorSizeYZ/2); //size
276 
277  logicLayer = new G4LogicalVolume(solidLayer, //its solid
278  defaultMaterial, //its material
279  "Layer"); //its name
280  if (NbOfLayers > 1)
281  physiLayer = new G4PVReplica("Layer", //its name
282  logicLayer, //its logical volume
283  logicCalor, //its mother
284  kXAxis, //axis of replication
285  NbOfLayers, //number of replica
286  LayerThickness); //witdth of replica
287  else
288  physiLayer = new G4PVPlacement(0, //no rotation
289  G4ThreeVector(), //at (0,0,0)
290  logicLayer, //its logical volume
291  "Layer", //its name
292  logicCalor, //its mother volume
293  false, //no boolean operation
294  0); //copy number
295  }
296 
297  //
298  // Absorber
299  //
300  solidAbsorber=0; logicAbsorber=0; physiAbsorber=0;
301 
302  if (AbsorberThickness > 0.)
303  { solidAbsorber = new G4Box("Absorber", //its name
304  AbsorberThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);
305 
306  logicAbsorber = new G4LogicalVolume(solidAbsorber, //its solid
307  AbsorberMaterial, //its material
308  AbsorberMaterial->GetName()); //name
309 
310  physiAbsorber = new G4PVPlacement(0, //no rotation
311  G4ThreeVector(-GapThickness/2,0.,0.), //its position
312  logicAbsorber, //its logical volume
313  AbsorberMaterial->GetName(), //its name
314  logicLayer, //its mother
315  false, //no boulean operat
316  0); //copy number
317 
318  }
319 
320  //
321  // Gap
322  //
323  solidGap=0; logicGap=0; physiGap=0;
324 
325  if (GapThickness > 0.)
326  { solidGap = new G4Box("Gap",
327  GapThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);
328 
329  logicGap = new G4LogicalVolume(solidGap,
330  GapMaterial,
331  GapMaterial->GetName());
332 
333  physiGap = new G4PVPlacement(0, //no rotation
334  G4ThreeVector(AbsorberThickness/2,0.,0.), //its position
335  logicGap, //its logical volume
336  GapMaterial->GetName(), //its name
337  logicLayer, //its mother
338  false, //no boulean operat
339  0); //copy number
340  }
341 
343 
344  //
345  // Visualization attributes
346  //
348 
349  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
350  simpleBoxVisAtt->SetVisibility(true);
351  logicCalor->SetVisAttributes(simpleBoxVisAtt);
352 
353  /*
354  // Below are vis attributes that permits someone to test / play
355  // with the interactive expansion / contraction geometry system of the
356  // vis/OpenInventor driver :
357  {G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0));
358  simpleBoxVisAtt->SetVisibility(true);
359  delete logicCalor->GetVisAttributes();
360  logicCalor->SetVisAttributes(simpleBoxVisAtt);}
361 
362  {G4VisAttributes* atb= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
363  logicLayer->SetVisAttributes(atb);}
364 
365  {G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.0,1.0,0.0));
366  atb->SetForceSolid(true);
367  logicAbsorber->SetVisAttributes(atb);}
368 
369  {//Set opacity = 0.2 then transparency = 1 - 0.2 = 0.8
370  G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.2));
371  atb->SetForceSolid(true);
372  logicGap->SetVisAttributes(atb);}
373  */
374 
375  //
376  //always return the physical World
377  //
378  return physiWorld;
379 }
380 
381 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
382 
384 {
385  G4cout << "\n------------------------------------------------------------"
386  << "\n---> The calorimeter is " << NbOfLayers << " layers of: [ "
387  << AbsorberThickness/mm << "mm of " << AbsorberMaterial->GetName()
388  << " + "
389  << GapThickness/mm << "mm of " << GapMaterial->GetName() << " ] "
390  << "\n------------------------------------------------------------\n";
391 }
392 
393 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
394 
396 {
397  // search the material by its name
398  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
399  if (pttoMaterial) AbsorberMaterial = pttoMaterial;
400 }
401 
402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
403 
405 {
406  // search the material by its name
407  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
408  if (pttoMaterial) GapMaterial = pttoMaterial;
409 }
410 
411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
412 
414 {
415  // change Absorber thickness and recompute the calorimeter parameters
416  AbsorberThickness = val;
417 }
418 
419 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
420 
422 {
423  // change Gap thickness and recompute the calorimeter parameters
424  GapThickness = val;
425 }
426 
427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
428 
430 {
431  // change the transverse size and recompute the calorimeter parameters
432  CalorSizeYZ = val;
433 }
434 
435 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
436 
438 {
439  NbOfLayers = val;
440 }
441 
442 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
443 
444 #include "G4FieldManager.hh"
446 
448 {
449  //apply a global uniform magnetic field along Z axis
450  G4FieldManager* fieldMgr
452 
453  if(magField) delete magField; //delete the existing magn field
454 
455  if(fieldValue!=0.) // create a new one if non nul
456  { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
457  fieldMgr->SetDetectorField(magField);
458  fieldMgr->CreateChordFinder(magField);
459  } else {
460  magField = 0;
461  fieldMgr->SetDetectorField(magField);
462  }
463 }
464 
465 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
466 
467 #include "G4RunManager.hh"
468 
470 {
471  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
472 }
473 
474 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
static constexpr double mm
Definition: G4SIunits.hh:115
static constexpr double mg
Definition: G4SIunits.hh:184
CLHEP::Hep3Vector G4ThreeVector
G4bool SetDetectorField(G4Field *detectorField)
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:467
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:602
int universe_mean_density
Definition: hepunit.py:307
Definition: G4Box.hh:64
void SetMeanExcitationEnergy(G4double value)
static constexpr double perCent
Definition: G4SIunits.hh:332
const G4String & GetName() const
Definition: G4Material.hh:178
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
static void Clean()
Definition: G4SolidStore.cc:79
double C(double temp)
float STP_Temperature
Definition: hepunit.py:302
int G4int
Definition: G4Types.hh:78
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
static G4PhysicalVolumeStore * GetInstance()
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4GLOB_DLL std::ostream G4cout
void SetVisibility(G4bool=true)
static constexpr double cm
Definition: G4SIunits.hh:119
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
#define pascal
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static constexpr double eV
Definition: G4SIunits.hh:215
const G4int n
static G4GeometryManager * GetInstance()
static constexpr double kelvin
Definition: G4SIunits.hh:281
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4TransportationManager * GetTransportationManager()
G4FieldManager * GetFieldManager() const
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
**D E S C R I P T I O N
Definition: HEPEvtcom.cc:77
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:362
static constexpr double bar
Definition: G4SIunits.hh:236
double G4double
Definition: G4Types.hh:76
void CreateChordFinder(G4MagneticField *detectorMagField)
static constexpr double atmosphere
Definition: G4SIunits.hh:237
static constexpr double mole
Definition: G4SIunits.hh:286
static const G4VisAttributes & GetInvisible()
void SetVisAttributes(const G4VisAttributes *pVA)