LDMX Software
XsecBiasingOperator.h
1#ifndef SIMCORE_XSECBIASINGOPERATOR_H_
2#define SIMCORE_XSECBIASINGOPERATOR_H_
3
4#include "Framework/Configure/Parameters.h"
5#include "Framework/Factory.h"
6#include "Framework/Logger.h"
7#include "Framework/RunHeader.h"
8
9//------------//
10// Geant4 //
11//------------//
12#include "G4BOptnChangeCrossSection.hh"
13#include "G4BiasingProcessInterface.hh"
14#include "G4BiasingProcessSharedData.hh"
15#include "G4ParticleDefinition.hh"
16#include "G4ProcessManager.hh"
17#include "G4Track.hh"
18#include "G4VBiasingOperator.hh"
19
20namespace simcore {
21
34class XsecBiasingOperator : public G4VBiasingOperator {
35 public:
46 XsecBiasingOperator(std::string name,
47 const framework::config::Parameters& parameters);
48
53 std::shared_ptr<XsecBiasingOperator>,
54 std::string,
56
59
73 virtual G4VBiasingOperation* ProposeOccurenceBiasingOperation(
74 const G4Track* track,
75 const G4BiasingProcessInterface* callingProcess) = 0;
76
87 void StartRun();
88
95 virtual std::string getProcessToBias() const = 0;
96
104 virtual std::string getParticleToBias() const = 0;
105
113 virtual std::string getVolumeToBias() const = 0;
114
121 // NOLINTNEXTLINE
122 virtual void RecordConfig(ldmx::RunHeader& header) const = 0;
123
124 protected:
139 // NOLINTNEXTLINE
140 G4VBiasingOperation* BiasedXsec(double biased_xsec) {
141 xsec_operation_->SetBiasedCrossSection(biased_xsec);
142 xsec_operation_->Sample();
143 return xsec_operation_;
144 }
145
152 bool processIsBiased(std::string process);
153
155 G4BOptnChangeCrossSection* xsec_operation_{nullptr};
156
158 G4ProcessManager* process_manager_{nullptr};
159
164 const G4Track*, const G4BiasingProcessInterface*) {
165 return nullptr;
166 }
167
172 const G4Track*, const G4BiasingProcessInterface*) {
173 return nullptr;
174 }
176 framework::logging::logger the_log_;
177
178}; // XsecBiasingOperator
179} // namespace simcore
180
187#define DECLARE_XSECBIASINGOPERATOR(CLASS) \
188 FACTORY_REGISTRATION(simcore::XsecBiasingOperator, CLASS)
189
190#endif // SIMCORE_XSECBIASINGOPERATOR_H_
Header holding Factory class and supporting macros.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
Run-specific configuration and data stored in its own output TTree alongside the event TTree in the o...
Definition RunHeader.h:68
Our specialization of the biasing operator used with Geant4.
G4VBiasingOperation * ProposeNonPhysicsBiasingOperation(const G4Track *, const G4BiasingProcessInterface *)
Do not propose any non-physics biasing.
DECLARE_FACTORY_WITH_WAREHOUSE(XsecBiasingOperator, std::shared_ptr< XsecBiasingOperator >, std::string, const framework::config::Parameters &)
The BiasingOperator factory.
virtual ~XsecBiasingOperator()
Destructor.
virtual std::string getProcessToBias() const =0
Return the process whose cross-section will be biased.
G4VBiasingOperation * ProposeFinalStateBiasingOperation(const G4Track *, const G4BiasingProcessInterface *)
Do not propose any biasing on final states.
void StartRun()
Method called at the beginning of a run.
XsecBiasingOperator(std::string name, const framework::config::Parameters &parameters)
Constructor.
virtual void RecordConfig(ldmx::RunHeader &header) const =0
Record the configuration of this biasing operator into the run header.
bool processIsBiased(std::string process)
Check if the given processed is being biased.
virtual G4VBiasingOperation * ProposeOccurenceBiasingOperation(const G4Track *track, const G4BiasingProcessInterface *callingProcess)=0
Propose a biasing operation for the current track and calling process.
G4ProcessManager * process_manager_
Process manager associated with the particle of interest.
G4VBiasingOperation * BiasedXsec(double biased_xsec)
Helper method for passing a biased interaction length to the Geant4 biasing framework.
virtual std::string getParticleToBias() const =0
Return the particle which should be biased.
G4BOptnChangeCrossSection * xsec_operation_
Cross-section biasing operation.
virtual std::string getVolumeToBias() const =0
Return the volume which should be biased.
framework::logging::logger the_log_
Enable logging.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...