CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/CalibCalorimetry/HcalAlgos/src/HcalPulseShape.cc

Go to the documentation of this file.
00001 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseShape.h"
00002 
00003 HcalPulseShape::HcalPulseShape() {
00004   nbin_=0;
00005   tpeak_=0;
00006 }
00007 
00008 void HcalPulseShape::setNBin(int n) {
00009   nbin_=n;
00010   shape_=std::vector<float>(n,0.0f);
00011 }
00012 
00013 void HcalPulseShape::setShapeBin(int i, float f) {
00014   if (i>=0 && i<nbin_) shape_[i]=f;
00015 }
00016 
00017 float HcalPulseShape::operator()(double t) const {
00018   // shape is in 1 ns steps
00019   return at(t);
00020 }
00021 
00022 float HcalPulseShape::at(double t) const {
00023   // shape is in 1 ns steps
00024   int i=(int)(t+0.5);
00025   float rv=0;
00026   if (i>=0 && i<nbin_) rv=shape_[i];
00027   return rv;
00028 }
00029 
00030 float HcalPulseShape::integrate(double t1, double t2) const {
00031   static const float int_delta_ns = 0.05f;
00032   double intval = 0.0;
00033 
00034   for (double t = t1; t < t2; t+= int_delta_ns) {
00035     float loedge = at(t);
00036     float hiedge = at(t+int_delta_ns);
00037     intval += (loedge+hiedge)*int_delta_ns/2.0;
00038   }
00039   return (float)intval;
00040 }
00041