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