11EcalClusterProducer::EcalClusterProducer(
const std::string& name,
13 : Producer(name, process) {}
15EcalClusterProducer::~EcalClusterProducer() {}
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");
28 const auto& geometry = getCondition<ldmx::EcalGeometry>(
29 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
33 std::vector<ldmx::EcalHit> ecalHits =
34 event.getCollection<
ldmx::EcalHit>(
"ecalDigis", digisPassName_);
35 int nEcalDigis = ecalHits.size();
38 if (!(nEcalDigis > 0)) {
44 if (hit.getEnergy() == 0) {
48 cf.add(&hit, geometry);
51 cf.cluster(seedThreshold_, cutoff_);
52 std::vector<WorkingCluster> wcVec = cf.getClusters();
54 std::map<int, double> cWeights = cf.getWeights();
57 algoResult.
set(algoName_, 3, cWeights.rbegin()->first);
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);
67 std::vector<ldmx::EcalCluster> ecalClusters;
68 for (
int aWC = 0; aWC < wcVec.size(); aWC++) {
71 cluster.
setEnergy(wcVec[aWC].centroid().E());
73 wcVec[aWC].centroid().Py(),
74 wcVec[aWC].centroid().Pz());
75 cluster.
setNHits(wcVec[aWC].getHits().size());
76 cluster.
addHits(wcVec[aWC].getHits());
78 ecalClusters.push_back(cluster);
81 event.add(clusterCollName_, ecalClusters);
82 event.add(algoCollName_, algoResult);
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.
Class which represents the process under execution.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
void setNHits(int nHits)
Sets total number of hits in the cluster.
void setEnergy(double energy)
Sets total energy for the cluster.
void setCentroidXYZ(double x, double y, double z)
Sets the three coordinates of the cluster centroid.
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.
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.