CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtEnergySumCondition.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iostream>
22 #include <iomanip>
23 
24 #include <string>
25 #include <vector>
26 #include <algorithm>
27 
28 // user include files
29 // base classes
32 
34 
36 
39 
40 // constructors
41 // default
44 
45  //empty
46 
47 }
48 
49 // from base template condition (from event setup usually)
51  const L1GlobalTriggerPSB* ptrPSB) :
53  m_gtEnergySumTemplate(static_cast<const L1GtEnergySumTemplate*>(eSumTemplate)),
54  m_gtPSB(ptrPSB)
55 
56 {
57 
58  // maximum number of objects received for the evaluation of the condition
59  // energy sums are global quantities - one object per event
60 
62 
63 }
64 
65 // copy constructor
67 
69  m_gtPSB = cp.gtPSB();
70 
74 
76 
77 }
78 
81 
82  copy(cp);
83 
84 }
85 
86 // destructor
88 
89  // empty
90 
91 }
92 
93 // equal operator
95 {
96  copy(cp);
97  return *this;
98 }
99 
100 // methods
102  const L1GtEnergySumTemplate* eSumTempl) {
103 
104  m_gtEnergySumTemplate = eSumTempl;
105 
106 }
107 
110 
111  m_gtPSB = ptrPSB;
112 
113 }
114 
115 // try all object permutations and check spatial correlations, if required
117 
118  // number of trigger objects in the condition
119  // in fact, there is only one object
120  int iCondition = 0;
121 
122  // condition result condResult set to true if the energy sum
123  // passes all requirements
124  bool condResult = false;
125 
126  // store the indices of the calorimeter objects
127  // from the combination evaluated in the condition
128  SingleCombInCond objectsInComb;
129 
130  // clear the m_combinationsInCond vector
132 
133  // clear the indices in the combination
134  objectsInComb.clear();
135 
136  // get energy, phi (ETM and HTM) and overflow for the trigger object
137 
138  unsigned int candEt = 0;
139  unsigned int candPhi = 0;
140  bool candOverflow = false;
141 
142  switch ((m_gtEnergySumTemplate->objectType())[0]) {
143  case ETT: {
144  const L1GctEtTotal* cand1 = m_gtPSB->getCandL1ETT();
145 
146  if (cand1 == 0) {
147  return false;
148  }
149 
150  candEt = cand1->et();
151  candOverflow = cand1->overFlow();
152 
153  break;
154  }
155  case ETM: {
156  const L1GctEtMiss* cand2 = m_gtPSB->getCandL1ETM();
157 
158  if (cand2 == 0) {
159  return false;
160  }
161 
162  candEt = cand2->et();
163  candPhi = cand2->phi();
164  candOverflow = cand2->overFlow();
165 
166  break;
167  }
168  case HTT: {
169  const L1GctEtHad* cand3 = m_gtPSB->getCandL1HTT();
170 
171  if (cand3 == 0) {
172  return false;
173  }
174 
175  candEt = cand3->et();
176  candOverflow = cand3->overFlow();
177 
178  break;
179  }
180  case HTM: {
181  const L1GctHtMiss* cand4 = m_gtPSB->getCandL1HTM();
182 
183  if (cand4 == 0) {
184  return false;
185  }
186 
187  candEt = cand4->et();
188  candPhi = cand4->phi();
189  candOverflow = cand4->overFlow();
190 
191  break;
192  }
193  default: {
194  // should not arrive here
195  return false;
196 
197  break;
198  }
199  }
200 
202  ( *(m_gtEnergySumTemplate->objectParameter()) )[iCondition];
203 
204  // check energy threshold and overflow
205  // overflow evaluation:
206  // for condGEq >=
207  // candidate overflow true -> condition true
208  // candidate overflow false -> evaluate threshold
209  // for condGEq =
210  // candidate overflow true -> condition false
211  // candidate overflow false -> evaluate threshold
212  //
213 
214  bool condGEqVal = m_gtEnergySumTemplate->condGEq();
215 
216  if (condGEqVal) {
217  if (!candOverflow) {
218  if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
219  return false;
220  }
221  }
222  } else {
223  if (candOverflow) {
224  return false;
225  } else {
226  if (!checkThreshold(objPar.etThreshold, candEt, condGEqVal)) {
227  return false;
228  }
229  }
230 
231  }
232 
233  // for ETM and HTM check phi also
234  // for overflow, the phi requirements are ignored
235 
236  if (!candOverflow) {
237  if ( ( m_gtEnergySumTemplate->objectType() )[0] == ETM) {
238 
239  // phi bitmask is saved in two uint64_t (see parser)
240  if (candPhi < 64) {
241  if (!checkBit(objPar.phiRange0Word, candPhi)) {
242 
243  return false;
244  }
245  } else {
246  if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
247 
248  return false;
249  }
250  }
251 
252  } else if ( ( m_gtEnergySumTemplate->objectType() )[0] == HTM) {
253 
254  // phi bitmask is in the first word for HTM
255  if (candPhi < 64) {
256  if (!checkBit(objPar.phiRange0Word, candPhi)) {
257 
258  return false;
259  }
260  } else {
261  if (!checkBit(objPar.phiRange1Word, candPhi - 64)) {
262 
263  return false;
264  }
265  }
266  }
267  }
268 
269 
270  // index is always zero, as they are global quantities (there is only one object)
271  int indexObj = 0;
272 
273  objectsInComb.push_back(indexObj);
274  (combinationsInCond()).push_back(objectsInComb);
275 
276  // if we get here all checks were successfull for this combination
277  // set the general result for evaluateCondition to "true"
278 
279  condResult = true;
280  return condResult;
281 
282 }
283 
284 void L1GtEnergySumCondition::print(std::ostream& myCout) const {
285 
286  m_gtEnergySumTemplate->print(myCout);
288 
289 }
290 
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:41
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:38
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 bool evaluateCondition() const
the core function to check if the condition matches
const std::vector< L1GtObject > & objectType() const
get / set the trigger object type(s) in the condition
Definition: L1GtCondition.h:88
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 setGtPSB(const L1GlobalTriggerPSB *)
set the pointer to PSB
void print(std::ostream &myCout) const
print condition
bool overFlow() const
get the overflow
Definition: L1GctEtHad.h:48
Definition: L1GtObject.h:40
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 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:168
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
string const
Definition: compareJSON.py:14
unsigned et() const
get the magnitude
Definition: L1GctEtMiss.h:58
Definition: L1GtObject.h:39
virtual void print(std::ostream &myCout) const
print condition
const bool condGEq() const
get / set condition GEq flag
Definition: L1GtCondition.h:99
const L1GctEtHad * getCandL1HTT() const
pointer to HTT data list
virtual void print(std::ostream &myCout) const
print the condition
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