CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoLocalTracker/SiStripRecHitConverter/src/CrosstalkInversion.cc

Go to the documentation of this file.
00001 #include "RecoLocalTracker/SiStripRecHitConverter/interface/CrosstalkInversion.h"
00002 
00003 namespace reco {
00004 
00005 std::vector<stats_t<float> > InverseCrosstalkMatrix::
00006 unfold(const std::vector<uint8_t>& q, const float x) {
00007   const stats_t<float> suppressed(-5,100);
00008   const stats_t<float> saturated(254,400);
00009   #define STATS(value) ( (value<254) ? stats_t<float>(value) : saturated )
00010 
00011   const unsigned N=q.size();
00012   std::vector<stats_t<float> > Q(N+2,stats_t<float>(0));
00013   Q[0] = Q[N+1] = suppressed;
00014 
00015   if(N==1)                                 //optimize N==1
00016     Q[1] = STATS(q[0])/(1-2*x);  
00017   else if(N==2) {                          //optimize N==2
00018     const double A=1-2*x; 
00019     const stats_t<float> q0 = STATS(q[0]);
00020     const stats_t<float> q1 = STATS(q[1]);
00021     Q[1] = ( A*q0 -x*q1 ) / (A*A-x*x);
00022     Q[2] = ( A*q1 -x*q0 ) / (A*A-x*x);
00023   } 
00024   else {                                   //general case
00025     const InverseCrosstalkMatrix inverse(N,x);  
00026     for(unsigned i=0; i<(N+1)/2; i++) {
00027       for(unsigned j=i; j<N-i; j++) {
00028         const float Cij = inverse(i+1,j+1);
00029         Q[i+1] += Cij * STATS(q[  j  ]) ;  if( i!=j)   
00030         Q[j+1] += Cij * STATS(q[  i  ]) ;  if( N!=i+j+1) {
00031         Q[N-i] += Cij * STATS(q[N-j-1]) ;  if( i!=j)
00032         Q[N-j] += Cij * STATS(q[N-i-1]) ;
00033         }
00034       }
00035     }
00036   }
00037   #undef STATS
00038   return Q;
00039 }
00040 
00041 InverseCrosstalkMatrix::
00042 InverseCrosstalkMatrix(const unsigned N, const float x)
00043   : N( x>0 ? N : 0 ),
00044     sq( sqrt(-x*4+1)),
00045     lambdaP( 1+(1+sq)/(-x*2) ),
00046     lambdaM( 1+(1-sq)/(-x*2) ),
00047     denominator( sq * ( pow(lambdaP,N+1) - pow(lambdaM,N+1) ) )
00048 {}
00049 
00050 float InverseCrosstalkMatrix::
00051 operator()(const unsigned i, const unsigned j) const
00052 { return N==0 || std::isinf(denominator) ? i==j : i>=j ? element(i,j) : element(j,i) ; }
00053 
00054 inline
00055 float InverseCrosstalkMatrix::
00056 element(const unsigned i, const unsigned j) const 
00057 { return ( pow(lambdaM,N+1-i) - pow(lambdaP,N+1-i) ) * ( pow(lambdaM,j) - pow(lambdaP,j) ) / denominator; }
00058 
00059 }