Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE06DetectorConstruction.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: RE06DetectorConstruction.cc 101905 2016-12-07 11:34:39Z gunter $
30 //
31 
33 
34 #include "G4RunManager.hh"
35 
36 #include "G4Material.hh"
37 #include "G4Box.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4PVPlacement.hh"
40 #include "G4PVReplica.hh"
41 
42 #include "G4VisAttributes.hh"
43 #include "G4Colour.hh"
44 
45 #include "G4SDManager.hh"
47 #include "G4VPrimitiveScorer.hh"
48 #include "G4PSEnergyDeposit.hh"
49 #include "G4PSNofSecondary.hh"
50 #include "G4PSTrackLength.hh"
51 #include "G4PSNofStep.hh"
53 #include "G4VSDFilter.hh"
54 #include "G4SDParticleFilter.hh"
55 #include "G4ios.hh"
56 
57 #include "RE06DetectorMessenger.hh"
59 #include "RE06ParallelWorld.hh"
60 
61 #include "G4PhysicalConstants.hh"
62 #include "G4SystemOfUnits.hh"
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
66 G4ThreadLocal G4bool RE06DetectorConstruction::fConstructedSDandField = false;
67 
70  fNumberOfLayers(40),
71  fTotalThickness (2.0*m),
72  fLayerThickness(0.),
73  fConstructed(false),
74  fWorldMaterial(0),
75  fAbsorberMaterial(0),
76  fGapMaterial(0),
77  fLayerSolid(0),
78  fGapSolid(0),
79  fWorldLogical(0),
80  fWorldPhysical(0),
81  fSerial(false),
82  fDetectorMessenger(0),
83  fVerboseLevel(1)
84 {
85  fLayerThickness = fTotalThickness / fNumberOfLayers;
86 
87  for(size_t i=0;i<3;i++)
88  {
89  fCalorLogical[i] = 0;
90  fLayerLogical[i] = 0;
91  fGapLogical[i] = 0;
92  fCalorPhysical[i] = 0;
93  fLayerPhysical[i] = 0;
94  fGapPhysical[i] = 0;
95  }
96 
97  fCalName[0] = "Calor-A";
98  fCalName[1] = "Calor-B";
99  fCalName[2] = "Calor-C";
100 
101  fDetectorMessenger = new RE06DetectorMessenger(this);
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
107 { delete fDetectorMessenger;}
108 
110 {
111  if(!fConstructed)
112  {
113  fConstructed = true;
114  DefineMaterials();
115  SetupGeometry();
116  }
117  if (GetVerboseLevel()>0) {
119  }
120  return fWorldPhysical;
121 }
122 
124 {
125  if(!fConstructedSDandField)
126  {
127  fConstructedSDandField = true;
128  SetupDetectors();
129  }
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
133 
134 void RE06DetectorConstruction::DefineMaterials()
135 {
136  G4String name, symbol; //a=mass of a mole;
137  G4double a, z, density; //z=mean number of protons;
138  G4int iz; //iz=number of protons in an isotope;
139  G4int n; // n=number of nucleons in an isotope;
140 
141  G4int ncomponents, natoms;
142  G4double abundance, fractionmass;
143  G4double temperature, pressure;
144 
145  //
146  // define Elements
147  //
148 
149  a = 1.01*g/mole;
150  G4Element* H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
151 
152  a = 12.01*g/mole;
153  G4Element* C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
154 
155  a = 14.01*g/mole;
156  G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
157 
158  a = 16.00*g/mole;
159  G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
160 
161  //
162  // define an Element from isotopes, by relative abundance
163  //
164 
165  G4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235, a=235.01*g/mole);
166  G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238, a=238.03*g/mole);
167 
168  G4Element* U = new G4Element(name="enriched Uranium",symbol="U",ncomponents=2);
169  U->AddIsotope(U5, abundance= 90.*perCent);
170  U->AddIsotope(U8, abundance= 10.*perCent);
171 
172  //
173  // define simple materials
174  //
175 
176  new G4Material(name="Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
177  new G4Material(name="Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3);
178  new G4Material(name="Iron", z=26., a=55.85*g/mole, density=7.87*g/cm3);
179  new G4Material(name="ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3);
180  new G4Material(name="He", z=2., a=4.0*g/mole, density=0.1786e-03*g/cm3);
181 
182  density = 1.390*g/cm3;
183  a = 39.95*g/mole;
184  G4Material* lAr = new G4Material(name="liquidArgon", z=18., a, density);
185 
186  density = 11.35*g/cm3;
187  a = 207.19*g/mole;
188  G4Material* Pb = new G4Material(name="Lead" , z=82., a, density);
189 
190  //
191  // define a material from elements. case 1: chemical molecule
192  //
193 
194  density = 1.000*g/cm3;
195  G4Material* H2O = new G4Material(name="Water", density, ncomponents=2);
196  H2O->AddElement(H, natoms=2);
197  H2O->AddElement(O, natoms=1);
198 
199  density = 1.032*g/cm3;
200  G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
201  Sci->AddElement(C, natoms=9);
202  Sci->AddElement(H, natoms=10);
203 
204  //
205  // define a material from elements. case 2: mixture by fractional mass
206  //
207 
208  density = 1.290*mg/cm3;
209  G4Material* Air = new G4Material(name="Air" , density, ncomponents=2);
210  Air->AddElement(N, fractionmass=0.7);
211  Air->AddElement(O, fractionmass=0.3);
212 
213  //
214  // examples of vacuum
215  //
216 
217  density = universe_mean_density;
218  pressure = 3.e-18*pascal;
219  temperature = 2.73*kelvin;
220  G4Material* Vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole,
221  density,kStateGas,temperature,pressure);
222 
223  if (GetVerboseLevel()>1) {
225  }
226 
227  //default materials of the calorimeter
228  fWorldMaterial = Vacuum;
229  fAbsorberMaterial = Pb;
230  fGapMaterial = lAr;
231 }
232 
233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
234 
235 void RE06DetectorConstruction::SetupGeometry()
236 {
237  //
238  // World
239  //
240  G4VSolid* worldSolid = new G4Box("World",2.*m,2.*m,fTotalThickness*2.);
241  fWorldLogical = new G4LogicalVolume(worldSolid,fWorldMaterial,"World");
242  fWorldPhysical = new G4PVPlacement(0,G4ThreeVector(),fWorldLogical,"World",
243  0,false,0);
244 
245  //
246  // Calorimeter
247  //
248  G4VSolid* calorSolid = new G4Box("Calor",0.5*m,0.5*m,fTotalThickness/2.);
249  G4int i;
250  for(i=0;i<3;i++)
251  {
252  fCalorLogical[i]
253  = new G4LogicalVolume(calorSolid,fAbsorberMaterial,fCalName[i]);
254  if(fSerial)
255  {
256  fCalorPhysical[i] = new G4PVPlacement(0,
257  G4ThreeVector(0.,0.,G4double(i-1)*fTotalThickness),
258  fCalorLogical[i],fCalName[i],fWorldLogical,false,i);
259  }
260  else
261  {
262  fCalorPhysical[i] = new G4PVPlacement(0,
263  G4ThreeVector(0.,G4double(i-1)*m,0.),
264  fCalorLogical[i],fCalName[i],fWorldLogical,false,i);
265  }
266  }
267 
268  //
269  // Layers --- as absorbers
270  //
271  fLayerSolid = new G4Box("Layer",0.5*m,0.5*m,fLayerThickness/2.);
272  for(i=0;i<3;i++)
273  {
274  fLayerLogical[i]
275  = new G4LogicalVolume(fLayerSolid,fAbsorberMaterial,fCalName[i]+"_LayerLog");
276  fLayerPhysical[i]
277  = new G4PVReplica(fCalName[i]+"_Layer",fLayerLogical[i],fCalorLogical[i],
278  kZAxis,fNumberOfLayers,fLayerThickness);
279  }
280 
281  //
282  // Gap
283  //
284  fGapSolid = new G4Box("Gap",0.5*m,0.5*m,fLayerThickness/4.);
285  for(i=0;i<3;i++)
286  {
287  fGapLogical[i] = new G4LogicalVolume(fGapSolid,fGapMaterial,fCalName[i]+"_Gap");
288  fGapPhysical[i] = new G4PVPlacement(0,G4ThreeVector(0.,0.,fLayerThickness/4.),
289  fGapLogical[i],fCalName[i]+"_gap",fLayerLogical[i],false,0);
290  }
291 
292  //
293  // Regions
294  //
295  for(i=0;i<3;i++)
296  {
297  G4Region* aRegion = new G4Region(fCalName[i]);
298  fCalorLogical[i]->SetRegion(aRegion);
299  aRegion->AddRootLogicalVolume(fCalorLogical[i]);
300  }
301 
302  //
303  // Visualization attributes
304  //
306  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
307  simpleBoxVisAtt->SetVisibility(true);
308  for(i=0;i<3;i++)
309  {
310  fCalorLogical[i]->SetVisAttributes(simpleBoxVisAtt);
311  fLayerLogical[i]->SetVisAttributes(simpleBoxVisAtt);
312  fGapLogical[i]->SetVisAttributes(simpleBoxVisAtt);
313  }
314 
315 }
316 
317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
318 
319 void RE06DetectorConstruction::SetupDetectors()
320 {
322  G4String filterName, particleName;
323 
324  G4SDParticleFilter* gammaFilter
325  = new G4SDParticleFilter(filterName="gammaFilter",particleName="gamma");
326  G4SDParticleFilter* electronFilter
327  = new G4SDParticleFilter(filterName="electronFilter",particleName="e-");
328  G4SDParticleFilter* positronFilter
329  = new G4SDParticleFilter(filterName="positronFilter",particleName="e+");
330  G4SDParticleFilter* epFilter
331  = new G4SDParticleFilter(filterName="epFilter");
332  epFilter->add(particleName="e-");
333  epFilter->add(particleName="e+");
334 
335 
336  for(G4int i=0;i<3;i++)
337  {
338  for(G4int j=0;j<2;j++)
339  {
340  // Loop counter j = 0 : absorber
341  // = 1 : gap
342  G4String detName = fCalName[i];
343  if(j==0)
344  { detName += "_abs"; }
345  else
346  { detName += "_gap"; }
349 
350  // The second argument in each primitive means the "level" of geometrical
351  // hierarchy, the copy number of that level is used as the key of the
352  // G4THitsMap.
353  // For absorber (j = 0), the copy number of its own physical volume is used.
354  // For gap (j = 1), the copy number of its mother physical volume is used,
355  // since there is only one physical volume of gap is placed with respect
356  // to its mother.
357  G4VPrimitiveScorer* primitive;
358  primitive = new G4PSEnergyDeposit("eDep",j);
359  det->RegisterPrimitive(primitive);
360  primitive = new G4PSNofSecondary("nGamma",j);
361  primitive->SetFilter(gammaFilter);
362  det->RegisterPrimitive(primitive);
363  primitive = new G4PSNofSecondary("nElectron",j);
364  primitive->SetFilter(electronFilter);
365  det->RegisterPrimitive(primitive);
366  primitive = new G4PSNofSecondary("nPositron",j);
367  primitive->SetFilter(positronFilter);
368  det->RegisterPrimitive(primitive);
369  primitive = new G4PSMinKinEAtGeneration("minEkinGamma",j);
370  primitive->SetFilter(gammaFilter);
371  det->RegisterPrimitive(primitive);
372  primitive = new G4PSMinKinEAtGeneration("minEkinElectron",j);
373  primitive->SetFilter(electronFilter);
374  det->RegisterPrimitive(primitive);
375  primitive = new G4PSMinKinEAtGeneration("minEkinPositron",j);
376  primitive->SetFilter(positronFilter);
377  det->RegisterPrimitive(primitive);
378  primitive = new G4PSTrackLength("trackLength",j);
379  primitive->SetFilter(epFilter);
380  det->RegisterPrimitive(primitive);
381  primitive = new G4PSNofStep("nStep",j);
382  primitive->SetFilter(epFilter);
383  det->RegisterPrimitive(primitive);
384 
385  if(j==0)
386  { SetSensitiveDetector(fLayerLogical[i], det); }
387  else
388  { SetSensitiveDetector(fGapLogical[i], det);}
389  }
390  }
392 }
393 
395 {
396  G4cout
397  << "--------------------------------------------------------" << G4endl;
398  if(fSerial)
399  { G4cout << " Calorimeters are placed in serial." << G4endl; }
400  else
401  { G4cout << " Calorimeters are placed in parallel." << G4endl; }
402  G4cout
403  << " Absorber is made of " << fAbsorberMaterial->GetName() << G4endl
404  << " Gap is made of " << fGapMaterial->GetName() << G4endl
405  << "--------------------------------------------------------" << G4endl;
406 }
407 
408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
409 
411 {
412  // search the material by its name
413  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
414  if(pttoMaterial)
415  {
416  fAbsorberMaterial = pttoMaterial;
417  if(fConstructed) for(size_t i=0;i<3;i++)
418  {
419  fCalorLogical[i]->SetMaterial(fAbsorberMaterial);
420  fLayerLogical[i]->SetMaterial(fAbsorberMaterial);
421  }
423  if (GetVerboseLevel()>1) {
425  }
426  }
427  else
428  {
429  G4cerr
430  << materialChoice << " is not defined. - Command is ignored." << G4endl;
431  }
432 }
433 
434 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
435 
437 { return fAbsorberMaterial->GetName(); }
438 
439 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
440 
442 {
443  // search the material by its name
444  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
445  if(pttoMaterial)
446  {
447  fGapMaterial = pttoMaterial;
448  if(fConstructed) for(size_t i=0;i<3;i++)
449  { fGapLogical[i]->SetMaterial(fGapMaterial); }
451  if (GetVerboseLevel()>1) {
453  }
454  }
455  else
456  {
457  G4cerr
458  << materialChoice << " is not defined. - Command is ignored." << G4endl;
459  }
460 }
461 
463 { return fGapMaterial->GetName(); }
464 
465 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
466 
468 {
469  if(fSerial==serial) return;
470  fSerial=serial;
473  if(gen) gen->SetSerial(fSerial);
474  if(!fConstructed) return;
475  for(G4int i=0;i<3;i++)
476  {
477  if(fSerial)
478  {
479  fCalorPhysical[i]
480  ->SetTranslation(G4ThreeVector(0.,0.,G4double(i-1)*2.*m));
481  }
482  else
483  {
484  fCalorPhysical[i]
485  ->SetTranslation(G4ThreeVector(0.,G4double(i-1)*m,0.));
486  }
487  }
490 }
491 
492 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
493 
495 {
496  fNumberOfLayers = nl;
497  fLayerThickness = fTotalThickness/fNumberOfLayers;
498  if(!fConstructed) return;
499 
500  fLayerSolid->SetZHalfLength(fLayerThickness/2.);
501  fGapSolid->SetZHalfLength(fLayerThickness/4.);
502  for(size_t i=0;i<3;i++)
503  {
504  fCalorLogical[i]->RemoveDaughter(fLayerPhysical[i]);
505  delete fLayerPhysical[i];
506  fLayerPhysical[i]
507  = new G4PVReplica(fCalName[i]+"_Layer",fLayerLogical[i],fCalorLogical[i],
508  kZAxis,fNumberOfLayers,fLayerThickness);
509  fGapPhysical[i]->SetTranslation(G4ThreeVector(0.,0.,fLayerThickness/4.));
510  }
512 }
513 
514 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
515 
517 {
518  static G4bool isAdded = false;
519 
520  if( isAdded ) return;
521 
522  G4String name, symbol; //a=mass of a mole;
523  G4double a, z, density; //z=mean number of protons;
524 
525  G4int ncomponents, natoms;
526 
527  //
528  // define simple materials
529  //
530 
531  new G4Material(name="Copper", z=29., a=63.546*g/mole, density=8.96*g/cm3);
532  new G4Material(name="Tungsten", z=74., a=183.84*g/mole, density=19.3*g/cm3);
533 
534  G4Element* C = G4Element::GetElement("Carbon");
535  G4Element* O = G4Element::GetElement("Oxygen");
536 
537 
538  G4Material* CO2 =
539  new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
540  kStateGas, 325.*kelvin, 50.*atmosphere);
541  CO2->AddElement(C, natoms=1);
542  CO2->AddElement(O, natoms=2);
543 
544  isAdded = true;
545 
546 }
547 
548 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GeometryHasBeenModified(G4bool prop=true)
const XML_Char * name
Definition: expat.h:151
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:174
Definition of the RE06DetectorMessenger class.
static constexpr double mg
Definition: G4SIunits.hh:184
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
static G4Element * GetElement(G4String name, G4bool warning=true)
Definition: G4Element.cc:412
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 SetVerboseLevel(G4int vl)
Definition: G4SDManager.hh:90
static constexpr double perCent
Definition: G4SIunits.hh:332
const G4String & GetName() const
Definition: G4Material.hh:178
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
void SetFilter(G4VSDFilter *f)
Definition of the RE06ParallelWorld class.
double C(double temp)
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void SetRegion(G4Region *reg)
G4GLOB_DLL std::ostream G4cout
static constexpr double m
Definition: G4SIunits.hh:129
void SetVisibility(G4bool=true)
bool G4bool
Definition: G4Types.hh:79
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
#define pascal
void SetTranslation(const G4ThreeVector &v)
G4VUserParallelWorld * GetParallelWorld(G4int i) const
const G4int n
static constexpr double kelvin
Definition: G4SIunits.hh:281
static constexpr double cm3
Definition: G4SIunits.hh:121
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetAbsorberMaterial(G4String materialChoice)
void add(const G4String &particleName)
virtual G4VPhysicalVolume * Construct()
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
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
Definition of the RE06PrimaryGeneratorAction class.
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:362
double G4double
Definition: G4Types.hh:76
Definition of the RE06DetectorConstruction class.
void SetMaterial(G4Material *pMaterial)
void SetGapMaterial(G4String materialChoice)
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)
void RemoveDaughter(const G4VPhysicalVolume *p)
G4GLOB_DLL std::ostream G4cerr