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::unfold(const SiStripCluster& clus, const float x) {
8  auto const& q = clus.amplitudes();
9  const stats_t<float> suppressed(-5, 100);
10  const stats_t<float> saturated(254, 400);
11 #define STATS(value) ((value < 254) ? stats_t<float>(value) : saturated)
12 
13  const unsigned N = q.size();
14  std::vector<stats_t<float> > Q(N + 2, stats_t<float>(0));
15  Q[0] = Q[N + 1] = suppressed;
16 
17  if (N == 1) //optimize N==1
18  Q[1] = STATS(q[0]) / (1 - 2 * x);
19  else if (N == 2) { //optimize N==2
20  const double A = 1 - 2 * x;
21  const stats_t<float> q0 = STATS(q[0]);
22  const stats_t<float> q1 = STATS(q[1]);
23  Q[1] = (A * q0 - x * q1) / (A * A - x * x);
24  Q[2] = (A * q1 - x * q0) / (A * A - x * x);
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]);
31  if (i != j)
32  Q[j + 1] += Cij * STATS(q[i]);
33  if (N != i + j + 1) {
34  Q[N - i] += Cij * STATS(q[N - j - 1]);
35  if (i != j)
36  Q[N - j] += Cij * STATS(q[N - i - 1]);
37  }
38  }
39  }
40  }
41 #undef STATS
42  return Q;
43  }
44 
45  InverseCrosstalkMatrix::InverseCrosstalkMatrix(const unsigned N, const float x)
46  : N(x > 0 ? N : 0),
47  sq(sqrt(-x * 4 + 1)),
48  lambdaP(1 + (1 + sq) / (-x * 2)),
49  lambdaM(1 + (1 - sq) / (-x * 2)),
50  denominator(sq * (pow(lambdaP, N + 1) - pow(lambdaM, N + 1))) {}
51 
52  float InverseCrosstalkMatrix::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 
56  inline float InverseCrosstalkMatrix::element(const unsigned i, const unsigned j) const {
57  return (pow(lambdaM, N + 1 - i) - pow(lambdaP, N + 1 - i)) * (pow(lambdaM, j) - pow(lambdaP, j)) / denominator;
58  }
59 
60 } // namespace reco
#define STATS(value)
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
InverseCrosstalkMatrix(const unsigned N, const float x)
SiStripCluster const & amplitudes() const
T sqrt(T t)
Definition: SSEVec.h:23
static std::vector< stats_t< float > > unfold(const SiStripCluster &q, const float x)
#define N
Definition: blowfish.cc:9
float element(const unsigned, const unsigned) const
fixed size matrix
float x
Definition: APVGainStruct.h:7
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
float operator()(const unsigned i, const unsigned j) const