Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GB03DetectorConstruction.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 // $Id$
27 //
30 
32 
33 #include "G4RunManager.hh"
34 
35 #include "G4Material.hh"
36 #include "G4Box.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4PVPlacement.hh"
39 #include "G4PVReplica.hh"
40 
41 #include "G4VisAttributes.hh"
42 #include "G4Colour.hh"
43 
44 #include "G4SDManager.hh"
46 #include "G4PSEnergyDeposit.hh"
47 #include "G4PSFlatSurfaceFlux.hh"
48 #include "G4SDNeutralFilter.hh"
49 #include "G4SDChargedFilter.hh"
50 #include "G4ios.hh"
51 
52 #include "GB03DetectorMessenger.hh"
53 
55 
56 #include "G4PhysicalConstants.hh"
57 #include "G4SystemOfUnits.hh"
58 
59 G4int GB03DetectorConstruction::fNumberOfLayers = 40;
60 G4ThreadLocal G4bool GB03DetectorConstruction::fConstructedSDandField = false;
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
66  fTotalThickness (2.0*m), fLayerThickness(0.),
67  fConstructed(false),
68  fWorldMaterial(0), fAbsorberMaterial(0), fGapMaterial(0),
69  fLayerSolid(0), fGapSolid(0),
70  fWorldLogical(0), fCalorLogical(0), fLayerLogical(0), fGapLogical(0),
71  fWorldPhysical(0), fCalorPhysical(0), fLayerPhysical(0), fGapPhysical(0),
72  fDetectorMessenger(0), fVerboseLevel(1)
73 {
74  fLayerThickness = fTotalThickness / fNumberOfLayers;
75  fCalName = "Calor";
76  fDetectorMessenger = new GB03DetectorMessenger(this);
77 }
78 
79 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
80 
82 { delete fDetectorMessenger;}
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  if(!fConstructed)
89  {
90  fConstructed = true;
91  DefineMaterials();
92  SetupGeometry();
93  }
94  if (GetVerboseLevel()>0)
96 
97  return fWorldPhysical;
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
103 {
104  if(!fConstructedSDandField)
105  {
106  fConstructedSDandField = true;
107  SetupDetectors();
108  SetupBiasing();
109  }
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113 
114 void GB03DetectorConstruction::DefineMaterials()
115 {
116  G4String name, symbol; //a=mass of a mole;
117  G4double a, z, density; //z=mean number of protons;
118  G4int iz; //iz=number of protons in an isotope;
119  G4int n; // n=number of nucleons in an isotope;
120 
121  G4int ncomponents, natoms;
122  G4double abundance, fractionmass;
123  G4double temperature, pressure;
124 
125  //
126  // define Elements
127  //
128 
129  a = 1.01*g/mole;
130  G4Element* H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
131 
132  a = 12.01*g/mole;
133  G4Element* C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
134 
135  a = 14.01*g/mole;
136  G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
137 
138  a = 16.00*g/mole;
139  G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
140 
141  //
142  // define an Element from isotopes, by relative abundance
143  //
144 
145  G4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235, a=235.01*g/mole);
146  G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238, a=238.03*g/mole);
147 
148  G4Element* U = new G4Element(name="enriched Uranium",symbol="U",ncomponents=2);
149  U->AddIsotope(U5, abundance= 90.*perCent);
150  U->AddIsotope(U8, abundance= 10.*perCent);
151 
152  //
153  // define simple materials
154  //
155 
156  new G4Material(name="Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
157  new G4Material(name="Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3);
158  new G4Material(name="Iron", z=26., a=55.85*g/mole, density=7.87*g/cm3);
159  new G4Material(name="ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3);
160  new G4Material(name="He", z=2., a=4.0*g/mole, density=0.1786e-03*g/cm3);
161 
162  density = 1.390*g/cm3;
163  a = 39.95*g/mole;
164  new G4Material(name="liquidArgon", z=18., a, density);
165 
166  density = 11.35*g/cm3;
167  a = 207.19*g/mole;
168  G4Material* Pb = new G4Material(name="Lead" , z=82., a, density);
169 
170  //
171  // define a material from elements. case 1: chemical molecule
172  //
173 
174  density = 1.000*g/cm3;
175  G4Material* H2O = new G4Material(name="Water", density, ncomponents=2);
176  H2O->AddElement(H, natoms=2);
177  H2O->AddElement(O, natoms=1);
178 
179  density = 1.032*g/cm3;
180  G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
181  Sci->AddElement(C, natoms=9);
182  Sci->AddElement(H, natoms=10);
183 
184  //
185  // define a material from elements. case 2: mixture by fractional mass
186  //
187 
188  density = 1.290*mg/cm3;
189  G4Material* Air = new G4Material(name="Air" , density, ncomponents=2);
190  Air->AddElement(N, fractionmass=0.7);
191  Air->AddElement(O, fractionmass=0.3);
192 
193  //
194  // examples of vacuum
195  //
196 
197  density = universe_mean_density;
198  pressure = 3.e-18*pascal;
199  temperature = 2.73*kelvin;
200  G4Material* Vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole,
201  density,kStateGas,temperature,pressure);
202 
203  if (GetVerboseLevel()>1) {
205  }
206 
207  //default materials of the calorimeter
208  fWorldMaterial = Vacuum;
209  fAbsorberMaterial = Pb;
210  fGapMaterial = Sci;
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
214 
215 void GB03DetectorConstruction::SetupGeometry()
216 {
217  //
218  // World
219  //
220  G4VSolid* worldSolid = new G4Box("World",2.*m,2.*m,fTotalThickness*2.);
221  fWorldLogical = new G4LogicalVolume(worldSolid,fWorldMaterial,"World");
222  fWorldPhysical = new G4PVPlacement(0,G4ThreeVector(),fWorldLogical,"World",
223  0,false,0);
224 
225  //
226  // Calorimeter
227  //
228  G4VSolid* calorSolid = new G4Box("Calor",0.5*m,0.5*m,fTotalThickness/2.);
229  fCalorLogical = new G4LogicalVolume(calorSolid,fAbsorberMaterial,fCalName);
230  fCalorPhysical = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
231  fCalorLogical,fCalName,fWorldLogical,false,0);
232 
233  //
234  // Layers --- as absorbers
235  //
236  fLayerSolid = new G4Box("Layer",0.5*m,0.5*m,fLayerThickness/2.);
237  fLayerLogical
238  = new G4LogicalVolume(fLayerSolid,fAbsorberMaterial,fCalName+"_LayerLog");
239  fLayerPhysical
240  = new G4PVReplica(fCalName+"_Layer",fLayerLogical,fCalorLogical,
241  kZAxis,fNumberOfLayers,fLayerThickness);
242 
243  //
244  // Gap
245  //
246  fGapSolid = new G4Box("Gap",0.5*m,0.5*m,fLayerThickness/4.);
247  fGapLogical = new G4LogicalVolume(fGapSolid,fGapMaterial,fCalName+"_Gap");
248  fGapPhysical = new G4PVPlacement(0,G4ThreeVector(0.,0.,fLayerThickness/4.),
249  fGapLogical,fCalName+"_gap",fLayerLogical,false,0);
250 
251  //
252  // Visualization attributes
253  //
255  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
256  simpleBoxVisAtt->SetVisibility(true);
257  fCalorLogical->SetVisAttributes(simpleBoxVisAtt);
258  fLayerLogical->SetVisAttributes(simpleBoxVisAtt);
259  fGapLogical->SetVisAttributes(simpleBoxVisAtt);
260 
261 }
262 
263 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
264 
265 void GB03DetectorConstruction::SetupDetectors()
266 {
268  G4String filterName;
269 
270  G4SDNeutralFilter* neutralFilter
271  = new G4SDNeutralFilter(filterName="neutralFilter");
272  G4SDChargedFilter* chargedFilter
273  = new G4SDChargedFilter(filterName="chargedFilter");
274 
275  for(G4int j=0;j<2;j++)
276  {
277  // Loop counter j = 0 : absorber
278  // = 1 : gap
279  G4String detName = fCalName;
280  if(j==0)
281  { detName += "_abs"; }
282  else
283  { detName += "_gap"; }
286  // The second argument in each primitive means the "level" of geometrical
287  // hierarchy, the copy number of that level is used as the key of the
288  // G4THitsMap.
289  // For absorber (j = 0), the copy number of its own physical volume is used.
290  // For gap (j = 1), the copy number of its mother physical volume is used,
291  // since there is only one physical volume of gap is placed with respect
292  // to its mother.
293  G4VPrimitiveScorer* primitive;
294  primitive = new G4PSEnergyDeposit("eDep",j);
295  det->RegisterPrimitive(primitive);
296  primitive = new G4PSFlatSurfaceFlux("nNeutral",1,j);
297  primitive->SetFilter(neutralFilter);
298  det->RegisterPrimitive(primitive);
299  primitive = new G4PSFlatSurfaceFlux("nCharged",1,j);
300  primitive->SetFilter(chargedFilter);
301  det->RegisterPrimitive(primitive);
302 
303  if(j==0)
304  { SetSensitiveDetector(fLayerLogical, det); }
305  else
306  { SetSensitiveDetector(fGapLogical, det);}
307 
308  }
310 }
311 
312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
313 
314 void GB03DetectorConstruction::SetupBiasing()
315 {
317  biasingOperator->AttachTo(fLayerLogical);
318 }
319 
320 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
321 
323 {
324  G4cout
325  << "--------------------------------------------------------" << G4endl;
326  G4cout
327  << " Absorber is made of " << fAbsorberMaterial->GetName() << G4endl
328  << " Gap is made of " << fGapMaterial->GetName() << G4endl
329  << "--------------------------------------------------------" << G4endl;
330 }
331 
332 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
333 
335 {
336  // search the material by its name
337  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
338  if(pttoMaterial)
339  {
340  fAbsorberMaterial = pttoMaterial;
341  if(fConstructed)
342  {
343  fCalorLogical->SetMaterial(fAbsorberMaterial);
344  fLayerLogical->SetMaterial(fAbsorberMaterial);
345  }
347  if (GetVerboseLevel()>1) {
349  }
350  }
351  else
352  {
353  G4cerr
354  << materialChoice << " is not defined. - Command is ignored." << G4endl;
355  }
356 }
357 
358 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
359 
361 { return fAbsorberMaterial->GetName(); }
362 
363 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
364 
366 {
367  // search the material by its name
368  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
369  if(pttoMaterial)
370  {
371  fGapMaterial = pttoMaterial;
372  if(fConstructed)
373  { fGapLogical->SetMaterial(fGapMaterial); }
375  if (GetVerboseLevel()>1) {
377  }
378  }
379  else
380  {
381  G4cerr
382  << materialChoice << " is not defined. - Command is ignored." << G4endl;
383  }
384 }
385 
386 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
387 
389 { return fGapMaterial->GetName(); }
390 
391 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
392 
394 {
395  fNumberOfLayers = nl;
396  fLayerThickness = fTotalThickness/fNumberOfLayers;
397  if(!fConstructed) return;
398 
399  fLayerSolid->SetZHalfLength(fLayerThickness/2.);
400  fGapSolid->SetZHalfLength(fLayerThickness/4.);
401 
402  fCalorLogical->RemoveDaughter(fLayerPhysical);
403  delete fLayerPhysical;
404  fLayerPhysical
405  = new G4PVReplica(fCalName+"_Layer",fLayerLogical,fCalorLogical,
406  kZAxis,fNumberOfLayers,fLayerThickness);
407  fGapPhysical->SetTranslation(G4ThreeVector(0.,0.,fLayerThickness/4.));
408 
410 }
411 
412 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GeometryHasBeenModified(G4bool prop=true)
const XML_Char * name
Definition: expat.h:151
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:174
static constexpr double mg
Definition: G4SIunits.hh:184
CLHEP::Hep3Vector G4ThreeVector
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
Definition of the GB03DetectorConstruction class.
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 GB03BOptrGeometryBasedBiasing class.
Definition of the GB03DetectorMessenger class.
double C(double temp)
#define G4ThreadLocal
Definition: tls.hh:89
int G4int
Definition: G4Types.hh:78
void SetGapMaterial(G4String materialChoice)
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
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)
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 AttachTo(const G4LogicalVolume *)
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetAbsorberMaterial(G4String materialChoice)
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
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:362
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
static constexpr double mole
Definition: G4SIunits.hh:286
static const G4VisAttributes & GetInvisible()
virtual G4VPhysicalVolume * Construct()
void SetVisAttributes(const G4VisAttributes *pVA)
void RemoveDaughter(const G4VPhysicalVolume *p)
G4GLOB_DLL std::ostream G4cerr