LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
g4b::DetectorConstruction Class Reference

#include "DetectorConstruction.h"

Inheritance diagram for g4b::DetectorConstruction:

Public Member Functions

 DetectorConstruction (std::string const &gdmlFile, bool const &overlapCheck=false, bool const &validateSchema=true)
 Standard constructor and destructor. More...
 
virtual ~DetectorConstruction ()
 
G4VPhysicalVolume * Construct ()
 
void SetCustomMagneticService ()
 Set a custom Magnetic service. More...
 

Static Public Member Functions

static G4VPhysicalVolume * GetWorld ()
 
static G4FieldManager * GetFieldMgr ()
 Magnetic field. More...
 

Static Private Attributes

static G4VPhysicalVolume * fWorld = nullptr
 pointer to the world volume More...
 
static G4FieldManager * fFieldMgr = nullptr
 pointer to the field manager More...
 

Detailed Description

Definition at line 19 of file DetectorConstruction.h.

Constructor & Destructor Documentation

DetectorConstruction::DetectorConstruction ( std::string const &  gdmlFile,
bool const &  overlapCheck = false,
bool const &  validateSchema = true 
)
explicit

Standard constructor and destructor.

Definition at line 32 of file DetectorConstruction.cxx.

References fWorld, and parser().

35  {
36  if ( gdmlFile.empty() ) {
37  throw cet::exception("DetectorConstruction") << "Supplied GDML filename is empty\n"
38  << __FILE__ << ":" << __LINE__ << "\n";
39  }
40  // Get the path to the GDML file from the Geometry interface.
41  const G4String GDMLfile = static_cast<const G4String>( gdmlFile );
42 
43  // Use Geant4's GDML parser to convert the geometry to Geant4 format.
44  G4GDMLParser parser;
45  parser.SetOverlapCheck(overlapCheck);
46  parser.Read(GDMLfile,validateSchema);
47 
48  // Fetch the world physical volume from the parser. This contains
49  // the entire detector, not just the outline of the experimental
50  // hall.
51  fWorld = parser.GetWorldVolume();
52 
53  }
CommandLineParser * parser(0)
static G4VPhysicalVolume * fWorld
pointer to the world volume
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
DetectorConstruction::~DetectorConstruction ( )
virtual

Definition at line 57 of file DetectorConstruction.cxx.

58  {
59  }

Member Function Documentation

G4VPhysicalVolume * DetectorConstruction::Construct ( )

The key method in this class; returns the Geant4 version of the detector geometry. Required of any class that inherits from G4VUserDetectorConstruction.

Definition at line 62 of file DetectorConstruction.cxx.

References fFieldMgr, fWorld, mag::kConstantBFieldMode, mag::kFieldRZMapMode, mag::kFieldXYZMapMode, mag::kNoBFieldMode, MF_LOG_ERROR, MF_LOG_INFO, and mag::MagneticFieldService::provider().

63  {
64  // Setup the magnetic field situation
66  auto const * pProvider = bField->provider(); //get the provider
67 
68  // loop over the possible fields
69  for(auto fd : pProvider->Fields()){
70  switch (fd.fMode) {
71  case mag::kNoBFieldMode:
72  /* NOP */
73  break;
75  // Attach this to the magnetized volume only, so get that volume
76  G4LogicalVolume *bvol = G4LogicalVolumeStore::GetInstance()->GetVolume(fd.fVolume);
77 
78  // Define the basic field, using p we should get the uniform field
79  G4UniformMagField* magField = new G4UniformMagField( fd.fField * CLHEP::tesla );
80  fFieldMgr = new G4FieldManager();
81  fFieldMgr->SetDetectorField(magField);
82  fFieldMgr->CreateChordFinder(magField);
83 
84  MF_LOG_INFO("DetectorConstruction")
85  << "Setting uniform magnetic field to be "
86  << magField->GetConstantFieldValue().x() << " "
87  << magField->GetConstantFieldValue().y() << " "
88  << magField->GetConstantFieldValue().z() << " "
89  << " in " << bvol->GetName();
90 
91  // Reset the chord finding accuracy
92  // fFieldMgr->GetChordFinder()->SetDeltaChord(1.0 * cm);
93 
94  // the boolean tells the field manager to use local volume
95  bvol->SetFieldManager(fFieldMgr, true);
96 
97  break;
98  } // case mag::kConstantBFieldMode
99  case mag::kFieldRZMapMode: {
100 
101  // Attach this to the magnetized volume only, so get that volume
102  G4LogicalVolume *bvol = G4LogicalVolumeStore::GetInstance()->GetVolume(fd.fVolume);
103 
105  fFieldMgr = new G4FieldManager();
106  fFieldMgr->SetDetectorField(magField);
107  fFieldMgr->CreateChordFinder(magField);
108 
109  MF_LOG_INFO("DetectorConstruction")
110  << "Setting magnetic field in kFieldRZMapMode to be"
111  << " in " << bvol->GetName();
112 
113  // the boolean tells the field manager to use local volume
114  bvol->SetFieldManager(fFieldMgr, true);
115 
116  break;
117  } // case mag::kFieldRZMapMode
118  case mag::kFieldXYZMapMode: {
119 
120  // Attach this to the magnetized volume only, so get that volume
121  G4LogicalVolume *bvol = G4LogicalVolumeStore::GetInstance()->GetVolume(fd.fVolume);
122 
124  fFieldMgr = new G4FieldManager();
125  fFieldMgr->SetDetectorField(magField);
126  fFieldMgr->CreateChordFinder(magField);
127 
128  MF_LOG_INFO("DetectorConstruction")
129  << "Setting magnetic field in kFieldXYZMapMode to be"
130  << " in " << bvol->GetName();
131 
132  // the boolean tells the field manager to use local volume
133  bvol->SetFieldManager(fFieldMgr, true);
134 
135  break;
136  } // case mag::kFieldXYZMapMode
137  default: // Complain if the user asks for something not handled
138  MF_LOG_ERROR("DetectorConstruction")
139  << "Unknown or illegal Magneticfield "
140  << "mode specified: "
141  << fd.fMode
142  << ". Note that AutomaticBFieldMode is reserved.";
143  break;
144  } // end switch cases
145 
146  } // end loop over fields
147 
148  return fWorld;
149  }
#define MF_LOG_ERROR(category)
virtual const mag::MagneticField * provider() const =0
#define MF_LOG_INFO(category)
static G4FieldManager * fFieldMgr
pointer to the field manager
static G4VPhysicalVolume * fWorld
pointer to the world volume
static G4FieldManager* g4b::DetectorConstruction::GetFieldMgr ( )
inlinestatic

Magnetic field.

Definition at line 43 of file DetectorConstruction.h.

References fFieldMgr.

43 { return fFieldMgr; }
static G4FieldManager * fFieldMgr
pointer to the field manager
static G4VPhysicalVolume* g4b::DetectorConstruction::GetWorld ( )
inlinestatic

Return a pointer to the world volume. This returns the same pointer as Construct(), but Construct() also does other actions such as setting up sensitive detectors. World() just returns the pointer to the top physical volume.

Definition at line 40 of file DetectorConstruction.h.

References fWorld.

Referenced by larg4::OpDetReadoutGeometry::Construct(), larg4::AuxDetReadoutGeometry::Construct(), and larg4::LArVoxelReadoutGeometry::Construct().

40 { return fWorld; }
static G4VPhysicalVolume * fWorld
pointer to the world volume
void g4b::DetectorConstruction::SetCustomMagneticService ( )

Set a custom Magnetic service.

Member Data Documentation

G4FieldManager * DetectorConstruction::fFieldMgr = nullptr
staticprivate

pointer to the field manager

Definition at line 47 of file DetectorConstruction.h.

Referenced by Construct(), and GetFieldMgr().

G4VPhysicalVolume * DetectorConstruction::fWorld = nullptr
staticprivate

pointer to the world volume

Definition at line 46 of file DetectorConstruction.h.

Referenced by Construct(), DetectorConstruction(), and GetWorld().


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