Changes suggested by Effective C++ (F.Carminati)
[u/mrichter/AliRoot.git] / STEER / AliESDVertex.cxx
CommitLineData
c5f0f3c1 1/**************************************************************************
0fc5cc25 2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
c5f0f3c1 3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//-----------------------------------------------------------------
17// Implementation of the Primary Vertex class
af7ba10c 18// for the Event Data Summary class
19// This class contains the Primary Vertex
20// of the event coming from reconstruction
c5f0f3c1 21// Origin: A.Dainese, Padova, andrea.dainese@pd.infn.it
22//-----------------------------------------------------------------
23
24//---- standard headers ----
8ba665e9 25#include "Riostream.h"
c5f0f3c1 26//---- Root headers --------
504de69b 27#include <TMath.h>
504de69b 28#include <TROOT.h>
c5f0f3c1 29//---- AliRoot headers -----
d681bb2d 30#include "AliESDVertex.h"
504de69b 31
32
d681bb2d 33ClassImp(AliESDVertex)
504de69b 34
c5f0f3c1 35//--------------------------------------------------------------------------
90e48c0c 36AliESDVertex::AliESDVertex() :
37 TNamed(),
38 fCovXX(0.005*0.005),
39 fCovXY(0),
40 fCovYY(0.005*0.005),
41 fCovXZ(0),
42 fCovYZ(0),
43 fCovZZ(5.3*5.3),
44 fChi2(0),
45 fNContributors(0)
46{
47 //
48 // Default Constructor, set everything to 0
49 //
0fc5cc25 50 SetToZero();
c5f0f3c1 51}
90e48c0c 52
c5f0f3c1 53//--------------------------------------------------------------------------
d681bb2d 54AliESDVertex::AliESDVertex(Double_t positionZ,Double_t sigmaZ,
90e48c0c 55 Int_t nContributors,const Char_t *vtxName) :
56 TNamed(vtxName,""),
57 fCovXX(0.005*0.005),
58 fCovXY(0),
59 fCovYY(0.005*0.005),
60 fCovXZ(0),
61 fCovYZ(0),
62 fCovZZ(sigmaZ*sigmaZ),
63 fChi2(0),
64 fNContributors(nContributors)
65{
0fc5cc25 66 //
67 // Constructor for vertex Z from pixels
68 //
c5f0f3c1 69
0fc5cc25 70 SetToZero();
c5f0f3c1 71
0fc5cc25 72 fPosition[2] = positionZ;
c5f0f3c1 73
c5f0f3c1 74}
90e48c0c 75
c5f0f3c1 76//-------------------------------------------------------------------------
d681bb2d 77AliESDVertex::AliESDVertex(Double_t position[3],Double_t covmatrix[6],
90e48c0c 78 Double_t chi2,Int_t nContributors,
79 const Char_t *vtxName) :
80 TNamed(vtxName,""),
81 fCovXX(covmatrix[0]),
82 fCovXY(covmatrix[1]),
83 fCovYY(covmatrix[2]),
84 fCovXZ(covmatrix[3]),
85 fCovYZ(covmatrix[4]),
86 fCovZZ(covmatrix[5]),
87 fChi2(chi2),
88 fNContributors(nContributors)
89{
90 //
91 // Constructor for vertex in 3D from tracks
92 //
0fc5cc25 93
94 SetToZero();
90e48c0c 95 fPosition[0] = position[0];
96 fPosition[1] = position[1];
97 fPosition[2] = position[2];
c5f0f3c1 98
cd77595e 99}
c5f0f3c1 100//--------------------------------------------------------------------------
d681bb2d 101AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
90e48c0c 102 const Char_t *vtxName) :
103 TNamed(vtxName,""),
104 fCovXX(sigma[0]*sigma[0]),
105 fCovXY(0),
106 fCovYY(sigma[1]*sigma[1]),
107 fCovXZ(0),
108 fCovYZ(0),
109 fCovZZ(sigma[2]*sigma[2]),
110 fChi2(0),
111 fNContributors(0)
112{
113 //
114 // Constructor for smearing of true position
115 //
0fc5cc25 116
117 SetToZero();
90e48c0c 118 fPosition[0] = position[0];
119 fPosition[1] = position[1];
120 fPosition[2] = position[2];
c5f0f3c1 121
c5f0f3c1 122}
123//--------------------------------------------------------------------------
d681bb2d 124AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
90e48c0c 125 Double_t snr[3], const Char_t *vtxName) :
126 TNamed(vtxName,""),
127 fCovXX(sigma[0]*sigma[0]),
128 fCovXY(0),
129 fCovYY(sigma[1]*sigma[1]),
130 fCovXZ(0),
131 fCovYZ(0),
132 fCovZZ(sigma[2]*sigma[2]),
133 fChi2(0),
134 fNContributors(0)
135{
0fc5cc25 136 //
137 // Constructor for Pb-Pb
138 //
139
140 SetToZero();
141 fPosition[0] = position[0];
142 fPosition[1] = position[1];
143 fPosition[2] = position[2];
0fc5cc25 144
145 fSNR[0] = snr[0];
146 fSNR[1] = snr[1];
147 fSNR[2] = snr[2];
148
0fc5cc25 149}
90e48c0c 150
0fc5cc25 151//--------------------------------------------------------------------------
d681bb2d 152void AliESDVertex::SetToZero() {
0fc5cc25 153 //
90e48c0c 154 // Set the content of arrays to 0. Used by constructors
0fc5cc25 155 //
156 for(Int_t i=0; i<3; i++){
157 fPosition[i] = 0.;
158 fTruePos[i] = 0;
159 fSNR[i] = 0.;
160 }
c5f0f3c1 161}
162//--------------------------------------------------------------------------
d681bb2d 163AliESDVertex::~AliESDVertex() {
c5f0f3c1 164//
90e48c0c 165// Destructor
c5f0f3c1 166//
0fc5cc25 167
c5f0f3c1 168}
169//--------------------------------------------------------------------------
d681bb2d 170void AliESDVertex::GetXYZ(Double_t position[3]) const {
c5f0f3c1 171//
172// Return position of the vertex in global frame
173//
c5f0f3c1 174 position[0] = fPosition[0];
175 position[1] = fPosition[1];
176 position[2] = fPosition[2];
177
178 return;
179}
180//--------------------------------------------------------------------------
d681bb2d 181void AliESDVertex::GetSigmaXYZ(Double_t sigma[3]) const {
c5f0f3c1 182//
c5f0f3c1 183// Return errors on vertex position in thrust frame
184//
185 sigma[0] = TMath::Sqrt(fCovXX);
186 sigma[1] = TMath::Sqrt(fCovYY);
187 sigma[2] = TMath::Sqrt(fCovZZ);
188
189 return;
cd77595e 190}
c5f0f3c1 191//--------------------------------------------------------------------------
d681bb2d 192void AliESDVertex::GetCovMatrix(Double_t covmatrix[6]) const {
c5f0f3c1 193//
194// Return covariance matrix of the vertex
195//
c5f0f3c1 196 covmatrix[0] = fCovXX;
197 covmatrix[1] = fCovXY;
198 covmatrix[2] = fCovYY;
199 covmatrix[3] = fCovXZ;
200 covmatrix[4] = fCovYZ;
201 covmatrix[5] = fCovZZ;
202
203 return;
cd77595e 204}
c5f0f3c1 205//--------------------------------------------------------------------------
d681bb2d 206Double_t AliESDVertex::GetXv() const {
c5f0f3c1 207//
208// Return global x
209//
11ba84a4 210 return fPosition[0];
c5f0f3c1 211}
212//--------------------------------------------------------------------------
d681bb2d 213Double_t AliESDVertex::GetYv() const {
c5f0f3c1 214//
215// Return global y
216//
11ba84a4 217 return fPosition[1];
c5f0f3c1 218}
219//--------------------------------------------------------------------------
d681bb2d 220Double_t AliESDVertex::GetZv() const {
c5f0f3c1 221//
222// Return global z
223//
224 return fPosition[2];
225}
226//--------------------------------------------------------------------------
d681bb2d 227Double_t AliESDVertex::GetXRes() const {
c5f0f3c1 228//
229// Return error on global x
230//
11ba84a4 231 return TMath::Sqrt(fCovXX);
c5f0f3c1 232}
233//--------------------------------------------------------------------------
d681bb2d 234Double_t AliESDVertex::GetYRes() const {
c5f0f3c1 235//
236// Return error on global y
237//
11ba84a4 238 return TMath::Sqrt(fCovYY);
c5f0f3c1 239}
240//--------------------------------------------------------------------------
d681bb2d 241Double_t AliESDVertex::GetZRes() const {
c5f0f3c1 242//
243// Return error on global z
244//
11ba84a4 245 return TMath::Sqrt(fCovZZ);
c5f0f3c1 246}
247//--------------------------------------------------------------------------
d681bb2d 248void AliESDVertex::GetSNR(Double_t snr[3]) const {
c5f0f3c1 249//
250// Return S/N ratios
251//
252 for(Int_t i=0;i<3;i++) snr[i] = fSNR[i];
253
254 return;
255}
256//--------------------------------------------------------------------------
5f7789fc 257void AliESDVertex::Print(Option_t* /*option*/) const {
c5f0f3c1 258//
259// Print out information on all data members
260//
5f7789fc 261 printf("ESD vertex position:\n");
c5f0f3c1 262 printf(" x = %f +- %f\n",fPosition[0],TMath::Sqrt(fCovXX));
263 printf(" y = %f +- %f\n",fPosition[1],TMath::Sqrt(fCovYY));
264 printf(" z = %f +- %f\n",fPosition[2],TMath::Sqrt(fCovZZ));
265 printf(" Covariance matrix:\n");
266 printf(" %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n",fCovXX,fCovXY,fCovXZ,fCovXY,fCovYY,fCovYZ,fCovXZ,fCovYZ,fCovZZ);
267 printf(" S/N = (%f, %f, %f)\n",fSNR[0],fSNR[1],fSNR[2]);
268 printf(" chi2 = %f\n",fChi2);
269 printf(" # tracks (or tracklets) = %d\n",fNContributors);
270
0fc5cc25 271 printf(" True vertex position - for comparison: %12.10f %12.10f %12.10f\n ",fTruePos[0],fTruePos[1],fTruePos[2]);
272
c5f0f3c1 273 return;
274}
275
276
277
6b88f180 278