LDMX Software
PFHcalClusterProducer.cxx
2
8#include "TFitResult.h"
9#include "TGraph.h"
10
11namespace recon {
12
14 hitCollName_ = ps.getParameter<std::string>("hitCollName");
15 clusterCollName_ = ps.getParameter<std::string>("clusterCollName");
16 suffix_ = ps.getParameter<std::string>("suffix", "");
17 singleCluster_ = ps.getParameter<bool>("doSingleCluster");
18 logEnergyWeight_ = ps.getParameter<bool>("logEnergyWeight");
19 // DBScan parameters
20 minClusterHitMult_ = ps.getParameter<int>("minClusterHitMult");
21 clusterHitDist_ = ps.getParameter<double>("clusterHitDist");
22 clusterZBias_ = ps.getParameter<double>("clusterZBias", 1);
23 minHitEnergy_ = ps.getParameter<double>("minHitEnergy");
24}
25
27 if (!event.exists(hitCollName_)) return;
28 const auto hcalRecHits = event.getCollection<ldmx::HcalHit>(hitCollName_);
29 float eTotal = 0;
30 for (const auto& h : hcalRecHits) eTotal += h.getEnergy();
31
32 std::vector<ldmx::CaloCluster> pfClusters;
33 if (!singleCluster_) {
34 // construct DBScan
35 DBScanClusterBuilder cb(minHitEnergy_, clusterHitDist_, clusterZBias_,
36 minClusterHitMult_);
37 std::vector<const ldmx::CalorimeterHit*> ptrs;
38 for (const auto& h : hcalRecHits) ptrs.push_back(&h);
39 std::vector<std::vector<const ldmx::CalorimeterHit*> > all_hit_ptrs =
40 cb.runDBSCAN(ptrs, false);
41
42 for (const auto& hit_ptrs : all_hit_ptrs) {
44 cb.fillClusterInfoFromHits(&cl, hit_ptrs, logEnergyWeight_);
45 pfClusters.push_back(cl);
46 }
47
48 } else {
50 std::vector<const ldmx::CalorimeterHit*> ptrs;
51 ptrs.reserve(hcalRecHits.size());
52 for (const auto& h : hcalRecHits) {
53 ptrs.push_back(&h);
54 }
56 dummy.fillClusterInfoFromHits(&cl, ptrs, logEnergyWeight_);
57 pfClusters.push_back(cl);
58 }
59
60 // sort
61 std::sort(pfClusters.begin(), pfClusters.end(),
63 return a.getEnergy() > b.getEnergy();
64 });
65 event.add(clusterCollName_, pfClusters);
66 event.add("HcalTotalEnergy" + suffix_, eTotal);
67}
68
69} // namespace recon
70
71DECLARE_PRODUCER_NS(recon, PFHcalClusterProducer);
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_NS(NS, 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:41
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:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
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:23
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.