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.
 
 DECLARE_FACTORY (UserAction, std::shared_ptr< UserAction >, const std::string &, framework::config::Parameters &)
 factory for user actions
 
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

- 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.
 
void abortEvent (const std::string &reason) const
 Helper to abort an event with a message.
 
- 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 the_log_
 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 30 of file NonFiducialFilter.h.

Constructor & Destructor Documentation

◆ NonFiducialFilter()

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

Constructor.

Definition at line 26 of file NonFiducialFilter.cxx.

28 : simcore::UserAction(name, parameters) {
29 recoil_max_p_ = parameters.get<double>("recoil_max_p");
30 abort_fiducial_ = parameters.get<bool>("abort_fiducial");
31}
bool abort_fiducial_
If turned on, this aborts fiducial events.
double recoil_max_p_
Recoil electron threshold.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
Interface that defines a user action.
Definition UserAction.h:46

References abort_fiducial_, framework::config::Parameters::get(), 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 101 of file NonFiducialFilter.cxx.

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

◆ getTypes()

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

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 52 of file NonFiducialFilter.h.

52 {
53 return {simcore::TYPE::EVENT, simcore::TYPE::STACKING,
54 simcore::TYPE::STEPPING};
55 }

◆ 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 33 of file NonFiducialFilter.cxx.

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

61{true};

Referenced by NonFiducialFilter(), and stepping().

◆ recoil_max_p_

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

Recoil electron threshold.

Definition at line 59 of file NonFiducialFilter.h.

59{1500}; // MeV

Referenced by NonFiducialFilter(), and stepping().


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