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.getParameter<std::string>("volume");
12 threshold_ = p.getParameter<double>("threshold");
13 factor_ = p.getParameter<double>("factor");
14 down_bias_conv_ = p.getParameter<bool>("down_bias_conv");
15 only_children_of_primary_ = p.getParameter<bool>("only_children_of_primary");
16}
17
20
22 emXsecOperation = 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 currentProcess =
44 callingProcess->GetWrappedProcess()->GetProcessName();
45
46 // If the current process is what want to bias
47 if (currentProcess.compare(this->getProcessToBias()) == 0) {
48 G4double interactionLength =
49 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
50
51 pnXsecUnbiased_ = 1. / interactionLength;
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 ((currentProcess.compare(CONVERSION_PROCESS) == 0) and down_bias_conv_) {
64 G4double interactionLength =
65 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
66
67 double emXsecUnbiased = 1. / interactionLength;
68
69 double emXsecBiased = std::max(
71 if (emXsecBiased == pnXsecUnbiased_) {
72 ldmx_log(debug) << "EM XS = PN unbiased XS! The biasing factor ("
73 << factor_ << ") is too large";
74 }
75
76 emXsecOperation->SetBiasedCrossSection(emXsecBiased);
77 emXsecOperation->Sample();
78
79 return emXsecOperation;
80 }
81 return nullptr;
82}
83
84} // namespace biasoperators
85} // namespace simcore
86
87DECLARE_XSECBIASINGOPERATOR(simcore::biasoperators::PhotoNuclear)
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
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?
G4BOptnChangeCrossSection * emXsecOperation
Cross-section biasing operation for conversion process.
bool down_bias_conv_
Should we down-bias the gamma conversion process?
G4VBiasingOperation * ProposeOccurenceBiasingOperation(const G4Track *track, const G4BiasingProcessInterface *callingProcess) override
void StartRun() override
Method called at the beginning of a run.
double threshold_
minimum kinetic energy [MeV] for a track to be biased
static const std::string CONVERSION_PROCESS
Geant4 gamma conversion process name.
double pnXsecUnbiased_
Unbiased photonuclear xsec.
PhotoNuclear(std::string name, const framework::config::Parameters &p)
Constructor.
double pnXsecBiased_
Biased photonuclear xsec.
std::string volume_
Volume we are going to bias within.