CMS 3D CMS Logo

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 }
CastorPulseShapes::Shape::setNBin
void setNBin(int n)
Definition: CastorPulseShapes.cc:42
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CastorPulseShapes::Shape::tpeak_
float tpeak_
Definition: CastorPulseShapes.h:27
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CastorPulseShapes::Shape::nbin_
int nbin_
Definition: CastorPulseShapes.h:26
CastorPulseShapes::computeCastorShape
void computeCastorShape(Shape &s)
Definition: CastorPulseShapes.cc:9
CastorPulseShapes::Shape::setShapeBin
void setShapeBin(int i, float f)
Definition: CastorPulseShapes.cc:47
CastorPulseShapes::Shape::integrate
float integrate(double tmin, double tmax) const
Definition: CastorPulseShapes.cc:70
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
CastorPulseShapes::Shape::at
float at(double time) const
Definition: CastorPulseShapes.cc:61
CastorPulseShapes::Shape::Shape
Shape()
Definition: CastorPulseShapes.cc:37
CastorPulseShapes.h
CastorPulseShapes::CastorPulseShapes
CastorPulseShapes()
Definition: CastorPulseShapes.cc:4
CastorPulseShapes::Shape::operator()
float operator()(double time) const
Definition: CastorPulseShapes.cc:52
createfilelist.int
int
Definition: createfilelist.py:10
CastorPulseShapes::castorShape_
Shape castorShape_
Definition: CastorPulseShapes.h:33
CastorPulseShapes::Shape
Definition: CastorPulseShapes.h:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644