CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ( const HcalPulseShapes::Shape aShape)

Definition at line 4 of file HcalShapeIntegrator.cc.

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

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

Member Function Documentation

float HcalShapeIntegrator::at ( double  time) const
private

Definition at line 19 of file HcalShapeIntegrator.cc.

References f, i, nbin_, and v_.

Referenced by operator()().

19  {
20  // shape is in 1 ns steps
21  // I round down to match the old algorithm
22  int i=(int)(t-0.5);
23  float rv=0;
24  if(i<0) {
25  rv = 0.;
26  } else if(i >= nbin_) {
27  rv = v_.back();
28  } else {
29  rv=v_[i];
30  // maybe interpolate
31  // assume 1 ns bins
32  float f = (t-0.5-i);
33  if(++i < nbin_ && f > 0) {
34  rv = rv*(1.-f)+ v_[i]*f;
35  }
36  }
37  return rv;
38 }
int i
Definition: DBlmapReader.cc:9
double f[11][100]
std::vector< float > v_
float HcalShapeIntegrator::operator() ( double  startTime,
double  stopTime 
) const

Definition at line 41 of file HcalShapeIntegrator.cc.

References at().

42 {
43  return at(stopTime) - at(startTime);
44 }
float at(double time) const

Member Data Documentation

int HcalShapeIntegrator::nbin_
private

Definition at line 21 of file HcalShapeIntegrator.h.

Referenced by at(), and HcalShapeIntegrator().

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

Definition at line 22 of file HcalShapeIntegrator.h.

Referenced by at(), and HcalShapeIntegrator().