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