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