LDMX Software
biasing::NonFiducialFilter Class Reference

User action that allows a user to filter out events that are non-fiducial, i.e. More...

#include <NonFiducialFilter.h>

Public Member Functions

 NonFiducialFilter (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
virtual ~NonFiducialFilter ()=default
 Destructor.
 
void stepping (const G4Step *step) override
 Implement the stepping action which performs the target volume biasing.
 
void EndOfEventAction (const G4Event *) override
 Method called at the end of every event.
 
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 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 recoil_max_p_ {1500}
 Recoil electron threshold.
 
bool abort_fiducial_ {true}
 If turned on, this aborts fiducial events.
 

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 action that allows a user to filter out events that are non-fiducial, i.e.

the electron is not contained in the ECAL and so can act like the signal

Definition at line 36 of file NonFiducialFilter.h.

Constructor & Destructor Documentation

◆ NonFiducialFilter()

NonFiducialFilter::NonFiducialFilter ( const std::string & name,
framework::config::Parameters & parameters )

Constructor.

Definition at line 27 of file NonFiducialFilter.cxx.

29 : simcore::UserAction(name, parameters) {
30 recoil_max_p_ = parameters.getParameter<double>("recoil_max_p");
31 abort_fiducial_ = parameters.getParameter<bool>("abort_fiducial");
32}
bool abort_fiducial_
If turned on, this aborts fiducial events.
double recoil_max_p_
Recoil electron threshold.
Interface that defines a user action.
Definition UserAction.h:43

References abort_fiducial_, and recoil_max_p_.

Member Function Documentation

◆ EndOfEventAction()

void NonFiducialFilter::EndOfEventAction ( const G4Event * )
overridevirtual

Method called at the end of every event.

Parameters
eventGeant4 event object.

Reimplemented from simcore::UserAction.

Definition at line 102 of file NonFiducialFilter.cxx.

102 {
103 if (nonFiducial_) {
104 ldmx_log(debug) << " >> This event is non-fiducial in ECAL, keeping it";
105 } else {
106 ldmx_log(debug) << ">> This event is fiducial, exiting";
107 }
108}

◆ getTypes()

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

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 58 of file NonFiducialFilter.h.

58 {
59 return {simcore::TYPE::EVENT, simcore::TYPE::STACKING,
60 simcore::TYPE::STEPPING};
61 }

◆ stepping()

void NonFiducialFilter::stepping ( const G4Step * step)
overridevirtual

Implement the stepping action which performs the target volume biasing.

Parameters
stepThe Geant4 step.

Reimplemented from simcore::UserAction.

Definition at line 34 of file NonFiducialFilter.cxx.

34 {
35 // Get the track associated with this step.
36 auto track{step->GetTrack()};
37
38 // Get the PDG ID of the track and make sure it's an electron.
39 if (auto pdgID{track->GetParticleDefinition()->GetPDGEncoding()};
40 pdgID != 11) {
41 return;
42 }
43
44 // Only process the primary electron track
45 int parentID{step->GetTrack()->GetParentID()};
46 if (parentID != 0) {
47 return;
48 }
49
50 // Check in which volume the electron is currently
51 auto phys_vol = track->GetVolume();
52 auto volume{phys_vol ? phys_vol->GetLogicalVolume() : nullptr};
53
54 // Check if the track is tagged.
55 auto electronCheck{simcore::UserTrackInformation::get(track)};
56 if (electronCheck->isRecoilElectron() == true) {
57 if (track->GetMomentum().mag() > recoil_max_p_) {
58 // Kill the track if its momemntum is too high
59 track->SetTrackStatus(fKillTrackAndSecondaries);
60 G4RunManager::GetRunManager()->AbortEvent();
61 ldmx_log(debug) << " Recoil track momentum is too high, expected to be "
62 "fiducial, exiting\n";
63 return;
64 }
65 // Check if the track ever enters the ECal. If it does, kill the track and
66 // abort the event.
67 auto volume_name{volume ? volume->GetName() : "undefined"};
68 auto is_in_ecal =
69 simcore::g4user::volumechecks::isInEcal(volume, volume_name);
70 if (abort_fiducial_ && is_in_ecal) {
71 track->SetTrackStatus(fKillTrackAndSecondaries);
72 G4RunManager::GetRunManager()->AbortEvent();
73 ldmx_log(debug) << ">> This event is fiducial, exiting";
74 nonFiducial_ = false;
75 return;
76 }
77 // I comment the following debug out since it would print per step and it's
78 // hard to read but it could be otherwise useful if somebody wants to do a
79 // step-by-step debugging ldmx_log(debug) << " >> In this step this is
80 // non-fiducial, keeping it so far";
81 nonFiducial_ = true;
82 return;
83 } else {
84 // Check if the particle enters the recoil tracker.
85 static auto recoil_volume =
86 simcore::g4user::ptrretrieval::getLogicalVolume("recoil");
87 if (!recoil_volume) {
88 ldmx_log(warn) << "Volume 'recoil' not found in Geant4 volume store";
89 }
90 if (volume == recoil_volume) {
91 /* Tag the tracks that:
92 1) Have a recoil electron
93 2) Enter/Exit the Target */
94 auto trackInfo{simcore::UserTrackInformation::get(track)};
95 trackInfo->tagRecoilElectron(); // tag the target recoil electron
96 ldmx_log(debug) << " >> This track is the recoil electron, tagging it";
97 return;
98 }
99 }
100}
static UserTrackInformation * get(const G4Track *track)
get

References abort_fiducial_, simcore::UserTrackInformation::get(), and recoil_max_p_.

Member Data Documentation

◆ abort_fiducial_

bool biasing::NonFiducialFilter::abort_fiducial_ {true}
private

If turned on, this aborts fiducial events.

Definition at line 67 of file NonFiducialFilter.h.

67{true};

Referenced by NonFiducialFilter(), and stepping().

◆ recoil_max_p_

double biasing::NonFiducialFilter::recoil_max_p_ {1500}
private

Recoil electron threshold.

Definition at line 65 of file NonFiducialFilter.h.

65{1500}; // MeV

Referenced by NonFiducialFilter(), and stepping().


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