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

Detector construction class to define materials, geometry and global uniform magnetic field. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B2b::DetectorConstruction:
G4VUserDetectorConstruction

Public Member Functions

 DetectorConstruction ()
 
 ~DetectorConstruction () override
 
G4VPhysicalVolumeConstruct () override
 
void ConstructSDandField () override
 
void SetTargetMaterial (G4String)
 
void SetChamberMaterial (G4String)
 
void SetMaxStep (G4double)
 
void SetCheckOverlaps (G4bool)
 

Private Member Functions

void DefineMaterials ()
 
G4VPhysicalVolumeDefineVolumes ()
 

Private Attributes

G4LogicalVolumefLogicTarget = nullptr
 
G4LogicalVolumefLogicChamber = nullptr
 
G4MaterialfTargetMaterial = nullptr
 
G4MaterialfChamberMaterial = nullptr
 
G4UserLimitsfStepLimit = nullptr
 
DetectorMessengerfMessenger = nullptr
 
G4bool fCheckOverlaps = true
 

Static Private Attributes

static G4ThreadLocal G4GlobalMagFieldMessengerfMagFieldMessenger = nullptr
 

Detailed Description

Detector construction class to define materials, geometry and global uniform magnetic field.

Definition at line 66 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ DetectorConstruction()

B2b::DetectorConstruction::DetectorConstruction ( )

Definition at line 67 of file DetectorConstruction.cc.

68{
69 fMessenger = new DetectorMessenger(this);
70}

◆ ~DetectorConstruction()

B2b::DetectorConstruction::~DetectorConstruction ( )
override

Definition at line 74 of file DetectorConstruction.cc.

75{
76 delete fStepLimit;
77 delete fMessenger;
78}

Member Function Documentation

◆ Construct()

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

Definition at line 82 of file DetectorConstruction.cc.

83{
84 // Define materials
86
87 // Define volumes
88 return DefineVolumes();
89}
G4VPhysicalVolume * DefineVolumes()

◆ ConstructSDandField()

void B2b::DetectorConstruction::ConstructSDandField ( )
override

Definition at line 270 of file DetectorConstruction.cc.

271{
272 // Sensitive detectors
273
274 G4String trackerChamberSDname = "B2/TrackerChamberSD";
275 auto aTrackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
276 G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
277 SetSensitiveDetector( fLogicChamber, aTrackerSD );
278
279 // Create global magnetic field messenger.
280 // Uniform magnetic field is then created automatically if
281 // the field value is not zero.
282 G4ThreeVector fieldValue = G4ThreeVector();
284 fMagFieldMessenger->SetVerboseLevel(1);
285
286 // Register the field messenger for deleting
287 G4AutoDelete::Register(fMagFieldMessenger);
288}
Tracker sensitive detector class.
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger

◆ SetTargetMaterial()

void B2b::DetectorConstruction::SetTargetMaterial ( G4String  materialName)

Definition at line 292 of file DetectorConstruction.cc.

293{
294 G4NistManager* nistManager = G4NistManager::Instance();
295
296 G4Material* pttoMaterial =
297 nistManager->FindOrBuildMaterial(materialName);
298
299 if (fTargetMaterial != pttoMaterial) {
300 if ( pttoMaterial ) {
301 fTargetMaterial = pttoMaterial;
302 if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
303 G4cout
304 << G4endl
305 << "----> The target is made of " << materialName << G4endl;
306 } else {
307 G4cout
308 << G4endl
309 << "--> WARNING from SetTargetMaterial : "
310 << materialName << " not found" << G4endl;
311 }
312 }
313}

◆ SetChamberMaterial()

void B2b::DetectorConstruction::SetChamberMaterial ( G4String  materialName)

Definition at line 317 of file DetectorConstruction.cc.

318{
319 G4NistManager* nistManager = G4NistManager::Instance();
320
321 G4Material* pttoMaterial =
322 nistManager->FindOrBuildMaterial(materialName);
323
324 if (fChamberMaterial != pttoMaterial) {
325 if ( pttoMaterial ) {
326 fChamberMaterial = pttoMaterial;
328 G4cout
329 << G4endl
330 << "----> The chambers are made of " << materialName << G4endl;
331 } else {
332 G4cout
333 << G4endl
334 << "--> WARNING from SetChamberMaterial : "
335 << materialName << " not found" << G4endl;
336 }
337 }
338}

◆ SetMaxStep()

void B2b::DetectorConstruction::SetMaxStep ( G4double  maxStep)

Definition at line 342 of file DetectorConstruction.cc.

343{
344 if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
345}

◆ SetCheckOverlaps()

void B2b::DetectorConstruction::SetCheckOverlaps ( G4bool  )

◆ DefineMaterials()

void B2b::DetectorConstruction::DefineMaterials ( )
private

Definition at line 93 of file DetectorConstruction.cc.

94{
95 // Material definition
96
97 G4NistManager* nistManager = G4NistManager::Instance();
98
99 // Air defined using NIST Manager
100 nistManager->FindOrBuildMaterial("G4_AIR");
101
102 // Lead defined using NIST Manager
103 fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
104
105 // Xenon gas defined using NIST Manager
106 fChamberMaterial = nistManager->FindOrBuildMaterial("G4_Xe");
107
108 // Print materials
109 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
110}

◆ DefineVolumes()

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

Set additional contraints on the track, with G4UserSpecialCuts

G4double maxLength = 2*trackerLength, maxTime = 0.1*ns, minEkin = 10*MeV; trackerLV->SetUserLimits(new G4UserLimits(maxStep, maxLength, maxTime, minEkin));

Definition at line 114 of file DetectorConstruction.cc.

115{
116 G4Material* air = G4Material::GetMaterial("G4_AIR");
117
118 // Sizes of the principal geometrical components (solids)
119
120 G4int NbOfChambers = 5;
121 G4double chamberSpacing = 80*cm; // from chamber center to center!
122
123 G4double chamberWidth = 20.0*cm; // width of the chambers
124 G4double targetLength = 5.0*cm; // full length of Target
125
126 G4double trackerLength = (NbOfChambers+1)*chamberSpacing;
127
128 G4double worldLength = 1.2 * (2*targetLength + trackerLength);
129
130 G4double targetRadius = 0.5*targetLength; // Radius of Target
131 targetLength = 0.5*targetLength; // Half length of the Target
132 G4double trackerSize = 0.5*trackerLength; // Half length of the Tracker
133
134 // Definitions of Solids, Logical Volumes, Physical Volumes
135
136 // World
137
138 G4GeometryManager::GetInstance()->SetWorldMaximumExtent(worldLength);
139
140 G4cout << "Computed tolerance = "
141 << G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()/mm
142 << " mm" << G4endl;
143
144 auto worldS = new G4Box("world", // its name
145 worldLength / 2, worldLength / 2, worldLength / 2); // its size
146 auto worldLV = new G4LogicalVolume(worldS, // its solid
147 air, // its material
148 "World"); // its name
149
150 // Must place the World Physical volume unrotated at (0,0,0).
151 //
152 auto worldPV = new G4PVPlacement(nullptr, // no rotation
153 G4ThreeVector(), // at (0,0,0)
154 worldLV, // its logical volume
155 "World", // its name
156 nullptr, // its mother volume
157 false, // no boolean operations
158 0, // copy number
159 fCheckOverlaps); // checking overlaps
160
161 // Target
162
163 G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
164
165 auto targetS = new G4Tubs("target", 0., targetRadius, targetLength, 0. * deg, 360. * deg);
166 fLogicTarget = new G4LogicalVolume(targetS, fTargetMaterial, "Target", nullptr, nullptr, nullptr);
167 new G4PVPlacement(nullptr, // no rotation
168 positionTarget, // at (x,y,z)
169 fLogicTarget, // its logical volume
170 "Target", // its name
171 worldLV, // its mother volume
172 false, // no boolean operations
173 0, // copy number
174 fCheckOverlaps); // checking overlaps
175
176 G4cout << "Target is " << 2*targetLength/cm << " cm of "
177 << fTargetMaterial->GetName() << G4endl;
178
179 // Tracker
180
181 G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
182
183 auto trackerS = new G4Tubs("tracker", 0, trackerSize, trackerSize, 0. * deg, 360. * deg);
184 auto trackerLV = new G4LogicalVolume(trackerS, air, "Tracker", nullptr, nullptr, nullptr);
185 new G4PVPlacement(nullptr, // no rotation
186 positionTracker, // at (x,y,z)
187 trackerLV, // its logical volume
188 "Tracker", // its name
189 worldLV, // its mother volume
190 false, // no boolean operations
191 0, // copy number
192 fCheckOverlaps); // checking overlaps
193
194 // Tracker segments
195
196 // An example of Parameterised volumes
197 // Dummy values for G4Tubs -- modified by parameterised volume
198
199 auto chamberS = new G4Tubs("tracker", 0, 100 * cm, 100 * cm, 0. * deg, 360. * deg);
201 new G4LogicalVolume(chamberS, fChamberMaterial, "Chamber", nullptr, nullptr, nullptr);
202
203 G4double firstPosition = -trackerSize + chamberSpacing;
204 G4double firstLength = trackerLength/10;
205 G4double lastLength = trackerLength;
206
207 G4VPVParameterisation* chamberParam =
208 new ChamberParameterisation(
209 NbOfChambers, // NoChambers
210 firstPosition, // Z of center of first
211 chamberSpacing, // Z spacing of centers
212 chamberWidth, // chamber width
213 firstLength, // initial length
214 lastLength); // final length
215
216 // dummy value : kZAxis -- modified by parameterised volume
217
218 new G4PVParameterised("Chamber", // their name
219 fLogicChamber, // their logical volume
220 trackerLV, // Mother logical volume
221 kZAxis, // Are placed along this axis
222 NbOfChambers, // Number of chambers
223 chamberParam, // The parametrisation
224 fCheckOverlaps); // checking overlaps
225
226 G4cout << "There are " << NbOfChambers << " chambers in the tracker region. "
227 << G4endl
228 << "The chambers are " << chamberWidth/cm << " cm of "
229 << fChamberMaterial->GetName() << G4endl
230 << "The distance between chamber is " << chamberSpacing/cm << " cm"
231 << G4endl;
232
233 // Visualization attributes
234
235 G4VisAttributes boxVisAtt(G4Colour::White());
236
237 worldLV ->SetVisAttributes(boxVisAtt);
238 fLogicTarget ->SetVisAttributes(boxVisAtt);
239 trackerLV ->SetVisAttributes(boxVisAtt);
240
241 G4VisAttributes chamberVisAtt(G4Colour::Yellow());
242 fLogicChamber->SetVisAttributes(chamberVisAtt);
243
244 // Example of User Limits
245 //
246 // Below is an example of how to set tracking constraints in a given
247 // logical volume
248 //
249 // Sets a max step length in the tracker region, with G4StepLimiter
250
251 G4double maxStep = 0.5*chamberWidth;
252 fStepLimit = new G4UserLimits(maxStep);
253 trackerLV->SetUserLimits(fStepLimit);
254
255 /// Set additional contraints on the track, with G4UserSpecialCuts
256 ///
257 /// G4double maxLength = 2*trackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
258 /// trackerLV->SetUserLimits(new G4UserLimits(maxStep,
259 /// maxLength,
260 /// maxTime,
261 /// minEkin));
262
263 // Always return the physical world
264
265 return worldPV;
266}

Member Data Documentation

◆ fMagFieldMessenger

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

Definition at line 73 of file DetectorConstruction.hh.

◆ fLogicTarget

G4LogicalVolume* B2b::DetectorConstruction::fLogicTarget = nullptr
private

Definition at line 76 of file DetectorConstruction.hh.

◆ fLogicChamber

G4LogicalVolume* B2b::DetectorConstruction::fLogicChamber = nullptr
private

Definition at line 77 of file DetectorConstruction.hh.

◆ fTargetMaterial

G4Material* B2b::DetectorConstruction::fTargetMaterial = nullptr
private

Definition at line 79 of file DetectorConstruction.hh.

◆ fChamberMaterial

G4Material* B2b::DetectorConstruction::fChamberMaterial = nullptr
private

Definition at line 80 of file DetectorConstruction.hh.

◆ fStepLimit

G4UserLimits* B2b::DetectorConstruction::fStepLimit = nullptr
private

Definition at line 82 of file DetectorConstruction.hh.

◆ fMessenger

DetectorMessenger* B2b::DetectorConstruction::fMessenger = nullptr
private

Definition at line 84 of file DetectorConstruction.hh.

◆ fCheckOverlaps

G4bool B2b::DetectorConstruction::fCheckOverlaps = true
private

Definition at line 86 of file DetectorConstruction.hh.


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

Applications | User Support | Publications | Collaboration