]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/Base/AliTPCParam.h
o adjust limits for Dz calculation close to the CE to not cross the CE
[u/mrichter/AliRoot.git] / TPC / Base / 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   //
198   // High voltage parameters
199   //
200   void  SetNominalVoltage(Float_t v, UInt_t i)  {if (i<72) fNominalVoltage[i]=v;}
201   void  SetMaxVoltageDeviation(Float_t voltage) { fMaxVoltageDeviation=voltage; }
202   void  SetMaxDipVoltage(Float_t voltage)       { fMaxDipVoltage=voltage;       }
203   void  SetMaxFractionHVbad(Float_t frac )      { fMaxHVfractionBad=frac;       }
204   void  SetVoltageDipScanPeriod(Float_t period) { fVoltageDipScanPeriod=period; }
205   //
206   //set response  parameters  
207   //
208   void  SetNResponseMax(Int_t max) { fNResponseMax = max;} 
209   void  SetResponseThreshold(Int_t threshold) {fResponseThreshold = threshold;}
210   //set L1 parameters
211   void  SetGateDelay(Float_t delay) {fGateDelay = delay;}
212   void  SetL1Delay(Float_t delay) {fL1Delay = delay;}
213   void  SetNTBinsBeforeL1(UShort_t nbins) {fNTBinsBeforeL1 = nbins;}
214   //
215   //get sector parameters
216   //
217   Float_t  GetInnerRadiusLow() const {return fInnerRadiusLow;}
218   Float_t  GetInnerRadiusUp() const {return fInnerRadiusUp;} 
219   Float_t  GetOuterRadiusLow() const {return fOuterRadiusLow;} 
220   Float_t  GetOuterRadiusUp() const {return fOuterRadiusUp;} 
221   Float_t  GetInnerFrameSpace() const {return fInnerFrameSpace;}
222   Float_t  GetOuterFrameSpace() const {return fOuterFrameSpace;}
223   Float_t  GetInnerWireMount() const {return fInnerWireMount;}
224   Float_t  GetOuterWireMount() const {return fOuterWireMount;}
225   Float_t  GetInnerAngle() const ;
226   Float_t  GetInnerAngleShift() const ;
227   Float_t  GetOuterAngle() const ;
228   Float_t  GetOuterAngleShift() const ; 
229   Int_t    GetNInnerSector() const {return fNInnerSector;}
230   Int_t    GetNOuterSector() const {return fNOuterSector;}
231   Int_t    GetNSector() const {return fNSector;}
232   Float_t  GetZLength(Int_t sector=0) const;
233   Int_t    GetGeometryType() const {return fGeometryType;}
234
235   //
236   //get wires parameter
237   //
238   Int_t    GetInnerNWires() const {return fNInnerWiresPerPad;}
239   Float_t  GetInnerWWPitch() const {return fInnerWWPitch;}  
240   Int_t    GetInnerDummyWire() const {return fInnerDummyWire;}
241   Float_t  GetInnerOffWire() const {return fInnerOffWire;}
242   Float_t  GetRInnerFirstWire() const {return fRInnerFirstWire;}
243   Float_t  GetRInnerLastWire() const {return fRInnerLastWire;}
244   Int_t    GetOuter1NWires() const {return fNOuter1WiresPerPad;}
245   Int_t    GetOuter2NWires() const {return fNOuter2WiresPerPad;}
246   Float_t  GetOuterWWPitch() const {return fOuterWWPitch;}  
247   Int_t    GetOuterDummyWire() const {return fOuterDummyWire;}
248   Float_t  GetOuterOffWire() const {return fOuterOffWire;}
249   Float_t  GetLastWireUp1()  const {return fLastWireUp1;}
250   Float_t  GetROuterFirstWire() const {return fROuterFirstWire;}
251   Float_t  GetROuterLastWire() const {return fROuterLastWire;}  
252   Float_t  GetWWPitch(Int_t isector = 0) const  {
253     return ( (isector < fNInnerSector) ? fInnerWWPitch :fOuterWWPitch);} 
254   //
255   //get pad  parameters
256   //
257   Float_t  GetInnerPadPitchLength() const {return fInnerPadPitchLength;}
258   Float_t  GetInnerPadPitchWidth() const {return fInnerPadPitchWidth;}
259   Float_t  GetInnerPadLength() const {return fInnerPadLength;}
260   Float_t  GetInnerPadWidth() const  {return fInnerPadWidth;}
261   Float_t  GetOuter1PadPitchLength() const {return fOuter1PadPitchLength;}
262   Float_t  GetOuter2PadPitchLength() const {return fOuter2PadPitchLength;}  
263   Float_t  GetOuterPadPitchWidth() const {return fOuterPadPitchWidth;}
264   Float_t  GetOuter1PadLength() const {return fOuter1PadLength;}
265   Float_t  GetOuter2PadLength() const {return fOuter2PadLength;}
266   Float_t  GetOuterPadWidth()  const {return fOuterPadWidth;}  
267   Bool_t   GetMWPCReadout() const {return fBMWPCReadout;}
268   Int_t    GetNCrossRows() const {return fNCrossRows;}
269   Float_t  GetPadPitchWidth(Int_t isector = 0) const  {
270     return ( (isector < fNInnerSector) ? fInnerPadPitchWidth :fOuterPadPitchWidth);}
271   Float_t  GetPadPitchLength(Int_t isector = 0, Int_t padrow=0)  const
272   { if (isector < fNInnerSector) return fInnerPadPitchLength; 
273     else return ((padrow<fNRowUp1) ? fOuter1PadPitchLength:fOuter2PadPitchLength);}
274   Int_t GetNRowLow() const;   //get the number of pad rows in low sector
275   Int_t GetNRowUp() const;    //get the number of pad rows in up sector
276   Int_t GetNRowUp1() const;  // number of short rows in up sector  
277   Int_t GetNRowUp2() const;  // number of long rows in up sector
278   Int_t GetNRow(Int_t isec) const {return  ((isec<fNInnerSector) ?  fNRowLow:fNRowUp);}
279   Int_t GetNRowsTotal() const {return fNtRows;}  //get total nuber of rows
280   Float_t GetPadRowRadiiLow(Int_t irow) const; //get the pad row (irow) radii
281   Float_t GetPadRowRadiiUp(Int_t irow) const;  //get the pad row (irow) radii
282   Float_t GetPadRowRadii(Int_t isec,Int_t irow) const {
283     return ( (isec < fNInnerSector) ?GetPadRowRadiiLow(irow):GetPadRowRadiiUp(irow));}
284     //retrun radii of the pad row irow in sector i
285   Int_t GetNPadsLow(Int_t irow) const;    //get the number of pads in row irow 
286   Int_t GetNPadsUp(Int_t irow) const;     //get the number of pads in row irow
287   Int_t GetNPads(Int_t isector,Int_t irow) const{
288      return ( (isector < fNInnerSector) ?GetNPadsLow(irow) : GetNPadsUp(irow));} 
289
290   Float_t GetYInner(Int_t irow) const; // wire length in low sec row
291   Float_t GetYOuter(Int_t irow) const; // wire length in up sec row  
292   Int_t GetSectorIndex(Float_t angle, Int_t row, Float_t z) const; // get sector index
293   Float_t GetChamberCenter(Int_t isec, Float_t * center = 0) const; // get readout chamber positions
294   TGeoHMatrix *GetTrackingMatrix(Int_t isec) const {
295     return fTrackingMatrix[isec];}
296   TGeoHMatrix *GetClusterMatrix(Int_t isec) const {
297     return fClusterMatrix[isec];}
298   TGeoHMatrix *GetGlobalMatrix(Int_t isec) const {
299     return fGlobalMatrix[isec];}
300   Bool_t   IsGeoRead(){ return fGlobalMatrix!=0;}
301   //
302   //get GAS parameters 
303   //
304   Float_t  GetDiffT() const {return fDiffT;}
305   Float_t  GetDiffL() const {return fDiffL;}
306   Float_t  GetGasGain() const {return fGasGain;}
307   Float_t  GetDriftV() const {return fDriftV;}
308   Float_t  GetOmegaTau() const {return fOmegaTau;}
309   Float_t  GetAttCoef() const {return fAttCoef;}
310   Float_t  GetOxyCont() const {return fOxyCont;}
311   //
312   //get Electronic parameters
313   //
314   Float_t  GetPadCoupling() const {return fPadCoupling;}
315   Int_t    GetZeroSup() const {return fZeroSup;}
316   Float_t  GetNoise() const {return fNoise;}
317   Float_t  GetChipGain() const {return fChipGain;}
318   Float_t  GetChipNorm() const {return fChipNorm;}
319   Float_t  GetTSample() const {return fTSample;}
320   Float_t  GetZWidth() const {return fZWidth;}
321   Float_t  GetTFWHM() const {return fTSigma*2.35;}
322   Float_t  GetZSigma() const {return fTSigma*fDriftV;}  
323   virtual  Float_t  GetZOffset() const {return 3*fTSigma*fDriftV;}
324   Int_t    GetMaxTBin() const {return fMaxTBin;}
325   Int_t    GetADCSat() const {return fADCSat;}
326   Float_t  GetADCDynRange() const {return fADCDynRange;}
327   Float_t  GetTotalNormFac() const {return fTotalNormFac;}
328   Float_t  GetNoiseNormFac() const {return fNoiseNormFac;}
329   //
330   // High voltage parameters
331   //
332   Float_t  GetNominalVoltage(UInt_t i) const {return (i<72)?fNominalVoltage[i]:0;} //0-35:IROC, 36-71:OROC
333   Float_t  GetMaxVoltageDeviation()    const { return fMaxVoltageDeviation;      }
334   Float_t  GetMaxDipVoltage()          const { return fMaxDipVoltage;            }
335   Float_t  GetMaxFractionHVbad()       const { return fMaxHVfractionBad;         }
336   Float_t  GetVoltageDipScanPeriod()   const { return fVoltageDipScanPeriod;     }
337   
338   //
339   // get response data
340   //  
341   Int_t * GetResBin(Int_t i);  
342   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
343   Float_t & GetResWeight(Int_t i);
344   //return  weight of response bin i
345
346   // get L1 data
347   Float_t  GetGateDelay() const {return fGateDelay;}
348   Float_t  GetL1Delay() const {return fL1Delay;}
349   UShort_t GetNTBinsBeforeL1() const {return fNTBinsBeforeL1;}
350   Float_t  GetNTBinsL1() const {return fNTBinsL1;}
351 protected :
352
353   Bool_t fbStatus;  //indicates consistency of the data
354   //---------------------------------------------------------------------
355   //   ALICE TPC sector geometry
356   //--------------------------------------------------------------------  
357   Float_t fInnerRadiusLow;    // lower radius of inner sector-IP
358   Float_t fInnerRadiusUp;     // upper radius of inner  sector-IP
359   Float_t fOuterRadiusUp;     // upper radius of outer  sector-IP
360   Float_t fOuterRadiusLow;    // lower radius of outer sector-IP
361   Float_t fInnerAngle;        //opening angle of Inner sector
362   Float_t fInnerAngleShift;   //shift of first inner sector center to the 0
363   Float_t fOuterAngle;        //opening angle of outer sector
364   Float_t fOuterAngleShift;   //shift of first sector center to the 0  
365   Float_t fInnerFrameSpace;   //space for inner frame in the phi direction 
366   Float_t fOuterFrameSpace;   //space for outer frame in the phi direction 
367   Float_t fInnerWireMount;    //space for wire mount, inner sector
368   Float_t fOuterWireMount;    //space for wire mount, outer sector
369   Int_t   fNInnerSector;      //number of inner sectors             -calculated
370   Int_t   fNOuterSector;      //number of outer sectors             -calculated
371   Int_t   fNSector;           // total number of sectors            -calculated
372   Float_t fZLength;           //length of the drift region of the TPC
373   Float_t *fRotAngle;         //[fNSector]  sin and cos of rotation angles for 
374                               //  diferent sectors -calculated
375   Int_t   fGeometryType;      //type of geometry -0 straight rows
376   //  Float_t *fChamberPos;       //[fNSector] displacements of the readout chambers 
377                               //with respect to the 'idead' geometry
378                               //in local corrdinate system
379   //  Float_t *fChamberRot;       //[fNSector] rotation angles of the readout chambers 
380                               //with respect to the 'idead' geometry
381                               //in local corrdinate system
382   TGeoHMatrix **fTrackingMatrix;   //![fNSector] transformation matrices of the tracking
383                               //coordinate system
384   TGeoHMatrix **fClusterMatrix;    //![fNSector] transformation matrices of the cluster
385                               //coordinate system
386   TGeoHMatrix **fGlobalMatrix;    //![fNSector] fTrackingMatrix * fClusterMatrix
387
388   //1-cylindrical
389   //---------------------------------------------------------------------
390   //   ALICE TPC wires  geometry - for GEM we can consider that it is gating  
391   //--------------------------------------------------------------------
392   Int_t   fNInnerWiresPerPad; //Number of wires per pad
393   Float_t fInnerWWPitch;      //pitch between wires  in inner sector     - calculated
394   Int_t   fInnerDummyWire;    //number of wires without pad readout
395   Float_t fInnerOffWire;      //oofset of first wire to the begining of the sector
396   Float_t fRInnerFirstWire;   //position of the first wire                -calculated
397   Float_t fRInnerLastWire;    //position of the last wire                 -calculated
398   Float_t fLastWireUp1;     //position of the last wire in outer1 sector
399   Int_t   fNOuter1WiresPerPad; //Number of wires per pad
400   Int_t   fNOuter2WiresPerPad; // Number of wires per pad
401   Float_t fOuterWWPitch;      //pitch between wires in outer sector      -calculated
402   Int_t   fOuterDummyWire;    //number of wires without pad readout
403   Float_t fOuterOffWire;      //oofset of first wire to the begining of the sector
404   Float_t fROuterFirstWire;   //position of the first wire                -calulated
405   Float_t fROuterLastWire;    //position of the last wire                 -calculated 
406   //---------------------------------------------------------------------
407   //   ALICE TPC pad parameters
408   //--------------------------------------------------------------------
409   Float_t   fInnerPadPitchLength;    //Inner pad pitch length
410   Float_t   fInnerPadPitchWidth;     //Inner pad pitch width
411   Float_t   fInnerPadLength;         //Inner pad  length
412   Float_t   fInnerPadWidth;          //Inner pad  width
413   Float_t   fOuter1PadPitchLength;    //Outer pad pitch length
414   Float_t   fOuter2PadPitchLength;    //Outer pad pitch length
415   Float_t   fOuterPadPitchWidth;     //Outer pad pitch width
416   Float_t   fOuter1PadLength;         //Outer pad  length
417   Float_t   fOuter2PadLength;         //Outer pad length
418   Float_t   fOuterPadWidth;          //Outer pad  width
419   Bool_t    fBMWPCReadout;           //indicate wire readout - kTRUE or GEM readout -kFALSE
420   Int_t     fNCrossRows;             //number of rows to crostalk calculation
421       
422   Int_t fNRowLow;           //number of pad rows per low sector        -set
423   Int_t fNRowUp1;            //number of short pad rows per sector up  -set
424   Int_t fNRowUp2;            //number of long pad rows per sector up   -set
425   Int_t fNRowUp;            //number of pad rows per sector up     -calculated
426   Int_t fNtRows;            //total number of rows in TPC          -calculated
427   Float_t  fPadRowLow[600]; //Lower sector, pad row radii          -calculated
428   Float_t  fPadRowUp[600];  //Upper sector, pad row radii          -calculated 
429   Int_t    fNPadsLow[600];  //Lower sector, number of pads per row -calculated
430   Int_t    fNPadsUp[600];   //Upper sector, number of pads per row -calculated
431   Float_t  fYInner[600];     //Inner sector, wire-length
432   Float_t  fYOuter[600];     //Outer sector, wire-length   
433   //---------------------------------------------------------------------
434   //   ALICE TPC Gas Parameters
435   //--------------------------------------------------------------------
436   Float_t  fDiffT;          //tangencial diffusion constant
437   Float_t  fDiffL;          //longutudinal diffusion constant
438   Float_t  fGasGain;        //gas gain constant
439   Float_t  fDriftV;         //drift velocity constant
440   Float_t  fOmegaTau;       //omega tau ExB coeficient
441   Float_t  fAttCoef;        //attachment coefitients
442   Float_t  fOxyCont;        //oxygen content
443   //---------------------------------------------------------------------
444   //   ALICE TPC  Electronics Parameters
445   //--------------------------------------------------------------------
446   Float_t fPadCoupling;     //coupling factor ration of  anode signal 
447                             //and total pads signal  
448   Int_t fZeroSup;           //zero suppresion constant
449   Float_t fNoise;           //noise sigma constant
450   Float_t fChipGain;        //preamp shaper constant
451   Float_t fChipNorm;         //preamp shaper normalisation 
452   Float_t fTSample;         //sampling time
453   Float_t fZWidth;          //derived value calculated using TSample and driftw  -computed
454   Float_t fTSigma;          //width of the Preamp/Shaper function
455   Int_t   fMaxTBin;         //maximum time bin number
456   Int_t   fADCSat;          //saturation value of ADC (10 bits)
457   Float_t fADCDynRange;     //input dynamic range (mV)
458   Float_t fTotalNormFac;    //full normalisation factor - calculated
459   Float_t fNoiseNormFac;    //normalisation factor to transform noise in electron to ADC channel
460   //---------------------------------------------------------------------
461   // High voltage parameters
462   //---------------------------------------------------------------------
463   Float_t fNominalVoltage[72];  //nominal voltage in [V] per chamber
464   Float_t fMaxVoltageDeviation; // maximum voltage deviation from nominal voltage before a chamber is masked
465   Float_t fMaxDipVoltage;       // maximum voltage deviation from median before a dip event is marked
466   Float_t fMaxHVfractionBad;    // maximum fraction of bad HV entries (deviation from Median) before a chamber is marked bad
467   Float_t fVoltageDipScanPeriod; // scanning period to detect a high volrage dip: event time stamp +- fVoltageDipScanPeriod [sec]
468   
469   //---------------------------------------------------------------------
470   // ALICE TPC response data 
471   //---------------------------------------------------------------------
472   Int_t   fNResponseMax;   //maximal dimension of response        
473   Float_t fResponseThreshold; //threshold for accepted response   
474   Int_t   fCurrentMax;     //!current maximal dimension            -calulated 
475   Int_t   *fResponseBin;    //!array with bins                     -calulated
476   Float_t *fResponseWeight; //!array with response                 -calulated
477
478   //---------------------------------------------------------------------
479   //   ALICE TPC L1 Parameters
480   //--------------------------------------------------------------------
481   Float_t fGateDelay;       //Delay of L1 arrival for the TPC gate signal
482   Float_t fL1Delay;         //Delay of L1 arrival for the TPC readout 
483   UShort_t fNTBinsBeforeL1; //Number of time bins before L1 arrival which are being read out 
484   Float_t fNTBinsL1;        //Overall L1 delay in time bins
485
486 private:
487   AliTPCParam(const AliTPCParam &);
488   AliTPCParam & operator=(const AliTPCParam &);
489
490   void CleanGeoMatrices();
491
492   ClassDef(AliTPCParam,5)  //parameter  object for set:TPC
493 };
494
495  
496 inline Int_t * AliTPCParam::GetResBin(Int_t i)
497 {
498   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
499   if (i<fCurrentMax) return &fResponseBin[i*3];
500   else return 0;
501 }
502   
503 inline Float_t &AliTPCParam::GetResWeight(Int_t i)
504 {
505   //return  weight of response bin i
506   if (i<fCurrentMax) return fResponseWeight[i];
507   else return fResponseWeight[i];
508 }
509
510
511 inline void  AliTPCParam::AdjustCosSin(Int_t isec, Float_t &cos, Float_t &sin) const
512 {
513   //
514   //set cosinus and sinus of rotation angles for sector isec
515   //
516   cos=fRotAngle[isec*4];
517   sin=fRotAngle[isec*4+1];
518 }
519
520 inline Float_t   AliTPCParam::GetAngle(Int_t isec) const
521 {
522   //
523   //return rotation angle of given sector
524   //
525   return fRotAngle[isec*4+2];
526 }
527
528
529 inline void AliTPCParam::Transform1to2Ideal(Float_t *xyz, Int_t *index) const
530 {
531   //transformation to rotated coordinates
532   //we must have information about sector!
533   //rotate to given sector
534   // ideal frame
535
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 inline void AliTPCParam::Transform1to2(Float_t *xyz, Int_t *index) const
548 {
549   //transformation to rotated coordinates 
550   //we must have information about sector!
551   //rotate to given sector
552   Double_t xyzmaster[3] = {xyz[0],xyz[1],xyz[2]};
553   Double_t xyzlocal[3]={0,0,0};
554   if (index[1]>=0 && index[1]<fNSector) 
555     fGlobalMatrix[index[1]]->MasterToLocal(xyzmaster,xyzlocal);
556   xyz[0] = xyzlocal[0];
557   xyz[1] = xyzlocal[1];
558   xyz[2] = xyzlocal[2];
559   index[0]=2;
560 }
561
562
563
564
565 inline void AliTPCParam::Transform2to1(Float_t *xyz, Int_t *index) const
566 {
567   //
568   //transformation from  rotated coordinates to global coordinates
569   //
570   Float_t cos,sin;
571   AdjustCosSin(index[1],cos,sin);   
572   Float_t x1=xyz[0]*cos - xyz[1]*sin;
573   Float_t y1=xyz[0]*sin + xyz[1]*cos; 
574   xyz[0]=x1;
575   xyz[1]=y1;
576   xyz[2]=fZLength-xyz[2]; 
577   if (index[1]<fNInnerSector)
578     {if ( index[1]>=(fNInnerSector>>1)) xyz[2]*=-1.;}
579   else 
580     {if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) )    xyz[2]*=-1;}
581   index[0]=1;
582 }
583
584 inline void AliTPCParam::Transform2to2(Float_t *xyz, Int_t *index, Int_t *oindex) const
585 {
586   //transform rotated coordinats of one sector to rotated
587   //coordinates relative to another sector
588   Transform2to1(xyz,index);
589   Transform1to2(xyz,oindex);
590   index[0]=2;
591   index[1]=oindex[1];  
592 }
593
594 inline Float_t  AliTPCParam::Transform2to2NearestWire(Float_t *xyz, Int_t *index)  const
595 {
596   //
597   // asigns the x-position of the closest wire to xyz[0], return the
598   // electron to closest wire distance
599   //
600   Float_t xnew,dx;
601   if (index[1]<fNInnerSector) {
602      xnew = fRInnerFirstWire+TMath::Nint((xyz[0]-fRInnerFirstWire)/fInnerWWPitch)*fInnerWWPitch;
603     }
604     else {
605      xnew = fROuterFirstWire+TMath::Nint((xyz[0]-fROuterFirstWire)/fOuterWWPitch)*fOuterWWPitch;
606     }
607   dx = xnew-xyz[0];
608   xyz[0]=xnew;
609   return  dx;
610 }
611
612 inline Int_t   AliTPCParam::Transform2to3(Float_t *xyz, Int_t *index)  const
613 {
614   //
615   //calulates coresponding pad row number, sets index[2] for straight rows
616   //does not change xyz[] information
617   //valid only for straight row
618   //
619   if  (index[1]<fNInnerSector)   
620     index[2] =TMath::Nint((xyz[0]-fPadRowLow[0])/fInnerPadPitchLength);
621   else
622     if (xyz[0] < fLastWireUp1 )
623       index[2] = TMath::Nint((xyz[0]-fPadRowUp[0])/fOuter1PadPitchLength);
624     else 
625       index[2] = TMath::Nint(fNRowUp1+(xyz[0]-fPadRowUp[64])/fOuter2PadPitchLength);
626   index[0]=3;
627   return index[2];
628 }
629
630 inline void   AliTPCParam::Transform3to4(Float_t *xyz, Int_t *index)  const
631 {
632   //
633   //valid only for straight rows straight rows
634   //calculate xyz[0] position relative to given index
635   //
636   if  (index[1]<fNInnerSector)   
637     xyz[0] -=index[2]*fInnerPadPitchLength+fPadRowLow[0];
638   else
639     if (index[2]<fNRowUp1)
640       xyz[0] -=index[2]*fOuter1PadPitchLength+fPadRowUp[0];
641     else 
642       xyz[0] -=(index[2]-fNRowUp1)*fOuter2PadPitchLength+fPadRowUp[64];
643   index[0]  =4;
644 }
645
646 inline void   AliTPCParam::Transform4to3(Float_t *xyz, Int_t *index) const
647 {
648   //
649   //valid only for straight rows 
650   //transforms  relative xyz[0] to the global one within given sector
651   //
652   if  (index[1]<fNInnerSector)   
653     xyz[0] +=index[2]*fInnerPadPitchLength+fPadRowLow[0];
654   else
655     if(index[2]<fNRowUp1)
656       xyz[0] +=index[2]*fOuter1PadPitchLength+fPadRowUp[0];
657     else 
658       xyz[0] +=index[2]*fOuter2PadPitchLength+fPadRowUp[64];
659   index[0]  =3;
660 }
661
662
663 inline void   AliTPCParam::Transform2to5( Float_t *xyz, Int_t *index) const
664 {
665   //
666   //transform [x,y,z] to [r,phi,z]
667   //
668   Float_t angle;
669   Float_t r = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
670   if ((xyz[0]==0)&&(xyz[1]==0)) angle = 0;
671   else
672     {
673       angle =TMath::ASin(xyz[1]/r);
674       if   (xyz[0]<0)   angle=TMath::Pi()-angle;
675       if ( (xyz[0]>0) && (xyz[1]<0) ) angle=2*TMath::Pi()+angle;
676     }
677   xyz[0]=r;
678   xyz[1]=angle;
679   index[0]=5;
680 }
681
682 inline void   AliTPCParam::Transform5to2( Float_t *xyz, Int_t *index)  const
683 {
684   //
685   //transform [r,rphi,z] to [x,y,z] 
686   //
687   Float_t r = xyz[0];
688   Float_t angle= xyz[1];
689   xyz[0]=r*TMath::Cos(angle);
690   xyz[1]=r*TMath::Sin(angle);
691   index[0]=2;
692 }
693
694 inline void AliTPCParam::Transform4to8(Float_t *xyz, Int_t *index) const
695 {
696   //
697   //transform xyz coordinates to 'digit' coordinates
698   //
699
700   if (index[1]<fNInnerSector) {
701     if ( index[1]>=(fNInnerSector>>1)) xyz[1]*=-1.;
702   }
703   else {
704     if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) ) xyz[1]*=-1;      
705   }
706
707   xyz[2]/=fZWidth;  
708   if  (index[1]<fNInnerSector) {    
709     xyz[0]/=fInnerPadPitchLength;
710     xyz[1]/=fInnerPadPitchWidth;
711   }
712   else{  
713     xyz[1]/=fOuterPadPitchWidth;  
714     if (index[2]<fNRowUp1 ) xyz[0]/=fOuter1PadPitchLength;      
715     else xyz[0]/=fOuter2PadPitchLength;     
716   }
717   xyz[1]-=0.5;
718   index[0]=8;
719 }
720
721 inline void AliTPCParam::Transform8to4(Float_t *xyz, Int_t *index) const
722 {
723   //
724   //transforms 'digit' coordinates to xyz coordinates
725   //
726   if (index[1]<fNInnerSector) {
727     if ( index[1]>=(fNInnerSector>>1)) xyz[1]*=-1.;
728   }
729   else {
730     if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) ) xyz[1]*=-1;      
731   }
732
733   xyz[2]*=fZWidth;
734   if  (index[1]<fNInnerSector) {    
735     xyz[0]*=fInnerPadPitchLength;
736     xyz[1]*=fInnerPadPitchWidth;    
737   }
738   else{  
739     xyz[1]*=fOuterPadPitchWidth;  
740     if (index[2] < fNRowUp1 ) xyz[0]*=fOuter1PadPitchLength;
741     else xyz[0]*=fOuter2PadPitchLength;           
742   } 
743   index[0]=4;
744 }
745
746 inline void  AliTPCParam::Transform6to8(Float_t *xyz, Int_t *index) const
747 {
748   //
749   //transforms cylindrical xyz coordinates to 'digit' coordinates
750   //
751   xyz[2]/=fZWidth;
752   if  (index[1]<fNInnerSector) {    
753     xyz[0]/=fInnerPadPitchLength;
754     xyz[1]*=xyz[0]/fInnerPadPitchWidth;
755   }
756   else{ 
757     xyz[1]*=xyz[0]/fOuterPadPitchWidth;
758     if (index[2] < fNRowUp1 ) xyz[0]/=fOuter1PadPitchLength;
759     else xyz[0]/=fOuter2PadPitchLength;       
760   }
761   index[0]=8;
762 }
763
764 inline void  AliTPCParam::Transform8to6(Float_t *xyz, Int_t *index) const
765 {
766   //
767   //transforms 'digit' coordinates to cylindrical xyz coordinates 
768   //
769   xyz[2]*=fZWidth;
770   if  (index[1]<fNInnerSector) {    
771     xyz[0]*=fInnerPadPitchLength;
772     xyz[1]/=xyz[0]/fInnerPadPitchWidth;
773   }
774   else{ 
775     xyz[1]/=xyz[0]/fOuterPadPitchWidth;  
776     if (index[2] < fNRowUp1 ) xyz[0]*=fOuter1PadPitchLength;
777     else xyz[0]*=fOuter2PadPitchLength;                
778   }  
779   index[0]=6;
780 }
781 inline Float_t AliTPCParam::GetZLength(Int_t sector) const
782 { if(sector <18 || (sector>35&&sector<54)) return   fZLength-0.275;
783   else return fZLength-0.302;
784 }
785 #endif