CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CrosstalkInversion.cc
Go to the documentation of this file.
3 
4 namespace reco {
5 
6 std::vector<stats_t<float> > InverseCrosstalkMatrix::
7 unfold(const std::vector<uint8_t>& q, const float x) {
8  const stats_t<float> suppressed(-5,100);
9  const stats_t<float> saturated(254,400);
10  #define STATS(value) ( (value<254) ? stats_t<float>(value) : saturated )
11 
12  const unsigned N=q.size();
13  std::vector<stats_t<float> > Q(N+2,stats_t<float>(0));
14  Q[0] = Q[N+1] = suppressed;
15 
16  if(N==1) //optimize N==1
17  Q[1] = STATS(q[0])/(1-2*x);
18  else if(N==2) { //optimize N==2
19  const double A=1-2*x;
20  const stats_t<float> q0 = STATS(q[0]);
21  const stats_t<float> q1 = STATS(q[1]);
22  Q[1] = ( A*q0 -x*q1 ) / (A*A-x*x);
23  Q[2] = ( A*q1 -x*q0 ) / (A*A-x*x);
24  }
25  else { //general case
26  const InverseCrosstalkMatrix inverse(N,x);
27  for(unsigned i=0; i<(N+1)/2; i++) {
28  for(unsigned j=i; j<N-i; j++) {
29  const float Cij = inverse(i+1,j+1);
30  Q[i+1] += Cij * STATS(q[ j ]) ; if( i!=j)
31  Q[j+1] += Cij * STATS(q[ i ]) ; if( N!=i+j+1) {
32  Q[N-i] += Cij * STATS(q[N-j-1]) ; if( i!=j)
33  Q[N-j] += Cij * STATS(q[N-i-1]) ;
34  }
35  }
36  }
37  }
38  #undef STATS
39  return Q;
40 }
41 
43 InverseCrosstalkMatrix(const unsigned N, const float x)
44  : N( x>0 ? N : 0 ),
45  sq( sqrt(-x*4+1)),
46  lambdaP( 1+(1+sq)/(-x*2) ),
47  lambdaM( 1+(1-sq)/(-x*2) ),
48  denominator( sq * ( pow(lambdaP,N+1) - pow(lambdaM,N+1) ) )
49 {}
50 
52 operator()(const unsigned i, const unsigned j) const
53 { return N==0 || edm::isNotFinite(denominator) ? i==j : i>=j ? element(i,j) : element(j,i) ; }
54 
55 inline
57 element(const unsigned i, const unsigned j) const
58 { return ( pow(lambdaM,N+1-i) - pow(lambdaP,N+1-i) ) * ( pow(lambdaM,j) - pow(lambdaP,j) ) / denominator; }
59 
60 }
#define STATS(value)
int i
Definition: DBlmapReader.cc:9
float operator()(const unsigned i, const unsigned j) const
InverseCrosstalkMatrix(const unsigned N, const float x)
bool isNotFinite(T x)
Definition: isFinite.h:10
list denominator
Definition: cuy.py:484
T sqrt(T t)
Definition: SSEVec.h:48
int j
Definition: DBlmapReader.cc:9
#define N
Definition: blowfish.cc:9
double q1[4]
Definition: TauolaWrapper.h:87
Definition: DDAxes.h:10
float element(const unsigned, const unsigned) const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
static std::vector< stats_t< float > > unfold(const std::vector< uint8_t > &q, const float x)