LDMX Software
GammaPhysics.cxx
Go to the documentation of this file.
1
9
10#include "G4ProcessManager.hh"
11#include "G4VProcess.hh"
12#include "SimCore/PhotoNuclearModels/PhotoNuclearModel.h"
13
14namespace simcore {
15
16GammaPhysics::GammaPhysics(const G4String& name,
17 const framework::config::Parameters& parameters)
18 : G4VPhysicsConstructor(name),
19 model_parameters_{
20 parameters.get<framework::config::Parameters>("photonuclear_model")} {
21}
22
24
26 G4ProcessManager* process_manager = G4Gamma::Gamma()->GetProcessManager();
27 if (process_manager == nullptr) {
28 EXCEPTION_RAISE("GammaPhysics",
29 "Was unable to access the process manager for photons, "
30 "something is very wrong!");
31 }
32 // configure our PN model based on runtime parameters
33 auto pn = PhotoNuclearModel::Factory::get().make(
34 model_parameters_.get<std::string>("class_name"),
35 model_parameters_.get<std::string>("instance_name"), model_parameters_);
36 if (not pn) {
37 EXCEPTION_RAISE("UnableToCreate",
38 "Unable to create a PhotoNuclearModel of type " +
39 model_parameters_.get<std::string>("class_name"));
40 }
41 pn.value()->removeExistingModel(process_manager);
42 pn.value()->constructGammaProcess(process_manager);
61 const auto processes{process_manager->GetProcessList()};
62 for (int i{0}; i < processes->size(); i++) {
63 const auto process{(*processes)[i]};
64 if (process->GetProcessName() == "photonNuclear") {
65 process_manager->SetProcessOrderingToFirst(
66 process, G4ProcessVectorDoItIndex::idxAll);
67 }
68 }
69 // Add the gamma -> mumu to the physics list.
70 process_manager->AddDiscreteProcess(&gamma_conv_process_);
71}
72} // namespace simcore
Class used to enhanced the gamma physics list.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
GammaPhysics(const G4String &name, const framework::config::Parameters &parameters)
Class constructor.
G4GammaConversionToMuons gamma_conv_process_
The gamma to muons process.
void ConstructProcess() final
We do two things for this call back during initialization.
void ConstructParticle() final
Construct particles.
framework::config::Parameters model_parameters_
Parameters from the configuration to pass along to the photonuclear model.
All classes in the ldmx-sw project use this namespace.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...