CbmRoot
CbmVertex.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- CbmVertex source file -----
3
// ----- Created 28/11/05 by V. Friese -----
4
// -------------------------------------------------------------------------
5
#include "
CbmVertex.h
"
6
7
#include <FairLogger.h>
// for Logger, LOG
8
9
#include <TMatrixTSym.h>
// for TMatrixTSym
10
#include <TMatrixTUtils.h>
// for TMatrixTRow, TMatrixTRow_const
11
#include <TNamed.h>
// for TNamed
12
13
#include <iomanip>
// for operator<<, setprecision
14
#include <sstream>
// for operator<<, basic_ostream, stringstream
15
#include <string>
// for char_traits
16
17
using namespace
std;
18
19
20
// ----- Default constructor -------------------------------------------
21
CbmVertex::CbmVertex
()
22
: TNamed(
"Vertex"
,
"Global"
)
23
, fX(0.)
24
, fY(0.)
25
, fZ(0.)
26
, fChi2(0.)
27
, fNDF(0)
28
, fNTracks(0)
29
, fCovMatrix() {
30
for
(Int_t
i
= 0;
i
< 6;
i
++)
31
fCovMatrix
[
i
] = 0;
32
}
33
// -------------------------------------------------------------------------
34
35
// ----- Constructor with name and title -------------------------------
36
CbmVertex::CbmVertex
(
const
char
* name,
const
char
* title)
37
: TNamed(name, title)
38
, fX(0.)
39
, fY(0.)
40
, fZ(0.)
41
, fChi2(0.)
42
, fNDF(0)
43
, fNTracks(0)
44
, fCovMatrix() {
45
for
(Int_t
i
= 0;
i
< 6;
i
++)
46
fCovMatrix
[
i
] = 0;
47
}
48
// -------------------------------------------------------------------------
49
50
51
// ----- Constructor with all parameters -------------------------------
52
CbmVertex::CbmVertex
(
const
char
* name,
53
const
char
* title,
54
Double_t
x
,
55
Double_t
y
,
56
Double_t z,
57
Double_t chi2,
58
Int_t ndf,
59
Int_t nTracks,
60
const
TMatrixFSym& covMat)
61
: TNamed(name, title)
62
, fX(
x
)
63
, fY(
y
)
64
, fZ(z)
65
, fChi2(chi2)
66
, fNDF(ndf)
67
, fNTracks(nTracks)
68
, fCovMatrix() {
69
if
((covMat.GetNrows() != 3) && (covMat.GetNcols() != 3)) {
70
LOG(error) <<
"Wrong dimension of passed covariance matrix. Clear the "
71
"covariance matrix."
;
72
for
(Int_t
i
= 0;
i
< 6;
i
++)
73
fCovMatrix
[
i
] = 0;
74
}
else
{
75
Int_t index = 0;
76
for
(Int_t
i
= 0;
i
< 3;
i
++) {
77
for
(Int_t j =
i
; j < 3; j++)
78
fCovMatrix
[index++] = covMat[
i
][j];
79
}
80
}
81
}
82
// -------------------------------------------------------------------------
83
84
85
// ----- Destructor ----------------------------------------------------
86
CbmVertex::~CbmVertex
() {}
87
// -------------------------------------------------------------------------
88
89
90
// ----- Public method Print -------------------------------------------
91
void
CbmVertex::Print
(Option_t*)
const
{
92
Double_t chi2ndf;
93
if
(
fNDF
)
94
chi2ndf =
fChi2
/ Double_t(
fNDF
);
95
else
96
chi2ndf = 0.;
97
LOG(info) <<
"Vertex coord. ("
<<
fX
<<
","
<<
fY
<<
","
<<
fZ
<<
") cm, "
98
<<
"chi2/ndf = "
<< chi2ndf <<
", "
<<
fNTracks
<<
" tracks used"
;
99
}
100
// -------------------------------------------------------------------------
101
102
103
// ----- Accessor to covariance matrix --------------------------------
104
void
CbmVertex::CovMatrix
(TMatrixFSym& covMat)
const
{
105
Int_t index = 0;
106
for
(
int
i
= 0;
i
< 3;
i
++) {
107
for
(
int
j =
i
; j < 3; j++) {
108
covMat[
i
][j] =
fCovMatrix
[index];
109
covMat[j][
i
] =
fCovMatrix
[index];
110
index++;
111
}
112
}
113
}
114
// -------------------------------------------------------------------------
115
116
117
// ----- Accessor to covariance matrix elements ------------------------
118
Double_t
CbmVertex::GetCovariance
(Int_t
i
, Int_t j)
const
{
119
TMatrixFSym* mat =
new
TMatrixFSym(3);
120
CovMatrix
(*mat);
121
Double_t element = (*mat)[
i
][j];
122
delete
mat;
123
return
element;
124
}
125
// -------------------------------------------------------------------------
126
127
128
// ----- Public method SetVertex ---------------------------------------
129
void
CbmVertex::SetVertex
(Double_t
x
,
130
Double_t
y
,
131
Double_t z,
132
Double_t chi2,
133
Int_t ndf,
134
Int_t nTracks,
135
const
TMatrixFSym& covMat) {
136
fX
=
x
;
137
fY
=
y
;
138
fZ
= z;
139
fChi2
= chi2;
140
fNDF
= ndf;
141
fNTracks
= nTracks;
142
if
((covMat.GetNrows() != 3) && (covMat.GetNcols() != 3)) {
143
LOG(error) <<
"Wrong dimension of passed covariance matrix. Clear the "
144
"covariance matrix."
;
145
for
(Int_t
i
= 0;
i
< 6;
i
++)
146
fCovMatrix
[
i
] = 0;
147
}
else
{
148
Int_t index = 0;
149
for
(Int_t
i
= 0;
i
< 3;
i
++) {
150
for
(Int_t j =
i
; j < 3; j++)
151
fCovMatrix
[index++] = covMat[
i
][j];
152
}
153
}
154
}
155
// -------------------------------------------------------------------------
156
157
158
// ----- Public method Reset -------------------------------------------
159
void
CbmVertex::Reset
() {
160
fX
=
fY
=
fZ
=
fChi2
= 0.;
161
fNDF
=
fNTracks
= 0;
162
for
(Int_t
i
= 0;
i
< 6;
i
++)
163
fCovMatrix
[
i
] = 0;
164
}
165
// -------------------------------------------------------------------------
166
167
168
// --- String output ------------------------------------------------------
169
string
CbmVertex::ToString
()
const
{
170
171
Double_t chi2ndf = (
fNDF
?
fChi2
/ Double_t(
fNDF
) : 0.);
172
stringstream ss;
173
ss <<
"Vertex: position ("
<< fixed << setprecision(4) <<
fX
<<
", "
<<
fY
174
<<
", "
<<
fZ
<<
") cm, chi2/ndf = "
<< chi2ndf
175
<<
", tracks used: "
<<
fNTracks
;
176
return
ss.str();
177
}
178
// -------------------------------------------------------------------------
179
180
181
ClassImp
(
CbmVertex
)
CbmVertex::Print
virtual void Print(Option_t *opt="") const
Definition:
CbmVertex.cxx:91
CbmVertex::SetVertex
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks, const TMatrixFSym &covMat)
Definition:
CbmVertex.cxx:129
CbmVertex::fNDF
Int_t fNDF
Definition:
CbmVertex.h:113
CbmVertex.h
CbmVertex::fZ
Double32_t fZ
Definition:
CbmVertex.h:107
CbmVertex::Reset
void Reset()
Definition:
CbmVertex.cxx:159
i
int i
Definition:
L1/vectors/P4_F32vec4.h:25
CbmVertex::GetCovariance
Double_t GetCovariance(Int_t i, Int_t j) const
Definition:
CbmVertex.cxx:118
CbmVertex::CbmVertex
CbmVertex()
Definition:
CbmVertex.cxx:21
CbmVertex::fNTracks
Int_t fNTracks
Definition:
CbmVertex.h:116
CbmVertex::fX
Double32_t fX
Definition:
CbmVertex.h:107
CbmVertex::fCovMatrix
Double32_t fCovMatrix[6]
Definition:
CbmVertex.h:121
CbmVertex::fChi2
Double32_t fChi2
Definition:
CbmVertex.h:110
CbmVertex::~CbmVertex
virtual ~CbmVertex()
Definition:
CbmVertex.cxx:86
CbmVertex
Definition:
CbmVertex.h:26
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition:
CbmConverterManager.cxx:12
CbmVertex::fY
Double32_t fY
Definition:
CbmVertex.h:107
x
Double_t x
Definition:
CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition:
CbmMvdSensorDigiToHitTask.cxx:68
CbmVertex::ToString
virtual std::string ToString() const
Definition:
CbmVertex.cxx:169
CbmVertex::CovMatrix
void CovMatrix(TMatrixFSym &covMat) const
Definition:
CbmVertex.cxx:104
core
data
global
CbmVertex.cxx
Generated on Wed Oct 28 2020 15:11:49 for CbmRoot by
1.8.18