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