LDMX Software
PhotoNuclear.cxx
1#include "SimCore/BiasOperators/PhotoNuclear.h"
2
3#include "SimCore/G4User/PtrRetrieval.h"
4
5namespace simcore {
6namespace biasoperators {
7
8const std::string PhotoNuclear::CONVERSION_PROCESS = "conv";
9
12 : XsecBiasingOperator(name, p) {
13 volume_ = p.get<std::string>("volume");
14 threshold_ = p.get<double>("threshold");
15 factor_ = p.get<double>("factor");
16 down_bias_conv_ = p.get<bool>("down_bias_conv");
17 only_children_of_primary_ = p.get<bool>("only_children_of_primary");
18}
19
22
24 em_xsec_operation_ = new G4BOptnChangeCrossSection("changeXsec-conv");
25 } else if (down_bias_conv_) {
26 EXCEPTION_RAISE(
27 "PhotoNuclearBiasing",
28 "Gamma Conversion process '" + CONVERSION_PROCESS + "' is not biased!");
29 }
30}
31
33 const G4Track* track, const G4BiasingProcessInterface* callingProcess) {
34 // if we want to only bias children of primary, leave if this track is NOT a
35 // child of the primary
36 if (only_children_of_primary_ and track->GetParentID() != 1) {
37 return nullptr;
38 }
39
40 // is this track too low energy to be biased?
41 if (track->GetKineticEnergy() < threshold_) {
42 return nullptr;
43 }
44
45 std::string current_process =
46 callingProcess->GetWrappedProcess()->GetProcessName();
47
48 // If the current process is what want to bias
49 if (current_process.compare(this->getProcessToBias()) == 0) {
50 G4double interaction_length =
51 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
52
53 pn_xsec_unbiased_ = 1. / interaction_length;
54
56
58 }
59
60 // If the current process is conversion and we want to bias down
61 // make sure that the biased electromagnetic xsec never falls below the
62 // normal (unbiased) photon-nuclear cross section
63 // In that regime, the PN events generated would almost certainly be over
64 // sampled.
65 if ((current_process.compare(CONVERSION_PROCESS) == 0) and down_bias_conv_) {
66 G4double interaction_length =
67 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
68
69 double em_xsec_unbiased = 1. / interaction_length;
70
71 double em_xsec_biased =
72 std::max(em_xsec_unbiased + pn_xsec_unbiased_ - pn_xsec_biased_,
74 static auto material_tungsten =
75 simcore::g4user::ptrretrieval::getMaterial("Tungsten");
76 // For versions < v15
77 if (material_tungsten == nullptr) {
78 ldmx_log(warn) << "Attempting to use old tungsten material G4_W... ";
79 material_tungsten = simcore::g4user::ptrretrieval::getMaterial("G4_W");
80 }
81 auto interaction_material = track->GetMaterial();
82 if ((em_xsec_biased == pn_xsec_unbiased_) &&
83 (interaction_material == material_tungsten)) {
84 ldmx_log(warn) << "EM XS = PN unbiased XS! The biasing factor ("
85 << factor_ << ") is too large for particle with energy "
86 << track->GetKineticEnergy()
87 << " and material = " << interaction_material->GetName();
88 }
89
90 em_xsec_operation_->SetBiasedCrossSection(em_xsec_biased);
91 em_xsec_operation_->Sample();
92
93 return em_xsec_operation_;
94 }
95 return nullptr;
96}
97
98} // namespace biasoperators
99} // namespace simcore
100
101DECLARE_XSECBIASINGOPERATOR(simcore::biasoperators::PhotoNuclear)
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
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 ...