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