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 if (currentProcess.compare(this->getProcessToBias()) == 0) {
46 G4double interactionLength =
47 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
48
49 pnXsecUnbiased_ = 1. / interactionLength;
50
52
54 }
55 if ((currentProcess.compare(CONVERSION_PROCESS) == 0) and down_bias_conv_) {
56 G4double interactionLength =
57 callingProcess->GetWrappedProcess()->GetCurrentInteractionLength();
58
59 double emXsecUnbiased = 1. / interactionLength;
60
61 double emXsecBiased = std::max(
63 if (emXsecBiased == pnXsecUnbiased_) {
64 G4cout << "[ PhotoNuclearXsecBiasingOperator ]: [ WARNING ]: "
65 << "Biasing factor is too large." << std::endl;
66 }
67
68 emXsecOperation->SetBiasedCrossSection(emXsecBiased);
69 emXsecOperation->Sample();
70
71 return emXsecOperation;
72 }
73 return nullptr;
74}
75
76} // namespace biasoperators
77} // namespace simcore
78
79DECLARE_XSECBIASINGOPERATOR(simcore::biasoperators::PhotoNuclear)
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
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.