Geant4_10
B4DetectorConstruction.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 // $Id: B4DetectorConstruction.cc 77601 2013-11-26 17:08:44Z gcosmo $
27 //
30 
31 #include "B4DetectorConstruction.hh"
32 
33 #include "G4Material.hh"
34 #include "G4NistManager.hh"
35 
36 #include "G4Box.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4PVPlacement.hh"
39 #include "G4PVReplica.hh"
41 #include "G4AutoDelete.hh"
42 
43 #include "G4GeometryManager.hh"
44 #include "G4PhysicalVolumeStore.hh"
45 #include "G4LogicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 
48 #include "G4VisAttributes.hh"
49 #include "G4Colour.hh"
50 
51 #include "G4PhysicalConstants.hh"
52 #include "G4SystemOfUnits.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 G4GlobalMagFieldMessenger* B4DetectorConstruction::fMagFieldMessenger = 0;
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
63  fAbsorberPV(0),
64  fGapPV(0),
65  fCheckOverlaps(true)
66 {
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
70 
72 {
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 {
79  // Define materials
80  DefineMaterials();
81 
82  // Define volumes
83  return DefineVolumes();
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
88 void B4DetectorConstruction::DefineMaterials()
89 {
90  // Lead material defined using NIST Manager
91  G4NistManager* nistManager = G4NistManager::Instance();
92  nistManager->FindOrBuildMaterial("G4_Pb");
93 
94  // Liquid argon material
95  G4double a; // mass of a mole;
96  G4double z; // z=mean number of protons;
98  new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
99  // The argon by NIST Manager is a gas with a different density
100 
101  // Vacuum
102  new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
103  kStateGas, 2.73*kelvin, 3.e-18*pascal);
104 
105  // Print materials
107 }
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110 
111 G4VPhysicalVolume* B4DetectorConstruction::DefineVolumes()
112 {
113  // Geometry parameters
114  G4int nofLayers = 10;
115  G4double absoThickness = 10.*mm;
116  G4double gapThickness = 5.*mm;
117  G4double calorSizeXY = 10.*cm;
118 
119  G4double layerThickness = absoThickness + gapThickness;
120  G4double calorThickness = nofLayers * layerThickness;
121  G4double worldSizeXY = 1.2 * calorSizeXY;
122  G4double worldSizeZ = 1.2 * calorThickness;
123 
124  // Get materials
125  G4Material* defaultMaterial = G4Material::GetMaterial("Galactic");
126  G4Material* absorberMaterial = G4Material::GetMaterial("G4_Pb");
127  G4Material* gapMaterial = G4Material::GetMaterial("liquidArgon");
128 
129  if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
131  msg << "Cannot retrieve materials already defined.";
132  G4Exception("B4DetectorConstruction::DefineVolumes()",
133  "MyCode0001", FatalException, msg);
134  }
135 
136  //
137  // World
138  //
139  G4VSolid* worldS
140  = new G4Box("World", // its name
141  worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
142 
143  G4LogicalVolume* worldLV
144  = new G4LogicalVolume(
145  worldS, // its solid
146  defaultMaterial, // its material
147  "World"); // its name
148 
149  G4VPhysicalVolume* worldPV
150  = new G4PVPlacement(
151  0, // no rotation
152  G4ThreeVector(), // at (0,0,0)
153  worldLV, // its logical volume
154  "World", // its name
155  0, // its mother volume
156  false, // no boolean operation
157  0, // copy number
158  fCheckOverlaps); // checking overlaps
159 
160  //
161  // Calorimeter
162  //
163  G4VSolid* calorimeterS
164  = new G4Box("Calorimeter", // its name
165  calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
166 
167  G4LogicalVolume* calorLV
168  = new G4LogicalVolume(
169  calorimeterS, // its solid
170  defaultMaterial, // its material
171  "Calorimeter"); // its name
172 
173  new G4PVPlacement(
174  0, // no rotation
175  G4ThreeVector(), // at (0,0,0)
176  calorLV, // its logical volume
177  "Calorimeter", // its name
178  worldLV, // its mother volume
179  false, // no boolean operation
180  0, // copy number
181  fCheckOverlaps); // checking overlaps
182 
183  //
184  // Layer
185  //
186  G4VSolid* layerS
187  = new G4Box("Layer", // its name
188  calorSizeXY/2, calorSizeXY/2, layerThickness/2); // its size
189 
190  G4LogicalVolume* layerLV
191  = new G4LogicalVolume(
192  layerS, // its solid
193  defaultMaterial, // its material
194  "Layer"); // its name
195 
196  new G4PVReplica(
197  "Layer", // its name
198  layerLV, // its logical volume
199  calorLV, // its mother
200  kZAxis, // axis of replication
201  nofLayers, // number of replica
202  layerThickness); // witdth of replica
203 
204  //
205  // Absorber
206  //
207  G4VSolid* absorberS
208  = new G4Box("Abso", // its name
209  calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
210 
211  G4LogicalVolume* absorberLV
212  = new G4LogicalVolume(
213  absorberS, // its solid
214  absorberMaterial, // its material
215  "Abso"); // its name
216 
217  fAbsorberPV
218  = new G4PVPlacement(
219  0, // no rotation
220  G4ThreeVector(0., 0., -gapThickness/2), // its position
221  absorberLV, // its logical volume
222  "Abso", // its name
223  layerLV, // its mother volume
224  false, // no boolean operation
225  0, // copy number
226  fCheckOverlaps); // checking overlaps
227 
228  //
229  // Gap
230  //
231  G4VSolid* gapS
232  = new G4Box("Gap", // its name
233  calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
234 
235  G4LogicalVolume* gapLV
236  = new G4LogicalVolume(
237  gapS, // its solid
238  gapMaterial, // its material
239  "Gap"); // its name
240 
241  fGapPV
242  = new G4PVPlacement(
243  0, // no rotation
244  G4ThreeVector(0., 0., absoThickness/2), // its position
245  gapLV, // its logical volume
246  "Gap", // its name
247  layerLV, // its mother volume
248  false, // no boolean operation
249  0, // copy number
250  fCheckOverlaps); // checking overlaps
251 
252  //
253  // print parameters
254  //
255  G4cout << "\n------------------------------------------------------------"
256  << "\n---> The calorimeter is " << nofLayers << " layers of: [ "
257  << absoThickness/mm << "mm of " << absorberMaterial->GetName()
258  << " + "
259  << gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] "
260  << "\n------------------------------------------------------------\n";
261 
262  //
263  // Visualization attributes
264  //
266 
267  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
268  simpleBoxVisAtt->SetVisibility(true);
269  calorLV->SetVisAttributes(simpleBoxVisAtt);
270 
271  //
272  // Always return the physical World
273  //
274  return worldPV;
275 }
276 
277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
278 
280 {
281  // Create global magnetic field messenger.
282  // Uniform magnetic field is then created automatically if
283  // the field value is not zero.
284  G4ThreeVector fieldValue = G4ThreeVector();
285  fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
286  fMagFieldMessenger->SetVerboseLevel(1);
287 
288  // Register the field messenger for deleting
289  G4AutoDelete::Register(fMagFieldMessenger);
290 }
291 
292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetVerboseLevel(G4int verboseLevel)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
tuple a
Definition: test.py:11
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:578
int universe_mean_density
Definition: hepunit.py:307
Definition: G4Box.hh:63
const G4String & GetName() const
Definition: G4Material.hh:176
void SetVisibility(G4bool)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
#define G4ThreadLocal
Definition: tls.hh:52
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
G4double density
Definition: TRTMaterials.hh:39
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
#define pascal
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4VPhysicalVolume * Construct()
static const G4VisAttributes Invisible
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetVisAttributes(const G4VisAttributes *pVA)