Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:08

0001 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShape.h"
0002 
0003 HcalPulseShape::HcalPulseShape() { nbin_ = 0; }
0004 
0005 HcalPulseShape::HcalPulseShape(const std::vector<double>& shape, unsigned nbin)
0006     : shape_(shape.begin(), shape.begin() + nbin), nbin_(nbin) {}
0007 
0008 void HcalPulseShape::setNBin(int n) {
0009   nbin_ = n;
0010   shape_ = std::vector<float>(n, 0.0f);
0011 }
0012 
0013 void HcalPulseShape::setShapeBin(int i, float f) {
0014   if (i >= 0 && i < nbin_)
0015     shape_[i] = f;
0016 }
0017 
0018 float HcalPulseShape::operator()(double t) const {
0019   // shape is in 1 ns steps
0020   return at(t);
0021 }
0022 
0023 float HcalPulseShape::at(double t) const {
0024   // shape is in 1 ns steps
0025   int i = (int)(t + 0.5);
0026   float rv = 0;
0027   if (i >= 0 && i < nbin_)
0028     rv = shape_[i];
0029   return rv;
0030 }
0031 
0032 float HcalPulseShape::integrate(double t1, double t2) const {
0033   static const float int_delta_ns = 0.05f;
0034   double intval = 0.0;
0035 
0036   for (double t = t1; t < t2; t += int_delta_ns) {
0037     float loedge = at(t);
0038     float hiedge = at(t + int_delta_ns);
0039     intval += (loedge + hiedge) * int_delta_ns / 2.0;
0040   }
0041   return (float)intval;
0042 }