LDMX Software
recon::RecoilFiducialityProcessor Class Reference

Flags events with a fiducial recoil electron, based on truth information. More...

#include <RecoilFiducialityProcessor.h>

Public Member Functions

 RecoilFiducialityProcessor (const std::string &name, framework::Process &process)
 Class constructor.
 
virtual ~RecoilFiducialityProcessor ()=default
 Class destructor.
 
void configure (framework::config::Parameters &parameters) override
 Configure the processor using the given user specified parameters.
 
void produce (framework::Event &event) override
 Create a FiducialFlag object to contain info about whether the recoil electron satisfies certain fiduciality conditions.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

double min_p_mag_
 Minimum recoil electron momentum at production.
 
int min_tracker_hits_
 Minimum number of recoil electron hits in the recoil tracker.
 
std::string input_pass_name_
 The pass name of the input collections.
 
std::string ecal_collection_
 The name of the ecal collection.
 
std::string hcal_collection_
 The name of the hcal collection.
 
std::string recoil_collection_
 The name of the recoil tracker collection.
 
std::string output_collection_
 The name of the output collection.
 
bool inverse_skim_ {false}
 Inverse option for skimming.
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Flags events with a fiducial recoil electron, based on truth information.

Note

Definition at line 29 of file RecoilFiducialityProcessor.h.

Constructor & Destructor Documentation

◆ RecoilFiducialityProcessor()

recon::RecoilFiducialityProcessor::RecoilFiducialityProcessor ( const std::string & name,
framework::Process & process )
inline

Class constructor.

Definition at line 34 of file RecoilFiducialityProcessor.h.

Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void recon::RecoilFiducialityProcessor::configure ( framework::config::Parameters & parameters)
overridevirtual

Configure the processor using the given user specified parameters.

Parameters
parametersSet of parameters used to configure this processor.

Reimplemented from framework::EventProcessor.

Definition at line 11 of file RecoilFiducialityProcessor.cxx.

12 {
13 min_p_mag_ = parameters.get<double>("min_p_mag");
14 min_tracker_hits_ = parameters.get<int>("min_tracker_hits");
15 input_pass_name_ = parameters.get<std::string>("input_pass_name");
16 ecal_collection_ = parameters.get<std::string>("ecal_collection");
17 hcal_collection_ = parameters.get<std::string>("hcal_collection");
18 recoil_collection_ = parameters.get<std::string>("recoil_collection");
19 output_collection_ = parameters.get<std::string>("output_collection");
20 inverse_skim_ = parameters.get<bool>("inverse_skim");
21}
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
bool inverse_skim_
Inverse option for skimming.
std::string ecal_collection_
The name of the ecal collection.
std::string hcal_collection_
The name of the hcal collection.
std::string output_collection_
The name of the output collection.
std::string recoil_collection_
The name of the recoil tracker collection.
int min_tracker_hits_
Minimum number of recoil electron hits in the recoil tracker.
double min_p_mag_
Minimum recoil electron momentum at production.
std::string input_pass_name_
The pass name of the input collections.

References ecal_collection_, framework::config::Parameters::get(), hcal_collection_, input_pass_name_, inverse_skim_, min_p_mag_, min_tracker_hits_, output_collection_, and recoil_collection_.

◆ produce()

void recon::RecoilFiducialityProcessor::produce ( framework::Event & event)
overridevirtual

Create a FiducialFlag object to contain info about whether the recoil electron satisfies certain fiduciality conditions.

Parameters
eventThe event to run the fiduciality check on.

Implements framework::Producer.

Definition at line 23 of file RecoilFiducialityProcessor.cxx.

23 {
24 // Get the collection of simulated particles from the event
25 auto particle_map{
26 event.getMap<int, ldmx::SimParticle>("SimParticles", input_pass_name_)};
27
28 // Search for the recoil electron
29 auto [recoil_track_id, recoil_electron] = analysis::getRecoil(particle_map);
30
31 // Get the collection of simulated Ecal hits_ from the event.
32 const std::vector<ldmx::SimCalorimeterHit> ecal_sim_hits =
33 event.getCollection<ldmx::SimCalorimeterHit>(ecal_collection_,
35
36 // Get the collection of simulated Ecal hits_ from the event.
37 const std::vector<ldmx::SimCalorimeterHit> hcal_sim_hits =
38 event.getCollection<ldmx::SimCalorimeterHit>(hcal_collection_,
40
41 // Get the collection of simulated tracker hits_ from the event.
42 const std::vector<ldmx::SimTrackerHit> recoil_sim_hits =
43 event.getCollection<ldmx::SimTrackerHit>(recoil_collection_,
45
46 // Loop through the Ecal hits_ and check if the recoil electron is
47 // associated with any of them.
48 bool has_ecal_hit = false;
49 int ecal_hit_id = -1;
50 for (const ldmx::SimCalorimeterHit &sim_hit : ecal_sim_hits) {
51 for (int i_contrib = 0; i_contrib < sim_hit.getNumberOfContribs();
52 ++i_contrib) {
53 ldmx::SimCalorimeterHit::Contrib contrib = sim_hit.getContrib(i_contrib);
54
55 if (contrib.track_id_ == recoil_track_id) {
56 has_ecal_hit = true;
57 ecal_hit_id = sim_hit.getID();
58 }
59 }
60 }
61
62 // Loop through the Hcal hits_ and check if the recoil electron is
63 // associated with any of them.
64 bool has_hcal_hit = false;
65 int hcal_hit_id = -1;
66 for (const ldmx::SimCalorimeterHit &sim_hit : hcal_sim_hits) {
67 for (int i_contrib = 0; i_contrib < sim_hit.getNumberOfContribs();
68 ++i_contrib) {
69 ldmx::SimCalorimeterHit::Contrib contrib = sim_hit.getContrib(i_contrib);
70
71 if (contrib.track_id_ == recoil_track_id) {
72 has_hcal_hit = true;
73 hcal_hit_id = sim_hit.getID();
74 }
75 }
76 }
77
78 // Loop through the recoil tracker hits_ and count how many
79 // the recoil electron is associated with
80 std::set<int> layers_hit;
81 for (const ldmx::SimTrackerHit &sim_hit : recoil_sim_hits) {
82 if (sim_hit.getTrackID() == recoil_track_id) {
83 // int sensorID = tracking::sim::utils::getSensorID(sim_hit);
84 if ((sim_hit.getTime() < 0.8) && (sim_hit.getMomentum()[2] > 0)) {
85 layers_hit.insert(sim_hit.getLayerID());
86 }
87 }
88 }
89 bool has_min_tracker_hits = false;
90 if (layers_hit.size() >= min_tracker_hits_) {
91 has_min_tracker_hits = true;
92 }
93
94 // Checking if the recoil electron energy is > min energy
95 bool has_min_energy = false;
96 if (recoil_electron->getEnergy() >= min_p_mag_) {
97 has_min_energy = true;
98 }
99
100 // Configure outputs
101 bool is_fiducial = has_min_energy && has_min_tracker_hits && has_ecal_hit;
102
103 int mask_tracker_e = has_min_energy << 0;
104 int mask_tracker_hits = has_min_tracker_hits << 1;
105 int mask_ecal = has_ecal_hit << 2;
106 int mask_hcal = has_hcal_hit << 3;
107 int fiducial_flag =
108 mask_tracker_e | mask_tracker_hits | mask_ecal | mask_hcal;
109
111 flag.setFiducialFlag(fiducial_flag, 6);
112 flag.setAlgoVar(0, recoil_electron->getEnergy());
113 flag.setAlgoVar(1, min_p_mag_);
114 flag.setAlgoVar(2, layers_hit.size());
116 flag.setAlgoVar(4, ecal_hit_id);
117 flag.setAlgoVar(5, hcal_hit_id);
118
119 flag.setIsFiducial(is_fiducial);
120 flag.setHasMinEnergy(has_min_energy);
121 flag.setHasMinTrackerHits(has_min_tracker_hits);
122 flag.setHasEcalHit(has_ecal_hit);
123 flag.setHasHcalHit(has_hcal_hit);
124
125 event.add(output_collection_, flag);
126
127 // Tell the skimmer to keep or drop the event based on whether there
128 // were recoil electron was fiducial.
129
130 if (!inverse_skim_) {
131 if (is_fiducial) {
133 } else {
135 }
136 } else {
137 if (is_fiducial) {
139 } else {
141 }
142 }
143}
std::tuple< int, const ldmx::SimParticle * > getRecoil(const std::map< int, ldmx::SimParticle > &particleMap)
Find and return the sim particle associated with the recoil electron.
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module_.
Holds truth-level fiduciality flags on the signal recoil electron.
void setHasHcalHit(bool has_hcal_hit)
Set hcal hit flag.
void setAlgoVar(int element, double value)
Set an algorithm variable.
void setHasMinTrackerHits(bool has_min_tracker_hits)
Set tracker hit flag.
void setIsFiducial(bool is_fiducial)
Set fiduciality flag.
void setFiducialFlag(int fiducial_flag, int nvar)
Set fiduciality bit mask.
void setHasEcalHit(bool has_ecal_hit)
Set ecal hit flag.
void setHasMinEnergy(bool has_min_energy)
Set recoil min.
Stores simulated calorimeter hit information.
Class representing a simulated particle.
Definition SimParticle.h:23
Represents a simulated tracker hit in the simulation.
constexpr StorageControl::Hint HINT_SHOULD_DROP
storage control hint alias for backwards compatibility
constexpr StorageControl::Hint HINT_SHOULD_KEEP
storage control hint alias for backwards compatibility
Information about a contribution to the hit in the associated cell.
int track_id_
track ID of this contributor

References ecal_collection_, hcal_collection_, framework::HINT_SHOULD_DROP, framework::HINT_SHOULD_KEEP, input_pass_name_, inverse_skim_, min_p_mag_, min_tracker_hits_, output_collection_, recoil_collection_, ldmx::FiducialFlag::setAlgoVar(), ldmx::FiducialFlag::setFiducialFlag(), ldmx::FiducialFlag::setHasEcalHit(), ldmx::FiducialFlag::setHasHcalHit(), ldmx::FiducialFlag::setHasMinEnergy(), ldmx::FiducialFlag::setHasMinTrackerHits(), ldmx::FiducialFlag::setIsFiducial(), framework::EventProcessor::setStorageHint(), and ldmx::SimCalorimeterHit::Contrib::track_id_.

Member Data Documentation

◆ ecal_collection_

std::string recon::RecoilFiducialityProcessor::ecal_collection_
private

The name of the ecal collection.

Definition at line 69 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().

◆ hcal_collection_

std::string recon::RecoilFiducialityProcessor::hcal_collection_
private

The name of the hcal collection.

Definition at line 72 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().

◆ input_pass_name_

std::string recon::RecoilFiducialityProcessor::input_pass_name_
private

The pass name of the input collections.

Definition at line 66 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().

◆ inverse_skim_

bool recon::RecoilFiducialityProcessor::inverse_skim_ {false}
private

Inverse option for skimming.

Definition at line 81 of file RecoilFiducialityProcessor.h.

81{false};

Referenced by configure(), and produce().

◆ min_p_mag_

double recon::RecoilFiducialityProcessor::min_p_mag_
private

Minimum recoil electron momentum at production.

Definition at line 60 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().

◆ min_tracker_hits_

int recon::RecoilFiducialityProcessor::min_tracker_hits_
private

Minimum number of recoil electron hits in the recoil tracker.

Definition at line 63 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().

◆ output_collection_

std::string recon::RecoilFiducialityProcessor::output_collection_
private

The name of the output collection.

Definition at line 78 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().

◆ recoil_collection_

std::string recon::RecoilFiducialityProcessor::recoil_collection_
private

The name of the recoil tracker collection.

Definition at line 75 of file RecoilFiducialityProcessor.h.

Referenced by configure(), and produce().


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