]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODVertex.h
Bug fix for GetLatestEvent()
[u/mrichter/AliRoot.git] / STEER / AliAODVertex.h
1 #ifndef AliAODVertex_H
2 #define AliAODVertex_H
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
11 //     Inheritance from AliVVertex: A. Dainese
12 //-------------------------------------------------------------------------
13
14 #include <TRef.h>
15 #include <TRefArray.h>
16 #include <TMath.h>
17
18 #include "AliVVertex.h"
19 #include "AliAODRedCov.h"
20
21 class AliAODVertex : public AliVVertex {
22
23  public :
24
25   enum AODVtx_t {kUndef=-1, kPrimary, kKink, kV0, kCascade, kMulti};
26
27   AliAODVertex();
28   AliAODVertex(const Double_t *position, 
29                const Double_t *covMatrix=0x0,
30                Double_t chi2perNDF = -999.,
31                TObject *parent = 0x0,
32                Short_t id=-1,
33                Char_t vtype=kUndef);
34   AliAODVertex(const Float_t *position, 
35                const Float_t *covMatrix=0x0,
36                Double_t chi2perNDF = -999.,
37                TObject *parent = 0x0,
38                Short_t id=-1,
39                Char_t vtype=kUndef);
40     AliAODVertex(const Double_t *position, 
41                  Double_t chi2perNDF,
42                  Char_t vtype=kUndef);
43     AliAODVertex(const Float_t *position, 
44                  Double_t chi2perNDF,
45                  Char_t vtype=kUndef);
46
47   virtual ~AliAODVertex();
48   AliAODVertex(const AliAODVertex& vtx); 
49   AliAODVertex& operator=(const AliAODVertex& vtx);
50
51   void     SetX(Double_t x) { fPosition[0] = x; }
52   void     SetY(Double_t y) { fPosition[1] = y; }
53   void     SetZ(Double_t z) { fPosition[2] = z; }
54   void     SetPosition(Double_t x, Double_t y, Double_t z) { fPosition[0] = x; fPosition[1] = y; fPosition[2] = z; }
55   template <class T> void SetPosition(T *pos)
56     { fPosition[0] = pos[0]; fPosition[1] = pos[1]; fPosition[2] = pos[2]; }
57
58   void     SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
59
60   void     SetParent(TObject *parent) { fParent = parent; }
61
62   Double_t GetX() const { return fPosition[0]; }
63   Double_t GetY() const { return fPosition[1]; }
64   Double_t GetZ() const { return fPosition[2]; }
65   void     GetXYZ(Double_t position[3]) const 
66     {position[0]=fPosition[0]; position[1]=fPosition[1]; position[2]=fPosition[2];}
67   template <class T> void GetPosition(T *pos) const
68     {pos[0]=fPosition[0]; pos[1]=fPosition[1]; pos[2]=fPosition[2];}
69
70   template <class T> void SetCovMatrix(const T *covMatrix) {
71     if(!fCovMatrix) fCovMatrix=new AliAODRedCov<3>();
72     fCovMatrix->SetCovMatrix(covMatrix);}
73
74   template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
75     if(!fCovMatrix) return kFALSE;
76     fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
77
78   void GetCovarianceMatrix(Double_t covmatrix[6]) const 
79                     {GetCovMatrix(covmatrix);}
80   void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
81
82   template <class T> void     GetSigmaXYZ(T *sigma) const;
83
84   Double_t GetChi2perNDF() const { return fChi2perNDF; }
85   Double_t GetChi2() const { return fChi2perNDF*(Double_t)GetNDF(); }
86   Int_t    GetNDF() const { return 2*GetNContributors()-3; }
87
88   Short_t  GetID() const { return fID; }
89   void     SetID(Short_t id) { fID=id; }
90
91   Char_t   GetType() const { return fType; }
92   void     SetType(AODVtx_t vtype) { fType=vtype; }
93
94   TObject* GetParent() const   { return fParent.GetObject(); }
95   Bool_t   HasParent(TObject *parent) const { return (fParent.GetObject() == parent) ? kTRUE : kFALSE; }
96
97   void     AddDaughter(TObject *daughter);
98   void     RemoveDaughter(TObject *daughter) { fDaughters.Remove(daughter); }
99   void     RemoveDaughters() { fDaughters.Clear(); }
100   TObject* GetDaughter(Int_t i) { return fDaughters.At(i); }
101   Bool_t   HasDaughter(TObject *daughter) const;
102   Int_t    GetNDaughters() const { return fDaughters.GetEntriesFast(); }
103   Int_t    GetNContributors() const;
104
105   // covariance matrix elements after rotation by phi around z-axis 
106   // and, then, by theta around new y-axis
107   Double_t  RotatedCovMatrixXX(Double_t phi = 0., Double_t theta = 0.) const;
108   Double_t  RotatedCovMatrixXY(Double_t phi = 0., Double_t theta = 0.) const;
109   Double_t  RotatedCovMatrixYY(Double_t phi = 0.) const;
110   Double_t  RotatedCovMatrixXZ(Double_t phi = 0., Double_t theta = 0.) const;
111   Double_t  RotatedCovMatrixYZ(Double_t phi = 0., Double_t theta = 0.) const;
112   Double_t  RotatedCovMatrixZZ(Double_t phi = 0., Double_t theta = 0.) const;
113
114   template <class T, class P> void     PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) const;
115   Double_t  DistanceToVertex(AliAODVertex *vtx) const;
116   Double_t  ErrorDistanceToVertex(AliAODVertex *vtx) const;
117   Double_t  DistanceXYToVertex(AliAODVertex *vtx) const;
118   Double_t  ErrorDistanceXYToVertex(AliAODVertex *vtx) const;
119
120   void     PrintIndices() const;
121   void     Print(Option_t* option = "") const;
122
123  private :
124
125   Double32_t      fPosition[3]; // vertex position
126   Double32_t      fChi2perNDF;  // chi2/NDF of vertex fit
127   Short_t         fID;          // vertex ID; corresponds to the array index of the appropriate ESD container
128   Char_t          fType;        // vertex type
129
130   AliAODRedCov<3> *fCovMatrix;  // vertex covariance matrix; values of and below the diagonal
131   TRef            fParent;      // reference to the parent particle
132   TRefArray       fDaughters;   // references to the daughter particles
133
134   ClassDef(AliAODVertex,4);
135 };
136
137 #endif