CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CastorPulseShapes.cc
Go to the documentation of this file.
2 #include <cmath>
3 
5  // computeHPDShape(hpdShape_);
7 }
8 
10  // cout << endl << " ===== computeShapeHF !!! " << endl << endl;
11 
12  const float ts = 3.0; // time constant in t * exp(-(t/ts)**2)
13 
14  // first create pulse shape over a range of time 0 ns to 255 ns in 1 ns steps
15  int nbin = 256;
16  sh.setNBin(nbin);
17  std::vector<float> ntmp(nbin, 0.0); //
18 
19  int j;
20  float norm;
21 
22  // CASTOR SHAPE
23  norm = 0.0;
24  for (j = 0; j < 3 * ts && j < nbin; j++) {
25  ntmp[j] = ((float)j) * exp(-((float)(j * j)) / (ts * ts));
26  norm += ntmp[j];
27  }
28  // normalize pulse area to 1.0
29  for (j = 0; j < 3 * ts && j < nbin; j++) {
30  ntmp[j] /= norm;
31 
32  // cout << " nt [" << j << "] = " << ntmp[j] << endl;
33  sh.setShapeBin(j, ntmp[j]);
34  }
35 }
36 
38  nbin_ = 0;
39  tpeak_ = 0;
40 }
41 
43  nbin_ = n;
44  shape_ = std::vector<float>(n, 0.0f);
45 }
46 
48  if (i >= 0 && i < nbin_)
49  shape_[i] = f;
50 }
51 
53  // shape is in 1 ns steps
54  int i = (int)(t + 0.5);
55  float rv = 0;
56  if (i >= 0 && i < nbin_)
57  rv = shape_[i];
58  return rv;
59 }
60 
61 float CastorPulseShapes::Shape::at(double t) const {
62  // shape is in 1 ns steps
63  int i = (int)(t + 0.5);
64  float rv = 0;
65  if (i >= 0 && i < nbin_)
66  rv = shape_[i];
67  return rv;
68 }
69 
70 float CastorPulseShapes::Shape::integrate(double t1, double t2) const {
71  static const float int_delta_ns = 0.05f;
72  double intval = 0.0;
73 
74  for (double t = t1; t < t2; t += int_delta_ns) {
75  float loedge = at(t);
76  float hiedge = at(t + int_delta_ns);
77  intval += (loedge + hiedge) * int_delta_ns / 2.0;
78  }
79 
80  return (float)intval;
81 }
float operator()(double time) const
float at(double time) const
void setShapeBin(int i, float f)
void computeCastorShape(Shape &s)
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
float integrate(double tmin, double tmax) const