]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCtrackerMI.h
Fix for negative sigmas. Memory leaks (Marco)
[u/mrichter/AliRoot.git] / TPC / AliTPCtrackerMI.h
index 529b637b48b279d26844ca9dd26e4a6804d52d27..9925a00ca72b5489deab9aeca773f5b6e7f30a38 100644 (file)
 //-------------------------------------------------------
 
 #include <TError.h>
-
 #include "AliTracker.h"
-#include "AliTPCtrack.h"
-#include "AliComplexCluster.h"
+#include "AliTPCreco.h"
+#include "AliPID.h"
+#include "AliTPCclusterMI.h"
+
 
 class TFile;
 class AliTPCParam;
 class AliTPCseed;
-class AliTPCclusterMI;
 class AliTPCTrackerPoint;
-class AliESD;   
+class AliESDEvent;   
 class TTree;
-
-class AliTPCseed : public AliTPCtrack {
-  friend class AliTPCtrackerMI;
-  public:  
-     AliTPCseed();
-     virtual ~AliTPCseed();
-     AliTPCseed(const AliTPCtrack &t);
-     AliTPCseed(const AliTPCseed &s);
-     AliTPCseed(const AliKalmanTrack &t, Double_t a);
-     Int_t Compare(const TObject *o) const;
-     void Reset(Bool_t all = kTRUE);
-     Int_t GetProlongation(Double_t xr, Double_t &y, Double_t & z) const;
-     virtual Double_t GetPredictedChi2(const AliTPCclusterMI *cluster) const;
-     virtual Int_t Update(const AliTPCclusterMI* c, Double_t chi2, UInt_t i);
-     AliTPCTrackerPoint * GetTrackPoint(Int_t i);
-     void RebuildSeed(); // rebuild seed to be ready for storing
-     AliTPCseed(UInt_t index, const Double_t xx[5], 
-                const Double_t cc[15], Double_t xr, Double_t alpha);
-
-     Double_t GetDensityFirst(Int_t n);
-     Double_t GetSigma2C() const {return fC44;};
-     void GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2);
-     
-     void Modify(Double_t factor);
-     void SetClusterIndex2(Int_t row, Int_t index) {
-       fIndex[row] = index;
-     }
-     Int_t  GetClusterIndex2(Int_t row) const {
-       return fIndex[row];
-     }
-     Int_t GetClusterSector(Int_t row) const {
-       Int_t pica = -1;
-       if (fIndex[row]>=0) pica =  ((fIndex[row]&0xff000000)>>24);
-       return pica;
-     }
-    
-     void SetErrorY2(Float_t sy2){fErrorY2=sy2;}
-     void SetErrorZ2(Float_t sz2){fErrorZ2=sz2;}
-     void CookdEdx(Double_t low=0.05, Double_t up=0.70, Int_t i1=0, Int_t i2=159, Bool_t onlyused = kFALSE);
-     //     void CookdEdx2(Double_t low=0.05, Double_t up=0.70);
-     Bool_t IsActive() const { return !(fRemoval);}
-     void Desactivate(Int_t reason){ fRemoval = reason;} 
-     //
-     //
- private:
-     AliTPCseed & operator = (const AliTPCseed &)
-       {::Fatal("= operator","Not Implemented\n");return *this;}
-     AliESDtrack * fEsd; //!
-     AliTPCclusterMI*   fClusterPointer[160];  //! array of cluster pointers  - 
-     TClonesArray * fPoints;              // array with points along the track
-     TClonesArray * fEPoints;             // array with exact points - calculated in special macro not used in tracking
-     //---CURRENT VALUES
-     Int_t fRow;                 //!current row number  
-     Int_t fSector;              //!current sector number
-     Int_t fRelativeSector;      //! index of current relative sector
-     Float_t fCurrentSigmaY2;    //!expected current cluster sigma Y
-     Float_t fCurrentSigmaZ2;    //!expected current cluster sigma Z
-     Float_t fErrorY2;           //!sigma of current cluster 
-     Float_t fErrorZ2;           //!sigma of current cluster    
-     AliTPCclusterMI * fCurrentCluster; //!pointer to the current cluster for prolongation
-     Int_t   fCurrentClusterIndex1; //! index of the current cluster
-     Bool_t  fInDead;            //! indicate if the track is in dead zone
-     Bool_t  fIsSeeding;         //!indicates if it is proces of seeading
-     Int_t   fNoCluster;         //!indicates number of rows without clusters
-     Int_t   fSort;              //!indicate criteria for sorting
-     Bool_t  fBSigned;        //indicates that clusters of this trackes are signed to be used
-     //
-     //
-     Float_t fDEDX[4];         // dedx according padrows
-     Float_t fSDEDX[4];        // sdedx according padrows
-     Int_t   fNCDEDX[4];       // number of clusters for dedx measurment
-     //
-     Int_t   fSeedType;         //seeding type
-     Int_t   fSeed1;            //first row for seeding
-     Int_t   fSeed2;            //last row for seeding
-     Int_t   fOverlapLabels[12];  //track labels and the length of the  overlap     
-     Float_t fMAngular;        // mean angular factor
-     AliTPCTrackerPoint  fTrackPoints[160];  //!track points - array track points
-   
-     ClassDef(AliTPCseed,1)  
-};
-
-
-
+class AliESDkink;
+class TTreeSRedirector;
+class AliTrackPoint;
 
 class AliTPCtrackerMI : public AliTracker {
 public:
-  AliTPCtrackerMI():AliTracker(),fkNIS(0),fkNOS(0) {
-    fInnerSec=fOuterSec=0; fSeeds=0; 
-  }
+  AliTPCtrackerMI();
   AliTPCtrackerMI(const AliTPCParam *par); 
-   AliTPCtrackerMI(const AliTPCtrackerMI& r);           //dummy copy constructor
-   AliTPCtrackerMI &operator=(const AliTPCtrackerMI& r);//dummy assignment operator
   virtual ~AliTPCtrackerMI();
   //
   void SetIteration(Int_t iteration){fIteration = iteration;}
-  virtual Int_t Clusters2Tracks (AliESD *esd);
-  virtual Int_t RefitInward (AliESD *esd);
+  virtual Int_t Clusters2Tracks (AliESDEvent *esd);
+  virtual Int_t RefitInward (AliESDEvent *esd);
   virtual Int_t LoadClusters (TTree * tree);
   Int_t  LoadClusters();
   void   UnloadClusters();
-
+  void   Transform(AliTPCclusterMI * cluster);
   //
   void SetIO();  //set default IO from folders
-  void SetIO(TTree * input, TTree * output, AliESD * event);
+  void SetIO(TTree * input, TTree * output, AliESDEvent * event);
   void FillESD(TObjArray* arr);
   void WriteTracks();
   void WriteTracks(TTree * tree);  
   void DeleteSeeds();
   void SetDebug(Int_t debug){ fDebug = debug;}
+  void FindKinks(TObjArray * array, AliESDEvent * esd);
+  void FindV0s(TObjArray * array, AliESDEvent * esd);
+  void UpdateKinkQualityM(AliTPCseed * seed);
+  void UpdateKinkQualityD(AliTPCseed * seed);
+  Int_t CheckKinkPoint(AliTPCseed*seed, AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink);
+  Int_t RefitKink(AliTPCseed &mother, AliTPCseed &daughter, AliESDkink &kink);
    Int_t ReadSeeds(const TFile *in);
    TObjArray * GetSeeds(){return fSeeds;}
    //   
-   AliCluster * GetCluster (int) const {return 0;}
+   AliCluster * GetCluster(Int_t index) const {return (AliCluster*)GetClusterMI(index);}
    AliTPCclusterMI *GetClusterMI(Int_t index) const;
-   Int_t Clusters2Tracks(const TFile */*in*/, TFile */*out*/) const {return 0;}
    Int_t Clusters2Tracks();
-   virtual void  CookLabel(AliTPCseed *t,Float_t wrong) const; 
+   virtual void  CookLabel(AliKalmanTrack *tk,Float_t wrong) const; 
+   virtual Int_t   CookLabel(AliTPCseed *t,Float_t wrong, Int_t first,Int_t last ) const; 
    
    void RotateToLocal(AliTPCseed *seed);
   
    
    Int_t FollowProlongation(AliTPCseed& t, Int_t rf=0, Int_t step=1);
    Int_t FollowProlongationFast(AliTPCseed& t, Int_t rf=0, Int_t step=1);
-   
+   Bool_t GetTrackPoint(Int_t index, AliTrackPoint &p ) const; 
+
    Int_t FollowBackProlongation(AliTPCseed& t, Int_t rf);
    Int_t FollowToNext(AliTPCseed& t, Int_t nr);
    Int_t FollowToNextFast(AliTPCseed& t, Int_t nr);
    Int_t UpdateClusters(AliTPCseed& t,  Int_t nr);
    Int_t FollowToNextCluster( AliTPCseed& t, Int_t nr);
 
-   virtual Int_t PropagateBack (const TFile *, TFile *) const {return 0;}
    Int_t PropagateBack(TObjArray * arr);
-   Int_t PropagateBack(AliESD * event);
+   Int_t PropagateBack(AliESDEvent * event);
    Int_t PropagateBack(AliTPCseed *pt, Int_t row0, Int_t row1);   
    Int_t PropagateForward();
    Int_t PropagateForward2(TObjArray * arr);
 
-   Int_t CheckKinkPoint(AliTPCseed*seed, Float_t th);
    void SortTracks(TObjArray * arr, Int_t mode) const;
   
 
@@ -185,12 +105,8 @@ public:
 //**************** Internal tracker class ********************** 
    class AliTPCSector;
    class AliTPCRow {
-     friend class AliTPCtrackerMI;
-     friend class AliTPCtrackerMI::AliTPCSector;
    public:
      AliTPCRow();
-     AliTPCRow(const AliTPCRow& r){;}           //dummy copy constructor
-     AliTPCRow &operator=(const AliTPCRow& r){return *this;} //dummy assignment operator
      ~AliTPCRow();
      void InsertCluster(const AliTPCclusterMI *c, UInt_t index);
      void ResetClusters();
@@ -205,7 +121,26 @@ public:
      
      void SetX(Double_t x) {fX=x;}
      Double_t GetX() const {return fX;}
+     Float_t GetDeadZone() const {return fDeadZone;}
+     void SetDeadZone(Float_t d) {fDeadZone=d;}
+     Int_t GetN1() const {return fN1;}
+     void SetN1(Int_t n) {fN1=n;}
+     Int_t GetN2() const {return fN2;}
+     void SetN2(Int_t n) {fN2=n;}
+     AliTPCclusterMI* GetClusters1() const {return fClusters1;}
+     AliTPCclusterMI* GetClusters2() const {return fClusters2;}
+     void SetClusters1(AliTPCclusterMI* cl) {fClusters1=cl;}
+     void SetClusters2(AliTPCclusterMI* cl) {fClusters2=cl;}
+     void SetCluster1(Int_t i, const AliTPCclusterMI &cl) {fClusters1[i]=cl;}
+     void SetCluster2(Int_t i, const AliTPCclusterMI &cl) {fClusters2[i]=cl;}
+     AliTPCclusterMI* GetCluster1(Int_t i) const {return &fClusters1[i];}
+     AliTPCclusterMI* GetCluster2(Int_t i) const {return &fClusters2[i];}
+     Short_t GetFastCluster(Int_t i) const {return fFastCluster[i];}
+     void SetFastCluster(Int_t i, Short_t cl) {fFastCluster[i]=cl;}
+
 private:  
+     AliTPCRow & operator=(const AliTPCRow & );
+     AliTPCRow(const AliTPCRow& /*r*/);           //dummy copy constructor
      Float_t fDeadZone;  // the width of the dead zone
      AliTPCclusterMI *fClusters1; //array with clusters 1
      Int_t fN1;  //number of clusters on left side
@@ -223,37 +158,44 @@ private:
 
 //**************** Internal tracker class ********************** 
    class AliTPCSector {
-     friend class AliTPCtrackerMI;
    public:
-     AliTPCSector() { fN=0; fRow = 0; }
+     AliTPCSector():
+       fN(0),
+       fRow(0),
+       fAlpha(0.),
+       fAlphaShift(0.),
+       fPadPitchWidth(0.),
+       fPadPitchLength(0.),
+       f1PadPitchLength(0.),
+       f2PadPitchLength(0.){}
     ~AliTPCSector() { delete[] fRow; }
-     AliTPCSector(const AliTPCSector &s){;}           //dummy copy contructor 
-     AliTPCSector& operator=(const AliTPCSector &s){return *this;}//dummy assignment operator
-     AliTPCRow& operator[](Int_t i) const { return *(fRow+i); }
-     Int_t GetNRows() const { return fN; }
-     void Setup(const AliTPCParam *par, Int_t flag);
-     Double_t GetX(Int_t l) const {return fRow[l].GetX();}
-     Double_t GetMaxY(Int_t l) const {
-         return GetX(l)*TMath::Tan(0.5*GetAlpha());
-     } 
-     Double_t GetAlpha() const {return fAlpha;}
-     Double_t GetAlphaShift() const {return fAlphaShift;}     
-     //Int_t GetFirst(){return fFirstRow;}
-     Int_t GetRowNumber(Double_t x) const;
-     Double_t GetPadPitchWidth()  const {return fPadPitchWidth;}
-     Double_t GetPadPitchLength() const {return fPadPitchLength;}
-     Double_t GetPadPitchLength(Float_t x) const {return (x<200) ? fPadPitchLength:f2PadPitchLength ;}
-
+    AliTPCRow& operator[](Int_t i) const { return *(fRow+i); }
+    Int_t GetNRows() const { return fN; }
+    void Setup(const AliTPCParam *par, Int_t flag);
+    Double_t GetX(Int_t l) const {return fRow[l].GetX();}
+    Double_t GetMaxY(Int_t l) const {
+      return GetX(l)*TMath::Tan(0.5*GetAlpha());
+    } 
+    Double_t GetAlpha() const {return fAlpha;}
+    Double_t GetAlphaShift() const {return fAlphaShift;}     
+    //Int_t GetFirst(){return fFirstRow;}
+    Int_t GetRowNumber(Double_t  x) const;
+    Double_t GetPadPitchWidth()  const {return fPadPitchWidth;}
+    Double_t GetPadPitchLength() const {return fPadPitchLength;}
+    Double_t GetPadPitchLength(Float_t x) const {return (x<200) ? fPadPitchLength:f2PadPitchLength ;}
+    
    private:
-     Int_t fN;                        //number of pad rows 
-     //Int_t fFirstRow;                 //offset
-     AliTPCRow *fRow;                    //array of pad rows
-     Double_t fAlpha;                    //opening angle
-     Double_t fAlphaShift;               //shift angle;
-     Double_t fPadPitchWidth;            //pad pitch width
-     Double_t fPadPitchLength;           //pad pitch length
-     Double_t f1PadPitchLength;           //pad pitch length
-     Double_t f2PadPitchLength;           //pad pitch length
+    AliTPCSector & operator=(const AliTPCSector & );
+    AliTPCSector(const AliTPCSector &/*s*/);           //dummy copy contructor 
+    Int_t fN;                        //number of pad rows 
+    //Int_t fFirstRow;                 //offset
+    AliTPCRow *fRow;                    //array of pad rows
+    Double_t fAlpha;                    //opening angle
+    Double_t fAlphaShift;               //shift angle;
+    Double_t fPadPitchWidth;            //pad pitch width
+    Double_t fPadPitchLength;           //pad pitch length
+    Double_t f1PadPitchLength;           //pad pitch length
+    Double_t f2PadPitchLength;           //pad pitch length
     
    };
 
@@ -262,6 +204,7 @@ private:
    void  SignShared(TObjArray * arr);
 
    void  RemoveUsed(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex);
+   void  RemoveUsed2(TObjArray * arr, Float_t factor1, Float_t factor2, Int_t minimal);
    void  RemoveDouble(TObjArray * arr, Float_t factor1, Float_t factor2,  Int_t removalindex);
 
    void  StopNotActive(TObjArray * arr, Int_t row0, Float_t th0, Float_t th1, Float_t th2) const;
@@ -269,10 +212,14 @@ private:
    Int_t AcceptCluster(AliTPCseed * seed, AliTPCclusterMI * cluster, Float_t factor, Float_t cory=1., Float_t corz=1.);
 
 private:
+  AliTPCtrackerMI(const AliTPCtrackerMI& r);           //dummy copy constructor
+  AliTPCtrackerMI &operator=(const AliTPCtrackerMI& r);//dummy assignment operator
    inline AliTPCRow &GetRow(Int_t sec, Int_t row);
+   inline Bool_t     IsActive(Int_t sec, Int_t row);
    inline Double_t  GetXrow(Int_t row) const;
    inline Double_t  GetMaxY(Int_t row) const;
    inline Int_t GetRowNumber(Double_t x) const;
+   Int_t GetRowNumber(Double_t x[3]) const;
    inline Double_t GetPadPitchLength(Double_t x) const;
    inline Double_t GetPadPitchLength(Int_t row) const;
 
@@ -280,7 +227,7 @@ private:
    Float_t  GetSigmaZ(AliTPCseed * seed);
    void GetShape(AliTPCseed * seed, Int_t row);
  
-   void ReadSeeds(AliESD *event, Int_t direction);  //read seeds from the event
+   void ReadSeeds(AliESDEvent *event, Int_t direction);  //read seeds from the event
 
    void MakeSeeds3(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1, Int_t ddsec=0); 
    void MakeSeeds5(TObjArray * arr, Int_t sec, Int_t i1, Int_t i2, Float_t cuts[4], Float_t deltay = -1);
@@ -290,6 +237,7 @@ private:
 
    AliTPCseed *MakeSeed(AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
    AliTPCseed *ReSeed(AliTPCseed *t, Float_t r0, Float_t r1, Float_t r2); //reseed
+   AliTPCseed *ReSeed(AliTPCseed *t, Int_t r0, Bool_t forward); //reseed
 
 
   
@@ -303,13 +251,15 @@ private:
    void Tracking(TObjArray * arr);
    TObjArray * Tracking(Int_t seedtype, Int_t i1, Int_t i2, Float_t cuts[4], Float_t dy=-1, Int_t dsec=0);
    TObjArray * Tracking();
-   void SumTracks(TObjArray *arr1,TObjArray *arr2) const;
+   TObjArray * TrackingSpecial();
+   void SumTracks(TObjArray *arr1,TObjArray *&arr2) const;
    void PrepareForBackProlongation(TObjArray * arr, Float_t fac) const;
    void PrepareForProlongation(TObjArray * arr, Float_t fac) const;
 
    void SetSampledEdx(AliTPCseed */*t*/, Float_t /*q*/, Int_t /*i*/) {;}
    Int_t UpdateTrack(AliTPCseed *t, Int_t accept); //update trackinfo
 
+   void MakeBitmaps(AliTPCseed *t);
 
    const Int_t fkNIS;        //number of inner sectors
    AliTPCSector *fInnerSec;  //array of inner sectors;
@@ -323,7 +273,7 @@ private:
    TTree * fOutput;      // output tree with tracks
    TTree * fSeedTree;    // output tree with seeds - filled in debug mode 1
    TTree * fTreeDebug;   // output with a debug information about track
-   AliESD * fEvent;      // output with esd tracks
+   AliESDEvent * fEvent;      // output with esd tracks
    Int_t    fDebug;      // debug option        
    Bool_t   fNewIO;      // indicated if we have data using New IO 
    Int_t fNtracks;                     //current number of tracks
@@ -335,7 +285,8 @@ private:
    Double_t fYMax[200];                // max y for given pad row
    Double_t fPadLength[200];                // max y for given pad row
    const AliTPCParam *fParam;          //pointer to the parameters
-   ClassDef(AliTPCtrackerMI,1) 
+   TTreeSRedirector *fDebugStreamer;     //!debug streamer
+   ClassDef(AliTPCtrackerMI,2) 
 };
 
 
@@ -345,6 +296,15 @@ AliTPCtrackerMI::AliTPCRow & AliTPCtrackerMI::GetRow(Int_t sec, Int_t row)
   return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()]:fInnerSec[sec][row];
 }
 
+Bool_t   AliTPCtrackerMI::IsActive(Int_t sec, Int_t row)
+{
+  //
+  // check if the given sector row is active 
+  //
+  return (row>=fInnerSec->GetNRows()) ? fOuterSec[sec][row-fInnerSec->GetNRows()].GetN()>0:fInnerSec[sec][row].GetN()>0;
+}
+
+
 Double_t  AliTPCtrackerMI::GetXrow(Int_t row) const {
   //  return (row>=fInnerSec->GetNRows()) ? fOuterSec->GetX(row-fInnerSec->GetNRows()):fInnerSec->GetX(row);
   return fXRow[row];