Belle II Software development
ECLLocalRunCalibAcc Class Reference

ECLLocalRunCalibAcc is the class designed to accumulate mean values, standard deviation and number of accepted events. More...

#include <ECLLocalRunCalibAcc.h>

Public Member Functions

 ECLLocalRunCalibAcc (const float &min_value, const float &max_value, const int *const ndevs)
 Constructor.
 
 ~ECLLocalRunCalibAcc ()
 Destructor.
 
int getNOfEvents () const
 Get total number of events.
 
int getCount () const
 Get number of accepted events.
 
float getMean () const
 Get mean value.
 
float getStdDev () const
 Get standard deviation.
 
void add (const float &value)
 Add value.
 
void calc ()
 Calculate mean value, standard deviation and number of accepted events.
 

Private Member Functions

bool isValueInRange (const float &value) const
 Check value.
 
float calcStdDev (const float &variance, const int &count) const
 Calculate standard deviation using variance and number of accepted events.
 
void updateLimits (const float &mean, const float &stddev)
 Update value limits.
 

Private Attributes

float m_leftLimit
 Lower value limit.
 
float m_rightLimit
 Upper value limit.
 
const int *const c_ndevs
 Number of standard deviations used to update value limits.
 
int m_nevents
 Total number of events.
 
int m_count
 Number of accepted events.
 
float m_mean
 Mean value.
 
float m_stddev
 Standard deviation.
 
std::vector< int > m_data
 Vector of accepted values.
 

Detailed Description

ECLLocalRunCalibAcc is the class designed to accumulate mean values, standard deviation and number of accepted events.

Definition at line 27 of file ECLLocalRunCalibAcc.h.

Constructor & Destructor Documentation

◆ ECLLocalRunCalibAcc()

ECLLocalRunCalibAcc ( const float &  min_value,
const float &  max_value,
const int *const  ndevs 
)

Constructor.

Parameters
min_valueis the lower value limit.
max_valueis the upper value limit
ndevsis the number of standard deviations. used to update value limits.

Definition at line 18 of file ECLLocalRunCalibAcc.cc.

21 :
22 m_leftLimit(min_value),
23 m_rightLimit(max_value),
24 c_ndevs(ndevs),
25 m_nevents(0),
26 m_count(0),
27 m_mean(0.),
28 m_stddev(0.)
29{
30 m_data.reserve(1000);
31}
float m_leftLimit
Lower value limit.
float m_rightLimit
Upper value limit.
std::vector< int > m_data
Vector of accepted values.
int m_nevents
Total number of events.
const int *const c_ndevs
Number of standard deviations used to update value limits.
int m_count
Number of accepted events.
float m_stddev
Standard deviation.

◆ ~ECLLocalRunCalibAcc()

Destructor.

Definition at line 33 of file ECLLocalRunCalibAcc.cc.

34{
35}

Member Function Documentation

◆ add()

void add ( const float &  value)

Add value.

Definition at line 43 of file ECLLocalRunCalibAcc.cc.

44{
45 m_data.push_back(value);
46}

◆ calc()

void calc ( )

Calculate mean value, standard deviation and number of accepted events.

Definition at line 65 of file ECLLocalRunCalibAcc.cc.

66{
67 if (m_data.size() == 0) {
68 m_nevents = 0;
69 m_count = 0;
70 m_mean = 0;
71 m_stddev = 0;
72 } else {
73 namespace bacc = boost::accumulators;
74 bacc::accumulator_set <
75 float,
76 bacc::features <
77 bacc::tag::count,
78 bacc::tag::median,
79 bacc::tag::variance >> acc;
80 for (const auto& value : m_data) {
81 if (isValueInRange(value)) {
82 acc(value);
83 }
84 }
85 float tcount = bacc::count(acc);
86 float tmedian = bacc::median(acc);
87 float tvariance = bacc::variance(acc);
88 float tstddev = calcStdDev(tvariance,
89 tcount);
90 updateLimits(tmedian, tstddev);
91 bacc::accumulator_set <
92 float,
93 bacc::features <
94 bacc::tag::count,
95 bacc::tag::mean,
96 bacc::tag::variance >> acc_final;
97 for (const auto& value : m_data) {
98 if (isValueInRange(value)) {
99 acc_final(value);
100 }
101 }
102 m_nevents = static_cast<int>(m_data.size());
103 m_data.clear();
104 m_count = bacc::count(acc_final);
105 m_mean = bacc::mean(acc_final);
106 tvariance = bacc::variance(acc_final);
107 m_stddev = calcStdDev(tvariance, m_count);
108 }
109}
float calcStdDev(const float &variance, const int &count) const
Calculate standard deviation using variance and number of accepted events.
void updateLimits(const float &mean, const float &stddev)
Update value limits.
bool isValueInRange(const float &value) const
Check value.

◆ calcStdDev()

float calcStdDev ( const float &  variance,
const int &  count 
) const
private

Calculate standard deviation using variance and number of accepted events.

Parameters
varianceis the variance.
countis the number of accepted events.

Definition at line 50 of file ECLLocalRunCalibAcc.cc.

52{
53 return sqrt((variance * count) / (count - 1));
54}
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ getCount()

int getCount ( ) const

Get number of accepted events.

Definition at line 116 of file ECLLocalRunCalibAcc.cc.

117{
118 return m_count;
119}

◆ getMean()

float getMean ( ) const

Get mean value.

Definition at line 121 of file ECLLocalRunCalibAcc.cc.

122{
123 return m_mean;
124}

◆ getNOfEvents()

int getNOfEvents ( ) const

Get total number of events.

Definition at line 111 of file ECLLocalRunCalibAcc.cc.

112{
113 return m_nevents;
114}

◆ getStdDev()

float getStdDev ( ) const

Get standard deviation.

Definition at line 126 of file ECLLocalRunCalibAcc.cc.

127{
128 return m_stddev;
129}

◆ isValueInRange()

bool isValueInRange ( const float &  value) const
private

Check value.

Parameters
valueis the amplitude or time value

Definition at line 37 of file ECLLocalRunCalibAcc.cc.

38{
39 return (value > m_leftLimit) &&
40 (value < m_rightLimit);
41}

◆ updateLimits()

void updateLimits ( const float &  mean,
const float &  stddev 
)
private

Update value limits.

Parameters
meanis the mean value.
stddevis the standard deviation.

Definition at line 56 of file ECLLocalRunCalibAcc.cc.

58{
59 m_leftLimit = std::max(m_leftLimit,
60 mean - (*c_ndevs) * stddev);
61 m_rightLimit = std::min(m_rightLimit,
62 mean + (*c_ndevs) * stddev);
63}

Member Data Documentation

◆ c_ndevs

const int* const c_ndevs
private

Number of standard deviations used to update value limits.

Definition at line 109 of file ECLLocalRunCalibAcc.h.

◆ m_count

int m_count
private

Number of accepted events.

Definition at line 118 of file ECLLocalRunCalibAcc.h.

◆ m_data

std::vector<int> m_data
private

Vector of accepted values.

Definition at line 130 of file ECLLocalRunCalibAcc.h.

◆ m_leftLimit

float m_leftLimit
private

Lower value limit.

Definition at line 99 of file ECLLocalRunCalibAcc.h.

◆ m_mean

float m_mean
private

Mean value.

Definition at line 122 of file ECLLocalRunCalibAcc.h.

◆ m_nevents

int m_nevents
private

Total number of events.

Definition at line 113 of file ECLLocalRunCalibAcc.h.

◆ m_rightLimit

float m_rightLimit
private

Upper value limit.

Definition at line 103 of file ECLLocalRunCalibAcc.h.

◆ m_stddev

float m_stddev
private

Standard deviation.

Definition at line 126 of file ECLLocalRunCalibAcc.h.


The documentation for this class was generated from the following files: