Geant4  10.00.p02
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 75123 2013-10-28 09:53:28Z gcosmo $
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 
68  fNumberOfLayers(40),
69  fTotalThickness (2.0*m),
70  fLayerThickness(0.),
71  fConstructed(false),
72  fConstructedSDandField(false),
73  fWorldMaterial(0),
74  fAbsorberMaterial(0),
75  fGapMaterial(0),
76  fLayerSolid(0),
77  fGapSolid(0),
78  fWorldLogical(0),
79  fWorldPhysical(0),
80  fSerial(false),
81  fDetectorMessenger(0),
82  fVerboseLevel(1)
83 {
85 
86  for(size_t i=0;i<3;i++)
87  {
88  fCalorLogical[i] = 0;
89  fLayerLogical[i] = 0;
90  fGapLogical[i] = 0;
91  fCalorPhysical[i] = 0;
92  fLayerPhysical[i] = 0;
93  fGapPhysical[i] = 0;
94  }
95 
96  fCalName[0] = "Calor-A";
97  fCalName[1] = "Calor-B";
98  fCalName[2] = "Calor-C";
99 
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
106 { delete fDetectorMessenger;}
107 
109 {
110 // if(!fConstructed)
111  {
112  fConstructed = true;
113  DefineMaterials();
114  SetupGeometry();
115  SetupDetectors();
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 
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 
236 {
237  //
238  // World
239  //
240  G4VSolid* worldSolid = new G4Box("World",2.*m,2.*m,fTotalThickness*2.);
241  fWorldLogical = new G4LogicalVolume(worldSolid,fWorldMaterial,"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,
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]
276  fLayerPhysical[i]
277  = new G4PVReplica(fCalName[i]+"_Layer",fLayerLogical[i],fCalorLogical[i],
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  {
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 
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"; }
348 
349  // The second argument in each primitive means the "level" of geometrical
350  // hierarchy, the copy number of that level is used as the key of the
351  // G4THitsMap.
352  // For absorber (j = 0), the copy number of its own physical volume is used.
353  // For gap (j = 1), the copy number of its mother physical volume is used,
354  // since there is only one physical volume of gap is placed with respect
355  // to its mother.
356  G4VPrimitiveScorer* primitive;
357  primitive = new G4PSEnergyDeposit("eDep",j);
358  det->RegisterPrimitive(primitive);
359  primitive = new G4PSNofSecondary("nGamma",j);
360  primitive->SetFilter(gammaFilter);
361  det->RegisterPrimitive(primitive);
362  primitive = new G4PSNofSecondary("nElectron",j);
363  primitive->SetFilter(electronFilter);
364  det->RegisterPrimitive(primitive);
365  primitive = new G4PSNofSecondary("nPositron",j);
366  primitive->SetFilter(positronFilter);
367  det->RegisterPrimitive(primitive);
368  primitive = new G4PSMinKinEAtGeneration("minEkinGamma",j);
369  primitive->SetFilter(gammaFilter);
370  det->RegisterPrimitive(primitive);
371  primitive = new G4PSMinKinEAtGeneration("minEkinElectron",j);
372  primitive->SetFilter(electronFilter);
373  det->RegisterPrimitive(primitive);
374  primitive = new G4PSMinKinEAtGeneration("minEkinPositron",j);
375  primitive->SetFilter(positronFilter);
376  det->RegisterPrimitive(primitive);
377  primitive = new G4PSTrackLength("trackLength",j);
378  primitive->SetFilter(epFilter);
379  det->RegisterPrimitive(primitive);
380  primitive = new G4PSNofStep("nStep",j);
381  primitive->SetFilter(epFilter);
382  det->RegisterPrimitive(primitive);
383 
384  if(j==0)
385  { SetSensitiveDetector(fLayerLogical[i], det); }
386  else
387  { SetSensitiveDetector(fGapLogical[i], det);}
388  }
389  }
391 }
392 
394 {
395  G4cout
396  << "--------------------------------------------------------" << G4endl;
397  if(fSerial)
398  { G4cout << " Calorimeters are placed in serial." << G4endl; }
399  else
400  { G4cout << " Calorimeters are placed in parallel." << G4endl; }
401  G4cout
402  << " Absorber is made of " << fAbsorberMaterial->GetName() << G4endl
403  << " Gap is made of " << fGapMaterial->GetName() << G4endl
404  << "--------------------------------------------------------" << G4endl;
405 }
406 
407 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
408 
410 {
411  // search the material by its name
412  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
413  if(pttoMaterial)
414  {
415  fAbsorberMaterial = pttoMaterial;
416  if(fConstructed) for(size_t i=0;i<3;i++)
417  {
420  }
422  if (GetVerboseLevel()>1) {
424  }
425  }
426  else
427  {
428  G4cerr
429  << materialChoice << " is not defined. - Command is ignored." << G4endl;
430  }
431 }
432 
433 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
434 
436 { return fAbsorberMaterial->GetName(); }
437 
438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
439 
441 {
442  // search the material by its name
443  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
444  if(pttoMaterial)
445  {
446  fGapMaterial = pttoMaterial;
447  if(fConstructed) for(size_t i=0;i<3;i++)
450  if (GetVerboseLevel()>1) {
452  }
453  }
454  else
455  {
456  G4cerr
457  << materialChoice << " is not defined. - Command is ignored." << G4endl;
458  }
459 }
460 
462 { return fGapMaterial->GetName(); }
463 
464 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
465 
467 {
468  if(fSerial==serial) return;
469  fSerial=serial;
472  if(gen) gen->SetSerial(fSerial);
473  if(!fConstructed) return;
474  for(G4int i=0;i<3;i++)
475  {
476  if(fSerial)
477  {
478  fCalorPhysical[i]
479  ->SetTranslation(G4ThreeVector(0.,0.,G4double(i-1)*2.*m));
480  }
481  else
482  {
483  fCalorPhysical[i]
484  ->SetTranslation(G4ThreeVector(0.,G4double(i-1)*m,0.));
485  }
486  }
489 }
490 
491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
492 
494 {
495  fNumberOfLayers = nl;
497  if(!fConstructed) return;
498 
501  for(size_t i=0;i<3;i++)
502  {
504  delete fLayerPhysical[i];
505  fLayerPhysical[i]
506  = new G4PVReplica(fCalName[i]+"_Layer",fLayerLogical[i],fCalorLogical[i],
509  }
511 }
512 
513 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
514 
516 {
517  static G4bool isAdded = false;
518 
519  if( isAdded ) return;
520 
521  G4String name, symbol; //a=mass of a mole;
522  G4double a, z, density; //z=mean number of protons;
523 
524  G4int ncomponents, natoms;
525 
526  //
527  // define simple materials
528  //
529 
530  new G4Material(name="Copper", z=29., a=63.546*g/mole, density=8.96*g/cm3);
531  new G4Material(name="Tungsten", z=74., a=183.84*g/mole, density=19.3*g/cm3);
532 
533  G4Element* C = G4Element::GetElement("Carbon");
534  G4Element* O = G4Element::GetElement("Oxygen");
535 
536 
537  G4Material* CO2 =
538  new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
539  kStateGas, 325.*kelvin, 50.*atmosphere);
540  CO2->AddElement(C, natoms=1);
541  CO2->AddElement(O, natoms=2);
542 
543  isAdded = true;
544 
545 }
546 
547 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GeometryHasBeenModified(G4bool prop=true)
RE06DetectorMessenger * fDetectorMessenger
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
const G4VUserPrimaryGeneratorAction * GetUserPrimaryGeneratorAction() const
G4String symbol
Definition: TRTMaterials.hh:40
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:173
G4Material * Air
Definition: TRTMaterials.hh:57
Definition of the RE06DetectorMessenger class.
G4VPhysicalVolume * fGapPhysical[3]
CLHEP::Hep3Vector G4ThreeVector
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:254
static G4Element * GetElement(G4String name, G4bool warning=true)
Definition: G4Element.cc:417
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:602
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:64
void SetVerboseLevel(G4int vl)
Definition: G4SDManager.hh:90
G4String name
Definition: TRTMaterials.hh:40
const G4String & GetName() const
Definition: G4Material.hh:176
void SetVisibility(G4bool)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
void SetFilter(G4VSDFilter *f)
Definition of the RE06ParallelWorld class.
G4double a
Definition: TRTMaterials.hh:39
static const double mg
Definition: G4SIunits.hh:163
int G4int
Definition: G4Types.hh:78
G4LogicalVolume * fLayerLogical[3]
G4double density
Definition: TRTMaterials.hh:39
void SetRegion(G4Region *reg)
G4GLOB_DLL std::ostream G4cout
G4double fTotalThickness
total thinkness of one calorimeter
bool G4bool
Definition: G4Types.hh:79
G4double iz
Definition: TRTMaterials.hh:39
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:151
void SetTranslation(const G4ThreeVector &v)
static const double cm3
Definition: G4SIunits.hh:108
static const double perCent
Definition: G4SIunits.hh:296
G4VUserParallelWorld * GetParallelWorld(G4int i) const
const G4int n
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static const double kelvin
Definition: G4SIunits.hh:260
#define pascal
Definition: G4SIunits.hh:213
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
void SetAbsorberMaterial(G4String materialChoice)
void add(const G4String &particleName)
static const double g
Definition: G4SIunits.hh:162
virtual G4VPhysicalVolume * Construct()
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static const G4VisAttributes Invisible
static const double atmosphere
Definition: G4SIunits.hh:216
G4double fLayerThickness
= fTotalThickness / fNumberOfLayers
static const double mole
Definition: G4SIunits.hh:265
G4LogicalVolume * fCalorLogical[3]
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:110
Definition of the RE06PrimaryGeneratorAction class.
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:363
double G4double
Definition: G4Types.hh:76
Definition of the RE06DetectorConstruction class.
G4Material * CO2
Definition: TRTMaterials.hh:81
void SetMaterial(G4Material *pMaterial)
void SetGapMaterial(G4String materialChoice)
void SetVisAttributes(const G4VisAttributes *pVA)
void RemoveDaughter(const G4VPhysicalVolume *p)
G4GLOB_DLL std::ostream G4cerr
G4VPhysicalVolume * fCalorPhysical[3]