]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITStrackerV2.h
speed optimization
[u/mrichter/AliRoot.git] / ITS / AliITStrackerV2.h
1 #ifndef ALIITSTRACKERV2_H
2 #define ALIITSTRACKERV2_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 //-------------------------------------------------------------------------
7 //                          ITS tracker
8 //     reads AliITSclusterV2 clusters and creates AliITStrackV2 tracks
9 //           Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch 
10 //-------------------------------------------------------------------------
11
12 #include <TObjArray.h>
13
14 #include "AliTracker.h"
15 #include "AliITSrecoV2.h"
16 #include "AliITStrackV2.h"
17
18 class AliITSclusterV2;
19 class AliESD;
20 class AliITSgeom;
21 class TTree;
22
23
24 //-------------------------------------------------------------------------
25 class AliITStrackerV2 : public AliTracker {
26 public:
27   AliITStrackerV2():AliTracker(){}
28   AliITStrackerV2(const AliITSgeom *geom);
29   AliCluster *GetCluster(Int_t index) const;
30   AliITSclusterV2 *GetClusterLayer(Int_t layn, Int_t ncl) const
31                         {return fgLayers[layn].GetCluster(ncl);}
32   Int_t GetNumberOfClustersLayer(Int_t layn) const 
33                         {return fgLayers[layn].GetNumberOfClusters();}
34   Int_t LoadClusters(TTree *cf);
35   void UnloadClusters();
36   Int_t Clusters2Tracks(TTree *in, TTree *out);
37   Int_t Clusters2Tracks(AliESD *event);
38   Int_t PropagateBack(AliESD *event);
39   Int_t RefitInward(AliESD *event);
40   Bool_t RefitAt(Double_t x, AliITStrackV2 *seed, const AliITStrackV2 *t);
41   void SetupFirstPass(Int_t *flags, Double_t *cuts=0);
42   void SetupSecondPass(Int_t *flags, Double_t *cuts=0);
43
44   void SetLastLayerToTrackTo(Int_t l=0) {fLastLayerToTrackTo=l;} 
45   void SetLayersNotToSkip(Int_t *l);
46
47   void UseClusters(const AliKalmanTrack *t, Int_t from=0) const;
48
49   class AliITSdetector { 
50   public:
51     AliITSdetector(){}
52     AliITSdetector(Double_t r,Double_t phi) {fR=r; fPhi=phi;}
53     Double_t GetR()   const {return fR;}
54     Double_t GetPhi() const {return fPhi;}
55   private:
56     Double_t fR;    // polar coordinates 
57     Double_t fPhi;  // of this detector
58   };
59
60   class AliITSlayer {
61     friend class AliITStrackerV2;
62   public:
63     AliITSlayer();
64     AliITSlayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
65    ~AliITSlayer();
66     Int_t InsertCluster(AliITSclusterV2 *c);
67     void ResetClusters();
68     void ResetWeights();
69     void SelectClusters(Double_t zmi,Double_t zma,Double_t ymi,Double_t yma);
70     const AliITSclusterV2 *GetNextCluster(Int_t &ci);
71     void ResetRoad();
72     Double_t GetRoad() const {return fRoad;}
73     Double_t GetR() const {return fR;}
74     AliITSclusterV2 *GetCluster(Int_t i) const {return i<fN? fClusters[i]:0;} 
75     Float_t         *GetWeight(Int_t i) {return i<fN ?&fClusterWeight[i]:0;}
76     AliITSdetector &GetDetector(Int_t n) const { return fDetectors[n]; }
77     Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
78     Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
79     Int_t InRoad() const ;
80     Int_t GetNumberOfClusters() const {return fN;}
81     Int_t GetNladders() const {return fNladders;}
82     Int_t GetNdetectors() const {return fNdetectors;}
83   protected:
84     Double_t fR;                // mean radius of this layer
85     Double_t fPhiOffset;        // offset of the first detector in Phi
86     Int_t fNladders;            // number of ladders
87     Double_t fZOffset;          // offset of the first detector in Z
88     Int_t fNdetectors;          // detectors/ladder
89     AliITSdetector *fDetectors; // array of detectors
90     Int_t fN;                   // number of clusters
91     AliITSclusterV2 *fClusters[kMaxClusterPerLayer]; // pointers to clusters
92     Float_t  fClusterWeight[kMaxClusterPerLayer]; // probabilistic weight of the cluster
93     Double_t fZmax;      //    edges
94     Double_t fYmin;      //   of  the
95     Double_t fYmax;      //   "window"
96     Int_t fI;            // index of the current cluster within the "window"
97     Double_t fRoad;      // road defined by the cluster density
98     Int_t FindClusterIndex(Double_t z) const;
99   };
100   
101 protected:
102   void CookLabel(AliKalmanTrack *t,Float_t wrong) const;
103   Double_t GetEffectiveThickness(Double_t y, Double_t z) const;
104   void  FollowProlongation();
105   Int_t TakeNextProlongation();
106   void ResetBestTrack() {
107      fBestTrack.~AliITStrackV2();
108      new(&fBestTrack) AliITStrackV2(fTrackToFollow);
109   }
110   void ResetTrackToFollow(const AliITStrackV2 &t) {
111      fTrackToFollow.~AliITStrackV2();
112      new(&fTrackToFollow) AliITStrackV2(t);
113   }
114   Float_t    *GetWeight(Int_t index);
115   void AddTrackHypothesys(AliITStrackV2 * track, Int_t esdindex);
116   void SortTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel);
117   void CompressTrackHypothesys(Int_t esdindex, Float_t likelihoodlevel, Int_t maxsize);
118   AliITStrackV2 * GetBestHypothesys(Int_t esdindex, AliITStrackV2 * original, Int_t checkmax); 
119   AliITStrackV2 * GetBestHypothesysMIP(Int_t esdindex, AliITStrackV2 * original); 
120   Int_t fI;                              // index of the current layer
121   static AliITSlayer fgLayers[kMaxLayer];// ITS layers
122   AliITStrackV2 fTracks[kMaxLayer];      // track estimations at the ITS layers
123   AliITStrackV2 fBestTrack;              // "best" track 
124   AliITStrackV2 fTrackToFollow;          // followed track
125   TObjArray     fTrackHypothesys;        // ! array with track hypothesys- ARRAY is the owner of tracks- MI
126   Int_t         fCurrentEsdTrack;        // ! current esd track           - MI
127   Int_t fPass;                           // current pass through the data 
128   Int_t fConstraint[2];                  // constraint flags
129
130   Int_t fLayersNotToSkip[kMaxLayer];     // layer masks
131   Int_t fLastLayerToTrackTo;             // the innermost layer to track to
132   ClassDef(AliITStrackerV2,1)   //ITS tracker V2
133 };
134
135
136 inline void AliITStrackerV2::SetupFirstPass(Int_t *flags, Double_t *cuts) {
137   // This function sets up flags and cuts for the first tracking pass   
138   //
139   //   flags[0] - vertex constaint flag                                
140   //              negative means "skip the pass"                        
141   //              0        means "no constraint"                        
142   //              positive means "normal constraint"                    
143
144    fConstraint[0]=flags[0];
145    if (cuts==0) return;
146 }
147
148 inline void AliITStrackerV2::SetupSecondPass(Int_t *flags, Double_t *cuts) {
149   // This function sets up flags and cuts for the second tracking pass   
150   //
151   //   flags[0] - vertex constaint flag                                
152   //              negative means "skip the pass"                        
153   //              0        means "no constraint"                        
154   //              positive means "normal constraint"                    
155
156    fConstraint[1]=flags[0];
157    if (cuts==0) return;
158 }
159
160 inline void AliITStrackerV2::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
161   //--------------------------------------------------------------------
162   //This function "cooks" a track label. If label<0, this track is fake.
163   //--------------------------------------------------------------------
164    Int_t tpcLabel=t->GetLabel();
165    if (tpcLabel<0) return;
166    AliTracker::CookLabel(t,wrong);
167    if (tpcLabel!=TMath::Abs(t->GetLabel())){
168      t->SetFakeRatio(1.);
169    }
170    if (tpcLabel !=t->GetLabel()) {
171      t->SetLabel(-tpcLabel);      
172    }
173 }
174
175 #endif