LDMX Software
simcore::DetectorConstruction Class Reference

Implements the Geant4 detector construction. More...

#include <DetectorConstruction.h>

Public Member Functions

 DetectorConstruction (simcore::geo::Parser *parser, framework::config::Parameters &parameters, ConditionsInterface &ci)
 Constructor.
 
virtual ~DetectorConstruction ()=default
 Class destructor.
 
G4VPhysicalVolume * Construct ()
 Construct the detector.
 
void ConstructSDandField ()
 
std::string getDetectorName ()
 

Private Attributes

simcore::geo::Parserparser_
 The parser used to load the detector into memory.
 
framework::config::Parameters parameters_
 The set of parameters used to configure this class.
 
simcore::ConditionsInterfaceconditions_interface_
 interface to conditions to be passed to SDs
 

Detailed Description

Implements the Geant4 detector construction.

Note
This class reads in a detector description from a GDML file using the basic G4GDMLParser and instantiates supplemental information using the AuxInfoReader.
See also
AuxInfoReader

Definition at line 33 of file DetectorConstruction.h.

Constructor & Destructor Documentation

◆ DetectorConstruction()

simcore::DetectorConstruction::DetectorConstruction ( simcore::geo::Parser * parser,
framework::config::Parameters & parameters,
ConditionsInterface & ci )

Constructor.

Parameters
parserParser used to parse the geometry into memory.
parametersThe parameters used to configure this class.
ciThe conditions needed to build the detector.

Definition at line 26 of file DetectorConstruction.cxx.

29 : parser_(parser), parameters_{parameters}, conditions_interface_{ci} {}
framework::config::Parameters parameters_
The set of parameters used to configure this class.
simcore::geo::Parser * parser_
The parser used to load the detector into memory.
simcore::ConditionsInterface & conditions_interface_
interface to conditions to be passed to SDs

Member Function Documentation

◆ Construct()

G4VPhysicalVolume * simcore::DetectorConstruction::Construct ( )

Construct the detector.

Returns
The top volume of the detector.

Definition at line 31 of file DetectorConstruction.cxx.

31 {
32 return parser_->GetWorldVolume();
33}
virtual G4VPhysicalVolume * GetWorldVolume()=0
Pure virtual method used to retrieve the G4VPhysicalVolume associated with the most top-level (world)...

References simcore::geo::Parser::GetWorldVolume(), and parser_.

◆ ConstructSDandField()

void simcore::DetectorConstruction::ConstructSDandField ( )

Definition at line 35 of file DetectorConstruction.cxx.

35 {
36 auto sens_dets{
37 parameters_.getParameter<std::vector<framework::config::Parameters>>(
38 "sensitive_detectors", {})};
39 for (auto& det : sens_dets) {
40 // create
42 det.getParameter<std::string>("class_name"),
43 det.getParameter<std::string>("instance_name"), conditions_interface_,
44 det);
45 // attach to volumes
46 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
47 if (sd->isSensDet(volume)) {
48 ldmx_log(debug) << "Attaching " << sd->GetName() << " to "
49 << volume->GetName();
50 volume->SetSensitiveDetector(sd);
51 }
52 }
53 }
54
55 // Biasing operators were created in RunManager::setupPhysics
56 // which is called before G4RunManager::Initialize
57 // which is where this method ends up being called.
59 logical_volume_tests::Test includeVolumeTest{nullptr};
60 if (bop->getVolumeToBias().compare("ecal") == 0) {
61 includeVolumeTest = &simcore::g4user::volumechecks::isInEcal;
62 } else if (bop->getVolumeToBias().compare("old_ecal") == 0) {
63 includeVolumeTest = &simcore::g4user::volumechecks::isInEcalOld;
64 } else if (bop->getVolumeToBias().compare("target") == 0) {
65 includeVolumeTest = &simcore::g4user::volumechecks::isInTargetOnly;
66 } else if (bop->getVolumeToBias().compare("target_region") == 0) {
67 includeVolumeTest = &simcore::g4user::volumechecks::isInTargetRegion;
68 } else if (bop->getVolumeToBias().compare("hcal") == 0) {
69 includeVolumeTest = &simcore::g4user::volumechecks::isInHcal;
70 } else {
71 std::cerr << "[ DetectorConstruction ] : "
72 << "WARN - Requested volume to bias '" << bop->getVolumeToBias()
73 << "' is not recognized. Will attach volumes based on if their"
74 << " name contains the volume to bias." << std::endl;
75 includeVolumeTest = &simcore::g4user::volumechecks::nameContains;
76 }
77
78 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
79 auto volume_name = volume->GetName();
80 if (includeVolumeTest(volume, bop->getVolumeToBias())) {
81 bop->AttachTo(volume);
82 ldmx_log(debug) << "Attaching biasing operator " << bop->GetName()
83 << " to volume " << volume->GetName();
84 } // BOP attached to target or ecal
85 } // loop over volumes
86 }); // loop over biasing operators
87}
void apply(UnaryFunction f) const
Apply the input UnaryFunction to each entry in the inventory.
Definition Factory.h:283
static Factory & get()
get the factory instance
Definition Factory.h:217
PrototypePtr make(const std::string &full_name, PrototypeConstructorArgs... maker_args)
make a new object by name
Definition Factory.h:265

◆ getDetectorName()

std::string simcore::DetectorConstruction::getDetectorName ( )
inline
Returns
The name of this detector. This is extracted from the description file used to build this detector.

Definition at line 65 of file DetectorConstruction.h.

65{ return parser_->getDetectorName(); }
virtual std::string getDetectorName()=0
Get the name of the parsed detector.

References simcore::geo::Parser::getDetectorName(), and parser_.

Referenced by simcore::Simulator::beforeNewRun().

Member Data Documentation

◆ conditions_interface_

simcore::ConditionsInterface& simcore::DetectorConstruction::conditions_interface_
private

interface to conditions to be passed to SDs

Definition at line 75 of file DetectorConstruction.h.

◆ parameters_

framework::config::Parameters simcore::DetectorConstruction::parameters_
private

The set of parameters used to configure this class.

Definition at line 72 of file DetectorConstruction.h.

◆ parser_

simcore::geo::Parser* simcore::DetectorConstruction::parser_
private

The parser used to load the detector into memory.

Definition at line 69 of file DetectorConstruction.h.

Referenced by Construct(), and getDetectorName().


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