Belle II Software  release-06-01-15
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 /* Belle2 headers. */
13 #include <framework/gearbox/Const.h>
14 #include <mdst/dataobjects/ECLCluster.h>
15 #include <mdst/dataobjects/Track.h>
16 
17 using namespace Belle2;
18 
19 KLMCluster::KLMCluster() : m_time(0), m_layers(0), m_innermostLayer(0),
20  m_globalX(0), m_globalY(0), m_globalZ(0), m_p(0),
21  m_errorX(0), m_errorY(0), m_errorZ(0), m_errorP(0)
22 {
23 }
24 
25 KLMCluster::KLMCluster(float x, float y, float z, float time, int nLayers,
26  int nInnermostLayer, float p) :
27  m_time(time), m_layers(nLayers), m_innermostLayer(nInnermostLayer),
28  m_globalX(x), m_globalY(y), m_globalZ(z), m_p(p),
29  m_errorX(0), m_errorY(0), m_errorZ(0), m_errorP(0)
30 {
31 }
32 
34 {
35 }
36 
38 {
39  return m_p;
40 }
41 
42 float KLMCluster::getEnergy() const
43 {
44  static double mass = Const::Klong.getMass();
45  return sqrt(mass * mass + m_p * m_p);
46 }
47 
48 TLorentzVector KLMCluster::getMomentum() const
49 {
50  TVector3 p3(m_globalX, m_globalY, m_globalZ);
51  p3 = p3.Unit() * m_p;
52  return TLorentzVector(p3, getEnergy());
53 }
54 
56 {
57  RelationVector<ECLCluster> eclClusters = this->getRelationsTo<ECLCluster>();
58  return eclClusters.size() > 0;
59 }
60 
62 {
63  RelationVector<Track> tracks = this->getRelationsFrom<Track>();
64  return tracks.size() > 0;
65 }
66 
67 TMatrixDSym KLMCluster::getError4x4() const
68 {
69  /* Elements: px, py, pz, E. */
70  double vertexDist3;
71  TMatrixDSym errorMatrix(4);
72  TMatrixD jacobian(4, 4);
73  errorMatrix[0][0] = m_errorX;
74  errorMatrix[1][1] = m_errorY;
75  errorMatrix[2][2] = m_errorZ;
76  errorMatrix[3][3] = m_errorP;
77  vertexDist3 = pow(m_globalX * m_globalX + m_globalY * m_globalY +
78  m_globalZ * m_globalZ, 1.5);
79  jacobian(0, 0) = m_p * (m_globalY * m_globalY + m_globalZ * m_globalZ) /
80  vertexDist3;
81  jacobian(0, 1) = -m_p * m_globalX * m_globalY / vertexDist3;
82  jacobian(0, 2) = -m_p * m_globalX * m_globalZ / vertexDist3;
83  jacobian(0, 3) = m_globalX / vertexDist3;
84  jacobian(1, 0) = jacobian(0, 1);
85  jacobian(1, 1) = m_p * (m_globalX * m_globalX + m_globalZ * m_globalZ) /
86  vertexDist3;
87  jacobian(1, 2) = -m_p * m_globalY * m_globalZ / vertexDist3;
88  jacobian(1, 3) = m_globalY / vertexDist3;
89  jacobian(2, 0) = jacobian(0, 2);
90  jacobian(2, 1) = jacobian(1, 2);
91  jacobian(2, 2) = m_p * (m_globalX * m_globalX + m_globalY * m_globalY) /
92  vertexDist3;
93  jacobian(2, 3) = m_globalZ / vertexDist3;
94  jacobian(3, 3) = m_p / getEnergy();
95  return errorMatrix.Similarity(jacobian);
96 }
97 
98 TMatrixDSym KLMCluster::getError7x7() const
99 {
100  /* Elements: px, py, pz, E, x, y, z. */
101  int i, j;
102  TMatrixDSym errorMatrix(7);
103  TMatrixDSym errorMatrix4 = getError4x4();
104  for (i = 0; i < 4; i++) {
105  for (j = i; j < 4; j++)
106  errorMatrix[i][j] = errorMatrix4[i][j];
107  }
108  for (i = 4; i < 7; i++)
109  errorMatrix[i][i] = 1.0;
110  return errorMatrix;
111 }
112 
double getMass() const
Particle mass.
Definition: UnitConst.cc:323
static const ParticleType Klong
K^0_L particle.
Definition: Const.h:558
bool getAssociatedTrackFlag() const
Check for associated tracks.
Definition: KLMCluster.cc:61
float getEnergy() const
Get energy.
Definition: KLMCluster.cc:42
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:98
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:55
~KLMCluster()
Destructor.
Definition: KLMCluster.cc:33
KLMCluster()
Constructor.
Definition: KLMCluster.cc:19
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:37
TMatrixDSym getError4x4() const
Get KLM cluster momentum error matrix.
Definition: KLMCluster.cc:67
float m_errorZ
Error of vertex Z coordinate.
Definition: KLMCluster.h:233
TLorentzVector getMomentum() const
Get momentum.
Definition: KLMCluster.cc:48
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.