LDMX Software
PFEcalClusterProducer.cxx
2
6
7namespace recon {
8
10 hitCollName_ = ps.getParameter<std::string>("hitCollName");
11 clusterCollName_ = ps.getParameter<std::string>("clusterCollName");
12 suffix_ = ps.getParameter<std::string>("suffix", "");
13 singleCluster_ = ps.getParameter<bool>("doSingleCluster");
14 logEnergyWeight_ = ps.getParameter<bool>("logEnergyWeight");
15 // DBScan parameters
16 minClusterHitMult_ = ps.getParameter<int>("minClusterHitMult");
17 clusterHitDist_ = ps.getParameter<double>("clusterHitDist");
18 clusterZBias_ = ps.getParameter<double>("clusterZBias", 1);
19 minHitEnergy_ = ps.getParameter<double>("minHitEnergy");
20}
21
23 if (!event.exists(hitCollName_)) return;
24 const auto ecalRecHits = event.getCollection<ldmx::EcalHit>(hitCollName_);
25
26 float eTotal = 0;
27 for (const auto& h : ecalRecHits) eTotal += h.getEnergy();
28
29 std::vector<ldmx::CaloCluster> pfClusters;
30 if (!singleCluster_) {
31 DBScanClusterBuilder cb(minHitEnergy_, clusterHitDist_, clusterZBias_,
32 minClusterHitMult_);
33 std::vector<const ldmx::CalorimeterHit*> ptrs;
34 for (const auto& h : ecalRecHits) ptrs.push_back(&h);
35 std::vector<std::vector<const ldmx::CalorimeterHit*> > all_hit_ptrs =
36 cb.runDBSCAN(ptrs, false);
37
38 for (const auto& hit_ptrs : all_hit_ptrs) {
40 cb.fillClusterInfoFromHits(&cl, hit_ptrs, logEnergyWeight_);
41 pfClusters.push_back(cl);
42 }
43 } else { // create a single, large cluster
44
46 std::vector<const ldmx::CalorimeterHit*> ptrs;
47 ptrs.reserve(ecalRecHits.size());
48 for (const auto& h : ecalRecHits) {
49 ptrs.push_back(&h);
50 }
52 dummy.fillClusterInfoFromHits(&cl, ptrs, logEnergyWeight_);
53 pfClusters.push_back(cl);
54 }
55
56 std::sort(pfClusters.begin(), pfClusters.end(),
58 return a.getEnergy() > b.getEnergy();
59 });
60 event.add(clusterCollName_, pfClusters);
61 event.add("EcalTotalEnergy" + suffix_, eTotal);
62}
63
64} // namespace recon
65
66DECLARE_PRODUCER_NS(recon, PFEcalClusterProducer);
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.
ECal 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 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.