CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalShapeIntegrator Class Reference

#include <HcalShapeIntegrator.h>

Public Member Functions

 HcalShapeIntegrator (const HcalPulseShapes::Shape *aShape)
 
float operator() (double startTime, double stopTime) const
 

Private Member Functions

float at (double time) const
 

Private Attributes

int nbin_
 
std::vector< float > v_
 

Detailed Description

This class takes an existing Shape, and integrates it, summing up all the values, each nanosecond

Definition at line 12 of file HcalShapeIntegrator.h.

Constructor & Destructor Documentation

◆ HcalShapeIntegrator()

HcalShapeIntegrator::HcalShapeIntegrator ( const HcalPulseShapes::Shape aShape)

Definition at line 4 of file HcalShapeIntegrator.cc.

4  : nbin_(shape->nbins()), v_(nbin_, 0.) {
5  for (int t = 0; t < nbin_; ++t) {
6  double amount = shape->at(t);
7  for (int ibin = t; ibin < nbin_; ++ibin) {
8  // v_ holds the cumulative integral
9  v_[ibin] += amount;
10  }
11  }
12 }

References HcalPulseShape::at(), nbin_, OrderedSet::t, and v_.

Member Function Documentation

◆ at()

float HcalShapeIntegrator::at ( double  time) const
private

Definition at line 14 of file HcalShapeIntegrator.cc.

14  {
15  // shape is in 1 ns steps
16  // I round down to match the old algorithm
17  int i = (int)(t - 0.5);
18  float rv = 0;
19  if (i < 0) {
20  rv = 0.;
21  } else if (i >= nbin_) {
22  rv = v_.back();
23  } else {
24  rv = v_[i];
25  // maybe interpolate
26  // assume 1 ns bins
27  float f = (t - 0.5 - i);
28  if (++i < nbin_ && f > 0) {
29  rv = rv * (1. - f) + v_[i] * f;
30  }
31  }
32  return rv;
33 }

References f, mps_fire::i, createfilelist::int, nbin_, OrderedSet::t, and v_.

Referenced by operator()().

◆ operator()()

float HcalShapeIntegrator::operator() ( double  startTime,
double  stopTime 
) const

Definition at line 35 of file HcalShapeIntegrator.cc.

35 { return at(stopTime) - at(startTime); }

References at().

Member Data Documentation

◆ nbin_

int HcalShapeIntegrator::nbin_
private

Definition at line 20 of file HcalShapeIntegrator.h.

Referenced by at(), and HcalShapeIntegrator().

◆ v_

std::vector<float> HcalShapeIntegrator::v_
private

Definition at line 21 of file HcalShapeIntegrator.h.

Referenced by at(), and HcalShapeIntegrator().

mps_fire.i
i
Definition: mps_fire.py:355
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
HcalShapeIntegrator::v_
std::vector< float > v_
Definition: HcalShapeIntegrator.h:21
OrderedSet.t
t
Definition: OrderedSet.py:90
createfilelist.int
int
Definition: createfilelist.py:10
HcalShapeIntegrator::at
float at(double time) const
Definition: HcalShapeIntegrator.cc:14
HcalShapeIntegrator::nbin_
int nbin_
Definition: HcalShapeIntegrator.h:20