CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GlobalTriggerObjectMaps.h
Go to the documentation of this file.
1 #ifndef DataFormats_L1GlobalTrigger_L1GlobalTriggerObjectMaps_h
2 #define DataFormats_L1GlobalTrigger_L1GlobalTriggerObjectMaps_h
3 
21 #include <vector>
22 
25 
27 {
28 
29 public:
30 
32 
34 
36 
38  bool algorithmExists(int algorithmBitNumber) const;
39 
41  bool algorithmResult(int algorithmBitNumber) const;
42 
44  void updateOperandTokenVector(int algorithmBitNumber,
45  std::vector<L1GtLogicParser::OperandToken>& operandTokenVector) const;
46 
48  void getAlgorithmBitNumbers(std::vector<int>& algorithmBitNumbers) const;
49 
51  unsigned getNumberOfConditions(int algorithmBitNumber) const;
52 
53  class ConditionsInAlgorithm;
54  class CombinationsInCondition;
55 
58  ConditionsInAlgorithm getConditionsInAlgorithm(int algorithmBitNumber) const;
59 
65  CombinationsInCondition getCombinationsInCondition(int algorithmBitNumber,
66  unsigned conditionNumber) const;
67 
71 
72  // the rest are methods used to fill the data
73  // and should only be used by the producer that
74  // creates these and puts them into the event.
75  // There are requirements on ordering and the
76  // stored indexes that the code that calls these
77  // functions is expected to carefully take care of.
78 
79  void reserveForAlgorithms(unsigned n);
80  void pushBackAlgorithm(unsigned startIndexOfConditions,
81  int algorithmBitNumber,
82  bool algorithmResult);
83 
84  // This function should be called after filling the data in this object
85  // using the pushBack* methods.
86  void consistencyCheck() const;
87 
88  void reserveForConditions(unsigned n);
89  void pushBackCondition(unsigned startIndexOfCombinations,
90  unsigned short nObjectsPerCombination,
91  bool conditionResult);
92 
93  void reserveForObjectIndexes(unsigned n);
94  void pushBackObjectIndex(unsigned char objectIndex);
95 
96  void setNamesParameterSetID(edm::ParameterSetID const& psetID);
97 
99  public:
100  AlgorithmResult();
102  int algorithmBitNumber,
103  bool algorithmResult);
105  short algorithmBitNumber() const { return m_algorithmBitNumber; }
106  bool algorithmResult() const { return m_algorithmResult; }
107  // The operator is used for searching in the std::vector<AlgorithmResult>
108  bool operator<(AlgorithmResult const& right) const {
109  return m_algorithmBitNumber < right.algorithmBitNumber();
110  }
111  private:
115  };
116 
118  public:
119  ConditionResult();
121  unsigned short nObjectsPerCombination,
122  bool conditionResult);
124  unsigned short nObjectsPerCombination() const { return m_nObjectsPerCombination; }
125  bool conditionResult() const { return m_conditionResult; }
126  private:
128  unsigned short m_nObjectsPerCombination;
130  };
131 
133  public:
134  ConditionsInAlgorithm(ConditionResult const* conditionResults,
135  unsigned nConditions);
136  unsigned nConditions() const { return m_nConditions; }
137  bool getConditionResult(unsigned condition) const;
138 
139  private:
141  unsigned m_nConditions;
142  };
143 
145  public:
146  CombinationsInCondition(unsigned char const* startOfObjectIndexes,
147  unsigned nCombinations,
148  unsigned short nObjectsPerCombination);
149 
150  unsigned nCombinations() const { return m_nCombinations; }
151  unsigned short nObjectsPerCombination() const { return m_nObjectsPerCombination; }
152  unsigned char getObjectIndex(unsigned combination,
153  unsigned object) const;
154  private:
155  unsigned char const* m_startOfObjectIndexes;
156  unsigned m_nCombinations;
157  unsigned short m_nObjectsPerCombination;
158  };
159 
160 private:
161 
162  void getStartEndIndex(int algorithmBitNumber, unsigned& startIndex, unsigned& endIndex) const;
163 
164  // data members
165  // The vectors are sorted. All three vectors are in algorithmBitNumber
166  // order. The second two vectors are sorted such that within an algorithm
167  // the conditions appear in the same order as in the algorithm logical
168  // expression. And the third is additionally sorted so each combination
169  // is contiguous and within a combination the order is the same as the
170  // type specification in the L1 Trigger Menu.
171  std::vector<AlgorithmResult> m_algorithmResults;
172  std::vector<ConditionResult> m_conditionResults;
173  std::vector<unsigned char> m_combinations;
175 };
176 
178  lh.swap(rh);
179 }
180 
181 #endif
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:70
unsigned char getObjectIndex(unsigned combination, unsigned object) const
void pushBackCondition(unsigned startIndexOfCombinations, unsigned short nObjectsPerCombination, bool conditionResult)
void pushBackObjectIndex(unsigned char objectIndex)
ConditionsInAlgorithm(ConditionResult const *conditionResults, unsigned nConditions)
edm::ParameterSetID m_namesParameterSetID
bool int lh
Definition: SSEVec.h:55
void getAlgorithmBitNumbers(std::vector< int > &algorithmBitNumbers) const
Fills the vector with all the algorithm bit numbers.
bool algorithmExists(int algorithmBitNumber) const
Returns true if there is an entry for this algorithm bit number.
bool operator<(AlgorithmResult const &right) const
void swap(L1GlobalTriggerObjectMaps &rh)
std::vector< AlgorithmResult > m_algorithmResults
edm::ParameterSetID const & namesParameterSetID() const
std::vector< unsigned char > m_combinations
std::vector< ConditionResult > m_conditionResults
CombinationsInCondition(unsigned char const *startOfObjectIndexes, unsigned nCombinations, unsigned short nObjectsPerCombination)
void updateOperandTokenVector(int algorithmBitNumber, std::vector< L1GtLogicParser::OperandToken > &operandTokenVector) const
Update the condition result in the operandTokenVector.
void pushBackAlgorithm(unsigned startIndexOfConditions, int algorithmBitNumber, bool algorithmResult)
CombinationsInCondition getCombinationsInCondition(int algorithmBitNumber, unsigned conditionNumber) const
unsigned getNumberOfConditions(int algorithmBitNumber) const
Number of conditions associated with an algorithm.
void setNamesParameterSetID(edm::ParameterSetID const &psetID)
ConditionsInAlgorithm getConditionsInAlgorithm(int algorithmBitNumber) const
bool algorithmResult(int algorithmBitNumber) const
Returns whether an algorithm trigger passed or failed.
void getStartEndIndex(int algorithmBitNumber, unsigned &startIndex, unsigned &endIndex) const