10 #ifndef EventFilter_CTPPSRawToDigi_CounterChecker 11 #define EventFilter_CTPPSRawToDigi_CounterChecker 31 typedef unsigned short word;
33 typedef std::map<word, std::vector<TotemFramePosition> >
CounterMap;
44 unsigned int _min=0,
double _fraction=0.,
unsigned int _verbosity=0) :
type(_type),
58 typedef unsigned short word;
59 bool operator()(
const std::pair<word, std::vector<TotemFramePosition> > &
a,
const std::pair<word, std::vector<TotemFramePosition> > &
b)
61 return a.second.size() <
b.second.size();
90 word mostFrequentCounter = 0;
91 word mostFrequentSize = 0;
92 unsigned int totalFrames = 0;
97 unsigned int iterSize = iter->second.size();
98 totalFrames += iterSize;
100 if (iterSize > mostFrequentSize)
102 mostFrequentCounter = iter->first;
103 mostFrequentSize = iter->second.size();
107 if (totalFrames <
min)
110 es <<
"Too few frames to determine the most frequent " <<
name <<
" value.";
116 if ((
float)mostFrequentSize/(
float)totalFrames <
fraction)
119 es <<
"The most frequent " <<
name <<
" value is doubtful - variance is too high.";
126 if (iter->first != mostFrequentCounter)
128 for (std::vector<TotemFramePosition>::iterator fr = iter->second.begin(); fr != iter->second.end(); fr++)
133 status[*fr].status.setECProgressError();
135 status[*fr].status.setBCProgressError();
139 es <<
"Frame at " << *fr <<
": " <<
name <<
" number " << iter->first
140 <<
" 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