CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
Date:
2012/03/02 21:46:28
Revision:
1.1

Definition at line 26 of file L1GlobalTriggerObjectMaps.h.

Constructor & Destructor Documentation

L1GlobalTriggerObjectMaps::L1GlobalTriggerObjectMaps ( )
inline

Definition at line 31 of file L1GlobalTriggerObjectMaps.h.

31 {}
L1GlobalTriggerObjectMaps::~L1GlobalTriggerObjectMaps ( )
inline

Definition at line 33 of file L1GlobalTriggerObjectMaps.h.

33 {}

Member Function Documentation

bool L1GlobalTriggerObjectMaps::algorithmExists ( int  algorithmBitNumber) const

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

Definition at line 32 of file L1GlobalTriggerObjectMaps.cc.

References i, and m_algorithmResults.

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

Returns whether an algorithm trigger passed or failed.

Definition at line 43 of file L1GlobalTriggerObjectMaps.cc.

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

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

Definition at line 156 of file L1GlobalTriggerObjectMaps.cc.

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

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

References i, and m_algorithmResults.

78  {
79  algorithmBitNumbers.clear();
80  for (std::vector<AlgorithmResult>::const_iterator i = m_algorithmResults.begin(),
81  iEnd = m_algorithmResults.end(); i != iEnd; ++i) {
82  algorithmBitNumbers.push_back(i->algorithmBitNumber());
83  }
84 }
int i
Definition: DBlmapReader.cc:9
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 104 of file L1GlobalTriggerObjectMaps.cc.

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

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

References getStartEndIndex(), and m_conditionResults.

96  {
97  unsigned startIndex = 0;
98  unsigned endIndex = 0;
99  getStartEndIndex(algorithmBitNumber, startIndex, endIndex);
100  return ConditionsInAlgorithm(&m_conditionResults[startIndex], endIndex - startIndex);
101 }
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 87 of file L1GlobalTriggerObjectMaps.cc.

References getStartEndIndex().

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

Definition at line 330 of file L1GlobalTriggerObjectMaps.cc.

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

Referenced by getCombinationsInCondition(), getConditionsInAlgorithm(), getNumberOfConditions(), and updateOperandTokenVector().

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

Returns the ID of the ParameterSet containing the algorithm names and condition names.

Definition at line 70 of file L1GlobalTriggerObjectMaps.h.

References m_namesParameterSetID.

70 { return m_namesParameterSetID; }
edm::ParameterSetID m_namesParameterSetID
void L1GlobalTriggerObjectMaps::pushBackAlgorithm ( unsigned  startIndexOfConditions,
int  algorithmBitNumber,
bool  algorithmResult 
)

Definition at line 148 of file L1GlobalTriggerObjectMaps.cc.

References m_algorithmResults.

150  {
151  m_algorithmResults.push_back(AlgorithmResult(startIndexOfConditions,
152  algorithmBitNumber,
153  algorithmResult));
154 }
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 217 of file L1GlobalTriggerObjectMaps.cc.

References m_conditionResults.

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

Definition at line 231 of file L1GlobalTriggerObjectMaps.cc.

References m_combinations.

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

Definition at line 143 of file L1GlobalTriggerObjectMaps.cc.

References m_algorithmResults.

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

Definition at line 212 of file L1GlobalTriggerObjectMaps.cc.

References m_conditionResults.

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

Definition at line 226 of file L1GlobalTriggerObjectMaps.cc.

References m_combinations.

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

Definition at line 236 of file L1GlobalTriggerObjectMaps.cc.

References m_namesParameterSetID.

236  {
237  m_namesParameterSetID = psetID;
238 }
edm::ParameterSetID m_namesParameterSetID
void L1GlobalTriggerObjectMaps::swap ( L1GlobalTriggerObjectMaps rh)

Definition at line 25 of file L1GlobalTriggerObjectMaps.cc.

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

Referenced by swap().

25  {
30 }
edm::ParameterSetID m_namesParameterSetID
void swap(Hash< I > &other)
Definition: Hash.h:202
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 58 of file L1GlobalTriggerObjectMaps.cc.

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

59  {
60  unsigned startIndex = 0;
61  unsigned endIndex = 0;
62  getStartEndIndex(algorithmBitNumber, startIndex, endIndex);
63 
64  unsigned length = endIndex - startIndex;
65  if (length != operandTokenVector.size()) {
66  cms::Exception ex("L1GlobalTrigger");
67  ex << "operand token vector size does not match number of conditions";
68  ex.addContext("Calling L1GlobalTriggerObjectMaps::updateOperandTokenVector");
69  throw ex;
70  }
71 
72  for (unsigned i = 0; i < length; ++i) {
73  operandTokenVector[i].tokenResult = m_conditionResults[startIndex + i].conditionResult();
74  }
75 }
int i
Definition: DBlmapReader.cc:9
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 174 of file L1GlobalTriggerObjectMaps.h.

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