Geant4  10.02
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 
38 #include "G4Material.hh"
39 #include "G4NistManager.hh"
40 
41 #include "G4Tubs.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 "G4SystemOfUnits.hh"
52 #include "G4PhysicalConstants.hh"
53 #include "G4UnitsTable.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
59  fTargetMater(0), fLogicTarget(0),
60  fDetectorMater(0), fLogicDetector(0),
61  fWorldMater(0), fPhysiWorld(0),
62  fDetectorMessenger(0)
63 {
64  fTargetLength = 1*cm;
65  fTargetRadius = 0.5*cm;
66  fDetectorLength = 5*cm;
68 
71 
73 
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 { delete fDetectorMessenger;}
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  return ConstructVolumes();
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  // build materials
94  //
96  new G4Material("Germanium", 32, 72.61*g/mole, 5.323*g/cm3);
97 
98 
99  G4Element* N = new G4Element("Nitrogen", "N", 7, 14.01*g/mole);
100  G4Element* O = new G4Element("Oxygen", "O", 8, 16.00*g/mole);
101  //
102  G4int ncomponents; G4double fractionmass;
103  G4Material* Air20 = new G4Material("Air", 1.205*mg/cm3, ncomponents=2,
104  kStateGas, 293.*kelvin, 1.*atmosphere);
105  Air20->AddElement(N, fractionmass=0.7);
106  Air20->AddElement(O, fractionmass=0.3);
107  //
108  fWorldMater = Air20;
109 
110  // or use G4 materials data base
111  //
113  fTargetMater = man->FindOrBuildMaterial("G4_CESIUM_IODIDE");
114 
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
121 {
122  // Cleanup old geometry
127 
128  // World
129  //
130  // (re) compute World dimensions if necessary
133 
134  G4Tubs*
135  sWorld = new G4Tubs("World", //name
136  0.,fWorldRadius, 0.5*fWorldLength, 0.,twopi); //dimensions
137 
139  lWorld = new G4LogicalVolume(sWorld, //shape
140  fWorldMater, //material
141  "World"); //name
142 
143  fPhysiWorld = new G4PVPlacement(0, //no rotation
144  G4ThreeVector(), //at (0,0,0)
145  lWorld, //logical volume
146  "World", //name
147  0, //mother volume
148  false, //no boolean operation
149  0); //copy number
150 
151  // Target
152  //
153  G4Tubs*
154  sTarget = new G4Tubs("Target", //name
155  0., fTargetRadius, 0.5*fTargetLength, 0.,twopi); //dimensions
156 
157 
158  fLogicTarget = new G4LogicalVolume(sTarget, //shape
159  fTargetMater, //material
160  "Target"); //name
161 
162  new G4PVPlacement(0, //no rotation
163  G4ThreeVector(), //at (0,0,0)
164  fLogicTarget, //logical volume
165  "Target", //name
166  lWorld, //mother volume
167  false, //no boolean operation
168  0); //copy number
169 
170  // Detector
171  //
172  G4Tubs*
173  sDetector = new G4Tubs("Detector",
175 
176 
177  fLogicDetector = new G4LogicalVolume(sDetector, //shape
178  fDetectorMater, //material
179  "Detector"); //name
180 
181  new G4PVPlacement(0, //no rotation
182  G4ThreeVector(), //at (0,0,0)
183  fLogicDetector, //logical volume
184  "Detector", //name
185  lWorld, //mother volume
186  false, //no boolean operation
187  0); //copy number
188 
189 
190  PrintParameters();
191 
192  //always return the root volume
193  //
194  return fPhysiWorld;
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
198 
200 {
201  G4cout << "\n Target : Length = " << G4BestUnit(fTargetLength,"Length")
202  << " Radius = " << G4BestUnit(fTargetRadius,"Length")
203  << " Material = " << fTargetMater->GetName();
204  G4cout << "\n Detector : Length = " << G4BestUnit(fDetectorLength,"Length")
205  << " Tickness = " << G4BestUnit(fDetectorThickness,"Length")
206  << " Material = " << fDetectorMater->GetName() << G4endl;
207  G4cout << "\n" << fTargetMater << "\n" << fDetectorMater << G4endl;
208 }
209 
210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
211 
213 {
214  // search the material by its name
215  G4Material* pttoMaterial =
216  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
217 
218  if (pttoMaterial) {
219  fTargetMater = pttoMaterial;
222  } else {
223  G4cout << "\n--> warning from DetectorConstruction::SetTargetMaterial : "
224  << materialChoice << " not found" << G4endl;
225  }
226 }
227 
228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
229 
231 {
232  // search the material by its name
233  G4Material* pttoMaterial =
234  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
235 
236  if (pttoMaterial) {
237  fDetectorMater = pttoMaterial;
240  } else {
241  G4cout << "\n--> warning from DetectorConstruction::SetDetectorMaterial : "
242  << materialChoice << " not found" << G4endl;
243  }
244 }
245 
246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
247 
249 {
250  fTargetRadius = value;
252 }
253 
254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
255 
257 {
258  fTargetLength = value;
260 }
261 
262 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
263 
265 {
266  fDetectorThickness = value;
268 }
269 
270 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
271 
273 {
274  fDetectorLength = value;
276 }
277 
278 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
279 
281 {
282  return fTargetLength;
283 }
284 
285 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
286 
288 {
289  return fTargetRadius;
290 }
291 
292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
293 
295 {
296  return fTargetMater;
297 }
298 
299 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
300 
302 {
303  return fLogicTarget;
304 }
305 
306 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
307 
309 {
310  return fDetectorLength;
311 }
312 
313 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
314 
316 {
317  return fDetectorThickness;
318 }
319 
320 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
321 
323 {
324  return fDetectorMater;
325 }
326 
327 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
328 
330 {
331  return fLogicDetector;
332 }
333 
334 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:118
void SetDetectorMaterial(G4String)
void SetTargetLength(G4double val)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4LogicalVolume * GetLogicTarget()
void SetDetectorThickness(G4double value)
CLHEP::Hep3Vector G4ThreeVector
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
Definition: G4Tubs.hh:85
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static const double mg
Definition: G4SIunits.hh:181
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
G4LogicalVolume * fLogicTarget
static G4PhysicalVolumeStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
G4Material * GetDetectorMaterial()
void PhysicsHasBeenModified()
G4VPhysicalVolume * fPhysiWorld
static const double twopi
Definition: G4SIunits.hh:75
void SetDetectorLength(G4double value)
static G4LogicalVolumeStore * GetInstance()
static const double cm3
Definition: G4SIunits.hh:120
static G4SolidStore * GetInstance()
G4LogicalVolume * fLogicDetector
static G4GeometryManager * GetInstance()
void SetTargetMaterial(const G4String &)
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static const double kelvin
Definition: G4SIunits.hh:278
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
T max(const T t1, const T t2)
brief Return the largest of the two arguments
static const double g
Definition: G4SIunits.hh:180
void SetTargetRadius(G4double val)
static const double atmosphere
Definition: G4SIunits.hh:234
static const double mole
Definition: G4SIunits.hh:283
#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()
void SetMaterial(G4Material *pMaterial)
Messenger class that defines commands for DetectorConstruction.
G4LogicalVolume * GetLogicDetector()
const G4Material * GetTargetMaterial() const
DetectorMessenger * fDetectorMessenger