Belle II Software development
ECLLocalRunCalibUnit Class Reference

ECLLocalRunCalibUnit is the class designed for the control of mean value and the standard deviation accumulators. More...

#include <ECLLocalRunCalibUnit.h>

Public Member Functions

 ECLLocalRunCalibUnit (const int &ncellids, const float &min_value, const float &max_value, const int *const ndevs)
 Constructor.
 
 ~ECLLocalRunCalibUnit ()
 Destructor.
 
void add (const int &cellid, const float &value)
 Add value to accumulate mean value, standard deviation and number of accepted events.
 
void calc ()
 Calculate accumulated values.
 
void writeToDB (bool isLocal, const std::string &dbName, const std::string &payloadName, const IntervalOfValidity &iov, const int &run, const bool &changePrev, const bool &addref)
 Write calibration results into a database.
 
void enableNegAmpl ()
 This function will be called only in the case, if negative amplitudes are observed in the current run.
 
bool isNegAmpl () const
 Check presence of negative amplitudes in the current run.
 

Private Member Functions

void markAsRefference (const bool &isLocal, const std::string &dbName, const int &run, const IntervalOfValidity &iov)
 Mark current run as reference.
 
void changePreviousIoV (const ECLDBTool &payload, const IntervalOfValidity &iov)
 Change previous validity interval.
 
template<typename T >
void callAccGetter (std::vector< T > *vec, T(ECLLocalRunCalibAcc::*getter)() const)
 Getter of accumulated values.
 

Private Attributes

bool m_isNegAmpl
 m_isNegAmpl is true if there are negative amplitudes in the current run and false otherwise.
 
std::vector< ECLLocalRunCalibAccm_unitData
 Mean value and standard deviation accumulators for each cell id.
 

Detailed Description

ECLLocalRunCalibUnit is the class designed for the control of mean value and the standard deviation accumulators.

Definition at line 27 of file ECLLocalRunCalibUnit.h.

Constructor & Destructor Documentation

◆ ECLLocalRunCalibUnit()

ECLLocalRunCalibUnit ( const int &  ncellids,
const float &  min_value,
const float &  max_value,
const int *const  ndevs 
)

Constructor.

Parameters
ncellidsis the number of cell ids.
min_valueis the minimum allowed value.
max_valueis the maximum allowed value.
ndevsis the number of standard deviations.

Definition at line 16 of file ECLLocalRunCalibUnit.cc.

20 :
21 m_isNegAmpl(false), m_unitData(ncellids,
23 min_value,
24 max_value,
25 ndevs))
26{
27}
ECLLocalRunCalibAcc is the class designed to accumulate mean values, standard deviation and number of...
std::vector< ECLLocalRunCalibAcc > m_unitData
Mean value and standard deviation accumulators for each cell id.
bool m_isNegAmpl
m_isNegAmpl is true if there are negative amplitudes in the current run and false otherwise.

◆ ~ECLLocalRunCalibUnit()

Destructor.

Definition at line 29 of file ECLLocalRunCalibUnit.cc.

30{
31}

Member Function Documentation

◆ add()

void add ( const int &  cellid,
const float &  value 
)

Add value to accumulate mean value, standard deviation and number of accepted events.

Parameters
cellidis the cell id number.
valueis the accumulated value.

Definition at line 49 of file ECLLocalRunCalibUnit.cc.

50{
51 m_unitData[index].add(value);
52}

◆ calc()

void calc ( )

Calculate accumulated values.

Definition at line 54 of file ECLLocalRunCalibUnit.cc.

55{
56 for (auto& cellAcc : m_unitData) {
57 cellAcc.calc();
58 }
59}

◆ callAccGetter()

void callAccGetter ( std::vector< T > *  vec,
T(ECLLocalRunCalibAcc::*)() const  getter 
)
private

Getter of accumulated values.

Parameters
vecis the vector used to get vector of accumulated values.
getteris the name of the getter method.

Definition at line 62 of file ECLLocalRunCalibUnit.cc.

65{
66 for (const auto& obj : m_unitData) {
67 vec->push_back((obj.*getter)());
68 }
69}

◆ changePreviousIoV()

void changePreviousIoV ( const ECLDBTool payload,
const IntervalOfValidity iov 
)
private

Change previous validity interval.

Parameters
payloadis the connection to a certain payload.
iovis the current validity interval.

Definition at line 84 of file ECLLocalRunCalibUnit.cc.

86{
87 int exp = iov.getExperimentLow();
88 int run_high = iov.getRunLow() - 1;
89 EventMetaData ev(1, run_high, exp);
90 IntervalOfValidity* prevIoV;
91 payload.read(&prevIoV, ev);
92 int run_low = prevIoV->getRunLow();
93 IntervalOfValidity ciov(exp, run_low,
94 exp, run_high);
95 payload.changeIoV(ev, ciov);
96 delete prevIoV;
97}
Store event, run, and experiment numbers.
Definition: EventMetaData.h:33
A class that describes the interval of experiments/runs for which an object in the database is valid.
int getRunLow() const
Getter for lowest run number.

◆ enableNegAmpl()

void enableNegAmpl ( )

This function will be called only in the case, if negative amplitudes are observed in the current run.

Definition at line 35 of file ECLLocalRunCalibUnit.cc.

36{
37 m_isNegAmpl = true;
38}

◆ isNegAmpl()

bool isNegAmpl ( ) const

Check presence of negative amplitudes in the current run.

Definition at line 41 of file ECLLocalRunCalibUnit.cc.

42{
43 return m_isNegAmpl;
44}

◆ markAsRefference()

void markAsRefference ( const bool &  isLocal,
const std::string &  dbName,
const int &  run,
const IntervalOfValidity iov 
)
private

Mark current run as reference.

Parameters
isLocalis true for local database
dbNameis central DB tag or path to a local DB.
runis the current run number.
iovis the current validity interval.

Definition at line 71 of file ECLLocalRunCalibUnit.cc.

75{
76 int exp = iov.getExperimentLow();
77 ECLDBTool refPayload(isLocal, dbName.c_str(),
78 "ECLCalibRef");
79 refPayload.connect();
80 ECLLocalRunCalibRef refobj(exp, run);
81 refPayload.write(&refobj, iov);
82}
The ECLDBTool class is designed to read / write object from / to database.
Definition: ECLDBTool.h:23
ECLLocalRunCalibRef is designed to store reference marks to database for ECL local run calibration.

◆ writeToDB()

void writeToDB ( bool  isLocal,
const std::string &  dbName,
const std::string &  payloadName,
const IntervalOfValidity iov,
const int &  run,
const bool &  changePrev,
const bool &  addref 
)

Write calibration results into a database.

Parameters
isLocalenables usage of a local database.
dbNameis the central database tag or path to a local database.
payloadNameis the payload name.
iovis the validity interval.
runis the current run number.
changePrevenables previous validity interval changing.
addrefis used to mark current run as reference.

Definition at line 99 of file ECLLocalRunCalibUnit.cc.

107{
108 int exp = iov.getExperimentLow();
110 if (m_unitData.size() > 0) {
111 int nevents = 0;
112 for (const auto& cellAcc : m_unitData) {
113 nevents = cellAcc.getNOfEvents();
114 if (nevents != 0) {
115 break;
116 }
117 }
118 std::vector<int> counts;
119 counts.reserve(m_unitData.size());
120 callAccGetter<int>(&counts,
122 std::vector<float> means;
123 means.reserve(m_unitData.size());
124 callAccGetter<float>(&means,
126 std::vector<float> stddevs;
127 stddevs.reserve(m_unitData.size());
128 callAccGetter<float>(&stddevs,
130 data.setNumberOfEvents(nevents);
131 data.setNumbersOfAcceptedEvents(counts);
132 data.setCalibVector(means, stddevs);
133 data.setExpRun(exp, run);
134 ECLDBTool payload(isLocal, dbName.c_str(),
135 payloadName.c_str());
136 payload.connect();
137 if (changePrev) {
138 changePreviousIoV(payload, iov);
139 }
140 payload.write(&data, iov);
141 if (addref) {
142 markAsRefference(isLocal, dbName,
143 run, iov);
144 }
145 }
146}
ECLCrystalLocalRunCalib is designed to store results of the ECL local run calibration to database.
int getCount() const
Get number of accepted events.
float getMean() const
Get mean value.
float getStdDev() const
Get standard deviation.
void markAsRefference(const bool &isLocal, const std::string &dbName, const int &run, const IntervalOfValidity &iov)
Mark current run as reference.
void changePreviousIoV(const ECLDBTool &payload, const IntervalOfValidity &iov)
Change previous validity interval.
bool isNegAmpl() const
Check presence of negative amplitudes in the current run.

Member Data Documentation

◆ m_isNegAmpl

bool m_isNegAmpl
private

m_isNegAmpl is true if there are negative amplitudes in the current run and false otherwise.

Definition at line 95 of file ECLLocalRunCalibUnit.h.

◆ m_unitData

std::vector<ECLLocalRunCalibAcc> m_unitData
private

Mean value and standard deviation accumulators for each cell id.

Definition at line 118 of file ECLLocalRunCalibUnit.h.


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