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_average::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 dqmdumpme::k.

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

Member Function Documentation

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

Definition at line 28 of file RunningAverage.h.

References N.

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

Definition at line 35 of file RunningAverage.h.

References MillePedeFileConverter_cfg::e, and dqmdumpme::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(), CAHitNtupletEDProducerT< T_Generator >::produce(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), 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().

35  {
36  int e = m_curr;
37  while (!m_curr.compare_exchange_weak(e, e + 1))
38  ;
39  int k = (N - 1) & e;
40  int old = m_buffer[k];
41  if (!m_buffer[k].compare_exchange_strong(old, q))
42  return;
43  m_mean += (q - old);
44  }
static constexpr int N
std::array< std::atomic< int >, N > m_buffer
std::atomic< int > m_mean
std::atomic< int > m_curr
int edm::RunningAverage::upper ( ) const
inline

Definition at line 30 of file RunningAverage.h.

References funct::abs(), and SiStripPI::mean.

Referenced by MultiHitFromChi2EDProducer::produce(), CAHitNtupletEDProducerT< T_Generator >::produce(), HitTripletGenerator::run(), MultiHitGenerator::run(), and HitPairGenerator::run().

30  {
31  auto lm = mean();
32  return lm += (std::abs(m_buffer[0] - lm) + std::abs(m_buffer[N / 2] - lm));
33  } // about 2 sigma
static constexpr int N
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::array< std::atomic< int >, N > m_buffer

Member Data Documentation

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

Definition at line 47 of file RunningAverage.h.

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

Definition at line 49 of file RunningAverage.h.

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

Definition at line 48 of file RunningAverage.h.

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

Definition at line 22 of file RunningAverage.h.