Belle II Software light-2405-quaxo
KLMCluster.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/* Own header. */
10#include <mdst/dataobjects/KLMCluster.h>
11
12/* Basf2 headers. */
13#include <framework/gearbox/Const.h>
14#include <mdst/dataobjects/ECLCluster.h>
15#include <mdst/dataobjects/Track.h>
16
17/* ROOT headers. */
18#include <TMatrixD.h>
19
20using namespace Belle2;
21
22KLMCluster::KLMCluster() : m_time(0), m_layers(0), m_innermostLayer(0),
23 m_globalX(0), m_globalY(0), m_globalZ(0), m_p(0),
24 m_errorX(0), m_errorY(0), m_errorZ(0), m_errorP(0)
25{
26}
27
28KLMCluster::KLMCluster(float x, float y, float z, float time, int nLayers,
29 int nInnermostLayer, float p) :
30 m_time(time), m_layers(nLayers), m_innermostLayer(nInnermostLayer),
31 m_globalX(x), m_globalY(y), m_globalZ(z), m_p(p),
32 m_errorX(0), m_errorY(0), m_errorZ(0), m_errorP(0)
33{
34}
35
37{
38}
39
41{
42 return m_p;
43}
44
46{
47 static double mass = Const::Klong.getMass();
48 return sqrt(mass * mass + m_p * m_p);
49}
50
51ROOT::Math::PxPyPzEVector KLMCluster::getMomentum() const
52{
53 ROOT::Math::XYZVector p3(m_globalX, m_globalY, m_globalZ);
54 p3 = p3.Unit() * m_p;
55 return ROOT::Math::PxPyPzEVector(p3.X(), p3.Y(), p3.Z(), getEnergy());
56}
57
59{
60 RelationVector<ECLCluster> eclClusters = this->getRelationsTo<ECLCluster>();
61 return eclClusters.size() > 0;
62}
63
65{
66 RelationVector<Track> tracks = this->getRelationsFrom<Track>();
67 return tracks.size() > 0;
68}
69
70TMatrixDSym KLMCluster::getError4x4() const
71{
72 /* Elements: px, py, pz, E. */
73 double vertexDist3;
74 TMatrixDSym errorMatrix(4);
75 TMatrixD jacobian(4, 4);
76 errorMatrix[0][0] = m_errorX;
77 errorMatrix[1][1] = m_errorY;
78 errorMatrix[2][2] = m_errorZ;
79 errorMatrix[3][3] = m_errorP;
80 vertexDist3 = pow(m_globalX * m_globalX + m_globalY * m_globalY +
81 m_globalZ * m_globalZ, 1.5);
82 jacobian(0, 0) = m_p * (m_globalY * m_globalY + m_globalZ * m_globalZ) /
83 vertexDist3;
84 jacobian(0, 1) = -m_p * m_globalX * m_globalY / vertexDist3;
85 jacobian(0, 2) = -m_p * m_globalX * m_globalZ / vertexDist3;
86 jacobian(0, 3) = m_globalX / vertexDist3;
87 jacobian(1, 0) = jacobian(0, 1);
88 jacobian(1, 1) = m_p * (m_globalX * m_globalX + m_globalZ * m_globalZ) /
89 vertexDist3;
90 jacobian(1, 2) = -m_p * m_globalY * m_globalZ / vertexDist3;
91 jacobian(1, 3) = m_globalY / vertexDist3;
92 jacobian(2, 0) = jacobian(0, 2);
93 jacobian(2, 1) = jacobian(1, 2);
94 jacobian(2, 2) = m_p * (m_globalX * m_globalX + m_globalY * m_globalY) /
95 vertexDist3;
96 jacobian(2, 3) = m_globalZ / vertexDist3;
97 jacobian(3, 3) = m_p / getEnergy();
98 return errorMatrix.Similarity(jacobian);
99}
100
101TMatrixDSym KLMCluster::getError7x7() const
102{
103 /* Elements: px, py, pz, E, x, y, z. */
104 int i, j;
105 TMatrixDSym errorMatrix(7);
106 TMatrixDSym errorMatrix4 = getError4x4();
107 for (i = 0; i < 4; i++) {
108 for (j = i; j < 4; j++)
109 errorMatrix[i][j] = errorMatrix4[i][j];
110 }
111 for (i = 4; i < 7; i++)
112 errorMatrix[i][i] = 1.0;
113 return errorMatrix;
114}
115
double getMass() const
Particle mass.
Definition: UnitConst.cc:356
static const ParticleType Klong
K^0_L particle.
Definition: Const.h:669
bool getAssociatedTrackFlag() const
Check for associated tracks.
Definition: KLMCluster.cc:64
float getEnergy() const
Get energy.
Definition: KLMCluster.cc:45
float m_globalX
Global position X coordinate.
Definition: KLMCluster.h:215
float m_errorX
Error of vertex X coordinate.
Definition: KLMCluster.h:227
TMatrixDSym getError7x7() const
Get KLM cluster momentum error matrix.
Definition: KLMCluster.cc:101
float m_globalZ
Global position Z coordinate.
Definition: KLMCluster.h:221
float m_p
Absolute value of momentum, 0 means unknown.
Definition: KLMCluster.h:224
bool getAssociatedEclClusterFlag() const
Check for associated ECL clusters.
Definition: KLMCluster.cc:58
~KLMCluster()
Destructor.
Definition: KLMCluster.cc:36
KLMCluster()
Constructor.
Definition: KLMCluster.cc:22
float m_errorP
Error of momentum absolute value.
Definition: KLMCluster.h:236
float m_errorY
Error of vertex Y coordinate.
Definition: KLMCluster.h:230
float getMomentumMag() const
Get momentum magnitude.
Definition: KLMCluster.cc:40
TMatrixDSym getError4x4() const
Get KLM cluster momentum error matrix.
Definition: KLMCluster.cc:70
float m_errorZ
Error of vertex Z coordinate.
Definition: KLMCluster.h:233
ROOT::Math::PxPyPzEVector getMomentum() const
Get momentum.
Definition: KLMCluster.cc:51
float m_globalY
Global position Y coordinate.
Definition: KLMCluster.h:218
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24