]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliESDVertex.cxx
Updates in event mixing code for low-pt code
[u/mrichter/AliRoot.git] / STEER / ESD / 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
de04aa35 21// Origin: A.Dainese, andrea.dainese@lnl.infn.it
c5f0f3c1 22//-----------------------------------------------------------------
23
24//---- standard headers ----
8ba665e9 25#include "Riostream.h"
c5f0f3c1 26//---- Root headers --------
504de69b 27#include <TMath.h>
504de69b 28#include <TROOT.h>
3f2db92f 29#include <TMatrixDSym.h>
c5f0f3c1 30//---- AliRoot headers -----
d681bb2d 31#include "AliESDVertex.h"
3f2db92f 32#include "AliVTrack.h"
33#include "AliLog.h"
504de69b 34
d681bb2d 35ClassImp(AliESDVertex)
504de69b 36
c5f0f3c1 37//--------------------------------------------------------------------------
90e48c0c 38AliESDVertex::AliESDVertex() :
8a553be2 39 AliVertex(),
90e48c0c 40 fCovXX(0.005*0.005),
41 fCovXY(0),
42 fCovYY(0.005*0.005),
43 fCovXZ(0),
44 fCovYZ(0),
45 fCovZZ(5.3*5.3),
6dc21f57 46 fChi2(0),
3f2db92f 47 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
48 fBCID(AliVTrack::kTOFBCNA)
90e48c0c 49{
50 //
51 // Default Constructor, set everything to 0
52 //
0fc5cc25 53 SetToZero();
c5f0f3c1 54}
90e48c0c 55
c5f0f3c1 56//--------------------------------------------------------------------------
d681bb2d 57AliESDVertex::AliESDVertex(Double_t positionZ,Double_t sigmaZ,
90e48c0c 58 Int_t nContributors,const Char_t *vtxName) :
8a553be2 59 AliVertex(),
90e48c0c 60 fCovXX(0.005*0.005),
61 fCovXY(0),
62 fCovYY(0.005*0.005),
63 fCovXZ(0),
64 fCovYZ(0),
65 fCovZZ(sigmaZ*sigmaZ),
6dc21f57 66 fChi2(0),
3f2db92f 67 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
68 fBCID(AliVTrack::kTOFBCNA)
90e48c0c 69{
0fc5cc25 70 //
71 // Constructor for vertex Z from pixels
72 //
c5f0f3c1 73
0fc5cc25 74 SetToZero();
c5f0f3c1 75
0fc5cc25 76 fPosition[2] = positionZ;
8a553be2 77 SetName(vtxName);
78 SetNContributors(nContributors);
c5f0f3c1 79
c5f0f3c1 80}
90e48c0c 81
c5f0f3c1 82//-------------------------------------------------------------------------
d681bb2d 83AliESDVertex::AliESDVertex(Double_t position[3],Double_t covmatrix[6],
90e48c0c 84 Double_t chi2,Int_t nContributors,
85 const Char_t *vtxName) :
8a553be2 86 AliVertex(position,0.,nContributors),
90e48c0c 87 fCovXX(covmatrix[0]),
88 fCovXY(covmatrix[1]),
89 fCovYY(covmatrix[2]),
90 fCovXZ(covmatrix[3]),
91 fCovYZ(covmatrix[4]),
92 fCovZZ(covmatrix[5]),
6dc21f57 93 fChi2(chi2),
3f2db92f 94 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
95 fBCID(AliVTrack::kTOFBCNA)
90e48c0c 96{
97 //
98 // Constructor for vertex in 3D from tracks
99 //
0fc5cc25 100
101 SetToZero();
8a553be2 102 SetName(vtxName);
c5f0f3c1 103
cd77595e 104}
c5f0f3c1 105//--------------------------------------------------------------------------
d681bb2d 106AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
90e48c0c 107 const Char_t *vtxName) :
8a553be2 108 AliVertex(position,0.,0),
90e48c0c 109 fCovXX(sigma[0]*sigma[0]),
110 fCovXY(0),
111 fCovYY(sigma[1]*sigma[1]),
112 fCovXZ(0),
113 fCovYZ(0),
114 fCovZZ(sigma[2]*sigma[2]),
6dc21f57 115 fChi2(0),
3f2db92f 116 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
117 fBCID(AliVTrack::kTOFBCNA)
90e48c0c 118{
119 //
120 // Constructor for smearing of true position
121 //
0fc5cc25 122
123 SetToZero();
8a553be2 124 SetName(vtxName);
c5f0f3c1 125
c5f0f3c1 126}
127//--------------------------------------------------------------------------
d681bb2d 128AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
90e48c0c 129 Double_t snr[3], const Char_t *vtxName) :
8a553be2 130 AliVertex(position,0.,0),
90e48c0c 131 fCovXX(sigma[0]*sigma[0]),
132 fCovXY(0),
133 fCovYY(sigma[1]*sigma[1]),
134 fCovXZ(0),
135 fCovYZ(0),
136 fCovZZ(sigma[2]*sigma[2]),
6dc21f57 137 fChi2(0),
3f2db92f 138 fID(-1), // ID=-1 means the vertex with the biggest number of contributors
139 fBCID(AliVTrack::kTOFBCNA)
90e48c0c 140{
0fc5cc25 141 //
142 // Constructor for Pb-Pb
143 //
144
145 SetToZero();
8a553be2 146 SetName(vtxName);
0fc5cc25 147
148 fSNR[0] = snr[0];
149 fSNR[1] = snr[1];
150 fSNR[2] = snr[2];
151
0fc5cc25 152}
de04aa35 153//--------------------------------------------------------------------------
154AliESDVertex::AliESDVertex(const AliESDVertex &source):
155 AliVertex(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),
6dc21f57 162 fChi2(source.fChi2),
3f2db92f 163 fID(source.fID),
164 fBCID(source.fBCID)
de04aa35 165{
166 //
167 // Copy constructor
168 //
169 for(Int_t i=0;i<3;i++) {
170 fSNR[i] = source.fSNR[i];
de04aa35 171 }
172}
173//--------------------------------------------------------------------------
174AliESDVertex &AliESDVertex::operator=(const AliESDVertex &source){
175 //
176 // assignment operator
177 //
316c6cd9 178 if(&source != this){
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;
6dc21f57 188 fID = source.fID;
3f2db92f 189 fBCID = source.fBCID;
de04aa35 190 }
191 return *this;
192}
bdd011d6 193//--------------------------------------------------------------------------
732a24fe 194void AliESDVertex::Copy(TObject &obj) const {
195
196 // this overwrites the virtual TOBject::Copy()
197 // to allow run time copying without casting
198 // in AliESDEvent
199
200 if(this==&obj)return;
201 AliESDVertex *robj = dynamic_cast<AliESDVertex*>(&obj);
202 if(!robj)return; // not an AliESDVertex
203 *robj = *this;
204
205}
0fc5cc25 206//--------------------------------------------------------------------------
d681bb2d 207void AliESDVertex::SetToZero() {
0fc5cc25 208 //
90e48c0c 209 // Set the content of arrays to 0. Used by constructors
0fc5cc25 210 //
211 for(Int_t i=0; i<3; i++){
0fc5cc25 212 fSNR[i] = 0.;
213 }
c5f0f3c1 214}
215//--------------------------------------------------------------------------
d681bb2d 216void AliESDVertex::GetSigmaXYZ(Double_t sigma[3]) const {
de04aa35 217 //
218 // Return errors on vertex position in thrust frame
219 //
c5f0f3c1 220 sigma[0] = TMath::Sqrt(fCovXX);
221 sigma[1] = TMath::Sqrt(fCovYY);
222 sigma[2] = TMath::Sqrt(fCovZZ);
223
224 return;
cd77595e 225}
c5f0f3c1 226//--------------------------------------------------------------------------
d681bb2d 227void AliESDVertex::GetCovMatrix(Double_t covmatrix[6]) const {
de04aa35 228 //
229 // Return covariance matrix of the vertex
230 //
c5f0f3c1 231 covmatrix[0] = fCovXX;
232 covmatrix[1] = fCovXY;
233 covmatrix[2] = fCovYY;
234 covmatrix[3] = fCovXZ;
235 covmatrix[4] = fCovYZ;
236 covmatrix[5] = fCovZZ;
237
238 return;
cd77595e 239}
8a553be2 240
3f2db92f 241//--------------------------------------------------------------------------
242void AliESDVertex::SetCovarianceMatrix(const Double_t *covmatrix) {
243 //
244 // Return covariance matrix of the vertex
245 //
246 fCovXX = covmatrix[0];
247 fCovXY = covmatrix[1];
248 fCovYY = covmatrix[2];
249 fCovXZ = covmatrix[3];
250 fCovYZ = covmatrix[4];
251 fCovZZ = covmatrix[5];
252
253 return;
254}
255
c5f0f3c1 256//--------------------------------------------------------------------------
d681bb2d 257void AliESDVertex::GetSNR(Double_t snr[3]) const {
de04aa35 258 //
259 // Return S/N ratios
260 //
c5f0f3c1 261 for(Int_t i=0;i<3;i++) snr[i] = fSNR[i];
262
263 return;
264}
265//--------------------------------------------------------------------------
5f7789fc 266void AliESDVertex::Print(Option_t* /*option*/) const {
de04aa35 267 //
268 // Print out information on all data members
269 //
5f7789fc 270 printf("ESD vertex position:\n");
c8be84e4 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.);
c5f0f3c1 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);
3f2db92f 278 printf(" # tracks (or tracklets) = %d BCID=%d\n",fNContributors,int(fBCID));
c8be84e4 279 //
280 if (fCovXX<0 || fCovYY<0 || fCovZZ<0) {AliError("Attention: negative diagonal element");}
281 //
c5f0f3c1 282 return;
283}
284
285
3f2db92f 286//____________________________________________________________
287Double_t AliESDVertex::GetWDist(const AliESDVertex* v) const
288{
289 // calculate sqrt of weighted distance to other vertex
290 static TMatrixDSym vVb(3);
291 double dist = -1;
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.;
298 vVb.InvertFast();
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;
303}