]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCParam.h
Fixed problem with z length mismatch (Marian, Marek)
[u/mrichter/AliRoot.git] / TPC / AliTPCParam.h
index 40efe2f480a82ed4d8d58bdb143c8082015de07d..ac07af7584c9279f81d6d4a317e2f7a1648faed7 100644 (file)
@@ -12,7 +12,7 @@
 #include "AliDetectorParam.h"
 #include "TMath.h"
 
-
+#include <TGeoMatrix.h>
 
 class AliTPCParam : public AliDetectorParam {
   //////////////////////////////////////////////////////
@@ -24,14 +24,16 @@ class AliTPCParam : public AliDetectorParam {
 public:
   AliTPCParam(); 
   virtual ~AliTPCParam();
-  
+  TGeoHMatrix *  Tracking2LocalMatrix(const TGeoHMatrix * geoMatrix, Int_t sector) const;  
   virtual Bool_t  Transform(Float_t *xyz, Int_t *index, Int_t* oindex);
   //transformation from input coodination system to output coordination system  
   Int_t  Transform0to1(Float_t *xyz, Int_t *index) const;
   //trasforamtion from global to global - adjust index[0] sector 
   //return value is equal to sector corresponding to global position
+  void Transform1to2Ideal(Float_t *xyz, Int_t *index) const;
+  //transformation to rotated coordinata - ideal frame 
   void Transform1to2(Float_t *xyz, Int_t *index) const;
-  //transformation to rotated coordinata 
+  //transformation to rotated coordinata   
   void Transform2to1(Float_t *xyz, Int_t *index) const;
   //transformation from rotated coordinata to global coordinata
   void Transform2to2(Float_t *xyz, Int_t *index, Int_t *oindex) const;
@@ -63,42 +65,43 @@ public:
   void  Transform8to6(Float_t *xyz, Int_t *index) const;
   //transform 'digit' coordinata to dr,f coordinata 
 
-  virtual Int_t  Transform2toPadRow(Float_t *xyz, Int_t *index) const{return 0;}
+  virtual Int_t  Transform2toPadRow(Float_t */*xyz*/, Int_t */*index*/) const{return 0;}
   //transform rotated to
 
   virtual  Int_t GetPadRow(Float_t *xyz, Int_t *index) const ;
   //return pad row of point xyz - xyz is given in coordinate system -(given by index)
   //output system is 3 for straight row and 7 for cylindrical row
-  virtual void XYZtoCRXYZ(Float_t *xyz
-                     Int_t &sector, Int_t &padrow, Int_t option=3) const {;}
+  virtual void XYZtoCRXYZ(Float_t */*xyz*/
+                         Int_t &/*sector*/, Int_t &/*padrow*/, Int_t /*option*/) const {;}
   //transform global position to the position relative to the sector padrow
   //if option=0  X calculate absolute            calculate sector
   //if option=1  X           absolute            use input sector
   //if option=2  X           relative to pad row calculate sector
   //if option=3  X           relative            use input sector
 
-  virtual void CRXYZtoXYZ(Float_t *xyz,
-                         const Int_t &sector, const Int_t & padrow, Int_t option=3) const {;}  
+  virtual void CRXYZtoXYZ(Float_t */*xyz*/,
+                         const Int_t &/*sector*/, const Int_t & /*padrow*/, Int_t /*option*/) const {;}  
   //transform relative position  to the gloabal position
 
-  virtual void CRTimePadtoYZ(Float_t &y, Float_t &z
-                            const Float_t &time, const Float_t &pad,
-                            Int_t sector, Int_t padrow ){;}
+  virtual void CRTimePadtoYZ(Float_t &/*y*/, Float_t &/*z*/
+                            const Float_t &/*time*/, const Float_t &/*pad*/,
+                            Int_t /*sector*/, Int_t /*padrow*/ ){;}
   //transform position in digit  units (time slices and pads)  to "normal" 
   //units (cm)   
-  virtual void CRYZtoTimePad(const Float_t &y, const Float_t &z
-                            Float_t &time, Float_t &pad,
-                            Int_t sector, Int_t padrow){;}
+  virtual void CRYZtoTimePad(const Float_t &/*y*/, const Float_t &/*z*/
+                            Float_t &/*time*/, Float_t &/*pad*/,
+                            Int_t /*sector*/, Int_t /*padrow*/){;}
   //transform position in cm to position in digit unit 
-  virtual Int_t   CalcResponse(Float_t* x, Int_t * index, Int_t row){return 0;}
+  virtual Int_t   CalcResponse(Float_t* /*x*/, Int_t * /*index*/, Int_t /*row*/){return 0;}
   //calculate bin response as function of the input position -x and the weight 
   //if row -pad row is equal -1 calculate response for each pad row 
   //otherwise it calculate only in given pad row
   //return number of valid response bin
   virtual void SetDefault();          //set defaut TPCparam 
   virtual Bool_t Update();            //recalculate and check geometric parameters 
-  Bool_t GetStatus();         //get information about object consistency  
-  Int_t GetIndex(Int_t sector, Int_t row);  //give index of the given sector and pad row 
+  virtual Bool_t ReadGeoMatrices();   //read geo matrixes        
+  Bool_t GetStatus() const;         //get information about object consistency  
+  Int_t GetIndex(Int_t sector, Int_t row) const;  //give index of the given sector and pad row 
   Int_t GetNSegmentsTotal() const {return fNtRows;} 
   Double_t GetLowMaxY(Int_t irow) const {return irow*0.;}
   Double_t GetUpMaxY(Int_t irow) const {return irow*0;}
@@ -110,6 +113,8 @@ public:
   void  AdjustCosSin(Int_t isec, Float_t &cos, Float_t &sin) const;
   //set cosinus and sinus of rotation angles for sector isec 
   Float_t GetAngle(Int_t isec) const;
+  //  void GetChamberPos(Int_t isec, Float_t* xyz) const;
+  //  void GetChamberRot(Int_t isec, Float_t* angles) const;
   //
   //set sector parameters
   //
@@ -126,25 +131,42 @@ public:
   void  SetZLength(Float_t zlength) {fZLength = zlength;} 
   void  SetGeometryType(Int_t type) {fGeometryType = type;}
   //
+  // pad rows geometry
+  //
+  void SetRowNLow( Int_t NRowLow){fNRowLow = NRowLow;}
+  void SetRowNUp1 (Int_t NRowUp1){fNRowUp1 = NRowUp1 ;} //upper sec short pads 
+  void SetRowNUp2 (Int_t NRowUp2){fNRowUp2 = NRowUp2 ;} //upper sec long pads
+  void SetRowNUp (Int_t NRowUp){fNRowUp = NRowUp ;}  
+  //
   //set wire parameters
   //
   void  SetInnerNWires(Int_t nWires){  fNInnerWiresPerPad=nWires;}
   void  SetInnerDummyWire(Int_t dummy) {fInnerDummyWire  = dummy;}
   void  SetInnerOffWire(Float_t offset) {fInnerOffWire =offset;}    
-  void  SetOuterNWires(Int_t nWires){  fNOuterWiresPerPad=nWires;}
+  void  SetOuter1NWires(Int_t nWires){  fNOuter1WiresPerPad=nWires;}
+  void  SetOuter2NWire(Int_t nWires){  fNOuter2WiresPerPad=nWires;}
   void  SetOuterDummyWire(Int_t dummy) {fOuterDummyWire  = dummy;}
-  void  SetOuterOffWire(Float_t offset) {fOuterOffWire =offset;}    
+  void  SetOuterOffWire(Float_t offset) {fOuterOffWire =offset;} 
+  void  SetInnerWWPitch( Float_t wwPitch) {fInnerWWPitch = wwPitch;}
+  void  SetRInnerFirstWire(Float_t firstWire){fRInnerFirstWire = firstWire;}
+  void  SetRInnerLastWire(Float_t lastWire){fRInnerLastWire = lastWire;}
+  void  SetOuterWWPitch(Float_t wwPitch){fOuterWWPitch = wwPitch;}
+  void  SetLastWireUp1(Float_t wireUp1){fLastWireUp1 = wireUp1;} 
+  void  SetROuterFirstWire(Float_t firstWire){fROuterFirstWire = firstWire;}
+  void  SetROuterLastWire(Float_t lastWire){fROuterLastWire = lastWire;}   
   //
   //set pad parameter
   //
   void  SetInnerPadPitchLength(Float_t PadPitchLength){  fInnerPadPitchLength=PadPitchLength;}
   void  SetInnerPadPitchWidth(Float_t PadPitchWidth){  fInnerPadPitchWidth = PadPitchWidth;}
   void  SetInnerPadLength(Float_t PadLength){  fInnerPadLength=PadLength;}
-  void  SetInnerPadWidth(Float_t PadWidth) {  fInnerPadWidth=PadWidth;}  
-  void  SetOuterPadPitchLength(Float_t PadPitchLength){  fOuterPadPitchLength=PadPitchLength;}
+  void  SetInnerPadWidth(Float_t PadWidth) {  fInnerPadWidth=PadWidth;} 
+  void  SetOuter1PadPitchLength(Float_t PadPitchLength){  fOuter1PadPitchLength=PadPitchLength;}
+  void  SetOuter2PadPitchLength(Float_t PadPitchLength){  fOuter2PadPitchLength=PadPitchLength;}
   void  SetOuterPadPitchWidth(Float_t PadPitchWidth){  fOuterPadPitchWidth = PadPitchWidth;}
-  void  SetOuterPadLength(Float_t PadLength){  fOuterPadLength=PadLength;}
-  void  SetOuterPadWidth(Float_t PadWidth) {  fOuterPadWidth=PadWidth;} 
+  void  SetOuter1PadLength(Float_t PadLength){  fOuter1PadLength=PadLength;}
+  void  SetOuter2PadLength(Float_t PadLength){  fOuter2PadLength=PadLength;}
+  void  SetOuterPadWidth(Float_t PadWidth) {  fOuterPadWidth=PadWidth;}
   void  SetMWPCReadout(Bool_t type) {fBMWPCReadout = type;}
   void  SetNCrossRows(Int_t rows){fNCrossRows = rows;}
   //
@@ -175,6 +197,10 @@ public:
   //
   void  SetNResponseMax(Int_t max) { fNResponseMax = max;} 
   void  SetResponseThreshold(Int_t threshold) {fResponseThreshold = threshold;}
+  //set L1 parameters
+  void  SetGateDelay(Float_t delay) {fGateDelay = delay;}
+  void  SetL1Delay(Float_t delay) {fL1Delay = delay;}
+  void  SetNTBinsBeforeL1(UShort_t nbins) {fNTBinsBeforeL1 = nbins;}
   //
   //get sector parameters
   //
@@ -193,7 +219,7 @@ public:
   Int_t    GetNInnerSector() const {return fNInnerSector;}
   Int_t    GetNOuterSector() const {return fNOuterSector;}
   Int_t    GetNSector() const {return fNSector;}
-  Float_t  GetZLength() const {return fZLength;}
+  Float_t  GetZLength(Int_t sector=0) const;
   Int_t    GetGeometryType() const {return fGeometryType;}
 
   //
@@ -205,10 +231,12 @@ public:
   Float_t  GetInnerOffWire() const {return fInnerOffWire;}
   Float_t  GetRInnerFirstWire() const {return fRInnerFirstWire;}
   Float_t  GetRInnerLastWire() const {return fRInnerLastWire;}
-  Int_t    GetOuterNWires() const {return fNOuterWiresPerPad;}
+  Int_t    GetOuter1NWires() const {return fNOuter1WiresPerPad;}
+  Int_t    GetOuter2NWires() const {return fNOuter2WiresPerPad;}
   Float_t  GetOuterWWPitch() const {return fOuterWWPitch;}  
   Int_t    GetOuterDummyWire() const {return fOuterDummyWire;}
   Float_t  GetOuterOffWire() const {return fOuterOffWire;}
+  Float_t  GetLastWireUp1()  const {return fLastWireUp1;}
   Float_t  GetROuterFirstWire() const {return fROuterFirstWire;}
   Float_t  GetROuterLastWire() const {return fROuterLastWire;}  
   Float_t  GetWWPitch(Int_t isector = 0) const  {
@@ -219,22 +247,26 @@ public:
   Float_t  GetInnerPadPitchLength() const {return fInnerPadPitchLength;}
   Float_t  GetInnerPadPitchWidth() const {return fInnerPadPitchWidth;}
   Float_t  GetInnerPadLength() const {return fInnerPadLength;}
-  Float_t  GetInnerPadWidth() const  {return fInnerPadWidth;}  
-  Float_t  GetOuterPadPitchLength() const {return fOuterPadPitchLength;}
+  Float_t  GetInnerPadWidth() const  {return fInnerPadWidth;}
+  Float_t  GetOuter1PadPitchLength() const {return fOuter1PadPitchLength;}
+  Float_t  GetOuter2PadPitchLength() const {return fOuter2PadPitchLength;}  
   Float_t  GetOuterPadPitchWidth() const {return fOuterPadPitchWidth;}
-  Float_t  GetOuterPadLength() const {return fOuterPadLength;}
+  Float_t  GetOuter1PadLength() const {return fOuter1PadLength;}
+  Float_t  GetOuter2PadLength() const {return fOuter2PadLength;}
   Float_t  GetOuterPadWidth()  const {return fOuterPadWidth;}  
   Bool_t   GetMWPCReadout() const {return fBMWPCReadout;}
   Int_t    GetNCrossRows() const {return fNCrossRows;}
   Float_t  GetPadPitchWidth(Int_t isector = 0) const  {
     return ( (isector < fNInnerSector) ? fInnerPadPitchWidth :fOuterPadPitchWidth);}
-  Float_t  GetPadPitchLength(Int_t isector = 0)  const {
-    return ( (isector < fNInnerSector) ? fInnerPadPitchLength :fOuterPadPitchLength);} 
-
+  Float_t  GetPadPitchLength(Int_t isector = 0, Int_t padrow=0)  const
+  { if (isector < fNInnerSector) return fInnerPadPitchLength; 
+    else return ((padrow<fNRowUp1) ? fOuter1PadPitchLength:fOuter2PadPitchLength);}
   Int_t GetNRowLow() const;   //get the number of pad rows in low sector
   Int_t GetNRowUp() const;    //get the number of pad rows in up sector
+  Int_t GetNRowUp1() const;  // number of short rows in up sector  
+  Int_t GetNRowUp2() const;  // number of long rows in up sector
   Int_t GetNRow(Int_t isec) const {return  ((isec<fNInnerSector) ?  fNRowLow:fNRowUp);}
-  Int_t GetNRowsTotal(){return fNtRows;}  //get total nuber of rows
+  Int_t GetNRowsTotal() const {return fNtRows;}  //get total nuber of rows
   Float_t GetPadRowRadiiLow(Int_t irow) const; //get the pad row (irow) radii
   Float_t GetPadRowRadiiUp(Int_t irow) const;  //get the pad row (irow) radii
   Float_t GetPadRowRadii(Int_t isec,Int_t irow) const {
@@ -243,7 +275,19 @@ public:
   Int_t GetNPadsLow(Int_t irow) const;    //get the number of pads in row irow 
   Int_t GetNPadsUp(Int_t irow) const;     //get the number of pads in row irow
   Int_t GetNPads(Int_t isector,Int_t irow) const{
-     return ( (isector < fNInnerSector) ?GetNPadsLow(irow) : GetNPadsUp(irow));}    
+     return ( (isector < fNInnerSector) ?GetNPadsLow(irow) : GetNPadsUp(irow));} 
+
+  Float_t GetYInner(Int_t irow) const; // wire length in low sec row
+  Float_t GetYOuter(Int_t irow) const; // wire length in up sec row  
+  Int_t GetSectorIndex(Float_t angle, Int_t row, Float_t z) const; // get sector index
+  Float_t GetChamberCenter(Int_t isec, Float_t * center = 0) const; // get readout chamber positions
+  TGeoHMatrix *GetTrackingMatrix(Int_t isec) const {
+    return fTrackingMatrix[isec];}
+  TGeoHMatrix *GetClusterMatrix(Int_t isec) const {
+    return fClusterMatrix[isec];}
+  TGeoHMatrix *GetGlobalMatrix(Int_t isec) const {
+    return fGlobalMatrix[isec];}
+  Bool_t   IsGeoRead(){ return fGlobalMatrix!=0;}
   //
   //get GAS parameters 
   //
@@ -266,7 +310,7 @@ public:
   Float_t  GetZWidth() const {return fZWidth;}
   Float_t  GetTFWHM() const {return fTSigma*2.35;}
   Float_t  GetZSigma() const {return fTSigma*fDriftV;}  
-  virtual  Float_t  GetZOffset() {return 3*fTSigma*fDriftV;}
+  virtual  Float_t  GetZOffset() const {return 3*fTSigma*fDriftV;}
   Int_t    GetMaxTBin() const {return fMaxTBin;}
   Int_t    GetADCSat() const {return fADCSat;}
   Float_t  GetADCDynRange() const {return fADCDynRange;}
@@ -277,8 +321,14 @@ public:
   //  
   Int_t * GetResBin(Int_t i);  
   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
-  Float_t GetResWeight(Int_t i);
+  Float_t GetResWeight(Int_t i);
   //return  weight of response bin i
+
+  // get L1 data
+  Float_t  GetGateDelay() const {return fGateDelay;}
+  Float_t  GetL1Delay() const {return fL1Delay;}
+  UShort_t GetNTBinsBeforeL1() const {return fNTBinsBeforeL1;}
+  Float_t  GetNTBinsL1() const {return fNTBinsL1;}
 protected :
 
   Bool_t fbStatus;  //indicates consistency of the data
@@ -297,25 +347,39 @@ protected :
   Float_t fOuterFrameSpace;   //space for outer frame in the phi direction 
   Float_t fInnerWireMount;    //space for wire mount, inner sector
   Float_t fOuterWireMount;    //space for wire mount, outer sector
-  Int_t   fNInnerSector;      //!number of inner sectors             -calculated
-  Int_t   fNOuterSector;      //!number of outer sectors             -calculated
-  Int_t   fNSector;           //! total number of sectors            -calculated
+  Int_t   fNInnerSector;      //number of inner sectors             -calculated
+  Int_t   fNOuterSector;      //number of outer sectors             -calculated
+  Int_t   fNSector;           // total number of sectors            -calculated
   Float_t fZLength;           //length of the drift region of the TPC
-  Float_t *fRotAngle;         //  sin and cos of rotation angles for 
+  Float_t *fRotAngle;         //[fNSector]  sin and cos of rotation angles for 
                               //  diferent sectors -calculated
   Int_t   fGeometryType;      //type of geometry -0 straight rows
+  //  Float_t *fChamberPos;       //[fNSector] displacements of the readout chambers 
+                              //with respect to the 'idead' geometry
+                              //in local corrdinate system
+  //  Float_t *fChamberRot;       //[fNSector] rotation angles of the readout chambers 
+                              //with respect to the 'idead' geometry
+                              //in local corrdinate system
+  TGeoHMatrix **fTrackingMatrix;   //![fNSector] transformation matrices of the tracking
+                              //coordinate system
+  TGeoHMatrix **fClusterMatrix;    //![fNSector] transformation matrices of the cluster
+                              //coordinate system
+  TGeoHMatrix **fGlobalMatrix;    //![fNSector] fTrackingMatrix * fClusterMatrix
+
   //1-cylindrical
   //---------------------------------------------------------------------
   //   ALICE TPC wires  geometry - for GEM we can consider that it is gating  
   //--------------------------------------------------------------------
-  Int_t   fNInnerWiresPerPad; //  Number of wires per pad
-  Float_t fInnerWWPitch;      // pitch between wires  in inner sector     - calculated
+  Int_t   fNInnerWiresPerPad; //Number of wires per pad
+  Float_t fInnerWWPitch;      //pitch between wires  in inner sector     - calculated
   Int_t   fInnerDummyWire;    //number of wires without pad readout
   Float_t fInnerOffWire;      //oofset of first wire to the begining of the sector
   Float_t fRInnerFirstWire;   //position of the first wire                -calculated
   Float_t fRInnerLastWire;    //position of the last wire                 -calculated
-  Int_t   fNOuterWiresPerPad; //  Number of wires per pad
-  Float_t fOuterWWPitch;      // pitch between wires in outer sector      -calculated
+  Float_t fLastWireUp1;     //position of the last wire in outer1 sector
+  Int_t   fNOuter1WiresPerPad; //Number of wires per pad
+  Int_t   fNOuter2WiresPerPad; // Number of wires per pad
+  Float_t fOuterWWPitch;      //pitch between wires in outer sector      -calculated
   Int_t   fOuterDummyWire;    //number of wires without pad readout
   Float_t fOuterOffWire;      //oofset of first wire to the begining of the sector
   Float_t fROuterFirstWire;   //position of the first wire                -calulated
@@ -327,20 +391,26 @@ protected :
   Float_t   fInnerPadPitchWidth;     //Inner pad pitch width
   Float_t   fInnerPadLength;         //Inner pad  length
   Float_t   fInnerPadWidth;          //Inner pad  width
-  Float_t   fOuterPadPitchLength;    //Outer pad pitch length
+  Float_t   fOuter1PadPitchLength;    //Outer pad pitch length
+  Float_t   fOuter2PadPitchLength;    //Outer pad pitch length
   Float_t   fOuterPadPitchWidth;     //Outer pad pitch width
-  Float_t   fOuterPadLength;         //Outer pad  length
+  Float_t   fOuter1PadLength;         //Outer pad  length
+  Float_t   fOuter2PadLength;         //Outer pad length
   Float_t   fOuterPadWidth;          //Outer pad  width
   Bool_t    fBMWPCReadout;           //indicate wire readout - kTRUE or GEM readout -kFALSE
   Int_t     fNCrossRows;             //number of rows to crostalk calculation
       
-  Int_t fNRowLow;           //number of pad rows per low sector    -calculated
+  Int_t fNRowLow;           //number of pad rows per low sector        -set
+  Int_t fNRowUp1;            //number of short pad rows per sector up  -set
+  Int_t fNRowUp2;            //number of long pad rows per sector up   -set
   Int_t fNRowUp;            //number of pad rows per sector up     -calculated
   Int_t fNtRows;            //total number of rows in TPC          -calculated
   Float_t  fPadRowLow[600]; //Lower sector, pad row radii          -calculated
   Float_t  fPadRowUp[600];  //Upper sector, pad row radii          -calculated 
   Int_t    fNPadsLow[600];  //Lower sector, number of pads per row -calculated
-  Int_t    fNPadsUp[600];   //Upper sector, number of pads per row -calculated  
+  Int_t    fNPadsUp[600];   //Upper sector, number of pads per row -calculated
+  Float_t  fYInner[600];     //Inner sector, wire-length
+  Float_t  fYOuter[600];     //Outer sector, wire-length   
   //---------------------------------------------------------------------
   //   ALICE TPC Gas Parameters
   //--------------------------------------------------------------------
@@ -369,18 +439,27 @@ protected :
   Float_t fTotalNormFac;    //full normalisation factor - calculated
   Float_t fNoiseNormFac;    //normalisation factor to transform noise in electron to ADC channel   
   
-protected:
   //---------------------------------------------------------------------
   // ALICE TPC response data 
   //---------------------------------------------------------------------
   Int_t   fNResponseMax;   //maximal dimension of response        
   Float_t fResponseThreshold; //threshold for accepted response   
-  Int_t   fCurrentMax;     //current maximal dimension            -calulated 
-  Int_t   *fResponseBin;    //array with bins                     -calulated
-  Float_t *fResponseWeight; //array with response                 -calulated
+  Int_t   fCurrentMax;     //!current maximal dimension            -calulated 
+  Int_t   *fResponseBin;    //!array with bins                     -calulated
+  Float_t *fResponseWeight; //!array with response                 -calulated
 
-  ClassDef(AliTPCParam,2)  //parameter  object for set:TPC
+  //---------------------------------------------------------------------
+  //   ALICE TPC L1 Parameters
+  //--------------------------------------------------------------------
+  Float_t fGateDelay;       //Delay of L1 arrival for the TPC gate signal
+  Float_t fL1Delay;         //Delay of L1 arrival for the TPC readout 
+  UShort_t fNTBinsBeforeL1; //Number of time bins before L1 arrival which are being read out 
+  Float_t fNTBinsL1;        //Overall L1 delay in time bins
+
+private:
+  AliTPCParam(const AliTPCParam &);
+  AliTPCParam & operator=(const AliTPCParam &);
+  ClassDef(AliTPCParam,4)  //parameter  object for set:TPC
 };
 
  
@@ -389,13 +468,13 @@ inline Int_t * AliTPCParam::GetResBin(Int_t i)
   //return response bin i  - bin given by  padrow [0] pad[1] timebin[2] 
   if (i<fCurrentMax) return &fResponseBin[i*3];
   else return 0;
-};
+}
   
-inline Float_t AliTPCParam::GetResWeight(Int_t i)
+inline Float_t &AliTPCParam::GetResWeight(Int_t i)
 {
   //return  weight of response bin i
   if (i<fCurrentMax) return fResponseWeight[i];
-  else return 0;
+  else return fResponseWeight[i];
 }
 
 
@@ -417,22 +496,41 @@ inline Float_t   AliTPCParam::GetAngle(Int_t isec) const
 }
 
 
-inline void AliTPCParam::Transform1to2(Float_t *xyz, Int_t *index) const
+inline void AliTPCParam::Transform1to2Ideal(Float_t *xyz, Int_t *index) const
 {
-  //transformation to rotated coordinates 
+  //transformation to rotated coordinates
   //we must have information about sector!
-
   //rotate to given sector
+  // ideal frame
+
   Float_t cos,sin;
-  AdjustCosSin(index[1],cos,sin);   
+  AdjustCosSin(index[1],cos,sin);
   Float_t x1=xyz[0]*cos + xyz[1]*sin;
-  Float_t y1=-xyz[0]*sin + xyz[1]*cos; 
+  Float_t y1=-xyz[0]*sin + xyz[1]*cos;
   xyz[0]=x1;
   xyz[1]=y1;
-  xyz[2]=fZLength-TMath::Abs(xyz[2]); 
+  xyz[2]=fZLength-TMath::Abs(xyz[2]);
   index[0]=2;
 }
 
+
+inline void AliTPCParam::Transform1to2(Float_t *xyz, Int_t *index) const
+{
+  //transformation to rotated coordinates 
+  //we must have information about sector!
+  //rotate to given sector
+  Double_t xyzmaster[3] = {xyz[0],xyz[1],xyz[2]};
+  Double_t xyzlocal[3];  
+  fGlobalMatrix[index[1]]->MasterToLocal(xyzmaster,xyzlocal);
+  xyz[0] = xyzlocal[0];
+  xyz[1] = xyzlocal[1];
+  xyz[2] = xyzlocal[2];
+  index[0]=2;
+}
+
+
+
+
 inline void AliTPCParam::Transform2to1(Float_t *xyz, Int_t *index) const
 {
   //
@@ -448,7 +546,7 @@ inline void AliTPCParam::Transform2to1(Float_t *xyz, Int_t *index) const
   if (index[1]<fNInnerSector)
     if ( index[1]>=(fNInnerSector>>1)) xyz[2]*=-1.;
   else 
-    if ( (index[1]-fNInnerSector) > (fNOuterSector>>1) )    xyz[2]*=-1;      
+    if ( (index[1]-fNInnerSector) >= (fNOuterSector>>1) )    xyz[2]*=-1;      
   index[0]=1;
 }
 
@@ -490,7 +588,10 @@ inline Int_t   AliTPCParam::Transform2to3(Float_t *xyz, Int_t *index)  const
   if  (index[1]<fNInnerSector)   
     index[2] =TMath::Nint((xyz[0]-fPadRowLow[0])/fInnerPadPitchLength);
   else
-    index[2] = TMath::Nint((xyz[0]-fPadRowUp[0])/fOuterPadPitchLength);
+    if (xyz[0] < fLastWireUp1 )
+      index[2] = TMath::Nint((xyz[0]-fPadRowUp[0])/fOuter1PadPitchLength);
+    else 
+      index[2] = TMath::Nint(fNRowUp1+(xyz[0]-fPadRowUp[64])/fOuter2PadPitchLength);
   index[0]=3;
   return index[2];
 }
@@ -504,7 +605,10 @@ inline void   AliTPCParam::Transform3to4(Float_t *xyz, Int_t *index)  const
   if  (index[1]<fNInnerSector)   
     xyz[0] -=index[2]*fInnerPadPitchLength+fPadRowLow[0];
   else
-    xyz[0] -=index[2]*fOuterPadPitchLength+fPadRowUp[0];
+    if (index[2]<fNRowUp1)
+      xyz[0] -=index[2]*fOuter1PadPitchLength+fPadRowUp[0];
+    else 
+      xyz[0] -=(index[2]-fNRowUp1)*fOuter2PadPitchLength+fPadRowUp[64];
   index[0]  =4;
 }
 
@@ -517,7 +621,10 @@ inline void   AliTPCParam::Transform4to3(Float_t *xyz, Int_t *index) const
   if  (index[1]<fNInnerSector)   
     xyz[0] +=index[2]*fInnerPadPitchLength+fPadRowLow[0];
   else
-    xyz[0] +=index[2]*fOuterPadPitchLength+fPadRowUp[0];
+    if(index[2]<fNRowUp1)
+      xyz[0] +=index[2]*fOuter1PadPitchLength+fPadRowUp[0];
+    else 
+      xyz[0] +=index[2]*fOuter2PadPitchLength+fPadRowUp[64];
   index[0]  =3;
 }
 
@@ -558,16 +665,18 @@ inline void AliTPCParam::Transform4to8(Float_t *xyz, Int_t *index) const
   //
   //transform xyz coordinates to 'digit' coordinates
   //
+
+  xyz[2]/=fZWidth;  
   if  (index[1]<fNInnerSector) {    
     xyz[0]/=fInnerPadPitchLength;
     xyz[1]/=fInnerPadPitchWidth;
-    xyz[2]/=fZWidth;
   }
-  else{    
-    xyz[0]/=fOuterPadPitchLength;
-    xyz[1]/=fOuterPadPitchWidth;
-    xyz[2]/=fZWidth;
-  }        
+  else{  
+    xyz[1]/=fOuterPadPitchWidth;  
+    if (index[2]<fNRowUp1 ) xyz[0]/=fOuter1PadPitchLength;      
+    else xyz[0]/=fOuter2PadPitchLength;     
+  }
+  xyz[1]-=0.5;
   index[0]=8;
 }
 
@@ -576,16 +685,16 @@ inline void AliTPCParam::Transform8to4(Float_t *xyz, Int_t *index) const
   //
   //transforms 'digit' coordinates to xyz coordinates
   //
+  xyz[2]*=fZWidth;
   if  (index[1]<fNInnerSector) {    
     xyz[0]*=fInnerPadPitchLength;
-    xyz[1]*=fInnerPadPitchWidth;
-    xyz[2]*=fZWidth;
+    xyz[1]*=fInnerPadPitchWidth;    
   }
-  else{    
-    xyz[0]*=fOuterPadPitchLength;
-    xyz[1]*=fOuterPadPitchWidth;
-    xyz[2]*=fZWidth;
-  }        
+  else{  
+    xyz[1]*=fOuterPadPitchWidth;  
+    if (index[2] < fNRowUp1 ) xyz[0]*=fOuter1PadPitchLength;
+    else xyz[0]*=fOuter2PadPitchLength;           
+  } 
   index[0]=4;
 }
 
@@ -594,17 +703,16 @@ inline void  AliTPCParam::Transform6to8(Float_t *xyz, Int_t *index) const
   //
   //transforms cylindrical xyz coordinates to 'digit' coordinates
   //
-  
+  xyz[2]/=fZWidth;
   if  (index[1]<fNInnerSector) {    
     xyz[0]/=fInnerPadPitchLength;
     xyz[1]*=xyz[0]/fInnerPadPitchWidth;
-    xyz[2]/=fZWidth;
   }
-  else{   
-    xyz[0]/=fOuterPadPitchLength;
+  else{ 
     xyz[1]*=xyz[0]/fOuterPadPitchWidth;
-    xyz[2]/=fZWidth;
-  }        
+    if (index[2] < fNRowUp1 ) xyz[0]/=fOuter1PadPitchLength;
+    else xyz[0]/=fOuter2PadPitchLength;       
+  }
   index[0]=8;
 }
 
@@ -613,20 +721,20 @@ inline void  AliTPCParam::Transform8to6(Float_t *xyz, Int_t *index) const
   //
   //transforms 'digit' coordinates to cylindrical xyz coordinates 
   //
-  
+  xyz[2]*=fZWidth;
   if  (index[1]<fNInnerSector) {    
     xyz[0]*=fInnerPadPitchLength;
     xyz[1]/=xyz[0]/fInnerPadPitchWidth;
-    xyz[2]*=fZWidth;
   }
-  else{   
-    xyz[0]*=fOuterPadPitchLength;
-    xyz[1]/=xyz[0]/fOuterPadPitchWidth;
-    xyz[2]*=fZWidth;
-  }        
+  else{ 
+    xyz[1]/=xyz[0]/fOuterPadPitchWidth;  
+    if (index[2] < fNRowUp1 ) xyz[0]*=fOuter1PadPitchLength;
+    else xyz[0]*=fOuter2PadPitchLength;                
+  }  
   index[0]=6;
 }
-
-
-
+inline Float_t AliTPCParam::GetZLength(Int_t sector) const
+{ if(sector <18 || (sector>35&&sector<54)) return   fZLength-0.275;
+  else return fZLength-0.302;
+}
 #endif