LDMX Software
PhotoNuclear.cxx
1#include "SimCore/BiasOperators/PhotoNuclear.h"
2
3namespace simcore {
4namespace biasoperators {
5
6const std::string PhotoNuclear::CONVERSION_PROCESS = "conv";
7
10 : XsecBiasingOperator(name, p) {
11 volume_ = p.get<std::string>("volume");
12 threshold_ = p.get<double>("threshold");
13 factor_ = p.get<double>("factor");
14 down_bias_conv_ = p.get<bool>("down_bias_conv");
15 only_children_of_primary_ = p.get<bool>("only_children_of_primary");
16}
17
20
22 em_xsec_operation_ = new G4BOptnChangeCrossSection("changeXsec-conv");
23 } else if (down_bias_conv_) {
24 EXCEPTION_RAISE(
25 "PhotoNuclearBiasing",
26 "Gamma Conversion process '" + CONVERSION_PROCESS + "' is not biased!");
27 }
28}
29
31 const G4Track* track, const G4BiasingProcessInterface* callingProcess) {
32 // if we want to only bias children of primary, leave if this track is NOT a
33 // child of the primary
34 if (only_children_of_primary_ and track->GetParentID() != 1) {
35 return nullptr;
36 }
37
38 // is this track too low energy to be biased?
39 if (track->GetKineticEnergy() < threshold_) {
40 return nullptr;
41 }
42
43 std::string current_process =
44 callingProcess->GetWrappedProcess()->GetProcessName();
45
46 // If the current process is what want to bias
47 if (current_process.compare(this->getProcessToBias()) == 0) {
48 G4double interaction_length =
49 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
50
51 pn_xsec_unbiased_ = 1. / interaction_length;
52
54
56 }
57
58 // If the current process is conversion and we want to bias down
59 // make sure that the biased electromagnetic xsec never falls below the
60 // normal (unbiased) photon-nuclear cross section
61 // In that regime, the PN events generated would almost certainly be over
62 // sampled.
63 if ((current_process.compare(CONVERSION_PROCESS) == 0) and down_bias_conv_) {
64 G4double interaction_length =
65 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
66
67 double em_xsec_unbiased = 1. / interaction_length;
68
69 double em_xsec_biased =
70 std::max(em_xsec_unbiased + pn_xsec_unbiased_ - pn_xsec_biased_,
72 static auto material_tungsten =
73 simcore::g4user::ptrretrieval::getMaterial("G4_W");
74 auto interaction_material = track->GetMaterial();
75 if ((em_xsec_biased == pn_xsec_unbiased_) &&
76 (interaction_material == material_tungsten)) {
77 ldmx_log(warn) << "EM XS = PN unbiased XS! The biasing factor ("
78 << factor_ << ") is too large for particle with energy "
79 << track->GetKineticEnergy()
80 << " and material = " << interaction_material->GetName();
81 }
82
83 em_xsec_operation_->SetBiasedCrossSection(em_xsec_biased);
84 em_xsec_operation_->Sample();
85
86 return em_xsec_operation_;
87 }
88 return nullptr;
89}
90
91} // namespace biasoperators
92} // namespace simcore
93
94DECLARE_XSECBIASINGOPERATOR(simcore::biasoperators::PhotoNuclear)
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
Our specialization of the biasing operator used with Geant4.
void StartRun()
Method called at the beginning of a run.
bool processIsBiased(std::string process)
Check if the given processed is being biased.
G4VBiasingOperation * BiasedXsec(double biased_xsec)
Helper method for passing a biased interaction length to the Geant4 biasing framework.
Bias the Photon-Nuclear process.
double factor_
factor to bias PN by
bool only_children_of_primary_
Should we restrict biasing to only children of primary?
bool down_bias_conv_
Should we down-bias the gamma conversion process?
G4BOptnChangeCrossSection * em_xsec_operation_
Cross-section biasing operation for conversion process.
G4VBiasingOperation * ProposeOccurenceBiasingOperation(const G4Track *track, const G4BiasingProcessInterface *callingProcess) override
void StartRun() override
Method called at the beginning of a run.
double pn_xsec_unbiased_
Unbiased photonuclear xsec.
double threshold_
minimum kinetic energy [MeV] for a track to be biased
static const std::string CONVERSION_PROCESS
Geant4 gamma conversion process name.
PhotoNuclear(std::string name, const framework::config::Parameters &p)
Constructor.
double pn_xsec_biased_
Biased photonuclear xsec.
std::string volume_
Volume we are going to bias within.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...