1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-----------------------------------------------------------------
17 // Implementation of the Primary Vertex class
18 // for the Event Data Summary class
19 // This class contains the Primary Vertex
20 // of the event coming from reconstruction
21 // Origin: A.Dainese, andrea.dainese@lnl.infn.it
22 //-----------------------------------------------------------------
24 //---- standard headers ----
25 #include "Riostream.h"
26 //---- Root headers --------
29 #include <TMatrixDSym.h>
30 //---- AliRoot headers -----
31 #include "AliESDVertex.h"
32 #include "AliVTrack.h"
35 ClassImp(AliESDVertex)
37 //--------------------------------------------------------------------------
38 AliESDVertex::AliESDVertex() :
47 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
48 fBCID(AliVTrack::kTOFBCNA)
51 // Default Constructor, set everything to 0
56 //--------------------------------------------------------------------------
57 AliESDVertex::AliESDVertex(Double_t positionZ,Double_t sigmaZ,
58 Int_t nContributors,const Char_t *vtxName) :
65 fCovZZ(sigmaZ*sigmaZ),
67 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
68 fBCID(AliVTrack::kTOFBCNA)
71 // Constructor for vertex Z from pixels
76 fPosition[2] = positionZ;
78 SetNContributors(nContributors);
82 //-------------------------------------------------------------------------
83 AliESDVertex::AliESDVertex(Double_t position[3],Double_t covmatrix[6],
84 Double_t chi2,Int_t nContributors,
85 const Char_t *vtxName) :
86 AliVertex(position,0.,nContributors),
94 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
95 fBCID(AliVTrack::kTOFBCNA)
98 // Constructor for vertex in 3D from tracks
105 //--------------------------------------------------------------------------
106 AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
107 const Char_t *vtxName) :
108 AliVertex(position,0.,0),
109 fCovXX(sigma[0]*sigma[0]),
111 fCovYY(sigma[1]*sigma[1]),
114 fCovZZ(sigma[2]*sigma[2]),
116 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
117 fBCID(AliVTrack::kTOFBCNA)
120 // Constructor for smearing of true position
127 //--------------------------------------------------------------------------
128 AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
129 Double_t snr[3], const Char_t *vtxName) :
130 AliVertex(position,0.,0),
131 fCovXX(sigma[0]*sigma[0]),
133 fCovYY(sigma[1]*sigma[1]),
136 fCovZZ(sigma[2]*sigma[2]),
138 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
139 fBCID(AliVTrack::kTOFBCNA)
142 // Constructor for Pb-Pb
153 //--------------------------------------------------------------------------
154 AliESDVertex::AliESDVertex(const AliESDVertex &source):
156 fCovXX(source.fCovXX),
157 fCovXY(source.fCovXY),
158 fCovYY(source.fCovYY),
159 fCovXZ(source.fCovXZ),
160 fCovYZ(source.fCovYZ),
161 fCovZZ(source.fCovZZ),
169 for(Int_t i=0;i<3;i++) {
170 fSNR[i] = source.fSNR[i];
173 //--------------------------------------------------------------------------
174 AliESDVertex &AliESDVertex::operator=(const AliESDVertex &source){
176 // assignment operator
179 AliVertex::operator=(source);
180 for(Int_t i=0;i<3;++i)fSNR[i] = source.fSNR[i];
181 fCovXX = source.fCovXX;
182 fCovXY = source.fCovXY;
183 fCovYY = source.fCovYY;
184 fCovXZ = source.fCovXZ;
185 fCovYZ = source.fCovYZ;
186 fCovZZ = source.fCovZZ;
187 fChi2 = source.fChi2;
189 fBCID = source.fBCID;
193 //--------------------------------------------------------------------------
194 void AliESDVertex::Copy(TObject &obj) const {
196 // this overwrites the virtual TOBject::Copy()
197 // to allow run time copying without casting
200 if(this==&obj)return;
201 AliESDVertex *robj = dynamic_cast<AliESDVertex*>(&obj);
202 if(!robj)return; // not an AliESDVertex
206 //--------------------------------------------------------------------------
207 void AliESDVertex::SetToZero() {
209 // Set the content of arrays to 0. Used by constructors
211 for(Int_t i=0; i<3; i++){
215 //--------------------------------------------------------------------------
216 void AliESDVertex::GetSigmaXYZ(Double_t sigma[3]) const {
218 // Return errors on vertex position in thrust frame
220 sigma[0] = TMath::Sqrt(fCovXX);
221 sigma[1] = TMath::Sqrt(fCovYY);
222 sigma[2] = TMath::Sqrt(fCovZZ);
226 //--------------------------------------------------------------------------
227 void AliESDVertex::GetCovMatrix(Double_t covmatrix[6]) const {
229 // Return covariance matrix of the vertex
231 covmatrix[0] = fCovXX;
232 covmatrix[1] = fCovXY;
233 covmatrix[2] = fCovYY;
234 covmatrix[3] = fCovXZ;
235 covmatrix[4] = fCovYZ;
236 covmatrix[5] = fCovZZ;
241 //--------------------------------------------------------------------------
242 void AliESDVertex::SetCovarianceMatrix(const Double_t *covmatrix) {
244 // Return covariance matrix of the vertex
246 fCovXX = covmatrix[0];
247 fCovXY = covmatrix[1];
248 fCovYY = covmatrix[2];
249 fCovXZ = covmatrix[3];
250 fCovYZ = covmatrix[4];
251 fCovZZ = covmatrix[5];
256 //--------------------------------------------------------------------------
257 void AliESDVertex::GetSNR(Double_t snr[3]) const {
261 for(Int_t i=0;i<3;i++) snr[i] = fSNR[i];
265 //--------------------------------------------------------------------------
266 void AliESDVertex::Print(Option_t* /*option*/) const {
268 // Print out information on all data members
270 printf("ESD vertex position:\n");
271 printf(" x = %f +- %f\n",fPosition[0], fCovXX>0 ? TMath::Sqrt(fCovXX) : 0.);
272 printf(" y = %f +- %f\n",fPosition[1], fCovYY>0 ? TMath::Sqrt(fCovYY) : 0.);
273 printf(" z = %f +- %f\n",fPosition[2], fCovZZ>0 ? TMath::Sqrt(fCovZZ) : 0.);
274 printf(" Covariance matrix:\n");
275 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);
276 printf(" S/N = (%f, %f, %f)\n",fSNR[0],fSNR[1],fSNR[2]);
277 printf(" chi2 = %f\n",fChi2);
278 printf(" # tracks (or tracklets) = %d BCID=%d\n",fNContributors,int(fBCID));
280 if (fCovXX<0 || fCovYY<0 || fCovZZ<0) {AliError("Attention: negative diagonal element");}
286 //____________________________________________________________
287 Double_t AliESDVertex::GetWDist(const AliESDVertex* v) const
289 // calculate sqrt of weighted distance to other vertex
290 static TMatrixDSym vVb(3);
292 double dx = fPosition[0]-v->fPosition[0], dy = fPosition[1]-v->fPosition[1], dz = fPosition[2]-v->fPosition[2];
293 vVb(0,0) = fCovXX + v->fCovXX;
294 vVb(1,1) = fCovYY + v->fCovYY;
295 vVb(2,2) = fCovZZ + v->fCovZZ;;
296 vVb(1,0) = vVb(0,1) = fCovXY + v->fCovXY;
297 vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;
299 if (!vVb.IsValid()) {AliError("Singular Matrix"); return dist;}
300 dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz
301 + 2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;
302 return dist>0 ? TMath::Sqrt(dist) : -1;