LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 ()
 

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 30 of file DetectorConstruction.cxx.

References fWorld, and parser().

33  {
34  if ( gdmlFile.empty() ) {
35  throw cet::exception("DetectorConstruction") << "Supplied GDML filename is empty\n"
36  << __FILE__ << ":" << __LINE__ << "\n";
37  }
38  // Get the path to the GDML file from the Geometry interface.
39  const G4String GDMLfile = static_cast<const G4String>( gdmlFile );
40 
41  // Use Geant4's GDML parser to convert the geometry to Geant4 format.
42  G4GDMLParser parser;
43  parser.SetOverlapCheck(overlapCheck);
44  parser.Read(GDMLfile,validateSchema);
45 
46  // Fetch the world physical volume from the parser. This contains
47  // the entire detector, not just the outline of the experimental
48  // hall.
49  fWorld = parser.GetWorldVolume();
50 
51  }
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 55 of file DetectorConstruction.cxx.

56  {
57  }

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 60 of file DetectorConstruction.cxx.

References fFieldMgr, mag::MagneticField::Fields(), fWorld, mag::kConstantBFieldMode, mag::kNoBFieldMode, LOG_ERROR, and LOG_INFO.

61  {
62  // Setup the magnetic field situation
64 
65  // loop over the possible fields
66  for(auto fd : bField->Fields()){
67  switch (fd.fMode) {
68  case mag::kNoBFieldMode:
69  /* NOP */
70  break;
72  // Attach this to the magnetized volume only, so get that volume
73  G4LogicalVolume *bvol = G4LogicalVolumeStore::GetInstance()->GetVolume(fd.fVolume);
74 
75  // Define the basic field, using p we should get the uniform field
76  G4UniformMagField* magField = new G4UniformMagField( fd.fField * CLHEP::tesla );
77  fFieldMgr = new G4FieldManager();
78  fFieldMgr->SetDetectorField(magField);
79  fFieldMgr->CreateChordFinder(magField);
80 
81  LOG_INFO("DetectorConstruction")
82  << "Setting uniform magnetic field to be "
83  << magField->GetConstantFieldValue().x() << " "
84  << magField->GetConstantFieldValue().y() << " "
85  << magField->GetConstantFieldValue().z() << " "
86  << " in " << bvol->GetName();
87 
88  // Reset the chord finding accuracy
89  // fFieldMgr->GetChordFinder()->SetDeltaChord(1.0 * cm);
90 
91  // the boolean tells the field manager to use local volume
92  bvol->SetFieldManager(fFieldMgr, true);
93 
94  break;
95  } // case mag::kConstantBFieldMode
96  default: // Complain if the user asks for something not handled
97  LOG_ERROR("DetectorConstruction")
98  << "Unknown or illegal Magneticfield "
99  << "mode specified: "
100  << fd.fMode
101  << ". Note that AutomaticBFieldMode is reserved.";
102  break;
103  } // end switch cases
104 
105  } // end loop over fields
106 
107  return fWorld;
108  }
#define LOG_INFO(category)
std::vector< MagneticFieldDescription > const & Fields() const
Definition: MagneticField.h:54
#define LOG_ERROR(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 40 of file DetectorConstruction.h.

References fFieldMgr.

40 { 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 37 of file DetectorConstruction.h.

References fWorld.

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

37 { return fWorld; }
static G4VPhysicalVolume * fWorld
pointer to the world volume

Member Data Documentation

G4FieldManager * DetectorConstruction::fFieldMgr = nullptr
staticprivate

pointer to the field manager

Definition at line 44 of file DetectorConstruction.h.

Referenced by Construct(), and GetFieldMgr().

G4VPhysicalVolume * DetectorConstruction::fWorld = nullptr
staticprivate

pointer to the world volume

Definition at line 43 of file DetectorConstruction.h.

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


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