EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmVertex.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmVertex.cxx
1 // -------------------------------------------------------------------------
2 // ----- CbmVertex source file -----
3 // ----- Created 28/11/05 by V. Friese -----
4 // -------------------------------------------------------------------------
5 #include "CbmVertex.h"
6 
7 #include <iostream>
8 
9 using std::cout;
10 using std::endl;
11 
12 
13 // ----- Default constructor -------------------------------------------
15  : TNamed("Vertex", "Global"),
16  fX(0.),
17  fY(0.),
18  fZ(0.),
19  fChi2(0.),
20  fNDF(0),
21  fNTracks(0),
22  fCovMatrix()
23 {
24  for(Int_t i=0; i<6; i++) fCovMatrix[i] = 0;
25 }
26 // -------------------------------------------------------------------------
27 
28 
29 
30 // ----- Constructor with name and title -------------------------------
31 CbmVertex::CbmVertex(const char* name, const char* title)
32  : TNamed(name, title),
33  fX(0.),
34  fY(0.),
35  fZ(0.),
36  fChi2(0.),
37  fNDF(0),
38  fNTracks(0),
39  fCovMatrix()
40 {
41  for(Int_t i=0; i<6; i++) fCovMatrix[i] = 0;
42 }
43 // -------------------------------------------------------------------------
44 
45 
46 
47 // ----- Constructor with all parameters -------------------------------
48 CbmVertex::CbmVertex(const char* name, const char* title,
49  Double_t x, Double_t y, Double_t z, Double_t chi2,
50  Int_t ndf, Int_t nTracks,
51  const TMatrixFSym& covMat)
52  : TNamed(name, title),
53  fX(x),
54  fY(y),
55  fZ(z),
56  fChi2(chi2),
57  fNDF(ndf),
58  fNTracks(nTracks),
59  fCovMatrix()
60 {
61  /*
62  fTitle = title;
63  fX = x;
64  fY = y;
65  fZ = z;
66  fChi2 = chi2;
67  fNDF = ndf;
68  fNTracks = nTracks;
69  */
70  Int_t index = 0;
71  for (Int_t i=0; i<3; i++) {
72  for (Int_t j=i; j<3; j++) fCovMatrix[index++] = covMat[i][j];
73  }
74 }
75 // -------------------------------------------------------------------------
76 
77 
78 
79 // ----- Destructor ----------------------------------------------------
81 // -------------------------------------------------------------------------
82 
83 
84 
85 // ----- Public method Print -------------------------------------------
87  Double_t chi2ndf;
88  if (fNDF) chi2ndf = fChi2 / Double_t(fNDF);
89  else chi2ndf = 0.;
90  cout << "Vertex coord. (" << fX << "," << fY << "," << fZ << ") cm, "
91  << "chi2/ndf = " << chi2ndf << ", " << fNTracks
92  << " tracks used" << endl;
93 }
94 // -------------------------------------------------------------------------
95 
96 
97 
98 // ----- Accessor to covariance matrix --------------------------------
99 void CbmVertex::CovMatrix(TMatrixFSym& covMat) const {
100  Int_t index = 0;
101  for (int i=0; i<3; i++) {
102  for (int j=i; j<3; j++) {
103  covMat[i][j] = fCovMatrix[index];
104  covMat[j][i] = fCovMatrix[index];
105  index++;
106  }
107  }
108 }
109 // -------------------------------------------------------------------------
110 
111 
112 
113 // ----- Accessor to covariance matrix elements ------------------------
114 Double_t CbmVertex::GetCovariance(Int_t i, Int_t j) const {
115  TMatrixFSym* mat = new TMatrixFSym(3);
116  CovMatrix(*mat);
117  Double_t element = (*mat)[i][j];
118  delete mat;
119  return element;
120 }
121 // -------------------------------------------------------------------------
122 
123 
124 
125 // ----- Public method SetVertex ---------------------------------------
126 void CbmVertex::SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2,
127  Int_t ndf, Int_t nTracks,
128  const TMatrixFSym& covMat) {
129  fX = x;
130  fY = y;
131  fZ = z;
132  fChi2 = chi2;
133  fNDF = ndf;
134  fNTracks = nTracks;
135  Int_t index = 0;
136  for (Int_t i=0; i<3; i++) {
137  for (Int_t j=i; j<3; j++) fCovMatrix[index++] = covMat[i][j];
138  }
139 }
140 // -------------------------------------------------------------------------
141 
142 
143 
144 // ----- Public method Reset -------------------------------------------
146  fX = fY = fZ = fChi2 = 0.;
147  fNDF = fNTracks = 0;
148  for(Int_t i=0; i<6; i++) fCovMatrix[i] = 0;
149 }
150 // -------------------------------------------------------------------------
151 
152 
153