BmnRoot
Loading...
Searching...
No Matches
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 <TNamed.h>
8#include <iostream>
9
10using std::cout;
11using std::endl;
12
13// ----- Default constructor -------------------------------------------
14
16 : TNamed("Vertex", "Global")
17 , fX(0.)
18 , fY(0.)
19 , fZ(0.)
20 , fChi2(0.)
21 , fNDF(0)
22 , fNTracks(0)
23 , fCovMatrix()
24{
25 for (Int_t i = 0; i < 6; i++)
26 fCovMatrix[i] = 0;
27}
28// -------------------------------------------------------------------------
29
30// ----- Constructor with name and title -------------------------------
31
32CbmVertex::CbmVertex(const char* name, const char* title)
33 : TNamed(name, title)
34 , fX(0.)
35 , fY(0.)
36 , fZ(0.)
37 , fChi2(0.)
38 , fNDF(0)
39 , fNTracks(0)
40 , fCovMatrix()
41{
42 for (Int_t i = 0; i < 6; i++)
43 fCovMatrix[i] = 0;
44}
45// -------------------------------------------------------------------------
46
47// ----- Constructor with all parameters -------------------------------
48
49CbmVertex::CbmVertex(const char* name,
50 const char* title,
51 Double_t x,
52 Double_t y,
53 Double_t z,
54 Double_t chi2,
55 Int_t ndf,
56 Int_t nTracks,
57 const TMatrixFSym& covMat)
58 : TNamed(name, title)
59 , fX(x)
60 , fY(y)
61 , fZ(z)
62 , fChi2(chi2)
63 , fNDF(ndf)
64 , fNTracks(nTracks)
65 , fCovMatrix()
66{
67 Int_t index = 0;
68 for (Int_t i = 0; i < 3; i++) {
69 for (Int_t j = i; j < 3; j++)
70 fCovMatrix[index++] = covMat[i][j];
71 }
72}
73// -------------------------------------------------------------------------
74
75// ----- Destructor ----------------------------------------------------
76
78// -------------------------------------------------------------------------
79
80// ----- Public method Print -------------------------------------------
81
83{
84 Double_t chi2ndf;
85 if (fNDF)
86 chi2ndf = fChi2 / Double_t(fNDF);
87 else
88 chi2ndf = 0.;
89
90 // if(chi2ndf>0 && chi2ndf<2){
91
92 cout << "Vertex coord. (" << fX << "," << fY << "," << fZ << ") cm, "
93 << "chi2/ndf = " << chi2ndf << ", " << fNTracks << " tracks used" << endl;
94 //}
95}
96// -------------------------------------------------------------------------
97
98// ----- Accessor to covariance matrix --------------------------------
99
100void CbmVertex::CovMatrix(TMatrixFSym& covMat) const
101{
102 Int_t index = 0;
103 for (int i = 0; i < 3; i++) {
104 for (int j = i; j < 3; j++) {
105 covMat[i][j] = fCovMatrix[index];
106 covMat[j][i] = fCovMatrix[index];
107 index++;
108 }
109 }
110}
111// -------------------------------------------------------------------------
112
113// ----- Accessor to covariance matrix elements ------------------------
114
115Double_t CbmVertex::GetCovariance(Int_t i, Int_t j) const
116{
117 TMatrixFSym* mat = new TMatrixFSym(3);
118 CovMatrix(*mat);
119 Double_t element = (*mat)[i][j];
120 delete mat;
121 return element;
122}
123// -------------------------------------------------------------------------
124
125// ----- Public method SetVertex ---------------------------------------
126
127void CbmVertex::SetVertex(Double_t x,
128 Double_t y,
129 Double_t z,
130 Double_t chi2,
131 Int_t ndf,
132 Int_t nTracks,
133 const TMatrixFSym& covMat)
134{
135 fX = x;
136 fY = y;
137 fZ = z;
138 fChi2 = chi2;
139 fNDF = ndf;
140 fNTracks = nTracks;
141 Int_t index = 0;
142 for (Int_t i = 0; i < 3; i++) {
143 for (Int_t j = i; j < 3; j++)
144 fCovMatrix[index++] = covMat[i][j];
145 }
146}
147// -------------------------------------------------------------------------
148
149// ----- Public method Reset -------------------------------------------
150
152{
153 fX = fY = fZ = fChi2 = 0.;
154 fNDF = fNTracks = 0;
155 for (Int_t i = 0; i < 6; i++)
156 fCovMatrix[i] = 0;
157}
158// -------------------------------------------------------------------------
159
161{
162 TMatrixFSym cm(3);
163 v->CovMatrix(cm);
164 SetVertex(v->GetX(), v->GetY(), v->GetZ(), v->GetChi2(), v->GetNDF(), v->GetNTracks(), cm);
165 // SetName(v->GetName());
166 SetTitle(v->GetTitle());
167}
168
169/* void CbmVertex::Copy(CbmVertex * v) {
170 TNamed::Copy(v);
171 CovMatrix(v->GetCovMatrix());
172
173
174 v->SetVertex(
175 GetX(),
176 GetY(),
177 GetZ(),
178 GetChi2(),
179 GetNDF(),
180 GetNTracks(),
181 GetCovMatrix());
182}
183 */
__m128 v
Definition P4_F32vec4.h:1
int i
Definition P4_F32vec4.h:22
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks, const TMatrixFSym &covMat)
void CopyFrom(CbmVertex *hdr)
void Reset()
void Print()
Definition CbmVertex.cxx:82
void CovMatrix(TMatrixFSym &covMat) const
virtual ~CbmVertex()
Definition CbmVertex.cxx:77
Double_t GetCovariance(Int_t i, Int_t j) const