CMS 3D CMS Logo

HcalPulseShape.cc
Go to the documentation of this file.
2 
4 
5 HcalPulseShape::HcalPulseShape(const std::vector<double>& shape, unsigned nbin)
6  : shape_(shape.begin(), shape.begin() + nbin), nbin_(nbin) {}
7 
9  nbin_ = n;
10  shape_ = std::vector<float>(n, 0.0f);
11 }
12 
13 void HcalPulseShape::setShapeBin(int i, float f) {
14  if (i >= 0 && i < nbin_)
15  shape_[i] = f;
16 }
17 
18 float HcalPulseShape::operator()(double t) const {
19  // shape is in 1 ns steps
20  return at(t);
21 }
22 
23 float HcalPulseShape::at(double t) const {
24  // shape is in 1 ns steps
25  int i = (int)(t + 0.5);
26  float rv = 0;
27  if (i >= 0 && i < nbin_)
28  rv = shape_[i];
29  return rv;
30 }
31 
32 float HcalPulseShape::integrate(double t1, double t2) const {
33  static const float int_delta_ns = 0.05f;
34  double intval = 0.0;
35 
36  for (double t = t1; t < t2; t += int_delta_ns) {
37  float loedge = at(t);
38  float hiedge = at(t + int_delta_ns);
39  intval += (loedge + hiedge) * int_delta_ns / 2.0;
40  }
41  return (float)intval;
42 }
void setNBin(int n)
void setShapeBin(int i, float f)
float integrate(double tmin, double tmax) const
std::vector< float > shape_
double f[11][100]
float operator()(double time) const
float at(double time) const