28 #include <boost/algorithm/string.hpp>
29 #include <ext/hash_map>
46 m_logicalExpression(alg.algoLogicalExpression()),
47 m_rpnVector(alg.algoRpnVector()){
58 const std::vector<ConditionEvaluationMap>& conditionResultMaps) {
61 if (m_rpnVector.empty() ) {
66 <<
"\nEmpty RPN vector for the logical expression = "
67 << m_logicalExpression
73 int rpnVectorSize = m_rpnVector.size();
75 m_algoCombinationVector.reserve(rpnVectorSize);
76 m_operandTokenVector.reserve(rpnVectorSize);
79 std::stack<bool, std::vector<bool> > resultStack;
84 for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {
91 switch (it->operation) {
95 CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).
find(it->operand);
96 if (itCond != (conditionResultMaps[chipNumber]).end()) {
98 if (0 == itCond->second) {
102 <<
" NULL pointer found in condition map"
107 bool condResult = (itCond->second)->condLastResult();
109 resultStack.push(condResult);
118 m_operandTokenVector.push_back(opToken);
122 CombinationsInCond const & combInCondition = (itCond->second)->getCombinationsInCond();
123 m_algoCombinationVector.push_back(combInCondition);
130 <<
"\nCondition " << (it->operand) <<
" not found in condition map"
139 b1 = resultStack.top();
141 resultStack.push(!b1);
146 b1 = resultStack.top();
148 b2 = resultStack.top();
150 resultStack.push(b1 || b2);
155 b1 = resultStack.top();
157 b2 = resultStack.top();
159 resultStack.push(b1 && b2);
173 m_algoResult = resultStack.top();
181 myCout <<
" Algorithm result: " << m_algoResult << std::endl;
183 myCout <<
" CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
185 int operandTokenVectorSize = m_operandTokenVector.size();
187 myCout <<
" Operand token vector size: " << operandTokenVectorSize;
189 if (operandTokenVectorSize == 0) {
190 myCout <<
" - not properly initialized! " << std::endl;
195 for (
int i = 0;
i < operandTokenVectorSize; ++
i) {
197 myCout <<
" " << std::setw(5) << (m_operandTokenVector[
i]).tokenNumber <<
"\t"
198 << std::setw(25) << (m_operandTokenVector[
i]).tokenName <<
"\t"
199 << (m_operandTokenVector[
i]).tokenResult
ConditionEvaluationMap::const_iterator CItEvalMap
void print(std::ostream &myCout) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
AlgorithmEvaluation(const GlobalAlgorithm &)
constructor
void evaluateAlgorithm(const int chipNumber, const std::vector< ConditionEvaluationMap > &)
evaluate an algorithm
volatile std::atomic< bool > shutdown_flag false
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition