]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliVertexerTracks.cxx
Init the TList with refence objects when using the copy ctor, added protection agains...
[u/mrichter/AliRoot.git] / STEER / AliVertexerTracks.cxx
index 5030484f5199ccdaf68b9878da41d0543ea6b446..5a68582d75cb0818ac5aab79f485ba3476b5e26c 100644 (file)
 
 //---- Root headers --------
 #include <TSystem.h>
+#include <TClonesArray.h>
 #include <TDirectory.h>
 #include <TFile.h>
-#include <TTree.h>
-#include <TMatrixD.h>
 //---- AliRoot headers -----
-#include "AliLog.h"
 #include "AliStrLine.h"
 #include "AliExternalTrackParam.h"
 #include "AliNeutralTrackParam.h"
 #include "AliVEvent.h"
 #include "AliVTrack.h"
-#include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliVertexerTracks.h"
 
@@ -67,6 +64,7 @@ fMaxd0z0(0.5),
 fMinDetFitter(100.),
 fMaxTgl(1000.),
 fITSrefit(kTRUE),
+fITSpureSA(kFALSE),
 fFiducialR(3.),
 fFiducialZ(30.),
 fnSigmaForUi00(1.5),
@@ -101,6 +99,7 @@ fMaxd0z0(0.5),
 fMinDetFitter(100.),
 fMaxTgl(1000.),
 fITSrefit(kTRUE),
+fITSpureSA(kFALSE),
 fFiducialR(3.),
 fFiducialZ(30.),
 fnSigmaForUi00(1.5),
@@ -120,11 +119,11 @@ AliVertexerTracks::~AliVertexerTracks()
   // The objects pointed by the following pointer are not owned
   // by this class and are not deleted
   fCurrentVertex = 0;
-  if(fTrksToSkip) { delete fTrksToSkip; fTrksToSkip=NULL; }
-  if(fIdSel) { delete fIdSel; fIdSel=NULL; }
+  if(fTrksToSkip) { delete [] fTrksToSkip; fTrksToSkip=NULL; }
+  if(fIdSel) { delete [] fIdSel; fIdSel=NULL; }
 }
 //----------------------------------------------------------------------------
-AliESDVertex* AliVertexerTracks::FindPrimaryVertex(AliVEvent *vEvent)
+AliESDVertex* AliVertexerTracks::FindPrimaryVertex(const AliVEvent *vEvent)
 {
 //
 // Primary vertex for current ESD or AOD event
@@ -176,8 +175,10 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(AliVEvent *vEvent)
     }
     if(skipThis) continue;
 
-    // skip pure ITS SA tracks
-    if(track->GetStatus()&AliESDtrack::kITSpureSA) continue;
+    // skip pure ITS SA tracks (default)
+    if(!fITSpureSA && (track->GetStatus()&AliESDtrack::kITSpureSA)) continue;
+    // or use only pure ITS SA tracks
+    if(fITSpureSA && !(track->GetStatus()&AliESDtrack::kITSpureSA)) continue;
 
     // kITSrefit
     if(fMode==0 && fITSrefit && !(track->GetStatus()&AliESDtrack::kITSrefit)) continue;
@@ -211,7 +212,7 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(AliVEvent *vEvent)
   FindPrimaryVertex(&trkArrayOrig,idOrig);
 
   if(fMode==0) trkArrayOrig.Delete();
-  delete idOrig; idOrig=NULL;
+  delete [] idOrig; idOrig=NULL;
 
   if(f) {
     f->Close(); delete f; f = NULL;
@@ -233,7 +234,7 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(AliVEvent *vEvent)
   return fCurrentVertex;
 }
 //----------------------------------------------------------------------------
-AliESDVertex* AliVertexerTracks::FindPrimaryVertex(TObjArray *trkArrayOrig,
+AliESDVertex* AliVertexerTracks::FindPrimaryVertex(const TObjArray *trkArrayOrig,
                                                   UShort_t *idOrig)
 {
 //
@@ -264,7 +265,7 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(TObjArray *trkArrayOrig,
     // fill fTrkArraySel, for VertexFinder()
     fIdSel = new UShort_t[nTrksOrig];
     PrepareTracks(*trkArrayOrig,idOrig,0);
-    if(fIdSel) { delete fIdSel; fIdSel=NULL; }
+    if(fIdSel) { delete [] fIdSel; fIdSel=NULL; }
     Double_t cutsave = fDCAcut;  
     fDCAcut = fDCAcutIter0;
     // vertex finder
@@ -304,7 +305,7 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(TObjArray *trkArrayOrig,
   //                   between initVertex and fCurrentVertex) 
   for(Int_t iter=1; iter<=2; iter++) {
     if(fOnlyFitter && iter==1) continue; 
-    if(fIdSel) { delete fIdSel; fIdSel=NULL; }
+    if(fIdSel) { delete [] fIdSel; fIdSel=NULL; }
     fIdSel = new UShort_t[nTrksOrig];
     Int_t nTrksSel = PrepareTracks(*trkArrayOrig,idOrig,iter);
     AliDebug(1,Form("N tracks selected in iteration %d: %d",iter,nTrksSel));
@@ -345,7 +346,7 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(TObjArray *trkArrayOrig,
       indices[jj] = fIdSel[jj];
     fCurrentVertex->SetIndices(nIndices,indices);
   }
-  if (indices) {delete indices; indices=NULL;}
+  if (indices) {delete [] indices; indices=NULL;}
   //
 
   // set vertex title
@@ -360,9 +361,9 @@ AliESDVertex* AliVertexerTracks::FindPrimaryVertex(TObjArray *trkArrayOrig,
   AliDebug(1,Form("xyz: %f %f %f; nc %d",fCurrentVertex->GetXv(),fCurrentVertex->GetYv(),fCurrentVertex->GetZv(),fCurrentVertex->GetNContributors()));
 
   // clean up
-  delete fIdSel; fIdSel=NULL;
+  delete [] fIdSel; fIdSel=NULL;
   fTrkArraySel.Delete();
-  if(fTrksToSkip) { delete fTrksToSkip; fTrksToSkip=NULL; }
+  if(fTrksToSkip) { delete [] fTrksToSkip; fTrksToSkip=NULL; }
   //
   
   return fCurrentVertex;
@@ -375,7 +376,7 @@ Double_t AliVertexerTracks::GetDeterminant3X3(Double_t matr[][3])
  return det;
 }
 //-------------------------------------------------------------------------
-void AliVertexerTracks::GetStrLinDerivMatrix(Double_t *p0,Double_t *p1,Double_t (*m)[3],Double_t *d)
+void AliVertexerTracks::GetStrLinDerivMatrix(const Double_t *p0,const Double_t *p1,Double_t (*m)[3],Double_t *d)
 {
   //
   Double_t x12=p0[0]-p1[0];
@@ -397,7 +398,7 @@ void AliVertexerTracks::GetStrLinDerivMatrix(Double_t *p0,Double_t *p1,Double_t
 
 }
 //--------------------------------------------------------------------------  
-void AliVertexerTracks::GetStrLinDerivMatrix(Double_t *p0,Double_t *p1,Double_t *sigmasq,Double_t (*m)[3],Double_t *d)
+void AliVertexerTracks::GetStrLinDerivMatrix(const Double_t *p0,const Double_t *p1,const Double_t *sigmasq,Double_t (*m)[3],Double_t *d)
 {
   //
   Double_t x12=p1[0]-p0[0];
@@ -440,7 +441,7 @@ void AliVertexerTracks::GetStrLinDerivMatrix(Double_t *p0,Double_t *p1,Double_t
 
   }
 //--------------------------------------------------------------------------   
-Double_t AliVertexerTracks::GetStrLinMinDist(Double_t *p0,Double_t *p1,Double_t *x0)
+Double_t AliVertexerTracks::GetStrLinMinDist(const Double_t *p0,const Double_t *p1,const Double_t *x0)
 {
   //
   Double_t x12=p0[0]-p1[0];
@@ -565,8 +566,8 @@ void AliVertexerTracks::HelixVertexFinder()
   fVert.SetNContributors(ncombi);
 }
 //----------------------------------------------------------------------------
-Int_t AliVertexerTracks::PrepareTracks(TObjArray &trkArrayOrig,
-                                      UShort_t *idOrig,
+Int_t AliVertexerTracks::PrepareTracks(const TObjArray &trkArrayOrig,
+                                      const UShort_t *idOrig,
                                       Int_t optImpParCut) 
 {
 //
@@ -719,9 +720,9 @@ Bool_t AliVertexerTracks::PropagateTrackTo(AliExternalTrackParam *track,
 }
 //---------------------------------------------------------------------------
 AliESDVertex* AliVertexerTracks::RemoveTracksFromVertex(AliESDVertex *inVtx,
-                                                       TObjArray *trkArray,
+                                                       const TObjArray *trkArray,
                                                        UShort_t *id,
-                                                       Float_t *diamondxy) const
+                                                       const Float_t *diamondxy) const
 {
 //
 // Removes tracks in trksTree from fit of inVtx
@@ -831,7 +832,7 @@ AliESDVertex* AliVertexerTracks::RemoveTracksFromVertex(AliESDVertex *inVtx,
     }
   }
   outVtx->SetIndices(nIndices,outindices);
-  if (outindices) delete outindices;
+  if (outindices) delete [] outindices;
 
   /*
     printf("Vertex before removing tracks:");
@@ -1036,7 +1037,7 @@ void AliVertexerTracks::SetTPCMode(Double_t dcacut,
   return; 
 }
 //---------------------------------------------------------------------------
-void AliVertexerTracks::SetSkipTracks(Int_t n,Int_t *skipped) 
+void AliVertexerTracks::SetSkipTracks(Int_t n,const Int_t *skipped) 
 {
 //
 // Mark the tracks not to be used in the vertex reconstruction.
@@ -1091,7 +1092,7 @@ void AliVertexerTracks::StrLinVertexFinderMinDist(Int_t optUseWeights)
   delete [] linarray;
 }
 //---------------------------------------------------------------------------
-AliESDVertex AliVertexerTracks::TrackletVertexFinder(TClonesArray *lines, Int_t optUseWeights)
+AliESDVertex AliVertexerTracks::TrackletVertexFinder(const TClonesArray *lines, Int_t optUseWeights)
 {
   // Calculate the point at minimum distance to prepared tracks (TClonesArray)
   const Int_t knacc = (Int_t)lines->GetEntriesFast();
@@ -1177,7 +1178,7 @@ AliESDVertex AliVertexerTracks::TrackletVertexFinder(AliStrLine **lines, const I
   Double_t det=GetDeterminant3X3(sum);
   Double_t sigma=0;
   
-  if(det!=0){
+  if(TMath::Abs(det) > kAlmost0){
     for(Int_t zz=0;zz<3;zz++){
       for(Int_t ww=0;ww<3;ww++){
        for(Int_t kk=0;kk<3;kk++) vett[ww][kk]=sum[ww][kk];
@@ -1202,8 +1203,8 @@ AliESDVertex AliVertexerTracks::TrackletVertexFinder(AliStrLine **lines, const I
   }
   AliESDVertex theVert(initPos,covmatrix,99999.,knacc);
   theVert.SetDispersion(sigma);
-  delete vectP0;
-  delete vectP1;
+  delete [] vectP0;
+  delete [] vectP1;
   return theVert;
 }
 
@@ -1344,8 +1345,8 @@ void AliVertexerTracks::TooFewTracks()
   }
 
   if(!fTrkArraySel.IsEmpty()) fTrkArraySel.Delete(); 
-  if(fIdSel) {delete fIdSel; fIdSel=NULL;}
-  if(fTrksToSkip) {delete fTrksToSkip; fTrksToSkip=NULL;}
+  if(fIdSel) {delete [] fIdSel; fIdSel=NULL;}
+  if(fTrksToSkip) {delete [] fTrksToSkip; fTrksToSkip=NULL;}
 
   return;
 }
@@ -1626,7 +1627,7 @@ void AliVertexerTracks::VertexFitter()
   return;
 }
 //----------------------------------------------------------------------------
-AliESDVertex* AliVertexerTracks::VertexForSelectedTracks(TObjArray *trkArray,
+AliESDVertex* AliVertexerTracks::VertexForSelectedTracks(const TObjArray *trkArray,
                                                         UShort_t *id,
                                                         Bool_t optUseFitter,
                                                         Bool_t optPropagate,
@@ -1705,8 +1706,8 @@ AliESDVertex* AliVertexerTracks::VertexForSelectedTracks(TObjArray *trkArray,
   }
 
   // clean up
-  if (indices) {delete indices; indices=NULL;}
-  delete fIdSel; fIdSel=NULL;
+  if (indices) {delete [] indices; indices=NULL;}
+  delete [] fIdSel; fIdSel=NULL;
   fTrkArraySel.Delete();
   
   return fCurrentVertex;
@@ -1733,7 +1734,7 @@ AliESDVertex* AliVertexerTracks::VertexForSelectedESDTracks(TObjArray *trkArray,
     
   VertexForSelectedTracks(trkArray,id,optUseFitter,optPropagate,optUseDiamondConstraint);
 
-  delete id; id=NULL;
+  delete [] id; id=NULL;
 
   return fCurrentVertex;
 }