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