File indexing completed on 2024-04-06 11:58:08
0001 #include "CalibCalorimetry/HcalAlgos/interface/HcalShapeIntegrator.h"
0002
0003 #include <iostream>
0004 HcalShapeIntegrator::HcalShapeIntegrator(const HcalPulseShapes::Shape* shape) : nbin_(shape->nbins()), v_(nbin_, 0.) {
0005 for (int t = 0; t < nbin_; ++t) {
0006 double amount = shape->at(t);
0007 for (int ibin = t; ibin < nbin_; ++ibin) {
0008
0009 v_[ibin] += amount;
0010 }
0011 }
0012 }
0013
0014 float HcalShapeIntegrator::at(double t) const {
0015
0016
0017 int i = (int)(t - 0.5);
0018 float rv = 0;
0019 if (i < 0) {
0020 rv = 0.;
0021 } else if (i >= nbin_) {
0022 rv = v_.back();
0023 } else {
0024 rv = v_[i];
0025
0026
0027 float f = (t - 0.5 - i);
0028 if (++i < nbin_ && f > 0) {
0029 rv = rv * (1. - f) + v_[i] * f;
0030 }
0031 }
0032 return rv;
0033 }
0034
0035 float HcalShapeIntegrator::operator()(double startTime, double stopTime) const { return at(stopTime) - at(startTime); }