Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F03DetectorConstruction.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 //
30 // $Id: F03DetectorConstruction.cc 101666 2016-11-21 09:12:08Z gcosmo $
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
37 #include "F03DetectorMessenger.hh"
38 
39 #include "F03CalorimeterSD.hh"
40 #include "F03FieldSetup.hh"
41 
42 #include "G4GeometryManager.hh"
43 #include "G4PhysicalVolumeStore.hh"
44 #include "G4LogicalVolumeStore.hh"
45 #include "G4SolidStore.hh"
46 
47 #include "G4Material.hh"
48 #include "G4Tubs.hh"
49 #include "G4LogicalVolume.hh"
50 #include "G4PVPlacement.hh"
51 #include "G4RunManager.hh"
52 #include "G4AutoDelete.hh"
53 #include "G4SDManager.hh"
54 
55 #include "G4PhysicalConstants.hh"
56 #include "G4SystemOfUnits.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62  fDetectorMessenger(0),
63  fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
64  fSolidAbsorber(0), fLogicAbsorber(0), fPhysiAbsorber(0),
65  fSolidRadSlice(0), fLogicRadSlice(0), fPhysiRadSlice(0),
66  fSolidRadiator(0), fLogicRadiator(0), fPhysiRadiator(0),
67  fWorldMaterial(0), fAbsorberMaterial(0), fRadiatorMat(0),
68  // default parameter values of the calorimeter
69  fWorldSizeR( 22000.*mm),
70  fWorldSizeZ( 44000.*mm),
71  fAbsorberThickness( 1.*mm),
72  fAbsorberRadius( 20000.*mm),
73  fZAbsorber( 21990.*mm),
74  fZStartAbs( 0.),
75  fZEndAbs( 0.),
76  fRadThickness( 100.*mm),
77  fGasGap( 100.*mm),
78  fDetGap( 1.*mm),
79  fFoilNumber(1)
80 {
81  fDetectorMessenger = new F03DetectorMessenger(this);
82 
83  // create materials
84 
85  DefineMaterials();
86 
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  delete fDetectorMessenger;
94 }
95 
96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
97 
99 {
100  return ConstructCalorimeter();
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
105 void F03DetectorConstruction::DefineMaterials()
106 {
107  //This function illustrates the possible ways to define materials
108 
109  G4String name, symbol; // a=mass of a mole;
110  G4double a, z, density; // z=mean number of protons;
111  G4int nel;
112  G4int ncomponents;
113  G4double fractionmass, pressure, temperature;
114 
115  //
116  // define Elements
117  //
118 
119  a = 1.01*g/mole;
120  G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
121 
122  a = 12.01*g/mole;
123  G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a);
124 
125  a = 14.01*g/mole;
126  G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
127 
128  a = 16.00*g/mole;
129  G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
130 
131  a = 39.948*g/mole;
132  G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a);
133 
134  //
135  // define simple materials
136  //
137 
138  // Mylar
139 
140  density = 1.39*g/cm3;
141  G4Material* mylar = new G4Material(name="Mylar", density, nel=3);
142  mylar->AddElement(elO,2);
143  mylar->AddElement(elC,5);
144  mylar->AddElement(elH,4);
145 
146  // Polypropelene
147 
148  G4Material* CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2);
149  CH2->AddElement(elH,2);
150  CH2->AddElement(elC,1);
151 
152  // Krypton as detector gas, STP
153 
154  density = 3.700*mg/cm3;
155  a = 83.80*g/mole;
156  G4Material* Kr = new G4Material(name="Kr",z=36., a, density );
157 
158  // Dry air (average composition)
159 
160  density = 1.7836*mg/cm3; // STP
161  G4Material* argon = new G4Material(name="Argon" , density, ncomponents=1);
162  argon->AddElement(elAr, 1);
163 
164  density = 1.25053*mg/cm3; // STP
165  G4Material* nitrogen = new G4Material(name="N2" , density, ncomponents=1);
166  nitrogen->AddElement(elN, 2);
167 
168  density = 1.4289*mg/cm3; // STP
169  G4Material* oxygen = new G4Material(name="O2" , density, ncomponents=1);
170  oxygen->AddElement(elO, 2);
171 
172  density = 1.2928*mg/cm3; // STP
173  density *= 1.0e-8; // pumped vacuum
174  temperature = STP_Temperature;
175  pressure = 1.0e-8*STP_Pressure;
176 
177  G4Material* air = new G4Material(name="Air" , density, ncomponents=3,
178  kStateGas,temperature,pressure);
179  air->AddMaterial( nitrogen, fractionmass = 0.7557 );
180  air->AddMaterial( oxygen, fractionmass = 0.2315 );
181  air->AddMaterial( argon, fractionmass = 0.0128 );
182 
183  // Xenon as detector gas, STP
184 
185  density = 5.858*mg/cm3;
186  a = 131.29*g/mole;
187  G4Material* Xe = new G4Material(name="Xenon",z=54., a, density );
188 
189  // Carbon dioxide, STP
190 
191  density = 1.842*mg/cm3;
192  G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2);
193  CarbonDioxide->AddElement(elC,1);
194  CarbonDioxide->AddElement(elO,2);
195 
196  // 80% Xe + 20% CO2, STP
197 
198  density = 5.0818*mg/cm3;
199  G4Material* Xe20CO2 = new G4Material(name="Xe20CO2", density, ncomponents=2);
200  Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 );
201  Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 );
202 
203  // 80% Kr + 20% CO2, STP
204 
205  density = 3.601*mg/cm3;
206  G4Material* Kr20CO2 = new G4Material(name="Kr20CO2", density, ncomponents=2);
207  Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 );
208  Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 );
209 
211 
212  //default materials of the calorimeter and TR radiator
213 
214  fRadiatorMat = air; // CH2 ; // mylar;
215 
216  fAbsorberMaterial = air; // Kr20CO2; // XeCO2CF4;
217 
218  fWorldMaterial = air;
219 }
220 
221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
222 
223 G4VPhysicalVolume* F03DetectorConstruction::ConstructCalorimeter()
224 {
225  // Cleanup old geometry
226 
227  if (fPhysiWorld)
228  {
233  }
234 
235  // complete the Calor parameters definition and Print
236 
237  ComputeCalorParameters();
239 
240  fSolidWorld = new G4Tubs("World", // its name
241  0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size
242 
243  fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
244  fWorldMaterial, // its material
245  "World"); // its name
246 
247  fPhysiWorld = new G4PVPlacement(0, // no rotation
248  G4ThreeVector(), // at (0,0,0)
249  "World", // its name
250  fLogicWorld, // its logical volume
251  0, // its mother volume
252  false, // no boolean op.
253  0); // copy number
254 
255  // TR radiator envelope
256 
257  G4double radThick = fFoilNumber*(fRadThickness + fGasGap) + fDetGap;
258 
259  G4double zRad = fZAbsorber - 20*cm - 0.5*radThick;
260  G4cout << "zRad = " << zRad/mm << " mm" << G4endl;
261 
262  radThick *= 1.02;
263  G4cout << "radThick = " << radThick/mm << " mm" << G4endl;
264  G4cout << "fFoilNumber = " << fFoilNumber << G4endl;
265  G4cout << "fRadiatorMat = " << fRadiatorMat->GetName() << G4endl;
266  G4cout << "WorldMaterial = " << fWorldMaterial->GetName() << G4endl;
267 
268  fSolidRadiator = new G4Tubs("Radiator",0.0,
269  1.01*fAbsorberRadius,
270  0.5*radThick,0.0, twopi);
271 
272  fLogicRadiator = new G4LogicalVolume(fSolidRadiator,
273  fWorldMaterial,
274  "Radiator");
275 
276  fPhysiRadiator = new G4PVPlacement(0,
277  G4ThreeVector(0,0,zRad),
278  "Radiator", fLogicRadiator,
279  fPhysiWorld, false, 0);
280 
281  fSolidRadSlice = new G4Tubs("RadSlice",0.0,
282  fAbsorberRadius,0.5*fRadThickness,0.0,twopi);
283 
284  fLogicRadSlice = new G4LogicalVolume(fSolidRadSlice,fRadiatorMat,
285  "RadSlice",0,0,0);
286 
287  G4double zModule, zRadiator;
288  zModule = zRad + 0.5*radThick/1.02;
289  G4cout << "zModule = " << zModule/mm << " mm" << G4endl;
290 
291  for (G4int j=0;j<fFoilNumber;j++)
292  {
293  zRadiator = zModule - j*(fRadThickness + fGasGap);
294  G4cout << zRadiator/mm << " mm" << "\t";
295  // G4cout << "j = " << j << "\t";
296 
297  fPhysiRadSlice = new G4PVPlacement(0,G4ThreeVector(0.,0.,zRadiator-zRad),
298  "RadSlice",fLogicRadSlice,
299  fPhysiRadiator,false,j);
300  }
301  G4cout << G4endl;
302 
303  // Absorber
304 
305  fSolidAbsorber = new G4Tubs("Absorber", 1.0*mm,
306  fAbsorberRadius,
307  fAbsorberThickness/2.,
308  0.0,twopi);
309 
310  fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber,
311  fAbsorberMaterial,
312  "Absorber");
313 
314  fPhysiAbsorber = new G4PVPlacement(0,
315  G4ThreeVector(0.,0.,fZAbsorber),
316  "Absorber",
317  fLogicAbsorber,
318  fPhysiWorld,
319  false,
320  0);
321 
322  return fPhysiWorld;
323 }
324 
325 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
326 
328 {
329  G4cout << "\n The WORLD is made of "
330  << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName();
331  G4cout << ", the transverse size (R) of the world is "
332  << fWorldSizeR/mm << " mm. " << G4endl;
333  G4cout << " The ABSORBER is made of "
334  << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName();
335  G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm
336  << " mm. " << G4endl;
337  G4cout << " Z position of the (middle of the) absorber "
338  << fZAbsorber/mm << " mm." << G4endl;
339  G4cout << G4endl;
340 }
341 
342 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
343 
345 {
346  // get the pointer to the material table
347  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
348 
349  // search the material by its name
351  for (size_t j=0 ; j<theMaterialTable->size() ; j++)
352  { material = (*theMaterialTable)[j];
353  if (material->GetName() == materialChoice)
354  {
355  fAbsorberMaterial = material;
356  fLogicAbsorber->SetMaterial(material);
358  }
359  }
360 }
361 
362 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
363 
365 {
366  // get the pointer to the material table
367  const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
368 
369  // search the material by its name
371  for (size_t j=0 ; j<theMaterialTable->size() ; j++)
372  { material = (*theMaterialTable)[j];
373  if(material->GetName() == materialChoice)
374  {
375  fWorldMaterial = material;
376  fLogicWorld->SetMaterial(material);
378  }
379  }
380 }
381 
382 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
383 
385 {
386  // change Absorber thickness and recompute the calorimeter parameters
387  fAbsorberThickness = val;
388  ComputeCalorParameters();
390 }
391 
392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
393 
395 {
396  // change the transverse size and recompute the calorimeter parameters
397  fAbsorberRadius = val;
398  ComputeCalorParameters();
400 }
401 
402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
403 
405 {
406  fWorldSizeZ = val;
407  ComputeCalorParameters();
409 }
410 
411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
412 
414 {
415  fWorldSizeR = val;
416  ComputeCalorParameters();
418 }
419 
420 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
421 
423 {
424  fZAbsorber = val;
425  ComputeCalorParameters();
427 }
428 
429 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
430 
432 {
433  // Sensitive Detectors: Absorber
434 
435  if (!fCalorimeterSD.Get()) {
436  F03CalorimeterSD* calorimeterSD = new F03CalorimeterSD("CalorSD",this);
437  fCalorimeterSD.Put(calorimeterSD);
438  }
439  G4SDManager::GetSDMpointer()->AddNewDetector(fCalorimeterSD.Get());
440  SetSensitiveDetector(fLogicAbsorber, fCalorimeterSD.Get());
441 
442  // Construct the field creator - this will register the field it creates
443 
444  if (!fEmFieldSetup.Get()) {
445  F03FieldSetup* emFieldSetup = new F03FieldSetup();
446 
447  fEmFieldSetup.Put(emFieldSetup);
448  G4AutoDelete::Register(emFieldSetup); //Kernel will delete the messenger
449  }
450  // Set local field manager and local field in radiator and its daughters:
451  G4bool allLocal = true;
452  fLogicRadiator->SetFieldManager(fEmFieldSetup.Get()->GetLocalFieldManager(),
453  allLocal );
454 }
455 
456 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4FieldManager * GetLocalFieldManager()
const XML_Char * name
Definition: expat.h:151
static constexpr double mm
Definition: G4SIunits.hh:115
static constexpr double mg
Definition: G4SIunits.hh:184
CLHEP::Hep3Vector G4ThreeVector
void AddMaterial(G4Material *material, G4double fraction)
Definition: G4Material.cc:467
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
const G4String & GetName() const
Definition: G4Material.hh:178
value_type & Get() const
Definition: G4Cache.hh:282
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
std::vector< G4Material * > G4MaterialTable
static void Clean()
Definition: G4SolidStore.cc:79
float STP_Temperature
Definition: hepunit.py:302
int G4int
Definition: G4Types.hh:78
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters)
static constexpr double twopi
Definition: G4SIunits.hh:76
Definition of the F03DetectorConstruction class.
static G4PhysicalVolumeStore * GetInstance()
string material
Definition: eplot.py:19
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
bool G4bool
Definition: G4Types.hh:79
static constexpr double cm
Definition: G4SIunits.hh:119
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
Definition of the F03CalorimeterSD class.
static constexpr double cm3
Definition: G4SIunits.hh:121
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
Definition of the F03DetectorMessenger class.
void OpenGeometry(G4VPhysicalVolume *vol=0)
virtual G4VPhysicalVolume * Construct()
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:362
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
Definition of the F03FieldSetup class.
void Put(const value_type &val) const
Definition: G4Cache.hh:286
static constexpr double mole
Definition: G4SIunits.hh:286
int STP_Pressure
Definition: hepunit.py:303