CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
11  gsl_complex z[3];
12  double w = -inpes;
13  // normalize params
14  double a = a2/w;
15  double b = b1/w;
16  double c = c0/w;
17  int nroots = gsl_poly_complex_solve_cubic(a, b, c, &z[1], &z[2], &z[3]);
18  assert(nroots);
19 
20  // all use cases tested over the full range of anticipated values;
21  // the first root is always the right one.
22  double realpix = 0;
23  // find real roots
24  for(int i = 0; i < 3; ++i){
25  if(z[i].dat[1]==0){
26  realpix = z[i].dat[0];
27  break;
28  }
29  }
30 
31  return realpix > 0 ? (int)(realpix+0.5) : 0;
32 }
int i
Definition: DBlmapReader.cc:9
const double w
Definition: UKUtility.cc:23
assert(m_qm.get())
int getPixelsFired(int inpes) const
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121