10 #ifndef EventFilter_CTPPSRawToDigi_CounterChecker 11 #define EventFilter_CTPPSRawToDigi_CounterChecker 28 typedef unsigned short word;
30 typedef std::map<word, std::vector<TotemFramePosition> >
CounterMap;
42 unsigned int _min = 0,
43 double _fraction = 0.,
44 unsigned int _verbosity = 0)
57 typedef unsigned short word;
59 const std::pair<
word, std::vector<TotemFramePosition> > &
b) {
60 return a.second.size() <
b.second.size();
86 word mostFrequentCounter = 0;
87 word mostFrequentSize = 0;
88 unsigned int totalFrames = 0;
92 unsigned int iterSize = iter->second.size();
93 totalFrames += iterSize;
95 if (iterSize > mostFrequentSize) {
96 mostFrequentCounter = iter->first;
97 mostFrequentSize = iter->second.size();
101 if (totalFrames <
min) {
103 es <<
"Too few frames to determine the most frequent " <<
name <<
" value.";
109 if ((
float)mostFrequentSize / (
float)totalFrames <
fraction) {
111 es <<
"The most frequent " <<
name <<
" value is doubtful - variance is too high.";
117 if (iter->first != mostFrequentCounter) {
118 for (std::vector<TotemFramePosition>::iterator fr = iter->second.begin(); fr != iter->second.end(); fr++) {
121 status[*fr].status.setECProgressError();
123 status[*fr].status.setBCProgressError();
127 es <<
"Frame at " << *fr <<
": " <<
name <<
" number " << iter->first
128 <<
" is different from the most frequent one " << mostFrequentCounter << std::endl;
unsigned int min
minimal required number of frames to search for the most frequent one
Class for finding the most popular both EC and BC counter, and filling the conversion status 'wrong E...
void Analyze(T &status, bool error, std::ostream &es)
summarizes and fill the status (wrong EC and BC progress error for some frames)
unsigned int verbosity
level of verbosity
std::string name
the name of this check, used in error messages
CounterChecker(CheckerType _type=CounterChecker::BCChecker, const std::string &_name="", unsigned int _min=0, double _fraction=0., unsigned int _verbosity=0)
void Fill(word counter, TotemFramePosition fr)
add new value to map, counter takes value of EC or BC number
CounterMap relationMap
counter value -> list of frames with this value
bool operator()(const std::pair< word, std::vector< TotemFramePosition > > &a, const std::pair< word, std::vector< TotemFramePosition > > &b)
CheckerType type
EC or BC counter checker.
std::map< word, std::vector< TotemFramePosition > > CounterMap