LDMX Software
PFEcalClusterProducer.cxx
2
3#include "Ecal/Event/EcalHit.h"
7
8namespace recon {
9
11 hit_coll_name_ = ps.get<std::string>("hit_coll_name");
12 hit_pass_name_ = ps.get<std::string>("hit_pass_name");
13 cluster_coll_name_ = ps.get<std::string>("cluster_coll_name");
14 suffix_ = ps.get<std::string>("suffix", "");
15 single_cluster_ = ps.get<bool>("do_single_cluster");
16 log_energy_weight_ = ps.get<bool>("log_energy_weight");
17 // DBScan parameters
18 min_cluster_hit_mult_ = ps.get<int>("min_cluster_hit_mult");
19 cluster_hit_dist_ = ps.get<double>("cluster_hit_dist");
20 cluster_z_bias_ = ps.get<double>("cluster_z_bias", 1);
21 min_hit_energy_ = ps.get<double>("min_hit_energy");
22 save_hit_contribs_ = ps.get<bool>("save_hit_contribs", true);
23}
24
26 if (!event.exists(hit_coll_name_, hit_pass_name_)) {
27 ldmx_log(fatal) << "Couldn't find input collection " << hit_coll_name_
28 << " with pass name " << hit_pass_name_;
29 return;
30 }
31 const auto ecal_rec_hits =
32 event.getCollection<ldmx::EcalHit>(hit_coll_name_, hit_pass_name_);
33
34 float e_total = 0;
35 for (const auto& h : ecal_rec_hits) e_total += h.getEnergy();
36
37 std::vector<ldmx::CaloCluster> pf_clusters;
38 if (!single_cluster_) {
39 DBScanClusterBuilder cb(min_hit_energy_, cluster_hit_dist_, cluster_z_bias_,
40 min_cluster_hit_mult_);
41 std::vector<const ldmx::CalorimeterHit*> ptrs;
42 for (const auto& h : ecal_rec_hits) ptrs.push_back(&h);
43 std::vector<std::vector<const ldmx::CalorimeterHit*> > all_hit_ptrs =
44 cb.runDBSCAN(ptrs);
45
46 for (const auto& hit_ptrs : all_hit_ptrs) {
48 cb.fillClusterInfoFromHits(&cl, hit_ptrs, log_energy_weight_,
49 save_hit_contribs_);
50 pf_clusters.push_back(cl);
51 }
52 } else { // create a single, large cluster
53
55 std::vector<const ldmx::CalorimeterHit*> ptrs;
56 ptrs.reserve(ecal_rec_hits.size());
57 for (const auto& h : ecal_rec_hits) {
58 ptrs.push_back(&h);
59 }
61 dummy.fillClusterInfoFromHits(&cl, ptrs, log_energy_weight_,
62 save_hit_contribs_);
63 pf_clusters.push_back(cl);
64 }
65
66 std::sort(pf_clusters.begin(), pf_clusters.end(),
68 return a.getEnergy() > b.getEnergy();
69 });
70 event.add(cluster_coll_name_, pf_clusters);
71 event.add("EcalTotalEnergy" + suffix_, e_total);
72}
73
74} // namespace recon
75
Class that stores calorimeter cluster information.
Class that represents a reconstructed hit in a calorimeter cell within the detector.
Implementation of DBSCAN clustering algo.
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
ECal clustering skeleton for PFlow Reco.
Implements an event buffer system for storing event data.
Definition Event.h:40
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:107
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:26
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:75
Stores cluster information from the ECal.
Definition CaloCluster.h:25
float getEnergy() const
Get the calorimetric energy of the hit, corrected for sampling factors [MeV].
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19
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.