CMS 3D CMS Logo

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