Geant4  10.02.p03
B2aDetectorConstruction Class Reference

#include <B2aDetectorConstruction.hh>

Inheritance diagram for B2aDetectorConstruction:
Collaboration diagram for B2aDetectorConstruction:

Public Member Functions

 B2aDetectorConstruction ()
 
virtual ~B2aDetectorConstruction ()
 
virtual G4VPhysicalVolumeConstruct ()
 
virtual void ConstructSDandField ()
 
void SetTargetMaterial (G4String)
 
void SetChamberMaterial (G4String)
 
void SetMaxStep (G4double)
 
void SetCheckOverlaps (G4bool)
 
- Public Member Functions inherited from G4VUserDetectorConstruction
 G4VUserDetectorConstruction ()
 
virtual ~G4VUserDetectorConstruction ()
 
virtual void CloneSD ()
 
virtual void CloneF ()
 
void RegisterParallelWorld (G4VUserParallelWorld *)
 
G4int ConstructParallelGeometries ()
 
void ConstructParallelSD ()
 
G4int GetNumberOfParallelWorld () const
 
G4VUserParallelWorldGetParallelWorld (G4int i) const
 

Private Member Functions

void DefineMaterials ()
 
G4VPhysicalVolumeDefineVolumes ()
 

Private Attributes

G4int fNbOfChambers
 
G4LogicalVolumefLogicTarget
 
G4LogicalVolume ** fLogicChamber
 
G4MaterialfTargetMaterial
 
G4MaterialfChamberMaterial
 
G4UserLimitsfStepLimit
 
B2aDetectorMessengerfMessenger
 
G4bool fCheckOverlaps
 

Static Private Attributes

static G4ThreadLocal G4GlobalMagFieldMessengerfMagFieldMessenger = 0
 

Additional Inherited Members

- Protected Member Functions inherited from G4VUserDetectorConstruction
void SetSensitiveDetector (const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
 
void SetSensitiveDetector (G4LogicalVolume *logVol, G4VSensitiveDetector *aSD)
 

Detailed Description

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

Definition at line 49 of file B2aDetectorConstruction.hh.

Constructor & Destructor Documentation

◆ B2aDetectorConstruction()

B2aDetectorConstruction::B2aDetectorConstruction ( )

Definition at line 60 of file B2aDetectorConstruction.cc.

◆ ~B2aDetectorConstruction()

B2aDetectorConstruction::~B2aDetectorConstruction ( )
virtual

Definition at line 76 of file B2aDetectorConstruction.cc.

77 {
78  delete [] fLogicChamber;
79  delete fStepLimit;
80  delete fMessenger;
81 }
B2aDetectorMessenger * fMessenger

Member Function Documentation

◆ Construct()

G4VPhysicalVolume * B2aDetectorConstruction::Construct ( void  )
virtual

Implements G4VUserDetectorConstruction.

Definition at line 85 of file B2aDetectorConstruction.cc.

86 {
87  // Define materials
89 
90  // Define volumes
91  return DefineVolumes();
92 }
G4VPhysicalVolume * DefineVolumes()
Here is the call graph for this function:

◆ ConstructSDandField()

void B2aDetectorConstruction::ConstructSDandField ( )
virtual

Reimplemented from G4VUserDetectorConstruction.

Definition at line 290 of file B2aDetectorConstruction.cc.

291 {
292  // Sensitive detectors
293 
294  G4String trackerChamberSDname = "B2/TrackerChamberSD";
295  B2TrackerSD* aTrackerSD = new B2TrackerSD(trackerChamberSDname,
296  "TrackerHitsCollection");
297  // Setting aTrackerSD to all logical volumes with the same name
298  // of "Chamber_LV".
299  SetSensitiveDetector("Chamber_LV", aTrackerSD, true);
300 
301  // Create global magnetic field messenger.
302  // Uniform magnetic field is then created automatically if
303  // the field value is not zero.
304  G4ThreeVector fieldValue = G4ThreeVector();
307 
308  // Register the field messenger for deleting
310 }
void SetVerboseLevel(G4int verboseLevel)
CLHEP::Hep3Vector G4ThreeVector
void Register(T *inst)
Definition: G4AutoDelete.hh:65
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger
Here is the call graph for this function:

◆ DefineMaterials()

void B2aDetectorConstruction::DefineMaterials ( )
private

Definition at line 96 of file B2aDetectorConstruction.cc.

97 {
98  // Material definition
99 
100  G4NistManager* nistManager = G4NistManager::Instance();
101 
102  // Air defined using NIST Manager
103  nistManager->FindOrBuildMaterial("G4_AIR");
104 
105  // Lead defined using NIST Manager
106  fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
107 
108  // Xenon gas defined using NIST Manager
109  fChamberMaterial = nistManager->FindOrBuildMaterial("G4_Xe");
110 
111  // Print materials
113 }
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
static G4NistManager * Instance()
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefineVolumes()

G4VPhysicalVolume * B2aDetectorConstruction::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 117 of file B2aDetectorConstruction.cc.

118 {
119  G4Material* air = G4Material::GetMaterial("G4_AIR");
120 
121  // Sizes of the principal geometrical components (solids)
122 
123  G4double chamberSpacing = 80*cm; // from chamber center to center!
124 
125  G4double chamberWidth = 20.0*cm; // width of the chambers
126  G4double targetLength = 5.0*cm; // full length of Target
127 
128  G4double trackerLength = (fNbOfChambers+1)*chamberSpacing;
129 
130  G4double worldLength = 1.2 * (2*targetLength + trackerLength);
131 
132  G4double targetRadius = 0.5*targetLength; // Radius of Target
133  targetLength = 0.5*targetLength; // Half length of the Target
134  G4double trackerSize = 0.5*trackerLength; // Half length of the Tracker
135 
136  // Definitions of Solids, Logical Volumes, Physical Volumes
137 
138  // World
139 
141 
142  G4cout << "Computed tolerance = "
144  << " mm" << G4endl;
145 
146  G4Box* worldS
147  = new G4Box("world", //its name
148  worldLength/2,worldLength/2,worldLength/2); //its size
149  G4LogicalVolume* worldLV
150  = new G4LogicalVolume(
151  worldS, //its solid
152  air, //its material
153  "World"); //its name
154 
155  // Must place the World Physical volume unrotated at (0,0,0).
156  //
157  G4VPhysicalVolume* worldPV
158  = new G4PVPlacement(
159  0, // no rotation
160  G4ThreeVector(), // at (0,0,0)
161  worldLV, // its logical volume
162  "World", // its name
163  0, // its mother volume
164  false, // no boolean operations
165  0, // copy number
166  fCheckOverlaps); // checking overlaps
167 
168  // Target
169 
170  G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
171 
172  G4Tubs* targetS
173  = new G4Tubs("target",0.,targetRadius,targetLength,0.*deg,360.*deg);
175  = new G4LogicalVolume(targetS, fTargetMaterial,"Target",0,0,0);
176  new G4PVPlacement(0, // no rotation
177  positionTarget, // at (x,y,z)
178  fLogicTarget, // its logical volume
179  "Target", // its name
180  worldLV, // its mother volume
181  false, // no boolean operations
182  0, // copy number
183  fCheckOverlaps); // checking overlaps
184 
185  G4cout << "Target is " << 2*targetLength/cm << " cm of "
186  << fTargetMaterial->GetName() << G4endl;
187 
188  // Tracker
189 
190  G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
191 
192  G4Tubs* trackerS
193  = new G4Tubs("tracker",0,trackerSize,trackerSize, 0.*deg, 360.*deg);
194  G4LogicalVolume* trackerLV
195  = new G4LogicalVolume(trackerS, air, "Tracker",0,0,0);
196  new G4PVPlacement(0, // no rotation
197  positionTracker, // at (x,y,z)
198  trackerLV, // its logical volume
199  "Tracker", // its name
200  worldLV, // its mother volume
201  false, // no boolean operations
202  0, // copy number
203  fCheckOverlaps); // checking overlaps
204 
205  // Visualization attributes
206 
207  G4VisAttributes* boxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
208  G4VisAttributes* chamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
209 
210  worldLV ->SetVisAttributes(boxVisAtt);
211  fLogicTarget ->SetVisAttributes(boxVisAtt);
212  trackerLV ->SetVisAttributes(boxVisAtt);
213 
214  // Tracker segments
215 
216  G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
217  << G4endl
218  << "The chambers are " << chamberWidth/cm << " cm of "
219  << fChamberMaterial->GetName() << G4endl
220  << "The distance between chamber is " << chamberSpacing/cm << " cm"
221  << G4endl;
222 
223  G4double firstPosition = -trackerSize + chamberSpacing;
224  G4double firstLength = trackerLength/10;
225  G4double lastLength = trackerLength;
226 
227  G4double halfWidth = 0.5*chamberWidth;
228  G4double rmaxFirst = 0.5 * firstLength;
229 
230  G4double rmaxIncr = 0.0;
231  if( fNbOfChambers > 0 ){
232  rmaxIncr = 0.5 * (lastLength-firstLength)/(fNbOfChambers-1);
233  if (chamberSpacing < chamberWidth) {
234  G4Exception("B2aDetectorConstruction::DefineVolumes()",
235  "InvalidSetup", FatalException,
236  "Width>Spacing");
237  }
238  }
239 
240  for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
241 
242  G4double Zposition = firstPosition + copyNo * chamberSpacing;
243  G4double rmax = rmaxFirst + copyNo * rmaxIncr;
244 
245  G4Tubs* chamberS
246  = new G4Tubs("Chamber_solid", 0, rmax, halfWidth, 0.*deg, 360.*deg);
247 
248  fLogicChamber[copyNo] =
249  new G4LogicalVolume(chamberS,fChamberMaterial,"Chamber_LV",0,0,0);
250 
251  fLogicChamber[copyNo]->SetVisAttributes(chamberVisAtt);
252 
253  new G4PVPlacement(0, // no rotation
254  G4ThreeVector(0,0,Zposition), // at (x,y,z)
255  fLogicChamber[copyNo], // its logical volume
256  "Chamber_PV", // its name
257  trackerLV, // its mother volume
258  false, // no boolean operations
259  copyNo, // copy number
260  fCheckOverlaps); // checking overlaps
261 
262  }
263 
264  // Example of User Limits
265  //
266  // Below is an example of how to set tracking constraints in a given
267  // logical volume
268  //
269  // Sets a max step length in the tracker region, with G4StepLimiter
270 
271  G4double maxStep = 0.5*chamberWidth;
272  fStepLimit = new G4UserLimits(maxStep);
273  trackerLV->SetUserLimits(fStepLimit);
274 
282 
283  // Always return the physical world
284 
285  return worldPV;
286 }
static const double cm
Definition: G4SIunits.hh:118
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:604
Definition: G4Box.hh:64
void SetUserLimits(G4UserLimits *pULimits)
Definition: G4Tubs.hh:85
G4double GetSurfaceTolerance() const
void SetWorldMaximumExtent(G4double worldExtent)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
static const double deg
Definition: G4SIunits.hh:151
static G4GeometryManager * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
const G4String & GetName() const
Definition: G4Material.hh:178
static const double mm
Definition: G4SIunits.hh:114
void SetVisAttributes(const G4VisAttributes *pVA)
static G4GeometryTolerance * GetInstance()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetChamberMaterial()

void B2aDetectorConstruction::SetChamberMaterial ( G4String  materialName)

Definition at line 339 of file B2aDetectorConstruction.cc.

340 {
341  G4NistManager* nistManager = G4NistManager::Instance();
342 
343  G4Material* pttoMaterial =
344  nistManager->FindOrBuildMaterial(materialName);
345 
346  if (fChamberMaterial != pttoMaterial) {
347  if ( pttoMaterial ) {
348  fChamberMaterial = pttoMaterial;
349  for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
350  if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->
352  }
353  G4cout
354  << G4endl
355  << "----> The chambers are made of " << materialName << G4endl;
356  } else {
357  G4cout
358  << G4endl
359  << "--> WARNING from SetChamberMaterial : "
360  << materialName << " not found" << G4endl;
361  }
362  }
363 }
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
def SetMaterial(material_name)
Definition: EmPlot.py:25
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCheckOverlaps()

void B2aDetectorConstruction::SetCheckOverlaps ( G4bool  checkOverlaps)

Definition at line 374 of file B2aDetectorConstruction.cc.

375 {
376  fCheckOverlaps = checkOverlaps;
377 }

◆ SetMaxStep()

void B2aDetectorConstruction::SetMaxStep ( G4double  maxStep)

Definition at line 367 of file B2aDetectorConstruction.cc.

368 {
369  if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
370 }
virtual void SetMaxAllowedStep(G4double ustepMax)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTargetMaterial()

void B2aDetectorConstruction::SetTargetMaterial ( G4String  materialName)

Definition at line 314 of file B2aDetectorConstruction.cc.

315 {
316  G4NistManager* nistManager = G4NistManager::Instance();
317 
318  G4Material* pttoMaterial =
319  nistManager->FindOrBuildMaterial(materialName);
320 
321  if (fTargetMaterial != pttoMaterial) {
322  if ( pttoMaterial ) {
323  fTargetMaterial = pttoMaterial;
325  G4cout
326  << G4endl
327  << "----> The target is made of " << materialName << G4endl;
328  } else {
329  G4cout
330  << G4endl
331  << "--> WARNING from SetTargetMaterial : "
332  << materialName << " not found" << G4endl;
333  }
334  }
335 }
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4NistManager * Instance()
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void SetMaterial(G4Material *pMaterial)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fChamberMaterial

G4Material* B2aDetectorConstruction::fChamberMaterial
private

Definition at line 77 of file B2aDetectorConstruction.hh.

◆ fCheckOverlaps

G4bool B2aDetectorConstruction::fCheckOverlaps
private

Definition at line 86 of file B2aDetectorConstruction.hh.

◆ fLogicChamber

G4LogicalVolume** B2aDetectorConstruction::fLogicChamber
private

Definition at line 74 of file B2aDetectorConstruction.hh.

◆ fLogicTarget

G4LogicalVolume* B2aDetectorConstruction::fLogicTarget
private

Definition at line 73 of file B2aDetectorConstruction.hh.

◆ fMagFieldMessenger

G4ThreadLocal G4GlobalMagFieldMessenger * B2aDetectorConstruction::fMagFieldMessenger = 0
staticprivate

Definition at line 83 of file B2aDetectorConstruction.hh.

◆ fMessenger

B2aDetectorMessenger* B2aDetectorConstruction::fMessenger
private

Definition at line 81 of file B2aDetectorConstruction.hh.

◆ fNbOfChambers

G4int B2aDetectorConstruction::fNbOfChambers
private

Definition at line 71 of file B2aDetectorConstruction.hh.

◆ fStepLimit

G4UserLimits* B2aDetectorConstruction::fStepLimit
private

Definition at line 79 of file B2aDetectorConstruction.hh.

◆ fTargetMaterial

G4Material* B2aDetectorConstruction::fTargetMaterial
private

Definition at line 76 of file B2aDetectorConstruction.hh.


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