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