Go to the documentation of this file.00001 #include "CalibCalorimetry/HcalAlgos/interface/HcalShapeIntegrator.h"
00002
00003 #include <iostream>
00004 HcalShapeIntegrator::HcalShapeIntegrator( const HcalPulseShapes::Shape* shape ) :
00005 nbin_(shape->nbins()),
00006 v_(nbin_, 0.)
00007 {
00008 for(int t = 0; t < nbin_; ++t)
00009 {
00010 double amount = shape->at(t);
00011 for(int ibin = t; ibin < nbin_; ++ibin)
00012 {
00013
00014 v_[ibin] += amount;
00015 }
00016 }
00017 }
00018
00019 float HcalShapeIntegrator::at(double t) const {
00020
00021
00022 int i=(int)(t-0.5);
00023 float rv=0;
00024 if(i<0) {
00025 rv = 0.;
00026 } else if(i >= nbin_) {
00027 rv = v_.back();
00028 } else {
00029 rv=v_[i];
00030
00031
00032 float f = (t-0.5-i);
00033 if(++i < nbin_ && f > 0) {
00034 rv = rv*(1.-f)+ v_[i]*f;
00035 }
00036 }
00037 return rv;
00038 }
00039
00040 float
00041 HcalShapeIntegrator::operator()(double startTime, double stopTime) const
00042 {
00043 return at(stopTime) - at(startTime);
00044 }
00045
00046