LDMX Software
Public Member Functions | Private Attributes | List of all members
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 = ::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

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

24 : simcore::UserAction(name, parameters) {
25 recoil_max_p_ = parameters.getParameter<double>("recoil_max_p");
26 abort_fiducial_ = parameters.getParameter<bool>("abort_fiducial");
27}
bool abort_fiducial_
If turned on, this aborts fiducial events.
double recoil_max_p_
Recoil electron threshold.
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 abort_fiducial_, framework::config::Parameters::getParameter(), 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 (nonFiducial_) {
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 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 29 of file NonFiducialFilter.cxx.

29 {
30 // Get the track associated with this step.
31 auto track{step->GetTrack()};
32
33 // Get the PDG ID of the track and make sure it's an electron.
34 if (auto pdgID{track->GetParticleDefinition()->GetPDGEncoding()};
35 pdgID != 11) {
36 return;
37 }
38
39 // Only process the primary electron track
40 int parentID{step->GetTrack()->GetParentID()};
41 if (parentID != 0) {
42 return;
43 }
44
45 // Check in which volume the electron is currently
46 auto volume{track->GetVolume()->GetLogicalVolume()
47 ? track->GetVolume()->GetLogicalVolume()->GetName()
48 : "undefined"};
49
50 // Check if the track is tagged.
51 auto electronCheck{simcore::UserTrackInformation::get(track)};
52 if (electronCheck->isRecoilElectron() == true) {
53 if (track->GetMomentum().mag() > recoil_max_p_) {
54 // Kill the track if its momemntum is too high
55 track->SetTrackStatus(fKillTrackAndSecondaries);
56 G4RunManager::GetRunManager()->AbortEvent();
57 ldmx_log(debug) << " Recoil track momentum is too high, expected to be "
58 "fiducial, exiting\n";
59 return;
60 }
61 // Check if the track ever enters the ECal. If it does, kill the track and
62 // abort the event.
63 auto isInEcal{((volume.contains("Si") || volume.contains("W") ||
64 volume.contains("PCB") || volume.contains("strongback") ||
65 volume.contains("Glue") || volume.contains("CFMix") ||
66 volume.contains("Al") || volume.contains("C")) &&
67 volume.contains("volume")) ||
68 (volume.contains("nohole_motherboard"))};
69
70 // isInEcal should be taken from
71 // simcore::logical_volume_tests::isInEcal(volume) but for now it's under
72 // its own namespace so I cannot reach it here see issue
73 // https://github.com/LDMX-Software/ldmx-sw/issues/1286
74 if (abort_fiducial_ && isInEcal) {
75 track->SetTrackStatus(fKillTrackAndSecondaries);
76 G4RunManager::GetRunManager()->AbortEvent();
77 ldmx_log(debug) << ">> This event is fiducial, exiting";
78 nonFiducial_ = false;
79 return;
80 }
81 // I comment the following debug out since it would print per step and it's
82 // hard to read but it could be otherwise useful if somebody wants to do a
83 // step-by-step debugging ldmx_log(debug) << " >> In this step this is
84 // non-fiducial, keeping it so far";
85 nonFiducial_ = true;
86 return;
87 } else {
88 // Check if the particle enters the recoil tracker.
89 if (volume.compareTo("recoil") == 0) {
90 /* Tag the tracks that:
91 1) Have a recoil electron
92 2) Enter/Exit the Target */
93 auto trackInfo{simcore::UserTrackInformation::get(track)};
94 trackInfo->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
void tagRecoilElectron(bool isRecoilElectron=true)
Tag this track as a recoil electron by the biasing filters.

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

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: