]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AOD/AliAODVertex.h
STEER CMakeList files
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODVertex.h
CommitLineData
26ba01d4 1#ifndef ALIAODVERTEX_H
2#define ALIAODVERTEX_H
df9db588 3/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
8//-------------------------------------------------------------------------
9// AOD vertex base class
10// Author: Markus Oldenburg, CERN
bdd011d6 11// Inheritance from AliVVertex: A. Dainese
df9db588 12//-------------------------------------------------------------------------
13
df9db588 14#include <TRef.h>
15#include <TRefArray.h>
16#include <TMath.h>
17
bdd011d6 18#include "AliVVertex.h"
5d62ce04 19#include "AliAODRedCov.h"
bca58dd7 20#include "AliLog.h"
5d62ce04 21
bdd011d6 22class AliAODVertex : public AliVVertex {
df9db588 23
24 public :
25
e4b91233 26 enum AODVtx_t {kUndef=-1, kPrimary, kKink, kV0, kCascade, kMulti, kMainSPD, kPileupSPD, kPileupTracks,kMainTPC};
df9db588 27
28 AliAODVertex();
29 AliAODVertex(const Double_t *position,
30 const Double_t *covMatrix=0x0,
0657f082 31 Double_t chi2perNDF = -999.,
df9db588 32 TObject *parent = 0x0,
02153d58 33 Short_t id=-1,
bca58dd7 34 Char_t vtype=kUndef,
35 Int_t nprong = 0);
02153d58 36 AliAODVertex(const Float_t *position,
37 const Float_t *covMatrix=0x0,
38 Double_t chi2perNDF = -999.,
39 TObject *parent = 0x0,
40 Short_t id=-1,
bca58dd7 41 Char_t vtype=kUndef,
42 Int_t nprong = 0);
df9db588 43 AliAODVertex(const Double_t *position,
0657f082 44 Double_t chi2perNDF,
bca58dd7 45 Char_t vtype=kUndef,
46 Int_t nprong = 0);
df9db588 47 AliAODVertex(const Float_t *position,
0657f082 48 Double_t chi2perNDF,
bca58dd7 49 Char_t vtype=kUndef,
50 Int_t nprong = 0);
df9db588 51
52 virtual ~AliAODVertex();
53 AliAODVertex(const AliAODVertex& vtx);
54 AliAODVertex& operator=(const AliAODVertex& vtx);
55
26ba01d4 56 virtual AliAODVertex* CloneWithoutRefs() const;
57
df9db588 58 void SetX(Double_t x) { fPosition[0] = x; }
59 void SetY(Double_t y) { fPosition[1] = y; }
60 void SetZ(Double_t z) { fPosition[2] = z; }
61 void SetPosition(Double_t x, Double_t y, Double_t z) { fPosition[0] = x; fPosition[1] = y; fPosition[2] = z; }
62 template <class T> void SetPosition(T *pos)
63 { fPosition[0] = pos[0]; fPosition[1] = pos[1]; fPosition[2] = pos[2]; }
64
0657f082 65 void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
df9db588 66
67 void SetParent(TObject *parent) { fParent = parent; }
68
0b0bfa4e 69 Double_t GetX() const { return fPosition[0]; }
70 Double_t GetY() const { return fPosition[1]; }
71 Double_t GetZ() const { return fPosition[2]; }
bdd011d6 72 void GetXYZ(Double_t position[3]) const
73 {position[0]=fPosition[0]; position[1]=fPosition[1]; position[2]=fPosition[2];}
9f7c531f 74 template <class T> void GetPosition(T *pos) const
75 {pos[0]=fPosition[0]; pos[1]=fPosition[1]; pos[2]=fPosition[2];}
df9db588 76
77 template <class T> void SetCovMatrix(const T *covMatrix) {
5d62ce04 78 if(!fCovMatrix) fCovMatrix=new AliAODRedCov<3>();
df9db588 79 fCovMatrix->SetCovMatrix(covMatrix);}
80
81 template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
82 if(!fCovMatrix) return kFALSE;
83 fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
84
bdd011d6 85 void GetCovarianceMatrix(Double_t covmatrix[6]) const
86 {GetCovMatrix(covmatrix);}
df9db588 87 void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
88
89 template <class T> void GetSigmaXYZ(T *sigma) const;
90
0b0bfa4e 91 Double_t GetChi2perNDF() const { return fChi2perNDF; }
92 Double_t GetChi2() const { return fChi2perNDF*(Double_t)GetNDF(); }
93 Int_t GetNDF() const { return 2*GetNContributors()-3; }
df9db588 94
02153d58 95 Short_t GetID() const { return fID; }
96 void SetID(Short_t id) { fID=id; }
97
0b0bfa4e 98 Char_t GetType() const { return fType; }
99 void SetType(AODVtx_t vtype) { fType=vtype; }
df9db588 100
101 TObject* GetParent() const { return fParent.GetObject(); }
102 Bool_t HasParent(TObject *parent) const { return (fParent.GetObject() == parent) ? kTRUE : kFALSE; }
103
cfa5b70c 104 void AddDaughter(TObject *daughter);
df9db588 105 void RemoveDaughter(TObject *daughter) { fDaughters.Remove(daughter); }
1e0b17ae 106 void RemoveDaughters() { fDaughters.Clear(); if(fProngs) {delete [] fProngs; fProngs=0; MakeProngs(); fIprong=0;} }
bca58dd7 107 TObject* GetDaughter(Int_t i);
df9db588 108 Bool_t HasDaughter(TObject *daughter) const;
bca58dd7 109 Int_t GetNDaughters() const;
0657f082 110 Int_t GetNContributors() const;
91bad62d 111 void SetNContributors(Int_t nc) {fNContributors = nc;}
df9db588 112 // covariance matrix elements after rotation by phi around z-axis
113 // and, then, by theta around new y-axis
114 Double_t RotatedCovMatrixXX(Double_t phi = 0., Double_t theta = 0.) const;
115 Double_t RotatedCovMatrixXY(Double_t phi = 0., Double_t theta = 0.) const;
116 Double_t RotatedCovMatrixYY(Double_t phi = 0.) const;
117 Double_t RotatedCovMatrixXZ(Double_t phi = 0., Double_t theta = 0.) const;
118 Double_t RotatedCovMatrixYZ(Double_t phi = 0., Double_t theta = 0.) const;
119 Double_t RotatedCovMatrixZZ(Double_t phi = 0., Double_t theta = 0.) const;
120
121 template <class T, class P> void PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) const;
5e6a3170 122 Double_t Distance2ToVertex(const AliAODVertex *vtx) const;
6766c805 123 Double_t DistanceToVertex(AliAODVertex *vtx) const
124 {return TMath::Sqrt(Distance2ToVertex(vtx));}
5e6a3170 125 Double_t DistanceXY2ToVertex(const AliAODVertex *vtx) const;
6766c805 126 Double_t DistanceXYToVertex(AliAODVertex *vtx) const
127 {return TMath::Sqrt(DistanceXY2ToVertex(vtx));}
128 Double_t Error2DistanceToVertex(AliAODVertex *vtx) const;
129 Double_t ErrorDistanceToVertex(AliAODVertex *vtx) const
130 {return TMath::Sqrt(Error2DistanceToVertex(vtx));}
131 Double_t Error2DistanceXYToVertex(AliAODVertex *vtx) const;
132 Double_t ErrorDistanceXYToVertex(AliAODVertex *vtx) const
133 {return TMath::Sqrt(Error2DistanceXYToVertex(vtx));}
19d55689 134
df9db588 135 void PrintIndices() const;
136 void Print(Option_t* option = "") const;
26ba01d4 137
138 const char* AsString() const;
139
140 static const char* GetTypeName(AODVtx_t type);
0249e9b8 141 void SetBC(Int_t bc) {fBCID = bc;}
142 Int_t GetBC() const {return fBCID;}
26ba01d4 143private:
0cccccc3 144 void MakeProngs() {if (fNprong > 0) {fProngs = new TRef[fNprong]; fIprong=0;}}
bca58dd7 145
146 private:
df9db588 147
91bad62d 148 Double32_t fPosition[3]; // vertex position
149 Double32_t fChi2perNDF; // chi2/NDF of vertex fit
150 Short_t fID; // vertex ID; corresponds to the array index of the appropriate ESD container
0249e9b8 151 Char_t fBCID; // BC ID assigned to vertex
91bad62d 152 Char_t fType; // vertex type
153 Int_t fNprong; // number of prongs
154 Int_t fIprong; //!index of prong
155 Int_t fNContributors; // Number of contributors for SPD vertex
156 AliAODRedCov<3> *fCovMatrix; // vertex covariance matrix; values of and below the diagonal
157 TRef fParent; // reference to the parent particle
158 TRefArray fDaughters; // references to the daughter particles
159 TRef *fProngs; //[fNprong] alternative daughters for n-prong vertex
bca58dd7 160
0249e9b8 161 ClassDef(AliAODVertex, 8);
df9db588 162};
163
bca58dd7 164inline Int_t AliAODVertex::GetNDaughters() const
165{
166 if (!fProngs) {
167 return fDaughters.GetEntriesFast();
168 } else {
169 return fNprong;
170 }
171}
172
173inline TObject* AliAODVertex::GetDaughter(Int_t i)
174{
175 if (!fProngs) {
176 return fDaughters.At(i);
177 } else {
178 if (i < fNprong) {
179 return fProngs[i].GetObject();
180 } else {
181 AliWarning("Daughter index out of range !\n");
182 return 0;
183 }
184 }
185}
186
df9db588 187#endif