]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/ITSUpgradeRec/AliITSUSeed.h
ITS UPGRADE
[u/mrichter/AliRoot.git] / ITS / UPGRADE / ITSUpgradeRec / AliITSUSeed.h
1 #ifndef ALIITSUSEED_H
2 #define ALIITSUSEED_H
3
4 #include "AliExternalTrackParam.h"
5 #include "AliITSUAux.h"
6 class AliESDtrack;
7
8 using namespace AliITSUAux;
9
10
11 class AliITSUSeed: public AliExternalTrackParam
12 {
13  public:
14   enum {kKilled=BIT(14),kSave=BIT(15),kMark=BIT(16),kFake=BIT(17)};
15   enum {kF02,kF04,kF12,kF13,kF14,kF24, kF44,kNFElem}; // non-trivial elems of propagation matrix
16   enum {kK00,kK01,kK10,kK11,kK20,kK21,kK30,kK31,kK40,kK41, kNKElem}; // non-trivial elems of gain matrix
17   enum {kS00,kS10,kS11,kS20,kS21,kS22,kS30,kS31,kS32,kS33,kS40,kS41,kS42,kS43,kS44,kNSElem}; // elements of 5x5 sym matrix
18   enum {kR00,kR22,kNRElem};                        // non trivial elements of rotation matrix
19   //
20   AliITSUSeed();
21   AliITSUSeed(const AliITSUSeed& src);
22   AliITSUSeed &operator=(const AliITSUSeed &src);
23   virtual ~AliITSUSeed();
24   virtual void    Print(Option_t* option = "") const;
25   //
26   void            SetLrClusterID(Int_t lr, Int_t cl);
27   void            SetLr(Int_t lr)                        {SetLrClusterID(lr,-1);} // lr w/o cluster
28   void            SetLrClusterID(UInt_t id)              {fClID = id;}
29   void            SetParent(TObject* par)                {fParent = par;}
30   void            SetChi2Cl(Double_t v)                  {fChi2Cl= v; v>0 ? fChi2Glo+=v : fChi2Penalty -= v;}
31   void            Kill(Bool_t v=kTRUE)                   {SetBit(kKilled, v);}
32   void            SetFake(Bool_t v=kTRUE)                {SetBit(kFake, v);}
33   void            Save(Bool_t v=kTRUE)                   {SetBit(kSave,v);}
34   void            SetMark(Bool_t v=kTRUE)                {SetBit(kMark,v);}
35   void            FlagTree(UInt_t bits, Bool_t v=kTRUE);
36   void            SetChi2ITSTPC(Float_t v)               {fChi2Match = v;}
37   void            SetChi2ITSSA(Float_t v)                {fChi2ITSSA = v;}
38   //
39   UInt_t          GetLrClusterID()                 const {return fClID;}
40   Int_t           GetLrCluster(Int_t &lr)          const {return UnpackCluster(fClID,lr);}
41   Int_t           GetLayerID()                     const {return UnpackLayer(fClID);}
42   Int_t           GetClusterID()                   const {return UnpackCluster(fClID);}
43   Bool_t          HasClusterOnLayer(Int_t lr)      const {return fHitsPattern&(0x1<<lr);}
44   Bool_t          HasCluster()                     const {return IsCluster(fClID);}
45   Int_t           GetNLayersHit()                  const {return NumberOfBitsSet(fHitsPattern);}
46   Int_t           GetNClusters()                   const;
47   Int_t           GetClusterIndex(Int_t ind)       const;
48   UShort_t        GetHitsPattern()                 const {return fHitsPattern;}
49   Float_t         GetChi2Cl()                      const {return fChi2Cl;}
50   Float_t         GetChi2Glo()                     const {return fChi2Glo;}
51   Float_t         GetChi2Penalty()                 const {return fChi2Penalty;}
52   Float_t         GetChi2GloNrm()                  const;
53   Float_t         GetChi2ITSTPC()                  const {return fChi2Match;}
54   Float_t         GetChi2ITSSA()                   const {return fChi2ITSSA;}
55   Float_t         GetQualityVar()                  const;
56   Bool_t          IsKilled()                       const {return TestBit(kKilled);}
57   Bool_t          IsFake()                         const {return TestBit(kFake);}
58   Bool_t          IsSaved()                        const {return TestBit(kSave);}
59   Bool_t          IsMarked()                       const {return TestBit(kMark);}
60   Bool_t          ContainsFake()                   const;
61   Int_t           FetchClusterInfo(Int_t *clIDarr) const;
62   //
63   Int_t           GetPoolID()                      const {return int(GetUniqueID())-1;}
64   void            SetPoolID(Int_t id)                    {SetUniqueID(id+1);}
65   //
66   TObject*        GetParent()                      const {return fParent;}
67   const AliITSUSeed* GetParent(Int_t lr)              const;
68   //
69   virtual Bool_t  IsSortable()                     const {return kTRUE;}
70   virtual Bool_t  IsEqual(const TObject* obj)      const;
71   virtual Int_t   Compare(const TObject* obj)      const;
72   //
73   // test
74   void            InitFromSeed(const AliExternalTrackParam* seed);
75   void            ResetFMatrix();
76   void            ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp);
77   Bool_t          ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp);
78   Bool_t          PropagateToX(Double_t xk, Double_t b);
79   Bool_t          RotateToAlpha(Double_t alpha);
80   Bool_t          GetTrackingXAtXAlpha(double xOther,double alpOther,double bz, double &x);
81   Double_t        GetPredictedChi2(Double_t p[2],Double_t cov[3]);
82   Bool_t          Update();
83   Bool_t          Smooth(Double_t vecL[5],Double_t matL[15]);
84   Double_t*       ProdABA(const double a[15],const double b[15]) const;
85   //
86   UInt_t          GetNChildren()                                 const {return fNChildren;}
87   Int_t           IncChildren()                                        {return ++fNChildren;}
88   Int_t           DecChildren()                                        {return --fNChildren;}
89   Double_t        GetResidY()                                    const {return fResid[0];}
90   Double_t        GetResidZ()                                    const {return fResid[1];}
91   //
92 #ifdef _ITSU_TUNING_MODE_ // this is used only for tuning histo filling
93   void                  SetOrdBranch(UShort_t v) {fOrdBranch=v;}
94   void                  SetOrdCand(UShort_t v)   {fOrdCand=v;}
95   Int_t                 GetOrdBranch()           const {return fOrdBranch;}
96   Int_t                 GetOrdCand()             const {return fOrdCand;}
97   Double_t              GetPullY()               const {return fResid[0]*Sqrt(fCovIYZ[0]);}
98   Double_t              GetPullZ()               const {return fResid[1]*Sqrt(fCovIYZ[2]);}
99 #endif
100   //
101  protected:
102   //
103   UShort_t              fHitsPattern;       // bit pattern of hits
104   UShort_t              fNChildren;         // number of children (prolongations)
105   UInt_t                fClID;              // packed cluster info (see AliITSUAux::PackCluster)
106   Float_t               fChi2Glo;           // current chi2 global (sum of track-cluster chi2's on layers with hit)
107   Float_t               fChi2Cl;            // track-cluster chi2 (if >0) or penalty for missing cluster (if < 0)
108   Float_t               fChi2Penalty;       // total penalty (e.g. for missing clusters)
109   Float_t               fChi2Match;         // ITS/TPC matching chi2 (per NDF)  // RS: to move to separate object of final seed
110   Float_t               fChi2ITSSA;         // ITSSA backward fit chi2 (per NDF) // RS: to move to separate object of final seed
111   Double_t              fFMatrix[kNFElem];  // matrix of propagation from prev layer (non-trivial elements)
112   Double_t              fKMatrix[kNKElem];  // Gain matrix non-trivial elements (note: standard MBF formula uses I-K*H)
113   Double_t              fRMatrix[kNRElem];  // rotation matrix non-trivial elements
114   Double_t              fCovIYZ[3];         // inverted matrix of propagation + meas errors = [Hi * Pi|i-1 * Hi^T + Ri]^-1
115   Double_t              fResid[2];          // residuals vector
116   TObject*              fParent;            // parent track (in higher tree hierarchy)
117   //
118 #ifdef _ITSU_TUNING_MODE_ // this is used only for tuning histo filling
119   UShort_t              fOrdBranch;         //! order in the seed branching
120   UShort_t              fOrdCand;           //! order in candidates tree
121 #endif
122   //
123   ClassDef(AliITSUSeed,1)
124 };
125
126 //_________________________________________________________________________
127 inline void AliITSUSeed::SetLrClusterID(Int_t lr, Int_t cl)
128 {
129   // assign layer, cluster (if -1 - no hit on this layer)
130   fClID = PackCluster(lr,cl);
131   if (cl>=0) fHitsPattern |= 0x1<<lr;
132 }
133
134 //_________________________________________________________________________
135 inline void AliITSUSeed::ResetFMatrix()
136 {
137   // reset transport matrix
138   fFMatrix[kF02] = fFMatrix[kF04] = fFMatrix[kF12] = fFMatrix[kF13] = fFMatrix[kF14] = fFMatrix[kF24] = 0;
139   fFMatrix[kF44] = 1.0;  // this element accumulates eloss 
140 }
141
142 //_________________________________________________________________________
143 inline Bool_t AliITSUSeed::ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp)
144 {
145   // apply material correction and modify transport matrix
146   double pold = Get1P();
147   if (!CorrectForMeanMaterial(xOverX0,xTimesRho,mass)) return kFALSE;
148   ApplyELoss2FMatrix( Get1P()/pold, beforeProp);
149   return kTRUE;
150 }
151
152
153 //_________________________________________________________________________
154 inline void AliITSUSeed::ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp)
155 {
156   // Accounts for the energy loss in the transport matrix
157   // equivalent to multiplying Fmatix by E=diag{1,1,1,1,P4new/P4old}, where P4 is the 1/pt param.
158   // If beforeProp is true, then it is assumed that the eloss was applied before the transport,
159   // i.e. F' = F * E, otherwise, after transport, F' = E * F
160   fFMatrix[kF44] *= frac;
161   if (beforeProp) {
162     fFMatrix[kF04] *= frac;
163     fFMatrix[kF14] *= frac;
164     fFMatrix[kF24] *= frac;
165   }
166 }
167
168 //_________________________________________________________________________
169 inline const AliITSUSeed* AliITSUSeed::GetParent(Int_t lr) const
170 {
171   // get parent at given layer
172   const AliITSUSeed* par=this;
173   int lrt;
174   while( par && (lrt=par->GetLayerID())>=0 ) {
175     if (lrt==lr) break;
176     par = dynamic_cast<const AliITSUSeed*>(par->GetParent());
177   }
178   return par;
179 }
180
181 //__________________________________________________________________
182 inline Int_t AliITSUSeed::GetNClusters() const
183 {
184   // count number of clusters (some layers may have >1 hit)
185   int ncl = 0;
186   const AliITSUSeed* seed = this;
187   while(seed) {
188     if (seed->HasCluster()) ncl++;
189     seed = (AliITSUSeed*)seed->GetParent();
190   }
191   return ncl;
192   //
193 }
194
195 //__________________________________________________________________
196 inline void AliITSUSeed::FlagTree(UInt_t bits, Bool_t v)
197 {
198   // set bits on all tree levels
199   AliITSUSeed* seed = this;
200   do {seed->SetBit(bits,v);} while ( (seed=(AliITSUSeed*)seed->GetParent()) );
201   //
202 }
203
204 //__________________________________________________________________
205 inline Float_t AliITSUSeed::GetQualityVar() const
206 {
207   // return variable for quality check (the smaller - the better)
208   //  return GetChi2ITSSA()/Pt(); // this may change! RS
209   return GetChi2GloNrm()/Pt();
210 }
211
212
213 #endif