Loading...
Searching...
No Matches
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//
26//
27/// \file B4/B4a/src/DetectorConstruction.cc
28/// \brief Implementation of the B4::DetectorConstruction class
29
30#include "DetectorConstruction.hh"
31
32#include "G4Material.hh"
33#include "G4NistManager.hh"
34
35#include "G4Box.hh"
36#include "G4LogicalVolume.hh"
37#include "G4PVPlacement.hh"
38#include "G4PVReplica.hh"
39#include "G4GlobalMagFieldMessenger.hh"
40#include "G4AutoDelete.hh"
41
42#include "G4GeometryManager.hh"
43#include "G4PhysicalVolumeStore.hh"
44#include "G4LogicalVolumeStore.hh"
45#include "G4SolidStore.hh"
46
47#include "G4VisAttributes.hh"
48#include "G4Colour.hh"
49
50#include "G4PhysicalConstants.hh"
51#include "G4SystemOfUnits.hh"
52
53namespace B4
54{
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58G4ThreadLocal
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
64{
65 // Define materials
67
68 // Define volumes
69 return DefineVolumes();
70}
71
72//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73
75{
76 // Lead material defined using NIST Manager
77 auto nistManager = G4NistManager::Instance();
78 nistManager->FindOrBuildMaterial("G4_Pb");
79
80 // Liquid argon material
81 G4double a; // mass of a mole;
82 G4double z; // z=mean number of protons;
83 G4double density;
84 new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
85 // The argon by NIST Manager is a gas with a different density
86
87 // Vacuum
88 new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
89 kStateGas, 2.73*kelvin, 3.e-18*pascal);
90
91 // Print materials
92 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
93}
94
95//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96
98{
99 // Geometry parameters
100 G4int nofLayers = 10;
101 G4double absoThickness = 10.*mm;
102 G4double gapThickness = 5.*mm;
103 G4double calorSizeXY = 10.*cm;
104
105 auto layerThickness = absoThickness + gapThickness;
106 auto calorThickness = nofLayers * layerThickness;
107 auto worldSizeXY = 1.2 * calorSizeXY;
108 auto worldSizeZ = 1.2 * calorThickness;
109
110 // Get materials
111 auto defaultMaterial = G4Material::GetMaterial("Galactic");
112 auto absorberMaterial = G4Material::GetMaterial("G4_Pb");
113 auto gapMaterial = G4Material::GetMaterial("liquidArgon");
114
115 if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
116 G4ExceptionDescription msg;
117 msg << "Cannot retrieve materials already defined.";
118 G4Exception("DetectorConstruction::DefineVolumes()",
119 "MyCode0001", FatalException, msg);
120 }
121
122 //
123 // World
124 //
125 auto worldS
126 = new G4Box("World", // its name
127 worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
128
129 auto worldLV
130 = new G4LogicalVolume(
131 worldS, // its solid
132 defaultMaterial, // its material
133 "World"); // its name
134
135 auto worldPV = new G4PVPlacement(nullptr, // no rotation
136 G4ThreeVector(), // at (0,0,0)
137 worldLV, // its logical volume
138 "World", // its name
139 nullptr, // its mother volume
140 false, // no boolean operation
141 0, // copy number
142 fCheckOverlaps); // checking overlaps
143
144 //
145 // Calorimeter
146 //
147 auto calorimeterS
148 = new G4Box("Calorimeter", // its name
149 calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
150
151 auto calorLV
152 = new G4LogicalVolume(
153 calorimeterS, // its solid
154 defaultMaterial, // its material
155 "Calorimeter"); // its name
156
157 new G4PVPlacement(nullptr, // no rotation
158 G4ThreeVector(), // at (0,0,0)
159 calorLV, // its logical volume
160 "Calorimeter", // its name
161 worldLV, // its mother volume
162 false, // no boolean operation
163 0, // copy number
164 fCheckOverlaps); // checking overlaps
165
166 //
167 // Layer
168 //
169 auto layerS
170 = new G4Box("Layer", // its name
171 calorSizeXY/2, calorSizeXY/2, layerThickness/2); // its size
172
173 auto layerLV
174 = new G4LogicalVolume(
175 layerS, // its solid
176 defaultMaterial, // its material
177 "Layer"); // its name
178
179 new G4PVReplica(
180 "Layer", // its name
181 layerLV, // its logical volume
182 calorLV, // its mother
183 kZAxis, // axis of replication
184 nofLayers, // number of replica
185 layerThickness); // witdth of replica
186
187 //
188 // Absorber
189 //
190 auto absorberS
191 = new G4Box("Abso", // its name
192 calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
193
194 auto absorberLV
195 = new G4LogicalVolume(
196 absorberS, // its solid
197 absorberMaterial, // its material
198 "Abso"); // its name
199
200 fAbsorberPV = new G4PVPlacement(nullptr, // no rotation
201 G4ThreeVector(0., 0., -gapThickness / 2), // its position
202 absorberLV, // its logical volume
203 "Abso", // its name
204 layerLV, // its mother volume
205 false, // no boolean operation
206 0, // copy number
207 fCheckOverlaps); // checking overlaps
208
209 //
210 // Gap
211 //
212 auto gapS
213 = new G4Box("Gap", // its name
214 calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
215
216 auto gapLV
217 = new G4LogicalVolume(
218 gapS, // its solid
219 gapMaterial, // its material
220 "Gap"); // its name
221
222 fGapPV = new G4PVPlacement(nullptr, // no rotation
223 G4ThreeVector(0., 0., absoThickness / 2), // its position
224 gapLV, // its logical volume
225 "Gap", // its name
226 layerLV, // its mother volume
227 false, // no boolean operation
228 0, // copy number
229 fCheckOverlaps); // checking overlaps
230
231 //
232 // print parameters
233 //
234 G4cout
235 << G4endl
236 << "------------------------------------------------------------" << G4endl
237 << "---> The calorimeter is " << nofLayers << " layers of: [ "
238 << absoThickness/mm << "mm of " << absorberMaterial->GetName()
239 << " + "
240 << gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] " << G4endl
241 << "------------------------------------------------------------" << G4endl;
242
243 //
244 // Visualization attributes
245 //
246 worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
247 calorLV->SetVisAttributes(G4VisAttributes(G4Colour::White()));
248
249 //
250 // Always return the physical World
251 //
252 return worldPV;
253}
254
255//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
256
258{
259 // Create global magnetic field messenger.
260 // Uniform magnetic field is then created automatically if
261 // the field value is not zero.
262 G4ThreeVector fieldValue;
264 fMagFieldMessenger->SetVerboseLevel(1);
265
266 // Register the field messenger for deleting
267 G4AutoDelete::Register(fMagFieldMessenger);
268}
269
270//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
271
272}
273
std::vector< ExP01TrackerHit * > a
G4VPhysicalVolume * Construct() override
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger
G4VPhysicalVolume * DefineVolumes()
G4VPhysicalVolume * fAbsorberPV

Applications | User Support | Publications | Collaboration