CMS 3D CMS Logo

HcalShapeIntegrator.cc
Go to the documentation of this file.
2 
3 #include <iostream>
4 HcalShapeIntegrator::HcalShapeIntegrator(const HcalPulseShapes::Shape* shape) : nbin_(shape->nbins()), v_(nbin_, 0.) {
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); }
mps_fire.i
i
Definition: mps_fire.py:355
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
HcalShapeIntegrator::v_
std::vector< float > v_
Definition: HcalShapeIntegrator.h:21
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
OrderedSet.t
t
Definition: OrderedSet.py:90
createfilelist.int
int
Definition: createfilelist.py:10
HcalShapeIntegrator::at
float at(double time) const
Definition: HcalShapeIntegrator.cc:14
HcalPulseShape
Definition: HcalPulseShape.h:6
HcalShapeIntegrator::operator()
float operator()(double startTime, double stopTime) const
Definition: HcalShapeIntegrator.cc:35
HcalShapeIntegrator::HcalShapeIntegrator
HcalShapeIntegrator(const HcalPulseShapes::Shape *aShape)
Definition: HcalShapeIntegrator.cc:4
HcalPulseShape::at
float at(double time) const
Definition: HcalPulseShape.cc:23
HcalShapeIntegrator::nbin_
int nbin_
Definition: HcalShapeIntegrator.h:20
HcalShapeIntegrator.h