LDMX Software
HcalClusterProducer.cxx
2
3#include <exception>
4#include <iostream>
5
8#include "TFile.h"
9#include "TString.h"
10#include "TTree.h"
11
12namespace hcal {
13
14HcalClusterProducer::HcalClusterProducer(const std::string& name,
15 framework::Process& process)
16 : Producer(name, process) {}
17
18void HcalClusterProducer::configure(framework::config::Parameters& parameters) {
19 enoise_cut_ = parameters.get<double>("enoise_cut");
20 delta_time_ = parameters.get<double>("delta_time");
21 delta_r_ = parameters.get<double>("delta_r");
22 emin_cluster_ = parameters.get<double>("emin_cluster");
23 cut_off_ = parameters.get<double>("cut_off");
24
25 cluster_coll_name_ = parameters.get<std::string>("cluster_coll_name");
26 hcal_hits_pass_name_ = parameters.get<std::string>("hcal_hits_pass_name");
27}
28
29static bool compHitTimes(const ldmx::HcalHit* a, const ldmx::HcalHit* b) {
30 return a->getTime() < b->getTime();
31}
32
33void HcalClusterProducer::produce(framework::Event& event) {
34 const ldmx::HcalGeometry& hcal_geom = getCondition<ldmx::HcalGeometry>(
36
38
39 std::vector<ldmx::HcalCluster> hcal_clusters;
40 std::list<const ldmx::HcalHit*> seed_list;
41 std::vector<ldmx::HcalHit> hcal_hits =
42 event.getCollection<ldmx::HcalHit>("HcalRecHits", hcal_hits_pass_name_);
43
44 if (hcal_hits.empty()) {
45 return;
46 }
47
48 for (ldmx::HcalHit& hit : hcal_hits) {
49 if (hit.getEnergy() < enoise_cut_) continue;
50 if (hit.getEnergy() == 0) continue;
51 auto pos = hcal_geom.getStripCenterPosition(hit.getID());
52 finder.add(&hit, pos.x(), pos.y(), pos.z());
53 }
54
55 finder.cluster(emin_cluster_, cut_off_);
56
57 auto wc_vec = finder.getClusters();
58 for (size_t c = 0; c < wc_vec.size(); c++) {
59 if (wc_vec[c].empty()) continue;
60 ldmx::HcalCluster cluster;
61 cluster.setEnergy(wc_vec[c].energy());
62 cluster.setCentroidXYZ(wc_vec[c].centroidX(), wc_vec[c].centroidY(),
63 wc_vec[c].centroidZ());
64 cluster.setNHits(wc_vec[c].hits().size());
65 cluster.addHits(wc_vec[c].hits());
66 auto hits = wc_vec[c].hits();
67 if (hits.size() > 0) {
68 std::sort(hits.begin(), hits.end(), compHitTimes);
69 cluster.setTime(hits[0]->getTime());
70 }
71 hcal_clusters.push_back(cluster);
72 }
73 event.add(cluster_coll_name_, hcal_clusters);
74}
75
76} // namespace hcal
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that performs clustering of HCal hits_.
Weight function for Hcal cluster merging decisions.
Templated clustering algorithm for calorimeter hits.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:37
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
Make clusters from hits in the HCAL.
void setNHits(int nHits)
Sets total number of hits in the cluster.
Definition CaloCluster.h:65
void setCentroidXYZ(double centroid_x, double centroid_y, double centroid_z)
Sets the three coordinates of the cluster centroid.
Definition CaloCluster.h:85
void setEnergy(double energy)
Sets total energy for the cluster.
Definition CaloCluster.h:59
float getTime() const
Get the time of the hit [ns].
Stores cluster information from the HCal.
Definition HcalCluster.h:21
void addHits(const std::vector< const ldmx::HcalHit * > hitsVec)
Take in the hits that make up the cluster.
Implementation of HCal strip readout.
ROOT::Math::XYZVector getStripCenterPosition(ldmx::HcalID id) const
Get a strip center position from a combined hcal ID.
static constexpr const char * CONDITIONS_OBJECT_NAME
Conditions object: The name of the python configuration calling this class (Hcal/python/HcalGeometry....
Stores reconstructed hit information from the HCAL.
Definition HcalHit.h:24
A templated agglomerative clustering algorithm.
void cluster(double seed_threshold, double cutoff)
Run the clustering algorithm.
std::vector< ClusterType > getClusters() const
Get the final clusters after filtering by seed threshold.
void add(const HitType &hit)
Add a hit to be clustered using its stored position.