LCOV - code coverage report
Current view: top level - TPC/TPCbase - AliTPCParamSR.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 152 290 52.4 %
Date: 2016-06-14 17:26:59 Functions: 10 23 43.5 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : 
      17             : /// \class AliTPCParamSR
      18             : /// \brief Manager and of geomety  classes for set: TPC
      19             : ///
      20             : /// !sectors are numbered from  0
      21             : /// !pad rows are numbered from 0
      22             : ///
      23             : /// 27.7.   - AliTPCPaaramSr object for TPC
      24             : /// TPC with straight pad rows
      25             : ///
      26             : /// \author Marian Ivanov, Uni. of Bratislava, ivanov@fmph.uniba.sk
      27             : 
      28             : //#include <Riostream.h>
      29             : #include <TMath.h>
      30             : #include "TBuffer.h"
      31             : 
      32             : #include "AliTPCPRF2D.h"
      33             : #include "AliTPCParamSR.h"
      34             : #include "AliTPCRF1D.h"
      35             : #include "TH1.h"
      36             : #include "AliTPCROC.h"
      37             : #include "TGeoManager.h"
      38             : 
      39             : /// \cond CLASSIMP
      40          24 : ClassImp(AliTPCParamSR)
      41             : /// \endcond
      42             : static const  Int_t kMaxRows=600;
      43             : static const  Float_t  kEdgeSectorSpace = 2.5;
      44             : static const Float_t kFacSigmaPadRow=3.;
      45             : static const Float_t kFacSigmaPad=3.;
      46             : static const Float_t kFacSigmaTime=3.;
      47             : 
      48             : 
      49             : AliTPCParamSR::AliTPCParamSR()
      50          18 :               :AliTPCParam(),
      51          18 :                fInnerPRF(0),
      52          18 :                fOuter1PRF(0),
      53          18 :                fOuter2PRF(0),
      54          18 :                fTimeRF(0),
      55          18 :                fFacSigmaPadRow(0),
      56          18 :                fFacSigmaPad(0),
      57          18 :                fFacSigmaTime(0)
      58          90 : {
      59             :   /// constructor set the default parameters
      60             : 
      61          18 :   fFacSigmaPadRow = Float_t(kFacSigmaPadRow);
      62          18 :   fFacSigmaPad = Float_t(kFacSigmaPad);
      63          18 :   fFacSigmaTime = Float_t(kFacSigmaTime);
      64          18 :   SetDefault();
      65          18 :   Update();
      66          36 : }
      67             : 
      68             : AliTPCParamSR::~AliTPCParamSR()
      69          18 : {
      70             :   /// destructor destroy some dynmicaly alocated variables
      71             : 
      72           5 :   if (fInnerPRF != 0) delete fInnerPRF;
      73           5 :   if (fOuter1PRF != 0) delete fOuter1PRF;
      74           5 :   if (fOuter2PRF != 0) delete fOuter2PRF;
      75           5 :   if (fTimeRF != 0) delete fTimeRF;
      76           9 : }
      77             : 
      78             : void AliTPCParamSR::SetDefault()
      79             : {
      80             :   /// set default TPC param
      81             : 
      82          36 :   fbStatus = kFALSE;
      83          18 :   AliTPCParam::SetDefault();
      84          18 : }
      85             : 
      86             : Int_t  AliTPCParamSR::CalcResponse(Float_t* xyz, Int_t * index, Int_t row)
      87             : {
      88             :   /// calculate bin response as function of the input position -x
      89             :   /// return number of valid response bin
      90             :   ///
      91             :   /// we suppose that coordinate is expressed in float digits
      92             :   /// it's mean coordinate system 8
      93             :   /// xyz[0] - float padrow xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
      94             :   /// xyz[3] - electron time in float time bin format
      95             : 
      96           0 :   if ( (fInnerPRF==0)||(fOuter1PRF==0)||(fOuter2PRF==0) ||(fTimeRF==0) ){
      97           0 :     Error("AliTPCParamSR", "response function was not adjusted");
      98           0 :     return -1;
      99             :   }
     100             : 
     101             :   Float_t sfpadrow;   // sigma of response function
     102             :   Float_t sfpad;      // sigma  of
     103           0 :   Float_t sftime= fFacSigmaTime*fTimeRF->GetSigma()/fZWidth;     //3 sigma of time response
     104           0 :   if (index[1]<fNInnerSector){
     105           0 :     sfpadrow =fFacSigmaPadRow*fInnerPRF->GetSigmaY()/fInnerPadPitchLength;
     106           0 :     sfpad    =fFacSigmaPad*fInnerPRF->GetSigmaX()/fInnerPadPitchWidth;
     107           0 :   }
     108             :   else{
     109           0 :   if(row<fNRowUp1){
     110           0 :     sfpadrow =fFacSigmaPadRow*fOuter1PRF->GetSigmaY()/fOuter1PadPitchLength;
     111           0 :     sfpad    =fFacSigmaPad*fOuter1PRF->GetSigmaX()/fOuterPadPitchWidth;}
     112             :     else{
     113           0 :       sfpadrow =fFacSigmaPadRow*fOuter2PRF->GetSigmaY()/fOuter2PadPitchLength;
     114           0 :       sfpad    =fFacSigmaPad*fOuter2PRF->GetSigmaX()/fOuterPadPitchWidth;
     115             :     }
     116             :   }
     117             : 
     118           0 :   Int_t fpadrow = TMath::Max(TMath::Nint(index[2]+xyz[0]-sfpadrow),0);  //"first" padrow
     119           0 :   Int_t fpad    = TMath::Nint(xyz[1]-sfpad);     //first pad
     120           0 :   Int_t ftime   = TMath::Max(TMath::Nint(xyz[2]+xyz[3]+GetZOffset()/GetZWidth()-sftime),0);  // first time
     121           0 :   Int_t lpadrow = TMath::Min(TMath::Nint(index[2]+xyz[0]+sfpadrow),fpadrow+19);  //"last" padrow
     122           0 :   lpadrow       = TMath::Min(GetNRow(index[1])-1,lpadrow);
     123           0 :   Int_t lpad    = TMath::Min(TMath::Nint(xyz[1]+sfpad),fpad+19);     //last pad
     124           0 :   Int_t ltime   = TMath::Min(TMath::Nint(xyz[2]+xyz[3]+GetZOffset()/GetZWidth()+sftime),ftime+19);    // last time
     125           0 :   ltime         = TMath::Min(ltime,GetMaxTBin()-1);
     126             :   //
     127           0 :   Int_t npads = GetNPads(index[1],row);
     128           0 :   if (fpad<-npads/2)
     129           0 :     fpad = -npads/2;
     130           0 :   if (lpad>npads/2)
     131           0 :     lpad= npads/2;
     132           0 :   if (ftime<0) ftime=0;
     133             :   //
     134           0 :   if (row>=0) { //if we are interesting about given pad row
     135           0 :     if (fpadrow<=row) fpadrow =row;
     136             :     else
     137           0 :       return 0;
     138           0 :     if (lpadrow>=row) lpadrow = row;
     139             :     else
     140           0 :       return 0;
     141           0 :   }
     142             : 
     143             : 
     144           0 :   Float_t  padres[20][20];  //I don't expect bigger number of bins
     145           0 :   Float_t  timeres[20];
     146             :   Int_t cindex3=0;
     147             :   Int_t cindex=0;
     148             :   Float_t cweight = 0;
     149           0 :   if (fpadrow>=0) {
     150             :   //calculate padresponse function
     151             :   Int_t padrow, pad;
     152           0 :   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
     153           0 :     for (pad = fpad;pad<=lpad;pad++){
     154           0 :       Float_t dy = (xyz[0]+Float_t(index[2]-padrow));
     155           0 :       Float_t dx = (xyz[1]+Float_t(pad));
     156           0 :       if (index[1]<fNInnerSector)
     157           0 :         padres[padrow-fpadrow][pad-fpad]=fInnerPRF->GetPRF(dx*fInnerPadPitchWidth,dy*fInnerPadPitchLength);
     158             :       else{
     159           0 :         if(row<fNRowUp1){
     160           0 :         padres[padrow-fpadrow][pad-fpad]=fOuter1PRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuter1PadPitchLength);}
     161             :         else{
     162           0 :           padres[padrow-fpadrow][pad-fpad]=fOuter2PRF->GetPRF(dx*fOuterPadPitchWidth,dy*fOuter2PadPitchLength);}}}
     163             :   //calculate time response function
     164             :   Int_t time;
     165           0 :   for (time = ftime;time<=ltime;time++)
     166           0 :     timeres[time-ftime]= fTimeRF->GetRF((-xyz[2]-xyz[3]+Float_t(time))*fZWidth);
     167             :   //write over threshold values to stack
     168           0 :   for (padrow = fpadrow;padrow<=lpadrow;padrow++)
     169           0 :     for (pad = fpad;pad<=lpad;pad++)
     170           0 :       for (time = ftime;time<=ltime;time++){
     171           0 :         cweight = timeres[time-ftime]*padres[padrow-fpadrow][pad-fpad];
     172           0 :         if (cweight>fResponseThreshold) {
     173           0 :           fResponseBin[cindex3]=padrow;
     174           0 :           fResponseBin[cindex3+1]=pad;
     175           0 :           fResponseBin[cindex3+2]=time;
     176           0 :           cindex3+=3;
     177           0 :           fResponseWeight[cindex]=cweight;
     178           0 :           cindex++;
     179           0 :         }
     180             :       }
     181           0 :   }
     182           0 :   fCurrentMax=cindex;
     183             :   return fCurrentMax;
     184           0 : }
     185             : 
     186             : void AliTPCParamSR::TransformTo8(Float_t *xyz, Int_t *index) const
     187             : {
     188             :   /// transformate point to digit coordinate
     189             : 
     190           0 :   if (index[0]==0) Transform0to1(xyz,index);
     191           0 :   if (index[0]==1) Transform1to2(xyz,index);
     192           0 :   if (index[0]==2) Transform2to3(xyz,index);
     193           0 :   if (index[0]==3) Transform3to4(xyz,index);
     194           0 :   if (index[0]==4) Transform4to8(xyz,index);
     195           0 : }
     196             : 
     197             : void AliTPCParamSR::TransformTo2(Float_t *xyz, Int_t *index) const
     198             : {
     199             :   /// transformate point to rotated coordinate
     200             :   ///
     201             :   /// we suppose that
     202             : 
     203           0 :   if (index[0]==0) Transform0to1(xyz,index);
     204           0 :   if (index[0]==1) Transform1to2(xyz,index);
     205           0 :   if (index[0]==4) Transform4to3(xyz,index);
     206           0 :   if (index[0]==8) {  //if we are in digit coordinate system transform to global
     207           0 :     Transform8to4(xyz,index);
     208           0 :     Transform4to3(xyz,index);
     209           0 :   }
     210           0 : }
     211             : 
     212             : void AliTPCParamSR::CRXYZtoXYZ(Float_t *xyz,
     213             :                const Int_t &sector, const Int_t & padrow, Int_t option) const
     214             : {
     215             :   /// transform relative coordinates to absolute
     216             : 
     217           0 :   Bool_t rel = ( (option&2)!=0);
     218           0 :   Int_t index[3]={sector,padrow,0};
     219           0 :   if (rel==kTRUE)      Transform4to3(xyz,index);//if the position is relative to pad row
     220           0 :   Transform2to1(xyz,index);
     221           0 : }
     222             : 
     223             : void AliTPCParamSR::XYZtoCRXYZ(Float_t *xyz,
     224             :                              Int_t &sector, Int_t & padrow, Int_t option) const
     225             : {
     226             :   /// transform global position to the position relative to the sector padrow
     227             :   /// if option=0  X calculate absolute            calculate sector
     228             :   /// if option=1  X           absolute            use input sector
     229             :   /// if option=2  X           relative to pad row calculate sector
     230             :   /// if option=3  X           relative            use input sector
     231             :   /// !!!!!!!!! WE start to calculate rows from row = 0
     232             : 
     233           0 :   Int_t index[3];
     234           0 :   Bool_t rel = ( (option&2)!=0);
     235             : 
     236             :   //option 0 and 2  means that we don't have information about sector
     237           0 :   if ((option&1)==0)   Transform0to1(xyz,index);  //we calculate sector number
     238             :   else
     239           0 :     index[0]=sector;
     240           0 :   Transform1to2(xyz,index);
     241           0 :   Transform2to3(xyz,index);
     242             :   //if we store relative position calculate position relative to pad row
     243           0 :   if (rel==kTRUE) Transform3to4(xyz,index);
     244           0 :   sector = index[0];
     245           0 :   padrow = index[1];
     246           0 : }
     247             : 
     248             : Float_t AliTPCParamSR::GetPrimaryLoss(Float_t */*x*/, Int_t *index, Float_t *angle)
     249             : {
     250             :   ///
     251             : 
     252           0 :   Float_t padlength=GetPadPitchLength(index[1]);
     253           0 :   Float_t a1=TMath::Sin(angle[0]);
     254           0 :   a1*=a1;
     255           0 :   Float_t a2=TMath::Sin(angle[1]);
     256           0 :   a2*=a2;
     257           0 :   Float_t length =padlength*TMath::Sqrt(1+a1+a2);
     258           0 :   return length*fNPrimLoss;
     259             : }
     260             : 
     261             : Float_t AliTPCParamSR::GetTotalLoss(Float_t */*x*/, Int_t *index, Float_t *angle)
     262             : {
     263             :   ///
     264             : 
     265           0 :   Float_t padlength=GetPadPitchLength(index[1]);
     266           0 :   Float_t a1=TMath::Sin(angle[0]);
     267           0 :   a1*=a1;
     268           0 :   Float_t a2=TMath::Sin(angle[1]);
     269           0 :   a2*=a2;
     270           0 :   Float_t length =padlength*TMath::Sqrt(1+a1+a2);
     271           0 :   return length*fNTotalLoss;
     272             : 
     273             : }
     274             : 
     275             : 
     276             : void AliTPCParamSR::GetClusterSize(Float_t *x, Int_t *index, Float_t */*angle*/, Int_t /*mode*/, Float_t *sigma)
     277             : {
     278             :   /// return cluster sigma2 (x,y) for particle at position x
     279             :   /// in this case x coordinata is in drift direction
     280             :   /// and y in pad row direction
     281             :   /// we suppose that input coordinate system is digit system
     282             : 
     283             :   Float_t  xx;
     284           0 :   Float_t lx[3] = {x[0],x[1],x[2]};
     285           0 :   Int_t   li[3] = {index[0],index[1],index[2]};
     286           0 :   TransformTo2(lx,li);
     287             :   //  Float_t  sigmadiff;
     288           0 :   sigma[0]=0;
     289           0 :   sigma[1]=0;
     290             : 
     291           0 :   xx = lx[2];  //calculate drift length in cm
     292           0 :   if (xx>0) {
     293           0 :     sigma[0]+= xx*GetDiffL()*GetDiffL();
     294           0 :     sigma[1]+= xx*GetDiffT()*GetDiffT();
     295           0 :   }
     296             : 
     297             : 
     298             :   //sigma[0]=sigma[1]=0;
     299           0 :   if (GetTimeRF()!=0) sigma[0]+=GetTimeRF()->GetSigma()*GetTimeRF()->GetSigma();
     300           0 :   if ( (index[1]<fNInnerSector) &&(GetInnerPRF()!=0))
     301           0 :     sigma[1]+=GetInnerPRF()->GetSigmaX()*GetInnerPRF()->GetSigmaX();
     302           0 :   if ( (index[1]>=fNInnerSector) &&(index[2]<fNRowUp1) && (GetOuter1PRF()!=0))
     303           0 :     sigma[1]+=GetOuter1PRF()->GetSigmaX()*GetOuter1PRF()->GetSigmaX();
     304           0 :   if( (index[1]>=fNInnerSector) &&(index[2]>=fNRowUp1) && (GetOuter2PRF()!=0))
     305           0 :     sigma[1]+=GetOuter2PRF()->GetSigmaX()*GetOuter2PRF()->GetSigmaX();
     306             : 
     307             : 
     308           0 :   sigma[0]/= GetZWidth()*GetZWidth();
     309           0 :   sigma[1]/=GetPadPitchWidth(index[0])*GetPadPitchWidth(index[0]);
     310           0 : }
     311             : 
     312             : 
     313             : 
     314             : 
     315             : void AliTPCParamSR::GetSpaceResolution(Float_t */*x*/, Int_t */*index*/, Float_t */*angle*/,
     316             :                                        Float_t /*amplitude*/, Int_t /*mode*/, Float_t */*sigma*/)
     317             : {
     318             :   ///
     319             : 
     320           0 : }
     321             : Float_t  AliTPCParamSR::GetAmp(Float_t */*x*/, Int_t */*index*/, Float_t */*angle*/)
     322             : {
     323             :   ///
     324             : 
     325           0 :   return 0;
     326             : }
     327             : 
     328             : Float_t * AliTPCParamSR::GetAnglesAccMomentum(Float_t *x, Int_t * index, Float_t* momentum, Float_t *angle)
     329             : {
     330             :   /// calculate angle of track to padrow at given position
     331             :   /// for given magnetic field and momentum of the particle
     332             : 
     333           0 :   TransformTo2(x,index);
     334           0 :   AliDetectorParam::GetAnglesAccMomentum(x,index,momentum,angle);
     335           0 :   Float_t addangle = TMath::ASin(x[1]/GetPadRowRadii(index[1],index[2]));
     336           0 :   angle[1] +=addangle;
     337           0 :   return angle;
     338             : }
     339             : 
     340             : 
     341             : Bool_t AliTPCParamSR::Update()
     342             : {
     343             :   Int_t i;
     344          66 :   if (AliTPCParam::Update()==kFALSE) return kFALSE;
     345          33 :   fbStatus = kFALSE;
     346             : 
     347          33 :  Float_t firstrow = fInnerRadiusLow + 1.575;
     348        4224 :  for( i= 0;i<fNRowLow;i++)
     349             :    {
     350        2079 :      Float_t x = firstrow + fInnerPadPitchLength*(Float_t)i;
     351        2079 :      fPadRowLow[i]=x;
     352             :      // number of pads per row
     353             :      //     Float_t y = (x-0.5*fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount-
     354             :      //  fInnerPadPitchWidth/2.;
     355             :      // 0 and fNRowLow+1 reserved for cross talk rows
     356        2079 :      fYInner[i+1]  = x*tan(fInnerAngle/2.)-fInnerWireMount;
     357             :      //fNPadsLow[i] = 1+2*(Int_t)(y/fInnerPadPitchWidth) ;
     358        2079 :      fNPadsLow[i] = AliTPCROC::Instance()->GetNPads(0,i) ;     // ROC implement
     359             :    }
     360             :  // cross talk rows
     361          33 :  fYInner[0]=(fPadRowLow[0]-fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount;
     362          33 :  fYInner[fNRowLow+1]=(fPadRowLow[fNRowLow-1]+fInnerPadPitchLength)*tan(fInnerAngle/2.)-fInnerWireMount;
     363          33 :  firstrow = fOuterRadiusLow + 1.6;
     364        6402 :  for(i=0;i<fNRowUp;i++)
     365             :    {
     366        3168 :      if(i<fNRowUp1){
     367        2112 :        Float_t x = firstrow + fOuter1PadPitchLength*(Float_t)i;
     368        2112 :        fPadRowUp[i]=x;
     369             : //     Float_t y =(x-0.5*fOuter1PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
     370             : //        fOuterPadPitchWidth/2.;
     371        2112 :      fYOuter[i+1]= x*tan(fOuterAngle/2.)-fOuterWireMount;
     372             :      //fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
     373        2112 :      fNPadsUp[i] =  AliTPCROC::Instance()->GetNPads(36,i) ;     // ROC implement
     374        2112 :      if(i==fNRowUp1-1) {
     375          33 :        fLastWireUp1=fPadRowUp[i] +0.625;
     376          33 :        firstrow = fPadRowUp[i] + 0.5*(fOuter1PadPitchLength+fOuter2PadPitchLength);
     377          33 :      }
     378        2112 :      }
     379             :      else
     380             :        {
     381        1056 :          Float_t x = firstrow + fOuter2PadPitchLength*(Float_t)(i-64);
     382        1056 :          fPadRowUp[i]=x;
     383             :          //Float_t y =(x-0.5*fOuter2PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount-
     384             :          //  fOuterPadPitchWidth/2.;
     385             :          //fNPadsUp[i] = 1+2*(Int_t)(y/fOuterPadPitchWidth) ;
     386        1056 :          fNPadsUp[i] =  AliTPCROC::Instance()->GetNPads(36,i) ;     // ROC implement
     387             :        }
     388        3168 :      fYOuter[i+1]  = fPadRowUp[i]*tan(fOuterAngle/2.)-fOuterWireMount;
     389             :    }
     390             :  // cross talk rows
     391          33 :  fYOuter[0]=(fPadRowUp[0]-fOuter1PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount;
     392          33 :  fYOuter[fNRowUp+1]=(fPadRowUp[fNRowUp-1]+fOuter2PadPitchLength)*tan(fOuterAngle/2.)-fOuterWireMount;
     393          33 :  fNtRows = fNInnerSector*fNRowLow+fNOuterSector*fNRowUp;
     394          33 :  fbStatus = kTRUE;
     395             :  return kTRUE;
     396          33 : }
     397             : Float_t AliTPCParamSR::GetYInner(Int_t irow) const
     398             : {
     399           0 :   return fYInner[irow];
     400             : }
     401             : Float_t AliTPCParamSR::GetYOuter(Int_t irow) const
     402             : {
     403           0 :   return fYOuter[irow];
     404             : }
     405             : 
     406             : void AliTPCParamSR::Streamer(TBuffer &R__b)
     407             : {
     408             :    /// Stream an object of class AliTPC.
     409             : 
     410          34 :    if (R__b.IsReading()) {
     411          15 :       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
     412             :       //      TObject::Streamer(R__b);
     413          15 :       AliTPCParam::Streamer(R__b);
     414             :       //      if (R__v < 2) return;
     415          15 :        Update();
     416          29 :        if (gGeoManager) ReadGeoMatrices();
     417          15 :    } else {
     418           2 :       R__b.WriteVersion(AliTPCParamSR::IsA());
     419             :       //TObject::Streamer(R__b);
     420           2 :       AliTPCParam::Streamer(R__b);
     421             :    }
     422          17 : }
     423             : Int_t  AliTPCParamSR::CalcResponseFast(Float_t* xyz, Int_t * index, Int_t row, Float_t phase)
     424             : {
     425             :   /// calculate bin response as function of the input position -x
     426             :   /// return number of valid response bin
     427             :   ///
     428             :   /// we suppose that coordinate is expressed in float digits
     429             :   /// it's mean coordinate system 8
     430             :   /// xyz[0] - electron position w.r.t. pad center, normalized to pad length,
     431             :   /// xyz[1] is float pad  (center pad is number 0) and xyz[2] is float time bin
     432             :   /// xyz[3] - electron time in float time bin format
     433             : 
     434    24614285 :   if ( (fInnerPRF==0)||(fOuter1PRF==0)||(fOuter2PRF==0) ||(fTimeRF==0) ){
     435           0 :     Error("AliTPCParamSR", "response function was not adjusted");
     436           0 :     return -1;
     437             :   }
     438             : 
     439             :   const Int_t kpadn =  500;
     440             :   const Float_t kfpadn =  500.;
     441             :   const Int_t ktimen = 500;
     442             :   const Float_t kftimen = 500.;
     443             :   const Int_t kpadrn = 500;
     444             :   const Float_t kfpadrn = 500.;
     445             : 
     446             : 
     447             : 
     448             :   static Float_t prfinner[2*kpadrn][5*kpadn];  //pad divided by 50
     449             :   static Float_t prfouter1[2*kpadrn][5*kpadn];  //prfouter division
     450             :   static Float_t prfouter2[2*kpadrn][5*kpadn];
     451             :   static Float_t kTanMax =0;
     452             : 
     453             :   static Float_t rftime[5*ktimen];         //time division
     454             :   static Int_t blabla=0;
     455             :   static Float_t zoffset=0;
     456             :   static Float_t zwidth=0;
     457             :   static Float_t zoffset2=0;
     458             :   static TH1F * hdiff=0;
     459             :   static TH1F * hdiff1=0;
     460             :   static TH1F * hdiff2=0;
     461             : 
     462     4922857 :   if (blabla==0) {  //calculate Response function - only at the begginning
     463           1 :     kTanMax = TMath::ATan(10.*TMath::DegToRad());
     464           2 :     hdiff =new TH1F("prf_diff","prf_diff",10000,-1,1);
     465           2 :     hdiff1 =new TH1F("no_repsonse1","no_response1",10000,-1,1);
     466           2 :     hdiff2 =new TH1F("no_response2","no_response2",10000,-1,1);
     467             : 
     468           1 :     blabla=1;
     469           1 :     zoffset = GetZOffset();
     470           1 :     zwidth  = fZWidth;
     471           1 :     zoffset2 = zoffset/zwidth;
     472        5002 :     for (Int_t i=0;i<5*ktimen;i++){
     473        2500 :       rftime[i] = fTimeRF->GetRF(((i-2.5*kftimen)/kftimen)*zwidth+zoffset);
     474             :     }
     475        5002 :     for (Int_t i=0;i<5*kpadn;i++){
     476     5005000 :       for (Int_t j=0;j<2*kpadrn;j++){
     477     2500000 :         prfinner[j][i] =
     478     7500000 :           fInnerPRF->GetPRF((i-2.5*kfpadn)/kfpadn
     479     5000000 :                             *fInnerPadPitchWidth,(j-kfpadrn)/kfpadrn*fInnerPadPitchLength);
     480     2500000 :         prfouter1[j][i] =
     481     7500000 :           fOuter1PRF->GetPRF((i-2.5*kfpadn)/kfpadn
     482     5000000 :                             *fOuterPadPitchWidth,(j-kfpadrn)/kfpadrn*fOuter1PadPitchLength);
     483             : 
     484             :         //
     485     2500000 :         prfouter2[j][i] =
     486     7500000 :           fOuter2PRF->GetPRF((i-2.5*kfpadn)/kfpadn
     487     5000000 :                             *fOuterPadPitchWidth,(j-kfpadrn)/kfpadrn*fOuter2PadPitchLength);
     488             :       }
     489             :     }
     490           1 :   } // the above is calculated only once
     491             : 
     492             :   // calculate central padrow, pad, time
     493     4922857 :   Int_t npads = GetNPads(index[1],index[3]-1);
     494     4922857 :   Int_t cpadrow = index[2]; // electrons are here
     495     4922857 :   Int_t cpad    = TMath::Nint(xyz[1]);
     496     4922857 :   Int_t ctime   = TMath::Nint(xyz[2]+zoffset2+xyz[3]);
     497             :   //calulate deviation
     498     4922857 :   Float_t dpadrow = xyz[0];
     499     4922857 :   Float_t dpad    = xyz[1]-cpad;
     500     4922857 :   Float_t dtime   = xyz[2]+zoffset2+xyz[3]-ctime+phase*0.25;
     501             :   Int_t cindex =0;
     502             :   Int_t cindex3 =0;
     503     4922857 :   Int_t maxt =GetMaxTBin();
     504             : 
     505             :   Int_t fpadrow;
     506             :   Int_t lpadrow;
     507             : 
     508     4922857 :   if (row>=0) { //if we are interesting about given pad row
     509     4922857 :     fpadrow = row-cpadrow;
     510             :     lpadrow = row-cpadrow;
     511     4922857 :   }else{
     512           0 :     fpadrow = (index[2]>1) ? -1 :0;
     513           0 :     lpadrow = (index[2]<GetNRow(index[1])-1) ? 1:0;
     514             :   }
     515             : 
     516    10035805 :   Int_t fpad =  (cpad > -npads/2+1) ? -2: -npads/2-cpad;
     517    10130498 :   Int_t lpad =  (cpad < npads/2-2)  ?  2: npads/2-1-cpad;
     518     4922857 :   Int_t ftime =  (ctime>1) ? -2: -ctime;
     519     9845714 :   Int_t ltime =  (ctime<maxt-2) ? 2: maxt-ctime-1;
     520             : 
     521             :   // cross talk from long pad to short one
     522     4922857 :   if(row==fNRowUp1 && fpadrow==-1) {
     523        6339 :     dpadrow *= fOuter2PadPitchLength;
     524        6339 :     dpadrow += fOuterWWPitch;
     525        6339 :     dpadrow /= fOuter1PadPitchLength;
     526        6339 :   }
     527             :   // cross talk from short pad to long one
     528     4922857 :   if(row==fNRowUp1+1 && fpadrow==1){
     529        3702 :     dpadrow *= fOuter1PadPitchLength;
     530        5502 :     if(dpadrow < 0.) dpadrow = -1.; //protection against 3rd wire
     531        3702 :     dpadrow += fOuterWWPitch;
     532        3702 :     dpadrow /= fOuter2PadPitchLength;
     533             : 
     534        3702 :   }
     535             : 
     536             :   // "normal"
     537     4922857 :   Int_t apadrow = TMath::Nint((dpadrow-fpadrow)*kfpadrn+kfpadrn);
     538    19691428 :   for (Int_t ipadrow = fpadrow; ipadrow<=lpadrow;ipadrow++){
     539     4922857 :     if ( (apadrow<0) || (apadrow>=2*kpadrn))
     540             :       continue;
     541             :     // pad angular correction
     542             :     Float_t angle = 0.;
     543     3281524 :     if (npads != 0)
     544     3281524 :       angle = kTanMax*2.*(cpad+0.5)/Float_t(npads);
     545             :     Float_t dpadangle =0;
     546     3281524 :     if (index[1]<fNInnerSector){
     547     1923772 :       dpadangle = angle*dpadrow*fInnerPadPitchLength/fInnerPadPitchWidth;
     548     1923772 :     }
     549             :     else{
     550     2715504 :       if(row < fNRowUp1+1){
     551     2021183 :         dpadangle    = angle*dpadrow*fOuter1PadPitchLength/fOuterPadPitchWidth;
     552      663431 :       }
     553             :       else {
     554      694321 :         dpadangle    = angle*dpadrow*fOuter2PadPitchLength/fOuterPadPitchWidth;
     555             :       }
     556             :     }
     557     4917681 :     if (ipadrow==0) dpadangle *=-1;
     558             :     //
     559             :     //    Int_t apad= TMath::Nint((dpad-fpad)*kfpadn+2.5*kfpadn);
     560     3281524 :     Int_t apad= TMath::Nint((dpad+dpadangle-fpad)*kfpadn+2.5*kfpadn);
     561    37503658 :     for (Int_t ipad = fpad; ipad<=lpad;ipad++){
     562             :         Float_t cweight;
     563    15470305 :         if (index[1]<fNInnerSector){
     564     9041086 :           cweight=prfinner[apadrow][apad];
     565     9041086 :         }
     566             :         else{
     567    12858438 :           if(row < fNRowUp1+1){
     568     9528827 :             cweight=prfouter1[apadrow][apad];
     569     3099608 :           }
     570             :           else {
     571     3329611 :             cweight=prfouter2[apadrow][apad];
     572             :           }
     573             :         }
     574             :         //      if (cweight<fResponseThreshold) continue;
     575    15470305 :         Int_t atime = TMath::Nint((dtime-ftime)*kftimen+2.5*kftimen);
     576   185643660 :         for (Int_t itime = ftime;itime<=ltime;itime++){
     577    77351525 :           Float_t cweight2 = cweight*rftime[atime];
     578    77351525 :           if (cweight2>fResponseThreshold) {
     579    51841029 :             fResponseBin[cindex3++]=cpadrow+ipadrow;
     580    51841029 :             fResponseBin[cindex3++]=cpad+ipad;
     581    51841029 :             fResponseBin[cindex3++]=ctime+itime;
     582    51841029 :             fResponseWeight[cindex++]=cweight2;
     583    51841029 :           }
     584    77351525 :           atime-=ktimen;
     585             :         }
     586    15470305 :         apad-= kpadn;
     587             :     }
     588     3281524 :     apadrow-=kpadrn;
     589     3281524 :   }
     590     4922857 :   fCurrentMax=cindex;
     591             :   return fCurrentMax;
     592             : 
     593     4922857 : }
     594             : 
     595             : 
     596             : 
     597             : 
     598             : 
     599             : 
     600             : 

Generated by: LCOV version 1.11