CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

HcalShapeIntegrator Class Reference

#include <HcalShapeIntegrator.h>

List of all members.

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_, lumiQTWidget::t, and v_.

                                                                            :
  nbin_(shape->nbins()),
  v_(nbin_, 0.)
{
  for(int t = 0; t < nbin_; ++t) 
  {
    double amount = shape->at(t);
    for(int ibin = t; ibin < nbin_; ++ibin) 
    {
      // v_ holds the cumulative integral
      v_[ibin] += amount;
    }
  }
}

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()().

                                            {
  // shape is in 1 ns steps
  // I round down to match the old algorithm
  int i=(int)(t-0.5);
  float rv=0;
  if(i<0) {
    rv = 0.;
  } else if(i >= nbin_) {
    rv = v_.back();
  } else {
    rv=v_[i];
    // maybe interpolate
    // assume 1 ns bins
    float f = (t-0.5-i);
    if(++i < nbin_ && f > 0) {
      rv = rv*(1.-f)+ v_[i]*f;
    }
  }
  return rv;
}
float HcalShapeIntegrator::operator() ( double  startTime,
double  stopTime 
) const

Definition at line 41 of file HcalShapeIntegrator.cc.

References at().

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

Member Data Documentation

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().