test
CMS 3D CMS Logo

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