Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
B4d::DetectorConstruction Class Reference
basic » B4 » B4d

Detector construction class to define materials and geometry. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B4d::DetectorConstruction:
G4VUserDetectorConstruction

Public Member Functions

 DetectorConstruction ()=default
 
 ~DetectorConstruction () override=default
 
G4VPhysicalVolumeConstruct () override
 
void ConstructSDandField () override
 

Private Member Functions

void DefineMaterials ()
 
G4VPhysicalVolumeDefineVolumes ()
 

Private Attributes

G4bool fCheckOverlaps = true
 

Static Private Attributes

static G4ThreadLocal G4GlobalMagFieldMessengerfMagFieldMessenger = nullptr
 

Detailed Description

Detector construction class to define materials and geometry.

The calorimeter is a box made of a given number of layers. A layer consists of an absorber plate and of a detection gap. The layer is replicated.

Four parameters define the geometry of the calorimeter :

In ConstructSDandField() sensitive detectors of G4MultiFunctionalDetector type with primitive scorers are created and associated with the Absorber and Gap volumes. In addition a transverse uniform magnetic field is defined via G4GlobalMagFieldMessenger class.

Definition at line 173 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ DetectorConstruction()

B4d::DetectorConstruction::DetectorConstruction ( )
default

◆ ~DetectorConstruction()

B4d::DetectorConstruction::~DetectorConstruction ( )
overridedefault

Member Function Documentation

◆ Construct()

G4VPhysicalVolume * B4d::DetectorConstruction::Construct ( )
override

Definition at line 65 of file DetectorConstruction.cc.

66{
67 // Define materials
69
70 // Define volumes
71 return DefineVolumes();
72}
G4VPhysicalVolume * DefineVolumes()

◆ ConstructSDandField()

void B4d::DetectorConstruction::ConstructSDandField ( )
override

Definition at line 259 of file DetectorConstruction.cc.

260{
261 G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
262 //
263 // Scorers
264 //
265
266 // declare Absorber as a MultiFunctionalDetector scorer
267 //
268 auto absDetector = new G4MultiFunctionalDetector("Absorber");
269 G4SDManager::GetSDMpointer()->AddNewDetector(absDetector);
270
271 G4VPrimitiveScorer* primitive;
272 primitive = new G4PSEnergyDeposit("Edep");
273 absDetector->RegisterPrimitive(primitive);
274
275 primitive = new G4PSTrackLength("TrackLength");
276 auto charged = new G4SDChargedFilter("chargedFilter");
277 primitive ->SetFilter(charged);
278 absDetector->RegisterPrimitive(primitive);
279
280 SetSensitiveDetector("AbsoLV",absDetector);
281
282 // declare Gap as a MultiFunctionalDetector scorer
283 //
284 auto gapDetector = new G4MultiFunctionalDetector("Gap");
285 G4SDManager::GetSDMpointer()->AddNewDetector(gapDetector);
286
287 primitive = new G4PSEnergyDeposit("Edep");
288 gapDetector->RegisterPrimitive(primitive);
289
290 primitive = new G4PSTrackLength("TrackLength");
291 primitive ->SetFilter(charged);
292 gapDetector->RegisterPrimitive(primitive);
293
294 SetSensitiveDetector("GapLV",gapDetector);
295
296 //
297 // Magnetic field
298 //
299 // Create global magnetic field messenger.
300 // Uniform magnetic field is then created automatically if
301 // the field value is not zero.
302 G4ThreeVector fieldValue;
304 fMagFieldMessenger->SetVerboseLevel(1);
305
306 // Register the field messenger for deleting
307 G4AutoDelete::Register(fMagFieldMessenger);
308}
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger

◆ DefineMaterials()

void B4d::DetectorConstruction::DefineMaterials ( )
private

Definition at line 76 of file DetectorConstruction.cc.

77{
78 // Lead material defined using NIST Manager
79 auto nistManager = G4NistManager::Instance();
80 nistManager->FindOrBuildMaterial("G4_Pb");
81
82 // Liquid argon material
83 G4double a; // mass of a mole;
84 G4double z; // z=mean number of protons;
85 G4double density;
86 new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
87 // The argon by NIST Manager is a gas with a different density
88
89 // Vacuum
90 new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
91 kStateGas, 2.73*kelvin, 3.e-18*pascal);
92
93 // Print materials
94 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
95}
std::vector< ExP01TrackerHit * > a

◆ DefineVolumes()

G4VPhysicalVolume * B4d::DetectorConstruction::DefineVolumes ( )
private

Definition at line 99 of file DetectorConstruction.cc.

100{
101 // Geometry parameters
102 G4int nofLayers = 10;
103 G4double absoThickness = 10.*mm;
104 G4double gapThickness = 5.*mm;
105 G4double calorSizeXY = 10.*cm;
106
107 auto layerThickness = absoThickness + gapThickness;
108 auto calorThickness = nofLayers * layerThickness;
109 auto worldSizeXY = 1.2 * calorSizeXY;
110 auto worldSizeZ = 1.2 * calorThickness;
111
112 // Get materials
113 auto defaultMaterial = G4Material::GetMaterial("Galactic");
114 auto absorberMaterial = G4Material::GetMaterial("G4_Pb");
115 auto gapMaterial = G4Material::GetMaterial("liquidArgon");
116
117 if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
118 G4ExceptionDescription msg;
119 msg << "Cannot retrieve materials already defined.";
120 G4Exception("DetectorConstruction::DefineVolumes()",
121 "MyCode0001", FatalException, msg);
122 }
123
124 //
125 // World
126 //
127 auto worldS
128 = new G4Box("World", // its name
129 worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
130
131 auto worldLV
132 = new G4LogicalVolume(
133 worldS, // its solid
134 defaultMaterial, // its material
135 "World"); // its name
136
137 auto worldPV = new G4PVPlacement(nullptr, // no rotation
138 G4ThreeVector(), // at (0,0,0)
139 worldLV, // its logical volume
140 "World", // its name
141 nullptr, // its mother volume
142 false, // no boolean operation
143 0, // copy number
144 fCheckOverlaps); // checking overlaps
145
146 //
147 // Calorimeter
148 //
149 auto calorimeterS
150 = new G4Box("Calorimeter", // its name
151 calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
152
153 auto calorLV
154 = new G4LogicalVolume(
155 calorimeterS, // its solid
156 defaultMaterial, // its material
157 "Calorimeter"); // its name
158
159 new G4PVPlacement(nullptr, // no rotation
160 G4ThreeVector(), // at (0,0,0)
161 calorLV, // its logical volume
162 "Calorimeter", // its name
163 worldLV, // its mother volume
164 false, // no boolean operation
165 0, // copy number
166 fCheckOverlaps); // checking overlaps
167
168 //
169 // Layer
170 //
171 auto layerS
172 = new G4Box("Layer", // its name
173 calorSizeXY/2, calorSizeXY/2, layerThickness/2); // its size
174
175 auto layerLV
176 = new G4LogicalVolume(
177 layerS, // its solid
178 defaultMaterial, // its material
179 "Layer"); // its name
180
181 new G4PVReplica(
182 "Layer", // its name
183 layerLV, // its logical volume
184 calorLV, // its mother
185 kZAxis, // axis of replication
186 nofLayers, // number of replica
187 layerThickness); // witdth of replica
188
189 //
190 // Absorber
191 //
192 auto absorberS
193 = new G4Box("Abso", // its name
194 calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
195
196 auto absorberLV
197 = new G4LogicalVolume(
198 absorberS, // its solid
199 absorberMaterial, // its material
200 "AbsoLV"); // its name
201
202 new G4PVPlacement(nullptr, // no rotation
203 G4ThreeVector(0., 0., -gapThickness / 2), // its position
204 absorberLV, // its logical volume
205 "Abso", // its name
206 layerLV, // its mother volume
207 false, // no boolean operation
208 0, // copy number
209 fCheckOverlaps); // checking overlaps
210
211 //
212 // Gap
213 //
214 auto gapS
215 = new G4Box("Gap", // its name
216 calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
217
218 auto gapLV
219 = new G4LogicalVolume(
220 gapS, // its solid
221 gapMaterial, // its material
222 "GapLV"); // its name
223
224 new G4PVPlacement(nullptr, // no rotation
225 G4ThreeVector(0., 0., absoThickness / 2), // its position
226 gapLV, // its logical volume
227 "Gap", // its name
228 layerLV, // its mother volume
229 false, // no boolean operation
230 0, // copy number
231 fCheckOverlaps); // checking overlaps
232
233 //
234 // print parameters
235 //
236 G4cout
237 << G4endl
238 << "------------------------------------------------------------" << G4endl
239 << "---> The calorimeter is " << nofLayers << " layers of: [ "
240 << absoThickness/mm << "mm of " << absorberMaterial->GetName()
241 << " + "
242 << gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] " << G4endl
243 << "------------------------------------------------------------" << G4endl;
244
245 //
246 // Visualization attributes
247 //
248 worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
249 calorLV->SetVisAttributes(G4VisAttributes(G4Colour::White()));
250
251 //
252 // Always return the physical World
253 //
254 return worldPV;
255}

Member Data Documentation

◆ fMagFieldMessenger

G4ThreadLocal G4GlobalMagFieldMessenger * B4d::DetectorConstruction::fMagFieldMessenger = nullptr
staticprivate

Definition at line 76 of file DetectorConstruction.hh.

◆ fCheckOverlaps

G4bool B4d::DetectorConstruction::fCheckOverlaps = true
private

Definition at line 79 of file DetectorConstruction.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration