CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
edm::RunningAverage Class Reference

#include <RunningAverage.h>

Public Member Functions

int mean () const
 
 RunningAverage (unsigned int k=4)
 
void update (unsigned int q)
 
int upper () const
 

Static Public Attributes

static constexpr int N = 16
 

Private Member Functions

friend int::test::running_average::test ()
 

Private Attributes

std::array< std::atomic< int >, Nm_buffer
 
std::atomic< int > m_curr
 
std::atomic< int > m_mean
 

Detailed Description

Definition at line 17 of file RunningAverage.h.

Constructor & Destructor Documentation

edm::RunningAverage::RunningAverage ( unsigned int  k = 4)
inlineexplicit

Definition at line 23 of file RunningAverage.h.

References mps_fire::i, and gen::k.

23  : m_mean(N*k), m_curr(0) {
24  for (auto & i : m_buffer) i=k;
25  }
std::array< std::atomic< int >, N > m_buffer
static constexpr int N
int k[5][pyjets_maxn]
std::atomic< int > m_mean
std::atomic< int > m_curr

Member Function Documentation

edm::RunningAverage::int::test::running_average::test ( )
private
int edm::RunningAverage::mean ( ) const
inline

Definition at line 27 of file RunningAverage.h.

References N.

27 { return m_mean/N;}
static constexpr int N
std::atomic< int > m_mean
void edm::RunningAverage::update ( unsigned int  q)
inline

Definition at line 31 of file RunningAverage.h.

References MillePedeFileConverter_cfg::e, and gen::k.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), HitPairGenerator::clear(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), MultiHitFromChi2EDProducer::produce(), PixelQuadrupletEDProducer::produce(), PixelQuadrupletMergerEDProducer::produce(), CAHitNtupletEDProducerT< T_Generator >::produce(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), HitQuadrupletGenerator::run(), HitTripletGenerator::run(), MultiHitGenerator::run(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

31  {
32  int e=m_curr;
33  while(!m_curr.compare_exchange_weak(e,e+1));
34  int k = (N-1)&e;
35  int old = m_buffer[k];
36  if (!m_buffer[k].compare_exchange_strong(old,q)) return;
37  m_mean+= (q-old);
38  }
std::array< std::atomic< int >, N > m_buffer
static constexpr int N
int k[5][pyjets_maxn]
std::atomic< int > m_mean
std::atomic< int > m_curr
int edm::RunningAverage::upper ( ) const
inline

Member Data Documentation

std::array<std::atomic<int>,N> edm::RunningAverage::m_buffer
private

Definition at line 42 of file RunningAverage.h.

std::atomic<int> edm::RunningAverage::m_curr
private

Definition at line 44 of file RunningAverage.h.

std::atomic<int> edm::RunningAverage::m_mean
private

Definition at line 43 of file RunningAverage.h.

constexpr int edm::RunningAverage::N = 16
static

Definition at line 22 of file RunningAverage.h.