LDMX Software
PFEcalClusterProducer.cxx
2
6
7namespace recon {
8
10 hit_coll_name_ = ps.get<std::string>("hit_coll_name");
11 hit_pass_name_ = ps.get<std::string>("hit_pass_name");
12 cluster_coll_name_ = ps.get<std::string>("cluster_coll_name");
13 suffix_ = ps.get<std::string>("suffix", "");
14 single_cluster_ = ps.get<bool>("do_single_cluster");
15 log_energy_weight_ = ps.get<bool>("log_energy_weight");
16 // DBScan parameters
17 min_cluster_hit_mult_ = ps.get<int>("min_cluster_hit_mult");
18 cluster_hit_dist_ = ps.get<double>("cluster_hit_dist");
19 cluster_z_bias_ = ps.get<double>("cluster_z_bias", 1);
20 min_hit_energy_ = ps.get<double>("min_hit_energy");
21 save_hit_contribs_ = ps.get<bool>("save_hit_contribs", true);
22}
23
25 if (!event.exists(hit_coll_name_, hit_pass_name_)) {
26 ldmx_log(fatal) << "Couldn't find input collection " << hit_coll_name_
27 << " with pass name " << hit_pass_name_;
28 return;
29 }
30 const auto ecal_rec_hits =
31 event.getCollection<ldmx::EcalHit>(hit_coll_name_, hit_pass_name_);
32
33 float e_total = 0;
34 for (const auto& h : ecal_rec_hits) e_total += h.getEnergy();
35
36 std::vector<ldmx::CaloCluster> pf_clusters;
37 if (!single_cluster_) {
38 DBScanClusterBuilder cb(min_hit_energy_, cluster_hit_dist_, cluster_z_bias_,
39 min_cluster_hit_mult_);
40 std::vector<const ldmx::CalorimeterHit*> ptrs;
41 for (const auto& h : ecal_rec_hits) ptrs.push_back(&h);
42 std::vector<std::vector<const ldmx::CalorimeterHit*> > all_hit_ptrs =
43 cb.runDBSCAN(ptrs);
44
45 for (const auto& hit_ptrs : all_hit_ptrs) {
47 cb.fillClusterInfoFromHits(&cl, hit_ptrs, log_energy_weight_,
48 save_hit_contribs_);
49 pf_clusters.push_back(cl);
50 }
51 } else { // create a single, large cluster
52
54 std::vector<const ldmx::CalorimeterHit*> ptrs;
55 ptrs.reserve(ecal_rec_hits.size());
56 for (const auto& h : ecal_rec_hits) {
57 ptrs.push_back(&h);
58 }
60 dummy.fillClusterInfoFromHits(&cl, ptrs, log_energy_weight_,
61 save_hit_contribs_);
62 pf_clusters.push_back(cl);
63 }
64
65 std::sort(pf_clusters.begin(), pf_clusters.end(),
67 return a.getEnergy() > b.getEnergy();
68 });
69 event.add(cluster_coll_name_, pf_clusters);
70 event.add("EcalTotalEnergy" + suffix_, e_total);
71}
72
73} // namespace recon
74
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:42
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:105
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
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 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.