]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODVertex.cxx
Coverity fix.
[u/mrichter/AliRoot.git] / STEER / AliAODVertex.cxx
index d5ba95d1931d80b2f4f87655f4cdb427ed5e6dc6..64285e7532cbfcfa450936beae0d66716866665e 100644 (file)
@@ -34,9 +34,13 @@ AliAODVertex::AliAODVertex() :
   fChi2perNDF(-999.),
   fID(-1),
   fType(kUndef),
+  fNprong(0),
+  fIprong(0),
+  fNContributors(0),
   fCovMatrix(NULL),
   fParent(),
-  fDaughters()
+  fDaughters(),
+  fProngs(NULL)
   {
   // default constructor
 
@@ -49,19 +53,25 @@ AliAODVertex::AliAODVertex(const Double_t position[3],
                           Double_t  chi2perNDF,
                           TObject  *parent,
                           Short_t id,
-                          Char_t vtype) :
+                          Char_t vtype, 
+                          Int_t  nprong) :
   AliVVertex(),
   fChi2perNDF(chi2perNDF),
   fID(id),
   fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
+  fNContributors(0),
   fCovMatrix(NULL),
   fParent(parent),
-  fDaughters()
+  fDaughters(),
+  fProngs(0)
 {
   // constructor
 
   SetPosition(position);
   if (covMatrix) SetCovMatrix(covMatrix);
+  MakeProngs();
 }
 
 //______________________________________________________________________________
@@ -70,54 +80,71 @@ AliAODVertex::AliAODVertex(const Float_t position[3],
                           Double_t  chi2perNDF,
                           TObject  *parent,
                           Short_t id,
-                          Char_t vtype) :
+                          Char_t vtype,
+                          Int_t nprong) :
 
   AliVVertex(),
   fChi2perNDF(chi2perNDF),
   fID(id),
   fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
+  fNContributors(0),
   fCovMatrix(NULL),
   fParent(parent),
-  fDaughters()
+  fDaughters(),
+  fProngs(0)
 {
   // constructor
 
   SetPosition(position);
   if (covMatrix) SetCovMatrix(covMatrix);
+  MakeProngs();
 }
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const Double_t position[3], 
                           Double_t  chi2perNDF,
-                          Char_t vtype) :
+                          Char_t vtype, 
+                          Int_t nprong) :
   AliVVertex(),
   fChi2perNDF(chi2perNDF),
   fID(-1),
   fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
+  fNContributors(0),
   fCovMatrix(NULL),
   fParent(),
-  fDaughters()
+  fDaughters(),
+  fProngs(0)
 {
   // constructor without covariance matrix
 
   SetPosition(position);  
+  MakeProngs();
 }
 
 //______________________________________________________________________________
 AliAODVertex::AliAODVertex(const Float_t position[3], 
                           Double_t  chi2perNDF,
-                          Char_t vtype) :
+                          Char_t vtype, Int_t nprong) :
   AliVVertex(),
   fChi2perNDF(chi2perNDF),
   fID(-1),
   fType(vtype),
+  fNprong(nprong),
+  fIprong(0),
+  fNContributors(0),
   fCovMatrix(NULL),
   fParent(),
-  fDaughters()
+  fDaughters(),
+  fProngs(0)
 {
   // constructor without covariance matrix
 
   SetPosition(position);  
+  MakeProngs();
 }
 
 //______________________________________________________________________________
@@ -126,6 +153,7 @@ AliAODVertex::~AliAODVertex()
   // Destructor
 
   delete fCovMatrix;
+  if (fNprong > 0) delete[] fProngs;
 }
 
 //______________________________________________________________________________
@@ -134,9 +162,13 @@ AliAODVertex::AliAODVertex(const AliAODVertex& vtx) :
   fChi2perNDF(vtx.fChi2perNDF),
   fID(vtx.fID),
   fType(vtx.fType),
+  fNprong(vtx.fNprong),
+  fIprong(vtx.fIprong),
+  fNContributors(vtx.fNContributors),
   fCovMatrix(NULL),
   fParent(vtx.fParent),
-  fDaughters(vtx.fDaughters)
+  fDaughters(vtx.fDaughters),
+  fProngs(0)
 {
   // Copy constructor.
   
@@ -144,6 +176,32 @@ 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];
+  }
+}
+
+//______________________________________________________________________________
+AliAODVertex* AliAODVertex::CloneWithoutRefs() const
+{
+  // Special method to copy all but the refs 
+  
+  Double_t cov[6] = { 0.0 };
+      
+  if (fCovMatrix) fCovMatrix->GetCovMatrix(cov);
+  
+  AliAODVertex* v = new AliAODVertex(fPosition,
+                                     cov,
+                                     fChi2perNDF,
+                                     0x0,
+                                     fID,
+                                     fType,
+                                     0);
+  
+  v->SetNContributors(fNContributors);  
+  
+  return v;
 }
 
 //______________________________________________________________________________
@@ -171,11 +229,39 @@ AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx)
     //other stuff
     fParent = vtx.fParent;
     fDaughters = vtx.fDaughters;
+    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
 {
@@ -200,13 +286,20 @@ 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;
-
-  for (Int_t iDaug = 0; iDaug < GetNDaughters(); iDaug++) {
-    if (((AliAODTrack*)fDaughters.At(iDaug))->GetUsedForVtxFit()) cont++;
+  Int_t cont  = 0;
+
+  TString vtitle = GetTitle();
+  if (!vtitle.Contains("VertexerTracks")) {
+    cont = fNContributors;
+  } else {
+    for (Int_t iDaug = 0; iDaug < GetNDaughters(); iDaug++) {
+       AliAODTrack* aodT = dynamic_cast<AliAODTrack*>(fDaughters.At(iDaug));
+       if (!aodT) continue;
+       if (aodT->GetUsedForPrimVtxFit()) cont++;
+    } 
+    // the constraint adds another DOF
+    if(vtitle.Contains("VertexerTracksWithConstraint"))cont++;
   }
-
   return cont;
 }
 
@@ -214,12 +307,19 @@ Int_t AliAODVertex::GetNContributors() const
 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;
+    }
 }
 
 //______________________________________________________________________________
@@ -460,6 +560,75 @@ void AliAODVertex::PrintIndices() const
   }
 }
 
+//______________________________________________________________________________
+const char* AliAODVertex::AsString() const
+{
+  // Make a string describing this object
+  
+  TString tmp(Form("%10s pos(%7.2f,%7.2f,%7.2f)",GetTypeName((AODVtx_t)GetType()),GetX(),GetY(),GetZ()));
+  
+  if (GetType()==kPrimary || GetType()==kMainSPD || GetType()==kPileupSPD )
+  {
+    tmp += Form(" ncontrib %d chi2/ndf %4.1f",GetNContributors(),GetChi2perNDF());
+
+  }
+  
+  if ( !fParent.GetObject() ) 
+  {
+    tmp += " no parent";
+  }
+  if ( fDaughters.GetEntriesFast() > 0 )
+  {
+    if ( fDaughters.GetEntriesFast() == 1 ) 
+    {
+      tmp += " origin of 1 particle";
+    }
+    else
+    {
+      tmp += Form(" origin of %2d particles",fDaughters.GetEntriesFast());
+    }
+  }
+  
+  return tmp.Data();
+}
+
+//______________________________________________________________________________
+const char* AliAODVertex::GetTypeName(AODVtx_t type)
+{
+  // Return an ASCII version of type
+  
+  switch (type)
+  {
+    case kPrimary:
+      return "primary";
+      break;
+    case kKink:
+      return "kink";
+      break;
+    case kV0:
+      return "v0";
+      break;
+    case kCascade:
+      return "cascade";
+      break;
+    case kMainSPD:
+      return "mainSPD";
+      break;
+    case kPileupSPD:
+      return "pileupSPD";
+      break;
+    case kPileupTracks:
+      return "pileupTRK";
+      break;
+    case kMainTPC:
+      return "mainTPC";
+      break;
+    default:
+      return "unknown";
+      break;
+  };
+}
+
 //______________________________________________________________________________
 void AliAODVertex::Print(Option_t* /*option*/) const 
 {