CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
L1GtAlgorithmEvaluation Class Reference

#include <L1GtAlgorithmEvaluation.h>

Inheritance diagram for L1GtAlgorithmEvaluation:
L1GtLogicParser

Public Types

typedef
ConditionEvaluationMap::const_iterator 
CItEvalMap
 
typedef __gnu_cxx::hash_map
< std::string,
L1GtConditionEvaluation * > 
ConditionEvaluationMap
 
typedef
ConditionEvaluationMap::iterator 
ItEvalMap
 
- Public Types inherited from L1GtLogicParser
enum  OperationType {
  OP_NULL =1, OP_INVALID =2, OP_AND =4, OP_OR =8,
  OP_NOT =16, OP_OPERAND =32, OP_OPENBRACKET =64, OP_CLOSEBRACKET =128
}
 
typedef std::vector< TokenRPNRpnVector
 

Public Member Functions

void evaluateAlgorithm (const int chipNumber, const std::vector< ConditionEvaluationMap > &)
 evaluate an algorithm More...
 
const std::vector
< CombinationsInCond > * 
gtAlgoCombinationVector () const
 
const bool & gtAlgoResult () const
 get / set the result of the algorithm More...
 
 L1GtAlgorithmEvaluation ()
 constructor More...
 
 L1GtAlgorithmEvaluation (const L1GtAlgorithm &)
 constructor from an algorithm from event setup More...
 
 L1GtAlgorithmEvaluation (L1GtAlgorithmEvaluation &)
 copy constructor More...
 
void print (std::ostream &myCout) const
 
void setGtAlgoResult (const bool algoResult)
 
virtual ~L1GtAlgorithmEvaluation ()
 destructor More...
 
- Public Member Functions inherited from L1GtLogicParser
void buildOperandTokenVector ()
 
void buildOperandTokenVectorNumExp ()
 
bool buildRpnVector (const std::string &)
 build the rpn vector More...
 
bool checkLogicalExpression (std::string &)
 check a logical expression for correctness - add/remove spaces if needed More...
 
void clearRpnVector ()
 clear possible old rpn vector More...
 
void convertIntToNameLogicalExpression (const std::map< int, std::string > &intToNameMap)
 
void convertNameToIntLogicalExpression (const std::map< std::string, int > &nameToIntMap)
 
virtual const bool expressionResult () const
 
virtual const bool expressionResultNumExp () const
 
std::vector
< L1GtLogicParser::OperandToken
expressionSeedsOperandList ()
 
 L1GtLogicParser ()
 constructor(s) More...
 
 L1GtLogicParser (const RpnVector &, const std::vector< OperandToken > &)
 
 L1GtLogicParser (const std::string &logicalExpressionVal)
 
 L1GtLogicParser (std::string &logicalExpressionVal)
 
 L1GtLogicParser (const std::string logicalExpressionVal, const std::string numericalExpressionVal)
 from a logical and a numerical expression More...
 
 L1GtLogicParser (const std::string &logicalExpressionVal, const std::string &numericalExpressionVal, const bool dummy)
 
std::string logicalExpression () const
 return the logical expression More...
 
std::string numericalExpression () const
 return the numerical expression More...
 
int operandIndex (const std::string &operandNameVal) const
 return the position index of the operand in the logical expression More...
 
std::string operandName (const int iOperand) const
 return the name of the (iOperand)th operand in the logical expression More...
 
bool operandResult (const std::string &operandNameVal) const
 
bool operandResult (const int tokenNumberVal) const
 
bool operandResultNumExp (const std::string &operandNameVal) const
 
bool operandResultNumExp (const int iOperand) const
 
std::vector< OperandToken > & operandTokenVector ()
 return the vector of operand tokens More...
 
const std::vector< OperandToken > & operandTokenVector () const
 
RpnVector rpnVector () const
 return the RPN vector More...
 
virtual ~L1GtLogicParser ()
 destructor More...
 

Private Attributes

std::vector< CombinationsInCondm_algoCombinationVector
 
bool m_algoResult
 algorithm result More...
 

Additional Inherited Members

- Protected Member Functions inherited from L1GtLogicParser
void addBracketSpaces (const std::string &, std::string &)
 add spaces before and after parantheses More...
 
virtual OperationType getOperation (const std::string &tokenString, OperationType lastOperation, TokenRPN &rpnToken) const
 
const OperationRulegetRuleFromType (OperationType t)
 get the rule entry to an operation type More...
 
bool setLogicalExpression (const std::string &)
 set the logical expression - check for correctness the input string More...
 
bool setNumericalExpression (const std::string &)
 
- Protected Attributes inherited from L1GtLogicParser
std::string m_logicalExpression
 logical expression to be parsed More...
 
std::string m_numericalExpression
 
std::vector< OperandTokenm_operandTokenVector
 vector of operand tokens More...
 
RpnVector m_rpnVector
 RPN vector - equivalent to the logical expression. More...
 
- Static Protected Attributes inherited from L1GtLogicParser
static struct OperationRule m_operationRules []
 

Detailed Description

Description: Evaluation of a L1 Global Trigger algorithm.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna

$Date$ $Revision$

Definition at line 67 of file L1GtAlgorithmEvaluation.h.

Member Typedef Documentation

typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap

Definition at line 86 of file L1GtAlgorithmEvaluation.h.

Definition at line 85 of file L1GtAlgorithmEvaluation.h.

typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap

Definition at line 87 of file L1GtAlgorithmEvaluation.h.

Constructor & Destructor Documentation

L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( )

constructor

Definition at line 48 of file L1GtAlgorithmEvaluation.cc.

References m_algoResult.

48  :
49  L1GtLogicParser() {
50 
51  m_algoResult = false;
52 
53  // the rest is properly initialized by default
54 }
bool m_algoResult
algorithm result
L1GtLogicParser()
constructor(s)
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.

57  :
58  L1GtLogicParser() {
59 
61  m_rpnVector = alg.algoRpnVector();
62 
63  m_algoResult = false;
64 
65  // the rest is properly initialized by default
66 
67 }
bool m_algoResult
algorithm result
L1GtLogicParser()
constructor(s)
const std::vector< L1GtLogicParser::TokenRPN > & algoRpnVector() const
return the RPN vector
Definition: L1GtAlgorithm.h:87
std::string const & algoLogicalExpression() const
get / set the logical expression for the algorithm
Definition: L1GtAlgorithm.h:76
std::string m_logicalExpression
logical expression to be parsed
RpnVector m_rpnVector
RPN vector - equivalent to the logical expression.
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().

70  {
71 
72  // parser part
75 
76  // L1GtAlgorithmEvaluation part
79 
80 }
std::string logicalExpression() const
return the logical expression
bool m_algoResult
algorithm result
RpnVector rpnVector() const
return the RPN vector
const std::vector< CombinationsInCond > * gtAlgoCombinationVector() const
std::vector< CombinationsInCond > m_algoCombinationVector
std::string m_logicalExpression
logical expression to be parsed
const bool & gtAlgoResult() const
get / set the result of the algorithm
RpnVector m_rpnVector
RPN vector - equivalent to the logical expression.
std::vector< TokenRPN > RpnVector
L1GtAlgorithmEvaluation::~L1GtAlgorithmEvaluation ( )
virtual

destructor

Definition at line 83 of file L1GtAlgorithmEvaluation.cc.

83  {
84 
85  // empty
86 
87 }

Member Function Documentation

void L1GtAlgorithmEvaluation::evaluateAlgorithm ( const int  chipNumber,
const std::vector< ConditionEvaluationMap > &  conditionResultMaps 
)

evaluate an algorithm

Definition at line 92 of file L1GtAlgorithmEvaluation.cc.

References edm::hlt::Exception, spr::find(), 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().

93  {
94 
95  // set result to false if there is no expression
96  if (m_rpnVector.empty() ) {
97  m_algoResult = false;
98 
99  // it should never be happen
100  throw cms::Exception("FailModule")
101  << "\nEmpty RPN vector for the logical expression = "
103  << std::endl;
104 
105  }
106 
107  // reserve memory
108  int rpnVectorSize = m_rpnVector.size();
109 
110  m_algoCombinationVector.reserve(rpnVectorSize);
111  m_operandTokenVector.reserve(rpnVectorSize);
112 
113  // stack containing temporary results
114  std::stack<bool> resultStack;
115  bool b1, b2;
116 
117  int opNumber = 0;
118 
119  for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {
120 
121  //LogTrace("L1GtAlgorithmEvaluation")
122  //<< "\nit->operation = " << it->operation
123  //<< "\nit->operand = '" << it->operand << "'\n"
124  //<< std::endl;
125 
126  switch (it->operation) {
127 
128  case OP_OPERAND: {
129 
130  CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).find(it->operand);
131  if (itCond != (conditionResultMaps[chipNumber]).end()) {
132 
133  //
134  bool condResult = (itCond->second)->condLastResult();
135 
136  resultStack.push(condResult);
137 
138  // only conditions are added to /counted in m_operandTokenVector
139  // opNumber is the index of the condition in the logical expression
140  OperandToken opToken;
141  opToken.tokenName = it->operand;
142  opToken.tokenNumber = opNumber;
143  opToken.tokenResult = condResult;
144 
145  m_operandTokenVector.push_back(opToken);
146  opNumber++;
147 
148  //
149  CombinationsInCond* combInCondition = (itCond->second)->getCombinationsInCond();
150  m_algoCombinationVector.push_back(*combInCondition);
151 
152  }
153  else {
154 
155  // it should never be happen, all conditions are in the maps
156  throw cms::Exception("FailModule")
157  << "\nCondition " << (it->operand) << " not found in condition map"
158  << std::endl;
159 
160  }
161 
162  }
163 
164  break;
165  case OP_NOT: {
166  b1 = resultStack.top();
167  resultStack.pop(); // pop the top
168  resultStack.push(!b1); // and push the result
169  }
170 
171  break;
172  case OP_OR: {
173  b1 = resultStack.top();
174  resultStack.pop();
175  b2 = resultStack.top();
176  resultStack.pop();
177  resultStack.push(b1 || b2);
178  }
179 
180  break;
181  case OP_AND: {
182  b1 = resultStack.top();
183  resultStack.pop();
184  b2 = resultStack.top();
185  resultStack.pop();
186  resultStack.push(b1 && b2);
187  }
188 
189  break;
190  default: {
191  // should not arrive here
192  }
193 
194  break;
195  }
196 
197  }
198 
199  // get the result in the top of the stack
200 
201  m_algoResult = resultStack.top();
202 
203 
204 }
bool m_algoResult
algorithm result
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
std::vector< OperandToken > m_operandTokenVector
vector of operand tokens
std::vector< CombinationsInCond > m_algoCombinationVector
std::string m_logicalExpression
logical expression to be parsed
RpnVector m_rpnVector
RPN vector - equivalent to the logical expression.
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
ConditionEvaluationMap::const_iterator CItEvalMap
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().

105  {
106  return &m_algoCombinationVector;
107  }
std::vector< CombinationsInCond > m_algoCombinationVector
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().

92  {
93  return m_algoResult;
94  }
bool m_algoResult
algorithm result
void L1GtAlgorithmEvaluation::print ( std::ostream &  myCout) const

Definition at line 207 of file L1GtAlgorithmEvaluation.cc.

References i, m_algoCombinationVector, m_algoResult, and L1GtLogicParser::m_operandTokenVector.

Referenced by L1GlobalTriggerGTL::run().

207  {
208 
209  myCout << std::endl;
210 
211  myCout << " Algorithm result: " << m_algoResult << std::endl;
212 
213  myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
214 
215  int operandTokenVectorSize = m_operandTokenVector.size();
216 
217  myCout << " Operand token vector size: " << operandTokenVectorSize;
218 
219  if (operandTokenVectorSize == 0) {
220  myCout << " - not properly initialized! " << std::endl;
221  }
222  else {
223  myCout << std::endl;
224 
225  for (int i = 0; i < operandTokenVectorSize; ++i) {
226 
227  myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
228  << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t"
229  << (m_operandTokenVector[i]).tokenResult
230  << std::endl;
231 
232  }
233 
234  }
235 
236  myCout << std::endl;
237 }
int i
Definition: DBlmapReader.cc:9
bool m_algoResult
algorithm result
std::vector< OperandToken > m_operandTokenVector
vector of operand tokens
std::vector< CombinationsInCond > m_algoCombinationVector
void L1GtAlgorithmEvaluation::setGtAlgoResult ( const bool  algoResult)
inline

Definition at line 96 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

96  {
97  m_algoResult = algoResult;
98  }
bool m_algoResult
algorithm result

Member Data Documentation

std::vector<CombinationsInCond> L1GtAlgorithmEvaluation::m_algoCombinationVector
private
bool L1GtAlgorithmEvaluation::m_algoResult
private

algorithm result

Definition at line 115 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), gtAlgoResult(), L1GtAlgorithmEvaluation(), print(), and setGtAlgoResult().