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