10 #include <klm/modules/KLMClusterEfficiency/KLMClusterEfficiencyModule.h>
13 #include <klm/dataobjects/bklm/BKLMHit2d.h>
14 #include <klm/dataobjects/eklm/EKLMHit2d.h>
17 #include <framework/gearbox/Const.h>
30 m_OutputFile(
nullptr), m_ClusterTree(
nullptr), m_ReconstructionTree(
nullptr),
31 m_DecayVertexX(0), m_DecayVertexY(0), m_DecayVertexZ(0),
32 m_MaxDecayVertexHitAngle(0), m_ClusterX(0), m_ClusterY(0), m_ClusterZ(0),
33 m_MaxClusterHitAngle(0), m_KL0Clusters(0), m_PartlyKL0Clusters(0),
34 m_OtherClusters(0), m_NonreconstructedKL0(0),
35 m_ReconstructedKL01Cluster{0, 0, 0}, m_ExactlyReconstructedKL0(0),
36 m_ReconstructedKL02Clusters{0, 0, 0, 0, 0, 0},
37 m_ReconstructedKL03Clusters(0)
39 setDescription(
"Module for KLM cluster reconstruction efficiency studies.");
40 addParam(
"SaveClusterData", m_SaveClusterData,
41 "Whether to save cluster data or not.",
false);
42 addParam(
"SaveReconstructionData", m_SaveReconstructionData,
43 "Whether to save reconstruction data or not.",
true);
44 addParam(
"OutputFile", m_OutputFileName,
"Output file.",
45 std::string(
"KLMClusterEfficiency.root"));
46 addParam(
"EventsClusterHistograms", m_EventsClusterHistograms,
47 "Draw cluster histograms for this number of events.", 0);
64 "MaxDecayVertexHitAngle/F");
69 "MaxClusterHitAngle/F");
76 "PartlyKL0Clusters/I");
80 "NonreconstructedKL0/I");
83 "ReconstructedKL01Cluster[3]/I");
86 "ReconstructedKL02Clusters[6]/I");
89 "ReconstructedKL03Clusters/I");
91 gStyle->SetOptStat(0);
100 static int nevent = 0;
103 int i1, i2, i3, n1, n2, n3;
104 int bs1, bs2, es1, es2;
105 TVector3 decayVertex, clusterPosition, hitPosition;
110 for (i1 = 0; i1 < n1; i1++) {
114 n2 = clusterMCParticles.
size();
115 for (i2 = 0; i2 < n2; i2++) {
128 static TH2F* hzx =
new TH2F(
"hzx",
"", 100, -300, 420, 100, -320, 320);
129 static TH2F* hzy =
new TH2F(
"hzy",
"", 100, -300, 420, 100, -320, 320);
130 static TH2F* hxy =
new TH2F(
"hxy",
"", 100, -320, 320, 100, -320, 320);
131 static TCanvas* c1 =
new TCanvas();
132 static TMarker* clusterMarker =
new TMarker(0, 0, 20);
133 static TMarker* hitMarker =
new TMarker(0, 0, 21);
135 hzx->GetXaxis()->SetTitle(
"z, cm");
136 hzx->GetYaxis()->SetTitle(
"x, cm");
137 hzy->GetXaxis()->SetTitle(
"z, cm");
138 hzy->GetYaxis()->SetTitle(
"y, cm");
139 hxy->GetXaxis()->SetTitle(
"x, cm");
140 hxy->GetYaxis()->SetTitle(
"y, cm");
143 for (i1 = 0; i1 < n1; i1++) {
144 clusterMarker->SetMarkerColor(i1 + 1);
145 hitMarker->SetMarkerColor(i1 + 1);
147 clusterMarker->DrawMarker(clusterPosition.Z(), clusterPosition.X());
150 n2 = bklmHit2ds.
size();
151 for (i2 = 0; i2 < n2; i2++) {
152 hitPosition = bklmHit2ds[i2]->getGlobalPosition();
153 hitMarker->DrawMarker(hitPosition.Z(), hitPosition.X());
157 n2 = eklmHit2ds.
size();
158 for (i2 = 0; i2 < n2; i2++) {
159 hitPosition = eklmHit2ds[i2]->getPosition();
160 hitMarker->DrawMarker(hitPosition.Z(), hitPosition.X());
163 snprintf(str, 128,
"clusters%dzx.eps", nevent);
166 for (i1 = 0; i1 < n1; i1++) {
167 clusterMarker->SetMarkerColor(i1 + 1);
168 hitMarker->SetMarkerColor(i1 + 1);
170 clusterMarker->DrawMarker(clusterPosition.Z(), clusterPosition.Y());
173 n2 = bklmHit2ds.
size();
174 for (i2 = 0; i2 < n2; i2++) {
175 hitPosition = bklmHit2ds[i2]->getGlobalPosition();
176 hitMarker->DrawMarker(hitPosition.Z(), hitPosition.Y());
180 n2 = eklmHit2ds.
size();
181 for (i2 = 0; i2 < n2; i2++) {
182 hitPosition = eklmHit2ds[i2]->getPosition();
183 hitMarker->DrawMarker(hitPosition.Z(), hitPosition.Y());
186 snprintf(str, 128,
"clusters%dzy.eps", nevent);
189 for (i1 = 0; i1 < n1; i1++) {
190 clusterMarker->SetMarkerColor(i1 + 1);
191 hitMarker->SetMarkerColor(i1 + 1);
193 clusterMarker->DrawMarker(clusterPosition.X(), clusterPosition.Y());
196 n2 = bklmHit2ds.
size();
197 for (i2 = 0; i2 < n2; i2++) {
198 hitPosition = bklmHit2ds[i2]->getGlobalPosition();
199 hitMarker->DrawMarker(hitPosition.X(), hitPosition.Y());
203 n2 = eklmHit2ds.
size();
204 for (i2 = 0; i2 < n2; i2++) {
205 hitPosition = eklmHit2ds[i2]->getPosition();
206 hitMarker->DrawMarker(hitPosition.X(), hitPosition.Y());
209 snprintf(str, 128,
"clusters%dxy.eps", nevent);
214 for (i1 = 0; i1 < n1; i1++) {
224 n2 = mcBKLMHit2ds.
size();
225 for (i2 = 0; i2 < n2; i2++) {
226 hitPosition = mcBKLMHit2ds[i2]->getGlobalPosition();
227 angle = decayVertex.Angle(hitPosition);
233 n2 = mcEKLMHit2ds.
size();
234 for (i2 = 0; i2 < n2; i2++) {
235 hitPosition = mcEKLMHit2ds[i2]->getPosition();
236 angle = decayVertex.Angle(hitPosition);
242 n2 = kl0Clusters.
size();
247 kl0Clusters[0]->getRelationsTo<
BKLMHit2d>();
249 kl0Clusters[0]->getRelationsTo<
EKLMHit2d>();
250 bs1 = bklmHit2ds.
size();
251 es1 = eklmHit2ds.size();
261 if (m_MCParticles2.
size() == 1) {
262 if (m_MCParticles2.
weight(0) == 1)
265 }
else if (n2 == 2) {
267 kl0Clusters[0]->getRelationsTo<
BKLMHit2d>();
269 kl0Clusters[1]->getRelationsTo<
BKLMHit2d>();
271 kl0Clusters[0]->getRelationsTo<
EKLMHit2d>();
273 kl0Clusters[1]->getRelationsTo<
EKLMHit2d>();
274 bs1 = bklmHit2ds1.
size();
275 bs2 = bklmHit2ds2.size();
276 es1 = eklmHit2ds1.size();
277 es2 = eklmHit2ds2.size();
278 if (bs1 > 0 && bs2 > 0) {
279 if (es1 > 0 && es2 > 0) {
281 }
else if ((es1 > 0 && es2 == 0) || (es1 == 0 && es2 > 0)) {
283 }
else if (es1 == 0 && es2 == 0) {
286 }
else if (bs1 > 0 && bs2 == 0) {
287 if (es1 > 0 && es2 > 0) {
289 }
else if (es1 == 0 && es2 > 0) {
292 }
else if (bs1 == 0 && bs2 > 0) {
293 if (es1 > 0 && es2 > 0) {
295 }
else if (es1 > 0 && es2 == 0) {
298 }
else if (bs1 == 0 && bs2 == 0) {
299 if (es1 > 0 && es2 > 0) {
306 for (i2 = 0; i2 < n2; i2++) {
307 clusterPosition = kl0Clusters[i2]->getClusterPosition();
313 kl0Clusters[i2]->getRelationsTo<
BKLMHit2d>();
314 n3 = bklmHit2ds.
size();
315 for (i3 = 0; i3 < n3; i3++) {
316 hitPosition = bklmHit2ds[i3]->getGlobalPosition();
317 angle = clusterPosition.Angle(hitPosition);
322 kl0Clusters[i2]->getRelationsTo<
EKLMHit2d>();
323 n3 = eklmHit2ds.
size();
324 for (i3 = 0; i3 < n3; i3++) {
325 hitPosition = eklmHit2ds[i3]->getPosition();
326 angle = clusterPosition.Angle(hitPosition);
342 int i, rec1Cluster, rec2Clusters;
345 for (i = 0; i < 3; i++)
347 for (i = 0; i < 6; i++)
358 B2INFO(
"K_L0 reconstructed as 1 cluster (total): " << rec1Cluster);
359 B2INFO(
"K_L0 reconstructed as 1 cluster (BKLM): " <<
361 B2INFO(
"K_L0 reconstructed as 1 cluster (BKLM/EKLM): " <<
363 B2INFO(
"K_L0 reconstructed as 1 cluster (EKLM): " <<
365 B2INFO(
"K_L0 reconstructed as 1 cluster (exact reconstruction): " <<
367 B2INFO(
"K_L0 reconstructed as 2 clusters (total): " << rec2Clusters);
368 B2INFO(
"K_L0 reconstructed as 2 clusters (2 * BKLM): " <<
370 B2INFO(
"K_L0 reconstructed as 2 clusters (BKLM + BKLM/EKLM): " <<
372 B2INFO(
"K_L0 reconstructed as 2 clusters (BKLM + EKLM): " <<
374 B2INFO(
"K_L0 reconstructed as 2 clusters (2 * BKLM/EKLM): " <<
376 B2INFO(
"K_L0 reconstructed as 2 clusters (BKLM/EKLM + EKLM): " <<
378 B2INFO(
"K_L0 reconstructed as 2 clusters (2 * EKLM): " <<
380 B2INFO(
"K_L0 reconstructed as 3 or more clusters: " <<
Store one BKLM strip hit as a ROOT object.
int getPDGCode() const
PDG code.
static const ParticleType Klong
K^0_L particle.
Class for 2d hits handling.
Module for KLM cluster reconstruction efficiency studies.
bool m_SaveClusterData
Whether to save cluster data or not.
float m_ClusterY
Cluster Y coordinate.
float m_DecayVertexZ
MCParticle decay vertex Z coordinate.
float m_DecayVertexX
MCParticle decay vertex X coordinate.
void initialize() override
Initializer.
TTree * m_ClusterTree
Cluster data tree.
float m_MaxClusterHitAngle
Maximal angle between KLM cluster and its hits.
void event() override
This method is called for each event.
~KLMClusterEfficiencyModule()
Destructor.
int m_KL0Clusters
Number of clusters from a K_L0.
void endRun() override
This method is called if the current run ends.
TFile * m_OutputFile
Output file.
void terminate() override
This method is called at the end of the event processing.
int m_ReconstructedKL03Clusters
Number of K_L0 reconstructed as >= 2 clusters.
float m_ClusterZ
Cluster Z coordinate.
int m_EventsClusterHistograms
Draw cluster histograms for this number of events.
bool m_SaveReconstructionData
Whether to save reconstruction data or not.
int m_OtherClusters
Number of clusters from other particles.
int m_ExactlyReconstructedKL0
Number of K_L0 reconstructed as 1 cluster, and this cluster should be related only to 1 (K_L0 ) MCPar...
void beginRun() override
Called when entering a new run.
float m_ClusterX
Cluster X coordinate.
int m_PartlyKL0Clusters
Number of clusters from a K_L0 + other particles.
TTree * m_ReconstructionTree
Reconstruction tree.
StoreArray< KLMCluster > m_KLMClusters
KLM clusters.
int m_ReconstructedKL02Clusters[6]
Number of K_L0 reconstructed as 2 clusters in (2 * BKLM, BKLM + BKLM/EKLM, BKLM + EKLM,...
int m_ReconstructedKL01Cluster[3]
Number of K_L0 reconstructed as 1 cluster in (BKLM, BKLM/EKLM, EKLM).
float m_MaxDecayVertexHitAngle
Maximal angle between MCParticle decay vertex and its hits.
std::string m_OutputFileName
Output file name.
float m_DecayVertexY
MCParticle decay vertex Y coordinate.
StoreArray< MCParticle > m_MCParticles
MC particles.
int m_NonreconstructedKL0
Number of nonreconstructed K_L0.
A Class to store the Monte Carlo particle information.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
float weight(int index) const
Get weight with index.
int getEntries() const
Get the number of objects in the array.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.