CMS 3D CMS Logo

HcalSiPMnonlinearity.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <gsl/gsl_poly.h>
3 #include <gsl/gsl_complex.h>
5 
6 // Assume parameters come to us from the reco side; i.e.,
7 // true pes = corfun(pixelsfired). But we want to invert that.
8 //
10  gsl_complex z[3];
11  double w = -inpes;
12  // normalize params
13  double a = a2 / w;
14  double b = b1 / w;
15  double c = c0 / w;
16  int nroots = gsl_poly_complex_solve_cubic(a, b, c, &z[1], &z[2], &z[3]);
17  assert(nroots);
18 
19  // all use cases tested over the full range of anticipated values;
20  // the first root is always the right one.
21  double realpix = 0;
22  // find real roots
23  for (int i = 0; i < 3; ++i) {
24  if (z[i].dat[1] == 0) {
25  realpix = z[i].dat[0];
26  break;
27  }
28  }
29 
30  return realpix > 0 ? (int)(realpix + 0.5) : 0;
31 }
T w() const
assert(be >=bs)
int getPixelsFired(int inpes) const
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119