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