]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCParam.h
Macros for analysis wagon:
[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 #include <TGeoMatrix.h>
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   TGeoHMatrix *  Tracking2LocalMatrix(const TGeoHMatrix * geoMatrix, Int_t sector) const;  
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 Transform1to2Ideal(Float_t *xyz, Int_t *index) const;
34   //transformation to rotated coordinata - ideal frame 
35   void Transform1to2(Float_t *xyz, Int_t *index) const;
36   //transformation to rotated coordinata   
37   void Transform2to1(Float_t *xyz, Int_t *index) const;
38   //transformation from rotated coordinata to global coordinata
39   void Transform2to2(Float_t *xyz, Int_t *index, Int_t *oindex) const;
40   //transform rotated coordinata of one sector to rotated
41   //coordinata relative to another sector
42   Float_t  Transform2to2NearestWire(Float_t *xyz, Int_t *index) const;
43   //round x position to nearest wire
44   Int_t   Transform2to3(Float_t *xyz, Int_t *index) const;
45   //calulate coresponding index[2] -pad row for straight rows
46   //does not change xyz[] 
47   //return pad - row 
48   void   Transform3to4(Float_t *xyz, Int_t *index) const;
49   //valid only for straight rows straight rows
50   //calculate xyz[0] position relative to given index
51   //return pad - row 
52   void   Transform4to3(Float_t *xyz, Int_t *index) const;
53   //valid only for straight rows straight rows
54   //transform  xyz[0] position relative to given index
55   void   Transform2to5( Float_t *xyz, Int_t *index) const;
56   //transform [x,y,z] to [r,rphi,z]
57   void   Transform5to2(Float_t *xyz, Int_t *index) const;
58   //transform [r,rphi,z] coordinata to [x,y,z] 
59   void  Transform4to8(Float_t *xyz, Int_t *index) const;
60   //transform xyz coordinata to 'digit' coordinata
61   void  Transform8to4(Float_t *xyz, Int_t *index) const;
62   //transform  'digit' coordinata to xyz coordinata   
63   void  Transform6to8(Float_t *xyz, Int_t *index) const;
64   //transform dr,f coordinata to 'digit' coordinata
65   void  Transform8to6(Float_t *xyz, Int_t *index) const;
66   //transform 'digit' coordinata to dr,f coordinata 
67
68   virtual Int_t  Transform2toPadRow(Float_t */*xyz*/, Int_t */*index*/) const{return 0;}
69   //transform rotated to
70
71   virtual  Int_t GetPadRow(Float_t *xyz, Int_t *index) const ;
72   //return pad row of point xyz - xyz is given in coordinate system -(given by index)
73   //output system is 3 for straight row and 7 for cylindrical row
74   virtual void XYZtoCRXYZ(Float_t */*xyz*/, 
75                           Int_t &/*sector*/, Int_t &/*padrow*/, Int_t /*option*/) const {;}
76   //transform global position to the position relative to the sector padrow
77   //if option=0  X calculate absolute            calculate sector
78   //if option=1  X           absolute            use input sector
79   //if option=2  X           relative to pad row calculate sector
80   //if option=3  X           relative            use input sector
81
82   virtual void CRXYZtoXYZ(Float_t */*xyz*/,
83                           const Int_t &/*sector*/, const Int_t & /*padrow*/, Int_t /*option*/) const {;}  
84   //transform relative position  to the gloabal position
85
86   virtual void CRTimePadtoYZ(Float_t &/*y*/, Float_t &/*z*/, 
87                              const Float_t &/*time*/, const Float_t &/*pad*/,
88                              Int_t /*sector*/, Int_t /*padrow*/ ){;}
89   //transform position in digit  units (time slices and pads)  to "normal" 
90   //units (cm)   
91   virtual void CRYZtoTimePad(const Float_t &/*y*/, const Float_t &/*z*/, 
92                              Float_t &/*time*/, Float_t &/*pad*/,
93                              Int_t /*sector*/, Int_t /*padrow*/){;}
94   //transform position in cm to position in digit unit 
95   virtual Int_t   CalcResponse(Float_t* /*x*/, Int_t * /*index*/, Int_t /*row*/){return 0;}
96   //calculate bin response as function of the input position -x and the weight 
97   //if row -pad row is equal -1 calculate response for each pad row 
98   //otherwise it calculate only in given pad row
99   //return number of valid response bin
100   virtual void SetDefault();          //set defaut TPCparam 
101   virtual Bool_t Update();            //recalculate and check geometric parameters 
102   virtual Bool_t ReadGeoMatrices();   //read geo matrixes        
103   Bool_t GetStatus() const;         //get information about object consistency  
104   Int_t GetIndex(Int_t sector, Int_t row) const;  //give index of the given sector and pad row 
105   Int_t GetNSegmentsTotal() const {return fNtRows;} 
106   Double_t GetLowMaxY(Int_t irow) const {return irow*0.;}
107   Double_t GetUpMaxY(Int_t irow) const {return irow*0;}
108   //additional geometrical function - for Belikov
109  
110   Bool_t   AdjustSectorRow(Int_t index, Int_t & sector, Int_t &row) const; //return sector and padrow
111   //for given index
112
113   void  AdjustCosSin(Int_t isec, Float_t &cos, Float_t &sin) const;
114   //set cosinus and sinus of rotation angles for sector isec 
115   Float_t GetAngle(Int_t isec) const;
116   //  void GetChamberPos(Int_t isec, Float_t* xyz) const;
117   //  void GetChamberRot(Int_t isec, Float_t* angles) const;
118   //
119   //set sector parameters
120   //
121   void  SetInnerRadiusLow(Float_t InnerRadiusLow )  { fInnerRadiusLow=InnerRadiusLow;}
122   void  SetOuterRadiusLow(Float_t OuterRadiusLow )  { fOuterRadiusLow=OuterRadiusLow;} 
123   void  SetInnerRadiusUp(Float_t InnerRadiusUp)  {  fInnerRadiusUp= InnerRadiusUp;} 
124   void  SetOuterRadiusUp(Float_t OuterRadiusUp) {  fOuterRadiusUp= OuterRadiusUp;}   
125   void  SetSectorAngles(Float_t innerangle, Float_t innershift, Float_t outerangle,
126                         Float_t outershift);
127   void  SetInnerFrameSpace(Float_t frspace) {fInnerFrameSpace = frspace;}
128   void  SetOuterFrameSpace(Float_t frspace) {fOuterFrameSpace = frspace;}
129   void  SetInnerWireMount(Float_t fmount) {fInnerWireMount = fmount;}
130   void  SetOuterWireMount(Float_t fmount) {fOuterWireMount = fmount;}
131   void  SetZLength(Float_t zlength) {fZLength = zlength;} 
132   void  SetGeometryType(Int_t type) {fGeometryType = type;}
133   //
134   // pad rows geometry
135   //
136   void SetRowNLow( Int_t NRowLow){fNRowLow = NRowLow;}
137   void SetRowNUp1 (Int_t NRowUp1){fNRowUp1 = NRowUp1 ;} //upper sec short pads 
138   void SetRowNUp2 (Int_t NRowUp2){fNRowUp2 = NRowUp2 ;} //upper sec long pads
139   void SetRowNUp (Int_t NRowUp){fNRowUp = NRowUp ;}  
140   //
141   //set wire parameters
142   //
143   void  SetInnerNWires(Int_t nWires){  fNInnerWiresPerPad=nWires;}
144   void  SetInnerDummyWire(Int_t dummy) {fInnerDummyWire  = dummy;}
145   void  SetInnerOffWire(Float_t offset) {fInnerOffWire =offset;}    
146   void  SetOuter1NWires(Int_t nWires){  fNOuter1WiresPerPad=nWires;}
147   void  SetOuter2NWire(Int_t nWires){  fNOuter2WiresPerPad=nWires;}
148   void  SetOuterDummyWire(Int_t dummy) {fOuterDummyWire  = dummy;}
149   void  SetOuterOffWire(Float_t offset) {fOuterOffWire =offset;} 
150   void  SetInnerWWPitch( Float_t wwPitch) {fInnerWWPitch = wwPitch;}
151   void  SetRInnerFirstWire(Float_t firstWire){fRInnerFirstWire = firstWire;}
152   void  SetRInnerLastWire(Float_t lastWire){fRInnerLastWire = lastWire;}
153   void  SetOuterWWPitch(Float_t wwPitch){fOuterWWPitch = wwPitch;}
154   void  SetLastWireUp1(Float_t wireUp1){fLastWireUp1 = wireUp1;} 
155   void  SetROuterFirstWire(Float_t firstWire){fROuterFirstWire = firstWire;}
156   void  SetROuterLastWire(Float_t lastWire){fROuterLastWire = lastWire;}   
157   //
158   //set pad parameter
159   //
160   void  SetInnerPadPitchLength(Float_t PadPitchLength){  fInnerPadPitchLength=PadPitchLength;}
161   void  SetInnerPadPitchWidth(Float_t PadPitchWidth){  fInnerPadPitchWidth = PadPitchWidth;}
162   void  SetInnerPadLength(Float_t PadLength){  fInnerPadLength=PadLength;}
163   void  SetInnerPadWidth(Float_t PadWidth) {  fInnerPadWidth=PadWidth;} 
164   void  SetOuter1PadPitchLength(Float_t PadPitchLength){  fOuter1PadPitchLength=PadPitchLength;}
165   void  SetOuter2PadPitchLength(Float_t PadPitchLength){  fOuter2PadPitchLength=PadPitchLength;}
166   void  SetOuterPadPitchWidth(Float_t PadPitchWidth){  fOuterPadPitchWidth = PadPitchWidth;}
167   void  SetOuter1PadLength(Float_t PadLength){  fOuter1PadLength=PadLength;}
168   void  SetOuter2PadLength(Float_t PadLength){  fOuter2PadLength=PadLength;}
169   void  SetOuterPadWidth(Float_t PadWidth) {  fOuterPadWidth=PadWidth;}
170   void  SetMWPCReadout(Bool_t type) {fBMWPCReadout = type;}
171   void  SetNCrossRows(Int_t rows){fNCrossRows = rows;}
172   //
173   //set gas paremeters
174   //
175   void  SetDiffT(Float_t DiffT){  fDiffT= DiffT;}
176   void  SetDiffL(Float_t DiffL){  fDiffL=DiffL;}
177   void  SetGasGain(Float_t GasGain){  fGasGain=GasGain;}
178   void  SetDriftV(Float_t DriftV){  fDriftV= DriftV;}
179   void  SetOmegaTau(Float_t OmegaTau){  fOmegaTau=OmegaTau;}
180   void  SetAttCoef(Float_t AttCoef){  fAttCoef=AttCoef;}
181   void  SetOxyCont(Float_t OxyCont){  fOxyCont=OxyCont;}
182   //
183   //set electronivc parameters  
184   //
185   void  SetPadCoupling(Float_t PadCoupling){  fPadCoupling=PadCoupling;}
186   void  SetZeroSup(Int_t ZeroSup)    {  fZeroSup=ZeroSup;}
187   void  SetNoise(Float_t Noise )     {  fNoise= Noise;}
188   void  SetChipGain(Float_t ChipGain){  fChipGain= ChipGain;}
189   void  SetChipNorm(Float_t ChipNorm){  fChipNorm= ChipNorm;}
190   void  SetTSample(Float_t TSample)  {  fTSample=TSample;}
191   void  SetTFWHM(Float_t fwhm)     {  fTSigma=fwhm/2.35;}
192   void  SetMaxTBin(Int_t maxtbin)  {  fMaxTBin = maxtbin;}
193   void  SetADCSat(Int_t adcsat)    {  fADCSat  = adcsat;}
194   void  SetADCDynRange(Float_t adcdynrange) {fADCDynRange = adcdynrange;}
195   //
196   //set response  parameters  
197   //
198   void  SetNResponseMax(Int_t max) { fNResponseMax = max;} 
199   void  SetResponseThreshold(Int_t threshold) {fResponseThreshold = threshold;}
200   //set L1 parameters
201   void  SetGateDelay(Float_t delay) {fGateDelay = delay;}
202   void  SetL1Delay(Float_t delay) {fL1Delay = delay;}
203   void  SetNTBinsBeforeL1(UShort_t nbins) {fNTBinsBeforeL1 = nbins;}
204   //
205   //get sector parameters
206   //
207   Float_t  GetInnerRadiusLow() const {return fInnerRadiusLow;}
208   Float_t  GetInnerRadiusUp() const {return fInnerRadiusUp;} 
209   Float_t  GetOuterRadiusLow() const {return fOuterRadiusLow;} 
210   Float_t  GetOuterRadiusUp() const {return fOuterRadiusUp;} 
211   Float_t  GetInnerFrameSpace() const {return fInnerFrameSpace;}
212   Float_t  GetOuterFrameSpace() const {return fOuterFrameSpace;}
213   Float_t  GetInnerWireMount() const {return fInnerWireMount;}
214   Float_t  GetOuterWireMount() const {return fOuterWireMount;}
215   Float_t  GetInnerAngle() const ;
216   Float_t  GetInnerAngleShift() const ;
217   Float_t  GetOuterAngle() const ;
218   Float_t  GetOuterAngleShift() const ; 
219   Int_t    GetNInnerSector() const {return fNInnerSector;}
220   Int_t    GetNOuterSector() const {return fNOuterSector;}
221   Int_t    GetNSector() const {return fNSector;}
222   Float_t  GetZLength(Int_t sector=0) const;
223   Int_t    GetGeometryType() const {return fGeometryType;}
224
225   //
226   //get wires parameter
227   //
228   Int_t    GetInnerNWires() const {return fNInnerWiresPerPad;}
229   Float_t  GetInnerWWPitch() const {return fInnerWWPitch;}  
230   Int_t    GetInnerDummyWire() const {return fInnerDummyWire;}
231   Float_t  GetInnerOffWire() const {return fInnerOffWire;}
232   Float_t  GetRInnerFirstWire() const {return fRInnerFirstWire;}
233   Float_t  GetRInnerLastWire() const {return fRInnerLastWire;}
234   Int_t    GetOuter1NWires() const {return fNOuter1WiresPerPad;}
235   Int_t    GetOuter2NWires() const {return fNOuter2WiresPerPad;}
236   Float_t  GetOuterWWPitch() const {return fOuterWWPitch;}  
237   Int_t    GetOuterDummyWire() const {return fOuterDummyWire;}
238   Float_t  GetOuterOffWire() const {return fOuterOffWire;}
239   Float_t  GetLastWireUp1()  const {return fLastWireUp1;}
240   Float_t  GetROuterFirstWire() const {return fROuterFirstWire;}
241   Float_t  GetROuterLastWire() const {return fROuterLastWire;}  
242   Float_t  GetWWPitch(Int_t isector = 0) const  {
243     return ( (isector < fNInnerSector) ? fInnerWWPitch :fOuterWWPitch);} 
244   //
245   //get pad  parameters
246   //
247   Float_t  GetInnerPadPitchLength() const {return fInnerPadPitchLength;}
248   Float_t  GetInnerPadPitchWidth() const {return fInnerPadPitchWidth;}
249   Float_t  GetInnerPadLength() const {return fInnerPadLength;}
250   Float_t  GetInnerPadWidth() const  {return fInnerPadWidth;}
251   Float_t  GetOuter1PadPitchLength() const {return fOuter1PadPitchLength;}
252   Float_t  GetOuter2PadPitchLength() const {return fOuter2PadPitchLength;}  
253   Float_t  GetOuterPadPitchWidth() const {return fOuterPadPitchWidth;}
254   Float_t  GetOuter1PadLength() const {return fOuter1PadLength;}
255   Float_t  GetOuter2PadLength() const {return fOuter2PadLength;}
256   Float_t  GetOuterPadWidth()  const {return fOuterPadWidth;}  
257   Bool_t   GetMWPCReadout() const {return fBMWPCReadout;}
258   Int_t    GetNCrossRows() const {return fNCrossRows;}
259   Float_t  GetPadPitchWidth(Int_t isector = 0) const  {
260     return ( (isector < fNInnerSector) ? fInnerPadPitchWidth :fOuterPadPitchWidth);}
261   Float_t  GetPadPitchLength(Int_t isector = 0, Int_t padrow=0)  const
262   { if (isector < fNInnerSector) return fInnerPadPitchLength; 
263     else return ((padrow<fNRowUp1) ? fOuter1PadPitchLength:fOuter2PadPitchLength);}
264   Int_t GetNRowLow() const;   //get the number of pad rows in low sector
265   Int_t GetNRowUp() const;    //get the number of pad rows in up sector
266   Int_t GetNRowUp1() const;  // number of short rows in up sector  
267   Int_t GetNRowUp2() const;  // number of long rows in up sector
268   Int_t GetNRow(Int_t isec) const {return  ((isec<fNInnerSector) ?  fNRowLow:fNRowUp);}
269   Int_t GetNRowsTotal() const {return fNtRows;}  //get total nuber of rows
270   Float_t GetPadRowRadiiLow(Int_t irow) const; //get the pad row (irow) radii
271   Float_t GetPadRowRadiiUp(Int_t irow) const;  //get the pad row (irow) radii
272   Float_t GetPadRowRadii(Int_t isec,Int_t irow) const {
273     return ( (isec < fNInnerSector) ?GetPadRowRadiiLow(irow):GetPadRowRadiiUp(irow));}
274     //retrun radii of the pad row irow in sector i
275   Int_t GetNPadsLow(Int_t irow) const;    //get the number of pads in row irow 
276   Int_t GetNPadsUp(Int_t irow) const;     //get the number of pads in row irow
277   Int_t GetNPads(Int_t isector,Int_t irow) const{
278      return ( (isector < fNInnerSector) ?GetNPadsLow(irow) : GetNPadsUp(irow));} 
279
280   Float_t GetYInner(Int_t irow) const; // wire length in low sec row
281   Float_t GetYOuter(Int_t irow) const; // wire length in up sec row  
282   Int_t GetSectorIndex(Float_t angle, Int_t row, Float_t z) const; // get sector index
283   Float_t GetChamberCenter(Int_t isec, Float_t * center = 0) const; // get readout chamber positions
284   TGeoHMatrix *GetTrackingMatrix(Int_t isec) const {
285     return fTrackingMatrix[isec];}
286   TGeoHMatrix *GetClusterMatrix(Int_t isec) const {
287     return fClusterMatrix[isec];}
288   TGeoHMatrix *GetGlobalMatrix(Int_t isec) const {
289     return fGlobalMatrix[isec];}
290   Bool_t   IsGeoRead(){ return fGlobalMatrix!=0;}
291   //
292   //get GAS parameters 
293   //
294   Float_t  GetDiffT() const {return fDiffT;}
295   Float_t  GetDiffL() const {return fDiffL;}
296   Float_t  GetGasGain() const {return fGasGain;}
297   Float_t  GetDriftV() const {return fDriftV;}
298   Float_t  GetOmegaTau() const {return fOmegaTau;}
299   Float_t  GetAttCoef() const {return fAttCoef;}
300   Float_t  GetOxyCont() const {return fOxyCont;}
301   //
302   //get Electronic parameters
303   //
304   Float_t  GetPadCoupling() const {return fPadCoupling;}
305   Int_t    GetZeroSup() const {return fZeroSup;}
306   Float_t  GetNoise() const {return fNoise;}
307   Float_t  GetChipGain() const {return fChipGain;}
308   Float_t  GetChipNorm() const {return fChipNorm;}
309   Float_t  GetTSample() const {return fTSample;}
310   Float_t  GetZWidth() const {return fZWidth;}
311   Float_t  GetTFWHM() const {return fTSigma*2.35;}
312   Float_t  GetZSigma() const {return fTSigma*fDriftV;}  
313   virtual  Float_t  GetZOffset() const {return 3*fTSigma*fDriftV;}
314   Int_t    GetMaxTBin() const {return fMaxTBin;}
315   Int_t    GetADCSat() const {return fADCSat;}
316   Float_t  GetADCDynRange() const {return fADCDynRange;}
317   Float_t  GetTotalNormFac() const {return fTotalNormFac;}
318   Float_t  GetNoiseNormFac() const {return fNoiseNormFac;}
319   //
320   // get response data
321   //  
322   Int_t * GetResBin(Int_t i);  
323   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
324   Float_t & GetResWeight(Int_t i);
325   //return  weight of response bin i
326
327   // get L1 data
328   Float_t  GetGateDelay() const {return fGateDelay;}
329   Float_t  GetL1Delay() const {return fL1Delay;}
330   UShort_t GetNTBinsBeforeL1() const {return fNTBinsBeforeL1;}
331   Float_t  GetNTBinsL1() const {return fNTBinsL1;}
332 protected :
333
334   Bool_t fbStatus;  //indicates consistency of the data
335   //---------------------------------------------------------------------
336   //   ALICE TPC sector geometry
337   //--------------------------------------------------------------------  
338   Float_t fInnerRadiusLow;    // lower radius of inner sector-IP
339   Float_t fInnerRadiusUp;     // upper radius of inner  sector-IP
340   Float_t fOuterRadiusUp;     // upper radius of outer  sector-IP
341   Float_t fOuterRadiusLow;    // lower radius of outer sector-IP
342   Float_t fInnerAngle;        //opening angle of Inner sector
343   Float_t fInnerAngleShift;   //shift of first inner sector center to the 0
344   Float_t fOuterAngle;        //opening angle of outer sector
345   Float_t fOuterAngleShift;   //shift of first sector center to the 0  
346   Float_t fInnerFrameSpace;   //space for inner frame in the phi direction 
347   Float_t fOuterFrameSpace;   //space for outer frame in the phi direction 
348   Float_t fInnerWireMount;    //space for wire mount, inner sector
349   Float_t fOuterWireMount;    //space for wire mount, outer sector
350   Int_t   fNInnerSector;      //number of inner sectors             -calculated
351   Int_t   fNOuterSector;      //number of outer sectors             -calculated
352   Int_t   fNSector;           // total number of sectors            -calculated
353   Float_t fZLength;           //length of the drift region of the TPC
354   Float_t *fRotAngle;         //[fNSector]  sin and cos of rotation angles for 
355                               //  diferent sectors -calculated
356   Int_t   fGeometryType;      //type of geometry -0 straight rows
357   //  Float_t *fChamberPos;       //[fNSector] displacements of the readout chambers 
358                               //with respect to the 'idead' geometry
359                               //in local corrdinate system
360   //  Float_t *fChamberRot;       //[fNSector] rotation angles of the readout chambers 
361                               //with respect to the 'idead' geometry
362                               //in local corrdinate system
363   TGeoHMatrix **fTrackingMatrix;   //![fNSector] transformation matrices of the tracking
364                               //coordinate system
365   TGeoHMatrix **fClusterMatrix;    //![fNSector] transformation matrices of the cluster
366                               //coordinate system
367   TGeoHMatrix **fGlobalMatrix;    //![fNSector] fTrackingMatrix * fClusterMatrix
368
369   //1-cylindrical
370   //---------------------------------------------------------------------
371   //   ALICE TPC wires  geometry - for GEM we can consider that it is gating  
372   //--------------------------------------------------------------------
373   Int_t   fNInnerWiresPerPad; //Number of wires per pad
374   Float_t fInnerWWPitch;      //pitch between wires  in inner sector     - calculated
375   Int_t   fInnerDummyWire;    //number of wires without pad readout
376   Float_t fInnerOffWire;      //oofset of first wire to the begining of the sector
377   Float_t fRInnerFirstWire;   //position of the first wire                -calculated
378   Float_t fRInnerLastWire;    //position of the last wire                 -calculated
379   Float_t fLastWireUp1;     //position of the last wire in outer1 sector
380   Int_t   fNOuter1WiresPerPad; //Number of wires per pad
381   Int_t   fNOuter2WiresPerPad; // Number of wires per pad
382   Float_t fOuterWWPitch;      //pitch between wires in outer sector      -calculated
383   Int_t   fOuterDummyWire;    //number of wires without pad readout
384   Float_t fOuterOffWire;      //oofset of first wire to the begining of the sector
385   Float_t fROuterFirstWire;   //position of the first wire                -calulated
386   Float_t fROuterLastWire;    //position of the last wire                 -calculated 
387   //---------------------------------------------------------------------
388   //   ALICE TPC pad parameters
389   //--------------------------------------------------------------------
390   Float_t   fInnerPadPitchLength;    //Inner pad pitch length
391   Float_t   fInnerPadPitchWidth;     //Inner pad pitch width
392   Float_t   fInnerPadLength;         //Inner pad  length
393   Float_t   fInnerPadWidth;          //Inner pad  width
394   Float_t   fOuter1PadPitchLength;    //Outer pad pitch length
395   Float_t   fOuter2PadPitchLength;    //Outer pad pitch length
396   Float_t   fOuterPadPitchWidth;     //Outer pad pitch width
397   Float_t   fOuter1PadLength;         //Outer pad  length
398   Float_t   fOuter2PadLength;         //Outer pad length
399   Float_t   fOuterPadWidth;          //Outer pad  width
400   Bool_t    fBMWPCReadout;           //indicate wire readout - kTRUE or GEM readout -kFALSE
401   Int_t     fNCrossRows;             //number of rows to crostalk calculation
402       
403   Int_t fNRowLow;           //number of pad rows per low sector        -set
404   Int_t fNRowUp1;            //number of short pad rows per sector up  -set
405   Int_t fNRowUp2;            //number of long pad rows per sector up   -set
406   Int_t fNRowUp;            //number of pad rows per sector up     -calculated
407   Int_t fNtRows;            //total number of rows in TPC          -calculated
408   Float_t  fPadRowLow[600]; //Lower sector, pad row radii          -calculated
409   Float_t  fPadRowUp[600];  //Upper sector, pad row radii          -calculated 
410   Int_t    fNPadsLow[600];  //Lower sector, number of pads per row -calculated
411   Int_t    fNPadsUp[600];   //Upper sector, number of pads per row -calculated
412   Float_t  fYInner[600];     //Inner sector, wire-length
413   Float_t  fYOuter[600];     //Outer sector, wire-length   
414   //---------------------------------------------------------------------
415   //   ALICE TPC Gas Parameters
416   //--------------------------------------------------------------------
417   Float_t  fDiffT;          //tangencial diffusion constant
418   Float_t  fDiffL;          //longutudinal diffusion constant
419   Float_t  fGasGain;        //gas gain constant
420   Float_t  fDriftV;         //drift velocity constant
421   Float_t  fOmegaTau;       //omega tau ExB coeficient
422   Float_t  fAttCoef;        //attachment coefitients
423   Float_t  fOxyCont;        //oxygen content
424   //---------------------------------------------------------------------
425   //   ALICE TPC  Electronics Parameters
426   //--------------------------------------------------------------------
427   Float_t fPadCoupling;     //coupling factor ration of  anode signal 
428                             //and total pads signal  
429   Int_t fZeroSup;           //zero suppresion constant
430   Float_t fNoise;           //noise sigma constant
431   Float_t fChipGain;        //preamp shaper constant
432   Float_t fChipNorm;         //preamp shaper normalisation 
433   Float_t fTSample;         //sampling time
434   Float_t fZWidth;          //derived value calculated using TSample and driftw  -computed
435   Float_t fTSigma;          //width of the Preamp/Shaper function
436   Int_t   fMaxTBin;         //maximum time bin number
437   Int_t   fADCSat;          //saturation value of ADC (10 bits)
438   Float_t fADCDynRange;     //input dynamic range (mV)
439   Float_t fTotalNormFac;    //full normalisation factor - calculated
440   Float_t fNoiseNormFac;    //normalisation factor to transform noise in electron to ADC channel   
441   
442   //---------------------------------------------------------------------
443   // ALICE TPC response data 
444   //---------------------------------------------------------------------
445   Int_t   fNResponseMax;   //maximal dimension of response        
446   Float_t fResponseThreshold; //threshold for accepted response   
447   Int_t   fCurrentMax;     //!current maximal dimension            -calulated 
448   Int_t   *fResponseBin;    //!array with bins                     -calulated
449   Float_t *fResponseWeight; //!array with response                 -calulated
450
451   //---------------------------------------------------------------------
452   //   ALICE TPC L1 Parameters
453   //--------------------------------------------------------------------
454   Float_t fGateDelay;       //Delay of L1 arrival for the TPC gate signal
455   Float_t fL1Delay;         //Delay of L1 arrival for the TPC readout 
456   UShort_t fNTBinsBeforeL1; //Number of time bins before L1 arrival which are being read out 
457   Float_t fNTBinsL1;        //Overall L1 delay in time bins
458
459 private:
460   AliTPCParam(const AliTPCParam &);
461   AliTPCParam & operator=(const AliTPCParam &);
462   ClassDef(AliTPCParam,4)  //parameter  object for set:TPC
463 };
464
465  
466 inline Int_t * AliTPCParam::GetResBin(Int_t i)
467 {
468   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
469   if (i<fCurrentMax) return &fResponseBin[i*3];
470   else return 0;
471 }
472   
473 inline Float_t &AliTPCParam::GetResWeight(Int_t i)
474 {
475   //return  weight of response bin i
476   if (i<fCurrentMax) return fResponseWeight[i];
477   else return fResponseWeight[i];
478 }
479
480
481 inline void  AliTPCParam::AdjustCosSin(Int_t isec, Float_t &cos, Float_t &sin) const
482 {
483   //
484   //set cosinus and sinus of rotation angles for sector isec
485   //
486   cos=fRotAngle[isec*4];
487   sin=fRotAngle[isec*4+1];
488 }
489
490 inline Float_t   AliTPCParam::GetAngle(Int_t isec) const
491 {
492   //
493   //return rotation angle of given sector
494   //
495   return fRotAngle[isec*4+2];
496 }
497
498
499 inline void AliTPCParam::Transform1to2Ideal(Float_t *xyz, Int_t *index) const
500 {
501   //transformation to rotated coordinates
502   //we must have information about sector!
503   //rotate to given sector
504   // ideal frame
505
506   Float_t cos,sin;
507   AdjustCosSin(index[1],cos,sin);
508   Float_t x1=xyz[0]*cos + xyz[1]*sin;
509   Float_t y1=-xyz[0]*sin + xyz[1]*cos;
510   xyz[0]=x1;
511   xyz[1]=y1;
512   xyz[2]=fZLength-TMath::Abs(xyz[2]);
513   index[0]=2;
514 }
515
516
517 inline void AliTPCParam::Transform1to2(Float_t *xyz, Int_t *index) const
518 {
519   //transformation to rotated coordinates 
520   //we must have information about sector!
521   //rotate to given sector
522   Double_t xyzmaster[3] = {xyz[0],xyz[1],xyz[2]};
523   Double_t xyzlocal[3];  
524   if (index[1]>=0 && index[1]<fNSector) 
525     fGlobalMatrix[index[1]]->MasterToLocal(xyzmaster,xyzlocal);
526   xyz[0] = xyzlocal[0];
527   xyz[1] = xyzlocal[1];
528   xyz[2] = xyzlocal[2];
529   index[0]=2;
530 }
531
532
533
534
535 inline void AliTPCParam::Transform2to1(Float_t *xyz, Int_t *index) const
536 {
537   //
538   //transformation from  rotated coordinates to global coordinates
539   //
540   Float_t cos,sin;
541   AdjustCosSin(index[1],cos,sin);   
542   Float_t x1=xyz[0]*cos - xyz[1]*sin;
543   Float_t y1=xyz[0]*sin + xyz[1]*cos; 
544   xyz[0]=x1;
545   xyz[1]=y1;
546   xyz[2]=fZLength-xyz[2]; 
547   if (index[1]<fNInnerSector)
548     {if ( index[1]>=(fNInnerSector>>1)) xyz[2]*=-1.;}
549   else 
550     {if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) )    xyz[2]*=-1;}
551   index[0]=1;
552 }
553
554 inline void AliTPCParam::Transform2to2(Float_t *xyz, Int_t *index, Int_t *oindex) const
555 {
556   //transform rotated coordinats of one sector to rotated
557   //coordinates relative to another sector
558   Transform2to1(xyz,index);
559   Transform1to2(xyz,oindex);
560   index[0]=2;
561   index[1]=oindex[1];  
562 }
563
564 inline Float_t  AliTPCParam::Transform2to2NearestWire(Float_t *xyz, Int_t *index)  const
565 {
566   //
567   // asigns the x-position of the closest wire to xyz[0], return the
568   // electron to closest wire distance
569   //
570   Float_t xnew,dx;
571   if (index[1]<fNInnerSector) {
572      xnew = fRInnerFirstWire+TMath::Nint((xyz[0]-fRInnerFirstWire)/fInnerWWPitch)*fInnerWWPitch;
573     }
574     else {
575      xnew = fROuterFirstWire+TMath::Nint((xyz[0]-fROuterFirstWire)/fOuterWWPitch)*fOuterWWPitch;
576     }
577   dx = xnew-xyz[0];
578   xyz[0]=xnew;
579   return  dx;
580 }
581
582 inline Int_t   AliTPCParam::Transform2to3(Float_t *xyz, Int_t *index)  const
583 {
584   //
585   //calulates coresponding pad row number, sets index[2] for straight rows
586   //does not change xyz[] information
587   //valid only for straight row
588   //
589   if  (index[1]<fNInnerSector)   
590     index[2] =TMath::Nint((xyz[0]-fPadRowLow[0])/fInnerPadPitchLength);
591   else
592     if (xyz[0] < fLastWireUp1 )
593       index[2] = TMath::Nint((xyz[0]-fPadRowUp[0])/fOuter1PadPitchLength);
594     else 
595       index[2] = TMath::Nint(fNRowUp1+(xyz[0]-fPadRowUp[64])/fOuter2PadPitchLength);
596   index[0]=3;
597   return index[2];
598 }
599
600 inline void   AliTPCParam::Transform3to4(Float_t *xyz, Int_t *index)  const
601 {
602   //
603   //valid only for straight rows straight rows
604   //calculate xyz[0] position relative to given index
605   //
606   if  (index[1]<fNInnerSector)   
607     xyz[0] -=index[2]*fInnerPadPitchLength+fPadRowLow[0];
608   else
609     if (index[2]<fNRowUp1)
610       xyz[0] -=index[2]*fOuter1PadPitchLength+fPadRowUp[0];
611     else 
612       xyz[0] -=(index[2]-fNRowUp1)*fOuter2PadPitchLength+fPadRowUp[64];
613   index[0]  =4;
614 }
615
616 inline void   AliTPCParam::Transform4to3(Float_t *xyz, Int_t *index) const
617 {
618   //
619   //valid only for straight rows 
620   //transforms  relative xyz[0] to the global one within given sector
621   //
622   if  (index[1]<fNInnerSector)   
623     xyz[0] +=index[2]*fInnerPadPitchLength+fPadRowLow[0];
624   else
625     if(index[2]<fNRowUp1)
626       xyz[0] +=index[2]*fOuter1PadPitchLength+fPadRowUp[0];
627     else 
628       xyz[0] +=index[2]*fOuter2PadPitchLength+fPadRowUp[64];
629   index[0]  =3;
630 }
631
632
633 inline void   AliTPCParam::Transform2to5( Float_t *xyz, Int_t *index) const
634 {
635   //
636   //transform [x,y,z] to [r,phi,z]
637   //
638   Float_t angle;
639   Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
640   if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0;
641   else
642     {
643       angle =TMath::ASin(xyz[1]/r);
644       if   (xyz[0]<0)   angle=TMath::Pi()-angle;
645       if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
646     }
647   xyz[0]=r;
648   xyz[1]=angle;
649   index[0]=5;
650 }
651
652 inline void   AliTPCParam::Transform5to2( Float_t *xyz, Int_t *index)  const
653 {
654   //
655   //transform [r,rphi,z] to [x,y,z] 
656   //
657   Float_t r = xyz[0];
658   Float_t angle= xyz[1];
659   xyz[0]=r*TMath::Cos(angle);
660   xyz[1]=r*TMath::Sin(angle);
661   index[0]=2;
662 }
663
664 inline void AliTPCParam::Transform4to8(Float_t *xyz, Int_t *index) const
665 {
666   //
667   //transform xyz coordinates to 'digit' coordinates
668   //
669
670   if (index[1]<fNInnerSector) {
671     if ( index[1]>=(fNInnerSector>>1)) xyz[1]*=-1.;
672   }
673   else {
674     if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) ) xyz[1]*=-1;      
675   }
676
677   xyz[2]/=fZWidth;  
678   if  (index[1]<fNInnerSector) {    
679     xyz[0]/=fInnerPadPitchLength;
680     xyz[1]/=fInnerPadPitchWidth;
681   }
682   else{  
683     xyz[1]/=fOuterPadPitchWidth;  
684     if (index[2]<fNRowUp1 ) xyz[0]/=fOuter1PadPitchLength;      
685     else xyz[0]/=fOuter2PadPitchLength;     
686   }
687   xyz[1]-=0.5;
688   index[0]=8;
689 }
690
691 inline void AliTPCParam::Transform8to4(Float_t *xyz, Int_t *index) const
692 {
693   //
694   //transforms 'digit' coordinates to xyz coordinates
695   //
696   if (index[1]<fNInnerSector) {
697     if ( index[1]>=(fNInnerSector>>1)) xyz[1]*=-1.;
698   }
699   else {
700     if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) ) xyz[1]*=-1;      
701   }
702
703   xyz[2]*=fZWidth;
704   if  (index[1]<fNInnerSector) {    
705     xyz[0]*=fInnerPadPitchLength;
706     xyz[1]*=fInnerPadPitchWidth;    
707   }
708   else{  
709     xyz[1]*=fOuterPadPitchWidth;  
710     if (index[2] < fNRowUp1 ) xyz[0]*=fOuter1PadPitchLength;
711     else xyz[0]*=fOuter2PadPitchLength;           
712   } 
713   index[0]=4;
714 }
715
716 inline void  AliTPCParam::Transform6to8(Float_t *xyz, Int_t *index) const
717 {
718   //
719   //transforms cylindrical xyz coordinates to 'digit' coordinates
720   //
721   xyz[2]/=fZWidth;
722   if  (index[1]<fNInnerSector) {    
723     xyz[0]/=fInnerPadPitchLength;
724     xyz[1]*=xyz[0]/fInnerPadPitchWidth;
725   }
726   else{ 
727     xyz[1]*=xyz[0]/fOuterPadPitchWidth;
728     if (index[2] < fNRowUp1 ) xyz[0]/=fOuter1PadPitchLength;
729     else xyz[0]/=fOuter2PadPitchLength;       
730   }
731   index[0]=8;
732 }
733
734 inline void  AliTPCParam::Transform8to6(Float_t *xyz, Int_t *index) const
735 {
736   //
737   //transforms 'digit' coordinates to cylindrical xyz coordinates 
738   //
739   xyz[2]*=fZWidth;
740   if  (index[1]<fNInnerSector) {    
741     xyz[0]*=fInnerPadPitchLength;
742     xyz[1]/=xyz[0]/fInnerPadPitchWidth;
743   }
744   else{ 
745     xyz[1]/=xyz[0]/fOuterPadPitchWidth;  
746     if (index[2] < fNRowUp1 ) xyz[0]*=fOuter1PadPitchLength;
747     else xyz[0]*=fOuter2PadPitchLength;                
748   }  
749   index[0]=6;
750 }
751 inline Float_t AliTPCParam::GetZLength(Int_t sector) const
752 { if(sector <18 || (sector>35&&sector<54)) return   fZLength-0.275;
753   else return fZLength-0.302;
754 }
755 #endif