LDMX Software
biasing::PrimaryToEcalFilter Class Reference

User stepping action used to filter events where the primary particle falls below a threshold before reaching the CalorimeterRegion. More...

#include <PrimaryToEcalFilter.h>

Public Member Functions

 PrimaryToEcalFilter (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
 ~PrimaryToEcalFilter ()
 Destructor.
 
void stepping (const G4Step *step) override
 Only process if the track is a primary (parentID == 0) and if the event is not aborted and the particle is not in the CalorimeterRegion.
 
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 PostUserTrackingAction (const G4Track *)
 Method called after the UserTrackingAction.
 
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

double threshold_
 Energy [MeV] below which a primary should be vetoed.
 

Additional Inherited Members

- Public Types inherited from simcore::UserAction
using Factory
 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.
 
mutable::framework::logging::logger theLog_
 the logging channel user actions can use ldmx_log with
 

Detailed Description

User stepping action used to filter events where the primary particle falls below a threshold before reaching the CalorimeterRegion.

This is a simplistic filter designed similar to the TaggerVetoFilter.

Definition at line 30 of file PrimaryToEcalFilter.h.

Constructor & Destructor Documentation

◆ PrimaryToEcalFilter()

biasing::PrimaryToEcalFilter::PrimaryToEcalFilter ( 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 20 of file PrimaryToEcalFilter.cxx.

22 : simcore::UserAction(name, parameters) {
23 threshold_ = parameters.getParameter<double>("threshold");
24}
double threshold_
Energy [MeV] below which a primary should be vetoed.
Interface that defines a user action.
Definition UserAction.h:43

References threshold_.

◆ ~PrimaryToEcalFilter()

biasing::PrimaryToEcalFilter::~PrimaryToEcalFilter ( )
inline

Destructor.

Definition at line 43 of file PrimaryToEcalFilter.h.

43{}

Member Function Documentation

◆ getTypes()

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

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 58 of file PrimaryToEcalFilter.h.

58 {
59 return {simcore::TYPE::STEPPING};
60 }

◆ stepping()

void biasing::PrimaryToEcalFilter::stepping ( const G4Step * step)
overridevirtual

Only process if the track is a primary (parentID == 0) and if the event is not aborted and the particle is not in the CalorimeterRegion.

If the energy of the particle is below the input threshold, then the event is aborted.

Parameters
[in]stepGeant4 step

Reimplemented from simcore::UserAction.

Definition at line 26 of file PrimaryToEcalFilter.cxx.

26 {
27 // Only process the primary electron track
28 if (int parentID{step->GetTrack()->GetParentID()}; parentID != 0) return;
29
30 if (G4EventManager::GetEventManager()->GetConstCurrentEvent()->IsAborted())
31 return;
32
33 // Get the region the particle is currently in. Continue processing
34 // the particle only if it's NOT in the calorimeter region
35 auto current_region =
36 step->GetTrack()->GetVolume()->GetLogicalVolume()->GetRegion();
37 auto calorimeter_region =
38 simcore::g4user::ptrretrieval::getRegion("CalorimeterRegion");
39 if (!calorimeter_region) {
40 ldmx_log(warn)
41 << "Region 'CalorimeterRegion' not found in Geant4 region store";
42 }
43 if (current_region == calorimeter_region) return;
44
45 // If the energy of the particle fell below threshold, stop processing the
46 // event.
47 if (auto energy{step->GetPostStepPoint()->GetTotalEnergy()};
48 energy < threshold_) {
49 /*
50 std::cout << "[ PrimaryToEcalFilter ] : Aborting "
51 <<
52 G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID() <<
53 std::endl;
54 */
55 step->GetTrack()->SetTrackStatus(fKillTrackAndSecondaries);
56 G4RunManager::GetRunManager()->AbortEvent();
57 return;
58 }
59}

References threshold_.

Member Data Documentation

◆ threshold_

double biasing::PrimaryToEcalFilter::threshold_
private

Energy [MeV] below which a primary should be vetoed.

Definition at line 64 of file PrimaryToEcalFilter.h.

Referenced by PrimaryToEcalFilter(), and stepping().


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