#include <L1GtAlgorithmEvaluation.h>
Public Types | |
typedef ConditionEvaluationMap::const_iterator | CItEvalMap |
typedef __gnu_cxx::hash_map < std::string, L1GtConditionEvaluation * > | ConditionEvaluationMap |
copy constructor | |
typedef ConditionEvaluationMap::iterator | ItEvalMap |
typedef L1GtLogicParser::OperandToken | OperandToken |
typedef std::vector< TokenRPN > | RpnVector |
typedef L1GtLogicParser::TokenRPN | TokenRPN |
Public Member Functions | |
void | evaluateAlgorithm (const int chipNumber, const std::vector< ConditionEvaluationMap > &) |
evaluate an algorithm | |
std::vector< CombinationsInCond > & | gtAlgoCombinationVector () |
bool | gtAlgoResult () const |
get / set the result of the algorithm | |
L1GtAlgorithmEvaluation (const L1GtAlgorithm &) | |
constructor | |
std::vector < L1GtLogicParser::OperandToken > & | operandTokenVector () |
void | print (std::ostream &myCout) const |
void | setGtAlgoResult (const bool algoResult) |
Private Attributes | |
std::vector< CombinationsInCond > | m_algoCombinationVector |
bool | m_algoResult |
algorithm result | |
std::string const & | m_logicalExpression |
std::vector< OperandToken > | m_operandTokenVector |
RpnVector const & | m_rpnVector |
Description: Evaluation of a L1 Global Trigger algorithm.
Implementation: <TODO: enter implementation details>
$Date$ $Revision$
Definition at line 68 of file L1GtAlgorithmEvaluation.h.
typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap |
Definition at line 90 of file L1GtAlgorithmEvaluation.h.
typedef __gnu_cxx ::hash_map<std::string, L1GtConditionEvaluation*> L1GtAlgorithmEvaluation::ConditionEvaluationMap |
typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap |
Definition at line 91 of file L1GtAlgorithmEvaluation.h.
Definition at line 73 of file L1GtAlgorithmEvaluation.h.
typedef std::vector<TokenRPN> L1GtAlgorithmEvaluation::RpnVector |
Definition at line 72 of file L1GtAlgorithmEvaluation.h.
Definition at line 71 of file L1GtAlgorithmEvaluation.h.
L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation | ( | const L1GtAlgorithm & | alg | ) | [explicit] |
constructor
constructor from an algorithm from event setup
Definition at line 47 of file L1GtAlgorithmEvaluation.cc.
: m_algoResult(false), m_logicalExpression(alg.algoLogicalExpression()), m_rpnVector(alg.algoRpnVector()){ // the rest is properly initialized by default }
void L1GtAlgorithmEvaluation::evaluateAlgorithm | ( | const int | chipNumber, |
const std::vector< ConditionEvaluationMap > & | conditionResultMaps | ||
) |
evaluate an algorithm
Definition at line 60 of file L1GtAlgorithmEvaluation.cc.
References Exception, spr::find(), m_algoCombinationVector, m_algoResult, m_logicalExpression, m_operandTokenVector, m_rpnVector, L1GtLogicParser::OP_AND, L1GtLogicParser::OP_NOT, L1GtLogicParser::OP_OPERAND, L1GtLogicParser::OP_OR, L1GtLogicParser::OperandToken::tokenName, L1GtLogicParser::OperandToken::tokenNumber, and L1GtLogicParser::OperandToken::tokenResult.
Referenced by L1GlobalTriggerGTL::run().
{ // set result to false if there is no expression if (m_rpnVector.empty() ) { m_algoResult = false; // it should never be happen throw cms::Exception("FailModule") << "\nEmpty RPN vector for the logical expression = " << m_logicalExpression << std::endl; } // reserve memory int rpnVectorSize = m_rpnVector.size(); m_algoCombinationVector.reserve(rpnVectorSize); m_operandTokenVector.reserve(rpnVectorSize); // stack containing temporary results // FIXME we shall find a better solution than static static std::stack<bool, std::vector<bool> > resultStack; bool b1, b2; int opNumber = 0; for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) { //LogTrace("L1GlobalTrigger") //<< "\nit->operation = " << it->operation //<< "\nit->operand = '" << it->operand << "'\n" //<< std::endl; switch (it->operation) { case L1GtLogicParser::OP_OPERAND: { CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).find(it->operand); if (itCond != (conditionResultMaps[chipNumber]).end()) { if (0 == itCond->second) { // it should never be happen, only valid conditions are in the maps throw cms::Exception("FailModule") << "\nCondition " << (it->operand) << " NULL pointer found in condition map" << std::endl; } // bool condResult = (itCond->second)->condLastResult(); resultStack.push(condResult); // only conditions are added to /counted in m_operandTokenVector // opNumber is the index of the condition in the logical expression OperandToken opToken; opToken.tokenName = it->operand; opToken.tokenNumber = opNumber; opToken.tokenResult = condResult; m_operandTokenVector.push_back(opToken); opNumber++; // CombinationsInCond const & combInCondition = (itCond->second)->getCombinationsInCond(); m_algoCombinationVector.push_back(combInCondition); } else { // it should never be happen, all conditions are in the maps throw cms::Exception("FailModule") << "\nCondition " << (it->operand) << " not found in condition map" << std::endl; } } break; case L1GtLogicParser::OP_NOT: { b1 = resultStack.top(); resultStack.pop(); // pop the top resultStack.push(!b1); // and push the result } break; case L1GtLogicParser::OP_OR: { b1 = resultStack.top(); resultStack.pop(); b2 = resultStack.top(); resultStack.pop(); resultStack.push(b1 || b2); } break; case L1GtLogicParser::OP_AND: { b1 = resultStack.top(); resultStack.pop(); b2 = resultStack.top(); resultStack.pop(); resultStack.push(b1 && b2); } break; default: { // should not arrive here } break; } } // get the result in the top of the stack m_algoResult = resultStack.top(); // clear resultStack while(!resultStack.empty()) resultStack.pop(); }
std::vector<CombinationsInCond>& L1GtAlgorithmEvaluation::gtAlgoCombinationVector | ( | ) | [inline] |
get all the object combinations evaluated to true in the conditions from the algorithm
Definition at line 110 of file L1GtAlgorithmEvaluation.h.
References m_algoCombinationVector.
Referenced by L1GlobalTriggerGTL::run().
{ return m_algoCombinationVector; }
bool L1GtAlgorithmEvaluation::gtAlgoResult | ( | ) | const [inline] |
get / set the result of the algorithm
Definition at line 96 of file L1GtAlgorithmEvaluation.h.
References m_algoResult.
Referenced by L1GlobalTriggerGTL::run().
{ return m_algoResult; }
std::vector<L1GtLogicParser::OperandToken>& L1GtAlgorithmEvaluation::operandTokenVector | ( | ) | [inline] |
Definition at line 114 of file L1GtAlgorithmEvaluation.h.
References m_operandTokenVector.
Referenced by L1GlobalTriggerGTL::run().
{ return m_operandTokenVector; }
void L1GtAlgorithmEvaluation::print | ( | std::ostream & | myCout | ) | const |
Definition at line 186 of file L1GtAlgorithmEvaluation.cc.
References i, m_algoCombinationVector, m_algoResult, and m_operandTokenVector.
Referenced by L1GlobalTriggerGTL::run().
{ myCout << std::endl; myCout << " Algorithm result: " << m_algoResult << std::endl; myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl; int operandTokenVectorSize = m_operandTokenVector.size(); myCout << " Operand token vector size: " << operandTokenVectorSize; if (operandTokenVectorSize == 0) { myCout << " - not properly initialized! " << std::endl; } else { myCout << std::endl; for (int i = 0; i < operandTokenVectorSize; ++i) { myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t" << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t" << (m_operandTokenVector[i]).tokenResult << std::endl; } } myCout << std::endl; }
void L1GtAlgorithmEvaluation::setGtAlgoResult | ( | const bool | algoResult | ) | [inline] |
Definition at line 100 of file L1GtAlgorithmEvaluation.h.
References m_algoResult.
{ m_algoResult = algoResult; }
std::vector<CombinationsInCond> L1GtAlgorithmEvaluation::m_algoCombinationVector [private] |
Definition at line 131 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm(), gtAlgoCombinationVector(), and print().
bool L1GtAlgorithmEvaluation::m_algoResult [private] |
algorithm result
Definition at line 123 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm(), gtAlgoResult(), print(), and setGtAlgoResult().
std::string const& L1GtAlgorithmEvaluation::m_logicalExpression [private] |
Definition at line 126 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm().
std::vector<OperandToken> L1GtAlgorithmEvaluation::m_operandTokenVector [private] |
Definition at line 129 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm(), operandTokenVector(), and print().
RpnVector const& L1GtAlgorithmEvaluation::m_rpnVector [private] |
Definition at line 127 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm().