28 #include <boost/algorithm/string.hpp>
29 #include <ext/hash_map>
47 m_logicalExpression(alg.algoLogicalExpression()),
48 m_rpnVector(alg.algoRpnVector()){
59 const std::vector<ConditionEvaluationMap>& conditionResultMaps) {
62 if (m_rpnVector.empty() ) {
67 <<
"\nEmpty RPN vector for the logical expression = "
68 << m_logicalExpression
74 int rpnVectorSize = m_rpnVector.size();
76 m_algoCombinationVector.reserve(rpnVectorSize);
77 m_operandTokenVector.reserve(rpnVectorSize);
81 static std::stack<bool, std::vector<bool> > resultStack;
86 for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {
93 switch (it->operation) {
97 CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).
find(it->operand);
98 if (itCond != (conditionResultMaps[chipNumber]).end()) {
100 if (0 == itCond->second) {
104 <<
" NULL pointer found in condition map"
109 bool condResult = (itCond->second)->condLastResult();
111 resultStack.push(condResult);
120 m_operandTokenVector.push_back(opToken);
124 CombinationsInCond const & combInCondition = (itCond->second)->getCombinationsInCond();
125 m_algoCombinationVector.push_back(combInCondition);
132 <<
"\nCondition " << (it->operand) <<
" not found in condition map"
141 b1 = resultStack.top();
143 resultStack.push(!b1);
148 b1 = resultStack.top();
150 b2 = resultStack.top();
152 resultStack.push(b1 || b2);
157 b1 = resultStack.top();
159 b2 = resultStack.top();
161 resultStack.push(b1 && b2);
176 m_algoResult = resultStack.top();
179 while(!resultStack.empty()) resultStack.pop();
188 myCout <<
" Algorithm result: " << m_algoResult << std::endl;
190 myCout <<
" CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
192 int operandTokenVectorSize = m_operandTokenVector.size();
194 myCout <<
" Operand token vector size: " << operandTokenVectorSize;
196 if (operandTokenVectorSize == 0) {
197 myCout <<
" - not properly initialized! " << std::endl;
202 for (
int i = 0;
i < operandTokenVectorSize; ++
i) {
204 myCout <<
" " << std::setw(5) << (m_operandTokenVector[
i]).tokenNumber <<
"\t"
205 << std::setw(25) << (m_operandTokenVector[
i]).tokenName <<
"\t"
206 << (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 L1GtAlgorithm &)
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