4#include "Framework/Exception/Exception.h"
9#include "SimCore/BiasOperators/XsecBiasingOperator.h"
10#include "SimCore/DetectorConstruction.h"
11#include "SimCore/G4User/VolumeChecks.h"
12#include "SimCore/SDs/SensitiveDetector.h"
15namespace logical_volume_tests {
22using Test = bool (*)(G4LogicalVolume*,
const std::string&);
27 std::shared_ptr<simcore::geo::Parser> parser,
29 : parser_(parser), parameters_{parameters}, conditions_interface_{ci} {}
32 return parser_->getWorldVolume();
35void DetectorConstruction::ConstructSDandField() {
36 auto sens_dets{
parameters_.
get<std::vector<framework::config::Parameters>>(
37 "sensitive_detectors", {})};
38 for (
auto& det : sens_dets) {
40 auto sd = SensitiveDetector::Factory::get().make(
41 det.get<std::string>(
"class_name"),
44 EXCEPTION_RAISE(
"UnableToCreate",
45 "Unable to create a SensitiveDetector of type " +
46 det.get<std::string>(
"class_name"));
49 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
50 if (sd.value()->isSensDet(volume)) {
51 ldmx_log(debug) <<
"Attaching " << sd.value()->GetName() <<
" to "
53 volume->SetSensitiveDetector(sd.value());
61 simcore::XsecBiasingOperator::Factory::get().apply([&](
auto bop) {
62 logical_volume_tests::Test include_volume_test{
nullptr};
63 if (bop->getVolumeToBias().compare(
"ecal") == 0) {
64 include_volume_test = &simcore::g4user::volumechecks::isInEcal;
65 }
else if (bop->getVolumeToBias().compare(
"old_ecal") == 0) {
66 include_volume_test = &simcore::g4user::volumechecks::isInEcalOld;
67 }
else if (bop->getVolumeToBias().compare(
"target") == 0) {
68 include_volume_test = &simcore::g4user::volumechecks::isInTargetOnly;
69 }
else if (bop->getVolumeToBias().compare(
"target_region") == 0) {
70 include_volume_test = &simcore::g4user::volumechecks::isInTargetRegion;
71 }
else if (bop->getVolumeToBias().compare(
"hcal") == 0) {
72 include_volume_test = &simcore::g4user::volumechecks::isInHcal;
74 std::cerr <<
"[ DetectorConstruction ] : "
75 <<
"WARN - Requested volume to bias '" << bop->getVolumeToBias()
76 <<
"' is not recognized. Will attach volumes based on if their"
77 <<
" name contains the volume to bias." << std::endl;
78 include_volume_test = &simcore::g4user::volumechecks::nameContains;
81 for (G4LogicalVolume* volume : *G4LogicalVolumeStore::GetInstance()) {
82 auto volume_name = volume->GetName();
83 if (include_volume_test(volume, bop->getVolumeToBias())) {
84 bop->AttachTo(volume);
85 ldmx_log(debug) <<
"Attaching biasing operator " << bop->GetName()
86 <<
" to volume " << volume->GetName();
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
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.
DetectorConstruction(std::shared_ptr< simcore::geo::Parser > parser, framework::config::Parameters ¶meters, ConditionsInterface &ci)
Constructor.
G4VPhysicalVolume * Construct()
Construct the detector.
std::shared_ptr< 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
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...