CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalPulseContainmentAlgo.cc
Go to the documentation of this file.
4 #include <cmath>
5 #include <iostream>
6 
7 // Function generates a lookup map for a passed-in function (via templated object algoObject,
8 // which must contain method "calcpair" that spits out (x,y) pair from a type float seed.
9 // Each map y-value is separated from the previous value by a programmable fractional error
10 // relative to the previous value.
11 //
12 HcalPulseContainmentAlgo::HcalPulseContainmentAlgo(int num_samples, double fixedphase_ns)
13 : fixedphasens_(fixedphase_ns),
14  integrator_(&(HcalPulseShapes().hbShape()))
15 {
16  init(num_samples);
17 }
18 
20  (const HcalPulseShape * shape, int num_samples, double fixedphase_ns)
21 : fixedphasens_(fixedphase_ns),
22  integrator_(shape)
23 {
24  init(num_samples);
25 }
26 
27 void
29 {
30  const int binsize_ns = 25;
31 
32  // First set up controlling parameters for calculating the correction factor:
33  // Integration window size...
34  //
35  integrationwindowns_ = (double)(binsize_ns*num_samples);
36 
37  // First find the point at which time bin "1" exceeds time bin "0",
38  // and call that point "time 0".
39  //
40  for (int shift_ns=0; shift_ns<binsize_ns; shift_ns++) {
41 
42  // Digitize by integrating to find all time sample
43  // bin values for this shift.
44  //
45  double tmin = -(double)shift_ns;
46  double bin0val = (double) integrator_(tmin, tmin+binsize_ns);
47  double bin1val = (double) integrator_(tmin+binsize_ns, tmin+2*binsize_ns);
48 
49 #if 0
50  char s[80];
51  sprintf (s, "%7.3f %8.5f %8.5f\n", tmin, bin0val, bin1val);
52  cout << s;
53 #endif
54 
55  if (bin1val > bin0val) {
56  time0shiftns_ = shift_ns;
57  break;
58  }
59  }
60 
61 #if 0
62  cout << "time0shiftns_ = " << time0shiftns_ << endl;
63 #endif
64 }
65 
66 std::pair<double,double>
68 {
69  double timeslew_ns = HcalTimeSlew::delay(std::max(0.0,(double)truefc),
71  double shift_ns = fixedphasens_ - time0shiftns_ + timeslew_ns;
72  //std::cout << "SHIFT " << fixedphasens_ << " " << time0shiftns_ << " " << timeslew_ns << std::endl;
73  double tmin = -shift_ns;
74  double tmax = tmin+integrationwindowns_;
75 
76  //double integral = shape_.integrate( tmin, tmax );
77  double integral = integrator_(tmin, tmax);
78  //std::cout << "INTEGRAL " << integral << " " << truefc << " " << tmin << " " << tmax << std::endl;
79  double corfactor = 1.0/integral;
80  double recofc = (double)truefc * integral;
81 
82 #if 0
83  char s[80];
84  sprintf (s, "%8.2f %8.4f %8.4f %8.5f %8.5f %8.5f ",
85  truefc, tmin, tmax, integral, corfactor, recofc);
86  cout << s;
87 #endif
88 
89  std::pair<double,double> thepair(recofc,corfactor);
90  return thepair;
91 }
int init
Definition: HydjetWrapper.h:67
std::pair< double, double > calcpair(double)
HcalPulseContainmentAlgo(const HcalPulseShape *shape, int num_samples, double fixedphase_ns)
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
static const double tmax[3]
tuple cout
Definition: gather_cfg.py:121
static double delay(double fC, BiasSetting bias=Medium)
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:12