BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnVertex.cxx
Go to the documentation of this file.
1#include "BmnVertex.h"
2
3#include "FairLogger.h"
4
5#include <iomanip>
6#include <iostream>
7#include <sstream>
8
9// ----- Default constructor -------------------------------------------
11 : fX(-1000.)
12 , fY(-1000.)
13 , fZ(-1000.)
14 , fChi2(-1.)
15 , fNDF(-1)
16 , fNTracks(-1)
17 , fCovMatrix()
18 , fTrackIdxs()
19 , fFlag(-1)
20{
21 for (Int_t i = 0; i < 6; i++)
22 fCovMatrix[i] = 0;
23}
24// -------------------------------------------------------------------------
25
26// ----- Constructor with all parameters -------------------------------
28 Double_t y,
29 Double_t z,
30 Double_t chi2,
31 Int_t ndf,
32 Int_t nTracks,
33 const TMatrixFSym& covMat,
34 Int_t flag,
35 vector<Int_t> idxs)
36 : fX(x)
37 , fY(y)
38 , fZ(z)
39 , fChi2(chi2)
40 , fNDF(ndf)
41 , fNTracks(nTracks)
42 , fCovMatrix()
43 , fTrackIdxs(idxs)
44 , fFlag(flag)
45{
46 if ((covMat.GetNrows() != 3) && (covMat.GetNcols() != 3)) {
47 LOG(error) << "Wrong dimension of passed covariance matrix. Clear the covariance matrix.";
48 for (Int_t i = 0; i < 6; i++)
49 fCovMatrix[i] = 0;
50 } else {
51 Int_t index = 0;
52 for (Int_t i = 0; i < 3; i++) {
53 for (Int_t j = i; j < 3; j++)
54 fCovMatrix[index++] = covMat[i][j];
55 }
56 }
57}
58// -------------------------------------------------------------------------
59
60// ----- Destructor ----------------------------------------------------
62// -------------------------------------------------------------------------
63
64// ----- Public method Print -------------------------------------------
66{
67 Double_t chi2ndf;
68 if (fNDF)
69 chi2ndf = fChi2 / Double_t(fNDF);
70 else
71 chi2ndf = 0.;
72 cout << "Vertex coord. (" << fX << "," << fY << "," << fZ << ") cm, "
73 << "chi2/ndf = " << chi2ndf << ", " << fNTracks << " tracks used, Vertex type: " << fFlag << endl;
74}
75// -------------------------------------------------------------------------
76
77// ----- Accessor to covariance matrix --------------------------------
79{
80 Int_t index = 0;
81 for (int i = 0; i < 3; i++) {
82 for (int j = i; j < 3; j++) {
83 covMat[i][j] = fCovMatrix[index];
84 covMat[j][i] = fCovMatrix[index];
85 index++;
86 }
87 }
88}
89// -------------------------------------------------------------------------
90
91// ----- Accessor to covariance matrix elements ------------------------
93{
94 TMatrixFSym* mat = new TMatrixFSym(3);
95 CovMatrix(*mat);
96 Double_t element = (*mat)[i][j];
97 delete mat;
98 return element;
99}
100// -------------------------------------------------------------------------
101
102// ----- Public method SetVertex ---------------------------------------
104 Double_t y,
105 Double_t z,
106 Double_t chi2,
107 Int_t ndf,
108 Int_t nTracks,
109 const TMatrixFSym& covMat,
110 Int_t flag,
111 vector<Int_t> idxs)
112{
113 fX = x;
114 fY = y;
115 fZ = z;
116 fChi2 = chi2;
117 fNDF = ndf;
118 fNTracks = nTracks;
119 fFlag = flag;
120 fTrackIdxs = idxs;
121 if ((covMat.GetNrows() != 3) && (covMat.GetNcols() != 3)) {
122 LOG(error) << "Wrong dimension of passed covariance matrix. Clear the covariance matrix.";
123 for (Int_t i = 0; i < 6; i++)
124 fCovMatrix[i] = 0;
125 } else {
126 Int_t index = 0;
127 for (Int_t i = 0; i < 3; i++) {
128 for (Int_t j = i; j < 3; j++)
129 fCovMatrix[index++] = covMat[i][j];
130 }
131 }
132}
133// -------------------------------------------------------------------------
134
135// ----- Public method Reset -------------------------------------------
137{
138 fX = fY = fZ = fChi2 = 0.;
139 fNDF = fNTracks = 0;
140 fFlag = -1;
141 fTrackIdxs.clear();
142 for (Int_t i = 0; i < 6; i++)
143 fCovMatrix[i] = 0;
144}
145// -------------------------------------------------------------------------
146
147// --- String output ------------------------------------------------------
149{
150 Double_t chi2ndf = (fNDF ? fChi2 / Double_t(fNDF) : 0.);
151 stringstream ss;
152 ss << "Vertex: position (" << fixed << setprecision(4) << fX << ", " << fY << ", " << fZ
153 << ") cm, chi2/ndf = " << chi2ndf << ", tracks used: " << fNTracks << ", Vertex type: " << fFlag;
154 return ss.str();
155}
156// -------------------------------------------------------------------------
int i
Definition P4_F32vec4.h:22
int Int_t
double Double_t
TMatrixTSym< Float_t > TMatrixFSym
Double32_t fZ
Definition BmnVertex.h:96
Double32_t fX
Position coordinates [cm].
Definition BmnVertex.h:96
Int_t fNTracks
Number of tracks used for the vertex fit.
Definition BmnVertex.h:105
BmnVertex()
Default constructor.
Definition BmnVertex.cxx:10
vector< Int_t > fTrackIdxs
Vector of indexes of tracks used to reconstruct current vertex.
Definition BmnVertex.h:113
Double32_t fChi2
Chi2 of vertex fit.
Definition BmnVertex.h:99
Int_t fFlag
Flag to mark vertexes by types for SRC setup next types are used: -1 - default value,...
Definition BmnVertex.h:122
virtual std::string ToString() const
String output.
Double32_t fCovMatrix[6]
Covariance matrix for x, y, and z stored in an array.
Definition BmnVertex.h:110
void Print()
Ouput to screen.
Definition BmnVertex.cxx:65
Double32_t fY
Definition BmnVertex.h:96
void CovMatrix(TMatrixFSym &covMat) const
Definition BmnVertex.cxx:78
virtual ~BmnVertex()
Destructor.
Definition BmnVertex.cxx:61
Double_t GetCovariance(Int_t i, Int_t j) const
Definition BmnVertex.cxx:92
void Reset()
Reset the member variables.
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks, const TMatrixFSym &covMat, Int_t flag, vector< Int_t > idxs)
Set the member variables.
Int_t fNDF
Number of degrees of freedom of vertex fit.
Definition BmnVertex.h:102