LDMX Software
GenieElectroNuclearProcess.h
Go to the documentation of this file.
1
7#ifndef SIMCORE_GENIEELECTRONUCLEARPROCESS_H
8#define SIMCORE_GENIEELECTRONUCLEARPROCESS_H
9
10#include <map>
11#include <memory>
12#include <set>
13#include <string>
14#include <vector>
15
16#include "Framework/Configure/Parameters.h"
17#include "Framework/Logger.h"
18#include "G4VDiscreteProcess.hh"
19#include "GENIE/Framework/EventGen/GEVGDriver.h"
20#include "GENIE/Framework/EventGen/HepMC3Converter.h"
21
22class G4Element;
23
24namespace simcore {
25
40class GenieElectroNuclearProcess : public G4VDiscreteProcess {
41 public:
43 static const std::string PROCESS_NAME;
44
54
57
61 G4bool IsApplicable(const G4ParticleDefinition& p) override;
62
70 G4VParticleChange* PostStepDoIt(const G4Track& track,
71 const G4Step& step) override;
72
74 void setOnlyOnePerEvent(bool val) { only_one_per_event_ = val; }
75
76 protected:
83 G4double GetMeanFreePath(const G4Track& track, G4double prevStepSize,
84 G4ForceCondition* condition) override;
85
86 private:
88 void initializeGENIE();
89
96
102 bool splineAvailable(int target_code) const;
103
105 void setupDrivers();
106
108 void discoverIsotopesForElement(const G4Element* element);
109
118 void discoverFromVolume();
119
121 std::vector<std::unique_ptr<genie::GEVGDriver>> evg_drivers_;
122
124 genie::HepMC3Converter hep_mc3_converter_;
125
127 std::vector<int> targets_;
128
130 std::vector<double> abundances_;
131
133 std::string tune_;
134
136 std::string spline_file_;
137
140
143
146
148 bool auto_discover_{false};
149
152 std::string discover_volume_;
153
155 std::set<int> discovered_z_;
156
159 std::set<int> available_targets_;
160
166 std::map<int, std::vector<std::pair<int, double>>> z_to_targets_;
167
173 std::vector<double> partial_sum_sigma_;
174
175 enableLogging("GenieElectroNuclearProcess")
176};
177
178} // namespace simcore
179
180#endif // SIMCORE_GENIEELECTRONUCLEARPROCESS_H
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Geant4 discrete process that fires GENIE electronuclear interactions.
void initializeGENIE()
Initialize the GENIE framework (tune, message thresholds, splines)
G4bool IsApplicable(const G4ParticleDefinition &p) override
bool only_one_per_event_
Only allow one EN interaction per event (then deactivate)
bool genie_initialized_
Flag to lazily sync GENIE random seed on first event.
static const std::string PROCESS_NAME
Process name — matches the built-in so the bias operator works unchanged.
void setupDrivers()
Set up GEVGDrivers for each target isotope (manual mode)
std::vector< int > targets_
GENIE target codes (10LZZZAAAI format)
std::set< int > discovered_z_
Z values already checked for isotope discovery.
std::vector< std::unique_ptr< genie::GEVGDriver > > evg_drivers_
One GENIE event generator driver per target isotope.
void loadAvailableTargets()
Parse the spline file for the set of target nuclei that have cross-section splines available.
G4double GetMeanFreePath(const G4Track &track, G4double prevStepSize, G4ForceCondition *condition) override
Calculate the mean free path for the electronuclear process.
std::vector< double > abundances_
Relative abundances for each target.
std::string discover_volume_
Name of the volume to auto-discover targets from (e.g.
void setOnlyOnePerEvent(bool val)
Set whether to allow only one interaction per event.
void discoverFromVolume()
One-shot auto-discovery of target isotopes from the configured volume.
std::vector< double > partial_sum_sigma_
Partial cross-section sums per element, used to select the target isotope in PostStepDoIt via weighte...
bool auto_discover_
Whether targets are auto-discovered from the Geant4 geometry.
GenieElectroNuclearProcess(const framework::config::Parameters &params)
Constructor.
G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &step) override
Called by Geant4 when this process fires.
std::map< int, std::vector< std::pair< int, double > > > z_to_targets_
Lookup map: element Z -> list of (driver_index, abundance).
std::set< int > available_targets_
Target nuclei (10LZZZAAAI codes) that have splines in the spline file.
genie::HepMC3Converter hep_mc3_converter_
Converter from GENIE EventRecord to HepMC3.
std::string message_threshold_file_
Path to GENIE message threshold configuration.
std::string spline_file_
Path to GENIE cross-section spline file.
void discoverIsotopesForElement(const G4Element *element)
Discover isotopes from a G4Element and set up GENIE drivers (auto mode)
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...