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 EnoiseCut_ = parameters.getParameter<double>("EnoiseCut");
21 deltaTime_ = parameters.getParameter<double>("deltaTime");
22 deltaR_ = parameters.getParameter<double>("deltaR");
23 EminCluster_ = parameters.getParameter<double>("EminCluster");
24 cutOff_ = parameters.getParameter<double>("cutOff");
25
26 clusterCollName_ = parameters.getParameter<std::string>("clusterCollName");
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& hcalGeom = getCondition<ldmx::HcalGeometry>(
36
38
39 std::vector<ldmx::HcalCluster> hcalClusters;
40 std::list<const ldmx::HcalHit*> seedList;
41 std::vector<ldmx::HcalHit> hcalHits =
42 event.getCollection<ldmx::HcalHit>("HcalRecHits");
43
44 if (hcalHits.empty()) {
45 return;
46 }
47
48 for (ldmx::HcalHit& hit : hcalHits) {
49 if (hit.getEnergy() < EnoiseCut_) continue;
50 if (hit.getEnergy() == 0) continue;
51 finder.add(&hit, hcalGeom);
52 }
53
54 // seedList.sort([](const ldmx::HcalHit* a, const ldmx::HcalHit* b) {return
55 // a->getEnergy() > b->getEnergy();});
56 finder.cluster(EminCluster_, cutOff_, deltaTime_);
57
58 std::vector<WorkingCluster> wcVec = finder.getClusters();
59 for (unsigned int c = 0; c < wcVec.size(); c++) {
60 if (wcVec[c].empty()) continue;
61 ldmx::HcalCluster cluster;
62 cluster.setEnergy(wcVec[c].centroid().E());
63 cluster.setCentroidXYZ(wcVec[c].centroid().Px(), wcVec[c].centroid().Py(),
64 wcVec[c].centroid().Pz());
65 cluster.setNHits(wcVec[c].getHits().size());
66 cluster.addHits(wcVec[c].getHits());
67 std::vector<const ldmx::HcalHit*> hits = wcVec[c].getHits();
68 if (hits.size() > 0) {
69 std::sort(hits.begin(), hits.end(), compHitTimes);
70 cluster.setTime(hits[0]->getTime());
71 }
72 hcalClusters.push_back(cluster);
73 }
74 event.add(clusterCollName_, hcalClusters);
75}
76
77} // namespace hcal
78DECLARE_PRODUCER_NS(hcal, HcalClusterProducer);
#define DECLARE_PRODUCER_NS(NS, 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:41
Class which represents the process under execution.
Definition Process.h:36
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
void setNHits(int nHits)
Sets total number of hits in the cluster.
Definition CaloCluster.h:65
void setEnergy(double energy)
Sets total energy for the cluster.
Definition CaloCluster.h:59
void setCentroidXYZ(double x, double y, double z)
Sets the three coordinates of the cluster centroid.
Definition CaloCluster.h:85
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:23