Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/medical/fanoCavity2/src/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 //
26 /// \file medical/fanoCavity2/src/DetectorConstruction.cc
27 /// \brief Implementation of the DetectorConstruction class
28 //
29 // $Id: DetectorConstruction.cc 68763 2013-04-05 12:36:20Z 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  fWallThickness = 5*cm;
60  fCavityThickness = 2*mm;
61  fWorldRadius = 10*m;
62 
63  DefineMaterials();
64  SetWallMaterial("Water");
65 
66  // create commands for interactive definition of the detector
67  fDetectorMessenger = new DetectorMessenger(this);
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
73 { delete fDetectorMessenger;}
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  return ConstructVolumes();
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
84 void DetectorConstruction::DefineMaterials()
85 {
86  //
87  // define Elements
88  //
89  G4double z,a;
90 
91  G4Element* H = new G4Element("Hydrogen" ,"H" , z= 1., a= 1.01*g/mole);
92  G4Element* O = new G4Element("Oxygen" ,"O" , z= 8., a= 16.00*g/mole);
93 
94  //
95  // define materials
96  //
97  G4Material* H2O =
98  new G4Material("Water", 1.0*g/cm3, 2);
99  H2O->AddElement(H, 2);
100  H2O->AddElement(O, 1);
102 
103  G4Material* gas =
104  new G4Material("Water_gas", 1.0*mg/cm3, 2);
105  gas->AddElement(H, 2);
106  gas->AddElement(O, 1);
108 
109  new G4Material("Graphite", 6, 12.01*g/mole, 2.265*g/cm3);
110  new G4Material("Graphite_gas", 6, 12.01*g/mole, 2.265*mg/cm3);
111 
112  new G4Material("Aluminium", 13, 26.98*g/mole, 2.700*g/cm3);
113  new G4Material("Aluminium_gas", 13, 26.98*g/mole, 2.700*mg/cm3);
114 
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
120 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
121 {
126 
127  // Wall
128  //
129  fWorldThickness = fCavityThickness + 2*fWallThickness;
130 
131  G4Tubs*
132  sWall = new G4Tubs("Wall", //name
133  0.,fWorldRadius,0.5*fWorldThickness,0.,twopi); //size
134 
136  lWall = new G4LogicalVolume(sWall, //solid
137  fWallMaterial, //material
138  "Wall"); //name
139 
140  fWall = new G4PVPlacement(0, //no rotation
141  G4ThreeVector(), //at (0,0,0)
142  lWall, //logical volume
143  "Wall", //name
144  0, //mother volume
145  false, //no boolean operation
146  0); //copy number
147 
148  // Cavity
149  //
150  G4Tubs*
151  sCavity = new G4Tubs("Cavity",
152  0.,fWorldRadius,0.5*fCavityThickness,0.,twopi);
153 
155  lCavity = new G4LogicalVolume(sCavity, //shape
156  fCavityMaterial, //material
157  "Cavity"); //name
158 
159  fCavity = new G4PVPlacement(0, //no rotation
160  G4ThreeVector(), //at (0,0,0)
161  lCavity, //logical volume
162  "Cavity", //name
163  lWall, //mother volume
164  false, //no boolean operation
165  1); //copy number
166 
167  PrintParameters();
168 
169  //
170  //always return the root volume
171  //
172  return fWall;
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 
178 {
179  G4cout << "\n---------------------------------------------------------\n";
180  G4cout << "---> The Wall is " << G4BestUnit(fWallThickness,"Length")
181  << " of " << fWallMaterial->GetName() << " ( "
182  << G4BestUnit(fWallMaterial->GetDensity(),"Volumic Mass") << " )\n";
183  G4cout << " The Cavity is " << G4BestUnit(fCavityThickness,"Length")
184  << " of " << fCavityMaterial->GetName() << " ( "
185  << G4BestUnit(fCavityMaterial->GetDensity(),"Volumic Mass") << " )";
186  G4cout << "\n---------------------------------------------------------\n";
187  G4cout << G4endl;
188 }
189 
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191 
193 {
194  // search the material by its name
195  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
196  if (pttoMaterial) fWallMaterial = pttoMaterial;
197 
198  pttoMaterial = G4Material::GetMaterial(materialChoice + "_gas");
199  if (pttoMaterial) fCavityMaterial = pttoMaterial;
200 }
201 
202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203 
205 {
206  fWallThickness = value;
207 }
208 
209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210 
212 {
213  fCavityThickness = value;
214 
215 }
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
217 
219 {
220  fWorldRadius = value;
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 
225 #include "G4RunManager.hh"
226 
228 {
229 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
230 }
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:224
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:578
G4double z
Definition: TRTMaterials.hh:39
void SetMeanExcitationEnergy(G4double value)
const G4String & GetName() const
Definition: G4Material.hh:176
Definition: G4Tubs.hh:84
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
G4double GetDensity() const
Definition: G4Material.hh:178
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
static G4PhysicalVolumeStore * GetInstance()
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4GLOB_DLL std::ostream G4cout
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
const XML_Char int const XML_Char * value
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:345
double G4double
Definition: G4Types.hh:76