Geant4  10.01.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 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58  fAbsorMaterial(0),
59  fAbsor(0),
60  fDetectorMessenger(0)
61 {
62  // default parameter values
63  fAbsorRadius = 3*cm;
64  fNbOfLayers = 1;
65 
67  SetMaterial("G4_WATER");
68 
69  // create commands for interactive definition of the detector
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 { delete fDetectorMessenger;}
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  return ConstructVolumes();
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
90 
91  man->FindOrBuildMaterial("G4_Al");
92  man->FindOrBuildMaterial("G4_Si");
93  man->FindOrBuildMaterial("G4_Fe");
94  man->FindOrBuildMaterial("G4_Ge");
95  man->FindOrBuildMaterial("G4_W");
96  man->FindOrBuildMaterial("G4_Pb");
97 
98  man->FindOrBuildMaterial("G4_AIR");
99  man->FindOrBuildMaterial("G4_WATER");
100 
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
107 {
112 
113  // Absorber
114  //
115  G4Sphere*
116  sAbsor = new G4Sphere("Absorber", //name
117  0., fAbsorRadius, 0., twopi, 0., pi); //size
118 
120  lAbsor = new G4LogicalVolume(sAbsor, //solid
121  fAbsorMaterial, //material
122  "Absorber"); //name
123 
124  fAbsor = new G4PVPlacement(0, //no rotation
125  G4ThreeVector(), //at (0,0,0)
126  lAbsor, //logical volume
127  "Absorber", //name
128  0, //mother volume
129  false, //no boolean operation
130  0); //copy number
131 
132  // Layers
133  //
135 
136  for (G4int i=1; i<=fNbOfLayers; i++) {
137  G4Sphere*
138  sLayer = new G4Sphere("Layer", (i-1)*fLayerThickness, i*fLayerThickness,
139  0., twopi, 0., pi);
140 
142  lLayer = new G4LogicalVolume(sLayer, //shape
143  fAbsorMaterial, //material
144  "Layer"); //name
145 
146  new G4PVPlacement(0, //no rotation
147  G4ThreeVector(), //at (0,0,0)
148  lLayer, //logical volume
149  "Layer", //name
150  lAbsor, //mother volume
151  false, //no boolean operation
152  i); //copy number
153 
154  }
155 
156  PrintParameters();
157 
158  //
159  //always return the root volume
160  //
161  return fAbsor;
162 }
163 
164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165 
167 {
168  G4cout << "\n---------------------------------------------------------\n";
169  G4cout << "---> The Absorber is a sphere of "
170  << G4BestUnit(fAbsorRadius,"Length") << " radius of "
171  << fAbsorMaterial->GetName() << " divided in " << fNbOfLayers
172  << " slices of " << G4BestUnit(fLayerThickness,"Length")
173  << "\n \n" << fAbsorMaterial << G4endl;
174  G4cout << "\n---------------------------------------------------------\n";
175 }
176 
177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
178 
180 {
181  fAbsorRadius = value;
183 }
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
186 
187 void DetectorConstruction::SetMaterial(G4String materialChoice)
188 {
189  // search the material by its name
190  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
191  if (pttoMaterial) fAbsorMaterial = pttoMaterial;
193 }
194 
195 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
196 
198 {
199  fNbOfLayers = value;
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:106
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:603
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
const G4double pi
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
G4Material * fAbsorMaterial[MaxAbsor]
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
G4VPhysicalVolume * fAbsor
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * ConstructVolumes()
Messenger class that defines commands for DetectorConstruction.
DetectorMessenger * fDetectorMessenger