CMS 3D CMS Logo

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