]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUSeed.h
Added split clusters tagging (MC info used)
[u/mrichter/AliRoot.git] / ITS / UPGRADE / 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),kFake=BIT(15)};
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   //
34   UInt_t          GetLrClusterID()                 const {return fClID;}
35   Int_t           GetLrCluster(Int_t &lr)          const {return UnpackCluster(fClID,lr);}
36   Int_t           GetLayerID()                     const {return UnpackLayer(fClID);}
37   Int_t           GetClusterID()                   const {return UnpackCluster(fClID);}
38   Bool_t          HasClusterOnLayer(Int_t lr)      const {return fHitsPattern&(0x1<<lr);}
39   Bool_t          HasCluster()                     const {return IsCluster(fClID);}
40   Int_t           GetNLayersHit()                  const {return NumberOfBitsSet(fHitsPattern);}
41   Int_t           GetNClusters()                   const;
42   Int_t           GetClusterIndex(Int_t ind)       const;
43   UShort_t        GetHitsPattern()                 const {return fHitsPattern;}
44   Float_t         GetChi2Cl()                      const {return fChi2Cl;}
45   Float_t         GetChi2Glo()                     const {return fChi2Glo;}
46   Float_t         GetChi2Penalty()                 const {return fChi2Penalty;}
47   Float_t         GetChi2GloNrm()                  const;
48   Bool_t          IsKilled()                       const {return TestBit(kKilled);}
49   Bool_t          IsFake()                         const {return TestBit(kFake);}
50   Bool_t          ContainsFake()                   const;
51   //
52   Int_t           GetPoolID()                      const {return int(GetUniqueID())-1;}
53   void            SetPoolID(Int_t id)                    {SetUniqueID(id+1);}
54   //
55   TObject*        GetParent()                      const {return fParent;}
56   const AliITSUSeed* GetParent(Int_t lr)              const;
57   //
58   virtual Bool_t  IsSortable()                     const {return kTRUE;}
59   virtual Bool_t  IsEqual(const TObject* obj)      const;
60   virtual Int_t   Compare(const TObject* obj)      const;
61   //
62   // test
63   void            InitFromESDTrack(const AliESDtrack* esdTr);
64   void            ResetFMatrix();
65   void            ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp);
66   Bool_t          ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp);
67   Bool_t          PropagateToX(Double_t xk, Double_t b);
68   Bool_t          RotateToAlpha(Double_t alpha);
69   Bool_t          GetTrackingXAtXAlpha(double xOther,double alpOther,double bz, double &x);
70   Double_t        GetPredictedChi2(Double_t p[2],Double_t cov[3]);
71   Bool_t          Update();
72   Bool_t          Smooth(Double_t vecL[5],Double_t matL[15]);
73   Double_t*       ProdABA(const double a[15],const double b[15]) const;
74   //
75   UInt_t          GetNChildren()                                 const {return fNChildren;}
76   Int_t           IncChildren()                                        {return ++fNChildren;}
77   Int_t           DecChildren()                                        {return --fNChildren;}
78   //
79  protected:
80   //
81   UShort_t              fHitsPattern;       // bit pattern of hits
82   UShort_t              fNChildren;         // number of children (prolongations)
83   UInt_t                fClID;              // packed cluster info (see AliITSUAux::PackCluster)
84   Float_t               fChi2Glo;           // current chi2 global (sum of track-cluster chi2's on layers with hit)
85   Float_t               fChi2Cl;            // track-cluster chi2 (if >0) or penalty for missing cluster (if < 0)
86   Float_t               fChi2Penalty;       // total penalty (e.g. for missing clusters)
87   Double_t              fFMatrix[kNFElem];  // matrix of propagation from prev layer (non-trivial elements)
88   Double_t              fKMatrix[kNKElem];  // Gain matrix non-trivial elements (note: standard MBF formula uses I-K*H)
89   Double_t              fRMatrix[kNRElem];  // rotation matrix non-trivial elements
90   Double_t              fCovIYZ[3];         // inverted matrix of propagation + meas errors = [Hi * Pi|i-1 * Hi^T + Ri]^-1
91   Double_t              fResid[2];          // residuals vector
92   TObject*              fParent;            // parent track (in higher tree hierarchy)
93   
94   ClassDef(AliITSUSeed,1)
95 };
96
97 //_________________________________________________________________________
98 inline void AliITSUSeed::SetLrClusterID(Int_t lr, Int_t cl)
99 {
100   // assign layer, cluster (if -1 - no hit on this layer)
101   fClID = PackCluster(lr,cl);
102   if (cl>=0) fHitsPattern |= 0x1<<lr;
103 }
104
105 //_________________________________________________________________________
106 inline void AliITSUSeed::ResetFMatrix()
107 {
108   // reset transport matrix
109   fFMatrix[kF02] = fFMatrix[kF04] = fFMatrix[kF12] = fFMatrix[kF13] = fFMatrix[kF14] = fFMatrix[kF24] = 0;
110   fFMatrix[kF44] = 1.0;  // this element accumulates eloss 
111 }
112
113 //_________________________________________________________________________
114 inline Bool_t AliITSUSeed::ApplyMaterialCorrection(Double_t xOverX0, Double_t xTimesRho, Double_t mass, Bool_t beforeProp)
115 {
116   // apply material correction and modify transport matrix
117   double pold = Get1P();
118   if (!CorrectForMeanMaterial(xOverX0,xTimesRho,mass)) return kFALSE;
119   ApplyELoss2FMatrix( Get1P()/pold, beforeProp);
120   return kTRUE;
121 }
122
123
124 //_________________________________________________________________________
125 inline void AliITSUSeed::ApplyELoss2FMatrix(Double_t frac, Bool_t beforeProp)
126 {
127   // Accounts for the energy loss in the transport matrix
128   // equivalent to multiplying Fmatix by E=diag{1,1,1,1,P4new/P4old}, where P4 is the 1/pt param.
129   // If beforeProp is true, then it is assumed that the eloss was applied before the transport,
130   // i.e. F' = F * E, otherwise, after transport, F' = E * F
131   fFMatrix[kF44] *= frac;
132   if (beforeProp) {
133     fFMatrix[kF04] *= frac;
134     fFMatrix[kF14] *= frac;
135     fFMatrix[kF24] *= frac;
136   }
137 }
138
139 //_________________________________________________________________________
140 inline const AliITSUSeed* AliITSUSeed::GetParent(Int_t lr) const
141 {
142   // get parent at given layer
143   const AliITSUSeed* par=this;
144   int lrt;
145   while( par && (lrt=par->GetLayerID())>=0 ) {
146     if (lrt==lr) break;
147     par = dynamic_cast<const AliITSUSeed*>(par->GetParent());
148   }
149   return par;
150 }
151
152 //__________________________________________________________________
153 inline Int_t AliITSUSeed::GetNClusters() const
154 {
155   // count number of clusters (some layers may have >1 hit)
156   int ncl = 0;
157   const AliITSUSeed* seed = this;
158   while(seed) {
159     if (seed->HasCluster()) ncl++;
160     seed = (AliITSUSeed*)seed->GetParent();
161   }
162   return ncl;
163   //
164 }
165
166 #endif