10#include <klm/modules/KLMClusterEfficiency/KLMClusterEfficiencyModule.h>
13#include <klm/dataobjects/KLMHit2d.h>
16#include <framework/gearbox/Const.h>
19#include <Math/VectorUtil.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.");
41 "Whether to save cluster data or not.",
false);
43 "Whether to save reconstruction data or not.",
true);
45 std::string(
"KLMClusterEfficiency.root"));
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 ROOT::Math::XYZVector clusterPosition;
106 ROOT::Math::XYZVector decayVertex, hitPosition;
111 for (i1 = 0; i1 < n1; i1++) {
115 n2 = clusterMCParticles.
size();
116 for (i2 = 0; i2 < n2; i2++) {
129 static TH2F* hzx =
new TH2F(
"hzx",
"", 100, -300, 420, 100, -320, 320);
130 static TH2F* hzy =
new TH2F(
"hzy",
"", 100, -300, 420, 100, -320, 320);
131 static TH2F* hxy =
new TH2F(
"hxy",
"", 100, -320, 320, 100, -320, 320);
132 static TCanvas* c1 =
new TCanvas();
133 static TMarker* clusterMarker =
new TMarker(0, 0, 20);
134 static TMarker* hitMarker =
new TMarker(0, 0, 21);
136 hzx->GetXaxis()->SetTitle(
"z, cm");
137 hzx->GetYaxis()->SetTitle(
"x, cm");
138 hzy->GetXaxis()->SetTitle(
"z, cm");
139 hzy->GetYaxis()->SetTitle(
"y, cm");
140 hxy->GetXaxis()->SetTitle(
"x, cm");
141 hxy->GetYaxis()->SetTitle(
"y, cm");
144 for (i1 = 0; i1 < n1; i1++) {
145 clusterMarker->SetMarkerColor(i1 + 1);
146 hitMarker->SetMarkerColor(i1 + 1);
148 clusterMarker->DrawMarker(clusterPosition.Z(), clusterPosition.X());
151 n2 = klmHit2ds.
size();
152 for (i2 = 0; i2 < n2; i2++) {
153 hitPosition = klmHit2ds[i2]->getPosition();
154 hitMarker->DrawMarker(hitPosition.Z(), hitPosition.X());
157 snprintf(str, 128,
"clusters%dzx.eps", nevent);
160 for (i1 = 0; i1 < n1; i1++) {
161 clusterMarker->SetMarkerColor(i1 + 1);
162 hitMarker->SetMarkerColor(i1 + 1);
164 clusterMarker->DrawMarker(clusterPosition.Z(), clusterPosition.Y());
167 n2 = klmHit2ds.
size();
168 for (i2 = 0; i2 < n2; i2++) {
169 hitPosition = klmHit2ds[i2]->getPosition();
170 hitMarker->DrawMarker(hitPosition.Z(), hitPosition.Y());
173 snprintf(str, 128,
"clusters%dzy.eps", nevent);
176 for (i1 = 0; i1 < n1; i1++) {
177 clusterMarker->SetMarkerColor(i1 + 1);
178 hitMarker->SetMarkerColor(i1 + 1);
180 clusterMarker->DrawMarker(clusterPosition.X(), clusterPosition.Y());
183 n2 = klmHit2ds.
size();
184 for (i2 = 0; i2 < n2; i2++) {
185 hitPosition = klmHit2ds[i2]->getPosition();
186 hitMarker->DrawMarker(hitPosition.X(), hitPosition.Y());
189 snprintf(str, 128,
"clusters%dxy.eps", nevent);
194 for (i1 = 0; i1 < n1; i1++) {
204 n2 = mcKLMHit2ds.
size();
205 for (i2 = 0; i2 < n2; i2++) {
206 hitPosition = mcKLMHit2ds[i2]->getPosition();
207 angle = ROOT::Math::VectorUtil::Angle(decayVertex, hitPosition);
213 n2 = kl0Clusters.
size();
218 kl0Clusters[0]->getRelationsTo<
KLMHit2d>();
221 for (
const KLMHit2d& hit2d : klmHit2ds) {
236 if (m_MCParticles2.
size() == 1) {
237 if (m_MCParticles2.
weight(0) == 1)
240 }
else if (n2 == 2) {
242 kl0Clusters[0]->getRelationsTo<
KLMHit2d>();
244 kl0Clusters[1]->getRelationsTo<
KLMHit2d>();
249 for (
const KLMHit2d& hit2d : klmHit2ds1) {
255 for (
const KLMHit2d& hit2d : klmHit2ds2) {
261 if (bs1 > 0 && bs2 > 0) {
262 if (es1 > 0 && es2 > 0) {
264 }
else if ((es1 > 0 && es2 == 0) || (es1 == 0 && es2 > 0)) {
266 }
else if (es1 == 0 && es2 == 0) {
269 }
else if (bs1 > 0 && bs2 == 0) {
270 if (es1 > 0 && es2 > 0) {
272 }
else if (es1 == 0 && es2 > 0) {
275 }
else if (bs1 == 0 && bs2 > 0) {
276 if (es1 > 0 && es2 > 0) {
278 }
else if (es1 > 0 && es2 == 0) {
281 }
else if (bs1 == 0 && bs2 == 0) {
282 if (es1 > 0 && es2 > 0) {
289 for (i2 = 0; i2 < n2; i2++) {
290 clusterPosition = kl0Clusters[i2]->getClusterPosition();
296 kl0Clusters[i2]->getRelationsTo<
KLMHit2d>();
297 n3 = klmHit2ds.
size();
298 for (i3 = 0; i3 < n3; i3++) {
299 hitPosition = klmHit2ds[i3]->getPosition();
300 angle = ROOT::Math::VectorUtil::Angle(clusterPosition, hitPosition);
316 int i, rec1Cluster, rec2Clusters;
319 for (i = 0; i < 3; i++)
321 for (i = 0; i < 6; i++)
332 B2INFO(
"K_L0 reconstructed as 1 cluster (total): " << rec1Cluster);
333 B2INFO(
"K_L0 reconstructed as 1 cluster (BKLM): " <<
335 B2INFO(
"K_L0 reconstructed as 1 cluster (BKLM/EKLM): " <<
337 B2INFO(
"K_L0 reconstructed as 1 cluster (EKLM): " <<
339 B2INFO(
"K_L0 reconstructed as 1 cluster (exact reconstruction): " <<
341 B2INFO(
"K_L0 reconstructed as 2 clusters (total): " << rec2Clusters);
342 B2INFO(
"K_L0 reconstructed as 2 clusters (2 * BKLM): " <<
344 B2INFO(
"K_L0 reconstructed as 2 clusters (BKLM + BKLM/EKLM): " <<
346 B2INFO(
"K_L0 reconstructed as 2 clusters (BKLM + EKLM): " <<
348 B2INFO(
"K_L0 reconstructed as 2 clusters (2 * BKLM/EKLM): " <<
350 B2INFO(
"K_L0 reconstructed as 2 clusters (BKLM/EKLM + EKLM): " <<
352 B2INFO(
"K_L0 reconstructed as 2 clusters (2 * EKLM): " <<
354 B2INFO(
"K_L0 reconstructed as 3 or more clusters: " <<
int getPDGCode() const
PDG code.
static const ParticleType Klong
K^0_L particle.
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.
KLMClusterEfficiencyModule()
Constructor.
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.
void setDescription(const std::string &description)
Sets the description of the module.
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.
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.