LDMX Software
PFHcalClusterProducer.cxx
2
8#include "TFitResult.h"
9#include "TGraph.h"
10
11namespace recon {
12
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}
26
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 }
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}
74
75} // namespace recon
76
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.
Class that stores cluster information from the ECal.
Class that stores Stores reconstructed hit information from the HCAL.
HCal 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:92
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 HCAL.
Definition HcalHit.h:24
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.