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>

Public Types

typedef
ConditionEvaluationMap::const_iterator 
CItEvalMap
 
typedef __gnu_cxx::hash_map
< std::string,
L1GtConditionEvaluation * > 
ConditionEvaluationMap
 copy constructor More...
 
typedef
ConditionEvaluationMap::iterator 
ItEvalMap
 
typedef
L1GtLogicParser::OperandToken 
OperandToken
 
typedef std::vector< TokenRPNRpnVector
 
typedef L1GtLogicParser::TokenRPN TokenRPN
 

Public Member Functions

void evaluateAlgorithm (const int chipNumber, const std::vector< ConditionEvaluationMap > &)
 evaluate an algorithm More...
 
std::vector< CombinationsInCond > & gtAlgoCombinationVector ()
 
bool gtAlgoResult () const
 get / set the result of the algorithm More...
 
 L1GtAlgorithmEvaluation (const L1GtAlgorithm &)
 constructor More...
 
std::vector
< L1GtLogicParser::OperandToken > & 
operandTokenVector ()
 
void print (std::ostream &myCout) const
 
void setGtAlgoResult (const bool algoResult)
 

Private Attributes

std::vector< CombinationsInCondm_algoCombinationVector
 
bool m_algoResult
 algorithm result More...
 
std::string const & m_logicalExpression
 
std::vector< OperandTokenm_operandTokenVector
 
RpnVector const & m_rpnVector
 

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 68 of file L1GtAlgorithmEvaluation.h.

Member Typedef Documentation

typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap

Definition at line 90 of file L1GtAlgorithmEvaluation.h.

typedef __gnu_cxx ::hash_map<std::string, L1GtConditionEvaluation*> L1GtAlgorithmEvaluation::ConditionEvaluationMap

copy constructor

destructor

Definition at line 89 of file L1GtAlgorithmEvaluation.h.

typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap

Definition at line 91 of file L1GtAlgorithmEvaluation.h.

Definition at line 73 of file L1GtAlgorithmEvaluation.h.

Definition at line 72 of file L1GtAlgorithmEvaluation.h.

Definition at line 71 of file L1GtAlgorithmEvaluation.h.

Constructor & Destructor Documentation

L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( const L1GtAlgorithm alg)
explicit

constructor

constructor from an algorithm from event setup

Definition at line 47 of file L1GtAlgorithmEvaluation.cc.

47  :
48  m_algoResult(false),
51 
52  // the rest is properly initialized by default
53 
54 }
bool m_algoResult
algorithm result
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 const & m_logicalExpression

Member Function Documentation

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

evaluate an algorithm

Definition at line 60 of file L1GtAlgorithmEvaluation.cc.

References edm::hlt::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().

61  {
62 
63  // set result to false if there is no expression
64  if (m_rpnVector.empty() ) {
65  m_algoResult = false;
66 
67  // it should never be happen
68  throw cms::Exception("FailModule")
69  << "\nEmpty RPN vector for the logical expression = "
71  << std::endl;
72 
73  }
74 
75  // reserve memory
76  int rpnVectorSize = m_rpnVector.size();
77 
78  m_algoCombinationVector.reserve(rpnVectorSize);
79  m_operandTokenVector.reserve(rpnVectorSize);
80 
81  // stack containing temporary results
82  // FIXME we shall find a better solution than static
83  static std::stack<bool, std::vector<bool> > resultStack;
84  bool b1, b2;
85 
86  int opNumber = 0;
87 
88  for (RpnVector::const_iterator it = m_rpnVector.begin(); it != m_rpnVector.end(); it++) {
89 
90  //LogTrace("L1GlobalTrigger")
91  //<< "\nit->operation = " << it->operation
92  //<< "\nit->operand = '" << it->operand << "'\n"
93  //<< std::endl;
94 
95  switch (it->operation) {
96 
98 
99  CItEvalMap itCond = (conditionResultMaps.at(chipNumber)).find(it->operand);
100  if (itCond != (conditionResultMaps[chipNumber]).end()) {
101 
102  if (0 == itCond->second) {
103  // it should never be happen, only valid conditions are in the maps
104  throw cms::Exception("FailModule") << "\nCondition "
105  << (it->operand)
106  << " NULL pointer found in condition map"
107  << std::endl;
108  }
109 
110  //
111  bool condResult = (itCond->second)->condLastResult();
112 
113  resultStack.push(condResult);
114 
115  // only conditions are added to /counted in m_operandTokenVector
116  // opNumber is the index of the condition in the logical expression
117  OperandToken opToken;
118  opToken.tokenName = it->operand;
119  opToken.tokenNumber = opNumber;
120  opToken.tokenResult = condResult;
121 
122  m_operandTokenVector.push_back(opToken);
123  opNumber++;
124 
125  //
126  CombinationsInCond const & combInCondition = (itCond->second)->getCombinationsInCond();
127  m_algoCombinationVector.push_back(combInCondition);
128 
129  }
130  else {
131 
132  // it should never be happen, all conditions are in the maps
133  throw cms::Exception("FailModule")
134  << "\nCondition " << (it->operand) << " not found in condition map"
135  << std::endl;
136 
137  }
138 
139  }
140 
141  break;
143  b1 = resultStack.top();
144  resultStack.pop(); // pop the top
145  resultStack.push(!b1); // and push the result
146  }
147 
148  break;
149  case L1GtLogicParser::OP_OR: {
150  b1 = resultStack.top();
151  resultStack.pop();
152  b2 = resultStack.top();
153  resultStack.pop();
154  resultStack.push(b1 || b2);
155  }
156 
157  break;
159  b1 = resultStack.top();
160  resultStack.pop();
161  b2 = resultStack.top();
162  resultStack.pop();
163  resultStack.push(b1 && b2);
164  }
165 
166  break;
167  default: {
168  // should not arrive here
169  }
170 
171  break;
172  }
173 
174  }
175 
176  // get the result in the top of the stack
177 
178  m_algoResult = resultStack.top();
179 
180  // clear resultStack
181  while(!resultStack.empty()) resultStack.pop();
182 
183 }
bool m_algoResult
algorithm result
std::vector< OperandToken > m_operandTokenVector
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
L1GtLogicParser::OperandToken OperandToken
std::vector< CombinationsInCond > m_algoCombinationVector
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
std::string const & m_logicalExpression
ConditionEvaluationMap::const_iterator CItEvalMap
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().

110  {
112  }
std::vector< CombinationsInCond > 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().

96  {
97  return m_algoResult;
98  }
bool m_algoResult
algorithm result
std::vector<L1GtLogicParser::OperandToken>& L1GtAlgorithmEvaluation::operandTokenVector ( )
inline

Definition at line 114 of file L1GtAlgorithmEvaluation.h.

References m_operandTokenVector.

Referenced by L1GlobalTriggerGTL::run().

114  {
115  return m_operandTokenVector;
116  }
std::vector< OperandToken > 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().

186  {
187 
188  myCout << std::endl;
189 
190  myCout << " Algorithm result: " << m_algoResult << std::endl;
191 
192  myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
193 
194  int operandTokenVectorSize = m_operandTokenVector.size();
195 
196  myCout << " Operand token vector size: " << operandTokenVectorSize;
197 
198  if (operandTokenVectorSize == 0) {
199  myCout << " - not properly initialized! " << std::endl;
200  }
201  else {
202  myCout << std::endl;
203 
204  for (int i = 0; i < operandTokenVectorSize; ++i) {
205 
206  myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
207  << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t"
208  << (m_operandTokenVector[i]).tokenResult
209  << std::endl;
210 
211  }
212 
213  }
214 
215  myCout << std::endl;
216 }
int i
Definition: DBlmapReader.cc:9
bool m_algoResult
algorithm result
std::vector< OperandToken > m_operandTokenVector
std::vector< CombinationsInCond > m_algoCombinationVector
void L1GtAlgorithmEvaluation::setGtAlgoResult ( const bool  algoResult)
inline

Definition at line 100 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

100  {
101  m_algoResult = algoResult;
102  }
bool m_algoResult
algorithm result

Member Data Documentation

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().