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