Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.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: DetectorConstruction.cc 70755 2013-06-05 12:17:48Z ihrivnac $
30 //
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "DetectorConstruction.hh"
36 #include "DetectorMessenger.hh"
37 #include "G4Material.hh"
38 #include "G4NistManager.hh"
39 
40 #include "G4Box.hh"
41 #include "G4Sphere.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4PVPlacement.hh"
44 
45 #include "G4GeometryManager.hh"
46 #include "G4PhysicalVolumeStore.hh"
47 #include "G4LogicalVolumeStore.hh"
48 #include "G4SolidStore.hh"
49 #include "G4RunManager.hh"
50 
51 #include "G4UnitsTable.hh"
52 #include "G4SystemOfUnits.hh"
53 #include "G4PhysicalConstants.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
59  fMaterial(0), fLAbsor(0), fWorldMat(0), fPWorld(0), fDetectorMessenger(0)
60 {
61  fRadius = 30*cm;
62  fWorldSize = 1.1*fRadius;
63  DefineMaterials();
64  SetMaterial("Water_ts");
65  fDetectorMessenger = new DetectorMessenger(this);
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 { delete fDetectorMessenger;}
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {
77  return ConstructVolumes();
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
82 void DetectorConstruction::DefineMaterials()
83 {
84  // specific element name for thermal neutronHP
85  // (see G4ParticleHPThermalScatteringNames.cc)
86 
87  G4int ncomponents, natoms;
88 
89  // pressurized water
90  G4Element* H = new G4Element("TS_H_of_Water" ,"H" , 1., 1.0079*g/mole);
91  G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole);
92  G4Material* H2O =
93  new G4Material("Water_ts", 1.000*g/cm3, ncomponents=2,
94  kStateLiquid, 593*kelvin, 150*bar);
95  H2O->AddElement(H, natoms=2);
96  H2O->AddElement(O, natoms=1);
98 
99  // heavy water
100  G4Isotope* H2 = new G4Isotope("H2",1,2);
101  G4Element* D = new G4Element("TS_D_of_Heavy_Water", "D", 1);
102  D->AddIsotope(H2, 100*perCent);
103  G4Material* D2O = new G4Material("HeavyWater", 1.11*g/cm3, ncomponents=2,
104  kStateLiquid, 293.15*kelvin, 1*atmosphere);
105  D2O->AddElement(D, natoms=2);
106  D2O->AddElement(O, natoms=1);
107 
108  // graphite
109  G4Isotope* C12 = new G4Isotope("C12", 6, 12);
110  G4Element* C = new G4Element("TS_C_of_Graphite","C", ncomponents=1);
111  C->AddIsotope(C12, 100.*perCent);
112  G4Material* graphite =
113  new G4Material("graphite", 2.27*g/cm3, ncomponents=1,
114  kStateSolid, 293*kelvin, 1*atmosphere);
115  graphite->AddElement(C, natoms=1);
116 
117  //NE213
118  G4Material* ne213 =
119  new G4Material("NE213", 0.874*g/cm3, ncomponents=2);
120  ne213->AddElement(H, 9.2*perCent);
121  ne213->AddElement(C, 90.8*perCent);
122 
123  // example of vacuum
124  fWorldMat = new G4Material("Galactic", 1, 1.01*g/mole, universe_mean_density,
125  kStateGas, 2.73*kelvin, 3.e-18*pascal);
126 
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 
133  G4String symbol, G4double density, G4int Z, G4int A)
134 {
135  // define a material from an isotope
136  //
137  G4int ncomponents;
138  G4double abundance, massfraction;
139 
140  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
141 
142  G4Element* element = new G4Element(name, symbol, ncomponents=1);
143  element->AddIsotope(isotope, abundance= 100.*perCent);
144 
145  G4Material* material = new G4Material(name, density, ncomponents=1);
146  material->AddElement(element, massfraction=100.*perCent);
147 
148  return material;
149 }
150 
151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
152 
153 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
154 {
155  // Cleanup old geometry
160 
161  // World
162  //
163  G4Box*
164  sWorld = new G4Box("World", //name
165  fWorldSize,fWorldSize,fWorldSize); //dimensions
166 
168  lWorld = new G4LogicalVolume(sWorld, //shape
169  fWorldMat, //material
170  "World"); //name
171 
172  fPWorld = new G4PVPlacement(0, //no rotation
173  G4ThreeVector(), //at (0,0,0)
174  lWorld, //logical volume
175  "World", //name
176  0, //mother volume
177  false, //no boolean operation
178  0); //copy number
179 
180  // Absorber
181  //
182  G4Sphere*
183  sAbsor = new G4Sphere("Absorber", //name
184  0., fRadius, 0., twopi, 0., pi); //dimensions
185 
186  fLAbsor = new G4LogicalVolume(sAbsor, //shape
187  fMaterial, //material
188  fMaterial->GetName()); //name
189 
190  new G4PVPlacement(0, //no rotation
191  G4ThreeVector(), //at (0,0,0)
192  fLAbsor, //logical volume
193  fMaterial->GetName(), //name
194  lWorld, //mother volume
195  false, //no boolean operation
196  0); //copy number
197  PrintParameters();
198 
199  //always return the root volume
200  //
201  return fPWorld;
202 }
203 
204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205 
207 {
208  G4cout << "\n The Absorber is " << G4BestUnit(fRadius,"Length")
209  << " of " << fMaterial->GetName()
210  << "\n \n" << fMaterial << G4endl;
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
214 
215 void DetectorConstruction::SetMaterial(G4String materialChoice)
216 {
217  // search the material by its name
218  G4Material* pttoMaterial =
219  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
220 
221  if (pttoMaterial) {
222  fMaterial = pttoMaterial;
223  if(fLAbsor) { fLAbsor->SetMaterial(fMaterial); }
225  } else {
226  G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
227  << materialChoice << " not found" << G4endl;
228  }
229 }
230 
231 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
232 
234 {
235  fRadius = value;
237 }
238 
239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
240 
const XML_Char * name
Definition: expat.h:151
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
int universe_mean_density
Definition: hepunit.py:307
Definition: G4Box.hh:64
void SetMeanExcitationEnergy(G4double value)
static constexpr double perCent
Definition: G4SIunits.hh:332
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
static void Clean()
Definition: G4SolidStore.cc:79
double C(double temp)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static constexpr double twopi
Definition: G4SIunits.hh:76
static G4PhysicalVolumeStore * GetInstance()
string material
Definition: eplot.py:19
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
const XML_Char int const XML_Char * value
Definition: expat.h:331
void PhysicsHasBeenModified()
static constexpr double cm
Definition: G4SIunits.hh:119
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
#define pascal
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static constexpr double eV
Definition: G4SIunits.hh:215
static G4GeometryManager * GetInstance()
static constexpr double kelvin
Definition: G4SIunits.hh:281
static constexpr double cm3
Definition: G4SIunits.hh:121
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)
double D(double temp)
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:362
static constexpr double pi
Definition: G4SIunits.hh:75
static constexpr double bar
Definition: G4SIunits.hh:236
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
static constexpr double atmosphere
Definition: G4SIunits.hh:237
static constexpr double mole
Definition: G4SIunits.hh:286