]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODVertex.h
Bug fix
[u/mrichter/AliRoot.git] / STEER / AliAODVertex.h
index 35aef15c0f4f58295616782212571c39ebfcb427..325f4168ee18be5bc0c9eef3997c069c88fd4cc4 100644 (file)
@@ -15,6 +15,8 @@
 #include <TRefArray.h>
 #include <TMath.h>
 
+#include "AliAODRedCov.h"
+
 class AliAODVertex : public TObject {
 
  public :
@@ -24,19 +26,19 @@ class AliAODVertex : public TObject {
   AliAODVertex();
   AliAODVertex(const Double_t *position, 
               const Double_t *covMatrix=0x0,
-              Double_t chi2 = -999.,
+              Double_t chi2perNDF = -999.,
               TObject *parent = 0x0,
               Char_t vtype=kUndef);
     AliAODVertex(const Float_t *position, 
                 const Float_t *covMatrix=0x0,
-                Double_t chi2 = -999.,
+                Double_t chi2perNDF = -999.,
                 TObject *parent = 0x0,
                 Char_t vtype=kUndef);
     AliAODVertex(const Double_t *position, 
-                Double_t chi2,
+                Double_t chi2perNDF,
                 Char_t vtype=kUndef);
     AliAODVertex(const Float_t *position, 
-                Double_t chi2,
+                Double_t chi2perNDF,
                 Char_t vtype=kUndef);
 
   virtual ~AliAODVertex();
@@ -50,17 +52,18 @@ class AliAODVertex : public TObject {
   template <class T> void SetPosition(T *pos)
     { fPosition[0] = pos[0]; fPosition[1] = pos[1]; fPosition[2] = pos[2]; }
 
-  void     SetChi2(Double_t chi2) { fChi2 = chi2; }
+  void     SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
 
   void     SetParent(TObject *parent) { fParent = parent; }
 
   Double_t  GetX() const { return fPosition[0]; }
   Double_t  GetY() const { return fPosition[1]; }
   Double_t  GetZ() const { return fPosition[2]; }
-  template <class T> void GetPosition(T *position) const;
+  template <class T> void GetPosition(T *pos) const
+    {pos[0]=fPosition[0]; pos[1]=fPosition[1]; pos[2]=fPosition[2];}
 
   template <class T> void SetCovMatrix(const T *covMatrix) {
-    if(!fCovMatrix) fCovMatrix=new AliAODVtxCov();
+    if(!fCovMatrix) fCovMatrix=new AliAODRedCov<3>();
     fCovMatrix->SetCovMatrix(covMatrix);}
 
   template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
@@ -71,18 +74,22 @@ class AliAODVertex : public TObject {
 
   template <class T> void     GetSigmaXYZ(T *sigma) const;
 
-  Double_t  GetChi2() const { return fChi2; }
-  Double_t  GetChi2perNDF() const;
+  Double_t  GetChi2perNDF() const { return fChi2perNDF; }
+  Double_t  GetChi2() const { return fChi2perNDF*(Double_t)GetNDF(); }
+  Int_t     GetNDF() const { return 2*GetNContributors()-3; }
 
-  Char_t    GetVtxType() const { return fType; }
-  void      GetVtxType(Char_t vtype) { fType=vtype; }
+  Char_t    GetType() const { return fType; }
+  void      SetType(AODVtx_t vtype) { fType=vtype; }
 
   TObject* GetParent() const   { return fParent.GetObject(); }
   Bool_t   HasParent(TObject *parent) const { return (fParent.GetObject() == parent) ? kTRUE : kFALSE; }
 
   void     AddDaughter(TObject *daughter) { fDaughters.Add(daughter);}
   void     RemoveDaughter(TObject *daughter) { fDaughters.Remove(daughter); }
+  TObject* GetDaughter(Int_t i) { return fDaughters.At(i); }
   Bool_t   HasDaughter(TObject *daughter) const;
+  Int_t    GetNDaughters() const { return fDaughters.GetEntriesFast(); }
+  Int_t    GetNContributors() const;
 
   // covariance matrix elements after rotation by phi around z-axis 
   // and, then, by theta around new y-axis
@@ -102,61 +109,16 @@ class AliAODVertex : public TObject {
   void     PrintIndices() const;
   void     Print(Option_t* option = "") const;
 
-   class AliAODVtxCov {
-
-   //
-   //  Class containing the covariance matrix for the vertex
-   //
-   //       X          Y          Z 
-   //
-   // X  fDiag[ 0]  
-   //
-   // Y  fOdia[ 0]  fDiag[ 1]
-   //
-   // Z  fOdia[ 1]  fOdia[ 2]  fDiag[ 2]
-   //
-   //
-
-   public:
-   AliAODVtxCov() {}
-   virtual ~AliAODVtxCov() {}
-   template <class T> void GetCovMatrix(T *cmat) const;
-   template <class T> void SetCovMatrix(T *cmat);
-
-   private:
-   Double32_t   fDiag[3];  // Diagonal elements
-   Double32_t   fODia[3]; // [-1, 1,8] 8 bit precision for off diagonal elements
-
-   ClassDef(AliAODVertex::AliAODVtxCov,1)
-   
- };
-
  private :
 
-  AliAODVtxCov *fCovMatrix;   // vertex covariance matrix; values of and below the diagonal
-  Double32_t  fPosition[3]; // vertex position
-  Double32_t  fChi2;        // chi2 of vertex fit
-  Char_t      fType;        // Vertex type
+  Double32_t    fPosition[3]; // vertex position
+  Double32_t    fChi2perNDF;  // chi2/NDF of vertex fit
+  AliAODRedCov<3> *fCovMatrix;   // vertex covariance matrix; values of and below the diagonal
+  TRef          fParent;      // reference to the parent particle
+  TRefArray     fDaughters;   // references to the daughter particles
+  Char_t        fType;        // Vertex type
 
-  TRef      fParent;        // reference to the parent particle
-  TRefArray fDaughters;     // references to the daughter particles
-
-  ClassDef(AliAODVertex,1);
+  ClassDef(AliAODVertex,2);
 };
 
-//______________________________________________________________________________
-template <class T> inline void AliAODVertex::GetPosition(T *position) const 
-{
-  position[0]=fPosition[0];
-  position[1]=fPosition[1];
-  position[2]=fPosition[2];
-}
-
-//______________________________________________________________________________
-inline Double_t AliAODVertex::GetChi2perNDF() const 
-{
-  // return the chi^2 per degree of freedom
-  return fChi2/(2.*fDaughters.GetEntriesFast()-3.);
-}
-
 #endif