]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCParam.h
removed obsolete AliTPCDigitsDisplay.C
[u/mrichter/AliRoot.git] / TPC / AliTPCParam.h
1 #ifndef TPCParam_H
2 #define TPCParam_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ////////////////////////////////////////////////
9 //  Manager class for TPC parameters          //
10 ////////////////////////////////////////////////
11
12 #include "AliDetectorParam.h"
13 #include "TMath.h"
14
15 // the last things from AliTPCSecGeo
16 const Float_t z_end = 250.; 
17 const Float_t alpha_low=0.34906585; // 20 degrees
18 const Float_t alpha_up=0.34906585; //  20 degrees
19 const Float_t q_el = 1.602e-19; // elementary charge
20 const Float_t adc_sat = 1023; // dynamic range (10 bits)
21 const Float_t dyn_range = 2000.; // output dynamic range (mV)
22 //
23
24
25 class AliTPCParam : public AliDetectorParam {
26   //////////////////////////////////////////////////////
27   //////////////////////////////////////////////////////
28   //ALITPCParam object to be possible change 
29   //geometry and some other parameters of TPC   
30   //used by AliTPC and AliTPCSector 
31  
32 public:
33   AliTPCParam(); 
34   virtual ~AliTPCParam();
35   
36   virtual Bool_t  Transform(Float_t *xyz, Int_t *index, Int_t* oindex);
37   //transformation from input coodination system to output coordination system  
38   Int_t  Transform0to1(Float_t *xyz, Int_t *index) const;
39   //trasforamtion from global to global - adjust index[0] sector 
40   //return value is equal to sector corresponding to global position
41   inline void Transform1to2(Float_t *xyz, Int_t *index) const;
42   //transformation to rotated coordinata 
43   inline void Transform2to1(Float_t *xyz, Int_t *index) const;
44   //transformation from rotated coordinata to global coordinata
45   inline void Transform2to2(Float_t *xyz, Int_t *index, Int_t *oindex) const;
46   //transform rotated coordinata of one sector to rotated
47   //coordinata relative to another sector
48   inline Float_t  Transform2to2NearestWire(Float_t *xyz, Int_t *index) const;
49   //round x position to nearest wire
50   inline Int_t   Transform2to3(Float_t *xyz, Int_t *index) const;
51   //calulate coresponding index[2] -pad row for straight rows
52   //does not change xyz[] 
53   //return pad - row 
54   inline void   Transform3to4(Float_t *xyz, Int_t *index) const;
55   //valid only for straight rows straight rows
56   //calculate xyz[0] position relative to given index
57   //return pad - row 
58   inline void   Transform4to3(Float_t *xyz, Int_t *index) const;
59   //valid only for straight rows straight rows
60   //transform  xyz[0] position relative to given index
61   inline void   Transform2to5( Float_t *xyz, Int_t *index) const;
62   //transform [x,y,z] to [r,rphi,z]
63   inline void   Transform5to2(Float_t *xyz, Int_t *index) const;
64   //transform [r,rphi,z] coordinata to [x,y,z] 
65   inline void  Transform4to8(Float_t *xyz, Int_t *index) const;
66   //transform xyz coordinata to 'digit' coordinata
67   inline void  Transform8to4(Float_t *xyz, Int_t *index) const;
68   //transform  'digit' coordinata to xyz coordinata   
69   inline void  Transform6to8(Float_t *xyz, Int_t *index) const;
70   //transform dr,f coordinata to 'digit' coordinata
71   inline void  Transform8to6(Float_t *xyz, Int_t *index) const;
72   //transform 'digit' coordinata to dr,f coordinata 
73
74   virtual Int_t  Transform2toPadRow(Float_t *xyz, Int_t *index) const{return 0;}
75   //transform rotated to
76
77   virtual  Int_t GetPadRow(Float_t *xyz, Int_t *index) const ;
78   //return pad row of point xyz - xyz is given in coordinate system -(given by index)
79   //output system is 3 for straight row and 7 for cylindrical row
80   virtual void XYZtoCRXYZ(Float_t *xyz, 
81                           Int_t &sector, Int_t &padrow, Int_t option=3){;}
82   //transform global position to the position relative to the sector padrow
83   //if option=0  X calculate absolute            calculate sector
84   //if option=1  X           absolute            use input sector
85   //if option=2  X           relative to pad row calculate sector
86   //if option=3  X           relative            use input sector
87
88   virtual void CRXYZtoXYZ(Float_t *xyz,
89                           const Int_t &sector, const Int_t & padrow, Int_t option=3) const {;}  
90   //transform relative position  to the gloabal position
91
92   virtual void CRTimePadtoYZ(Float_t &y, Float_t &z, 
93                              const Float_t &time, const Float_t &pad,
94                              Int_t sector, Int_t padrow ){;}
95   //transform position in digit  units (time slices and pads)  to "normal" 
96   //units (cm)   
97   virtual void CRYZtoTimePad(const Float_t &y, const Float_t &z, 
98                              Float_t &time, Float_t &pad,
99                              Int_t sector, Int_t padrow){;}
100   //transform position in cm to position in digit unit 
101   virtual Int_t   CalcResponse(Float_t* x, Int_t * index, Int_t row){return 0;}
102   //calculate bin response as function of the input position -x and the weight 
103   //if row -pad row is equal -1 calculate response for each pad row 
104   //otherwise it calculate only in given pad row
105   //return number of valid response bin
106   virtual void SetDefault();          //set defaut TPCparam 
107   virtual Bool_t Update();            //recalculate and check geometric parameters 
108   Bool_t GetStatus();         //get information about object consistency  
109   Int_t GetIndex(Int_t sector, Int_t row);  //give index of the given sector and pad row 
110   Int_t GetNSegmentsTotal() const {return fNtRows;} 
111   Double_t GetLowMaxY(Int_t irow) const {return irow*0.;}
112   Double_t GetUpMaxY(Int_t irow) const {return irow*0;}
113   //additional geometrical function - for Belikov
114  
115   Bool_t   AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row) const; //return sector and padrow
116   //for given index
117
118   inline void  AdjustCosSin(Int_t isec, Float_t &cos, Float_t &sin) const;
119   //set cosinus and sinus of rotation angles for sector isec 
120   inline Float_t GetAngle(Int_t isec) const;
121   //
122   //set sector parameters
123   //
124   void  SetInnerRadiusLow(Float_t InnerRadiusLow )  { fInnerRadiusLow=InnerRadiusLow;}
125   void  SetOuterRadiusLow(Float_t OuterRadiusLow )  { fOuterRadiusLow=OuterRadiusLow;} 
126   void  SetInnerRadiusUp(Float_t InnerRadiusUp)  {  fInnerRadiusUp= InnerRadiusUp;} 
127   void  SetOuterRadiusUp(Float_t OuterRadiusUp) {  fOuterRadiusUp= OuterRadiusUp;}   
128   void  SetSectorAngles(Float_t innerangle, Float_t innershift, Float_t outerangle,
129                         Float_t outershift);
130   void  SetInnerFrameSpace(Float_t frspace) {fInnerFrameSpace = frspace;}
131   void  SetOuterFrameSpace(Float_t frspace) {fOuterFrameSpace = frspace;}
132   void  SetInnerWireMount(Float_t fmount) {fInnerWireMount = fmount;}
133   void  SetOuterWireMount(Float_t fmount) {fOuterWireMount = fmount;}
134   void  SetZLength(Float_t zlength) {fZLength = zlength;} 
135   void  SetGeometryType(Int_t type) {fGeometryType = type;}
136   //
137   //set wire parameters
138   //
139   void  SetInnerNWires(Int_t nWires){  fNInnerWiresPerPad=nWires;}
140   void  SetInnerDummyWire(Int_t dummy) {fInnerDummyWire  = dummy;}
141   void  SetInnerOffWire(Float_t offset) {fInnerOffWire =offset;}    
142   void  SetOuterNWires(Int_t nWires){  fNOuterWiresPerPad=nWires;}
143   void  SetOuterDummyWire(Int_t dummy) {fOuterDummyWire  = dummy;}
144   void  SetOuterOffWire(Float_t offset) {fOuterOffWire =offset;}    
145   //
146   //set pad parameter
147   //
148   void  SetInnerPadPitchLength(Float_t PadPitchLength){  fInnerPadPitchLength=PadPitchLength;}
149   void  SetInnerPadPitchWidth(Float_t PadPitchWidth){  fInnerPadPitchWidth = PadPitchWidth;}
150   void  SetInnerPadLength(Float_t PadLength){  fInnerPadLength=PadLength;}
151   void  SetInnerPadWidth(Float_t PadWidth) {  fInnerPadWidth=PadWidth;}  
152   void  SetOuterPadPitchLength(Float_t PadPitchLength){  fOuterPadPitchLength=PadPitchLength;}
153   void  SetOuterPadPitchWidth(Float_t PadPitchWidth){  fOuterPadPitchWidth = PadPitchWidth;}
154   void  SetOuterPadLength(Float_t PadLength){  fOuterPadLength=PadLength;}
155   void  SetOuterPadWidth(Float_t PadWidth) {  fOuterPadWidth=PadWidth;} 
156   void  SetMWPCReadout(Bool_t type) {fBMWPCReadout = type;}
157   void  SetNCrossRows(Int_t rows){fNCrossRows = rows;}
158   //
159   //set gas paremeters
160   //
161   void  SetDiffT(Float_t DiffT){  fDiffT= DiffT;}
162   void  SetDiffL(Float_t DiffL){  fDiffL=DiffL;}
163   void  SetGasGain(Float_t GasGain){  fGasGain=GasGain;}
164   void  SetDriftV(Float_t DriftV){  fDriftV= DriftV;}
165   void  SetOmegaTau(Float_t OmegaTau){  fOmegaTau=OmegaTau;}
166   void  SetAttCoef(Float_t AttCoef){  fAttCoef=AttCoef;}
167   void  SetOxyCont(Float_t OxyCont){  fOxyCont=OxyCont;}
168   //
169   //set electronivc parameters  
170   //
171   void  SetPadCoupling(Float_t PadCoupling){  fPadCoupling=PadCoupling;}
172   void  SetZeroSup(Int_t ZeroSup)    {  fZeroSup=ZeroSup;}
173   void  SetNoise(Float_t Noise )     {  fNoise= Noise;}
174   void  SetChipGain(Float_t ChipGain){  fChipGain= ChipGain;}
175   void  SetChipNorm(Float_t ChipNorm){  fChipNorm= ChipNorm;}
176   void  SetTSample(Float_t TSample)  {  fTSample=TSample;}
177   void  SetTFWHM(Float_t fwhm)     {  fTSigma=fwhm/2.35;}
178   void  SetMaxTBin(Int_t maxtbin)  {  fMaxTBin = maxtbin;}
179   void  SetADCSat(Int_t adcsat)    {  fADCSat  = adcsat;}
180   void  SetADCDynRange(Float_t adcdynrange) {fADCDynRange = adcdynrange;}
181   //
182   //set response  parameters  
183   //
184   void  SetNResponseMax(Int_t max) { fNResponseMax = max;} 
185   void  SetResponseThreshold(Int_t threshold) {fResponseThreshold = threshold;}
186   //
187   //get sector parameters
188   //
189   Float_t  GetInnerRadiusLow() const {return fInnerRadiusLow;}
190   Float_t  GetInnerRadiusUp() const {return fInnerRadiusUp;} 
191   Float_t  GetOuterRadiusLow() const {return fOuterRadiusLow;} 
192   Float_t  GetOuterRadiusUp() const {return fOuterRadiusUp;} 
193   Float_t  GetInnerFrameSpace() const {return fInnerFrameSpace;}
194   Float_t  GetOuterFrameSpace() const {return fOuterFrameSpace;}
195   Float_t  GetInnerWireMount() const {return fInnerWireMount;}
196   Float_t  GetOuterWireMount() const {return fOuterWireMount;}
197   Float_t  GetInnerAngle() const ;
198   Float_t  GetInnerAngleShift() const ;
199   Float_t  GetOuterAngle() const ;
200   Float_t  GetOuterAngleShift() const ; 
201   Int_t    GetNInnerSector() const {return fNInnerSector;}
202   Int_t    GetNOuterSector() const {return fNOuterSector;}
203   Int_t    GetNSector() const {return fNSector;}
204   Float_t  GetZLength() const {return fZLength;}
205   Int_t    GetGeometryType() const {return fGeometryType;}
206
207   //
208   //get wires parameter
209   //
210   Int_t    GetInnerNWires() const {return fNInnerWiresPerPad;}
211   Float_t  GetInnerWWPitch() const {return fInnerWWPitch;}  
212   Int_t    GetInnerDummyWire() const {return fInnerDummyWire;}
213   Float_t  GetInnerOffWire() const {return fInnerOffWire;}
214   Float_t  GetRInnerFirstWire() const {return fRInnerFirstWire;}
215   Float_t  GetRInnerLastWire() const {return fRInnerLastWire;}
216   Int_t    GetOuterNWires() const {return fNOuterWiresPerPad;}
217   Float_t  GetOuterWWPitch() const {return fOuterWWPitch;}  
218   Int_t    GetOuterDummyWire() const {return fOuterDummyWire;}
219   Float_t  GetOuterOffWire() const {return fOuterOffWire;}
220   Float_t  GetROuterFirstWire() const {return fROuterFirstWire;}
221   Float_t  GetROuterLastWire() const {return fROuterLastWire;}  
222   Float_t  GetWWPitch(Int_t isector = 0) const  {
223     return ( (isector < fNInnerSector) ? fInnerWWPitch :fOuterWWPitch);} 
224   //
225   //get pad  parameters
226   //
227   Float_t  GetInnerPadPitchLength() const {return fInnerPadPitchLength;}
228   Float_t  GetInnerPadPitchWidth() const {return fInnerPadPitchWidth;}
229   Float_t  GetInnerPadLength() const {return fInnerPadLength;}
230   Float_t  GetInnerPadWidth() const  {return fInnerPadWidth;}  
231   Float_t  GetOuterPadPitchLength() const {return fOuterPadPitchLength;}
232   Float_t  GetOuterPadPitchWidth() const {return fOuterPadPitchWidth;}
233   Float_t  GetOuterPadLength() const {return fOuterPadLength;}
234   Float_t  GetOuterPadWidth()  const {return fOuterPadWidth;}  
235   Bool_t   GetMWPCReadout() const {return fBMWPCReadout;}
236   Int_t    GetNCrossRows() const {return fNCrossRows;}
237   Float_t  GetPadPitchWidth(Int_t isector = 0) const  {
238     return ( (isector < fNInnerSector) ? fInnerPadPitchWidth :fOuterPadPitchWidth);}
239   Float_t  GetPadPitchLength(Int_t isector = 0)  const {
240     return ( (isector < fNInnerSector) ? fInnerPadPitchLength :fOuterPadPitchLength);} 
241
242   Int_t GetNRowLow() const;   //get the number of pad rows in low sector
243   Int_t GetNRowUp() const;    //get the number of pad rows in up sector
244   Int_t GetNRow(Int_t isec) const {return  ((isec<fNInnerSector) ?  fNRowLow:fNRowUp);}
245   Int_t GetNRowsTotal(){return fNtRows;}  //get total nuber of rows
246   Float_t GetPadRowRadiiLow(Int_t irow) const; //get the pad row (irow) radii
247   Float_t GetPadRowRadiiUp(Int_t irow) const;  //get the pad row (irow) radii
248   Float_t GetPadRowRadii(Int_t isec,Int_t irow) const {
249     return ( (isec < fNInnerSector) ?GetPadRowRadiiLow(irow):GetPadRowRadiiUp(irow));}
250     //retrun radii of the pad row irow in sector i
251   Int_t GetNPadsLow(Int_t irow) const;    //get the number of pads in row irow 
252   Int_t GetNPadsUp(Int_t irow) const;     //get the number of pads in row irow
253   Int_t GetNPads(Int_t isector,Int_t irow) const{
254      return ( (isector < fNInnerSector) ?GetNPadsLow(irow) : GetNPadsUp(irow));}    
255   //
256   //get GAS parameters 
257   //
258   Float_t  GetDiffT() const {return fDiffT;}
259   Float_t  GetDiffL() const {return fDiffL;}
260   Float_t  GetGasGain() const {return fGasGain;}
261   Float_t  GetDriftV() const {return fDriftV;}
262   Float_t  GetOmegaTau() const {return fOmegaTau;}
263   Float_t  GetAttCoef() const {return fAttCoef;}
264   Float_t  GetOxyCont() const {return fOxyCont;}
265   //
266   //get Electronic parameters
267   //
268   Float_t  GetPadCoupling() const {return fPadCoupling;}
269   Int_t    GetZeroSup() const {return fZeroSup;}
270   Float_t  GetNoise() const {return fNoise;}
271   Float_t  GetChipGain() const {return fChipGain;}
272   Float_t  GetChipNorm() const {return fChipNorm;}
273   Float_t  GetTSample() const {return fTSample;}
274   Float_t  GetZWidth() const {return fZWidth;}
275   Float_t  GetTFWHM() const {return fTSigma*2.35;}
276   Float_t  GetZSigma() const {return fTSigma*fDriftV;}  
277   virtual  Float_t  GetZOffset() {return 3*fTSigma*fDriftV;}
278   Int_t    GetMaxTBin() const {return fMaxTBin;}
279   Int_t    GetADCSat() const {return fADCSat;}
280   Float_t  GetADCDynRange() const {return fADCDynRange;}
281   Float_t  GetTotalNormFac() const {return fTotalNormFac;}
282   Float_t  GetNoiseNormFac() const {return fNoiseNormFac;}
283   //
284   // get response data
285   //  
286   inline Int_t * GetResBin(Int_t i);  
287   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
288   inline Float_t GetResWeight(Int_t i);
289   //return  weight of response bin i
290 protected :
291
292   Bool_t fbStatus;  //indicates consistency of the data
293   //---------------------------------------------------------------------
294   //   ALICE TPC sector geometry
295   //--------------------------------------------------------------------  
296   Float_t fInnerRadiusLow;    // lower radius of inner sector-IP
297   Float_t fInnerRadiusUp;     // upper radius of inner  sector-IP
298   Float_t fOuterRadiusUp;     // upper radius of outer  sector-IP
299   Float_t fOuterRadiusLow;    // lower radius of outer sector-IP
300   Float_t fInnerAngle;        //opening angle of Inner sector
301   Float_t fInnerAngleShift;   //shift of first inner sector center to the 0
302   Float_t fOuterAngle;        //opening angle of outer sector
303   Float_t fOuterAngleShift;   //shift of first sector center to the 0  
304   Float_t fInnerFrameSpace;   //space for inner frame in the phi direction 
305   Float_t fOuterFrameSpace;   //space for outer frame in the phi direction 
306   Float_t fInnerWireMount;    //space for wire mount, inner sector
307   Float_t fOuterWireMount;    //space for wire mount, outer sector
308   Int_t   fNInnerSector;      //!number of inner sectors             -calculated
309   Int_t   fNOuterSector;      //!number of outer sectors             -calculated
310   Int_t   fNSector;           //! total number of sectors            -calculated
311   Float_t fZLength;           //length of the drift region of the TPC
312   Float_t *fRotAngle;         //  sin and cos of rotation angles for 
313                               //  diferent sectors -calculated
314   Int_t   fGeometryType;      //type of geometry -0 straight rows
315   //1-cylindrical
316   //---------------------------------------------------------------------
317   //   ALICE TPC wires  geometry - for GEM we can consider that it is gating  
318   //--------------------------------------------------------------------
319   Int_t   fNInnerWiresPerPad; //  Number of wires per pad
320   Float_t fInnerWWPitch;      // pitch between wires  in inner sector     - calculated
321   Int_t   fInnerDummyWire;    //number of wires without pad readout
322   Float_t fInnerOffWire;      //oofset of first wire to the begining of the sector
323   Float_t fRInnerFirstWire;   //position of the first wire                -calculated
324   Float_t fRInnerLastWire;    //position of the last wire                 -calculated
325   Int_t   fNOuterWiresPerPad; //  Number of wires per pad
326   Float_t fOuterWWPitch;      // pitch between wires in outer sector      -calculated
327   Int_t   fOuterDummyWire;    //number of wires without pad readout
328   Float_t fOuterOffWire;      //oofset of first wire to the begining of the sector
329   Float_t fROuterFirstWire;   //position of the first wire                -calulated
330   Float_t fROuterLastWire;    //position of the last wire                 -calculated 
331   //---------------------------------------------------------------------
332   //   ALICE TPC pad parameters
333   //--------------------------------------------------------------------
334   Float_t   fInnerPadPitchLength;    //Inner pad pitch length
335   Float_t   fInnerPadPitchWidth;     //Inner pad pitch width
336   Float_t   fInnerPadLength;         //Inner pad  length
337   Float_t   fInnerPadWidth;          //Inner pad  width
338   Float_t   fOuterPadPitchLength;    //Outer pad pitch length
339   Float_t   fOuterPadPitchWidth;     //Outer pad pitch width
340   Float_t   fOuterPadLength;         //Outer pad  length
341   Float_t   fOuterPadWidth;          //Outer pad  width
342   Bool_t    fBMWPCReadout;           //indicate wire readout - kTRUE or GEM readout -kFALSE
343   Int_t     fNCrossRows;             //number of rows to crostalk calculation
344       
345   Int_t fNRowLow;           //number of pad rows per low sector    -calculated
346   Int_t fNRowUp;            //number of pad rows per sector up     -calculated
347   Int_t fNtRows;            //total number of rows in TPC          -calculated
348   Float_t  fPadRowLow[600]; //Lower sector, pad row radii          -calculated
349   Float_t  fPadRowUp[600];  //Upper sector, pad row radii          -calculated 
350   Int_t    fNPadsLow[600];  //Lower sector, number of pads per row -calculated
351   Int_t    fNPadsUp[600];   //Upper sector, number of pads per row -calculated  
352   //---------------------------------------------------------------------
353   //   ALICE TPC Gas Parameters
354   //--------------------------------------------------------------------
355   Float_t  fDiffT;          //tangencial diffusion constant
356   Float_t  fDiffL;          //longutudinal diffusion constant
357   Float_t  fGasGain;        //gas gain constant
358   Float_t  fDriftV;         //drift velocity constant
359   Float_t  fOmegaTau;       //omega tau ExB coeficient
360   Float_t  fAttCoef;        //attachment coefitients
361   Float_t  fOxyCont;        //oxygen content
362   //---------------------------------------------------------------------
363   //   ALICE TPC  Electronics Parameters
364   //--------------------------------------------------------------------
365   Float_t fPadCoupling;     //coupling factor ration of  anode signal 
366                             //and total pads signal  
367   Int_t fZeroSup;           //zero suppresion constant
368   Float_t fNoise;           //noise sigma constant
369   Float_t fChipGain;        //preamp shaper constant
370   Float_t fChipNorm;         //preamp shaper normalisation 
371   Float_t fTSample;         //sampling time
372   Float_t fZWidth;          //derived value calculated using TSample and driftw  -computed
373   Float_t fTSigma;          //width of the Preamp/Shaper function
374   Int_t   fMaxTBin;         //maximum time bin number
375   Int_t   fADCSat;          //saturation value of ADC (10 bits)
376   Float_t fADCDynRange;     //input dynamic range (mV)
377   Float_t fTotalNormFac;    //full normalisation factor - calculated
378   Float_t fNoiseNormFac;    //normalisation factor to transform noise in electron to ADC channel   
379   
380  
381 protected:
382   //---------------------------------------------------------------------
383   // ALICE TPC response data 
384   //---------------------------------------------------------------------
385   Int_t   fNResponseMax;   //maximal dimension of response        
386   Float_t fResponseThreshold; //threshold for accepted response   
387   Int_t   fCurrentMax;     //current maximal dimension            -calulated 
388   Int_t   *fResponseBin;    //array with bins                     -calulated
389   Float_t *fResponseWeight; //array with response                 -calulated
390
391   ClassDef(AliTPCParam,2)  //parameter  object for set:TPC
392 };
393
394  
395 inline Int_t * AliTPCParam::GetResBin(Int_t i)
396 {
397   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
398   if (i<fCurrentMax) return &fResponseBin[i*3];
399   else return 0;
400 };
401   
402 inline Float_t AliTPCParam::GetResWeight(Int_t i)
403 {
404   //return  weight of response bin i
405   if (i<fCurrentMax) return fResponseWeight[i];
406   else return 0;
407 }
408
409  
410 /////////////////////////////////////////////////////////////////////////////
411 //
412 //---------------------------------------------------------------------
413 //   ALICE TPC Cluster Parameters
414 //--------------------------------------------------------------------
415 //
416 //
417 // Sigma rphi
418 const Float_t a_rphi=0.41818e-2;
419 const Float_t b_rphi=0.17460e-4;
420 const Float_t c_rphi=0.30993e-2;
421 const Float_t d_rphi=0.41061e-3;
422 // Sigma z
423 const Float_t a_z=0.39614e-2;
424 const Float_t b_z=0.22443e-4;
425 const Float_t c_z=0.51504e-1;
426 // Cluster width in rphi
427 const Float_t ac_rphi=0.18322;
428 const Float_t bc_rphi=0.59551e-3;
429 const Float_t cc_rphi=0.60952e-1;
430 // Cluster width in z
431 const Float_t ac_z=0.19081;
432 const Float_t bc_z=0.55938e-3;
433 const Float_t cc_z=0.30428;
434
435
436
437 void  AliTPCParam::AdjustCosSin(Int_t isec, Float_t &cos, Float_t &sin) const
438 {
439   //
440   //set cosinus and sinus of rotation angles for sector isec
441   //
442   cos=fRotAngle[isec*4];
443   sin=fRotAngle[isec*4+1];
444 }
445
446 Float_t   AliTPCParam::GetAngle(Int_t isec) const
447 {
448   //
449   //return rotation angle of given sector
450   //
451   return fRotAngle[isec*4+2];
452 }
453
454
455 inline void AliTPCParam::Transform1to2(Float_t *xyz, Int_t *index) const
456 {
457   //transformation to rotated coordinates 
458   //we must have information about sector!
459
460   //rotate to given sector
461   Float_t cos,sin;
462   AdjustCosSin(index[1],cos,sin);   
463   Float_t x1=xyz[0]*cos + xyz[1]*sin;
464   Float_t y1=-xyz[0]*sin + xyz[1]*cos; 
465   xyz[0]=x1;
466   xyz[1]=y1;
467   xyz[2]=fZLength-TMath::Abs(xyz[2]); 
468   index[0]=2;
469 }
470
471 inline void AliTPCParam::Transform2to1(Float_t *xyz, Int_t *index) const
472 {
473   //
474   //transformation from  rotated coordinates to global coordinates
475   //
476   Float_t cos,sin;
477   AdjustCosSin(index[1],cos,sin);   
478   Float_t x1=xyz[0]*cos - xyz[1]*sin;
479   Float_t y1=xyz[0]*sin + xyz[1]*cos; 
480   xyz[0]=x1;
481   xyz[1]=y1;
482   xyz[2]=fZLength-xyz[2]; 
483   if (index[1]<fNInnerSector)
484     if ( index[1]>=(fNInnerSector>>1))  xyz[2]*=-1.;
485   else 
486     if ( (index[1]-fNInnerSector) > (fNOuterSector>>1) )    xyz[2]*=-1;      
487   index[0]=1;
488 }
489
490 inline void AliTPCParam::Transform2to2(Float_t *xyz, Int_t *index, Int_t *oindex) const
491 {
492   //transform rotated coordinats of one sector to rotated
493   //coordinates relative to another sector
494   Transform2to1(xyz,index);
495   Transform1to2(xyz,oindex);
496   index[0]=2;
497   index[1]=oindex[1];  
498 }
499
500 inline Float_t  AliTPCParam::Transform2to2NearestWire(Float_t *xyz, Int_t *index)  const
501 {
502   //
503   // asigns the x-position of the closest wire to xyz[0], return the
504   // electron to closest wire distance
505   //
506   Float_t xnew,dx;
507   if (index[1]<fNInnerSector) {
508      xnew = fRInnerFirstWire+TMath::Nint((xyz[0]-fRInnerFirstWire)/fInnerWWPitch)*fInnerWWPitch;
509     }
510     else {
511      xnew = fROuterFirstWire+TMath::Nint((xyz[0]-fROuterFirstWire)/fOuterWWPitch)*fOuterWWPitch;
512     }
513   dx = xnew-xyz[0];
514   xyz[0]=xnew;
515   return  dx;
516 }
517
518 inline Int_t   AliTPCParam::Transform2to3(Float_t *xyz, Int_t *index)  const
519 {
520   //
521   //calulates coresponding pad row number, sets index[2] for straight rows
522   //does not change xyz[] information
523   //valid only for straight row
524   //
525   if  (index[1]<fNInnerSector)   
526     index[2] =TMath::Nint((xyz[0]-fPadRowLow[0])/fInnerPadPitchLength);
527   else
528     index[2] = TMath::Nint((xyz[0]-fPadRowUp[0])/fOuterPadPitchLength);
529   index[0]=3;
530   return index[2];
531 }
532
533 inline void   AliTPCParam::Transform3to4(Float_t *xyz, Int_t *index)  const
534 {
535   //
536   //valid only for straight rows straight rows
537   //calculate xyz[0] position relative to given index
538   //
539   if  (index[1]<fNInnerSector)   
540     xyz[0] -=index[2]*fInnerPadPitchLength+fPadRowLow[0];
541   else
542     xyz[0] -=index[2]*fOuterPadPitchLength+fPadRowUp[0];
543   index[0]  =4;
544 }
545
546 inline void   AliTPCParam::Transform4to3(Float_t *xyz, Int_t *index) const
547 {
548   //
549   //valid only for straight rows 
550   //transforms  relative xyz[0] to the global one within given sector
551   //
552   if  (index[1]<fNInnerSector)   
553     xyz[0] +=index[2]*fInnerPadPitchLength+fPadRowLow[0];
554   else
555     xyz[0] +=index[2]*fOuterPadPitchLength+fPadRowUp[0];
556   index[0]  =3;
557 }
558
559
560 inline void   AliTPCParam::Transform2to5( Float_t *xyz, Int_t *index) const
561 {
562   //
563   //transform [x,y,z] to [r,phi,z]
564   //
565   Float_t angle;
566   Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
567   if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0;
568   else
569     {
570       angle =TMath::ASin(xyz[1]/r);
571       if   (xyz[0]<0)   angle=TMath::Pi()-angle;
572       if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
573     }
574   xyz[0]=r;
575   xyz[1]=angle;
576   index[0]=5;
577 }
578
579 inline void   AliTPCParam::Transform5to2( Float_t *xyz, Int_t *index)  const
580 {
581   //
582   //transform [r,rphi,z] to [x,y,z] 
583   //
584   Float_t r = xyz[0];
585   Float_t angle= xyz[1];
586   xyz[0]=r*TMath::Cos(angle);
587   xyz[1]=r*TMath::Sin(angle);
588   index[0]=2;
589 }
590
591 inline void AliTPCParam::Transform4to8(Float_t *xyz, Int_t *index) const
592 {
593   //
594   //transform xyz coordinates to 'digit' coordinates
595   //
596   if  (index[1]<fNInnerSector) {    
597     xyz[0]/=fInnerPadPitchLength;
598     xyz[1]/=fInnerPadPitchWidth;
599     xyz[2]/=fZWidth;
600   }
601   else{    
602     xyz[0]/=fOuterPadPitchLength;
603     xyz[1]/=fOuterPadPitchWidth;
604     xyz[2]/=fZWidth;
605   }        
606   index[0]=8;
607 }
608
609 inline void AliTPCParam::Transform8to4(Float_t *xyz, Int_t *index) const
610 {
611   //
612   //transforms 'digit' coordinates to xyz coordinates
613   //
614   if  (index[1]<fNInnerSector) {    
615     xyz[0]*=fInnerPadPitchLength;
616     xyz[1]*=fInnerPadPitchWidth;
617     xyz[2]*=fZWidth;
618   }
619   else{    
620     xyz[0]*=fOuterPadPitchLength;
621     xyz[1]*=fOuterPadPitchWidth;
622     xyz[2]*=fZWidth;
623   }        
624   index[0]=4;
625 }
626
627 inline void  AliTPCParam::Transform6to8(Float_t *xyz, Int_t *index) const
628 {
629   //
630   //transforms cylindrical xyz coordinates to 'digit' coordinates
631   //
632   
633   if  (index[1]<fNInnerSector) {    
634     xyz[0]/=fInnerPadPitchLength;
635     xyz[1]*=xyz[0]/fInnerPadPitchWidth;
636     xyz[2]/=fZWidth;
637   }
638   else{   
639     xyz[0]/=fOuterPadPitchLength;
640     xyz[1]*=xyz[0]/fOuterPadPitchWidth;
641     xyz[2]/=fZWidth;
642   }        
643   index[0]=8;
644 }
645
646 inline void  AliTPCParam::Transform8to6(Float_t *xyz, Int_t *index) const
647 {
648   //
649   //transforms 'digit' coordinates to cylindrical xyz coordinates 
650   //
651   
652   if  (index[1]<fNInnerSector) {    
653     xyz[0]*=fInnerPadPitchLength;
654     xyz[1]/=xyz[0]/fInnerPadPitchWidth;
655     xyz[2]*=fZWidth;
656   }
657   else{   
658     xyz[0]*=fOuterPadPitchLength;
659     xyz[1]/=xyz[0]/fOuterPadPitchWidth;
660     xyz[2]*=fZWidth;
661   }        
662   index[0]=6;
663 }
664
665
666
667 #endif