LDMX Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 beginning of a new stage.
 
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 Member Functions

 enableLogging ("DeepEcalProcessFilter") bool photonFromTarget_
 Enable logging.
 

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 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 = ::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 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 20 of file DeepEcalProcessFilter.cxx.

22 : simcore::UserAction(name, parameters) {
23 bias_threshold_ = parameters.getParameter<double>("bias_threshold");
24 processes_ = parameters.getParameter<std::vector<std::string>>("processes");
25 ecal_min_Z_ = parameters.getParameter<double>("ecal_min_Z");
27 parameters.getParameter<bool>("require_photon_fromTarget");
28}
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.
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 bias_threshold_, ecal_min_Z_, framework::config::Parameters::getParameter(), 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 30 of file DeepEcalProcessFilter.cxx.

30 {
31 hasDeepEcalProcess_ = false;
32 photonFromTarget_ = false;
33}
bool hasDeepEcalProcess_
member used to help tag events that have a deep-ecal process ocurr

References hasDeepEcalProcess_.

◆ enableLogging()

biasing::DeepEcalProcessFilter::enableLogging ( "DeepEcalProcessFilter"  )
inlineprivate

Enable logging.

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

Definition at line 78 of file DeepEcalProcessFilter.h.

80 {false};

◆ 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 beginning of a new stage.

TYPE::STACKING

Reimplemented from simcore::UserAction.

Definition at line 119 of file DeepEcalProcessFilter.cxx.

119 {
121 ldmx_log(debug) << "> Event with a hard deep conversion found, yaaay!";
122 ldmx_log(debug) << "> -----------------------------------------";
123 } else {
124 // ldmx_log(debug) << "> -----------------------------------------";
125 G4RunManager::GetRunManager()->AbortEvent();
126 }
127}

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 35 of file DeepEcalProcessFilter.cxx.

35 {
36 // Get the track associated with this step.
37 auto track{step->GetTrack()};
38
39 // Check the creation process and PDG ID of the particle
40 auto processName = track->GetCreatorProcess()
41 ? track->GetCreatorProcess()->GetProcessName()
42 : "unknown";
43 auto PDGid = track->GetParticleDefinition()->GetPDGEncoding();
44
45 // Skip the steps that are for the recoil electron
46 // PrimaryToEcalFilter made sure there is a fiducial e-
47 if (processName.contains("unknown")) return;
48
49 // Energy of the particle is below threshold, move to next step
50 if (track->GetKineticEnergy() < bias_threshold_) {
51 return;
52 }
53
54 // Check in which volume the particle is currently
55 auto volume{track->GetVolume()->GetLogicalVolume()
56 ? track->GetVolume()->GetLogicalVolume()->GetName()
57 : "undefined"};
58
59 auto trackInfo{simcore::UserTrackInformation::get(track)};
60 // Tag the brem photon from the primary electron
61 if (processName.contains("eBrem") and (track->GetParentID() == 1)) {
62 trackInfo->tagBremCandidate();
64 trackInfo->setSaveFlag(true);
65 if (volume.contains("target")) {
66 photonFromTarget_ = true;
67 }
68 }
69
70 // If we require that the photon comes from the target and
71 // and if it does not, let's skip the event
72 if (require_photon_fromTarget_ and !photonFromTarget_) {
73 return;
74 }
75
76 // Tag if the event has the processes we are looking for
77 bool hasProcessNeeded{false};
78 for (auto& process : processes_) {
79 // ldmx_log(debug) << "Allowed processed " << process << " now we have " <<
80 // processName;
81 if (processName.contains(process)) {
82 hasProcessNeeded = true;
83 break;
84 }
85 }
86 // skip this step if it does not have any of the processes needed
87 if (not hasProcessNeeded) return;
88
89 // isInEcal should be taken from
90 // simcore::logical_volume_tests::isInEcal(volume) but for now it's under
91 // its own namespace so I cannot reach it here, see issue
92 // https://github.com/LDMX-Software/ldmx-sw/issues/1286
93 auto isInEcal{((volume.contains("Si") || volume.contains("W") ||
94 volume.contains("PCB") || volume.contains("strongback") ||
95 volume.contains("Glue") || volume.contains("CFMix") ||
96 volume.contains("Al") || volume.contains("C")) &&
97 volume.contains("volume")) ||
98 (volume.contains("nohole_motherboard"))};
99
100 // Skip this step if it does not have the processes needed
101 // or if it's not in the ECAL
102 if (not isInEcal) return;
103
104 // Check the z position of the particle, and
105 // flag if it is deeper than the min Z we are considering (but in ECAL)
106 auto zPosition = step->GetPreStepPoint()->GetPosition().z();
107 // Printout for testing
108 if (zPosition > (0.75 * ecal_min_Z_)) {
109 ldmx_log(debug) << " Particle ID " << PDGid << " with energy "
110 << track->GetKineticEnergy() << " on " << volume << " from "
111 << processName << " at Z = " << zPosition;
112 if (zPosition > ecal_min_Z_) {
113 hasDeepEcalProcess_ = true;
114 }
115 }
116 return;
117}
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
void tagBremCandidate(bool isBremCandidate=true)
Tag this track as a brem candidate by the biasing filters.

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

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 82 of file DeepEcalProcessFilter.h.

82{false};

Referenced by BeginOfEventAction(), NewStage(), 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: