CMS 3D CMS Logo

L1GtEnergySumCondition.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iomanip>
20 #include <iostream>
21 
22 #include <algorithm>
23 #include <string>
24 #include <vector>
25 
26 // user include files
27 // base classes
30 
32 
34 
37 
38 // constructors
39 // default
41 
42  // empty
43 }
44 
45 // from base template condition (from event setup usually)
47  const L1GtCondition *eSumTemplate, const L1GlobalTriggerPSB *ptrPSB)
50  static_cast<const L1GtEnergySumTemplate *>(eSumTemplate)),
51  m_gtPSB(ptrPSB)
52 
53 {
54 
55  // maximum number of objects received for the evaluation of the condition
56  // energy sums are global quantities - one object per event
57 
59 }
60 
61 // copy constructor
63 
65  m_gtPSB = cp.gtPSB();
66 
70 
72 }
73 
76 
77  copy(cp);
78 }
79 
80 // destructor
82 
83  // empty
84 }
85 
86 // equal operator
89  copy(cp);
90  return *this;
91 }
92 
93 // methods
95  const L1GtEnergySumTemplate *eSumTempl) {
96 
97  m_gtEnergySumTemplate = eSumTempl;
98 }
99 
102 
103  m_gtPSB = ptrPSB;
104 }
105 
106 // try all object permutations and check spatial correlations, if required
108 
109  // number of trigger objects in the condition
110  // in fact, there is only one object
111  int iCondition = 0;
112 
113  // condition result condResult set to true if the energy sum
114  // passes all requirements
115  bool condResult = false;
116 
117  // store the indices of the calorimeter objects
118  // from the combination evaluated in the condition
119  SingleCombInCond objectsInComb;
120 
121  // clear the m_combinationsInCond vector
123 
124  // clear the indices in the combination
125  objectsInComb.clear();
126 
127  // get energy, phi (ETM and HTM) and overflow for the trigger object
128 
129  unsigned int candEt = 0;
130  unsigned int candPhi = 0;
131  bool candOverflow = false;
132 
133  switch ((m_gtEnergySumTemplate->objectType())[0]) {
134  case ETT: {
135  const L1GctEtTotal *cand1 = m_gtPSB->getCandL1ETT();
136 
137  if (cand1 == nullptr) {
138  return false;
139  }
140 
141  candEt = cand1->et();
142  candOverflow = cand1->overFlow();
143 
144  break;
145  }
146  case ETM: {
147  const L1GctEtMiss *cand2 = m_gtPSB->getCandL1ETM();
148 
149  if (cand2 == nullptr) {
150  return false;
151  }
152 
153  candEt = cand2->et();
154  candPhi = cand2->phi();
155  candOverflow = cand2->overFlow();
156 
157  break;
158  }
159  case HTT: {
160  const L1GctEtHad *cand3 = m_gtPSB->getCandL1HTT();
161 
162  if (cand3 == nullptr) {
163  return false;
164  }
165 
166  candEt = cand3->et();
167  candOverflow = cand3->overFlow();
168 
169  break;
170  }
171  case HTM: {
172  const L1GctHtMiss *cand4 = m_gtPSB->getCandL1HTM();
173 
174  if (cand4 == nullptr) {
175  return false;
176  }
177 
178  candEt = cand4->et();
179  candPhi = cand4->phi();
180  candOverflow = cand4->overFlow();
181 
182  break;
183  }
184  default: {
185  // should not arrive here
186  return false;
187 
188  break;
189  }
190  }
191 
193  (*(m_gtEnergySumTemplate->objectParameter()))[iCondition];
194 
195  // check energy threshold and overflow
196  // overflow evaluation:
197  // for condGEq >=
198  // candidate overflow true -> condition true
199  // candidate overflow false -> evaluate threshold
200  // for condGEq =
201  // candidate overflow true -> condition false
202  // candidate overflow false -> evaluate threshold
203  //
204 
205  bool condGEqVal = m_gtEnergySumTemplate->condGEq();
206 
207  if (condGEqVal) {
208  if (!candOverflow) {
209  if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
210  return false;
211  }
212  }
213  } else {
214  if (candOverflow) {
215  return false;
216  } else {
217  if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
218  return false;
219  }
220  }
221  }
222 
223  // for ETM and HTM check phi also
224  // for overflow, the phi requirements are ignored
225 
226  if (!candOverflow) {
227  if ((m_gtEnergySumTemplate->objectType())[0] == ETM) {
228 
229  // phi bitmask is saved in two uint64_t (see parser)
230  if (candPhi < 64) {
231  if (!checkBit(objPar.phiRange0Word, candPhi)) {
232 
233  return false;
234  }
235  } else {
236  if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
237 
238  return false;
239  }
240  }
241 
242  } else if ((m_gtEnergySumTemplate->objectType())[0] == HTM) {
243 
244  // phi bitmask is in the first word for HTM
245  if (candPhi < 64) {
246  if (!checkBit(objPar.phiRange0Word, candPhi)) {
247 
248  return false;
249  }
250  } else {
251  if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
252 
253  return false;
254  }
255  }
256  }
257  }
258 
259  // index is always zero, as they are global quantities (there is only one
260  // object)
261  int indexObj = 0;
262 
263  objectsInComb.push_back(indexObj);
264  (combinationsInCond()).push_back(objectsInComb);
265 
266  // if we get here all checks were successfull for this combination
267  // set the general result for evaluateCondition to "true"
268 
269  condResult = true;
270  return condResult;
271 }
272 
273 void L1GtEnergySumCondition::print(std::ostream &myCout) const {
274 
275  m_gtEnergySumTemplate->print(myCout);
277 }
void print(std::ostream &myCout) const override
print condition
bool overFlow() const
get the overflow
Definition: L1GctEtTotal.h:48
void setGtEnergySumTemplate(const L1GtEnergySumTemplate *)
unsigned et() const
get the Et
Definition: L1GctEtTotal.h:45
Definition: L1GtObject.h:39
const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const
check if a bit with a given number is set in a mask
bool m_condLastResult
the last result of evaluateCondition()
Definition: L1GtObject.h:36
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
CombinationsInCond & combinationsInCond() const
get all the object combinations (to fill it...)
const L1GctEtTotal * getCandL1ETT() const
pointer to ETT data list
std::vector< int > SingleCombInCond
typedefs
Persistable copy of missing Et measured at Level-1.
Definition: L1GctEtMiss.h:18
const std::vector< L1GtObject > & objectType() const
get / set the trigger object type(s) in the condition
Definition: L1GtCondition.h:90
unsigned phi() const
get the Et
Definition: L1GctEtMiss.h:64
const L1GtEnergySumTemplate * gtEnergySumTemplate() const
get / set the pointer to a L1GtCondition
const L1GlobalTriggerPSB * gtPSB() const
get / set the pointer to PSB
void print(std::ostream &myCout) const override
print the condition
void setGtPSB(const L1GlobalTriggerPSB *)
set the pointer to PSB
bool overFlow() const
get the overflow
Definition: L1GctEtHad.h:48
Definition: L1GtObject.h:38
bool overFlow() const
get the overflow
Definition: L1GctEtMiss.h:61
bool overFlow() const
get the overflow
Definition: L1GctHtMiss.h:63
unsigned et() const
get the Et
Definition: L1GctEtHad.h:45
const bool evaluateCondition() const override
the core function to check if the condition matches
const std::vector< ObjectParameter > * objectParameter() const
Persistable copy of total Et measured at Level-1.
Definition: L1GctEtTotal.h:18
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
const bool checkThreshold(const Type1 &threshold, const Type2 &value, const bool condGEqValue) const
unsigned et() const
get the magnitude
Definition: L1GctHtMiss.h:60
Persistable copy of total Ht measured at Level-1.
Definition: L1GctEtHad.h:18
L1GtEnergySumCondition & operator=(const L1GtEnergySumCondition &)
const L1GlobalTriggerPSB * m_gtPSB
pointer to PSB, to be able to get the trigger objects
const L1GtEnergySumTemplate * m_gtEnergySumTemplate
pointer to a L1GtEnergySumTemplate
const L1GctHtMiss * getCandL1HTM() const
pointer to HTM data list
Persistable copy of missing Et measured at Level-1.
Definition: L1GctHtMiss.h:16
const L1GctEtMiss * getCandL1ETM() const
pointer to ETM data list
unsigned et() const
get the magnitude
Definition: L1GctEtMiss.h:58
Definition: L1GtObject.h:37
virtual void print(std::ostream &myCout) const
print condition
const bool condGEq() const
get / set condition GEq flag
const L1GctEtHad * getCandL1HTT() const
pointer to HTT data list
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
unsigned phi() const
get the Et
Definition: L1GctHtMiss.h:66
typedef for a single object template
void copy(const L1GtEnergySumCondition &cp)
copy function for copy constructor and operator=
bool condLastResult() const
get the latest result for the condition