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;
58 bool operator()(
const std::pair<
word, std::vector<TotemFramePosition> > &
a,
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;