Belle II Software  release-05-01-25
KLMCluster.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Timofey Uglov, Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* External headers. */
12 #include <TDatabasePDG.h>
13 
14 /* Belle2 headers. */
15 #include <mdst/dataobjects/ECLCluster.h>
16 #include <mdst/dataobjects/KLMCluster.h>
17 #include <mdst/dataobjects/Track.h>
18 
19 using namespace Belle2;
20 
21 KLMCluster::KLMCluster() : m_time(0), m_layers(0), m_innermostLayer(0),
22  m_globalX(0), m_globalY(0), m_globalZ(0), m_p(0),
23  m_errorX(0), m_errorY(0), m_errorZ(0), m_errorP(0)
24 {
25 }
26 
27 KLMCluster::KLMCluster(float x, float y, float z, float time, int nLayers,
28  int nInnermostLayer, float p) :
29  m_time(time), m_layers(nLayers), m_innermostLayer(nInnermostLayer),
30  m_globalX(x), m_globalY(y), m_globalZ(z), m_p(p),
31  m_errorX(0), m_errorY(0), m_errorZ(0), m_errorP(0)
32 {
33 }
34 
36 {
37 }
38 
40 {
41  return m_p;
42 }
43 
44 float KLMCluster::getEnergy() const
45 {
46  static double mass = TDatabasePDG::Instance()->GetParticle(130)->Mass();
47  return sqrt(mass * mass + m_p * m_p);
48 }
49 
50 TLorentzVector KLMCluster::getMomentum() const
51 {
52  TVector3 p3(m_globalX, m_globalY, m_globalZ);
53  p3 = p3.Unit() * m_p;
54  return TLorentzVector(p3, getEnergy());
55 }
56 
58 {
59  RelationVector<ECLCluster> eclClusters = this->getRelationsTo<ECLCluster>();
60  return eclClusters.size() > 0;
61 }
62 
64 {
65  RelationVector<Track> tracks = this->getRelationsFrom<Track>();
66  return tracks.size() > 0;
67 }
68 
69 TMatrixDSym KLMCluster::getError4x4() const
70 {
71  /* Elements: px, py, pz, E. */
72  double vertexDist3;
73  TMatrixDSym errorMatrix(4);
74  TMatrixD jacobian(4, 4);
75  errorMatrix[0][0] = m_errorX;
76  errorMatrix[1][1] = m_errorY;
77  errorMatrix[2][2] = m_errorZ;
78  errorMatrix[3][3] = m_errorP;
79  vertexDist3 = pow(m_globalX * m_globalX + m_globalY * m_globalY +
80  m_globalZ * m_globalZ, 1.5);
81  jacobian(0, 0) = m_p * (m_globalY * m_globalY + m_globalZ * m_globalZ) /
82  vertexDist3;
83  jacobian(0, 1) = -m_p * m_globalX * m_globalY / vertexDist3;
84  jacobian(0, 2) = -m_p * m_globalX * m_globalZ / vertexDist3;
85  jacobian(0, 3) = m_globalX / vertexDist3;
86  jacobian(1, 0) = jacobian(0, 1);
87  jacobian(1, 1) = m_p * (m_globalX * m_globalX + m_globalZ * m_globalZ) /
88  vertexDist3;
89  jacobian(1, 2) = -m_p * m_globalY * m_globalZ / vertexDist3;
90  jacobian(1, 3) = m_globalY / vertexDist3;
91  jacobian(2, 0) = jacobian(0, 2);
92  jacobian(2, 1) = jacobian(1, 2);
93  jacobian(2, 2) = m_p * (m_globalX * m_globalX + m_globalY * m_globalY) /
94  vertexDist3;
95  jacobian(2, 3) = m_globalZ / vertexDist3;
96  jacobian(3, 3) = m_p / getEnergy();
97  return errorMatrix.Similarity(jacobian);
98 }
99 
100 TMatrixDSym KLMCluster::getError7x7() const
101 {
102  /* Elements: px, py, pz, E, x, y, z. */
103  int i, j;
104  TMatrixDSym errorMatrix(7);
105  TMatrixDSym errorMatrix4 = getError4x4();
106  for (i = 0; i < 4; i++) {
107  for (j = i; j < 4; j++)
108  errorMatrix[i][j] = errorMatrix4[i][j];
109  }
110  for (i = 4; i < 7; i++)
111  errorMatrix[i][i] = 1.0;
112  return errorMatrix;
113 }
114 
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::KLMCluster::getEnergy
float getEnergy() const
Get energy.
Definition: KLMCluster.cc:44
Belle2::KLMCluster::m_errorP
float m_errorP
Error of momentum absolute value.
Definition: KLMCluster.h:246
Belle2::KLMCluster::m_globalX
float m_globalX
Global position X coordinate.
Definition: KLMCluster.h:225
Belle2::KLMCluster::~KLMCluster
~KLMCluster()
Destructor.
Definition: KLMCluster.cc:35
Belle2::KLMCluster::getError4x4
TMatrixDSym getError4x4() const
Get KLM cluster momentum error matrix.
Definition: KLMCluster.cc:69
Belle2::KLMCluster::m_p
float m_p
Absolute value of momentum, 0 means unknown.
Definition: KLMCluster.h:234
Belle2::KLMCluster::m_globalY
float m_globalY
Global position Y coordinate.
Definition: KLMCluster.h:228
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::KLMCluster::KLMCluster
KLMCluster()
Constructor.
Definition: KLMCluster.cc:21
Belle2::KLMCluster::getMomentum
TLorentzVector getMomentum() const
Get momentum.
Definition: KLMCluster.cc:50
Belle2::KLMCluster::m_errorX
float m_errorX
Error of vertex X coordinate.
Definition: KLMCluster.h:237
Belle2::KLMCluster::m_errorZ
float m_errorZ
Error of vertex Z coordinate.
Definition: KLMCluster.h:243
Belle2::KLMCluster::getMomentumMag
float getMomentumMag() const
Get momentum magnitude.
Definition: KLMCluster.cc:39
Belle2::KLMCluster::m_globalZ
float m_globalZ
Global position Z coordinate.
Definition: KLMCluster.h:231
Belle2::KLMCluster::m_errorY
float m_errorY
Error of vertex Y coordinate.
Definition: KLMCluster.h:240
Belle2::KLMCluster::getAssociatedTrackFlag
bool getAssociatedTrackFlag() const
Check for associated tracks.
Definition: KLMCluster.cc:63
Belle2::KLMCluster::getError7x7
TMatrixDSym getError7x7() const
Get KLM cluster momentum error matrix.
Definition: KLMCluster.cc:100
Belle2::KLMCluster::getAssociatedEclClusterFlag
bool getAssociatedEclClusterFlag() const
Check for associated ECL clusters.
Definition: KLMCluster.cc:57