Geant4  10.00.p01
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 "G4LogicalVolume.hh"
42 #include "G4PVPlacement.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 #include "G4RunManager.hh"
49 
50 #include "G4UnitsTable.hh"
51 #include "G4SystemOfUnits.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
57  fPBox(0), fLBox(0), fMaterial(0), fDetectorMessenger(0)
58 {
59  fBoxSize = 1*m;
61  SetMaterial("Water_ts");
63 }
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
66 
68 { delete fDetectorMessenger;}
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 {
74  return ConstructVolumes();
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  // specific element name for thermal neutronHP
82  // (see G4NeutronHPThermalScatteringNames.cc)
83  G4Element* H = new G4Element("TS_H_of_Water" ,"H" , 1., 1.0079*g/mole);
84  G4Element* O = new G4Element("Oxygen" ,"O" , 8., 16.00*g/mole);
85 
86  G4int ncomponents, natoms;
87 
88  G4Material* H2O =
89  new G4Material("Water_ts", 1.000*g/cm3, ncomponents=2,
90  kStateLiquid, 593*kelvin, 150*bar);
91  H2O->AddElement(H, natoms=2);
92  H2O->AddElement(O, natoms=1);
94 
95  // graphite
96  G4Isotope* C12 = new G4Isotope("C12", 6, 12);
97  G4Element* elC = new G4Element("TS_C_of_Graphite","C", ncomponents=1);
98  elC->AddIsotope(C12, 100.*perCent);
99  G4Material* graphite =
100  new G4Material("graphite", 2.27*g/cm3, ncomponents=1,
101  kStateSolid, 293*kelvin, 1*atmosphere);
102  graphite->AddElement(elC, natoms=1);
103 
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 
111 {
112  // define a material from an isotope
113  //
114  G4int ncomponents;
115  G4double abundance, massfraction;
116 
117  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
118 
119  G4Element* element = new G4Element(name, symbol, ncomponents=1);
120  element->AddIsotope(isotope, abundance= 100.*perCent);
121 
122  G4Material* material = new G4Material(name, density, ncomponents=1);
123  material->AddElement(element, massfraction=100.*perCent);
124 
125  return material;
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129 
131 {
132  // Cleanup old geometry
137 
138  G4Box*
139  sBox = new G4Box("Container", //its name
140  fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
141 
142  fLBox = new G4LogicalVolume(sBox, //its shape
143  fMaterial, //its material
144  fMaterial->GetName()); //its name
145 
146  fPBox = new G4PVPlacement(0, //no rotation
147  G4ThreeVector(), //at (0,0,0)
148  fLBox, //its logical volume
149  fMaterial->GetName(), //its name
150  0, //its mother volume
151  false, //no boolean operation
152  0); //copy number
153 
154  PrintParameters();
155 
156  //always return the root volume
157  //
158  return fPBox;
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
164 {
165  G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
166  << " of " << fMaterial->GetName()
167  << "\n \n" << fMaterial << G4endl;
168 }
169 
170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
171 
172 void DetectorConstruction::SetMaterial(G4String materialChoice)
173 {
174  // search the material by its name
175  G4Material* pttoMaterial =
176  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
177 
178  if (pttoMaterial) {
179  if(fMaterial != pttoMaterial) {
180  fMaterial = pttoMaterial;
181  if(fLBox) { fLBox->SetMaterial(pttoMaterial); }
183  }
184  } else {
185  G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
186  << materialChoice << " not found" << G4endl;
187  }
188 }
189 
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191 
193 {
194  fBoxSize = value;
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199 
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:224
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4String symbol
Definition: TRTMaterials.hh:40
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:63
void SetMeanExcitationEnergy(G4double value)
G4String name
Definition: TRTMaterials.hh:40
const G4String & GetName() const
Definition: G4Material.hh:176
G4VPhysicalVolume * Construct()
G4Element * elC
Definition: TRTMaterials.hh:48
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
G4double density
Definition: TRTMaterials.hh:39
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:151
static G4LogicalVolumeStore * GetInstance()
static const double cm3
Definition: G4SIunits.hh:108
static G4SolidStore * GetInstance()
static const double perCent
Definition: G4SIunits.hh:296
static const double bar
Definition: G4SIunits.hh:215
static G4GeometryManager * GetInstance()
static const G4double A[nN]
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static const double kelvin
Definition: G4SIunits.hh:260
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
static const double eV
Definition: G4SIunits.hh:194
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)
static const double g
Definition: G4SIunits.hh:162
static const double atmosphere
Definition: G4SIunits.hh:216
static const double mole
Definition: G4SIunits.hh:265
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:110
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:345
G4VPhysicalVolume * fPBox
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * ConstructVolumes()
void SetMaterial(G4Material *pMaterial)
Messenger class that defines commands for DetectorConstruction.
DetectorMessenger * fDetectorMessenger