Geant4.10
 All Data Structures 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 77601 2013-11-26 17:08:44Z gcosmo $
27 //
28 /// \file B4cDetectorConstruction.cc
29 /// \brief Implementation of the B4cDetectorConstruction class
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  G4NistManager* 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;
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  G4double layerThickness = absoThickness + gapThickness;
116  G4double calorThickness = fNofLayers * layerThickness;
117  G4double worldSizeXY = 1.2 * calorSizeXY;
118  G4double worldSizeZ = 1.2 * calorThickness;
119 
120  // Get materials
121  G4Material* defaultMaterial = G4Material::GetMaterial("Galactic");
122  G4Material* absorberMaterial = G4Material::GetMaterial("G4_Pb");
123  G4Material* 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  G4VSolid* worldS
136  = new G4Box("World", // its name
137  worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
138 
139  G4LogicalVolume* worldLV
140  = new G4LogicalVolume(
141  worldS, // its solid
142  defaultMaterial, // its material
143  "World"); // its name
144 
145  G4VPhysicalVolume* 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  G4VSolid* calorimeterS
160  = new G4Box("Calorimeter", // its name
161  calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
162 
163  G4LogicalVolume* 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  G4VSolid* layerS
183  = new G4Box("Layer", // its name
184  calorSizeXY/2, calorSizeXY/2, layerThickness/2); //its size
185 
186  G4LogicalVolume* 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  G4VSolid* absorberS
204  = new G4Box("Abso", // its name
205  calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
206 
207  G4LogicalVolume* 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  G4VSolid* gapS
227  = new G4Box("Gap", // its name
228  calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
229 
230  G4LogicalVolume* 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 << "\n------------------------------------------------------------"
250  << "\n---> The calorimeter is " << fNofLayers << " layers of: [ "
251  << absoThickness/mm << "mm of " << absorberMaterial->GetName()
252  << " + "
253  << gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] "
254  << "\n------------------------------------------------------------\n";
255 
256  //
257  // Visualization attributes
258  //
260 
261  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
262  simpleBoxVisAtt->SetVisibility(true);
263  calorLV->SetVisAttributes(simpleBoxVisAtt);
264 
265  //
266  // Always return the physical World
267  //
268  return worldPV;
269 }
270 
271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
272 
274 {
275  // G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
276 
277  //
278  // Sensitive detectors
279  //
280  B4cCalorimeterSD* absoSD
281  = new B4cCalorimeterSD("AbsorberSD", "AbsorberHitsCollection", fNofLayers);
282  SetSensitiveDetector("AbsoLV",absoSD);
283 
284  B4cCalorimeterSD* gapSD
285  = new B4cCalorimeterSD("GapSD", "GapHitsCollection", fNofLayers);
286  SetSensitiveDetector("GapLV",gapSD);
287 
288  //
289  // Magnetic field
290  //
291  // Create global magnetic field messenger.
292  // Uniform magnetic field is then created automatically if
293  // the field value is not zero.
294  G4ThreeVector fieldValue = G4ThreeVector();
295  fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
296  fMagFieldMessenger->SetVerboseLevel(1);
297 
298  // Register the field messenger for deleting
299  G4AutoDelete::Register(fMagFieldMessenger);
300 }
301 
302 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetVerboseLevel(G4int verboseLevel)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:578
G4double z
Definition: TRTMaterials.hh:39
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
virtual G4VPhysicalVolume * Construct()
#define G4ThreadLocal
Definition: tls.hh:52
static G4NistManager * Instance()
G4double density
Definition: TRTMaterials.hh:39
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
Definition of the B4cDetectorConstruction class.
#define pascal
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
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetVisAttributes(const G4VisAttributes *pVA)