LDMX Software
PFEcalClusterProducer.cxx
2
6
7namespace recon {
8
10 hit_coll_name_ = ps.get<std::string>("hitCollName");
11 hit_pass_name_ = ps.get<std::string>("hitPassName");
12 cluster_coll_name_ = ps.get<std::string>("clusterCollName");
13 suffix_ = ps.get<std::string>("suffix", "");
14 single_cluster_ = ps.get<bool>("doSingleCluster");
15 log_energy_weight_ = ps.get<bool>("logEnergyWeight");
16 // DBScan parameters
17 min_cluster_hit_mult_ = ps.get<int>("minClusterHitMult");
18 cluster_hit_dist_ = ps.get<double>("clusterHitDist");
19 cluster_z_bias_ = ps.get<double>("clusterZBias", 1);
20 min_hit_energy_ = ps.get<double>("minHitEnergy");
21}
22
24 if (!event.exists(hit_coll_name_, hit_pass_name_)) {
25 ldmx_log(fatal) << "Couldn't find input collection " << hit_coll_name_
26 << " with pass name " << hit_pass_name_;
27 return;
28 }
29 const auto ecal_rec_hits =
30 event.getCollection<ldmx::EcalHit>(hit_coll_name_, hit_pass_name_);
31
32 float e_total = 0;
33 for (const auto& h : ecal_rec_hits) e_total += h.getEnergy();
34
35 std::vector<ldmx::CaloCluster> pf_clusters;
36 if (!single_cluster_) {
37 DBScanClusterBuilder cb(min_hit_energy_, cluster_hit_dist_, cluster_z_bias_,
38 min_cluster_hit_mult_);
39 std::vector<const ldmx::CalorimeterHit*> ptrs;
40 for (const auto& h : ecal_rec_hits) ptrs.push_back(&h);
41 std::vector<std::vector<const ldmx::CalorimeterHit*> > all_hit_ptrs =
42 cb.runDBSCAN(ptrs);
43
44 for (const auto& hit_ptrs : all_hit_ptrs) {
46 cb.fillClusterInfoFromHits(&cl, hit_ptrs, log_energy_weight_);
47 pf_clusters.push_back(cl);
48 }
49 } else { // create a single, large cluster
50
52 std::vector<const ldmx::CalorimeterHit*> ptrs;
53 ptrs.reserve(ecal_rec_hits.size());
54 for (const auto& h : ecal_rec_hits) {
55 ptrs.push_back(&h);
56 }
58 dummy.fillClusterInfoFromHits(&cl, ptrs, log_energy_weight_);
59 pf_clusters.push_back(cl);
60 }
61
62 std::sort(pf_clusters.begin(), pf_clusters.end(),
64 return a.getEnergy() > b.getEnergy();
65 });
66 event.add(cluster_coll_name_, pf_clusters);
67 event.add("EcalTotalEnergy" + suffix_, e_total);
68}
69
70} // namespace recon
71
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: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 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.