CMS 3D CMS Logo

HcalShapeIntegrator.cc
Go to the documentation of this file.
2 
3 #include <iostream>
5  for (int t = 0; t < nbin_; ++t) {
6  double amount = shape->at(t);
7  for (int ibin = t; ibin < nbin_; ++ibin) {
8  // v_ holds the cumulative integral
9  v_[ibin] += amount;
10  }
11  }
12 }
13 
14 float HcalShapeIntegrator::at(double t) const {
15  // shape is in 1 ns steps
16  // I round down to match the old algorithm
17  int i = (int)(t - 0.5);
18  float rv = 0;
19  if (i < 0) {
20  rv = 0.;
21  } else if (i >= nbin_) {
22  rv = v_.back();
23  } else {
24  rv = v_[i];
25  // maybe interpolate
26  // assume 1 ns bins
27  float f = (t - 0.5 - i);
28  if (++i < nbin_ && f > 0) {
29  rv = rv * (1. - f) + v_[i] * f;
30  }
31  }
32  return rv;
33 }
34 
35 float HcalShapeIntegrator::operator()(double startTime, double stopTime) const { return at(stopTime) - at(startTime); }
HcalShapeIntegrator(const HcalPulseShapes::Shape *aShape)
double f[11][100]
float operator()(double startTime, double stopTime) const
std::vector< float > v_
float at(double time) const