40 : m_algoResult(
false), m_logicalExpression(alg.algoLogicalExpression()), m_rpnVector(alg.algoRpnVector()) {
48 const std::vector<ConditionEvaluationMap>& conditionResultMaps) {
50 if (m_rpnVector.empty()) {
54 throw cms::Exception(
"FailModule") <<
"\nEmpty RPN vector for the logical expression = " << m_logicalExpression
59 int rpnVectorSize = m_rpnVector.size();
61 m_algoCombinationVector.reserve(rpnVectorSize);
62 m_operandTokenVector.reserve(rpnVectorSize);
65 std::stack<bool, std::vector<bool> > resultStack;
70 for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {
76 switch (it->operation) {
78 CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).
find(it->operand);
79 if (itCond != (conditionResultMaps[chipNumber]).end()) {
80 if (
nullptr == itCond->second) {
83 <<
"\nCondition " << (it->operand) <<
" NULL pointer found in condition map" << std::endl;
87 bool condResult = (itCond->second)->condLastResult();
89 resultStack.push(condResult);
98 m_operandTokenVector.push_back(opToken);
102 CombinationsInCond const& combInCondition = (itCond->second)->getCombinationsInCond();
103 m_algoCombinationVector.push_back(combInCondition);
108 <<
"\nCondition " << (it->operand) <<
" not found in condition map" << std::endl;
115 b1 = resultStack.top();
117 resultStack.push(!
b1);
122 b1 = resultStack.top();
124 b2 = resultStack.top();
126 resultStack.push(
b1 ||
b2);
131 b1 = resultStack.top();
133 b2 = resultStack.top();
135 resultStack.push(
b1 &&
b2);
140 b1 = resultStack.top();
142 b2 = resultStack.top();
144 resultStack.push(
b1 ^
b2);
157 m_algoResult = resultStack.top();
164 myCout <<
" Algorithm result: " << m_algoResult << std::endl;
166 myCout <<
" CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
168 int operandTokenVectorSize = m_operandTokenVector.size();
170 myCout <<
" Operand token vector size: " << operandTokenVectorSize;
172 if (operandTokenVectorSize == 0) {
173 myCout <<
" - not properly initialized! " << std::endl;
177 for (
int i = 0;
i < operandTokenVectorSize; ++
i) {
178 myCout <<
" " << std::setw(5) << (m_operandTokenVector[
i]).tokenNumber <<
"\t" << std::setw(25)
179 << (m_operandTokenVector[
i]).tokenName <<
"\t" << (m_operandTokenVector[
i]).tokenResult << std::endl;
ConditionEvaluationMap::const_iterator CItEvalMap
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void print(std::ostream &myCout) const
AlgorithmEvaluation(const GlobalAlgorithm &)
constructor
void evaluateAlgorithm(const int chipNumber, const std::vector< ConditionEvaluationMap > &)
evaluate an algorithm
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition