LDMX Software
|
A simulation action that makes sure that all particles above a certain threshold are processed first. More...
#include <PartialEnergySorter.h>
Public Member Functions | |
PartialEnergySorter (const std::string &name, framework::config::Parameters ¶meters) | |
Constructor. | |
virtual | ~PartialEnergySorter () |
Destructor. | |
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 threshold. | |
G4ClassificationOfNewTrack | ClassifyNewTrack (const G4Track *aTrack, const G4ClassificationOfNewTrack ¤tTrackClass) override |
Classify a "new" track. | |
void | stepping (const G4Step *step) override |
Checks if a particle steps from above the threshold to below it. | |
std::vector< simcore::TYPE > | getTypes () override |
Retrieve the type of actions this class defines. | |
void | NewStage () override |
Flag that we are now going below threshold. | |
Public Member Functions inherited from simcore::UserAction | |
UserAction (const std::string &name, framework::config::Parameters ¶meters) | |
Constructor. | |
virtual | ~UserAction ()=default |
Destructor. | |
virtual void | EndOfEventAction (const G4Event *) |
Method called at the end of every event. | |
virtual void | BeginOfRunAction (const G4Run *) |
Method called at the beginning of a run. | |
virtual void | EndOfRunAction (const G4Run *) |
Method called at the end of a run. | |
virtual void | PreUserTrackingAction (const G4Track *) |
Method called before the UserTrackingAction. | |
virtual void | PostUserTrackingAction (const G4Track *) |
Method called after the UserTrackingAction. | |
virtual void | PrepareNewEvent () |
Method called at the beginning of a new event. | |
Private Attributes | |
double | threshold_ |
Minimum Kinetic Energy [MeV] we want to simulate first. | |
bool | below_threshold_ |
Are we simulating below the threshold yet? | |
Additional Inherited Members | |
Public Types inherited from simcore::UserAction | |
using | Factory = ::simcore::Factory< UserAction, std::shared_ptr< UserAction >, const std::string &, framework::config::Parameters & > |
factory for user actions | |
Protected Member Functions inherited from simcore::UserAction | |
UserEventInformation * | getEventInfo () const |
Get a handle to the event information. | |
const std::map< int, ldmx::SimParticle > & | getCurrentParticleMap () const |
Get the current particle map. | |
Protected Attributes inherited from simcore::UserAction | |
std::string | name_ {""} |
Name of the UserAction. | |
framework::config::Parameters | parameters_ |
The set of parameters used to configure this class. | |
A simulation action that makes sure that all particles above a certain threshold are processed first.
This is not intended to modify any physics or perform any filters, only to improve efficiency by processing the more important, higher energy particles first before applying filtering.
This UserAction can run on its own or combined with other actions doing the filtering.
Definition at line 41 of file PartialEnergySorter.h.
biasing::utility::PartialEnergySorter::PartialEnergySorter | ( | const std::string & | name, |
framework::config::Parameters & | parameters | ||
) |
Constructor.
[in] | name | the name of the instance of this UserAction. |
[in] | parameters | the parameters used to configure this UserAction. |
Definition at line 14 of file PartialEnergySorter.cxx.
References framework::config::Parameters::getParameter(), and threshold_.
|
inlinevirtual |
|
overridevirtual |
At the beginning of a new event, we reset the counter for the number of particles above the energy threshold.
This reset is mandatory because sometimes previous events will be aborted before all of the particles above threshold are processed.
[in] | event | unused |
debug printout std::cout << "[ PartialEnergySorter ] : " << "Starting a new event." << std::endl;
Reimplemented from simcore::UserAction.
Definition at line 20 of file PartialEnergySorter.cxx.
References below_threshold_.
|
overridevirtual |
Classify a "new" track.
This is called when a new track is created or when a current track is suspended. We can use this functionality to move any tracks below the energy threshold to the waiting stack.
All tracks with kinetic energy above the threshold are put onto the urgent stack while any other particles are put onto the waiting stack if there are particles still above threshold.
aTrack | The Geant4 track. |
currentTrackClass | The current track classification. |
debug printout std::cout << "[ PartialEnergySorter ] : Classifying track " << aTrack->GetTrackID() << " with energy " << aTrack->GetKineticEnergy() << " MeV." << std::endl;
debug printout std::cout << "[ PartialEnergySorter ] : Classifying track " << aTrack->GetTrackID() << " with energy " << aTrack->GetKineticEnergy() << " MeV." << std::endl;
Reimplemented from simcore::UserAction.
Definition at line 29 of file PartialEnergySorter.cxx.
References below_threshold_, and threshold_.
|
inlineoverridevirtual |
Retrieve the type of actions this class defines.
Implements simcore::UserAction.
Definition at line 101 of file PartialEnergySorter.h.
|
inlineoverridevirtual |
Flag that we are now going below threshold.
This function is called when the urgent stack is empty and the waiting stack is transferred to the urgent stack.
With all tracks below threshold being pushed to the waiting stack, the first time this occurs during the event is when the rest of the particles are below the threshold energy, so we reset the counter on the number of particles above the threshold here.
This function can be called several times in an event, but the first time it is called in an event is when there is no more particles with kinetic energy above the threshold left to be processed.
Sometimes (e.g. in the case when you are using this with the custom dark brem process) there will still be particles "left-over" that are above the threshold. These particles are the electron that went dark brem and the A' which are above the threshold but both don't interact with anything else. Since they don't interact with anything else, they finish tracking without "stepping" from above the threshold to below it.
debug printout std::cout << "[ PartialEnergySorter ] : " << "Starting new stage with " << num_particles_above_threshold_ << " particles above threshold." << std::endl;
Reimplemented from simcore::UserAction.
Definition at line 131 of file PartialEnergySorter.h.
References below_threshold_.
|
overridevirtual |
Checks if a particle steps from above the threshold to below it.
If the particle does step below the threshold it is suspended, so that it can be re-classifed onto the waiting stack.
Nothing happens if we are already below threshold (i.e. below_threshold_ is true).
[in] | step | Geant4 step |
debug printout std::cout << "[ PartialEnergySorter ] : Stepping track " << step->GetTrack()->GetTrackID() << " going from " << pre_energy << " MeV to " << post_energy << " MeV." << std::endl;
Reimplemented from simcore::UserAction.
Definition at line 57 of file PartialEnergySorter.cxx.
References below_threshold_, and threshold_.
|
private |
Are we simulating below the threshold yet?
Definition at line 147 of file PartialEnergySorter.h.
Referenced by BeginOfEventAction(), ClassifyNewTrack(), NewStage(), and stepping().
|
private |
Minimum Kinetic Energy [MeV] we want to simulate first.
Definition at line 144 of file PartialEnergySorter.h.
Referenced by ClassifyNewTrack(), PartialEnergySorter(), and stepping().