4#include "Framework/Exception/Exception.h"
9#include "SimCore/DetectorConstruction.h"
10#include "SimCore/G4User/VolumeChecks.h"
11#include "SimCore/SensitiveDetector.h"
12#include "SimCore/XsecBiasingOperator.h"
15namespace logical_volume_tests {
22using Test = bool (*)(G4LogicalVolume*,
const std::string&);
29 : parser_(parser), parameters_{parameters}, conditions_interface_{ci} {}
35void DetectorConstruction::ConstructSDandField() {
37 parameters_.getParameter<std::vector<framework::config::Parameters>>(
38 "sensitive_detectors", {})};
39 for (
auto& det : sens_dets) {
42 det.getParameter<std::string>(
"class_name"),
46 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
47 if (sd->isSensDet(volume)) {
48 ldmx_log(debug) <<
"Attaching " << sd->GetName() <<
" to "
50 volume->SetSensitiveDetector(sd);
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;
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;
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();
Class encapsulating parameters for configuring a processor.
Handle to the conditions system, provided at construction to classes which require it.
framework::config::Parameters parameters_
The set of parameters used to configure this class.
G4VPhysicalVolume * Construct()
Construct the detector.
DetectorConstruction(simcore::geo::Parser *parser, framework::config::Parameters ¶meters, ConditionsInterface &ci)
Constructor.
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
void apply(UnaryFunction f) const
Apply the input UnaryFunction to each entry in the inventory.
static Factory & get()
get the factory instance
PrototypePtr make(const std::string &full_name, PrototypeConstructorArgs... maker_args)
make a new object by name
Interface for a parser used to load a geometry into Geant4.
virtual G4VPhysicalVolume * GetWorldVolume()=0
Pure virtual method used to retrieve the G4VPhysicalVolume associated with the most top-level (world)...