LDMX Software
Public Member Functions | Private Attributes | List of all members
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 119 of file DetectorConstruction.cxx.

122 : 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 124 of file DetectorConstruction.cxx.

124 {
125 return parser_->GetWorldVolume();
126}
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 128 of file DetectorConstruction.cxx.

128 {
129 auto sens_dets{
130 parameters_.getParameter<std::vector<framework::config::Parameters>>(
131 "sensitive_detectors", {})};
132 for (auto& det : sens_dets) {
133 // create
135 det.getParameter<std::string>("class_name"),
136 det.getParameter<std::string>("instance_name"), conditions_interface_,
137 det);
138 // attach to volumes
139 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
140 if (sd->isSensDet(volume)) {
141 ldmx_log(debug) << "Attaching " << sd->GetName() << " to "
142 << volume->GetName();
143 volume->SetSensitiveDetector(sd);
144 }
145 }
146 }
147
148 // Biasing operators were created in RunManager::setupPhysics
149 // which is called before G4RunManager::Initialize
150 // which is where this method ends up being called.
152 logical_volume_tests::Test includeVolumeTest{nullptr};
153 if (bop->getVolumeToBias().compare("ecal") == 0) {
154 includeVolumeTest = &logical_volume_tests::isInEcal;
155 } else if (bop->getVolumeToBias().compare("old_ecal") == 0) {
156 includeVolumeTest = &logical_volume_tests::isInEcalOld;
157 } else if (bop->getVolumeToBias().compare("target") == 0) {
158 includeVolumeTest = &logical_volume_tests::isInTargetOnly;
159 } else if (bop->getVolumeToBias().compare("target_region") == 0) {
160 includeVolumeTest = &logical_volume_tests::isInTargetRegion;
161 } else if (bop->getVolumeToBias().compare("hcal") == 0) {
162 includeVolumeTest = &logical_volume_tests::isInHcal;
163 } else {
164 std::cerr << "[ DetectorConstruction ] : "
165 << "WARN - Requested volume to bias '" << bop->getVolumeToBias()
166 << "' is not recognized. Will attach volumes based on if their"
167 << " name contains the volume to bias." << std::endl;
168 includeVolumeTest = &logical_volume_tests::nameContains;
169 }
170
171 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
172 auto volume_name = volume->GetName();
173 if (includeVolumeTest(volume, bop->getVolumeToBias())) {
174 bop->AttachTo(volume);
175 ldmx_log(debug) << "Attaching biasing operator " << bop->GetName()
176 << " to volume " << volume->GetName();
177 } // BOP attached to target or ecal
178 } // loop over volumes
179 }); // loop over biasing operators
180}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
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: