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

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

#include <Doxymodules_basic.h>

Inheritance diagram for B4::DetectorConstruction:
G4VUserDetectorConstruction

Public Member Functions

 DetectorConstruction ()=default
 
 ~DetectorConstruction () override=default
 
G4VPhysicalVolumeConstruct () override
 
void ConstructSDandField () override
 
const G4VPhysicalVolumeGetAbsorberPV () const
 
const G4VPhysicalVolumeGetGapPV () const
 

Private Member Functions

void DefineMaterials ()
 
G4VPhysicalVolumeDefineVolumes ()
 

Private Attributes

G4VPhysicalVolumefAbsorberPV = nullptr
 
G4VPhysicalVolumefGapPV = nullptr
 
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 addition a transverse uniform magnetic field is defined via G4GlobalMagFieldMessenger class.

Definition at line 123 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ DetectorConstruction()

B4::DetectorConstruction::DetectorConstruction ( )
default

◆ ~DetectorConstruction()

B4::DetectorConstruction::~DetectorConstruction ( )
overridedefault

Member Function Documentation

◆ Construct()

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

Definition at line 63 of file DetectorConstruction.cc.

64{
65 // Define materials
67
68 // Define volumes
69 return DefineVolumes();
70}
G4VPhysicalVolume * DefineVolumes()

◆ ConstructSDandField()

void B4::DetectorConstruction::ConstructSDandField ( )
override

Definition at line 257 of file DetectorConstruction.cc.

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}
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger

◆ GetAbsorberPV()

const G4VPhysicalVolume * B4::DetectorConstruction::GetAbsorberPV ( ) const
inline

Definition at line 90 of file DetectorConstruction.hh.

90 {
91 return fAbsorberPV;
92}
G4VPhysicalVolume * fAbsorberPV

◆ GetGapPV()

const G4VPhysicalVolume * B4::DetectorConstruction::GetGapPV ( ) const
inline

Definition at line 94 of file DetectorConstruction.hh.

94 {
95 return fGapPV;
96}

◆ DefineMaterials()

void B4::DetectorConstruction::DefineMaterials ( )
private

Definition at line 74 of file DetectorConstruction.cc.

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}
std::vector< ExP01TrackerHit * > a

◆ DefineVolumes()

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

Definition at line 97 of file DetectorConstruction.cc.

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}

Member Data Documentation

◆ fMagFieldMessenger

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

Definition at line 79 of file DetectorConstruction.hh.

◆ fAbsorberPV

G4VPhysicalVolume* B4::DetectorConstruction::fAbsorberPV = nullptr
private

Definition at line 82 of file DetectorConstruction.hh.

◆ fGapPV

G4VPhysicalVolume* B4::DetectorConstruction::fGapPV = nullptr
private

Definition at line 83 of file DetectorConstruction.hh.

◆ fCheckOverlaps

G4bool B4::DetectorConstruction::fCheckOverlaps = true
private

Definition at line 85 of file DetectorConstruction.hh.


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

Applications | User Support | Publications | Collaboration