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