Geant4  10.02.p02
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 87359 2014-12-01 16:04:27Z gcosmo $
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 
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
77 
78  // Define volumes
79  return DefineVolumes();
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
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 
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
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  //
262 
263  G4VisAttributes* 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  B4cCalorimeterSD* absoSD
283  = new B4cCalorimeterSD("AbsorberSD", "AbsorberHitsCollection", fNofLayers);
284  SetSensitiveDetector("AbsoLV",absoSD);
285 
286  B4cCalorimeterSD* gapSD
287  = new B4cCalorimeterSD("GapSD", "GapHitsCollection", fNofLayers);
288  SetSensitiveDetector("GapLV",gapSD);
289 
290  //
291  // Magnetic field
292  //
293  // Create global magnetic field messenger.
294  // Uniform magnetic field is then created automatically if
295  // the field value is not zero.
296  G4ThreeVector fieldValue = G4ThreeVector();
299 
300  // Register the field messenger for deleting
302 }
303 
304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:118
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:604
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:64
const G4String & GetName() const
Definition: G4Material.hh:178
void SetVisibility(G4bool)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
virtual G4VPhysicalVolume * Construct()
G4double a
Definition: TRTMaterials.hh:39
#define G4ThreadLocal
Definition: tls.hh:89
static G4NistManager * Instance()
G4double density
Definition: TRTMaterials.hh:39
Definition of the B4cCalorimeterSD class.
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
Definition of the B4cDetectorConstruction class.
static const double cm3
Definition: G4SIunits.hh:120
G4VPhysicalVolume * DefineVolumes()
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 double kelvin
Definition: G4SIunits.hh:278
#define pascal
Definition: G4SIunits.hh:231
static const double g
Definition: G4SIunits.hh:180
static const G4VisAttributes Invisible
Calorimeter sensitive detector class.
static const double mole
Definition: G4SIunits.hh:283
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:114
void SetVisAttributes(const G4VisAttributes *pVA)