10#include <klm/modules/KLMClustersReconstructor/KLMClustersReconstructorModule.h>
13#include <klm/dataobjects/bklm/BKLMElementNumbers.h>
14#include <klm/dataobjects/eklm/EKLMElementNumbers.h>
17#include <Math/VectorUtil.h>
27 m_PositionMode(c_FirstLayer),
28 m_ClusterMode(c_AnyHit)
30 setDescription(
"Unified BKLM/EKLM module for the reconstruction of KLMClusters.");
35 "Vertex position calculation mode ('FullAverage' or 'FirstLayer').",
36 std::string(
"FirstLayer"));
38 "Clusterization mode ('AnyHit' or 'FirstHit').",
39 std::string(
"AnyHit"));
56 B2FATAL(
"Incorrect PositionMode argument.");
62 B2FATAL(
"Incorrect ClusterMode argument.");
77 int i, nLayers, innermostLayer, nHits;
80 int* layerHitsBKLM, *layerHitsEKLM;
83 std::vector<KLMHit2d*> klmHit2ds, klmClusterHits;
84 std::vector<KLMHit2d*>::iterator it, it0, it2;
86 layerHitsBKLM =
new int[nLayersBKLM];
87 layerHitsEKLM =
new int[nLayersEKLM];
90 for (i = 0; i < nHits; i++) {
96 sort(klmHit2ds.begin(), klmHit2ds.end(), compareDistance);
98 while (klmHit2ds.size() > 0) {
99 klmClusterHits.clear();
100 it = klmHit2ds.begin();
101 klmClusterHits.push_back(*it);
102 it = klmHit2ds.erase(it);
103 while (it != klmHit2ds.end()) {
104 it2 = klmClusterHits.begin();
107 while (it2 != klmClusterHits.end()) {
108 if (ROOT::Math::VectorUtil::Angle(
109 (*it)->getPosition(), (*it2)->getPosition()) <
111 klmClusterHits.push_back(*it);
112 it = klmHit2ds.erase(it);
119 if (ROOT::Math::VectorUtil::Angle(
120 (*it)->getPosition(), (*it2)->getPosition()) <
122 klmClusterHits.push_back(*it);
123 it = klmHit2ds.erase(it);
131 ROOT::Math::XYZVector clusterPosition{0, 0, 0};
132 for (i = 0; i < nLayersBKLM; i++)
133 layerHitsBKLM[i] = 0;
134 for (i = 0; i < nLayersEKLM; i++)
135 layerHitsEKLM[i] = 0;
137 it0 = klmClusterHits.begin();
139 for (it = klmClusterHits.begin(); it != klmClusterHits.end(); ++it) {
140 if (((*it)->getSubdetector() == (*it0)->getSubdetector() &&
141 (*it)->getLayer() == (*it0)->getLayer()) ||
143 clusterPosition = clusterPosition + (*it)->getPosition();
146 if (minTime < 0 || (*it)->getTime() < minTime)
147 minTime = (*it)->getTime();
149 layerHitsBKLM[(*it)->getLayer() - 1]++;
151 layerHitsEKLM[(*it)->getLayer() - 1]++;
153 clusterPosition = clusterPosition * (1.0 / nHits);
157 for (i = 0; i < nLayersBKLM; i++) {
158 if (layerHitsBKLM[i] > 0) {
160 if (innermostLayer < 0)
161 innermostLayer = i + 1;
164 for (i = 0; i < nLayersEKLM; i++) {
165 if (layerHitsEKLM[i] > 0) {
167 if (innermostLayer < 0)
168 innermostLayer = i + 1;
177 p = klmClusterHits.size() * 0.215;
187 clusterPosition.X(), clusterPosition.Y(), clusterPosition.Z(), minTime, nLayers,
189 for (it = klmClusterHits.begin(); it != klmClusterHits.end(); ++it)
192 delete[] layerHitsBKLM;
193 delete[] layerHitsEKLM;
static constexpr int getMaximalLayerNumber()
Get maximal layer number (1-based).
static constexpr int getMaximalLayerNumber()
Get maximal layer number.
~KLMClustersReconstructorModule()
Destructor.
enum ClusterMode m_ClusterMode
Clusterization mode.
void initialize() override
Initializer.
void event() override
This method is called for each event.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
std::string m_PositionModeString
Vertex position calculation mode.
enum PositionMode m_PositionMode
Vertex position calculation mode.
std::string m_ClusterModeString
Clusterization mode.
@ c_FullAverage
Full average.
@ c_FirstLayer
First layer only.
KLMClustersReconstructorModule()
Constructor.
void beginRun() override
Called when entering a new run.
double m_ClusteringAngle
Clustering angle.
StoreArray< KLMCluster > m_KLMClusters
KLM clusters.
@ c_FirstHit
Angle from first hit.
@ c_AnyHit
Angle from any hit.
StoreArray< KLMHit2d > m_Hit2ds
Two-dimensional hits.
ROOT::Math::XYZVector getPosition() const
Get hit global position.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.