LDMX Software
HcalClusterProducer.cxx
2
3#include <exception>
4#include <iostream>
5
6#include "Hcal/MyClusterWeight.h"
7#include "Hcal/TemplatedClusterFinder.h"
8#include "Hcal/WorkingCluster.h"
9#include "TFile.h"
10#include "TString.h"
11#include "TTree.h"
12
13namespace hcal {
14
15HcalClusterProducer::HcalClusterProducer(const std::string& name,
16 framework::Process& process)
17 : Producer(name, process) {}
18
19void HcalClusterProducer::configure(framework::config::Parameters& parameters) {
20 enoise_cut_ = parameters.get<double>("EnoiseCut");
21 delta_time_ = parameters.get<double>("deltaTime");
22 delta_r_ = parameters.get<double>("deltaR");
23 emin_cluster_ = parameters.get<double>("EminCluster");
24 cut_off_ = parameters.get<double>("cutOff");
25
26 cluster_coll_name_ = parameters.get<std::string>("clusterCollName");
27 hcal_hits_pass_name_ = parameters.get<std::string>("hcal_hits_pass_name");
28}
29
30static bool compHitTimes(const ldmx::HcalHit* a, const ldmx::HcalHit* b) {
31 return a->getTime() < b->getTime();
32}
33
34void HcalClusterProducer::produce(framework::Event& event) {
35 const ldmx::HcalGeometry& hcal_geom = getCondition<ldmx::HcalGeometry>(
37
39
40 std::vector<ldmx::HcalCluster> hcal_clusters;
41 std::list<const ldmx::HcalHit*> seed_list;
42 std::vector<ldmx::HcalHit> hcal_hits =
43 event.getCollection<ldmx::HcalHit>("HcalRecHits", hcal_hits_pass_name_);
44
45 if (hcal_hits.empty()) {
46 return;
47 }
48
49 for (ldmx::HcalHit& hit : hcal_hits) {
50 if (hit.getEnergy() < enoise_cut_) continue;
51 if (hit.getEnergy() == 0) continue;
52 finder.add(&hit, hcal_geom);
53 }
54
55 // seedList.sort([](const ldmx::HcalHit* a, const ldmx::HcalHit* b) {return
56 // a->getEnergy() > b->getEnergy();});
57 finder.cluster(emin_cluster_, cut_off_, delta_time_);
58
59 std::vector<WorkingCluster> wc_vec = finder.getClusters();
60 for (unsigned int c = 0; c < wc_vec.size(); c++) {
61 if (wc_vec[c].empty()) continue;
62 ldmx::HcalCluster cluster;
63 cluster.setEnergy(wc_vec[c].centroid().E());
64 cluster.setCentroidXYZ(wc_vec[c].centroid().Px(), wc_vec[c].centroid().Py(),
65 wc_vec[c].centroid().Pz());
66 cluster.setNHits(wc_vec[c].getHits().size());
67 cluster.addHits(wc_vec[c].getHits());
68 std::vector<const ldmx::HcalHit*> hits = wc_vec[c].getHits();
69 if (hits.size() > 0) {
70 std::sort(hits.begin(), hits.end(), compHitTimes);
71 cluster.setTime(hits[0]->getTime());
72 }
73 hcal_clusters.push_back(cluster);
74 }
75 event.add(cluster_coll_name_, hcal_clusters);
76}
77
78} // 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_.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:36
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.
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