CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalPulseContainmentCorrection.cc
Go to the documentation of this file.
4 
5 // Function generates a lookup map for a passed-in function (via templated object algoObject,
6 // which must contain method "calcpair" that spits out (x,y) pair from a type float seed.
7 // Each map y-value is separated from the previous value by a programmable fractional error
8 // relative to the previous value.
9 //
10 // Currently this function coded for only monotonically increasing or
11 // decreasing functions...
12 
14 
16 //
18  float fixedphase_ns,
19  float max_fracerror)
20 {
21  HcalPulseContainmentAlgo corFalgo(num_samples, (double)fixedphase_ns);
22 
23  // Generate lookup map for the correction function, never exceeding
24  // a maximum fractional error for lookups.
25  //
26  // static const double max_recofc = 5000.0f; // HPD,
27  // max_recofc = 200000.0f; // SiPMs
28  genlkupmap<HcalPulseContainmentAlgo> (1.0, 200000.0f, // generation domain
29  max_fracerror, // maximum fractional error
30  1.0, // min_xstep = minimum true fC increment
31  corFalgo,
32  mCorFactors_); // return lookup map
33 }
34 
35 // do the same, but with a shape passed in
37  const HcalPulseShape * shape,
38  int num_samples,
39  float fixedphase_ns,
40  float max_fracerror)
41 {
42  HcalPulseContainmentAlgo corFalgo(shape, num_samples, (double)fixedphase_ns);
43  genlkupmap<HcalPulseContainmentAlgo> (1.0, 200000.0f, // generation domain
44  max_fracerror, // maximum fractional error
45  1.0, // min_xstep = minimum true fC increment
46  corFalgo,
47  mCorFactors_); // return lookup map
48 }
49 
51 {
52  double correction;
53 
54  std::map<double,double>::const_iterator fcupper,fclower;
55 
56  fcupper = mCorFactors_.upper_bound(fc_ampl);
57  fclower = fcupper;
58  fclower--;
59 
60  if (fcupper == mCorFactors_.end()) {
61  correction = fclower->second;
62  }
63  else if (fcupper == mCorFactors_.begin()) {
64  correction = fcupper->second;
65  }
66  else {
67  if (fabs(fclower->first - fc_ampl) <
68  fabs(fcupper->first - fc_ampl) )
69  correction = fclower->second;
70  else
71  correction = fcupper->second;
72  }
73 
74 #if 0
75  char s[80];
76  sprintf (s, "%7.1f (%8.5f %8.5f) (%8.5f %8.5f) %8.5f",
77  fc_ampl,
78  fclower->first, fclower->second,
79  fcupper->first, fcupper->second,
80  correction);
81  cout << s << endl;
82 #endif
83 
84  return correction;
85 }
double getCorrection(double fc_ampl) const
HcalPulseContainmentCorrection(int num_samples, float fixedphase_ns, float max_fracerror)
Generate energy correction factors based on a predetermined phase of the hit + time slew...
tuple cout
Definition: gather_cfg.py:121