]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPC.h
Set variable dummy even if not used.
[u/mrichter/AliRoot.git] / TPC / AliTPC.h
1 #ifndef TPC_H
2 #define TPC_H
3 ////////////////////////////////////////////////
4 //  Manager class for TPC                     //
5 ////////////////////////////////////////////////
6
7 #include "AliDetector.h"
8 #include "AliHit.h" 
9 #include "AliDigit.h" 
10 #include "AliTPCSecGeo.h" 
11 #include <TMatrix.h>
12
13 #define MAXTPCTBK 500
14
15 class AliTPCcluster;
16 class AliTPCtrack;
17
18 class AliTPC : public AliDetector {
19 protected:
20   Int_t          fSens;             // ISENS
21   Int_t          fSecAL;            // Upper sector selector
22   Int_t          fSecAU;            // Lower sector selector
23   Int_t          fSecLows[6];       // List of lower sectors selected
24   Int_t          fSecUps[12];       // List of upper sectors selected
25   Int_t          fNsectors;         // Number of sectors in TPC
26   Int_t          fNclusters;        // Number of clusters in TPC
27   Int_t          fNtracks;          // Number of tracks in TPC
28   Int_t          *fClustersIndex;   // Index for each sector in fClusters
29   Int_t          *fDigitsIndex;     // Index for each sector in fDigits
30   TClonesArray   *fClusters;        // List of clusters for all sectors
31   TClonesArray   *fTracks;          // List of reconstructed tracks
32   
33 public:
34   AliTPC();
35   AliTPC(const char *name, const char *title);
36   virtual      ~AliTPC();
37   virtual void  AddCluster(Float_t*, Int_t*);
38   /*virtual*/void  AddCluster(const AliTPCcluster&);
39   virtual void  AddDigit(Int_t*, Int_t*);
40   virtual void  AddHit(Int_t, Int_t*, Float_t*);
41   virtual void  AddTrack(Float_t*);
42   /*virtual*/void  AddTrack(const AliTPCtrack&);
43   Int_t         DistancetoPrimitive(Int_t px, Int_t py);
44   virtual void  BuildGeometry();
45   virtual void  CreateGeometry() {}
46   virtual void  CreateMaterials();
47   virtual void  Hits2Clusters();
48   virtual void  Hits2Digits();
49   virtual void  Init();
50   virtual Int_t IsVersion() const =0;
51   virtual void  Digits2Clusters();
52   virtual void  Clusters2Tracks();
53   TClonesArray  *Clusters() {return fClusters;}
54   TClonesArray  *Tracks()   {return fTracks;}
55   Int_t         *GetClustersIndex() {return fClustersIndex;}
56   Int_t         *GetDigitsIndex()   {return fDigitsIndex;}
57   Int_t         GetNsectors()       {return fNsectors;}
58   virtual void  MakeBranch(Option_t *opt=" ");
59   virtual void  ResetDigits();
60   virtual void  SetSecAL(Int_t sec);
61   virtual void  SetSecAU(Int_t sec);
62   virtual void  SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6);
63   virtual void  SetSecUps (Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
64                            Int_t s7,Int_t s8,Int_t s9,Int_t s10, Int_t s11, Int_t s12);
65   virtual void  SetSens(Int_t sens);
66   virtual void  StepManager()=0;
67   virtual void  DrawModule() {}
68   
69 private:
70   //
71   //  Private inline functions for AliTPC
72   //
73   inline Float_t P1(const Float_t x){
74 #ifndef __CINT__
75     const
76 #endif
77     Float_t y=x*x;
78     return(1.25e-3-8.0e-3*x+0.0274*y-0.0523*x*y); //electron is 3 pads away
79   }
80   //
81   inline Float_t P2(const Float_t x){
82 #ifndef __CINT__
83     const
84 #endif
85     Float_t y=x*x;
86
87     return(.0114-0.0726*x+0.2408*y-0.4421*x*y);    //electron is 2 pads away
88   }
89   //
90   inline Float_t P3(const Float_t x){
91 #ifndef __CINT__
92     const
93 #endif
94     Float_t y=x*x;
95
96     return(0.0959-0.5204*x+0.9272*y+0.2865*x*y);      //electron is 1 pad away
97   }
98   //
99   inline Float_t P4(const Float_t x){
100 #ifndef __CINT__
101     const
102 #endif
103       Float_t y=x*x; 
104     return(.2835-2.7*y+11.55*y*y); //electron is here
105   }
106
107
108   //
109   //  Time response, 3 sigma truncated Gaussian
110   //
111   inline Float_t TimeRes(const Float_t x) {
112 #ifndef __CINT__
113     const 
114 #endif
115       Float_t sigma = fwhm/2.354820045;
116 #ifndef __CINT__
117     const
118 #endif
119       Float_t trunc = 3.*sigma;
120     const Float_t norm = 0.4; // according to H-G. Fischer
121 #ifndef __CINT__
122     const
123 #endif
124       Float_t x1 = x-trunc;
125     return (TMath::Abs(x1)>trunc) ? 0 : norm*TMath::Exp(-0.5*x1*x1/sigma/sigma);
126   }
127   //
128   // Private prototypes for Alice TPC
129   //
130   void CreateList(Int_t *tracks,Float_t signal[][MAXTPCTBK+1],Int_t ntr,Int_t time);
131   void DigSignal(Int_t isec,Int_t irow,TObjArray *pointer);
132   void ElDiff(Float_t *xyz);
133   
134   ClassDef(AliTPC,2)  // Time Projection Chamber class
135 };
136
137 //_____________________________________________________________________________
138
139 class AliTPCcluster : public TObject {
140 public:
141   Int_t     fTracks[3];//labels of overlapped tracks
142   Int_t     fSector;   //sector number
143   Int_t     fPadRow;   //PadRow number
144   Float_t   fY ;       //Y of cluster
145   Float_t   fZ ;       //Z of cluster
146   Float_t   fQ ;       //Q of cluster (in ADC counts)
147   Float_t   fSigmaY2;  //Sigma Y square of cluster
148   Float_t   fSigmaZ2;  //Sigma Z square of cluster
149   
150 public:
151   AliTPCcluster() {
152     fTracks[0]=fTracks[1]=fTracks[2]=0; 
153     fSector=fPadRow=0;
154     fY=fZ=fQ=fSigmaY2=fSigmaZ2=0.;
155   }
156   AliTPCcluster(Float_t *hits, Int_t*);
157   virtual ~AliTPCcluster() {;}
158   void Use() {fTracks[0]=-fTracks[0];}
159   int IsUsed() const {return (fTracks[0]<0) ? 1 : 0;}
160   void GetXYZ(Double_t& x,Double_t& y,Double_t& z) const; //Get global x,y,z
161   
162   ClassDef(AliTPCcluster,1)  // Time Projection Chamber clusters
163 };
164
165
166 //_____________________________________________________________________________
167
168 class AliTPCdigit : public AliDigit {
169 public:
170    Int_t     fSector;     //array of volumes
171    Int_t     fPadRow;     //Row number
172    Int_t     fPad ;       //Pad number
173    Int_t     fTime;       //Time bucket
174    Int_t     fSignal;     //Signal amplitude
175  
176 public:
177    AliTPCdigit() {}
178    AliTPCdigit(Int_t *tracks, Int_t *digits);
179    virtual ~AliTPCdigit() {}
180  
181    ClassDef(AliTPCdigit,1)  // Time Projection Chamber digits
182 };
183  
184  
185 //_____________________________________________________________________________
186  
187 class AliTPChit : public AliHit {
188 public:
189    Int_t     fSector;     //sector number
190    Int_t     fPadRow;     //Pad Row number
191    Float_t   fQ ;         //charge
192  
193 public:
194    AliTPChit() {}
195    AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits);
196    virtual ~AliTPChit() {}
197  
198    ClassDef(AliTPChit,1)  // Time Projection Chamber hits
199 };
200  
201  
202 //_____________________________________________________________________________
203  
204 const unsigned MAX_CLUSTER_PER_ROW=500;
205 const Double_t FIELD=0.2;
206
207 class AliTPCtrack : public TObject {
208    Double_t fAlpha;          // rotation angle
209    Double_t ref;             // track reference plane (X-coordinate)
210    TVector x;                // vector of track parameters
211    TMatrix C;                // covariance matrix of track parameters
212    TObjArray clusters;       // pointers to clusters belonging to this track
213    Double_t chi2;            // total chi2 value for this track
214 public:
215    AliTPCtrack(Float_t *hits);
216    AliTPCtrack(const AliTPCcluster& c, const TVector& xx, const TMatrix& CC); 
217    AliTPCtrack(const AliTPCtrack& t);
218    int PropagateTo(Double_t x,
219                     Double_t x0=28.94,Double_t rho=0.9e-3,Double_t pm=0.139);
220    void PropagateToVertex(
221                     Double_t x0=36.66,Double_t rho=1.2e-3,Double_t pm=0.139);
222    void Update(const AliTPCcluster* c, Double_t chi2);
223    int Rotate(Double_t angle);
224
225    void UseClusters() const ;
226    Double_t GetPredictedChi2(const AliTPCcluster*) const ;
227    Double_t GetX() const {return ref;}
228    Double_t GetY() const {return x(0);}
229    Double_t GetC() const {return x(2);}
230    Double_t GetY(Double_t x) const;
231    Double_t GetZ() const {return x(1);}
232    Double_t GetTgl() const {return x(4);}
233    Double_t GetPt() const {return 0.3*FIELD/x(2)/100;}
234    int GetLab() const ;
235    Double_t GetSigmaY2() const {return C(0,0);}
236    Double_t GetSigmaZ2() const {return C(1,1);}
237    Double_t GetSigmaC2() const {return C(2,2);}
238    Double_t GetSigmaTgl2() const {return C(4,4);}
239    Double_t GetAlpha() const {return fAlpha;}
240    Double_t GetChi2() const {return chi2;}
241    operator int() const {return clusters.GetEntriesFast();}
242    AliTPCcluster& operator[](int i) {
243       return *((AliTPCcluster*)clusters.UncheckedAt(i));
244    } 
245    void GetPxPyPz(Double_t&, Double_t&, Double_t&) const ;
246    void GetXYZ(Double_t& X,Double_t& Y,Double_t& Z) const {X=ref;Y=x(0);Z=x(1);}
247  
248    ClassDef(AliTPCtrack,1)  // Time Projection Chamber reconstructed tracks
249 };
250
251 //_____Classes for internal tracking use ______________________________________
252
253 class TrackSeed : public AliTPCtrack {
254 public:
255    TrackSeed(const AliTPCcluster& c, const TVector& x, const TMatrix& C) :
256    AliTPCtrack(c,x,C) {}
257    Bool_t IsSortable() const {return kTRUE;}
258    Int_t Compare(TObject *o) {
259       AliTPCtrack *t=(AliTPCtrack*)o;
260       Double_t c =GetSigmaY2();
261       Double_t co=t->GetSigmaY2();
262       if (c>co) return 1;
263       else if (c<co) return -1;
264       return 0;
265    }
266 };
267
268 class AliTPCRow {
269    unsigned num_of_clusters;
270    const AliTPCcluster *clusters[MAX_CLUSTER_PER_ROW];
271 public:
272    AliTPCRow() {num_of_clusters=0;}
273    void InsertCluster(const AliTPCcluster*);
274
275    operator int() const {return num_of_clusters;}
276    const AliTPCcluster* operator[](int i) const {return clusters[i];}
277    int Find(Double_t y) const; 
278 };
279
280 class AliTPCSector {
281    unsigned num_of_rows; 
282    AliTPCRow *row;
283 public:
284    AliTPCSector(int nl) { 
285       row = new AliTPCRow[nl]; num_of_rows=nl;
286    }
287    virtual ~AliTPCSector() { delete[] row; }
288    AliTPCRow& operator[](int i) const { return *(row+i); }
289    virtual Double_t GetX(int l) const = 0;
290    virtual Double_t GetMaxY(int l) const = 0;
291    virtual Double_t GetAlpha() const = 0;
292 };
293
294 class AliTPCSSector : public AliTPCSector {
295 public:
296    AliTPCSSector(): AliTPCSector(nrow_low){}
297    virtual ~AliTPCSSector() {}
298    Double_t GetX(int l) const { return pad_row_low[0] + (l+0.0)*pad_pitch_l; }
299    Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*alpha_low); }
300    Double_t GetAlpha() const {return alpha_low;}
301 };
302
303 class AliTPCLSector : public AliTPCSector {
304 public:
305    AliTPCLSector(): AliTPCSector(nrow_up){}
306    virtual ~AliTPCLSector() {}
307    Double_t GetX(int l) const { return pad_row_up[0] + (l+0.0)*pad_pitch_l; }
308    Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*alpha_up); }
309    Double_t GetAlpha() const {return alpha_up;}
310 };
311
312 #endif
313