CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalShapeIntegrator.cc
Go to the documentation of this file.
2 
3 #include <iostream>
5  nbin_(shape->nbins()),
6  v_(nbin_, 0.)
7 {
8  for(int t = 0; t < nbin_; ++t)
9  {
10  double amount = shape->at(t);
11  for(int ibin = t; ibin < nbin_; ++ibin)
12  {
13  // v_ holds the cumulative integral
14  v_[ibin] += amount;
15  }
16  }
17 }
18 
19 float HcalShapeIntegrator::at(double t) const {
20  // shape is in 1 ns steps
21  // I round down to match the old algorithm
22  int i=(int)(t-0.5);
23  float rv=0;
24  if(i<0) {
25  rv = 0.;
26  } else if(i >= nbin_) {
27  rv = v_.back();
28  } else {
29  rv=v_[i];
30  // maybe interpolate
31  // assume 1 ns bins
32  float f = (t-0.5-i);
33  if(++i < nbin_ && f > 0) {
34  rv = rv*(1.-f)+ v_[i]*f;
35  }
36  }
37  return rv;
38 }
39 
40 float
41 HcalShapeIntegrator::operator()(double startTime, double stopTime) const
42 {
43  return at(stopTime) - at(startTime);
44 }
45 
46 
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
float at(double time) const
HcalShapeIntegrator(const HcalPulseShapes::Shape *aShape)
float at(double time) const
double f[11][100]
float operator()(double startTime, double stopTime) const
std::vector< float > v_