CMS 3D CMS Logo

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

Definition at line 69 of file L1GtAlgorithmEvaluation.h.

Definition at line 68 of file L1GtAlgorithmEvaluation.h.

Constructor & Destructor Documentation

L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( const L1GtAlgorithm alg)
explicit

constructor

constructor from an algorithm from event setup

Definition at line 43 of file L1GtAlgorithmEvaluation.cc.

45  m_rpnVector(alg.algoRpnVector()) {
46 
47  // the rest is properly initialized by default
48 }
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 53 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().

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

Referenced by L1GlobalTriggerGTL::run().

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

get / set the result of the algorithm

Definition at line 93 of file L1GtAlgorithmEvaluation.h.

Referenced by L1GlobalTriggerGTL::run().

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

Definition at line 109 of file L1GtAlgorithmEvaluation.h.

References edm::print().

Referenced by L1GlobalTriggerGTL::run().

109  {
110  return m_operandTokenVector;
111  }
std::vector< OperandToken > m_operandTokenVector
void L1GtAlgorithmEvaluation::print ( std::ostream &  myCout) const

Definition at line 175 of file L1GtAlgorithmEvaluation.cc.

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

Referenced by L1GlobalTriggerGTL::run().

175  {
176 
177  myCout << std::endl;
178 
179  myCout << " Algorithm result: " << m_algoResult << std::endl;
180 
181  myCout << " CombinationVector size: " << m_algoCombinationVector.size()
182  << std::endl;
183 
184  int operandTokenVectorSize = m_operandTokenVector.size();
185 
186  myCout << " Operand token vector size: " << operandTokenVectorSize;
187 
188  if (operandTokenVectorSize == 0) {
189  myCout << " - not properly initialized! " << std::endl;
190  } else {
191  myCout << std::endl;
192 
193  for (int i = 0; i < operandTokenVectorSize; ++i) {
194 
195  myCout << " " << std::setw(5)
196  << (m_operandTokenVector[i]).tokenNumber << "\t" << std::setw(25)
197  << (m_operandTokenVector[i]).tokenName << "\t"
198  << (m_operandTokenVector[i]).tokenResult << std::endl;
199  }
200  }
201 
202  myCout << std::endl;
203 }
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 95 of file L1GtAlgorithmEvaluation.h.

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

Member Data Documentation

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

Definition at line 125 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), and print().

bool L1GtAlgorithmEvaluation::m_algoResult
private

algorithm result

Definition at line 117 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), and print().

std::string const& L1GtAlgorithmEvaluation::m_logicalExpression
private

Definition at line 120 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm().

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

Definition at line 123 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm(), and print().

RpnVector const& L1GtAlgorithmEvaluation::m_rpnVector
private

Definition at line 121 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm().