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

◆ RunningAverage()

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

Definition at line 23 of file RunningAverage.h.

References mps_fire::i, isotrackApplyRegressor::k, and m_buffer.

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

◆ int ::test_average::running_average::test()

edm::RunningAverage::int ::test_average::running_average::test ( )
private

◆ mean()

int edm::RunningAverage::mean ( ) const
inline

Definition at line 28 of file RunningAverage.h.

References m_mean, and N.

Referenced by upper().

28 { return m_mean / N; }
static constexpr int N
std::atomic< int > m_mean

◆ update()

void edm::RunningAverage::update ( unsigned int  q)
inline

◆ upper()

int edm::RunningAverage::upper ( ) const
inline

Definition at line 30 of file RunningAverage.h.

References funct::abs(), m_buffer, mean(), and N.

Referenced by MultiHitFromChi2EDProducer::produce(), hitTripletEDProducerT::Impl< T_HitTripletGenerator, T_SeedingHitSets, T_IntermediateHitTriplets >::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

◆ m_buffer

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

Definition at line 47 of file RunningAverage.h.

Referenced by RunningAverage(), update(), and upper().

◆ m_curr

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

Definition at line 49 of file RunningAverage.h.

Referenced by update().

◆ m_mean

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

Definition at line 48 of file RunningAverage.h.

Referenced by mean(), and update().

◆ N

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

Definition at line 22 of file RunningAverage.h.

Referenced by mean(), update(), and upper().