LDMX Software
EcalClusterProducer.cxx
Go to the documentation of this file.
1
8
9namespace ecal {
10
11EcalClusterProducer::EcalClusterProducer(const std::string& name,
12 framework::Process& process)
13 : Producer(name, process) {}
14
15EcalClusterProducer::~EcalClusterProducer() {}
16
17void EcalClusterProducer::configure(framework::config::Parameters& parameters) {
18 cutoff_ = parameters.getParameter<double>("cutoff");
19 seedThreshold_ = parameters.getParameter<double>("seedThreshold");
20 digisPassName_ = parameters.getParameter<std::string>("digisPassName");
21 algoCollName_ = parameters.getParameter<std::string>("algoCollName");
22 algoName_ = parameters.getParameter<std::string>("algoName");
23 clusterCollName_ = parameters.getParameter<std::string>("clusterCollName");
24}
25
26void EcalClusterProducer::produce(framework::Event& event) {
27 // Get the Ecal Geometry
28 const auto& geometry = getCondition<ldmx::EcalGeometry>(
29 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
30
32
33 std::vector<ldmx::EcalHit> ecalHits =
34 event.getCollection<ldmx::EcalHit>("ecalDigis", digisPassName_);
35 int nEcalDigis = ecalHits.size();
36
37 // Don't do anything if there are no ECal digis!
38 if (!(nEcalDigis > 0)) {
39 return;
40 }
41
42 for (ldmx::EcalHit& hit : ecalHits) {
43 // Skip zero energy digis.
44 if (hit.getEnergy() == 0) {
45 continue;
46 }
47
48 cf.add(&hit, geometry);
49 }
50
51 cf.cluster(seedThreshold_, cutoff_);
52 std::vector<WorkingCluster> wcVec = cf.getClusters();
53
54 std::map<int, double> cWeights = cf.getWeights();
55
56 ldmx::ClusterAlgoResult algoResult;
57 algoResult.set(algoName_, 3, cWeights.rbegin()->first);
58 algoResult.setAlgoVar(0, cutoff_);
59 algoResult.setAlgoVar(1, seedThreshold_);
60 algoResult.setAlgoVar(2, cf.getNSeeds());
61
62 std::map<int, double>::iterator it = cWeights.begin();
63 for (it = cWeights.begin(); it != cWeights.end(); it++) {
64 algoResult.setWeight(it->first, it->second / 100);
65 }
66
67 std::vector<ldmx::EcalCluster> ecalClusters;
68 for (int aWC = 0; aWC < wcVec.size(); aWC++) {
69 ldmx::EcalCluster cluster;
70
71 cluster.setEnergy(wcVec[aWC].centroid().E());
72 cluster.setCentroidXYZ(wcVec[aWC].centroid().Px(),
73 wcVec[aWC].centroid().Py(),
74 wcVec[aWC].centroid().Pz());
75 cluster.setNHits(wcVec[aWC].getHits().size());
76 cluster.addHits(wcVec[aWC].getHits());
77
78 ecalClusters.push_back(cluster);
79 }
80
81 event.add(clusterCollName_, ecalClusters);
82 event.add(algoCollName_, algoResult);
83}
84} // namespace ecal
85
86DECLARE_PRODUCER_NS(ecal, EcalClusterProducer);
Simple algorithm that does clustering in the ECal.
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
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
Contains details about the clustering algorithm.
void setAlgoVar(int element, double value)
Set an algorithm variable.
void set(const TString &name, int nvar)
Set name and number of variables of cluster algo.
void setWeight(int nClusters, double weight)
Set a weight when number of clusters reached.
Stores cluster information from the ECal.
Definition EcalCluster.h:20
void addHits(const std::vector< const ldmx::EcalHit * > hitsVec)
Take in the hits that make up the cluster.
Stores reconstructed hit information from the ECAL.
Definition EcalHit.h:19