]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODVertex.cxx
Fixed: GetStringArray(Int_t index) should return TObjString*
[u/mrichter/AliRoot.git] / STEER / AliAODVertex.cxx
index 3743a4d098fffb236f51e406cf72185af55c1056..9ee1d1f8f1bc06237849dfc776624349513c5cec 100644 (file)
 //     Base class for Analysis Object Data
 //     Generic version
 //     Author: Markus Oldenburg, CERN
+//     Inheritance from AliVVertex: A. Dainese
 //-------------------------------------------------------------------------
 
 #include "AliAODVertex.h"
+#include "AliAODTrack.h"
 
 ClassImp(AliAODVertex)
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex() : 
-  TObject(),
-  fChi2(-999.),
+  AliVVertex(),
+  fChi2perNDF(-999.),
+  fID(-1),
+  fType(kUndef),
+  fNprong(0),
+  fIprong(0),
   fCovMatrix(NULL),
-  fParent(0x0),
+  fParent(),
   fDaughters(),
-  fType(kUndef)
- {
+  fProngs(NULL)
 {
   // default constructor
 
   fPosition[0] = fPosition[1] = fPosition[2] = -999.;
@@ -42,72 +48,98 @@ AliAODVertex::AliAODVertex() :
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const Double_t position[3], 
-                          const Double_t  covMatrix[6],
-                          Double_t  chi2,
+                          const Double_t covMatrix[6],
+                          Double_t  chi2perNDF,
                           TObject  *parent,
-                          Char_t vtype) :
-  TObject(),
-  fChi2(chi2),
+                          Short_t id,
+                          Char_t vtype, 
+                          Int_t  nprong) :
+  AliVVertex(),
+  fChi2perNDF(chi2perNDF),
+  fID(id),
+  fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
   fCovMatrix(NULL),
   fParent(parent),
   fDaughters(),
-  fType(vtype)
+  fProngs(0)
 {
   // constructor
 
   SetPosition(position);
   if (covMatrix) SetCovMatrix(covMatrix);
+  MakeProngs();
 }
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const Float_t position[3], 
                           const Float_t  covMatrix[6],
-                          Double_t  chi2,
+                          Double_t  chi2perNDF,
                           TObject  *parent,
-                          Char_t vtype) :
-  TObject(),
-  fChi2(chi2),
+                          Short_t id,
+                          Char_t vtype,
+                          Int_t nprong) :
+
+  AliVVertex(),
+  fChi2perNDF(chi2perNDF),
+  fID(id),
+  fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
   fCovMatrix(NULL),
   fParent(parent),
   fDaughters(),
-  fType(vtype)
+  fProngs(0)
 {
   // constructor
 
   SetPosition(position);
   if (covMatrix) SetCovMatrix(covMatrix);
+  MakeProngs();
 }
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const Double_t position[3], 
-                          Double_t  chi2,
-                          Char_t vtype) :
-  TObject(),
-  fChi2(chi2),
+                          Double_t  chi2perNDF,
+                          Char_t vtype, 
+                          Int_t nprong) :
+  AliVVertex(),
+  fChi2perNDF(chi2perNDF),
+  fID(-1),
+  fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
   fCovMatrix(NULL),
-  fParent(0x0),
+  fParent(),
   fDaughters(),
-  fType(vtype)
+  fProngs(0)
 {
   // constructor without covariance matrix
 
   SetPosition(position);  
+  MakeProngs();
 }
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const Float_t position[3], 
-                          Double_t  chi2,
-                          Char_t vtype) :
-  TObject(),
-  fChi2(chi2),
+                          Double_t  chi2perNDF,
+                          Char_t vtype, Int_t nprong) :
+  AliVVertex(),
+  fChi2perNDF(chi2perNDF),
+  fID(-1),
+  fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
   fCovMatrix(NULL),
-  fParent(0x0),
+  fParent(),
   fDaughters(),
-  fType(vtype)
+  fProngs(0)
 {
   // constructor without covariance matrix
 
   SetPosition(position);  
+  MakeProngs();
 }
 
 //______________________________________________________________________________
@@ -116,16 +148,21 @@ AliAODVertex::~AliAODVertex()
   // Destructor
 
   delete fCovMatrix;
+  if (fNprong > 0) delete[] fProngs;
 }
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const AliAODVertex& vtx) :
-  TObject(vtx),
-  fChi2(vtx.fChi2),
+  AliVVertex(vtx),
+  fChi2perNDF(vtx.fChi2perNDF),
+  fID(vtx.fID),
+  fType(vtx.fType),
+  fNprong(vtx.fNprong),
+  fIprong(vtx.fIprong),
   fCovMatrix(NULL),
   fParent(vtx.fParent),
   fDaughters(vtx.fDaughters),
-  fType(vtx.fType)
+  fProngs(0)
 {
   // Copy constructor.
   
@@ -133,6 +170,10 @@ AliAODVertex::AliAODVertex(const AliAODVertex& vtx) :
     fPosition[i] = vtx.fPosition[i];
 
   if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix);
+  MakeProngs();
+  for (int i = 0; i < fNprong; i++) {
+      fProngs[i] = vtx.fProngs[i];
+  }
 }
 
 //______________________________________________________________________________
@@ -142,13 +183,15 @@ AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx)
   if (this != &vtx) {
 
     // name and type
-    TObject::operator=(vtx);
+    AliVVertex::operator=(vtx);
 
     //momentum
     for (int i = 0; i < 3; i++) 
       fPosition[i] = vtx.fPosition[i];
     
-    fChi2 = vtx.fChi2;
+    fChi2perNDF = vtx.fChi2perNDF;
+    fID = vtx.fID;
+    fType = vtx.fType;
 
     //covariance matrix
     delete fCovMatrix;
@@ -158,12 +201,39 @@ AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx)
     //other stuff
     fParent = vtx.fParent;
     fDaughters = vtx.fDaughters;
-    fType = vtx.fType;
+    fNprong    = vtx.fNprong;
+    fIprong    = vtx.fIprong;  
+
+    MakeProngs();
+    for (int i = 0; i < fNprong; i++) {
+       fProngs[i] = vtx.fProngs[i];
+    }
   }
   
   return *this;
 }
 
+//______________________________________________________________________________
+void AliAODVertex::AddDaughter(TObject *daughter)
+{
+  // Add reference to daughter track
+    if (!fProngs) {
+       if (fDaughters.GetEntries()==0) {
+           TRefArray* arr = &fDaughters;
+           new(arr)TRefArray(TProcessID::GetProcessWithUID(daughter));         
+       }
+       fDaughters.Add(daughter);       
+    } else {
+       if (fIprong < fNprong) {
+           fProngs[fIprong++] = daughter;
+       } else {
+           AliWarning("Number of daughters out of range !\n");
+       }
+    }
+  return;
+}
+
+
 //______________________________________________________________________________
 template <class T> void AliAODVertex::GetSigmaXYZ(T sigma[3]) const
 {
@@ -184,16 +254,39 @@ template <class T> void AliAODVertex::GetSigmaXYZ(T sigma[3]) const
   */
 }
 
+//______________________________________________________________________________
+Int_t AliAODVertex::GetNContributors() const 
+{
+  // Returns the number of tracks used to fit this vertex.
+  Int_t cont = 0;
+
+  if (!strcmp(GetTitle(), "vertexer: 3D")) {
+    cont = fNContributors;
+  } else {
+    for (Int_t iDaug = 0; iDaug < GetNDaughters(); iDaug++) {
+      if (((AliAODTrack*)fDaughters.At(iDaug))->GetUsedForVtxFit()) cont++;
+    }
+  }
+  return cont;
+}
+
 //______________________________________________________________________________
 Bool_t AliAODVertex::HasDaughter(TObject *daughter) const 
 {
   // Checks if the given daughter (particle) is part of this vertex.
-
-  TRefArrayIter iter(&fDaughters);
-  while (TObject *daugh = iter.Next()) {
-    if (daugh == daughter) return kTRUE;
-  }
-  return kFALSE;
+    if (!fProngs) {
+       TRefArrayIter iter(&fDaughters);
+       while (TObject *daugh = iter.Next()) {
+           if (daugh == daughter) return kTRUE;
+       }
+       return kFALSE;
+    } else {
+       Bool_t has = kFALSE;
+       for (int i = 0; i < fNprong; i++) {
+           if (fProngs[i].GetObject() == daughter) has = kTRUE;
+       }
+       return has;
+    }
 }
 
 //______________________________________________________________________________
@@ -417,7 +510,7 @@ void AliAODVertex::PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) cons
   // rotation angles around z-axis (phi) and around new y-axis (theta)
   // with which vtx is seen (used by RotatedCovMatrix... methods)
 
-  phi = TMath::ATan2(vtx->GetY()-GetY(),vtx->GetX()-GetX());
+  phi = TMath::Pi()+TMath::ATan2(-vtx->GetY()+GetY(),-vtx->GetX()+GetX());
   Double_t vtxxphi = vtx->GetX()*TMath::Cos(phi)+vtx->GetY()*TMath::Sin(phi);
   Double_t xphi = GetX()*TMath::Cos(phi)+GetY()*TMath::Sin(phi);
   theta = TMath::ATan2(vtx->GetZ()-GetZ(),vtxxphi-xphi);
@@ -430,7 +523,7 @@ void AliAODVertex::PrintIndices() const
 
   TRefArrayIter iter(&fDaughters);
   while (TObject *daugh = iter.Next()) {
-    printf("Particle %p originates from this vertex.\n", daugh);
+    printf("Particle %p originates from this vertex.\n", static_cast<void*>(daugh));
   }
 }
 
@@ -443,7 +536,7 @@ void AliAODVertex::Print(Option_t* /*option*/) const
   printf("     x = %f\n", fPosition[0]);
   printf("     y = %f\n", fPosition[1]);
   printf("     z = %f\n", fPosition[2]);
-  printf(" parent particle: %p\n", fParent.GetObject());
+  printf(" parent particle: %p\n", static_cast<void*>(fParent.GetObject()));
   printf(" origin of %d particles\n", fDaughters.GetEntriesFast());
   printf(" vertex type %d\n", fType);
   
@@ -461,6 +554,6 @@ void AliAODVertex::Print(Option_t* /*option*/) const
           fCovMatrix[4],
           fCovMatrix[5]); 
           } */
-  printf(" Chi^2 = %f\n", fChi2);
+  printf(" Chi^2/NDF = %f\n", fChi2perNDF);
 }