]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseedV1.h
Protections added in GetEvent method.
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.h
index b7d3d127ef5c27ab610bfc37583500d3c146a055..3e93580ac8569b3fae8293671f3a6bcff94b0d14 100644 (file)
@@ -7,7 +7,9 @@
 
 ////////////////////////////////////////////////////////////////////////////
 //                                                                        //
-//  The TRD offline tracklet                                              //
+// \class AliTRDseedV1
+// \brief The TRD offline tracklet
+// \author Alexandru Bercuci
 //                                                                        //
 ////////////////////////////////////////////////////////////////////////////
 
 #include "AliTRDcluster.h"
 #endif
 
+#include "AliTRDReconstructor.h"
+
 class TTreeSRedirector;
+class TLinearFitter;
 
 class AliRieman;
 
 class AliTRDtrackingChamber;
 class AliTRDtrackV1;
-class AliTRDReconstructor;
 class AliTRDpadPlane;
 class AliTRDseedV1 : public AliTRDtrackletBase
 {
+  friend class AliHLTTRDTracklet;
+
 public:
   enum ETRDtrackletBuffers {    
-    kNtb       = 31     // max clusters/pad row
+    kNbits     = 6      // bits to store number of clusters
+   ,kMask      = 0x3f   // bit mask
+   ,kNtb       = 31     // max clusters/pad row
    ,kNclusters = 2*kNtb // max number of clusters/tracklet
    ,kNslices   = 10     // max dEdx slices
   };
@@ -59,7 +67,16 @@ public:
    ,kPID        = BIT(16) // PID contributor
    ,kCalib      = BIT(17) // calibrated tracklet
    ,kKink       = BIT(18) // kink prolongation tracklet
-   ,kStandAlone = BIT(19) // stand alone build tracklet
+   ,kStandAlone = BIT(19) // tracklet build during stand alone track finding
+  };
+  enum ETRDtrackletError {
+    kAttachClFound = 1  // not enough clusters found
+   ,kAttachRowGap       // found gap attached rows
+   ,kAttachRow          // found 3 rows
+   ,kAttachMultipleCl   // multiple clusters attached to time bin
+   ,kAttachClAttach     // not enough clusters attached
+   ,kFitFailed          // fit failed det=0
+   ,kFitOutside         // ref radial position outside chamber - wrong covariance
   };
 
   AliTRDseedV1(Int_t det = -1);
@@ -67,11 +84,7 @@ public:
   AliTRDseedV1(const AliTRDseedV1 &ref);
   AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
 
-/*  Bool_t       AttachClustersIter(
-              AliTRDtrackingChamber *chamber, Float_t quality, 
-              Bool_t kZcorr = kFALSE, AliTRDcluster *c=0x0);*/
-  Bool_t         AttachClusters(
-              AliTRDtrackingChamber *chamber, Bool_t tilt = kFALSE);
+  Bool_t    AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt = kFALSE);
   void      Bootstrap(const AliTRDReconstructor *rec);
   void      Calibrate();
   void      CookdEdx(Int_t nslices);
@@ -98,25 +111,26 @@ public:
   void      GetCovAt(Double_t x, Double_t *cov) const;
   void      GetCovXY(Double_t *cov) const { memcpy(cov, &fCov[0], 3*sizeof(Double_t));}
   void      GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov, 7*sizeof(Double_t));}
-  static Double_t GetCovSqrt(Double_t *c, Double_t *d);
-  static Double_t GetCovInv(Double_t *c, Double_t *d);
+  static Double_t GetCovSqrt(const Double_t * const c, Double_t *d);
+  static Double_t GetCovInv(const Double_t * const c, Double_t *d);
+  UChar_t   GetErrorMsg() const      { return fErrorMsg;}
   Float_t   GetdX() const            { return fdX;}
-  Float_t*  GetdEdx()                { return &fdEdx[0];}
-  Float_t   GetdQdl(Int_t ic, Float_t *dx=0x0) const;
+  const Float_t*  GetdEdx() const    { return &fdEdx[0];}
+  Float_t   GetdQdl(Int_t ic, Float_t *dx=NULL) const;
   Float_t   GetdYdX() const          { return fYfit[1]; } 
   Float_t   GetdZdX() const          { return fZref[1]; }
   Int_t     GetdY() const            { return Int_t(GetY()/0.014);}
   Int_t     GetDetector() const      { return fDet;}
   void      GetCalibParam(Float_t &exb, Float_t &vd, Float_t &t0, Float_t &s2, Float_t &dl, Float_t &dt) const    { 
               exb = fExB; vd = fVD; t0 = fT0; s2 = fS2PRF; dl = fDiffL; dt = fDiffT;}
-  AliTRDcluster*  GetClusters(Int_t i) const               { return i<0 || i>=kNclusters ? 0x0 : fClusters[i];}
+  AliTRDcluster*  GetClusters(Int_t i) const               { return i<0 || i>=kNclusters ? NULL: fClusters[i];}
   Int_t     GetIndexes(Int_t i) const{ return i<0 || i>=kNclusters ? -1 : fIndexes[i];}
   Int_t     GetLabels(Int_t i) const { return fLabels[i];}  
-  Float_t   GetMomentum(Float_t *err = 0x0) const;
-  Int_t     GetN() const             { return (Int_t)fN&0x1f;}
+  Float_t   GetMomentum(Float_t *err = NULL) const;
+  Int_t     GetN() const             { return (Int_t)fN&kMask;}
   Int_t     GetN2() const            { return GetN();}
-  Int_t     GetNUsed() const         { return Int_t((fN>>5)&0x1f);}
-  Int_t     GetNShared() const       { return Int_t((fN>>10)&0x1f);}
+  Int_t     GetNUsed() const         { return Int_t((fN>>kNbits)&kMask);}
+  Int_t     GetNShared() const       { return Int_t(((fN>>kNbits)>>kNbits)&kMask);}
   Float_t   GetQuality(Bool_t kZcorr) const;
   Float_t   GetPadLength() const     { return fPad[0];}
   Float_t   GetPadWidth() const      { return fPad[1];}
@@ -129,7 +143,7 @@ public:
   Float_t   GetS2Z() const           { return fS2Z;}
   Float_t   GetSigmaY() const        { return fS2Y > 0. ? TMath::Sqrt(fS2Y) : 0.2;}
   Float_t   GetSnp() const           { return fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
-  Float_t   GetTgl() const           { return fZref[1];}
+  Float_t   GetTgl() const           { return fZref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);}
   Float_t   GetTilt() const          { return fPad[2];}
   UInt_t    GetTrackletWord() const  { return 0;}
   UShort_t  GetVolumeId() const;
@@ -137,24 +151,25 @@ public:
   Float_t   GetX() const             { return fX0 - fX;}
   Float_t   GetY() const             { return fYfit[0] - fYfit[1] * fX;}
   Double_t  GetYat(Double_t x) const { return fYfit[0] - fYfit[1] * (fX0-x);}
-  Float_t   GetYfit(Int_t id) const { return fYfit[id];}
-  Float_t   GetYref(Int_t id) const { return fYref[id];}
-  Float_t   GetZ() const            { return fZfit[0] - fZfit[1] * fX;}
+  Float_t   GetYfit(Int_t id) const  { return fYfit[id];}
+  Float_t   GetYref(Int_t id) const  { return fYref[id];}
+  Float_t   GetZ() const             { return fZfit[0] - fZfit[1] * fX;}
   Double_t  GetZat(Double_t x) const { return fZfit[0] - fZfit[1] * (fX0-x);}
-  Float_t   GetZfit(Int_t id) const { return fZfit[id];}
-  Float_t   GetZref(Int_t id) const { return fZref[id];}
-  Int_t     GetYbin() const         { return Int_t(GetY()/0.016);}
-  Int_t     GetZbin() const         { return Int_t(GetZ()/fPad[0]);}
+  Float_t   GetZfit(Int_t id) const  { return fZfit[id];}
+  Float_t   GetZref(Int_t id) const  { return fZref[id];}
+  Int_t     GetYbin() const          { return Int_t(GetY()/0.016);}
+  Int_t     GetZbin() const          { return Int_t(GetZ()/fPad[0]);}
 
   inline AliTRDcluster* NextCluster();
   inline AliTRDcluster* PrevCluster();
   void      Print(Option_t *o = "") const;
   inline void ResetClusterIter(Bool_t forward = kTRUE);
-  void      Reset();
+  void      Reset(Option_t *opt="");
 
-  void      SetC(Float_t c)         { fC = c;}
-  void      SetChi2(Float_t chi2)   { fChi2 = chi2;}
+  void      SetC(Float_t c)          { fC = c;}
+  void      SetChi2(Float_t chi2)    { fChi2 = chi2;}
   inline void SetCovRef(const Double_t *cov);
+  void      SetErrorMsg(Int_t err)   { fErrorMsg = err;}
   void      SetIndexes(Int_t i, Int_t idx) { fIndexes[i]  = idx; }
   void      SetLabels(Int_t *lbls)   { memcpy(fLabels, lbls, 3*sizeof(Int_t)); }
   void      SetKink(Bool_t k = kTRUE){ SetBit(kKink, k);}
@@ -168,7 +183,7 @@ public:
   void      SetTilt(Float_t tilt)    { fPad[2] = tilt; }
   void      SetDetector(Int_t d)     { fDet = d;  }
   void      SetDX(Float_t inDX)      { fdX = inDX;}
-  void      SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
+  void      SetReconstructor(const AliTRDReconstructor *rec) {fkReconstructor = rec;}
   void      SetX0(Float_t x0)        { fX0 = x0; }
   void      SetYref(Int_t i, Float_t y) { fYref[i]     = y;}
   void      SetZref(Int_t i, Float_t z) { fZref[i]     = z;}
@@ -184,25 +199,28 @@ private:
   inline void SetN(Int_t n);
   inline void SetNUsed(Int_t n);
   inline void SetNShared(Int_t n);
+  inline void Swap(Int_t &n1, Int_t &n2);
+  inline void Swap(Double_t &d1, Double_t &d2);
 
-  const AliTRDReconstructor *fReconstructor;//! local reconstructor
+  const AliTRDReconstructor *fkReconstructor;//! local reconstructor
   AliTRDcluster  **fClusterIter;            //! clusters iterator
   Int_t            fIndexes[kNclusters];    //! Indexes
-  Float_t          fExB;                    //! tg(a_L) @ tracklet location
-  Float_t          fVD;                     //! drift velocity @ tracklet location
-  Float_t          fT0;                     //! time 0 @ tracklet location
-  Float_t          fS2PRF;                  //! sigma^2 PRF for xd->0 and phi=a_L 
-  Float_t          fDiffL;                  //! longitudinal diffusion coefficient
-  Float_t          fDiffT;                  //! transversal diffusion coefficient
+  Float_t          fExB;                    // tg(a_L) @ tracklet location
+  Float_t          fVD;                     // drift velocity @ tracklet location
+  Float_t          fT0;                     // time 0 @ tracklet location
+  Float_t          fS2PRF;                  // sigma^2 PRF for xd->0 and phi=a_L 
+  Float_t          fDiffL;                  // longitudinal diffusion coefficient
+  Float_t          fDiffT;                  // transversal diffusion coefficient
   Char_t           fClusterIdx;             //! clusters iterator
-  UShort_t         fN;                      // number of clusters attached/used/shared
+  UChar_t          fErrorMsg;               // processing error
+  UInt_t           fN;                      // number of clusters attached/used/shared
   Short_t          fDet;                    // TRD detector
   AliTRDcluster   *fClusters[kNclusters];   // Clusters
   Float_t          fPad[3];                 // local pad definition : length/width/tilt 
-  Float_t          fYref[2];                //  Reference y
-  Float_t          fZref[2];                //  Reference z
-  Float_t          fYfit[2];                //  Y fit position +derivation
-  Float_t          fZfit[2];                //  Z fit position
+  Float_t          fYref[2];                //  Reference y, dydx
+  Float_t          fZref[2];                //  Reference z, dz/dx
+  Float_t          fYfit[2];                //  Fit y, dy/dx
+  Float_t          fZfit[2];                //  Fit z
   Float_t          fPt;                     //  Pt estimate @ tracklet [GeV/c]
   Float_t          fdX;                     // length of time bin
   Float_t          fX0;                     // anode wire position
@@ -214,12 +232,12 @@ private:
   Float_t          fC;                      // Curvature
   Float_t          fChi2;                   // Global chi2  
   Float_t          fdEdx[kNslices];         // dE/dx measurements for tracklet
-  Float_t          fProb[AliPID::kSPECIES]; //  PID probabilities
+  Float_t          fProb[AliPID::kSPECIES]; // PID probabilities
   Int_t            fLabels[3];              // most frequent MC labels and total number of different labels
   Double_t         fRefCov[7];              // covariance matrix of the track in the yz plane + the rest of the diagonal elements
   Double_t         fCov[3];                 // covariance matrix of the tracklet in the xy plane
 
-  ClassDef(AliTRDseedV1, 7)                 // The offline TRD tracklet 
+  ClassDef(AliTRDseedV1, 10)                 // The offline TRD tracklet 
 };
 
 //____________________________________________________________
@@ -266,6 +284,13 @@ inline void AliTRDseedV1::Init(const AliRieman *rieman)
   fZref[1] = rieman->GetDZat(fX0);
   fYref[0] = rieman->GetYat(fX0);
   fYref[1] = rieman->GetDYat(fX0);
+  if(fkReconstructor && fkReconstructor->IsHLT()){
+    fRefCov[0] = 1;
+    fRefCov[2] = 10;
+  }else{
+    fRefCov[0] = rieman->GetErrY(fX0);
+    fRefCov[2] = rieman->GetErrZ(fX0);
+  }
   fC       = rieman->GetC(); 
   fChi2    = rieman->GetChi2();
 }
@@ -285,7 +310,7 @@ inline AliTRDcluster* AliTRDseedV1::NextCluster()
     }
     return *fClusterIter;
   }
-  return 0x0;
+  return NULL;
 }
 
 //____________________________________________________________
@@ -303,7 +328,7 @@ inline AliTRDcluster* AliTRDseedV1::PrevCluster()
     }
     return *fClusterIter;
   }
-  return 0x0;
+  return NULL;
 }
 
 //____________________________________________________________
@@ -343,25 +368,43 @@ inline void AliTRDseedV1::SetCovRef(const Double_t *cov)
 //____________________________________________________________
 inline void AliTRDseedV1::SetN(Int_t n)
 {
-  if(n<0 || n>= (1<<5)) return; 
-  fN &= ~0x1f;
-  fN |= n;
+  if(n<0 || n>kNclusters) return; 
+  fN &= ~kMask; 
+  fN |= (n&kMask);
 }
 
 //____________________________________________________________
 inline void AliTRDseedV1::SetNUsed(Int_t n)
 {
-  if(n<0 || n>= (1<<5)) return; 
-  fN &= ~(0x1f<<5);
-  n <<= 5; fN |= n;
+  if(n<0 || n>kNclusters) return; 
+  UInt_t mask(kMask<<kNbits); 
+  fN &= ~mask;
+  n=n<<kNbits; fN |= (n&mask);
 }
 
 //____________________________________________________________
 inline void AliTRDseedV1::SetNShared(Int_t n)
 {
-  if(n<0 || n>= (1<<5)) return; 
-  fN &= ~(0x1f<<10);
-  n <<= 10; fN |= n;
+  if(n<0 || n>kNclusters) return; 
+  UInt_t mask((kMask<<kNbits)<<kNbits); 
+  fN &= ~mask;
+  n = (n<<kNbits)<<kNbits; fN|=(n&mask);
+}
+
+//____________________________________________________________
+inline void AliTRDseedV1::Swap(Int_t &n1, Int_t &n2)
+{
+// swap values of n1 with n2
+  Int_t tmp(n1);
+  n1=n2; n2=tmp;
+}
+
+//____________________________________________________________
+inline void AliTRDseedV1::Swap(Double_t &d1, Double_t &d2)
+{
+// swap values of d1 with d2
+  Double_t tmp(d1);
+  d1=d2; d2=tmp;
 }