]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCParamSR.cxx
AliTPCclusterInof is added to the cluster only as option
[u/mrichter/AliRoot.git] / TPC / AliTPCParamSR.cxx
index bb758fff41bbd1adab601540109aed81c67dc6dc..77ad0cfda796fbe193c8819b1b566bbf6ebb0df5 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.5  2001/12/06 07:49:30  kowal2
-corrected number of pads calculation
-
-Revision 1.4  2000/11/02 07:33:15  kowal2
-Improvements of the code.
-
-Revision 1.3  2000/06/30 12:07:50  kowal2
-Updated from the TPC-PreRelease branch
-
-Revision 1.2.4.2  2000/06/14 16:48:24  kowal2
-Parameter setting improved. Removed compiler warnings
-
-Revision 1.2.4.1  2000/06/09 07:55:39  kowal2
-
-Updated defaults
-
-Revision 1.2  2000/04/17 09:37:33  kowal2
-removed obsolete AliTPCDigitsDisplay.C
-
-Revision 1.1.4.2  2000/04/10 11:36:13  kowal2
-
-New Detector parameters handling class
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////
 //  Manager and of geomety  classes for set: TPC                     //
@@ -52,44 +27,75 @@ New Detector parameters handling class
 //                                                                   //  
 ///////////////////////////////////////////////////////////////////////
 
-
-#include <iostream.h>
+//#include <Riostream.h>
 #include <TMath.h>
-#include <TObject.h>
-#include <AliTPCParamSR.h>
+
 #include "AliTPCPRF2D.h"
+#include "AliTPCParamSR.h"
 #include "AliTPCRF1D.h"
 #include "TH1.h"
-
+#include "AliTPCROC.h"
+#include "TGeoManager.h"
 
 ClassImp(AliTPCParamSR)
-const static  Int_t kMaxRows=600;
-const static  Float_t  kEdgeSectorSpace = 2.5;
-const static Float_t kFacSigmaPadRow=3.;
-const static Float_t kFacSigmaPad=3.;
-const static Float_t kFacSigmaTime=3.;
+static const  Int_t kMaxRows=600;
+static const  Float_t  kEdgeSectorSpace = 2.5;
+static const Float_t kFacSigmaPadRow=3.;
+static const Float_t kFacSigmaPad=3.;
+static const Float_t kFacSigmaTime=3.;
 
 
 AliTPCParamSR::AliTPCParamSR()
+              :AliTPCParam(),
+              fInnerPRF(0),
+              fOuter1PRF(0),
+              fOuter2PRF(0),
+              fTimeRF(0),
+              fFacSigmaPadRow(0),
+              fFacSigmaPad(0),
+              fFacSigmaTime(0)
 {   
   //
   //constructor set the default parameters
-  fInnerPRF=0;
-  fOuterPRF=0;
-  fTimeRF = 0;
+  //
+
   fFacSigmaPadRow = Float_t(kFacSigmaPadRow);
   fFacSigmaPad = Float_t(kFacSigmaPad);
   fFacSigmaTime = Float_t(kFacSigmaTime);
   SetDefault();
   Update();
 }
+AliTPCParamSR::AliTPCParamSR(const AliTPCParamSR &param)
+              :AliTPCParam(),
+              fInnerPRF(0),
+              fOuter1PRF(0),
+              fOuter2PRF(0),
+              fTimeRF(0),
+              fFacSigmaPadRow(0),
+              fFacSigmaPad(0),
+              fFacSigmaTime(0)
+{
+  //
+  //  copy constructor - dummy
+  //
+  fFacSigmaPadRow = param.fFacSigmaPadRow;
+}
+AliTPCParamSR & AliTPCParamSR::operator =(const AliTPCParamSR & param)
+{
+  //
+  // assignment operator - dummy
+  //
+  fZLength=param.fZLength;
+  return (*this);
+}
 
 AliTPCParamSR::~AliTPCParamSR()
 {
   //
   //destructor destroy some dynmicaly alocated variables
   if (fInnerPRF != 0) delete fInnerPRF;
-  if (fOuterPRF != 0) delete fOuterPRF;
+  if (fOuter1PRF != 0) delete fOuter1PRF;
+  if (fOuter2PRF != 0) delete fOuter2PRF;
   if (fTimeRF != 0) delete fTimeRF;
 }
 
@@ -109,7 +115,8 @@ Int_t  AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
   //we suppose that coordinate is expressed in float digits 
   // it's mean coordinate system 8
   //xyz[0] - float padrow xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
-  if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){ 
+  //xyz[3] - electron time in float time bin format
+  if ( (fInnerPRF==0)||(fOuter1PRF==0)||(fOuter2PRF==0) ||(fTimeRF==0) ){ 
     Error("AliTPCParamSR", "response function was not adjusted");
     return -1;
   }
@@ -120,18 +127,24 @@ Int_t  AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
   if (index[1]<fNInnerSector){
     sfpadrow =fFacSigmaPadRow*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
     sfpad    =fFacSigmaPad*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
-  }else{
-    sfpadrow =fFacSigmaPadRow*fOuterPRF->GetSigmaY()/fOuterPadPitchLength;
-    sfpad    =fFacSigmaPad*fOuterPRF->GetSigmaX()/fOuterPadPitchWidth;
+  }
+  else{
+  if(row<fNRowUp1){
+    sfpadrow =fFacSigmaPadRow*fOuter1PRF->GetSigmaY()/fOuter1PadPitchLength;
+    sfpad    =fFacSigmaPad*fOuter1PRF->GetSigmaX()/fOuterPadPitchWidth;}
+    else{
+      sfpadrow =fFacSigmaPadRow*fOuter2PRF->GetSigmaY()/fOuter2PadPitchLength;
+      sfpad    =fFacSigmaPad*fOuter2PRF->GetSigmaX()/fOuterPadPitchWidth;
+    }   
   }
 
   Int_t fpadrow = TMath::Max(TMath::Nint(index[2]+xyz[0]-sfpadrow),0);  //"first" padrow
   Int_t fpad    = TMath::Nint(xyz[1]-sfpad);     //first pad
-  Int_t ftime   = TMath::Max(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()-sftime),0);  // first time
+  Int_t ftime   = TMath::Max(TMath::Nint(xyz[2]+xyz[3]+GetZOffset()/GetZWidth()-sftime-GetNTBinsL1()),0);  // first time
   Int_t lpadrow = TMath::Min(TMath::Nint(index[2]+xyz[0]+sfpadrow),fpadrow+19);  //"last" padrow
   lpadrow       = TMath::Min(GetNRow(index[1])-1,lpadrow);
   Int_t lpad    = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19);     //last pad
-  Int_t ltime   = TMath::Min(TMath::Nint(xyz[2]+GetZOffset()/GetZWidth()+sftime),ftime+19);    // last time
+  Int_t ltime   = TMath::Min(TMath::Nint(xyz[2]+xyz[3]+GetZOffset()/GetZWidth()+sftime-GetNTBinsL1()),ftime+19);    // last time
   ltime         = TMath::Min(ltime,GetMaxTBin()-1); 
   // 
   Int_t npads = GetNPads(index[1],row);
@@ -161,16 +174,19 @@ Int_t  AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
   Int_t padrow, pad;
   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
     for (pad = fpad;pad<=lpad;pad++){
-      Float_t dy = (-xyz[0]+Float_t(index[2]-padrow));
-      Float_t dx = (-xyz[1]+Float_t(pad));
+      Float_t dy = (xyz[0]+Float_t(index[2]-padrow));
+      Float_t dx = (xyz[1]+Float_t(pad));
       if (index[1]<fNInnerSector)
        padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
-      else
-       padres[padrow-fpadrow][pad-fpad]=fOuterPRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuterPadPitchLength);          }
+      else{
+       if(row<fNRowUp1){
+       padres[padrow-fpadrow][pad-fpad]=fOuter1PRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuter1PadPitchLength);}
+       else{
+         padres[padrow-fpadrow][pad-fpad]=fOuter2PRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuter2PadPitchLength);}}}
   //calculate time response function
   Int_t time;
   for (time = ftime;time<=ltime;time++) 
-    timeres[time-ftime]= fTimeRF->GetRF((-xyz[2]+Float_t(time))*fZWidth);     
+    timeres[time-ftime]= fTimeRF->GetRF((-xyz[2]-xyz[3]+Float_t(time))*fZWidth+GetNTBinsL1());     
   //write over threshold values to stack
   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
     for (pad = fpad;pad<=lpad;pad++)
@@ -251,7 +267,7 @@ void AliTPCParamSR::XYZtoCRXYZ(Float_t *xyz,
   padrow = index[1];
 }
 
-Float_t AliTPCParamSR::GetPrimaryLoss(Float_t *x, Int_t *index, Float_t *angle)
+Float_t AliTPCParamSR::GetPrimaryLoss(Float_t */*x*/, Int_t *index, Float_t *angle)
 {
   //
   //
@@ -264,7 +280,7 @@ Float_t AliTPCParamSR::GetPrimaryLoss(Float_t *x, Int_t *index, Float_t *angle)
   return length*fNPrimLoss;
 }
 
-Float_t AliTPCParamSR::GetTotalLoss(Float_t *x, Int_t *index, Float_t *angle)
+Float_t AliTPCParamSR::GetTotalLoss(Float_t */*x*/, Int_t *index, Float_t *angle)
 {
   //
   //
@@ -279,7 +295,7 @@ Float_t AliTPCParamSR::GetTotalLoss(Float_t *x, Int_t *index, Float_t *angle)
 }
 
 
-void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t *angle, Int_t mode, Float_t *sigma)
+void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t */*angle*/, Int_t /*mode*/, Float_t *sigma)
 {
   //
   //return cluster sigma2 (x,y) for particle at position x
@@ -306,8 +322,10 @@ void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t *angle, Int
   if (GetTimeRF()!=0) sigma[0]+=GetTimeRF()->GetSigma()*GetTimeRF()->GetSigma();
   if ( (index[1]<fNInnerSector) &&(GetInnerPRF()!=0))   
     sigma[1]+=GetInnerPRF()->GetSigmaX()*GetInnerPRF()->GetSigmaX();
-  if ( (index[1]>=fNInnerSector) && (GetOuterPRF()!=0))
-    sigma[1]+=GetOuterPRF()->GetSigmaX()*GetOuterPRF()->GetSigmaX();
+  if ( (index[1]>=fNInnerSector) &&(index[2]<fNRowUp1) && (GetOuter1PRF()!=0))
+    sigma[1]+=GetOuter1PRF()->GetSigmaX()*GetOuter1PRF()->GetSigmaX();
+  if( (index[1]>=fNInnerSector) &&(index[2]>=fNRowUp1) && (GetOuter2PRF()!=0))
+    sigma[1]+=GetOuter2PRF()->GetSigmaX()*GetOuter2PRF()->GetSigmaX();
 
 
   sigma[0]/= GetZWidth()*GetZWidth();
@@ -317,15 +335,15 @@ void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t *angle, Int
 
 
 
-void AliTPCParamSR::GetSpaceResolution(Float_t *x, Int_t *index, Float_t *angle
-                                      Float_t amplitude, Int_t mode, Float_t *sigma)
+void AliTPCParamSR::GetSpaceResolution(Float_t */*x*/, Int_t */*index*/, Float_t */*angle*/
+                                      Float_t /*amplitude*/, Int_t /*mode*/, Float_t */*sigma*/)
 {
   //
   //
   //
   
 }
-Float_t  AliTPCParamSR::GetAmp(Float_t *x, Int_t *index, Float_t *angle)
+Float_t  AliTPCParamSR::GetAmp(Float_t */*x*/, Int_t */*index*/, Float_t */*angle*/)
 {
   //
   //
@@ -350,57 +368,68 @@ Float_t * AliTPCParamSR::GetAnglesAccMomentum(Float_t *x, Int_t * index, Float_t
          
 Bool_t AliTPCParamSR::Update()
 {
-  
-  //
-  // update some calculated parameter which must be updated after changing "base"
-  // parameters 
-  // for example we can change size of pads and according this recalculate number
-  // of pad rows, number of of pads in given row ....
   Int_t i;
   if (AliTPCParam::Update()==kFALSE) return kFALSE;
   fbStatus = kFALSE;
 
-  // adjust lower sectors pad row positions and pad numbers 
-  fNRowLow   =  (Int_t(1.001+((fRInnerLastWire-fRInnerFirstWire)/fInnerWWPitch))
-              -2*fInnerDummyWire)/fNInnerWiresPerPad;  
-  if ( kMaxRows<fNRowLow) fNRowUp = kMaxRows;
-  if (1>fNRowLow) return kFALSE;
-  //Float_t firstpad = fRInnerFirstWire+(fInnerDummyWire-0.5)*fInnerWWPitch
-  //    +fInnerPadPitchLength/2.;
-  Float_t lastpad = fRInnerLastWire-(fInnerDummyWire-0.5)*fInnerWWPitch
-    -fInnerPadPitchLength/2.;
-  Float_t firstpad = lastpad-Float_t(fNRowLow-1)*fInnerPadPitchLength;  
-  for (i = 0;i<fNRowLow;i++) 
-    {
-       Float_t x  = firstpad +fInnerPadPitchLength*(Float_t)i;       
-       Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount-
-                   fInnerPadPitchWidth/2.;
-       fPadRowLow[i] = x;
-       fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
+ Float_t firstrow = fInnerRadiusLow + 1.575;   
+ for( i= 0;i<fNRowLow;i++)
+   {
+     Float_t x = firstrow + fInnerPadPitchLength*(Float_t)i;  
+     fPadRowLow[i]=x;
+     // number of pads per row
+     //     Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount-
+     //  fInnerPadPitchWidth/2.;
+     // 0 and fNRowLow+1 reserved for cross talk rows
+     fYInner[i+1]  = x*tan(fInnerAngle/2.)-fInnerWireMount;
+     //fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
+     fNPadsLow[i] = AliTPCROC::Instance()->GetNPads(0,i) ;     // ROC implement     
+   }
+ // cross talk rows
+ fYInner[0]=(fPadRowLow[0]-fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount;
+ fYInner[fNRowLow+1]=(fPadRowLow[fNRowLow-1]+fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount; 
+ firstrow = fOuterRadiusLow + 1.6;
+ for(i=0;i<fNRowUp;i++)
+   {
+     if(i<fNRowUp1){
+       Float_t x = firstrow + fOuter1PadPitchLength*(Float_t)i; 
+       fPadRowUp[i]=x;
+//     Float_t y =(x-0.5*fOuter1PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
+//       fOuterPadPitchWidth/2.;
+     fYOuter[i+1]= x*tan(fOuterAngle/2.)-fOuterWireMount;
+     //fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
+     fNPadsUp[i] =  AliTPCROC::Instance()->GetNPads(36,i) ;     // ROC implement      
+     if(i==fNRowUp1-1) {
+       fLastWireUp1=fPadRowUp[i] +0.625;
+       firstrow = fPadRowUp[i] + 0.5*(fOuter1PadPitchLength+fOuter2PadPitchLength);
+     }
+     }
+     else
+       {
+        Float_t x = firstrow + fOuter2PadPitchLength*(Float_t)(i-64);
+         fPadRowUp[i]=x;
+        //Float_t y =(x-0.5*fOuter2PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
+        //  fOuterPadPitchWidth/2.;
+        //fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ; 
+        fNPadsUp[i] =  AliTPCROC::Instance()->GetNPads(36,i) ;     // ROC implement
        }
-
-  // adjust upper sectors pad row positions and pad numbers
-  fNRowUp   = (Int_t(1.001+((fROuterLastWire-fROuterFirstWire)/fOuterWWPitch))
-              -2*fOuterDummyWire)/fNOuterWiresPerPad; 
-  if ( kMaxRows<fNRowUp) fNRowUp = kMaxRows;
-  if (1>fNRowUp) return kFALSE;
-  firstpad = fROuterFirstWire+(fOuterDummyWire-0.5)*fOuterWWPitch
-    +fOuterPadPitchLength/2.;
-  for (i = 0;i<fNRowUp;i++) 
-    {
-       Float_t x  = firstpad + fOuterPadPitchLength*(Float_t)i;      
-       Float_t y = (x-0.5*fOuterPadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
-                   fOuterPadPitchWidth/2.;
-       fPadRowUp[i] = x;
-       fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
-    }
-  fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
-  fbStatus = kTRUE;
-  return kTRUE;
+     fYOuter[i+1]  = fPadRowUp[i]*tan(fOuterAngle/2.)-fOuterWireMount;
+   }
+ // cross talk rows
+ fYOuter[0]=(fPadRowUp[0]-fOuter1PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount;
+ fYOuter[fNRowUp+1]=(fPadRowUp[fNRowUp-1]+fOuter2PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount;
+ fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
+ fbStatus = kTRUE;
+ return kTRUE;
+}
+Float_t AliTPCParamSR::GetYInner(Int_t irow) const
+{
+  return fYInner[irow];
+}
+Float_t AliTPCParamSR::GetYOuter(Int_t irow) const
+{
+  return fYOuter[irow];
 }
-
 
 void AliTPCParamSR::Streamer(TBuffer &R__b)
 {
@@ -412,6 +441,7 @@ void AliTPCParamSR::Streamer(TBuffer &R__b)
       AliTPCParam::Streamer(R__b);
       //      if (R__v < 2) return;
        Update();
+       if (gGeoManager) ReadGeoMatrices();
    } else {
       R__b.WriteVersion(AliTPCParamSR::IsA());
       //TObject::Streamer(R__b);  
@@ -426,25 +456,29 @@ Int_t  AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
   //
   //we suppose that coordinate is expressed in float digits 
   // it's mean coordinate system 8
-  //xyz[0] - float padrow xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
-  if ( (fInnerPRF==0)||(fOuterPRF==0)||(fTimeRF==0) ){ 
+  //xyz[0] - electron position w.r.t. pad center, normalized to pad length,
+  //xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
+  //xyz[3] - electron time in float time bin format
+  if ( (fInnerPRF==0)||(fOuter1PRF==0)||(fOuter2PRF==0) ||(fTimeRF==0) ){ 
     Error("AliTPCParamSR", "response function was not adjusted");
     return -1;
   }
   
-  const Int_t padn =  500;
-  const Float_t fpadn =  500.;
-  const Int_t timen = 500;
-  const Float_t ftimen = 500.;
-  const Int_t padrn = 500;
-  const Float_t fpadrn = 500.;
+  const Int_t kpadn =  500;
+  const Float_t kfpadn =  500.;
+  const Int_t ktimen = 500;
+  const Float_t kftimen = 500.;
+  const Int_t kpadrn = 500;
+  const Float_t kfpadrn = 500.;
 
  
 
-  static Float_t prfinner[2*padrn][5*padn];  //pad divided by 50
-  static Float_t prfouter[2*padrn][5*padn];  //prfouter division
-  
-  static Float_t rftime[5*timen];         //time division
+  static Float_t prfinner[2*kpadrn][5*kpadn];  //pad divided by 50
+  static Float_t prfouter1[2*kpadrn][5*kpadn];  //prfouter division
+  static Float_t prfouter2[2*kpadrn][5*kpadn];
+  static Float_t kTanMax =0;  
+
+  static Float_t rftime[5*ktimen];         //time division
   static Int_t blabla=0;
   static Float_t zoffset=0;
   static Float_t zwidth=0;
@@ -454,6 +488,7 @@ Int_t  AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
   static TH1F * hdiff2=0;
   
   if (blabla==0) {  //calculate Response function - only at the begginning
+    kTanMax = TMath::ATan(10.*TMath::DegToRad());
     hdiff =new TH1F("prf_diff","prf_diff",10000,-1,1);
     hdiff1 =new TH1F("no_repsonse1","no_response1",10000,-1,1);
     hdiff2 =new TH1F("no_response2","no_response2",10000,-1,1);
@@ -462,29 +497,35 @@ Int_t  AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
     zoffset = GetZOffset();
     zwidth  = fZWidth;
     zoffset2 = zoffset/zwidth;
-    for (Int_t i=0;i<5*timen;i++){
-      rftime[i] = fTimeRF->GetRF(((i-2.5*ftimen)/ftimen)*zwidth+zoffset);
+    for (Int_t i=0;i<5*ktimen;i++){
+      rftime[i] = fTimeRF->GetRF(((i-2.5*kftimen)/kftimen)*zwidth+zoffset);
     }
-    for (Int_t i=0;i<5*padn;i++){    
-      for (Int_t j=0;j<2*padrn;j++){
+    for (Int_t i=0;i<5*kpadn;i++){    
+      for (Int_t j=0;j<2*kpadrn;j++){
        prfinner[j][i] =
-         fInnerPRF->GetPRF((i-2.5*fpadn)/fpadn
-                           *fInnerPadPitchWidth,(j-fpadrn)/fpadrn*fInnerPadPitchLength);
-       prfouter[j][i] =
-         fOuterPRF->GetPRF((i-2.5*fpadn)/fpadn
-                           *fOuterPadPitchWidth,(j-fpadrn)/fpadrn*fOuterPadPitchLength);
+         fInnerPRF->GetPRF((i-2.5*kfpadn)/kfpadn
+                           *fInnerPadPitchWidth,(j-kfpadrn)/kfpadrn*fInnerPadPitchLength);
+       prfouter1[j][i] =
+         fOuter1PRF->GetPRF((i-2.5*kfpadn)/kfpadn
+                           *fOuterPadPitchWidth,(j-kfpadrn)/kfpadrn*fOuter1PadPitchLength);
+
+       //
+       prfouter2[j][i] =
+         fOuter2PRF->GetPRF((i-2.5*kfpadn)/kfpadn
+                           *fOuterPadPitchWidth,(j-kfpadrn)/kfpadrn*fOuter2PadPitchLength);
       }
     }      
-  }
+  } // the above is calculated only once
+
   // calculate central padrow, pad, time
-  Int_t npads = GetNPads(index[1],index[2]);
-  Int_t cpadrow = index[2];
+  Int_t npads = GetNPads(index[1],index[3]-1);
+  Int_t cpadrow = index[2]; // electrons are here
   Int_t cpad    = TMath::Nint(xyz[1]);
-  Int_t ctime   = TMath::Nint(xyz[2]+zoffset2);
+  Int_t ctime   = TMath::Nint(xyz[2]+zoffset2+xyz[3]-GetNTBinsL1());
   //calulate deviation
   Float_t dpadrow = xyz[0];
   Float_t dpad    = xyz[1]-cpad;
-  Float_t dtime   = xyz[2]+zoffset2-ctime;
+  Float_t dtime   = xyz[2]+zoffset2+xyz[3]-ctime-GetNTBinsL1();
   Int_t cindex =0;
   Int_t cindex3 =0;
   Int_t maxt =GetMaxTBin();
@@ -499,45 +540,78 @@ Int_t  AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row)
     fpadrow = (index[2]>1) ? -1 :0;
     lpadrow = (index[2]<GetNRow(index[1])-1) ? 1:0;
   }
+
   Int_t fpad =  (cpad > -npads/2+1) ? -2: -npads/2-cpad;
-  Int_t lpad =  (cpad < npads/2-1)  ?  2: npads/2-cpad;
+  Int_t lpad =  (cpad < npads/2-2)  ?  2: npads/2-1-cpad;
   Int_t ftime =  (ctime>1) ? -2: -ctime;
   Int_t ltime =  (ctime<maxt-2) ? 2: maxt-ctime-1;
 
-  Int_t apadrow= TMath::Nint((dpadrow-fpadrow)*fpadrn+fpadrn);
-  //Int_t apadrow= TMath::Nint((-dpadrow-fpadrow)*fpadrn+fpadrn);
-  
+  // cross talk from long pad to short one
+  if(row==fNRowUp1 && fpadrow==-1) {
+    dpadrow *= fOuter2PadPitchLength;
+    dpadrow += fOuterWWPitch;
+    dpadrow /= fOuter1PadPitchLength;
+  }    
+  // cross talk from short pad to long one
+  if(row==fNRowUp1+1 && fpadrow==1){ 
+    dpadrow *= fOuter1PadPitchLength;
+    if(dpadrow < 0.) dpadrow = -1.; //protection against 3rd wire
+    dpadrow += fOuterWWPitch;
+    dpadrow /= fOuter2PadPitchLength;
+    
+  }
+
+  // "normal"
+  Int_t apadrow = TMath::Nint((dpadrow-fpadrow)*kfpadrn+kfpadrn);
   for (Int_t ipadrow = fpadrow; ipadrow<=lpadrow;ipadrow++){
-    if ( (apadrow<0) || (apadrow>=2*padrn)) 
+    if ( (apadrow<0) || (apadrow>=2*kpadrn)) 
       continue;
-    Int_t apad= TMath::Nint((dpad-fpad)*fpadn+2.5*fpadn);
+    // pad angular correction
+    Float_t angle = kTanMax*2.*(cpad+0.5)/Float_t(npads);
+    Float_t dpadangle =0;
+    if (index[1]<fNInnerSector){
+      dpadangle = angle*dpadrow*fInnerPadPitchLength/fInnerPadPitchWidth;
+    }
+    else{
+      if(row < fNRowUp1+1){
+        dpadangle    = angle*dpadrow*fOuter1PadPitchLength/fOuterPadPitchWidth;
+      }
+      else {
+       dpadangle    = angle*dpadrow*fOuter2PadPitchLength/fOuterPadPitchWidth;
+      }
+    }
+    if (ipadrow==0) dpadangle *=-1;
+    //
+    //    Int_t apad= TMath::Nint((dpad-fpad)*kfpadn+2.5*kfpadn);
+    Int_t apad= TMath::Nint((dpad+dpadangle-fpad)*kfpadn+2.5*kfpadn);
     for (Int_t ipad = fpad; ipad<=lpad;ipad++){
        Float_t cweight;
-       if (index[1]<fNInnerSector)
+       if (index[1]<fNInnerSector){
          cweight=prfinner[apadrow][apad];
-       else
-         cweight=prfouter[apadrow][apad];
+       }
+       else{
+         if(row < fNRowUp1+1){
+           cweight=prfouter1[apadrow][apad];
+         }
+          else {
+           cweight=prfouter2[apadrow][apad];
+         }
+       }
        //      if (cweight<fResponseThreshold) continue;
-       Int_t atime = TMath::Nint((dtime-ftime)*ftimen+2.5*ftimen);
+       Int_t atime = TMath::Nint((dtime-ftime)*kftimen+2.5*kftimen);
        for (Int_t itime = ftime;itime<=ltime;itime++){ 
          Float_t cweight2 = cweight*rftime[atime];
          if (cweight2>fResponseThreshold) {
            fResponseBin[cindex3++]=cpadrow+ipadrow;
            fResponseBin[cindex3++]=cpad+ipad;
            fResponseBin[cindex3++]=ctime+itime;
-           fResponseWeight[cindex++]=cweight2;
-           
-           if (cweight2>100) 
-             {
-               printf("Pici pici %d %f %d\n",ipad,dpad,apad);
-             }
-           
+           fResponseWeight[cindex++]=cweight2;             
          }
-         atime-=timen;
+         atime-=ktimen;
        }
-       apad-= padn;    
+       apad-= kpadn;   
     }
-    apadrow-=padrn;
+    apadrow-=kpadrn;
   }
   fCurrentMax=cindex;  
   return fCurrentMax;