]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITStrackerV2.h
fix bugs add new features
[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 AliITSRecPoint clusters and creates AliITStrackV2 tracks
9 //           Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch 
10 //-------------------------------------------------------------------------
11 #include "AliTracker.h"
12 #include "AliITSRecoParam.h"
13 #include "AliITStrackV2.h"
14 #include "AliITSgeomTGeo.h"
15
16
17 class AliITSRecPoint;
18 class AliESDEvent;
19 class TTree;
20
21
22 //-------------------------------------------------------------------------
23 class AliITStrackerV2 : public AliTracker {
24 public:
25   AliITStrackerV2();
26   AliITStrackerV2(const Char_t *geom);
27   ~AliITStrackerV2(){}
28   AliCluster *GetCluster(Int_t index) const;
29   AliITSRecPoint *GetCluster(Int_t l, Int_t c) const {
30     return fgLayers[l].GetCluster(c);
31   }
32   Int_t GetNumberOfClustersLayer(Int_t n) const {
33      return fgLayers[n].GetNumberOfClusters();
34   }   
35   Int_t LoadClusters(TTree *cf);
36   void UnloadClusters();
37   Int_t Clusters2Tracks(AliESDEvent *event);
38   Int_t PropagateBack(AliESDEvent *event);
39   Int_t RefitInward(AliESDEvent *event);
40   Bool_t RefitAt(Double_t x, AliITStrackV2 *seed, 
41                  const AliITStrackV2 *t, Bool_t extra=kFALSE);
42   void SetupFirstPass(Int_t *flags, Double_t *cuts=0);
43   void SetupSecondPass(Int_t *flags, Double_t *cuts=0);
44
45   void SetLastLayerToTrackTo(Int_t l=0) {fLastLayerToTrackTo=l;} 
46   void SetLayersNotToSkip(Int_t *l);
47
48   void UseClusters(const AliKalmanTrack *t, Int_t from=0) const;
49
50   class AliITSdetector {
51   public:
52     AliITSdetector():fR(0.),fPhi(0.){}
53     AliITSdetector(Double_t r,Double_t phi):fR(r),fPhi(phi){}
54     Double_t GetR()   const {return fR;}
55     Double_t GetPhi() const {return fPhi;}
56   private:
57     Double_t fR;    // polar coordinates 
58     Double_t fPhi;  // of this detector
59   };
60
61   class AliITSlayer {
62   public:
63     enum {kNsector=5, kMaxClusterPerSector=AliITSRecoParam::kMaxClusterPerLayer/kNsector};
64     AliITSlayer();
65     AliITSlayer(Double_t r, Double_t p, Double_t z, Int_t nl, Int_t nd);
66    ~AliITSlayer();
67     Int_t InsertCluster(AliITSRecPoint *c);
68     void ResetClusters();
69     Int_t SelectClusters(Float_t zmi, Float_t zma, Float_t ymi, Float_t yma);
70     const AliITSRecPoint *GetNextCluster(Int_t &ci);
71     void ResetRoad();
72     Double_t GetRoad() const {return fRoad;}
73     Double_t GetR() const {return fR;}
74     AliITSRecPoint *GetCluster(Int_t i) const { return fClusters[i]; } 
75     AliITSdetector &GetDetector(Int_t n) const { return fDetectors[n]; }
76     Int_t FindDetectorIndex(Double_t phi, Double_t z) const;
77     Double_t GetThickness(Double_t y, Double_t z, Double_t &x0) const;
78     Int_t GetNladders() const {return fNladders;}
79     Int_t GetNdetectors() const {return fNdetectors;}
80     Int_t GetNumberOfClusters() const;
81   protected:
82     AliITSlayer(const AliITSlayer&);
83     AliITSlayer &operator=(const AliITSlayer &tr);  
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
91     AliITSRecPoint *fClusters[AliITSRecoParam::kMaxClusterPerLayer]; // pointers to clusters
92     Int_t fN[kNsector];         // numbers of clusters sector by sector 
93
94     Int_t fIndex[AliITSRecoParam::kMaxClusterPerLayer]; // indexes of selected clusters 
95     Int_t fNsel;                       // number of selected clusters
96
97     Double_t fRoad;     // road defined by the cluster density
98     Int_t FindClusterIndex(Float_t z, Int_t s) const;
99   };
100
101 protected:
102   AliITStrackerV2(const AliITStrackerV2&);
103   void CookLabel(AliKalmanTrack *t,Float_t wrong) const;
104   Double_t GetEffectiveThickness(Double_t y, Double_t z) const;
105   void  FollowProlongation();
106   Int_t TakeNextProlongation();
107   void ResetBestTrack() {
108      fBestTrack.~AliITStrackV2();
109      new(&fBestTrack) AliITStrackV2(fTrackToFollow);
110   }
111   void ResetTrackToFollow(const AliITStrackV2 &t) {
112      fTrackToFollow.~AliITStrackV2();
113      new(&fTrackToFollow) AliITStrackV2(t);
114   }
115   Int_t fI;                              // index of the current layer
116   static AliITSlayer fgLayers[AliITSgeomTGeo::kNLayers];// ITS layers
117   AliITStrackV2 fTracks[AliITSgeomTGeo::kNLayers];      // track estimations at the ITS layers
118   AliITStrackV2 fBestTrack;              // "best" track 
119   AliITStrackV2 fTrackToFollow;          // followed track
120   Int_t fPass;                           // current pass through the data 
121   Int_t fConstraint[2];                  // constraint flags
122
123   Int_t fLayersNotToSkip[AliITSgeomTGeo::kNLayers];     // layer masks
124   Int_t fLastLayerToTrackTo;             // the innermost layer to track to
125
126 private:
127   AliITStrackerV2 &operator=(const AliITStrackerV2 &tr);  
128   ClassDef(AliITStrackerV2,1)   //ITS tracker V2
129 };
130
131
132 inline void AliITStrackerV2::SetupFirstPass(Int_t *flags, Double_t *cuts) {
133   // This function sets up flags and cuts for the first tracking pass   
134   //
135   //   flags[0] - vertex constaint flag                                
136   //              negative means "skip the pass"                        
137   //              0        means "no constraint"                        
138   //              positive means "normal constraint"                    
139
140    fConstraint[0]=flags[0];
141    if (cuts==0) return;
142 }
143
144 inline void AliITStrackerV2::SetupSecondPass(Int_t *flags, Double_t *cuts) {
145   // This function sets up flags and cuts for the second tracking pass   
146   //
147   //   flags[0] - vertex constaint flag                                
148   //              negative means "skip the pass"                        
149   //              0        means "no constraint"                        
150   //              positive means "normal constraint"                    
151
152    fConstraint[1]=flags[0];
153    if (cuts==0) return;
154 }
155
156 inline void AliITStrackerV2::CookLabel(AliKalmanTrack *t,Float_t wrong) const {
157   //--------------------------------------------------------------------
158   //This function "cooks" a track label. If label<0, this track is fake.
159   //--------------------------------------------------------------------
160    Int_t tpcLabel=t->GetLabel();
161    if (tpcLabel<0) return;
162    AliTracker::CookLabel(t,wrong);
163    if (tpcLabel != t->GetLabel()) t->SetLabel(-tpcLabel); 
164 }
165
166 #endif