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