1 /**************************************************************************
2 * Copyright(c) 1998-2007, 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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // AOD track base class
20 // Base class for Analysis Object Data
22 // Author: Markus Oldenburg, CERN
23 //-------------------------------------------------------------------------
25 #include "AliAODVertex.h"
27 ClassImp(AliAODVertex)
29 //______________________________________________________________________________
30 AliAODVertex::AliAODVertex() :
38 // default constructor
40 fPosition[0] = fPosition[1] = fPosition[2] = -999.;
43 //______________________________________________________________________________
44 AliAODVertex::AliAODVertex(const Double_t position[3],
45 const Double_t covMatrix[6],
58 SetPosition(position);
59 if (covMatrix) SetCovMatrix(covMatrix);
62 //______________________________________________________________________________
63 AliAODVertex::AliAODVertex(const Float_t position[3],
64 const Float_t covMatrix[6],
78 SetPosition(position);
79 if (covMatrix) SetCovMatrix(covMatrix);
82 //______________________________________________________________________________
83 AliAODVertex::AliAODVertex(const Double_t position[3],
93 // constructor without covariance matrix
95 SetPosition(position);
98 //______________________________________________________________________________
99 AliAODVertex::AliAODVertex(const Float_t position[3],
109 // constructor without covariance matrix
111 SetPosition(position);
114 //______________________________________________________________________________
115 AliAODVertex::~AliAODVertex()
122 //______________________________________________________________________________
123 AliAODVertex::AliAODVertex(const AliAODVertex& vtx) :
127 fParent(vtx.fParent),
128 fDaughters(vtx.fDaughters),
133 for (int i = 0; i < 3; i++)
134 fPosition[i] = vtx.fPosition[i];
136 if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix);
139 //______________________________________________________________________________
140 AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx)
142 // Assignment operator
146 TObject::operator=(vtx);
149 for (int i = 0; i < 3; i++)
150 fPosition[i] = vtx.fPosition[i];
157 if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix);
160 fParent = vtx.fParent;
161 fDaughters = vtx.fDaughters;
168 //______________________________________________________________________________
169 template <class T> void AliAODVertex::GetSigmaXYZ(T sigma[3]) const
171 // Return errors on vertex position in thrust frame
174 sigma[0]=fCovMatrix[3]; //GetCovXZ
175 sigma[1]=fCovMatrix[4]; //GetCovYZ
176 sigma[2]=fCovMatrix[5]; //GetCovZZ
178 sigma[0]=sigma[1]=sigma[2]=-999.;
181 for (int i = 0, j = 6; i < 3; i++) {
183 sigma[2-i] = fCovMatrix ? TMath::Sqrt(fCovMatrix[j]) : -999.;
188 //______________________________________________________________________________
189 Bool_t AliAODVertex::HasDaughter(TObject *daughter) const
191 // Checks if the given daughter (particle) is part of this vertex.
193 TRefArrayIter iter(&fDaughters);
194 while (TObject *daugh = iter.Next()) {
195 if (daugh == daughter) return kTRUE;
200 //______________________________________________________________________________
201 Double_t AliAODVertex::RotatedCovMatrixXX(Double_t phi, Double_t theta) const
203 // XX term of covariance matrix after rotation by phi around z-axis
204 // and, then, by theta around new y-axis
207 //AliFatal("Covariance matrix not set");
211 Double_t covMatrix[6];
213 GetCovMatrix(covMatrix);
215 Double_t cp = TMath::Cos(phi);
216 Double_t sp = TMath::Sin(phi);
217 Double_t ct = TMath::Cos(theta);
218 Double_t st = TMath::Sin(theta);
220 covMatrix[0]*cp*cp*ct*ct // GetCovXX
221 +covMatrix[1]*2.*cp*sp*ct*ct // GetCovXY
222 +covMatrix[3]*2.*cp*ct*st // GetCovXZ
223 +covMatrix[2]*sp*sp*ct*ct // GetCovYY
224 +covMatrix[4]*2.*sp*ct*st // GetCovYZ
225 +covMatrix[5]*st*st; // GetCovZZ
228 //______________________________________________________________________________
229 Double_t AliAODVertex::RotatedCovMatrixXY(Double_t phi, Double_t theta) const
231 // XY term of covariance matrix after rotation by phi around z-axis
232 // and, then, by theta around new y-axis
235 //AliFatal("Covariance matrix not set");
239 Double_t covMatrix[6];
241 GetCovMatrix(covMatrix);
243 Double_t cp = TMath::Cos(phi);
244 Double_t sp = TMath::Sin(phi);
245 Double_t ct = TMath::Cos(theta);
246 Double_t st = TMath::Sin(theta);
248 -covMatrix[0]*cp*sp*ct // GetCovXX
249 +covMatrix[1]*ct*(cp*cp-sp*sp) // GetCovXY
250 -covMatrix[3]*sp*st // GetCovXZ
251 +covMatrix[2]*cp*sp*ct // GetCovYY
252 +covMatrix[4]*cp*st; // GetCovYZ
255 //______________________________________________________________________________
256 Double_t AliAODVertex::RotatedCovMatrixXZ(Double_t phi, Double_t theta) const
258 // XZ term of covariance matrix after rotation by phi around z-axis
259 // and, then, by theta around new y-axis
262 //AliFatal("Covariance matrix not set");
266 Double_t covMatrix[6];
268 GetCovMatrix(covMatrix);
270 Double_t cp = TMath::Cos(phi);
271 Double_t sp = TMath::Sin(phi);
272 Double_t ct = TMath::Cos(theta);
273 Double_t st = TMath::Sin(theta);
275 -covMatrix[0]*cp*cp*ct*st // GetCovXX
276 -covMatrix[1]*2.*cp*sp*ct*st // GetCovXY
277 +covMatrix[3]*cp*(ct*ct-st*st) // GetCovXZ
278 -covMatrix[2]*sp*sp*ct*st // GetCovYY
279 +covMatrix[4]*sp*(ct*ct-st*st) // GetCovYZ
280 +covMatrix[5]*ct*st; // GetCovZZ
283 //______________________________________________________________________________
284 Double_t AliAODVertex::RotatedCovMatrixYY(Double_t phi) const
286 // YY term of covariance matrix after rotation by phi around z-axis
287 // and, then, by theta around new y-axis
290 //AliFatal("Covariance matrix not set");
294 Double_t covMatrix[6];
296 GetCovMatrix(covMatrix);
298 Double_t cp = TMath::Cos(phi);
299 Double_t sp = TMath::Sin(phi);
301 covMatrix[0]*sp*sp // GetCovXX
302 -covMatrix[1]*2.*cp*sp // GetCovXY
303 +covMatrix[2]*cp*cp; // GetCovYY
306 //______________________________________________________________________________
307 Double_t AliAODVertex::RotatedCovMatrixYZ(Double_t phi, Double_t theta) const
309 // YZ term of covariance matrix after rotation by phi around z-axis
310 // and, then, by theta around new y-axis
313 //AliFatal("Covariance matrix not set");
317 Double_t covMatrix[6];
319 GetCovMatrix(covMatrix);
321 Double_t cp = TMath::Cos(phi);
322 Double_t sp = TMath::Sin(phi);
323 Double_t ct = TMath::Cos(theta);
324 Double_t st = TMath::Sin(theta);
326 covMatrix[0]*cp*sp*st // GetCovXX
327 +covMatrix[1]*st*(sp*sp-cp*cp) // GetCovXY
328 -covMatrix[3]*sp*ct // GetCovXZ
329 -covMatrix[2]*cp*sp*st // GetCovYY
330 +covMatrix[4]*cp*ct; // GetCovYZ
333 //______________________________________________________________________________
334 Double_t AliAODVertex::RotatedCovMatrixZZ(Double_t phi, Double_t theta) const
336 // ZZ term of covariance matrix after rotation by phi around z-axis
337 // and, then, by theta around new y-axis
340 //AliFatal("Covariance matrix not set");
344 Double_t covMatrix[6];
346 GetCovMatrix(covMatrix);
348 Double_t cp = TMath::Cos(phi);
349 Double_t sp = TMath::Sin(phi);
350 Double_t ct = TMath::Cos(theta);
351 Double_t st = TMath::Sin(theta);
353 covMatrix[0]*cp*cp*st*st // GetCovXX
354 +covMatrix[1]*2.*cp*sp*st*st // GetCovXY
355 -covMatrix[3]*2.*cp*ct*st // GetCovXZ
356 +covMatrix[2]*sp*sp*st*st // GetCovYY
357 -covMatrix[4]*2.*sp*sp*ct*st // GetCovYZ
358 +covMatrix[5]*ct*ct; // GetCovZZ
361 //______________________________________________________________________________
362 Double_t AliAODVertex::DistanceToVertex(AliAODVertex *vtx) const
364 // distance in 3D to another AliAODVertex
366 Double_t dx = GetX()-vtx->GetX();
367 Double_t dy = GetY()-vtx->GetY();
368 Double_t dz = GetZ()-vtx->GetZ();
370 return TMath::Sqrt(dx*dx+dy*dy+dz*dz);
373 //______________________________________________________________________________
374 Double_t AliAODVertex::DistanceXYToVertex(AliAODVertex *vtx) const
376 // distance in XY to another AliAODVertex
378 Double_t dx = GetX()-vtx->GetX();
379 Double_t dy = GetY()-vtx->GetY();
381 return TMath::Sqrt(dx*dx+dy*dy);
384 //______________________________________________________________________________
385 Double_t AliAODVertex::ErrorDistanceToVertex(AliAODVertex *vtx) const
387 // error on the distance in 3D to another AliAODVertex
390 PhiAndThetaToVertex(vtx,phi,theta);
391 // error2 due to this vertex
392 Double_t error2 = RotatedCovMatrixXX(phi,theta);
393 // error2 due to vtx vertex
394 Double_t error2vtx = vtx->RotatedCovMatrixXX(phi,theta);
396 return TMath::Sqrt(error2+error2vtx);
399 //______________________________________________________________________________
400 Double_t AliAODVertex::ErrorDistanceXYToVertex(AliAODVertex *vtx) const
402 // error on the distance in XY to another AliAODVertex
405 PhiAndThetaToVertex(vtx,phi,theta);
406 // error2 due to this vertex
407 Double_t error2 = RotatedCovMatrixXX(phi);
408 // error2 due to vtx vertex
409 Double_t error2vtx = vtx->RotatedCovMatrixXX(phi);
411 return TMath::Sqrt(error2+error2vtx);
414 //______________________________________________________________________________
415 template <class T, class P>
416 void AliAODVertex::PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) const
418 // rotation angles around z-axis (phi) and around new y-axis (theta)
419 // with which vtx is seen (used by RotatedCovMatrix... methods)
421 phi = TMath::ATan2(vtx->GetY()-GetY(),vtx->GetX()-GetX());
422 Double_t vtxxphi = vtx->GetX()*TMath::Cos(phi)+vtx->GetY()*TMath::Sin(phi);
423 Double_t xphi = GetX()*TMath::Cos(phi)+GetY()*TMath::Sin(phi);
424 theta = TMath::ATan2(vtx->GetZ()-GetZ(),vtxxphi-xphi);
427 //______________________________________________________________________________
428 void AliAODVertex::PrintIndices() const
430 // Print indices of particles originating form this vertex
432 TRefArrayIter iter(&fDaughters);
433 while (TObject *daugh = iter.Next()) {
434 printf("Particle %p originates from this vertex.\n", daugh);
438 //______________________________________________________________________________
439 void AliAODVertex::Print(Option_t* /*option*/) const
441 // Print information of all data members
443 printf("Vertex position:\n");
444 printf(" x = %f\n", fPosition[0]);
445 printf(" y = %f\n", fPosition[1]);
446 printf(" z = %f\n", fPosition[2]);
447 printf(" parent particle: %p\n", fParent.GetObject());
448 printf(" origin of %d particles\n", fDaughters.GetEntriesFast());
449 printf(" vertex type %d\n", fType);
453 printf("Covariance matrix:\n");
454 printf(" %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n",
465 printf(" Chi^2 = %f\n", fChi2);