LDMX Software
biasing::DeepEcalProcessFilter Class Reference

User action that allows a user to filter out events where the interaction happened deep in the ECAL. More...

#include <DeepEcalProcessFilter.h>

Public Member Functions

 DeepEcalProcessFilter (const std::string &name, framework::config::Parameters &parameters)
 Constructor.
 
virtual ~DeepEcalProcessFilter ()=default
 Destructor.
 
void BeginOfEventAction (const G4Event *event) override
 Method to set flags in the beginning of the event.
 
void stepping (const G4Step *step) override
 Implement the stepping action which performs the target volume biasing.
 
void NewStage () 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 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 PrepareNewEvent ()
 Method called at the beginning of a new event.
 

Private Attributes

double bias_threshold_ {1500.}
 Minimal energy the products should have.
 
std::vector< std::string > processes_ {"conv", "phot"}
 The allowed processes that can happen deep inside the ECAL, default is conversion (conv) and photoelectron (photo)
 
double ecal_min_Z_ {400.}
 Minimum Z location where the deep process should happen.
 
bool require_photon_fromTarget_ {false}
 Require that the hard brem photon originates from the target.
 
bool photonFromTarget_ {false}
 member used to help tag events where the photon comes from the target
 
bool hasDeepEcalProcess_ {false}
 member used to help tag events that have a deep-ecal process ocurr
 

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 where the interaction happened deep in the ECAL.

Definition at line 35 of file DeepEcalProcessFilter.h.

Constructor & Destructor Documentation

◆ DeepEcalProcessFilter()

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

Constructor.

Definition at line 21 of file DeepEcalProcessFilter.cxx.

23 : simcore::UserAction(name, parameters) {
24 bias_threshold_ = parameters.getParameter<double>("bias_threshold");
25 processes_ = parameters.getParameter<std::vector<std::string>>("processes");
26 ecal_min_Z_ = parameters.getParameter<double>("ecal_min_Z");
28 parameters.getParameter<bool>("require_photon_fromTarget");
29}
double bias_threshold_
Minimal energy the products should have.
std::vector< std::string > processes_
The allowed processes that can happen deep inside the ECAL, default is conversion (conv) and photoele...
double ecal_min_Z_
Minimum Z location where the deep process should happen.
bool require_photon_fromTarget_
Require that the hard brem photon originates from the target.
Interface that defines a user action.
Definition UserAction.h:43

References bias_threshold_, ecal_min_Z_, processes_, and require_photon_fromTarget_.

Member Function Documentation

◆ BeginOfEventAction()

void DeepEcalProcessFilter::BeginOfEventAction ( const G4Event * event)
overridevirtual

Method to set flags in the beginning of the event.

Reimplemented from simcore::UserAction.

Definition at line 31 of file DeepEcalProcessFilter.cxx.

31 {
32 hasDeepEcalProcess_ = false;
33 photonFromTarget_ = false;
34}
bool hasDeepEcalProcess_
member used to help tag events that have a deep-ecal process ocurr
bool photonFromTarget_
member used to help tag events where the photon comes from the target

References hasDeepEcalProcess_, and photonFromTarget_.

◆ getTypes()

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

Retrieve the type of actions this class defines.

Implements simcore::UserAction.

Definition at line 62 of file DeepEcalProcessFilter.h.

62 {
63 return {simcore::TYPE::STACKING, simcore::TYPE::STEPPING,
64 simcore::TYPE::EVENT};
65 }

◆ NewStage()

void DeepEcalProcessFilter::NewStage ( )
overridevirtual

Method called at the end of every event.

Parameters
eventGeant4 event object.

Reimplemented from simcore::UserAction.

Definition at line 112 of file DeepEcalProcessFilter.cxx.

112 {
114 ldmx_log(debug) << "> Event with a hard deep conversion found, yaaay!";
115 ldmx_log(debug) << "> -----------------------------------------";
116 } else {
117 // ldmx_log(debug) << "> -----------------------------------------";
118 G4RunManager::GetRunManager()->AbortEvent();
119 }
120}

References hasDeepEcalProcess_.

◆ stepping()

void DeepEcalProcessFilter::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 36 of file DeepEcalProcessFilter.cxx.

36 {
37 // Get the track associated with this step.
38 auto track{step->GetTrack()};
39
40 // Check the creation process and PDG ID of the particle
41 auto processName = track->GetCreatorProcess()
42 ? track->GetCreatorProcess()->GetProcessName()
43 : "unknown";
44 auto PDGid = track->GetParticleDefinition()->GetPDGEncoding();
45
46 // Skip the steps that are for the recoil electron
47 // PrimaryToEcalFilter made sure there is a fiducial e-
48 if (processName.contains("unknown")) return;
49
50 // Energy of the particle is below threshold, move to next step
51 if (track->GetKineticEnergy() < bias_threshold_) {
52 return;
53 }
54
55 // Check in which volume the particle is currently
56 auto phys_vol{track->GetVolume()};
57 auto volume{phys_vol ? phys_vol->GetLogicalVolume() : nullptr};
58 auto volume_name{volume ? volume->GetName() : "undefined"};
59
60 auto trackInfo{simcore::UserTrackInformation::get(track)};
61 // Tag the brem photon from the primary electron
62 if (processName.contains("eBrem") and (track->GetParentID() == 1)) {
63 trackInfo->tagBremCandidate();
65 trackInfo->setSaveFlag(true);
66 if (volume_name.contains("target")) {
67 photonFromTarget_ = true;
68 }
69 }
70
71 // If we require that the photon comes from the target and
72 // and if it does not, let's skip the event
74 return;
75 }
76
77 // Tag if the event has the processes we are looking for
78 bool hasProcessNeeded{false};
79 for (auto& process : processes_) {
80 // ldmx_log(debug) << "Allowed processed " << process << " now we have " <<
81 // processName;
82 if (processName.contains(process)) {
83 hasProcessNeeded = true;
84 break;
85 }
86 }
87 // skip this step if it does not have any of the processes needed
88 if (not hasProcessNeeded) return;
89
90 auto is_in_ecal =
91 simcore::g4user::volumechecks::isInEcal(volume, volume_name);
92
93 // Skip this step if it does not have the processes needed
94 // or if it's not in the ECAL
95 if (not is_in_ecal) return;
96
97 // Check the z position of the particle, and
98 // flag if it is deeper than the min Z we are considering (but in ECAL)
99 auto zPosition = step->GetPreStepPoint()->GetPosition().z();
100 // Printout for testing
101 if (zPosition > (0.75 * ecal_min_Z_)) {
102 ldmx_log(debug) << " Particle ID " << PDGid << " with energy "
103 << track->GetKineticEnergy() << " on " << volume << " from "
104 << processName << " at Z = " << zPosition;
105 if (zPosition > ecal_min_Z_) {
106 hasDeepEcalProcess_ = true;
107 }
108 }
109 return;
110}
UserEventInformation * getEventInfo() const
Get a handle to the event information.
void incBremCandidateCount()
Increment the number of brem candidates in an event.
static UserTrackInformation * get(const G4Track *track)
get

References bias_threshold_, ecal_min_Z_, simcore::UserTrackInformation::get(), simcore::UserAction::getEventInfo(), hasDeepEcalProcess_, simcore::UserEventInformation::incBremCandidateCount(), photonFromTarget_, processes_, and require_photon_fromTarget_.

Member Data Documentation

◆ bias_threshold_

double biasing::DeepEcalProcessFilter::bias_threshold_ {1500.}
private

Minimal energy the products should have.

Definition at line 69 of file DeepEcalProcessFilter.h.

69{1500.};

Referenced by DeepEcalProcessFilter(), and stepping().

◆ ecal_min_Z_

double biasing::DeepEcalProcessFilter::ecal_min_Z_ {400.}
private

Minimum Z location where the deep process should happen.

Definition at line 74 of file DeepEcalProcessFilter.h.

74{400.};

Referenced by DeepEcalProcessFilter(), and stepping().

◆ hasDeepEcalProcess_

bool biasing::DeepEcalProcessFilter::hasDeepEcalProcess_ {false}
private

member used to help tag events that have a deep-ecal process ocurr

Definition at line 80 of file DeepEcalProcessFilter.h.

80{false};

Referenced by BeginOfEventAction(), NewStage(), and stepping().

◆ photonFromTarget_

bool biasing::DeepEcalProcessFilter::photonFromTarget_ {false}
private

member used to help tag events where the photon comes from the target

Definition at line 78 of file DeepEcalProcessFilter.h.

78{false};

Referenced by BeginOfEventAction(), and stepping().

◆ processes_

std::vector<std::string> biasing::DeepEcalProcessFilter::processes_ {"conv", "phot"}
private

The allowed processes that can happen deep inside the ECAL, default is conversion (conv) and photoelectron (photo)

Definition at line 72 of file DeepEcalProcessFilter.h.

72{"conv", "phot"};

Referenced by DeepEcalProcessFilter(), and stepping().

◆ require_photon_fromTarget_

bool biasing::DeepEcalProcessFilter::require_photon_fromTarget_ {false}
private

Require that the hard brem photon originates from the target.

Definition at line 76 of file DeepEcalProcessFilter.h.

76{false};

Referenced by DeepEcalProcessFilter(), and stepping().


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