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 std ::unordered_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 34 of file L1GtAlgorithmEvaluation.h.

Member Typedef Documentation

◆ CItEvalMap

typedef ConditionEvaluationMap::const_iterator L1GtAlgorithmEvaluation::CItEvalMap

Definition at line 55 of file L1GtAlgorithmEvaluation.h.

◆ ConditionEvaluationMap

typedef std ::unordered_map<std::string, L1GtConditionEvaluation *> L1GtAlgorithmEvaluation::ConditionEvaluationMap

copy constructor

destructor

Definition at line 54 of file L1GtAlgorithmEvaluation.h.

◆ ItEvalMap

typedef ConditionEvaluationMap::iterator L1GtAlgorithmEvaluation::ItEvalMap

Definition at line 56 of file L1GtAlgorithmEvaluation.h.

◆ OperandToken

Definition at line 38 of file L1GtAlgorithmEvaluation.h.

◆ RpnVector

Definition at line 37 of file L1GtAlgorithmEvaluation.h.

◆ TokenRPN

Definition at line 36 of file L1GtAlgorithmEvaluation.h.

Constructor & Destructor Documentation

◆ L1GtAlgorithmEvaluation()

L1GtAlgorithmEvaluation::L1GtAlgorithmEvaluation ( const L1GtAlgorithm alg)
explicit

constructor

constructor from an algorithm from event setup

Definition at line 42 of file L1GtAlgorithmEvaluation.cc.

44  // the rest is properly initialized by default
45 }
bool m_algoResult
algorithm result
const std::vector< L1GtLogicParser::TokenRPN > & algoRpnVector() const
return the RPN vector
Definition: L1GtAlgorithm.h:69
std::string const & m_logicalExpression
std::string const & algoLogicalExpression() const
get / set the logical expression for the algorithm
Definition: L1GtAlgorithm.h:62

Member Function Documentation

◆ evaluateAlgorithm()

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

evaluate an algorithm

Definition at line 50 of file L1GtAlgorithmEvaluation.cc.

References b1, b2, 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().

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

◆ gtAlgoCombinationVector()

std::vector<CombinationsInCond>& L1GtAlgorithmEvaluation::gtAlgoCombinationVector ( )
inline

get all the object combinations evaluated to true in the conditions from the algorithm

Definition at line 69 of file L1GtAlgorithmEvaluation.h.

References m_algoCombinationVector.

Referenced by L1GlobalTriggerGTL::run().

69 { return m_algoCombinationVector; }
std::vector< CombinationsInCond > m_algoCombinationVector

◆ gtAlgoResult()

bool L1GtAlgorithmEvaluation::gtAlgoResult ( ) const
inline

get / set the result of the algorithm

Definition at line 60 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

Referenced by L1GlobalTriggerGTL::run().

60 { return m_algoResult; }
bool m_algoResult
algorithm result

◆ operandTokenVector()

std::vector<L1GtLogicParser::OperandToken>& L1GtAlgorithmEvaluation::operandTokenVector ( )
inline

Definition at line 71 of file L1GtAlgorithmEvaluation.h.

References m_operandTokenVector.

Referenced by L1GlobalTriggerGTL::run().

71 { return m_operandTokenVector; }
std::vector< OperandToken > m_operandTokenVector

◆ print()

void L1GtAlgorithmEvaluation::print ( std::ostream &  myCout) const

Definition at line 159 of file L1GtAlgorithmEvaluation.cc.

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

Referenced by L1GlobalTriggerGTL::run().

159  {
160  myCout << std::endl;
161 
162  myCout << " Algorithm result: " << m_algoResult << std::endl;
163 
164  myCout << " CombinationVector size: " << m_algoCombinationVector.size() << std::endl;
165 
166  int operandTokenVectorSize = m_operandTokenVector.size();
167 
168  myCout << " Operand token vector size: " << operandTokenVectorSize;
169 
170  if (operandTokenVectorSize == 0) {
171  myCout << " - not properly initialized! " << std::endl;
172  } else {
173  myCout << std::endl;
174 
175  for (int i = 0; i < operandTokenVectorSize; ++i) {
176  myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t" << std::setw(25)
177  << (m_operandTokenVector[i]).tokenName << "\t" << (m_operandTokenVector[i]).tokenResult << std::endl;
178  }
179  }
180 
181  myCout << std::endl;
182 }
bool m_algoResult
algorithm result
std::vector< OperandToken > m_operandTokenVector
std::vector< CombinationsInCond > m_algoCombinationVector

◆ setGtAlgoResult()

void L1GtAlgorithmEvaluation::setGtAlgoResult ( const bool  algoResult)
inline

Definition at line 62 of file L1GtAlgorithmEvaluation.h.

References m_algoResult.

62 { m_algoResult = algoResult; }
bool m_algoResult
algorithm result

Member Data Documentation

◆ m_algoCombinationVector

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

Definition at line 85 of file L1GtAlgorithmEvaluation.h.

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

◆ m_algoResult

bool L1GtAlgorithmEvaluation::m_algoResult
private

algorithm result

Definition at line 77 of file L1GtAlgorithmEvaluation.h.

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

◆ m_logicalExpression

std::string const& L1GtAlgorithmEvaluation::m_logicalExpression
private

Definition at line 80 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm().

◆ m_operandTokenVector

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

Definition at line 83 of file L1GtAlgorithmEvaluation.h.

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

◆ m_rpnVector

RpnVector const& L1GtAlgorithmEvaluation::m_rpnVector
private

Definition at line 81 of file L1GtAlgorithmEvaluation.h.

Referenced by evaluateAlgorithm().