LDMX Software
Public Member Functions | Private Attributes | List of all members
biasing::utility::DecayChildrenKeeper Class Reference

Filter to keep tracks that are the products of certain particle's decays. More...

#include <DecayChildrenKeeper.h>

Public Member Functions

 DecayChildrenKeeper (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
 ~DecayChildrenKeeper ()
 Destructor.
 
void PostUserTrackingAction (const G4Track *track) override
 Method called when a track is done being processed.
 
std::vector< simcore::TYPE > getTypes () override
 Retrieve the type of actions this class defines.
 
- Public Member Functions inherited from simcore::UserAction
 UserAction (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
virtual ~UserAction ()=default
 Destructor.
 
virtual void BeginOfEventAction (const G4Event *)
 Method called at the beginning of every event.
 
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 stepping (const G4Step *)
 Method called after each simulation step.
 
virtual G4ClassificationOfNewTrack ClassifyNewTrack (const G4Track *, const G4ClassificationOfNewTrack &cl)
 Method called when a track is updated.
 
virtual void NewStage ()
 Method called at the beginning of a new stage.
 
virtual void PrepareNewEvent ()
 Method called at the beginning of a new event.
 

Private Attributes

std::vector< int > parents_
 The PDG IDs for which to keep decay children.
 

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
UserEventInformationgetEventInfo () 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.
 

Detailed Description

Filter to keep tracks that are the products of certain particle's decays.

Note
It is important to emphasize that this filter is only able to persist products of particles that are themselves kept. i.e. Another action needs to keep the parent particle and then this action will save that particle's children.

Definition at line 27 of file DecayChildrenKeeper.h.

Constructor & Destructor Documentation

◆ DecayChildrenKeeper()

biasing::utility::DecayChildrenKeeper::DecayChildrenKeeper ( const std::string &  name,
framework::config::Parameters parameters 
)

Constructor.

Parameters
[in]namethe name of the instance of this UserAction.
[in]parametersthe parameters used to configure this UserAction.

Definition at line 17 of file DecayChildrenKeeper.cxx.

19 : simcore::UserAction(name, parameters) {
20 parents_ = parameters.getParameter<std::vector<int>>("parents");
21}
std::vector< int > parents_
The PDG IDs for which to keep decay children.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
Interface that defines a user action.
Definition UserAction.h:42

References framework::config::Parameters::getParameter(), and parents_.

◆ ~DecayChildrenKeeper()

biasing::utility::DecayChildrenKeeper::~DecayChildrenKeeper ( )

Destructor.

Definition at line 23 of file DecayChildrenKeeper.cxx.

23{}

Member Function Documentation

◆ getTypes()

std::vector< simcore::TYPE > biasing::utility::DecayChildrenKeeper::getTypes ( )
inlineoverridevirtual

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 61 of file DecayChildrenKeeper.h.

61 {
62 return {simcore::TYPE::TRACKING};
63 }

◆ PostUserTrackingAction()

void biasing::utility::DecayChildrenKeeper::PostUserTrackingAction ( const G4Track *  track)
overridevirtual

Method called when a track is done being processed.

We get the stored particle map from the TrackMap object and look for the current track's parent in it. If the current track's parent is in it THEN we check if that parent has a PDG matching ANY of the configured PDGs.

Note
Techinically, we can check for children of any particle that has finished processing (and is therefore in the stored particle map), but I focus here on "decays" because that is the only one where the parent is definitely at the end of processing.
Parameters
[in]trackGeant4 track associated with a particle.

Reimplemented from simcore::UserAction.

Definition at line 25 of file DecayChildrenKeeper.cxx.

25 {
26 const auto& particle_map{getCurrentParticleMap()};
27 if (particle_map.find(track->GetParentID()) != particle_map.end()) {
28 const int& parent_pdg{particle_map.at(track->GetParentID()).getPdgID()};
29 for (const int& parent : parents_) {
30 if (parent_pdg == parent) {
32 break;
33 } // parent is an interesting one
34 } // loop through interesting parent options
35 } // parent is in particle map
36}
const std::map< int, ldmx::SimParticle > & getCurrentParticleMap() const
Get the current particle map.
static UserTrackInformation * get(const G4Track *track)
get
void setSaveFlag(bool saveFlag)
Set the save flag so the associated track will be persisted as a Trajectory.

References simcore::UserTrackInformation::get(), simcore::UserAction::getCurrentParticleMap(), parents_, and simcore::UserTrackInformation::setSaveFlag().

Member Data Documentation

◆ parents_

std::vector<int> biasing::utility::DecayChildrenKeeper::parents_
private

The PDG IDs for which to keep decay children.

Definition at line 67 of file DecayChildrenKeeper.h.

Referenced by DecayChildrenKeeper(), and PostUserTrackingAction().


The documentation for this class was generated from the following files: