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) {}
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 std::cout << "[ XsecBiasingOperator ]: Biasing particles of type "
27 << this->getParticleToBias() << std::endl;
28
29 if (processIsBiased(this->getProcessToBias())) {
31 new G4BOptnChangeCrossSection("changeXsec-" + this->getProcessToBias());
32 } else {
33 EXCEPTION_RAISE("BiasSetup",
34 this->getProcessToBias() +
35 " is not found in list of biased processes!");
36 }
37}
38
39bool XsecBiasingOperator::processIsBiased(std::string process) {
40 // Loop over all processes and check if the given process is being
41 // biased.
42 const G4BiasingProcessSharedData* sharedData =
43 G4BiasingProcessInterface::GetSharedData(processManager_);
44 if (sharedData) {
45 for (size_t iprocess = 0;
46 iprocess < (sharedData->GetPhysicsBiasingProcessInterfaces()).size();
47 ++iprocess) {
48 const G4BiasingProcessInterface* wrapperProcess =
49 (sharedData->GetPhysicsBiasingProcessInterfaces())[iprocess];
50
51 if (wrapperProcess->GetWrappedProcess()->GetProcessName().compareTo(
52 process) == 0) {
53 return true;
54 }
55 }
56 }
57 return false;
58}
59
60} // namespace simcore
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
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.