LDMX Software
PartialEnergySorter.cxx
1
2#include "Biasing/Utility/PartialEnergySorter.h"
3
4/*~~~~~~~~~~~~*/
5/* Geant4 */
6/*~~~~~~~~~~~~*/
7#include "G4EventManager.hh"
8#include "G4Step.hh"
9
10namespace biasing {
11namespace utility {
12
14 const std::string& name, framework::config::Parameters& parameters)
15 : simcore::UserAction(name, parameters) {
16 threshold_ = parameters.get<double>("threshold");
17}
18
25 below_threshold_ = false;
26}
27
28G4ClassificationOfNewTrack PartialEnergySorter::classifyNewTrack(
29 const G4Track* aTrack,
30 const G4ClassificationOfNewTrack& currentTrackClassification) {
38 if (aTrack->GetKineticEnergy() > threshold_) {
45 return fUrgent;
46 }
47
48 /*
49 * Track has kinetic energy less than or equal to
50 * the threshold, so we put it on the waiting stack
51 * if there are still particles above threshold to be processed.
52 */
53 return below_threshold_ ? currentTrackClassification : fWaiting;
54}
55
56void PartialEnergySorter::stepping(const G4Step* step) {
57 if (below_threshold_) return;
58
59 auto pre_energy{step->GetPreStepPoint()->GetKineticEnergy()};
60 auto post_energy{step->GetPostStepPoint()->GetKineticEnergy()};
61
62 if (pre_energy >= threshold_ and post_energy <= threshold_) {
70 step->GetTrack()->SetTrackStatus(fSuspend);
71 }
72}
73
74} // namespace utility
75} // namespace biasing
76
#define DECLARE_ACTION(CLASS)
register a new UserAction with its factory
Definition UserAction.h:215
A simulation action that makes sure that all particles above a certain threshold are processed first.
bool below_threshold_
Are we simulating below the threshold yet?
G4ClassificationOfNewTrack classifyNewTrack(const G4Track *aTrack, const G4ClassificationOfNewTrack &currentTrackClass) override
Classify a "new" track.
PartialEnergySorter(const std::string &name, framework::config::Parameters &parameters)
Constructor.
void beginOfEventAction(const G4Event *event) override
At the beginning of a new event, we reset the counter for the number of particles above the energy th...
double threshold_
Minimum Kinetic Energy [MeV] we want to simulate first.
void stepping(const G4Step *step) override
Checks if a particle steps from above the threshold to below it.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...