CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
L1GlobalTriggerObjectMaps Class Reference

#include <L1GlobalTriggerObjectMaps.h>

Classes

class  AlgorithmResult
 
class  CombinationsInCondition
 
class  ConditionResult
 
class  ConditionsInAlgorithm
 

Public Member Functions

bool algorithmExists (int algorithmBitNumber) const
 Returns true if there is an entry for this algorithm bit number. More...
 
bool algorithmResult (int algorithmBitNumber) const
 Returns whether an algorithm trigger passed or failed. More...
 
void consistencyCheck () const
 
void getAlgorithmBitNumbers (std::vector< int > &algorithmBitNumbers) const
 Fills the vector with all the algorithm bit numbers. More...
 
CombinationsInCondition getCombinationsInCondition (int algorithmBitNumber, unsigned conditionNumber) const
 
ConditionsInAlgorithm getConditionsInAlgorithm (int algorithmBitNumber) const
 
unsigned getNumberOfConditions (int algorithmBitNumber) const
 Number of conditions associated with an algorithm. More...
 
 L1GlobalTriggerObjectMaps ()
 
edm::ParameterSetID const & namesParameterSetID () const
 
void pushBackAlgorithm (unsigned startIndexOfConditions, int algorithmBitNumber, bool algorithmResult)
 
void pushBackCondition (unsigned startIndexOfCombinations, unsigned short nObjectsPerCombination, bool conditionResult)
 
void pushBackObjectIndex (unsigned char objectIndex)
 
void reserveForAlgorithms (unsigned n)
 
void reserveForConditions (unsigned n)
 
void reserveForObjectIndexes (unsigned n)
 
void setNamesParameterSetID (edm::ParameterSetID const &psetID)
 
void swap (L1GlobalTriggerObjectMaps &rh)
 
void updateOperandTokenVector (int algorithmBitNumber, std::vector< L1GtLogicParser::OperandToken > &operandTokenVector) const
 Update the condition result in the operandTokenVector. More...
 
 ~L1GlobalTriggerObjectMaps ()
 

Private Member Functions

void getStartEndIndex (int algorithmBitNumber, unsigned &startIndex, unsigned &endIndex) const
 

Private Attributes

std::vector< AlgorithmResultm_algorithmResults
 
std::vector< unsigned char > m_combinations
 
std::vector< ConditionResultm_conditionResults
 
edm::ParameterSetID m_namesParameterSetID
 

Detailed Description

Description: map trigger objects to algorithms and conditions.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna
: W. David Dagenhart

Definition at line 24 of file L1GlobalTriggerObjectMaps.h.

Constructor & Destructor Documentation

L1GlobalTriggerObjectMaps::L1GlobalTriggerObjectMaps ( )
inline

Definition at line 29 of file L1GlobalTriggerObjectMaps.h.

29 {}
L1GlobalTriggerObjectMaps::~L1GlobalTriggerObjectMaps ( )
inline

Member Function Documentation

bool L1GlobalTriggerObjectMaps::algorithmExists ( int  algorithmBitNumber) const

Returns true if there is an entry for this algorithm bit number.

Definition at line 30 of file L1GlobalTriggerObjectMaps.cc.

References mps_fire::i, and m_algorithmResults.

Referenced by pat::PATTriggerProducer::produce(), and ~L1GlobalTriggerObjectMaps().

30  {
31  std::vector<AlgorithmResult>::const_iterator i =
32  std::lower_bound(m_algorithmResults.begin(),
33  m_algorithmResults.end(),
34  AlgorithmResult(0, algorithmBitNumber, false));
35  if (i == m_algorithmResults.end() || i->algorithmBitNumber() != algorithmBitNumber) {
36  return false;
37  }
38  return true;
39 }
std::vector< AlgorithmResult > m_algorithmResults
bool L1GlobalTriggerObjectMaps::algorithmResult ( int  algorithmBitNumber) const

Returns whether an algorithm trigger passed or failed.

Definition at line 41 of file L1GlobalTriggerObjectMaps.cc.

References cms::Exception::addContext(), mps_fire::i, m_algorithmResults, and updateOperandTokenVector().

Referenced by CompareToObjectMapRecord::analyze(), pat::PATTriggerProducer::produce(), and ~L1GlobalTriggerObjectMaps().

41  {
42  std::vector<AlgorithmResult>::const_iterator i =
43  std::lower_bound(m_algorithmResults.begin(),
44  m_algorithmResults.end(),
45  AlgorithmResult(0, algorithmBitNumber, false));
46  if (i == m_algorithmResults.end() || i->algorithmBitNumber() != algorithmBitNumber) {
47  cms::Exception ex("L1GlobalTrigger");
48  ex << "algorithmBitNumber not found";
49  ex.addContext("Calling L1GlobalTriggerObjectMaps::algorithmResult");
50  throw ex;
51  }
52  return i->algorithmResult();
53 }
std::vector< AlgorithmResult > m_algorithmResults
void L1GlobalTriggerObjectMaps::consistencyCheck ( ) const

Definition at line 154 of file L1GlobalTriggerObjectMaps.cc.

References cms::Exception::addContext(), mps_fire::i, m_algorithmResults, m_combinations, m_conditionResults, reserveForConditions(), and mitigatedMETSequence_cff::U.

Referenced by namesParameterSetID(), and pat::PATTriggerProducer::produce().

154  {
155  // None of these checks should ever fail unless there
156  // is a bug in the code filling this object
157  for (std::vector<AlgorithmResult>::const_iterator i = m_algorithmResults.begin(),
158  iEnd = m_algorithmResults.end(); i != iEnd; ++i) {
159  std::vector<AlgorithmResult>::const_iterator j = i;
160  ++j;
161  if (j != iEnd && !(*i < *j)) {
162  cms::Exception ex("L1GlobalTrigger");
163  ex << "AlgorithmResults should be sorted in increasing order of bit number with no duplicates. It is not.";
164  ex.addContext("Calling L1GlobalTriggerObjectMaps::consistencyCheck");
165  throw ex;
166  }
167  unsigned endIndex =
168  (j != iEnd) ? j->startIndexOfConditions() : m_conditionResults.size();
169 
170  if (endIndex < i->startIndexOfConditions()) {
171  cms::Exception ex("L1GlobalTrigger");
172  ex << "startIndexOfConditions decreases or exceeds the size of m_conditionResults";
173  ex.addContext("Calling L1GlobalTriggerObjectMaps::consistencyCheck");
174  throw ex;
175  }
176  }
177  for (std::vector<ConditionResult>::const_iterator i = m_conditionResults.begin(),
178  iEnd = m_conditionResults.end(); i != iEnd; ++i) {
179  std::vector<ConditionResult>::const_iterator j = i;
180  ++j;
181  unsigned endIndex =
182  (j != iEnd) ? j->startIndexOfCombinations() : m_combinations.size();
183 
184  if (endIndex < i->startIndexOfCombinations()) {
185  cms::Exception ex("L1GlobalTrigger");
186  ex << "startIndexOfCombinations decreases or exceeds the size of m_conditionResults";
187  ex.addContext("Calling L1GlobalTriggerObjectMaps::consistencyCheck");
188  throw ex;
189  }
190  unsigned length = endIndex - i->startIndexOfCombinations();
191  if (length == 0U) {
192  if (i->nObjectsPerCombination() != 0U) {
193  cms::Exception ex("L1GlobalTrigger");
194  ex << "Length is zero and nObjectsInCombination is not zero";
195  ex.addContext("Calling L1GlobalTriggerObjectMaps::consistencyCheck");
196  throw ex;
197  }
198  } else {
199  if (i->nObjectsPerCombination() == 0 || length % i->nObjectsPerCombination() != 0) {
200  cms::Exception ex("L1GlobalTrigger");
201  ex << "Size indicated by startIndexOfCombinations is not a multiple of nObjectsInCombination";
202  ex.addContext("Calling L1GlobalTriggerObjectMaps::consistencyCheck");
203  throw ex;
204  }
205  }
206  }
207 }
std::vector< AlgorithmResult > m_algorithmResults
std::vector< unsigned char > m_combinations
std::vector< ConditionResult > m_conditionResults
void L1GlobalTriggerObjectMaps::getAlgorithmBitNumbers ( std::vector< int > &  algorithmBitNumbers) const

Fills the vector with all the algorithm bit numbers.

Definition at line 76 of file L1GlobalTriggerObjectMaps.cc.

References getNumberOfConditions(), mps_fire::i, and m_algorithmResults.

Referenced by CompareToObjectMapRecord::analyze(), updateOperandTokenVector(), and ~L1GlobalTriggerObjectMaps().

76  {
77  algorithmBitNumbers.clear();
78  for (std::vector<AlgorithmResult>::const_iterator i = m_algorithmResults.begin(),
79  iEnd = m_algorithmResults.end(); i != iEnd; ++i) {
80  algorithmBitNumbers.push_back(i->algorithmBitNumber());
81  }
82 }
std::vector< AlgorithmResult > m_algorithmResults
L1GlobalTriggerObjectMaps::CombinationsInCondition L1GlobalTriggerObjectMaps::getCombinationsInCondition ( int  algorithmBitNumber,
unsigned  conditionNumber 
) const

Each condition can be satisfied by multiple combinations of L1 objects. The number, order, and type of objects associated with each condition is defined in the L1 Trigger Menu. The following function returns an object which has a function that returns the index into the L1 Object Collections of each object in each combination.

Definition at line 102 of file L1GlobalTriggerObjectMaps.cc.

References cms::Exception::addContext(), getStartEndIndex(), m_combinations, m_conditionResults, reserveForAlgorithms(), and mitigatedMETSequence_cff::U.

Referenced by CompareToObjectMapRecord::analyze(), getConditionsInAlgorithm(), pat::PATTriggerProducer::produce(), and ~L1GlobalTriggerObjectMaps().

103  {
104  unsigned startIndex = 0;
105  unsigned endIndex = 0;
106  getStartEndIndex(algorithmBitNumber, startIndex, endIndex);
107 
108  if (endIndex <= startIndex + conditionNumber) {
109  cms::Exception ex("L1GlobalTrigger");
110  ex << "Condition number is out of range";
111  ex.addContext("Calling L1GlobalTriggerObjectMaps::getCombinationsInCondition");
112  throw ex;
113  }
114 
115  unsigned endObjectIndex = m_combinations.size();
116  unsigned nextConditionIndex = startIndex + conditionNumber + 1U;
117  if (nextConditionIndex < m_conditionResults.size()) {
118  endObjectIndex = m_conditionResults[nextConditionIndex].startIndexOfCombinations();
119  }
120  unsigned beginObjectIndex = m_conditionResults[startIndex + conditionNumber].startIndexOfCombinations();
121  unsigned short nObjectsPerCombination = m_conditionResults[startIndex + conditionNumber].nObjectsPerCombination();
122 
123  if (endObjectIndex == beginObjectIndex) {
124  return CombinationsInCondition(0, 0, 0);
125  }
126  if (endObjectIndex < beginObjectIndex ||
127  m_combinations.size() < endObjectIndex ||
128  nObjectsPerCombination == 0 ||
129  (endObjectIndex - beginObjectIndex) % nObjectsPerCombination != 0) {
130  cms::Exception ex("L1GlobalTrigger");
131  ex << "Indexes to combinations are invalid";
132  ex.addContext("Calling L1GlobalTriggerObjectMaps::getCombinationsInCondition");
133  throw ex;
134  }
135  return CombinationsInCondition(&m_combinations[beginObjectIndex],
136  (endObjectIndex - beginObjectIndex) / nObjectsPerCombination,
137  nObjectsPerCombination);
138 }
std::vector< unsigned char > m_combinations
std::vector< ConditionResult > m_conditionResults
void getStartEndIndex(int algorithmBitNumber, unsigned &startIndex, unsigned &endIndex) const
L1GlobalTriggerObjectMaps::ConditionsInAlgorithm L1GlobalTriggerObjectMaps::getConditionsInAlgorithm ( int  algorithmBitNumber) const

Return an object which has a function that returns the results of the conditions associated with an algorithm.

Definition at line 94 of file L1GlobalTriggerObjectMaps.cc.

References getCombinationsInCondition(), getStartEndIndex(), and m_conditionResults.

Referenced by CompareToObjectMapRecord::analyze(), getNumberOfConditions(), pat::PATTriggerProducer::produce(), and ~L1GlobalTriggerObjectMaps().

94  {
95  unsigned startIndex = 0;
96  unsigned endIndex = 0;
97  getStartEndIndex(algorithmBitNumber, startIndex, endIndex);
98  return ConditionsInAlgorithm(&m_conditionResults[startIndex], endIndex - startIndex);
99 }
std::vector< ConditionResult > m_conditionResults
void getStartEndIndex(int algorithmBitNumber, unsigned &startIndex, unsigned &endIndex) const
unsigned L1GlobalTriggerObjectMaps::getNumberOfConditions ( int  algorithmBitNumber) const

Number of conditions associated with an algorithm.

Definition at line 85 of file L1GlobalTriggerObjectMaps.cc.

References getConditionsInAlgorithm(), and getStartEndIndex().

Referenced by CompareToObjectMapRecord::analyze(), getAlgorithmBitNumbers(), and ~L1GlobalTriggerObjectMaps().

85  {
86 
87  unsigned startIndex = 0;
88  unsigned endIndex = 0;
89  getStartEndIndex(algorithmBitNumber, startIndex, endIndex);
90  return endIndex - startIndex;
91 }
void getStartEndIndex(int algorithmBitNumber, unsigned &startIndex, unsigned &endIndex) const
void L1GlobalTriggerObjectMaps::getStartEndIndex ( int  algorithmBitNumber,
unsigned &  startIndex,
unsigned &  endIndex 
) const
private

Definition at line 328 of file L1GlobalTriggerObjectMaps.cc.

References cms::Exception::addContext(), m_algorithmResults, and m_conditionResults.

Referenced by getCombinationsInCondition(), getConditionsInAlgorithm(), getNumberOfConditions(), L1GlobalTriggerObjectMaps::CombinationsInCondition::getObjectIndex(), and updateOperandTokenVector().

328  {
329  std::vector<AlgorithmResult>::const_iterator iAlgo =
330  std::lower_bound(m_algorithmResults.begin(),
331  m_algorithmResults.end(),
332  AlgorithmResult(0, algorithmBitNumber, false));
333 
334  if (iAlgo == m_algorithmResults.end() || iAlgo->algorithmBitNumber() != algorithmBitNumber) {
335  cms::Exception ex("L1GlobalTrigger");
336  ex << "algorithmBitNumber not found";
337  ex.addContext("Calling L1GlobalTriggerObjectMaps::getStartEndIndex");
338  throw ex;
339  }
340 
341  startIndex = iAlgo->startIndexOfConditions();
342  ++iAlgo;
343  endIndex = (iAlgo != m_algorithmResults.end()) ?
344  iAlgo->startIndexOfConditions() : m_conditionResults.size();
345 
346  if (endIndex < startIndex || m_conditionResults.size() < endIndex) {
347  cms::Exception ex("L1GlobalTrigger");
348  ex << "index out of order or out of range";
349  ex.addContext("Calling L1GlobalTriggerObjectMaps::getStartEndIndex");
350  throw ex;
351  }
352 }
std::vector< AlgorithmResult > m_algorithmResults
std::vector< ConditionResult > m_conditionResults
edm::ParameterSetID const& L1GlobalTriggerObjectMaps::namesParameterSetID ( ) const
inline
void L1GlobalTriggerObjectMaps::pushBackAlgorithm ( unsigned  startIndexOfConditions,
int  algorithmBitNumber,
bool  algorithmResult 
)

Definition at line 146 of file L1GlobalTriggerObjectMaps.cc.

References m_algorithmResults.

Referenced by namesParameterSetID(), and reserveForAlgorithms().

148  {
149  m_algorithmResults.push_back(AlgorithmResult(startIndexOfConditions,
150  algorithmBitNumber,
151  algorithmResult));
152 }
std::vector< AlgorithmResult > m_algorithmResults
bool algorithmResult(int algorithmBitNumber) const
Returns whether an algorithm trigger passed or failed.
void L1GlobalTriggerObjectMaps::pushBackCondition ( unsigned  startIndexOfCombinations,
unsigned short  nObjectsPerCombination,
bool  conditionResult 
)

Definition at line 215 of file L1GlobalTriggerObjectMaps.cc.

References m_conditionResults, and reserveForObjectIndexes().

Referenced by namesParameterSetID(), and reserveForConditions().

217  {
218  m_conditionResults.push_back(ConditionResult(startIndexOfCombinations,
219  nObjectsPerCombination,
220  conditionResult));
221 }
std::vector< ConditionResult > m_conditionResults
void L1GlobalTriggerObjectMaps::pushBackObjectIndex ( unsigned char  objectIndex)

Definition at line 229 of file L1GlobalTriggerObjectMaps.cc.

References m_combinations, and setNamesParameterSetID().

Referenced by namesParameterSetID(), and reserveForObjectIndexes().

229  {
230  m_combinations.push_back(objectIndex);
231 }
std::vector< unsigned char > m_combinations
void L1GlobalTriggerObjectMaps::reserveForAlgorithms ( unsigned  n)

Definition at line 141 of file L1GlobalTriggerObjectMaps.cc.

References m_algorithmResults, and pushBackAlgorithm().

Referenced by getCombinationsInCondition(), and namesParameterSetID().

141  {
142  m_algorithmResults.reserve(n);
143 }
std::vector< AlgorithmResult > m_algorithmResults
void L1GlobalTriggerObjectMaps::reserveForConditions ( unsigned  n)

Definition at line 210 of file L1GlobalTriggerObjectMaps.cc.

References m_conditionResults, and pushBackCondition().

Referenced by consistencyCheck(), and namesParameterSetID().

210  {
211  m_conditionResults.reserve(n);
212 }
std::vector< ConditionResult > m_conditionResults
void L1GlobalTriggerObjectMaps::reserveForObjectIndexes ( unsigned  n)

Definition at line 224 of file L1GlobalTriggerObjectMaps.cc.

References m_combinations, and pushBackObjectIndex().

Referenced by namesParameterSetID(), and pushBackCondition().

224  {
225  m_combinations.reserve(n);
226 }
std::vector< unsigned char > m_combinations
void L1GlobalTriggerObjectMaps::setNamesParameterSetID ( edm::ParameterSetID const &  psetID)
void L1GlobalTriggerObjectMaps::swap ( L1GlobalTriggerObjectMaps rh)

Definition at line 23 of file L1GlobalTriggerObjectMaps.cc.

References m_algorithmResults, m_combinations, m_conditionResults, m_namesParameterSetID, and edm::Hash< I >::swap().

Referenced by swap(), and ~L1GlobalTriggerObjectMaps().

23  {
28 }
edm::ParameterSetID m_namesParameterSetID
void swap(Hash< I > &other)
Definition: Hash.h:207
std::vector< AlgorithmResult > m_algorithmResults
std::vector< unsigned char > m_combinations
std::vector< ConditionResult > m_conditionResults
void L1GlobalTriggerObjectMaps::updateOperandTokenVector ( int  algorithmBitNumber,
std::vector< L1GtLogicParser::OperandToken > &  operandTokenVector 
) const

Update the condition result in the operandTokenVector.

Definition at line 56 of file L1GlobalTriggerObjectMaps.cc.

References cms::Exception::addContext(), getAlgorithmBitNumbers(), getStartEndIndex(), mps_fire::i, and m_conditionResults.

Referenced by algorithmResult(), and ~L1GlobalTriggerObjectMaps().

57  {
58  unsigned startIndex = 0;
59  unsigned endIndex = 0;
60  getStartEndIndex(algorithmBitNumber, startIndex, endIndex);
61 
62  unsigned length = endIndex - startIndex;
63  if (length != operandTokenVector.size()) {
64  cms::Exception ex("L1GlobalTrigger");
65  ex << "operand token vector size does not match number of conditions";
66  ex.addContext("Calling L1GlobalTriggerObjectMaps::updateOperandTokenVector");
67  throw ex;
68  }
69 
70  for (unsigned i = 0; i < length; ++i) {
71  operandTokenVector[i].tokenResult = m_conditionResults[startIndex + i].conditionResult();
72  }
73 }
std::vector< ConditionResult > m_conditionResults
void getStartEndIndex(int algorithmBitNumber, unsigned &startIndex, unsigned &endIndex) const

Member Data Documentation

std::vector<AlgorithmResult> L1GlobalTriggerObjectMaps::m_algorithmResults
private
std::vector<unsigned char> L1GlobalTriggerObjectMaps::m_combinations
private
std::vector<ConditionResult> L1GlobalTriggerObjectMaps::m_conditionResults
private
edm::ParameterSetID L1GlobalTriggerObjectMaps::m_namesParameterSetID
private

Definition at line 172 of file L1GlobalTriggerObjectMaps.h.

Referenced by namesParameterSetID(), setNamesParameterSetID(), and swap().