From bead97966682c50bb0cf6636acb323e32712da79 Mon Sep 17 00:00:00 2001 From: belikov Date: Fri, 25 Jan 2008 09:34:25 +0000 Subject: [PATCH] Possibility to sort AliTrackPointArray --- STEER/AliTrackFitterKalman.cxx | 1 + STEER/AliTrackPointArray.cxx | 28 ++++++++++++++++++++++++++++ STEER/AliTrackPointArray.h | 5 ++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/STEER/AliTrackFitterKalman.cxx b/STEER/AliTrackFitterKalman.cxx index 62854095acd..c9b2d58d0a6 100755 --- a/STEER/AliTrackFitterKalman.cxx +++ b/STEER/AliTrackFitterKalman.cxx @@ -56,6 +56,7 @@ Bool_t AliTrackFitterKalman::Begin(Int_t first, Int_t last) { // This is the "default" seed. // if (fSeed) return kTRUE; + fPoints->Sort(); AliTrackPoint fp,lp; fPoints->GetPoint(fp,first); fPoints->GetPoint(lp,last); return MakeSeed(&fp,&lp); diff --git a/STEER/AliTrackPointArray.cxx b/STEER/AliTrackPointArray.cxx index 72f73ce01c6..3f7d7b63336 100644 --- a/STEER/AliTrackPointArray.cxx +++ b/STEER/AliTrackPointArray.cxx @@ -33,6 +33,7 @@ ClassImp(AliTrackPointArray) //______________________________________________________________________________ AliTrackPointArray::AliTrackPointArray() : TObject(), + fSorted(kFALSE), fNPoints(0), fX(0), fY(0), @@ -46,6 +47,7 @@ AliTrackPointArray::AliTrackPointArray() : //______________________________________________________________________________ AliTrackPointArray::AliTrackPointArray(Int_t npoints): TObject(), + fSorted(kFALSE), fNPoints(npoints), fX(new Float_t[npoints]), fY(new Float_t[npoints]), @@ -61,6 +63,7 @@ AliTrackPointArray::AliTrackPointArray(Int_t npoints): //______________________________________________________________________________ AliTrackPointArray::AliTrackPointArray(const AliTrackPointArray &array): TObject(array), + fSorted(array.fSorted), fNPoints(array.fNPoints), fX(new Float_t[fNPoints]), fY(new Float_t[fNPoints]), @@ -86,6 +89,7 @@ AliTrackPointArray &AliTrackPointArray::operator =(const AliTrackPointArray& arr if(this==&array) return *this; ((TObject *)this)->operator=(array); + fSorted = array.fSorted; fNPoints = array.fNPoints; fSize = array.fSize; delete [] fX; @@ -159,6 +163,29 @@ Bool_t AliTrackPointArray::HasVolumeID(UShort_t volid) const return check; } +//______________________________________________________________________________ +void AliTrackPointArray::Sort(Bool_t down) +{ + // Sort the array by the values of Y-coordinate of the track points. + // The order is given by "down". + // Optimized more for maintenance rather than for speed. + + if (fSorted) return; + + Int_t *index=new Int_t[fNPoints]; + AliTrackPointArray a(*this); + TMath::Sort(fNPoints,a.GetY(),index,down); + + AliTrackPoint p; + for (Int_t i = 0; i < fNPoints; i++) { + a.GetPoint(p,index[i]); + AddPoint(i,&p); + } + + delete[] index; + fSorted=kTRUE; +} + ClassImp(AliTrackPoint) //______________________________________________________________________________ @@ -492,3 +519,4 @@ void AliTrackPoint::SetAlignCovMatrix(const TMatrixDSym alignparmtrx){ SetXYZ(fX,fY,fZ,newcov); } + diff --git a/STEER/AliTrackPointArray.h b/STEER/AliTrackPointArray.h index 76881442230..1ae9144f9a2 100644 --- a/STEER/AliTrackPointArray.h +++ b/STEER/AliTrackPointArray.h @@ -94,7 +94,10 @@ class AliTrackPointArray : public TObject { Bool_t HasVolumeID(UShort_t volid) const; + void Sort(Bool_t down=kTRUE); + private: + Bool_t fSorted; // Sorted flag Int_t fNPoints; // Number of space points Float_t *fX; //[fNPoints] Array with space point X coordinates @@ -104,7 +107,7 @@ class AliTrackPointArray : public TObject { Float_t *fCov; //[fSize] Array with space point coordinates cov matrix UShort_t *fVolumeID; //[fNPoints] Array of space point volume IDs - ClassDef(AliTrackPointArray,1) + ClassDef(AliTrackPointArray,2) }; #endif -- 2.39.3