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