Geant4  10.02.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 78723 2014-01-20 10:32:17Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4NistManager.hh"
38 #include "G4Sphere.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4VPhysicalVolume.hh"
41 #include "G4PVPlacement.hh"
42 #include "G4PVReplica.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 "G4PhysicalConstants.hh"
52 #include "G4SystemOfUnits.hh"
53 #include "G4UserLimits.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
59  fAbsorMaterial(0),
60  fAbsor(0),
61  fDetectorMessenger(0)
62 {
63  //default tracking cut
64  fTrackingCut = 7.4*eV;
65 
66  // default parameter values
67  fAbsorRadius = 1*m;
68 
70  SetMaterial("G4_WATER");
71 
72  // create commands for interactive definition of the detector
74 }
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 { delete fDetectorMessenger;}
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  return ConstructVolumes();
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
91 {
93 
94  man->FindOrBuildMaterial("G4_WATER");
95 
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
106 
107  // Spherical absorber
108  //
109  G4Sphere*
110  sAbsor = new G4Sphere("Absorber", //name
111  0., fAbsorRadius, 0., twopi, 0., pi); //size
112 
113  fLogicalAbsor = new G4LogicalVolume(sAbsor, //solid
114  fAbsorMaterial, //material
115  "Absorber"); //name
116 
117  fAbsor = new G4PVPlacement(0, //no rotation
118  G4ThreeVector(), //at (0,0,0)
119  fLogicalAbsor, //logical volume
120  "Absorber", //name
121  0, //mother volume
122  false, //no boolean operation
123  0); //copy number
124 
125  PrintParameters();
126 
128  fTrackingCut));
129 
130  //
131  //always return the root volume
132  //
133  return fAbsor;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
139 {
140  G4cout << "\n---------------------------------------------------------\n";
141  G4cout << "---> The tracking cut to all particles is set to "
142  << G4BestUnit(fTrackingCut,"Energy") << G4endl;
143  G4cout << "---> The Absorber is a sphere of "
144  << G4BestUnit(fAbsorRadius,"Length") << " radius of "
145  << fAbsorMaterial->GetName() << " made of"
146  << "\n \n" << fAbsorMaterial << G4endl;
147  G4cout << "\n---------------------------------------------------------\n";
148 }
149 
150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151 
153 {
154  fTrackingCut = value;
156 }
157 
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159 
161 {
162  fAbsorRadius = value;
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167 
168 void DetectorConstruction::SetMaterial(G4String materialChoice)
169 {
170  // search the material by its name
171  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
172  if (pttoMaterial) fAbsorMaterial = pttoMaterial;
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:604
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
void SetUserLimits(G4UserLimits *pULimits)
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4Material * fAbsorMaterial[MaxAbsor]
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
static const double twopi
Definition: G4SIunits.hh:75
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
G4VPhysicalVolume * fAbsor
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
G4LogicalVolume * fLogicalAbsor
static const double eV
Definition: G4SIunits.hh:212
static const double pi
Definition: G4SIunits.hh:74
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:128
void OpenGeometry(G4VPhysicalVolume *vol=0)
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * ConstructVolumes()
#define DBL_MAX
Definition: templates.hh:83
Messenger class that defines commands for DetectorConstruction.
DetectorMessenger * fDetectorMessenger