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