Geant4  10.01.p02
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 86064 2014-11-07 08:49:32Z gcosmo $
30 
31 //
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "DetectorConstruction.hh"
36 #include "DetectorMessenger.hh"
37 
38 #include "G4Material.hh"
39 #include "G4Tubs.hh"
40 #include "G4LogicalVolume.hh"
41 #include "G4VPhysicalVolume.hh"
42 #include "G4PVPlacement.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 
49 #include "G4UnitsTable.hh"
50 #include "G4PhysicalConstants.hh"
51 #include "G4SystemOfUnits.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 :fWallMaterial(0),fWall(0),fCavityMaterial(0),fCavity(0),fDetectorMessenger(0)
57 {
58  // default parameter values
59  fCavityThickness = 2*mm;
60  fCavityRadius = 1*cm;
61 
62  fWallThickness = 5*mm;
63 
65  SetWallMaterial("Water");
66  SetCavityMaterial("Water_vapor");
67 
68  // create commands for interactive definition of the detector
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 { delete fDetectorMessenger;}
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  return ConstructVolumes();
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  //
89  // define Elements
90  //
91  G4double z,a;
92 
93  G4Element* H = new G4Element("Hydrogen" ,"H" , z= 1., a= 1.01*g/mole);
94  G4Element* N = new G4Element("Nitrogen" ,"N" , z= 7., a= 14.01*g/mole);
95  G4Element* O = new G4Element("Oxygen" ,"O" , z= 8., a= 16.00*g/mole);
96 
97  //
98  // define materials
99  //
100  G4Material* H2O =
101  new G4Material("Water", 1.0*g/cm3, 2);
102  H2O->AddElement(H, 2);
103  H2O->AddElement(O, 1);
105 
106  G4Material* vapor =
107  new G4Material("Water_vapor", 1.0*mg/cm3, 2);
108  vapor->AddElement(H, 2);
109  vapor->AddElement(O, 1);
110  vapor->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
111 
112  G4Material* Air =
113  new G4Material("Air", 1.290*mg/cm3, 2);
114  Air->AddElement(N, 70.*perCent);
115  Air->AddElement(O, 30.*perCent);
116 
117  new G4Material("Graphite", 6, 12.01*g/mole, 2.265*g/cm3);
118  new G4Material("Graphite_gas", 6, 12.01*g/mole, 2.265*mg/cm3);
119 
120  new G4Material("Aluminium", 13, 26.98*g/mole, 2.700*g/cm3);
121  new G4Material("Aluminium_gas", 13, 26.98*g/mole, 2.700*mg/cm3);
122 
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127 
129 {
134 
135  // Chamber
136  //
139 
140  G4Tubs*
141  sChamber = new G4Tubs("Chamber", //name
142  0.,fWallRadius,0.5*fTotalThickness,0.,twopi); //size
143 
145  lChamber = new G4LogicalVolume(sChamber, //solid
146  fWallMaterial, //material
147  "Chamber"); //name
148 
149  fWall = new G4PVPlacement(0, //no rotation
150  G4ThreeVector(), //at (0,0,0)
151  lChamber, //logical volume
152  "Wall", //name
153  0, //mother volume
154  false, //no boolean operation
155  0); //copy number
156 
157  // Cavity
158  //
159  G4Tubs*
160  sCavity = new G4Tubs("Cavity",
161  0.,fCavityRadius,0.5*fCavityThickness,0.,twopi);
162 
164  lCavity = new G4LogicalVolume(sCavity, //shape
165  fCavityMaterial, //material
166  "Cavity"); //name
167 
168  fCavity = new G4PVPlacement(0, //no rotation
169  G4ThreeVector(), //at (0,0,0)
170  lCavity, //logical volume
171  "Cavity", //name
172  lChamber, //mother volume
173  false, //no boolean operation
174  1); //copy number
175 
176  PrintParameters();
177 
178  //
179  //always return the root volume
180  //
181  return fWall;
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185 
187 {
188  G4cout << "\n---------------------------------------------------------\n";
189  G4cout << "---> The Wall is " << G4BestUnit(fWallThickness,"Length")
190  << " of " << fWallMaterial->GetName() << " ( "
191  << G4BestUnit(fWallMaterial->GetDensity(),"Volumic Mass") << " )\n";
192  G4cout << " The Cavity is " << G4BestUnit(fCavityThickness,"Length")
193  << " of " << fCavityMaterial->GetName() << " ( "
194  << G4BestUnit(fCavityMaterial->GetDensity(),"Volumic Mass") << " )";
195  G4cout << "\n---------------------------------------------------------\n";
196  G4cout << G4endl;
197 }
198 
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
200 
202 {
203  fWallThickness = value;
204 }
205 
206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207 
209 {
210  // search the material by its name
211  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
212  if (pttoMaterial) fWallMaterial = pttoMaterial;
213 }
214 
215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
216 
218 {
219  fCavityThickness = value;
220 }
221 
222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
223 
225 {
226  fCavityRadius = value;
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
230 
232 {
233  // search the material by its name
234  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
235  if (pttoMaterial) fCavityMaterial = pttoMaterial;
236 }
237 
238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
239 
240 #include "G4RunManager.hh"
241 
243 {
245 }
246 
247 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:106
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
G4Material * Air
Definition: TRTMaterials.hh:57
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
G4double z
Definition: TRTMaterials.hh:39
void SetMeanExcitationEnergy(G4double value)
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:588
G4double GetDensity() const
Definition: G4Material.hh:180
static void Clean()
Definition: G4SolidStore.cc:79
G4double a
Definition: TRTMaterials.hh:39
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static const double mg
Definition: G4SIunits.hh:163
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
static G4PhysicalVolumeStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
G4VPhysicalVolume * fWall
static G4LogicalVolumeStore * GetInstance()
static const double cm3
Definition: G4SIunits.hh:108
static G4SolidStore * GetInstance()
static const double perCent
Definition: G4SIunits.hh:296
static G4GeometryManager * GetInstance()
void SetCavityMaterial(G4String)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetCavityThickness(G4double)
static const double eV
Definition: G4SIunits.hh:194
static const double g
Definition: G4SIunits.hh:162
static const double mole
Definition: G4SIunits.hh:265
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * ConstructVolumes()
G4VPhysicalVolume * fCavity
static const double mm
Definition: G4SIunits.hh:102
Messenger class that defines commands for DetectorConstruction.
DetectorMessenger * fDetectorMessenger