]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPC.h
Preliminary version of new TPC code
[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 "AliTPCParam.h"
12 #include <TMatrix.h>
13 #include <TTree.h>
14 #include <TClonesArray.h>
15
16 #define MAXTPCTBK 500
17
18 class AliTPCcluster;
19 class AliTPCtrack;
20 class AliTPCParam;
21 //MI changes
22 class AliTPCD;
23
24 class AliTPC : public AliDetector {
25 protected:
26   Int_t          fSens;             // ISENS
27   Int_t          fSecAL;            // Upper sector selector
28   Int_t          fSecAU;            // Lower sector selector
29   Int_t          fSecLows[6];       // List of lower sectors selected
30   Int_t          fSecUps[12];       // List of upper sectors selected
31   Int_t          fNsectors;         // Number of sectors in TPC
32   Int_t          fNclusters;        // Number of clusters in TPC
33   Int_t          fNtracks;          // Number of tracks in TPC
34   Int_t          *fClustersIndex;   // Index for each sector in fClusters
35   Int_t          *fDigitsIndex;     // Index for each sector in fDigits
36
37   //MK changes
38
39   Float_t        fSide;  // selects left(-1), right(+1), or both(0) sides of the TPC
40
41   TClonesArray   *fClusters;        // List of clusters for all sectors
42   TClonesArray   *fTracks;          // List of reconstructed tracks
43   //MI changes
44   AliTPCD * fDigParam;              //detector parameters  
45 public:
46   AliTPC();
47   AliTPC(const char *name, const char *title);
48   virtual      ~AliTPC();
49   virtual void  AddCluster(Float_t*, Int_t*);
50   /*virtual*/void  AddCluster(const AliTPCcluster&);
51   virtual void  AddDigit(Int_t*, Int_t*);
52   virtual void  AddHit(Int_t, Int_t*, Float_t*);
53   virtual void  AddTrack(Float_t*);
54   /*virtual*/void  AddTrack(const AliTPCtrack&);
55   Int_t         DistancetoPrimitive(Int_t px, Int_t py);
56   virtual void  BuildGeometry();
57   virtual void  CreateGeometry() {}
58   virtual void  CreateMaterials();
59   virtual void  Hits2Clusters();
60
61   virtual void  Hits2Digits();   //MI change
62   virtual void Hits2DigitsSector(Int_t isec);  //MI change
63   virtual void  Init();
64   virtual Int_t IsVersion() const =0;
65   virtual void  Digits2Clusters();
66   virtual void  Clusters2Tracks();
67   TClonesArray  *Clusters() {return fClusters;}
68   TClonesArray  *Tracks()   {return fTracks;}
69   Int_t         *GetClustersIndex() {return fClustersIndex;}
70   Int_t         *GetDigitsIndex()   {return fDigitsIndex;}
71   Int_t         GetNsectors()       {return fNsectors;}
72   virtual void  MakeBranch(Option_t *opt=" ");
73   virtual void  ResetDigits();
74   virtual void  SetSecAL(Int_t sec);
75   virtual void  SetSecAU(Int_t sec);
76   virtual void  SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6);
77   virtual void  SetSecUps (Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
78                            Int_t s7,Int_t s8,Int_t s9,Int_t s10, Int_t s11, Int_t s12);
79   virtual void  SetSens(Int_t sens);
80   //MK changes
81
82   virtual void  SetSide(Float_t side);
83   virtual void  StepManager()=0;
84   virtual void  DrawDetector() {}
85   AliTPCD*  GetDigParam() {return fDigParam;} //MI change8
86   void SetDigParam(AliTPCD* param) {fDigParam=param;}  //MI must think about it
87 private:
88   //
89   void ElDiff(Float_t *xyz);
90   void MakeTriplet(Int_t row,TObjArray **rowTriplet, 
91                    TObjArray **prow);
92
93   void ExB(Float_t *xyz);
94   void DigitizeRow(Int_t irow,Int_t isec,TObjArray **rowTriplet);
95   Float_t GetSignal(TObjArray *p1, Int_t ntr, Int_t np, TMatrix *m1, TMatrix *m2,
96                     Int_t *IndexRange);
97   void GetList (Float_t label,Int_t np,TMatrix *m,Int_t *IndexRange,
98                 Float_t **pList);
99   void MakeSector(Int_t isec,Int_t nrows,TTree *TH,Stat_t ntracks,TObjArray **row);
100   void GetCrossTalk (Int_t iFlag,TObjArray *p,Int_t ntracks,Int_t *npads,
101                      TMatrix *m);
102
103   
104   ClassDef(AliTPC,2)  // Time Projection Chamber class
105 };
106
107 //_____________________________________________________________________________
108
109 class AliTPCcluster : public TObject {
110 public:
111   Int_t     fTracks[3];//labels of overlapped tracks
112   Int_t     fSector;   //sector number
113   Int_t     fPadRow;   //PadRow number
114   Float_t   fY ;       //Y of cluster
115   Float_t   fZ ;       //Z of cluster
116   Float_t   fQ ;       //Q of cluster (in ADC counts)
117   Float_t   fSigmaY2;  //Sigma Y square of cluster
118   Float_t   fSigmaZ2;  //Sigma Z square of cluster
119   
120 public:
121   AliTPCcluster() {
122     fTracks[0]=fTracks[1]=fTracks[2]=0; 
123     fSector=fPadRow=0;
124     fY=fZ=fQ=fSigmaY2=fSigmaZ2=0.;
125   }
126   AliTPCcluster(Float_t *hits, Int_t*);
127   virtual ~AliTPCcluster() {;}
128   void Use() {fTracks[0]=-fTracks[0];}
129   int IsUsed() const {return (fTracks[0]<0) ? 1 : 0;}
130   void GetXYZ(Float_t *x, const AliTPCParam *) const; //Get global x,y,z
131   Bool_t    IsSortable() const;
132   Int_t Compare(TObject *o) ;
133   ClassDef(AliTPCcluster,1)  // Time Projection Chamber clusters
134 };
135
136
137 //_____________________________________________________________________________
138
139 class AliTPCdigit : public AliDigit {
140 public:
141    Int_t     fSector;     //array of volumes
142    Int_t     fPadRow;     //Row number
143    Int_t     fPad ;       //Pad number
144    Int_t     fTime;       //Time bucket
145    Int_t     fSignal;     //Signal amplitude
146  
147 public:
148    AliTPCdigit() {}
149    AliTPCdigit(Int_t *tracks, Int_t *digits);
150    virtual ~AliTPCdigit() {}
151  
152    ClassDef(AliTPCdigit,1)  // Time Projection Chamber digits
153 };
154  
155  
156 //_____________________________________________________________________________
157  
158 class AliTPChit : public AliHit {
159 public:
160    Int_t     fSector;     //sector number
161    Int_t     fPadRow;     //Pad Row number
162    Float_t   fQ ;         //charge
163  
164 public:
165    AliTPChit() {}
166    AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits);
167    virtual ~AliTPChit() {}
168  
169    ClassDef(AliTPChit,1)  // Time Projection Chamber hits
170 };
171  
172  
173 //_____________________________________________________________________________
174  
175 const unsigned MAX_CLUSTER_PER_ROW=1500;
176 const Double_t FIELD=0.2;
177
178 class AliTPCtrack : public TObject {
179    Double_t fAlpha;          // rotation angle
180    Double_t ref;             // track reference plane (X-coordinate)
181    TVector x;                // vector of track parameters
182    TMatrix C;                // covariance matrix of track parameters
183    TObjArray clusters;       // pointers to clusters belonging to this track
184    Double_t chi2;            // total chi2 value for this track
185 public:
186    AliTPCtrack(Float_t *hits);
187    AliTPCtrack(const AliTPCcluster& c, const TVector& xx, const TMatrix& CC,
188                const AliTPCParam *); 
189    AliTPCtrack(const AliTPCtrack& t);
190    int PropagateTo(Double_t x,
191                     Double_t x0=28.94,Double_t rho=0.9e-3,Double_t pm=0.139);
192    void PropagateToVertex(
193                     Double_t x0=36.66,Double_t rho=1.2e-3,Double_t pm=0.139);
194    void Update(const AliTPCcluster* c, Double_t chi2);
195    int Rotate(Double_t angle);
196
197    void UseClusters() const ;
198    Double_t GetPredictedChi2(const AliTPCcluster*) const ;
199    Double_t GetX() const {return ref;}
200    Double_t GetY() const {return x(0);}
201    Double_t GetC() const {return x(2);}
202    Double_t GetY(Double_t x) const;
203    Double_t GetZ() const {return x(1);}
204    Double_t GetTgl() const {return x(4);}
205    Double_t GetPt() const {return 0.3*FIELD/x(2)/100;}
206    int GetLab() const ;
207    Double_t GetSigmaY2() const {return C(0,0);}
208    Double_t GetSigmaZ2() const {return C(1,1);}
209    Double_t GetSigmaC2() const {return C(2,2);}
210    Double_t GetSigmaTgl2() const {return C(4,4);}
211    Double_t GetAlpha() const {return fAlpha;}
212    Double_t GetChi2() const {return chi2;}
213    operator int() const {return clusters.GetEntriesFast();}
214    AliTPCcluster& operator[](int i) {
215       return *((AliTPCcluster*)clusters.UncheckedAt(i));
216    } 
217    void GetPxPyPz(Double_t&, Double_t&, Double_t&) const ;
218    void GetXYZ(Double_t& X,Double_t& Y,Double_t& Z) const {X=ref;Y=x(0);Z=x(1);}
219  
220    ClassDef(AliTPCtrack,1)  // Time Projection Chamber reconstructed tracks
221 };
222
223 //_____Classes for internal tracking use ______________________________________
224
225 class TrackSeed : public AliTPCtrack {
226 public:
227    TrackSeed(const AliTPCcluster& c, const TVector& x, const TMatrix& C,
228    const AliTPCParam *p) : AliTPCtrack(c,x,C,p) {}
229    Bool_t IsSortable() const {return kTRUE;}
230    Int_t Compare(TObject *o) {
231       AliTPCtrack *t=(AliTPCtrack*)o;
232       Double_t c =GetSigmaY2();
233       Double_t co=t->GetSigmaY2();
234       if (c>co) return 1;
235       else if (c<co) return -1;
236       return 0;
237    }
238 };
239
240 class AliTPCRow {
241    unsigned num_of_clusters;
242    const AliTPCcluster *clusters[MAX_CLUSTER_PER_ROW];
243 public:
244    AliTPCRow() {num_of_clusters=0;}
245    void InsertCluster(const AliTPCcluster*);
246
247    operator int() const {return num_of_clusters;}
248    const AliTPCcluster* operator[](int i) const {return clusters[i];}
249    int Find(Double_t y) const; 
250 };
251
252
253 class AliTPCSector {
254 protected:
255    unsigned num_of_rows; 
256    AliTPCRow *row;
257    const AliTPCParam *param; 
258 public:
259    AliTPCSector() { 
260       row = 0; num_of_rows=0;
261       param=0;
262    }
263    virtual void SetUp(AliTPCParam *p) {param=p;}
264    virtual ~AliTPCSector() { delete[] row; }
265    AliTPCRow& operator[](int i) const { return *(row+i); }
266    virtual Double_t GetX(int l) const = 0;
267    virtual Double_t GetMaxY(int l) const = 0;
268    virtual Double_t GetAlpha() const = 0;
269 };
270
271 class AliTPCSSector : public AliTPCSector {
272 public:
273    AliTPCSSector(){}
274    virtual ~AliTPCSSector() {}
275    virtual void SetUp(AliTPCParam *p) {
276       param=p;
277       num_of_rows=p->GetNRowLow();
278       row=new AliTPCRow[num_of_rows];
279    }
280    Double_t GetX(int l) const { return param->GetPadRowRadiiLow(l); }
281    Double_t GetAlpha() const {return alpha_low;}
282    Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*GetAlpha()); }
283 };
284
285 class AliTPCLSector : public AliTPCSector {
286 public:
287    AliTPCLSector(){}
288    virtual ~AliTPCLSector() {}
289    virtual void SetUp(AliTPCParam *p) {
290       param=p;
291       num_of_rows=p->GetNRowUp();
292       row=new AliTPCRow[num_of_rows];
293    }
294    Double_t GetX(int l) const { return param->GetPadRowRadiiUp(l); }
295    Double_t GetAlpha() const {return alpha_up;}
296    Double_t GetMaxY(int l) const { return GetX(l)*tan(0.5*GetAlpha()); }
297 };
298
299
300
301
302 #endif
303