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

Applications | User Support | Publications | Collaboration