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

Definition at line 66 of file L1GtAlgorithmEvaluation.h.

Member Typedef Documentation

typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap

Definition at line 88 of file L1GtAlgorithmEvaluation.h.

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

copy constructor

destructor

Definition at line 87 of file L1GtAlgorithmEvaluation.h.

typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap

Definition at line 89 of file L1GtAlgorithmEvaluation.h.

Definition at line 71 of file L1GtAlgorithmEvaluation.h.

Definition at line 70 of file L1GtAlgorithmEvaluation.h.

Definition at line 69 of file L1GtAlgorithmEvaluation.h.

Constructor & Destructor Documentation

L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( const L1GtAlgorithm alg)
explicit

constructor

constructor from an algorithm from event setup

Definition at line 45 of file L1GtAlgorithmEvaluation.cc.

45  :
46  m_algoResult(false),
49 
50  // the rest is properly initialized by default
51 
52 }
bool m_algoResult
algorithm result
const std::vector< L1GtLogicParser::TokenRPN > & algoRpnVector() const
return the RPN vector
Definition: L1GtAlgorithm.h:89
std::string const & algoLogicalExpression() const
get / set the logical expression for the algorithm
Definition: L1GtAlgorithm.h:78
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 58 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().

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

References m_algoCombinationVector.

Referenced by L1GlobalTriggerGTL::run().

108  {
110  }
std::vector< CombinationsInCond > m_algoCombinationVector
bool L1GtAlgorithmEvaluation::gtAlgoResult ( ) const
inline

get / set the result of the algorithm

Definition at line 94 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

Referenced by L1GlobalTriggerGTL::run().

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

Definition at line 112 of file L1GtAlgorithmEvaluation.h.

References m_operandTokenVector.

Referenced by L1GlobalTriggerGTL::run().

112  {
113  return m_operandTokenVector;
114  }
std::vector< OperandToken > m_operandTokenVector
void L1GtAlgorithmEvaluation::print ( std::ostream &  myCout) const

Definition at line 183 of file L1GtAlgorithmEvaluation.cc.

References i, m_algoCombinationVector, m_algoResult, and m_operandTokenVector.

Referenced by L1GlobalTriggerGTL::run().

183  {
184 
185  myCout << std::endl;
186 
187  myCout << " Algorithm result: " << m_algoResult << std::endl;
188 
189  myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
190 
191  int operandTokenVectorSize = m_operandTokenVector.size();
192 
193  myCout << " Operand token vector size: " << operandTokenVectorSize;
194 
195  if (operandTokenVectorSize == 0) {
196  myCout << " - not properly initialized! " << std::endl;
197  }
198  else {
199  myCout << std::endl;
200 
201  for (int i = 0; i < operandTokenVectorSize; ++i) {
202 
203  myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
204  << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t"
205  << (m_operandTokenVector[i]).tokenResult
206  << std::endl;
207 
208  }
209 
210  }
211 
212  myCout << std::endl;
213 }
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 98 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

98  {
99  m_algoResult = algoResult;
100  }
bool m_algoResult
algorithm result

Member Data Documentation

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

Definition at line 129 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), gtAlgoCombinationVector(), and print().

bool L1GtAlgorithmEvaluation::m_algoResult
private

algorithm result

Definition at line 121 of file L1GtAlgorithmEvaluation.h.

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

std::string const& L1GtAlgorithmEvaluation::m_logicalExpression
private

Definition at line 124 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm().

std::vector<OperandToken> L1GtAlgorithmEvaluation::m_operandTokenVector
private

Definition at line 127 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), operandTokenVector(), and print().

RpnVector const& L1GtAlgorithmEvaluation::m_rpnVector
private

Definition at line 125 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm().