LDMX Software
recon::PileupFinder Class Reference

Public Member Functions

 PileupFinder (const std::string &name, framework::Process &process)
 
virtual void configure (framework::config::Parameters &ps)
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
virtual void produce (framework::Event &event)
 Process the event and put new data products into it.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
- 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.
 
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

std::string rec_hit_coll_name_
 
std::string rec_hit_pass_name_
 
std::string pf_cand_coll_name_
 
std::string pf_cand_pass_name_
 
std::string cluster_coll_name_
 
std::string cluster_pass_name_
 
std::string output_rec_hit_coll_name_
 
double min_mom_ {0.}
 

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

Definition at line 28 of file PileupFinder.h.

Constructor & Destructor Documentation

◆ PileupFinder()

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

Definition at line 30 of file PileupFinder.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::PileupFinder::configure ( framework::config::Parameters & parameters)
virtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 7 of file PileupFinder.cxx.

7 {
8 // I/O
9 rec_hit_coll_name_ = ps.getParameter<std::string>("rec_hit_coll_name");
10 rec_hit_pass_name_ = ps.getParameter<std::string>("rec_hit_pass_name");
11 pf_cand_coll_name_ = ps.getParameter<std::string>("pf_cand_coll_name");
12 pf_cand_pass_name_ = ps.getParameter<std::string>("pf_cand_pass_name");
13 cluster_coll_name_ = ps.getParameter<std::string>("cluster_coll_name");
14 cluster_pass_name_ = ps.getParameter<std::string>("cluster_pass_name");
15 output_rec_hit_coll_name_ =
16 ps.getParameter<std::string>("output_rec_hit_coll_name");
17 // Algorithm configuration
18 min_mom_ = ps.getParameter<double>("min_momentum");
19}

◆ onProcessEnd()

void recon::PileupFinder::onProcessEnd ( )
virtual

Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.

Reimplemented from framework::EventProcessor.

Definition at line 96 of file PileupFinder.cxx.

96 {
97 ldmx_log(debug) << "Process ends!";
98
99 return;
100}

◆ produce()

void recon::PileupFinder::produce ( framework::Event & event)
virtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 22 of file PileupFinder.cxx.

22 {
23 if (!event.exists(rec_hit_coll_name_, rec_hit_pass_name_)) { // ecal rechits
24 ldmx_log(error) << "Unable to find (one) collection named "
25 << rec_hit_coll_name_ << "_" << rec_hit_pass_name_;
26 return;
27 }
28 if (!event.exists(pf_cand_coll_name_, pf_cand_pass_name_)) {
29 ldmx_log(error) << "Unable to find (one) collection named "
30 << pf_cand_coll_name_ << "_" << pf_cand_pass_name_;
31 return;
32 }
33 if (!event.exists(cluster_coll_name_, cluster_pass_name_)) {
34 ldmx_log(error) << "Unable to find (one) collection named "
35 << cluster_coll_name_ << "_" << cluster_pass_name_;
36 return;
37 }
38
39 const auto& ecal_hits{event.getCollection<ldmx::EcalHit>(rec_hit_coll_name_,
40 rec_hit_pass_name_)};
41
42 const auto& pf_cands{event.getCollection<ldmx::PFCandidate>(
43 pf_cand_coll_name_, pf_cand_pass_name_)};
44
45 const auto& clusters{event.getCollection<ldmx::CaloCluster>(
46 cluster_coll_name_, cluster_pass_name_)};
47 // get PID 3 and 7 -- the ones with track and ecal matching
48 // get the high-momentum track ones from there -- pileup candidate!
49 // get the list of hits associated with pileup candidates
50 // if a rechit is not on that list, add to output collection.
51 std::vector<ldmx::EcalHit> output_hits;
52 std::vector<unsigned int> pileup_hit_i_ds;
53
54 // this needs to be a two-step procedure: loop over all clusters deemed to be
55 // pileup to find all their associated hits
56 // then loop over that list to make a collection of output hits that doesn't
57 // contain them
58 for (const auto& pf_cand : pf_cands) {
59 if (pf_cand.getPID() == 3 || pf_cand.getPID() == 7) {
60 // we have both ecal cluster and track
61 std::vector<float> mom_vec = pf_cand.getTrackPxPyPz();
62 float mom = mom_vec[0] * mom_vec[0] + mom_vec[1] * mom_vec[1] +
63 mom_vec[2] * mom_vec[2];
64 mom = sqrt(mom);
65
66 if (mom < min_mom_) continue;
67 ldmx_log(trace) << "Got pileup candidate with PID = " << pf_cand.getPID()
68 << " and momentum = " << mom << " MeV.";
69
70 // now! use the hit-candidate association to get the associated ecal hits.
71 int pf_cl_idx = pf_cand.getEcalIndex();
72 ldmx_log(trace) << "Got Ecal cluster with index " << pf_cl_idx
73 << " while cluster array length is " << clusters.size();
74 if (pf_cl_idx < 0) // was never set
75 continue;
76 auto cl = clusters[pf_cl_idx];
77 auto hit_i_ds = cl.getHitIDs();
78 // add to collection of pileup hits
79 pileup_hit_i_ds.insert(pileup_hit_i_ds.end(), hit_i_ds.begin(),
80 hit_i_ds.end());
81 } // if trk/ecal matched
82 } // over PF objects
83
84 for (auto hit : ecal_hits) {
85 auto found_index = std::find(std::begin(pileup_hit_i_ds),
86 std::end(pileup_hit_i_ds), hit.getID());
87 // When the element is not found, std::find returns the end of the range
88 if (found_index ==
89 std::end(pileup_hit_i_ds)) { // hit not part of any pileup cluster
90 output_hits.emplace_back(hit); // keep it
91 ldmx_log(trace) << "Got no-pileup hit! ";
92 }
93 }
94 event.add(output_rec_hit_coll_name_, output_hits);
95}
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:92
Stores cluster information from the ECal.
Definition CaloCluster.h:26
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
Represents a reconstructed particle.
Definition PFCandidate.h:19

References framework::Event::exists().

Member Data Documentation

◆ cluster_coll_name_

std::string recon::PileupFinder::cluster_coll_name_
private

Definition at line 45 of file PileupFinder.h.

◆ cluster_pass_name_

std::string recon::PileupFinder::cluster_pass_name_
private

Definition at line 46 of file PileupFinder.h.

◆ min_mom_

double recon::PileupFinder::min_mom_ {0.}
private

Definition at line 51 of file PileupFinder.h.

51{0.}; // MeV

◆ output_rec_hit_coll_name_

std::string recon::PileupFinder::output_rec_hit_coll_name_
private

Definition at line 48 of file PileupFinder.h.

◆ pf_cand_coll_name_

std::string recon::PileupFinder::pf_cand_coll_name_
private

Definition at line 43 of file PileupFinder.h.

◆ pf_cand_pass_name_

std::string recon::PileupFinder::pf_cand_pass_name_
private

Definition at line 44 of file PileupFinder.h.

◆ rec_hit_coll_name_

std::string recon::PileupFinder::rec_hit_coll_name_
private

Definition at line 41 of file PileupFinder.h.

◆ rec_hit_pass_name_

std::string recon::PileupFinder::rec_hit_pass_name_
private

Definition at line 42 of file PileupFinder.h.


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