]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDseedV1.h
fix tracklet fit in the reconstruction code
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.h
1 #ifndef ALITRDSEEDV1_H
2 #define ALITRDSEEDV1_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ////////////////////////////////////////////////////////////////////////////
9 //                                                                        //
10 //  The TRD track seed                                                    //
11 //                                                                        //
12 ////////////////////////////////////////////////////////////////////////////
13
14 #ifndef ALITRDSEED_H
15 #include "AliTRDseed.h"
16 #endif
17
18 #ifndef ALITRDGEOMETRY_H
19 #include "AliTRDgeometry.h"
20 #endif
21
22 #ifndef ALIPID_H
23 #include "AliPID.h"
24 #endif
25
26 #ifndef ALIRIEMAN_H
27 #include "AliRieman.h"
28 #endif
29
30 class TTreeSRedirector;
31
32 class AliRieman;
33
34 class AliTRDtrackingChamber;
35 class AliTRDcluster;
36 class AliTRDtrackV1;
37 class AliTRDReconstructor;
38 class AliTRDseedV1 : public AliTRDseed
39 {
40
41   public:
42
43   enum {
44     knSlices = 10
45   };
46   // bits from 0-13 are reserved by ROOT (see TObject.h)
47   enum AliTRDtrackletStatus {
48     kOwner    = BIT(14)
49   , kRowCross = BIT(15) 
50   };
51
52   AliTRDseedV1(Int_t det = -1);
53   ~AliTRDseedV1();
54   AliTRDseedV1(const AliTRDseedV1 &ref);
55   AliTRDseedV1& operator=(const AliTRDseedV1 &ref);
56
57   Bool_t          AttachClustersIter(
58               AliTRDtrackingChamber *chamber, Float_t quality, 
59               Bool_t kZcorr = kFALSE, AliTRDcluster *c=0x0);
60   Bool_t          AttachClusters(
61               AliTRDtrackingChamber *chamber, Bool_t kZcorr = kFALSE);
62   void      Bootstrap(const AliTRDReconstructor *rec);
63   void      CookdEdx(Int_t nslices);
64   Bool_t    Fit(Bool_t tilt=kTRUE);
65
66   Bool_t    Init(AliTRDtrackV1 *track);
67   inline void      Init(const AliRieman *fit);
68   Bool_t    IsEqual(const TObject *inTracklet) const;
69   Bool_t    IsOwner() const          { return TestBit(kOwner);}
70   Bool_t    IsRowCross() const       { return TestBit(kRowCross);}
71
72   inline Float_t   GetChi2Z(const Float_t z = 999.) const;
73   inline Float_t   GetChi2Y(const Float_t y = 999.) const;
74   void      GetCovAt(Double_t x, Double_t *cov) const;
75   void      GetCovRef(Double_t *cov) const { memcpy(cov, &fRefCov[0], 3*sizeof(Double_t));}
76   Double_t* GetCrossXYZ()            { return &fCross[0];}
77   Double_t  GetCrossSz2() const      { return fCross[3];}
78   Float_t   GetdX() const            { return fdX;}
79   Float_t*  GetdEdx()                { return &fdEdx[0];}
80   Float_t   GetdQdl(Int_t ic) const;
81   Int_t     GetDetector() const      { return fDet;}
82   Double_t  GetMomentum() const      { return fMom;}
83   Int_t     GetN() const             { return fN2;}
84   Float_t   GetQuality(Bool_t kZcorr) const;
85   Int_t     GetPlane() const         { return AliTRDgeometry::GetLayer(fDet);    }
86
87   Double_t* GetProbability();
88   Double_t  GetSnp() const           { return fSnp;}
89   Double_t  GetTgl() const           { return fTgl;}
90   Float_t   GetXref() const          { return fXref;}
91   Double_t  GetYat(Double_t x) const { return fYfit[0] + fYfit[1] * (fX0-x);}
92   Double_t  GetZat(Double_t x) const { return fZfit[0] + fZfit[1] * (fX0-x);}
93   
94   inline AliTRDcluster* NextCluster();
95   inline AliTRDcluster* PrevCluster();
96   void      Print(Option_t *o = "") const;
97   inline void ResetClusterIter(Bool_t forward = kTRUE);
98
99   void      SetCovRef(const Double_t *cov) { memcpy(&fRefCov[0], cov, 3*sizeof(Double_t));}
100   void      SetMomentum(Double_t mom){ fMom = mom;}
101   void      SetOwner();
102   void      SetDetector(Int_t d)     { fDet = d;  }
103   void      SetDX(Float_t inDX)      { fdX = inDX;}
104   void      SetSnp(Double_t snp)     { fSnp = snp;}
105   void      SetTgl(Double_t tgl)     { fTgl = tgl;}
106   void      SetReconstructor(const AliTRDReconstructor *rec) {fReconstructor = rec;}
107 protected:
108
109   void Copy(TObject &ref) const;
110
111 private:
112   const AliTRDReconstructor *fReconstructor;//! local reconstructor
113   AliTRDcluster    **fClusterIter;          //! clusters iterator
114   Char_t           fClusterIdx;             //! clusters iterator
115   Int_t            fDet;                    //  TRD detector
116   Float_t          fMom;                    //  Momentum estimate for tracklet [GeV/c]
117   Float_t          fSnp;                    // sin of track with respect to x direction in XY plane     
118   Float_t          fTgl;                    // tg of track with respect to x direction in XZ plane      
119   Float_t          fdX;                     // length of time bin
120   Float_t          fXref;                   // average radial position of clusters
121   Float_t          fdEdx[knSlices];         // dE/dx measurements for tracklet
122   Double_t         fCross[4];               // spatial parameters of the pad row crossing
123   Double_t         fRefCov[3];              // covariance matrix of the track in the yz plane
124   Double_t         fProb[AliPID::kSPECIES]; //  PID probabilities
125
126   ClassDef(AliTRDseedV1, 3)                 //  New TRD seed 
127
128 };
129
130 //____________________________________________________________
131 inline Float_t AliTRDseedV1::GetChi2Z(const Float_t z) const
132 {
133   Float_t z1  = (z == 999.) ? fMeanz : z;
134   Float_t chi = fZref[0] - z1;
135   return chi*chi;
136 }
137
138 //____________________________________________________________
139 inline Float_t AliTRDseedV1::GetChi2Y(const Float_t y) const
140 {
141   Float_t y1  = (y == 999.) ? fYfitR[0] : y;
142   Float_t chi = fYref[0] - y1;
143   return chi*chi;
144 }
145
146 //____________________________________________________________
147 inline void AliTRDseedV1::Init(const AliRieman *rieman)
148 {
149   fZref[0] = rieman->GetZat(fX0);
150   fZref[1] = rieman->GetDZat(fX0);
151   fYref[0] = rieman->GetYat(fX0);
152   fYref[1] = rieman->GetDYat(fX0);
153   fC       = rieman->GetC(); 
154   fChi2    = rieman->GetChi2();
155 }
156
157 //____________________________________________________________
158 inline AliTRDcluster* AliTRDseedV1::NextCluster()
159 {
160 // Mimic the usage of STL iterators.
161 // Forward iterator
162
163   fClusterIdx++; fClusterIter++;
164   while(fClusterIdx < AliTRDseed::knTimebins){
165     if(!(*fClusterIter)){ 
166       fClusterIdx++; 
167       fClusterIter++;
168       continue;
169     }
170     return *fClusterIter;
171   }
172   return 0x0;
173 }
174
175 //____________________________________________________________
176 inline AliTRDcluster* AliTRDseedV1::PrevCluster()
177 {
178 // Mimic the usage of STL iterators.
179 // Backward iterator
180
181   fClusterIdx--; fClusterIter--;
182   while(fClusterIdx >= 0){
183     if(!(*fClusterIter)){ 
184       fClusterIdx--; 
185       fClusterIter--;
186       continue;
187     }
188     return *fClusterIter;
189   }
190   return 0x0;
191 }
192
193 //____________________________________________________________
194 inline void AliTRDseedV1::ResetClusterIter(Bool_t forward) 
195 {
196 // Mimic the usage of STL iterators.
197 // Facilitate the usage of NextCluster for forward like 
198 // iterator (kTRUE) and PrevCluster for backward like iterator (kFALSE)
199
200   if(forward){
201     fClusterIter = &fClusters[0]; fClusterIter--; 
202     fClusterIdx=-1;
203   } else {
204     fClusterIter = &fClusters[AliTRDseed::knTimebins-1]; fClusterIter++; 
205     fClusterIdx=AliTRDseed::knTimebins;
206   }
207 }
208
209 #endif
210
211
212