28 #include <boost/algorithm/string.hpp>
29 #include <ext/hash_map>
43 : m_algoResult(
false), m_logicalExpression(alg.algoLogicalExpression()), m_rpnVector(alg.algoRpnVector()) {
51 const std::vector<ConditionEvaluationMap>& conditionResultMaps) {
53 if (m_rpnVector.empty()) {
57 throw cms::Exception(
"FailModule") <<
"\nEmpty RPN vector for the logical expression = " << m_logicalExpression
62 int rpnVectorSize = m_rpnVector.size();
64 m_algoCombinationVector.reserve(rpnVectorSize);
65 m_operandTokenVector.reserve(rpnVectorSize);
68 std::stack<bool, std::vector<bool> > resultStack;
73 for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {
79 switch (it->operation) {
81 CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).
find(it->operand);
82 if (itCond != (conditionResultMaps[chipNumber]).end()) {
83 if (
nullptr == itCond->second) {
86 <<
"\nCondition " << (it->operand) <<
" NULL pointer found in condition map" << std::endl;
90 bool condResult = (itCond->second)->condLastResult();
92 resultStack.push(condResult);
101 m_operandTokenVector.push_back(opToken);
105 CombinationsInCond const& combInCondition = (itCond->second)->getCombinationsInCond();
106 m_algoCombinationVector.push_back(combInCondition);
111 <<
"\nCondition " << (it->operand) <<
" not found in condition map" << std::endl;
118 b1 = resultStack.top();
120 resultStack.push(!
b1);
125 b1 = resultStack.top();
127 b2 = resultStack.top();
129 resultStack.push(
b1 ||
b2);
134 b1 = resultStack.top();
136 b2 = resultStack.top();
138 resultStack.push(
b1 &&
b2);
143 b1 = resultStack.top();
145 b2 = resultStack.top();
147 resultStack.push(
b1 ^
b2);
160 m_algoResult = resultStack.top();
167 myCout <<
" Algorithm result: " << m_algoResult << std::endl;
169 myCout <<
" CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
171 int operandTokenVectorSize = m_operandTokenVector.size();
173 myCout <<
" Operand token vector size: " << operandTokenVectorSize;
175 if (operandTokenVectorSize == 0) {
176 myCout <<
" - not properly initialized! " << std::endl;
180 for (
int i = 0;
i < operandTokenVectorSize; ++
i) {
181 myCout <<
" " << std::setw(5) << (m_operandTokenVector[
i]).tokenNumber <<
"\t" << std::setw(25)
182 << (m_operandTokenVector[
i]).tokenName <<
"\t" << (m_operandTokenVector[
i]).tokenResult << std::endl;