]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODVertex.cxx
add protection against truncated events + coverity - Rachid
[u/mrichter/AliRoot.git] / STEER / AliAODVertex.cxx
index 5518f3a5a39abc86c1ec708ec8bdfb8583413199..01c05088f0895ecec913ff250020224adc056b1f 100644 (file)
@@ -182,6 +182,28 @@ AliAODVertex::AliAODVertex(const AliAODVertex& vtx) :
   }
 }
 
+//______________________________________________________________________________
+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;
+}
+
 //______________________________________________________________________________
 AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx) 
 {
@@ -266,7 +288,8 @@ Int_t AliAODVertex::GetNContributors() const
   // Returns the number of tracks used to fit this vertex.
   Int_t cont  = 0;
 
-  if (!strcmp(GetTitle(), "vertexer: 3D")) {
+  TString vtitle = GetTitle();
+  if (!vtitle.Contains("VertexerTracks")) {
     cont = fNContributors;
   } else {
     for (Int_t iDaug = 0; iDaug < GetNDaughters(); iDaug++) {
@@ -274,7 +297,9 @@ Int_t AliAODVertex::GetNContributors() const
        if (!aodT) continue;
        if (aodT->GetUsedForPrimVtxFit()) cont++;
     } 
- }
+    // the constraint adds another DOF
+    if(vtitle.Contains("VertexerTracksWithConstraint"))cont++;
+  }
   return cont;
 }
 
@@ -459,7 +484,7 @@ Double_t AliAODVertex::RotatedCovMatrixZZ(Double_t phi, Double_t theta) const
 }
 
 //______________________________________________________________________________
-Double_t AliAODVertex::DistanceToVertex(AliAODVertex *vtx) const
+Double_t AliAODVertex::Distance2ToVertex(const AliAODVertex *vtx) const
 {
   // distance in 3D to another AliAODVertex
 
@@ -467,22 +492,22 @@ Double_t AliAODVertex::DistanceToVertex(AliAODVertex *vtx) const
   Double_t dy = GetY()-vtx->GetY();
   Double_t dz = GetZ()-vtx->GetZ();
 
-  return TMath::Sqrt(dx*dx+dy*dy+dz*dz);
+  return dx*dx+dy*dy+dz*dz;
 }
 
 //______________________________________________________________________________
-Double_t AliAODVertex::DistanceXYToVertex(AliAODVertex *vtx) const
+Double_t AliAODVertex::DistanceXY2ToVertex(const AliAODVertex *vtx) const
 {
   // distance in XY to another AliAODVertex
 
   Double_t dx = GetX()-vtx->GetX();
   Double_t dy = GetY()-vtx->GetY();
 
-  return TMath::Sqrt(dx*dx+dy*dy);
+  return dx*dx+dy*dy;
 }
 
 //______________________________________________________________________________
-Double_t AliAODVertex::ErrorDistanceToVertex(AliAODVertex *vtx) const
+Double_t AliAODVertex::Error2DistanceToVertex(AliAODVertex *vtx) const
 {
   // error on the distance in 3D to another AliAODVertex
 
@@ -493,11 +518,11 @@ Double_t AliAODVertex::ErrorDistanceToVertex(AliAODVertex *vtx) const
   // error2 due to vtx vertex
   Double_t error2vtx = vtx->RotatedCovMatrixXX(phi,theta);
 
-  return TMath::Sqrt(error2+error2vtx);
+  return error2+error2vtx;
 }
 
 //______________________________________________________________________________
-Double_t AliAODVertex::ErrorDistanceXYToVertex(AliAODVertex *vtx) const
+Double_t AliAODVertex::Error2DistanceXYToVertex(AliAODVertex *vtx) const
 {
   // error on the distance in XY to another AliAODVertex
 
@@ -508,7 +533,7 @@ Double_t AliAODVertex::ErrorDistanceXYToVertex(AliAODVertex *vtx) const
   // error2 due to vtx vertex
   Double_t error2vtx = vtx->RotatedCovMatrixXX(phi);
 
-  return TMath::Sqrt(error2+error2vtx);
+  return error2+error2vtx;
 }
 
 //______________________________________________________________________________
@@ -535,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 
 {