#include <L1Trigger/GlobalTrigger/interface/L1GtAlgorithmEvaluation.h>
Public Types | |
typedef ConditionEvaluationMap::const_iterator | CItEvalMap |
typedef __gnu_cxx::hash_map < std::string, L1GtConditionEvaluation * > | ConditionEvaluationMap |
typedef ConditionEvaluationMap::iterator | ItEvalMap |
Public Member Functions | |
void | evaluateAlgorithm (const int chipNumber, const std::vector< ConditionEvaluationMap > &) |
evaluate an algorithm | |
const std::vector < CombinationsInCond > * | gtAlgoCombinationVector () const |
get all the object combinations evaluated to true in the conditions from the algorithm | |
const bool & | gtAlgoResult () const |
get / set the result of the algorithm | |
L1GtAlgorithmEvaluation (L1GtAlgorithmEvaluation &) | |
copy constructor | |
L1GtAlgorithmEvaluation (const L1GtAlgorithm &) | |
constructor from an algorithm from event setup | |
L1GtAlgorithmEvaluation () | |
constructor | |
void | print (std::ostream &myCout) const |
void | setGtAlgoResult (const bool algoResult) |
virtual | ~L1GtAlgorithmEvaluation () |
destructor | |
Private Attributes | |
std::vector< CombinationsInCond > | m_algoCombinationVector |
bool | m_algoResult |
algorithm result |
Implementation: <TODO: enter implementation details>
$Date$ $Revision$
Definition at line 67 of file L1GtAlgorithmEvaluation.h.
typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap |
Definition at line 86 of file L1GtAlgorithmEvaluation.h.
typedef __gnu_cxx::hash_map<std::string, L1GtConditionEvaluation*> L1GtAlgorithmEvaluation::ConditionEvaluationMap |
Definition at line 85 of file L1GtAlgorithmEvaluation.h.
typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap |
Definition at line 87 of file L1GtAlgorithmEvaluation.h.
L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation | ( | ) |
constructor
Definition at line 48 of file L1GtAlgorithmEvaluation.cc.
References m_algoResult.
00048 : 00049 L1GtLogicParser() { 00050 00051 m_algoResult = false; 00052 00053 // the rest is properly initialized by default 00054 }
L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation | ( | const L1GtAlgorithm & | alg | ) |
constructor from an algorithm from event setup
Definition at line 57 of file L1GtAlgorithmEvaluation.cc.
References L1GtAlgorithm::algoLogicalExpression(), L1GtAlgorithm::algoRpnVector(), m_algoResult, L1GtLogicParser::m_logicalExpression, and L1GtLogicParser::m_rpnVector.
00057 : 00058 L1GtLogicParser() { 00059 00060 m_logicalExpression = alg.algoLogicalExpression(); 00061 m_rpnVector = alg.algoRpnVector(); 00062 00063 m_algoResult = false; 00064 00065 // the rest is properly initialized by default 00066 00067 }
L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation | ( | L1GtAlgorithmEvaluation & | cp | ) |
copy constructor
Definition at line 70 of file L1GtAlgorithmEvaluation.cc.
References gtAlgoCombinationVector(), gtAlgoResult(), L1GtLogicParser::logicalExpression(), m_algoCombinationVector, m_algoResult, L1GtLogicParser::m_logicalExpression, L1GtLogicParser::m_rpnVector, and L1GtLogicParser::rpnVector().
00070 { 00071 00072 // parser part 00073 m_logicalExpression = cp.logicalExpression(); 00074 RpnVector m_rpnVector = cp.rpnVector(); 00075 00076 // L1GtAlgorithmEvaluation part 00077 m_algoResult = cp.gtAlgoResult(); 00078 m_algoCombinationVector = *(cp.gtAlgoCombinationVector()); 00079 00080 }
L1GtAlgorithmEvaluation::~L1GtAlgorithmEvaluation | ( | ) | [virtual] |
void L1GtAlgorithmEvaluation::evaluateAlgorithm | ( | const int | chipNumber, | |
const std::vector< ConditionEvaluationMap > & | conditionResultMaps | |||
) |
evaluate an algorithm
Definition at line 92 of file L1GtAlgorithmEvaluation.cc.
References b1, b2, lat::endl(), Exception, find(), it, m_algoCombinationVector, m_algoResult, L1GtLogicParser::m_logicalExpression, L1GtLogicParser::m_operandTokenVector, L1GtLogicParser::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().
00093 { 00094 00095 // set result to false if there is no expression 00096 if (m_rpnVector.empty() ) { 00097 m_algoResult = false; 00098 00099 // it should never be happen 00100 throw cms::Exception("FailModule") 00101 << "\nEmpty RPN vector for the logical expression = " 00102 << m_logicalExpression 00103 << std::endl; 00104 00105 } 00106 00107 // reserve memory 00108 int rpnVectorSize = m_rpnVector.size(); 00109 00110 m_algoCombinationVector.reserve(rpnVectorSize); 00111 m_operandTokenVector.reserve(rpnVectorSize); 00112 00113 // stack containing temporary results 00114 std::stack<bool> resultStack; 00115 bool b1, b2; 00116 00117 int opNumber = 0; 00118 00119 for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) { 00120 00121 //LogTrace("L1GtAlgorithmEvaluation") 00122 //<< "\nit->operation = " << it->operation 00123 //<< "\nit->operand = '" << it->operand << "'\n" 00124 //<< std::endl; 00125 00126 switch (it->operation) { 00127 00128 case OP_OPERAND: { 00129 00130 CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).find(it->operand); 00131 if (itCond != (conditionResultMaps[chipNumber]).end()) { 00132 00133 // 00134 bool condResult = (itCond->second)->condLastResult(); 00135 00136 resultStack.push(condResult); 00137 00138 // only conditions are added to /counted in m_operandTokenVector 00139 // opNumber is the index of the condition in the logical expression 00140 OperandToken opToken; 00141 opToken.tokenName = it->operand; 00142 opToken.tokenNumber = opNumber; 00143 opToken.tokenResult = condResult; 00144 00145 m_operandTokenVector.push_back(opToken); 00146 opNumber++; 00147 00148 // 00149 CombinationsInCond* combInCondition = (itCond->second)->getCombinationsInCond(); 00150 m_algoCombinationVector.push_back(*combInCondition); 00151 00152 } 00153 else { 00154 00155 // it should never be happen, all conditions are in the maps 00156 throw cms::Exception("FailModule") 00157 << "\nCondition " << (itCond->first) << "not found in condition map" 00158 << std::endl; 00159 00160 } 00161 00162 } 00163 00164 break; 00165 case OP_NOT: { 00166 b1 = resultStack.top(); 00167 resultStack.pop(); // pop the top 00168 resultStack.push(!b1); // and push the result 00169 } 00170 00171 break; 00172 case OP_OR: { 00173 b1 = resultStack.top(); 00174 resultStack.pop(); 00175 b2 = resultStack.top(); 00176 resultStack.pop(); 00177 resultStack.push(b1 || b2); 00178 } 00179 00180 break; 00181 case OP_AND: { 00182 b1 = resultStack.top(); 00183 resultStack.pop(); 00184 b2 = resultStack.top(); 00185 resultStack.pop(); 00186 resultStack.push(b1 && b2); 00187 } 00188 00189 break; 00190 default: { 00191 // should not arrive here 00192 } 00193 00194 break; 00195 } 00196 00197 } 00198 00199 // get the result in the top of the stack 00200 00201 m_algoResult = resultStack.top(); 00202 00203 00204 }
const std::vector<CombinationsInCond>* L1GtAlgorithmEvaluation::gtAlgoCombinationVector | ( | ) | const [inline] |
get all the object combinations evaluated to true in the conditions from the algorithm
Definition at line 105 of file L1GtAlgorithmEvaluation.h.
References m_algoCombinationVector.
Referenced by L1GtAlgorithmEvaluation(), and L1GlobalTriggerGTL::run().
00105 { 00106 return &m_algoCombinationVector; 00107 }
const bool& L1GtAlgorithmEvaluation::gtAlgoResult | ( | ) | const [inline] |
get / set the result of the algorithm
Definition at line 92 of file L1GtAlgorithmEvaluation.h.
References m_algoResult.
Referenced by L1GtAlgorithmEvaluation(), and L1GlobalTriggerGTL::run().
00092 { 00093 return m_algoResult; 00094 }
void L1GtAlgorithmEvaluation::print | ( | std::ostream & | myCout | ) | const |
Definition at line 207 of file L1GtAlgorithmEvaluation.cc.
References lat::endl(), i, m_algoCombinationVector, m_algoResult, and L1GtLogicParser::m_operandTokenVector.
Referenced by L1GlobalTriggerGTL::run().
00207 { 00208 00209 myCout << std::endl; 00210 00211 myCout << " Algorithm result: " << m_algoResult << std::endl; 00212 00213 myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl; 00214 00215 int operandTokenVectorSize = m_operandTokenVector.size(); 00216 00217 myCout << " Operand token vector size: " << operandTokenVectorSize; 00218 00219 if (operandTokenVectorSize == 0) { 00220 myCout << " - not properly initialized! " << std::endl; 00221 } 00222 else { 00223 myCout << std::endl; 00224 00225 for (int i = 0; i < operandTokenVectorSize; ++i) { 00226 00227 myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t" 00228 << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t" 00229 << (m_operandTokenVector[i]).tokenResult 00230 << std::endl; 00231 00232 } 00233 00234 } 00235 00236 myCout << std::endl; 00237 }
Definition at line 96 of file L1GtAlgorithmEvaluation.h.
References m_algoResult.
00096 { 00097 m_algoResult = algoResult; 00098 }
std::vector<CombinationsInCond> L1GtAlgorithmEvaluation::m_algoCombinationVector [private] |
Definition at line 117 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm(), gtAlgoCombinationVector(), L1GtAlgorithmEvaluation(), and print().
bool L1GtAlgorithmEvaluation::m_algoResult [private] |
algorithm result
Definition at line 115 of file L1GtAlgorithmEvaluation.h.
Referenced by evaluateAlgorithm(), gtAlgoResult(), L1GtAlgorithmEvaluation(), print(), and setGtAlgoResult().