LDMX Software
recon::PFHcalClusterProducer Class Reference

Public Member Functions

 PFHcalClusterProducer (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.
 
- 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

bool single_cluster_ {true}
 
bool log_energy_weight_ {true}
 
float min_hit_energy_ {0}
 
float cluster_hit_dist_ {100.}
 
float cluster_z_bias_ {1.}
 
int min_cluster_hit_mult_ {2}
 
std::string hit_coll_name_
 
std::string hit_pass_name_
 
std::string cluster_coll_name_
 
std::string suffix_
 

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 21 of file PFHcalClusterProducer.h.

Constructor & Destructor Documentation

◆ PFHcalClusterProducer()

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

Definition at line 23 of file PFHcalClusterProducer.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::PFHcalClusterProducer::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 13 of file PFHcalClusterProducer.cxx.

13 {
14 hit_coll_name_ = ps.get<std::string>("hitCollName");
15 hit_pass_name_ = ps.get<std::string>("hitPassName");
16 cluster_coll_name_ = ps.get<std::string>("clusterCollName");
17 suffix_ = ps.get<std::string>("suffix", "");
18 single_cluster_ = ps.get<bool>("doSingleCluster");
19 log_energy_weight_ = ps.get<bool>("logEnergyWeight");
20 // DBScan parameters
21 min_cluster_hit_mult_ = ps.get<int>("minClusterHitMult");
22 cluster_hit_dist_ = ps.get<double>("clusterHitDist");
23 cluster_z_bias_ = ps.get<double>("clusterZBias", 1);
24 min_hit_energy_ = ps.get<double>("minHitEnergy");
25}

References framework::config::Parameters::get().

◆ produce()

void recon::PFHcalClusterProducer::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 27 of file PFHcalClusterProducer.cxx.

27 {
28 if (!event.exists(hit_coll_name_, hit_pass_name_)) {
29 ldmx_log(fatal) << "Couldn't find input collection " << hit_coll_name_
30 << "_" << hit_pass_name_;
31 return;
32 }
33 const auto hcal_rec_hits =
34 event.getCollection<ldmx::HcalHit>(hit_coll_name_, hit_pass_name_);
35 float e_total = 0;
36 for (const auto& h : hcal_rec_hits) e_total += h.getEnergy();
37
38 std::vector<ldmx::CaloCluster> pf_clusters;
39 if (!single_cluster_) {
40 // construct DBScan
41 DBScanClusterBuilder cb(min_hit_energy_, cluster_hit_dist_, cluster_z_bias_,
42 min_cluster_hit_mult_);
43 std::vector<const ldmx::CalorimeterHit*> ptrs;
44 for (const auto& h : hcal_rec_hits) ptrs.push_back(&h);
45 std::vector<std::vector<const ldmx::CalorimeterHit*> > all_hit_ptrs =
46 cb.runDBSCAN(ptrs);
47
48 for (const auto& hit_ptrs : all_hit_ptrs) {
50 cb.fillClusterInfoFromHits(&cl, hit_ptrs, log_energy_weight_);
51 pf_clusters.push_back(cl);
52 }
53
54 } else {
56 std::vector<const ldmx::CalorimeterHit*> ptrs;
57 ptrs.reserve(hcal_rec_hits.size());
58 for (const auto& h : hcal_rec_hits) {
59 ptrs.push_back(&h);
60 }
61 DBScanClusterBuilder dummy;
62 dummy.fillClusterInfoFromHits(&cl, ptrs, log_energy_weight_);
63 pf_clusters.push_back(cl);
64 }
65
66 // sort
67 std::sort(pf_clusters.begin(), pf_clusters.end(),
69 return a.getEnergy() > b.getEnergy();
70 });
71 event.add(cluster_coll_name_, pf_clusters);
72 event.add("HcalTotalEnergy" + suffix_, e_total);
73}
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
float getEnergy() const
Get the calorimetric energy of the hit, corrected for sampling factors [MeV].
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:24

References framework::Event::exists(), and ldmx::CalorimeterHit::getEnergy().

Member Data Documentation

◆ cluster_coll_name_

std::string recon::PFHcalClusterProducer::cluster_coll_name_
private

Definition at line 44 of file PFHcalClusterProducer.h.

◆ cluster_hit_dist_

float recon::PFHcalClusterProducer::cluster_hit_dist_ {100.}
private

Definition at line 35 of file PFHcalClusterProducer.h.

35{100.};

◆ cluster_z_bias_

float recon::PFHcalClusterProducer::cluster_z_bias_ {1.}
private

Definition at line 36 of file PFHcalClusterProducer.h.

36{1.}; // private parameter for z_ bias

◆ hit_coll_name_

std::string recon::PFHcalClusterProducer::hit_coll_name_
private

Definition at line 40 of file PFHcalClusterProducer.h.

◆ hit_pass_name_

std::string recon::PFHcalClusterProducer::hit_pass_name_
private

Definition at line 42 of file PFHcalClusterProducer.h.

◆ log_energy_weight_

bool recon::PFHcalClusterProducer::log_energy_weight_ {true}
private

Definition at line 32 of file PFHcalClusterProducer.h.

32{true};

◆ min_cluster_hit_mult_

int recon::PFHcalClusterProducer::min_cluster_hit_mult_ {2}
private

Definition at line 37 of file PFHcalClusterProducer.h.

37{2};

◆ min_hit_energy_

float recon::PFHcalClusterProducer::min_hit_energy_ {0}
private

Definition at line 34 of file PFHcalClusterProducer.h.

34{0};

◆ single_cluster_

bool recon::PFHcalClusterProducer::single_cluster_ {true}
private

Definition at line 31 of file PFHcalClusterProducer.h.

31{true};

◆ suffix_

std::string recon::PFHcalClusterProducer::suffix_
private

Definition at line 45 of file PFHcalClusterProducer.h.


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