]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODVertex.h
Moving from TNamed to TObject
[u/mrichter/AliRoot.git] / STEER / AliAODVertex.h
CommitLineData
df9db588 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//-------------------------------------------------------------------------
12
13#include <TNamed.h>
14#include <TRef.h>
15#include <TRefArray.h>
16#include <TMath.h>
17
18class AliAODVertex : public TObject {
19
20 public :
21
22 enum AODVtx_t {kUndef=-1, kPrimary, kKink, kV0, kCascade, kMulti};
23
24 AliAODVertex();
25 AliAODVertex(const Double_t *position,
26 const Double_t *covMatrix=0x0,
27 Double_t chi2 = -999.,
28 TObject *parent = 0x0,
29 Char_t vtype=kUndef);
30 AliAODVertex(const Float_t *position,
31 const Float_t *covMatrix=0x0,
32 Double_t chi2 = -999.,
33 TObject *parent = 0x0,
34 Char_t vtype=kUndef);
35 AliAODVertex(const Double_t *position,
36 Double_t chi2,
37 Char_t vtype=kUndef);
38 AliAODVertex(const Float_t *position,
39 Double_t chi2,
40 Char_t vtype=kUndef);
41
42 virtual ~AliAODVertex();
43 AliAODVertex(const AliAODVertex& vtx);
44 AliAODVertex& operator=(const AliAODVertex& vtx);
45
46 void SetX(Double_t x) { fPosition[0] = x; }
47 void SetY(Double_t y) { fPosition[1] = y; }
48 void SetZ(Double_t z) { fPosition[2] = z; }
49 void SetPosition(Double_t x, Double_t y, Double_t z) { fPosition[0] = x; fPosition[1] = y; fPosition[2] = z; }
50 template <class T> void SetPosition(T *pos)
51 { fPosition[0] = pos[0]; fPosition[1] = pos[1]; fPosition[2] = pos[2]; }
52
53 void SetChi2(Double_t chi2) { fChi2 = chi2; }
54
55 void SetParent(TObject *parent) { fParent = parent; }
56
57 Double_t GetX() const { return fPosition[0]; }
58 Double_t GetY() const { return fPosition[1]; }
59 Double_t GetZ() const { return fPosition[2]; }
60 template <class T> void GetPosition(T *position) const;
61
62 template <class T> void SetCovMatrix(const T *covMatrix) {
63 if(!fCovMatrix) fCovMatrix=new AliAODVtxCov();
64 fCovMatrix->SetCovMatrix(covMatrix);}
65
66 template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
67 if(!fCovMatrix) return kFALSE;
68 fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
69
70 void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
71
72 template <class T> void GetSigmaXYZ(T *sigma) const;
73
74 Double_t GetChi2() const { return fChi2; }
75 Double_t GetChi2perNDF() const;
76
77 Char_t GetVtxType() const { return fType; }
78 void GetVtxType(Char_t vtype) { fType=vtype; }
79
80 TObject* GetParent() const { return fParent.GetObject(); }
81 Bool_t HasParent(TObject *parent) const { return (fParent.GetObject() == parent) ? kTRUE : kFALSE; }
82
83 void AddDaughter(TObject *daughter) { fDaughters.Add(daughter);}
84 void RemoveDaughter(TObject *daughter) { fDaughters.Remove(daughter); }
85 Bool_t HasDaughter(TObject *daughter) const;
86
87 // covariance matrix elements after rotation by phi around z-axis
88 // and, then, by theta around new y-axis
89 Double_t RotatedCovMatrixXX(Double_t phi = 0., Double_t theta = 0.) const;
90 Double_t RotatedCovMatrixXY(Double_t phi = 0., Double_t theta = 0.) const;
91 Double_t RotatedCovMatrixYY(Double_t phi = 0.) const;
92 Double_t RotatedCovMatrixXZ(Double_t phi = 0., Double_t theta = 0.) const;
93 Double_t RotatedCovMatrixYZ(Double_t phi = 0., Double_t theta = 0.) const;
94 Double_t RotatedCovMatrixZZ(Double_t phi = 0., Double_t theta = 0.) const;
95
96 template <class T, class P> void PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) const;
97 Double_t DistanceToVertex(AliAODVertex *vtx) const;
98 Double_t ErrorDistanceToVertex(AliAODVertex *vtx) const;
99 Double_t DistanceXYToVertex(AliAODVertex *vtx) const;
100 Double_t ErrorDistanceXYToVertex(AliAODVertex *vtx) const;
101
102 void PrintIndices() const;
103 void Print(Option_t* option = "") const;
104
105 class AliAODVtxCov {
106
107 //
108 // Class containing the covariance matrix for the vertex
109 //
110 // X Y Z
111 //
112 // X fDiag[ 0]
113 //
114 // Y fOdia[ 0] fDiag[ 1]
115 //
116 // Z fOdia[ 1] fOdia[ 2] fDiag[ 2]
117 //
118 //
119
120 public:
121 AliAODVtxCov() {}
122 virtual ~AliAODVtxCov() {}
123 template <class T> void GetCovMatrix(T *cmat) const;
124 template <class T> void SetCovMatrix(T *cmat);
125
126 private:
127 Double32_t fDiag[3]; // Diagonal elements
128 Double32_t fODia[3]; // [-1, 1,8] 8 bit precision for off diagonal elements
129
130 ClassDef(AliAODVertex::AliAODVtxCov,1)
131
132 };
133
134 private :
135
136 AliAODVtxCov *fCovMatrix; // vertex covariance matrix; values of and below the diagonal
137 Double32_t fPosition[3]; // vertex position
138 Double32_t fChi2; // chi2 of vertex fit
139 Char_t fType; // Vertex type
140
141 TRef fParent; // reference to the parent particle
142 TRefArray fDaughters; // references to the daughter particles
143
144 ClassDef(AliAODVertex,1);
145};
146
147//______________________________________________________________________________
148template <class T> inline void AliAODVertex::GetPosition(T *position) const
149{
150 position[0]=fPosition[0];
151 position[1]=fPosition[1];
152 position[2]=fPosition[2];
153}
154
155//______________________________________________________________________________
156inline Double_t AliAODVertex::GetChi2perNDF() const
157{
158 // return the chi^2 per degree of freedom
159 return fChi2/(2.*fDaughters.GetEntriesFast()-3.);
160}
161
162#endif