LDMX Software
XsecBiasingOperator.cxx
1#include "SimCore/XsecBiasingOperator.h"
2
3#include "Framework/Exception/Exception.h"
4
5namespace simcore {
6
8 std::string name, const framework::config::Parameters& parameters)
9 : G4VBiasingOperator(name), theLog_{framework::logging::makeLogger(name)} {}
10
12 if (this->getParticleToBias().compare("gamma") == 0) {
13 processManager_ = G4Gamma::GammaDefinition()->GetProcessManager();
14 } else if (this->getParticleToBias().compare("e-") == 0) {
15 processManager_ = G4Electron::ElectronDefinition()->GetProcessManager();
16 } else if (this->getParticleToBias().compare("neutron") == 0) {
17 processManager_ = G4Neutron::NeutronDefinition()->GetProcessManager();
18 } else if (this->getParticleToBias().compare("kaon0L") == 0) {
20 G4KaonZeroLong::KaonZeroLongDefinition()->GetProcessManager();
21 } else {
22 EXCEPTION_RAISE("BiasSetup", "Invalid particle type '" +
23 this->getParticleToBias() + "'.");
24 }
25
26 ldmx_log(info) << "Biasing particles of type " << this->getParticleToBias();
27
28 if (processIsBiased(this->getProcessToBias())) {
30 new G4BOptnChangeCrossSection("changeXsec-" + this->getProcessToBias());
31 } else {
32 EXCEPTION_RAISE("BiasSetup",
33 this->getProcessToBias() +
34 " is not found in list of biased processes!");
35 }
36}
37
38bool XsecBiasingOperator::processIsBiased(std::string process) {
39 // Loop over all processes and check if the given process is being
40 // biased.
41 const G4BiasingProcessSharedData* sharedData =
42 G4BiasingProcessInterface::GetSharedData(processManager_);
43 if (sharedData) {
44 for (size_t iprocess = 0;
45 iprocess < (sharedData->GetPhysicsBiasingProcessInterfaces()).size();
46 ++iprocess) {
47 const G4BiasingProcessInterface* wrapperProcess =
48 (sharedData->GetPhysicsBiasingProcessInterfaces())[iprocess];
49
50 if (wrapperProcess->GetWrappedProcess()->GetProcessName().compareTo(
51 process) == 0) {
52 return true;
53 }
54 }
55 }
56 return false;
57}
58
59} // namespace simcore
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
virtual std::string getProcessToBias() const =0
Return the process whose cross-section will be biased.
void StartRun()
Method called at the beginning of a run.
XsecBiasingOperator(std::string name, const framework::config::Parameters &parameters)
Constructor.
bool processIsBiased(std::string process)
Check if the given processed is being biased.
virtual std::string getParticleToBias() const =0
Return the particle which should be biased.
G4ProcessManager * processManager_
Process manager associated with the particle of interest.
G4BOptnChangeCrossSection * xsecOperation_
Cross-section biasing operation.
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45