CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
l1t::ConditionEvaluation Class Referenceabstract

#include <ConditionEvaluation.h>

Inheritance diagram for l1t::ConditionEvaluation:
l1t::CaloCondition l1t::CorrCondition l1t::CorrWithOverlapRemovalCondition l1t::EnergySumCondition l1t::ExternalCondition l1t::MuCondition

Public Member Functions

 ConditionEvaluation ()
 constructor More...
 
bool condLastResult () const
 get the latest result for the condition More...
 
int condMaxNumberObjects () const
 
virtual const bool evaluateCondition (const int bxEval) const =0
 the core function to check if the condition matches More...
 
void evaluateConditionStoreResult (const int bxEval)
 call evaluateCondition and save last result More...
 
CombinationsInCond const & getCombinationsInCond () const
 get all the object combinations evaluated to true in the condition More...
 
virtual std::string getNumericExpression () const
 get numeric expression More...
 
virtual void print (std::ostream &myCout) const
 print condition More...
 
void setCondMaxNumberObjects (int condMaxNumberObjectsValue)
 
void setVerbosity (const int verbosity)
 
virtual ~ConditionEvaluation ()
 destructor More...
 

Protected Member Functions

template<class Type1 >
const bool checkBit (const Type1 &mask, const unsigned int bitNumber) const
 check if a bit with a given number is set in a mask More...
 
template<class Type1 >
const bool checkIndex (const Type1 &indexLo, const Type1 &indexHi, const unsigned int index) const
 check if a index is in a given range More...
 
template<class Type1 >
const bool checkRangeDeltaEta (const unsigned int obj1Eta, const unsigned int obj2Eta, const Type1 &lowerR, const Type1 &upperR, const unsigned int nEtaBits) const
 check if a value is in a given range More...
 
template<class Type1 >
const bool checkRangeDeltaPhi (const unsigned int obj1Phi, const unsigned int obj2Phi, const Type1 &lowerR, const Type1 &upperR) const
 check if a value is in a given range More...
 
template<class Type1 >
const bool checkRangeEta (const unsigned int bitNumber, const Type1 &W1beginR, const Type1 &W1endR, const Type1 &W2beginR, const Type1 &W2endR, const unsigned int nEtaBits) const
 check if a value is in a given range and outside of a veto range More...
 
template<class Type1 >
const bool checkRangePhi (const unsigned int bitNumber, const Type1 &W1beginR, const Type1 &W1endR, const Type1 &W2beginR, const Type1 &W2endR) const
 check if a value is in a given range and outside of a veto range More...
 
template<class Type1 , class Type2 >
const bool checkThreshold (const Type1 &thresholdL, const Type1 &thresholdH, const Type2 &value, bool condGEqValue) const
 
CombinationsInCondcombinationsInCond () const
 get all the object combinations (to fill it...) More...
 

Protected Attributes

CombinationsInCond m_combinationsInCond
 store all the object combinations evaluated to true in the condition More...
 
bool m_condLastResult
 the last result of evaluateCondition() More...
 
int m_condMaxNumberObjects
 
int m_verbosity
 verbosity level More...
 

Detailed Description

Definition at line 39 of file ConditionEvaluation.h.

Constructor & Destructor Documentation

l1t::ConditionEvaluation::ConditionEvaluation ( )
inline

constructor

Definition at line 42 of file ConditionEvaluation.h.

int m_verbosity
verbosity level
bool m_condLastResult
the last result of evaluateCondition()
virtual l1t::ConditionEvaluation::~ConditionEvaluation ( )
inlinevirtual

destructor

Definition at line 45 of file ConditionEvaluation.h.

45 {}

Member Function Documentation

template<class Type1 >
const bool ConditionEvaluation::checkBit ( const Type1 &  mask,
const unsigned int  bitNumber 
) const
protected

check if a bit with a given number is set in a mask

Definition at line 209 of file ConditionEvaluation.h.

References L1TBPTX_cfi::bitNumber, LogTrace, and m_verbosity.

Referenced by combinationsInCond(), and l1t::EnergySumCondition::evaluateCondition().

209  {
210  uint64_t oneBit = 1ULL;
211 
212  if (bitNumber >= (sizeof(oneBit) * 8)) {
213  if (m_verbosity) {
214  LogTrace("L1GlobalTrigger") << " checkBit "
215  << "\n Bit number = " << bitNumber << " larger than maximum allowed "
216  << sizeof(oneBit) * 8 << std::endl;
217  }
218 
219  return false;
220  }
221 
222  oneBit <<= bitNumber;
223 
224  //LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = " << &mask
225  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
226  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
227  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
228  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
229 
230  return (mask & oneBit);
231  }
#define LogTrace(id)
int m_verbosity
verbosity level
unsigned long long uint64_t
Definition: Time.h:13
template<class Type1 >
const bool ConditionEvaluation::checkIndex ( const Type1 &  indexLo,
const Type1 &  indexHi,
const unsigned int  index 
) const
protected

check if a index is in a given range

Definition at line 189 of file ConditionEvaluation.h.

References LogDebug.

Referenced by l1t::MuCondition::checkObjectParameter(), l1t::CaloCondition::checkObjectParameter(), and combinationsInCond().

191  {
192  LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
193  << "\n\t indexLo = " << indexLo << "\n\t indexHi = " << indexHi << "\n\t index = " << index
194  << std::endl;
195 
196  // set condtion to false if indexLo > indexHi
197  if (indexLo > indexHi) {
198  return false;
199  }
200  if (index >= indexLo && index <= indexHi) {
201  return true;
202  }
203 
204  return false;
205  }
#define LogDebug(id)
template<class Type1 >
const bool ConditionEvaluation::checkRangeDeltaEta ( const unsigned int  obj1Eta,
const unsigned int  obj2Eta,
const Type1 &  lowerR,
const Type1 &  upperR,
const unsigned int  nEtaBits 
) const
protected

check if a value is in a given range

Definition at line 379 of file ConditionEvaluation.h.

References change_name::diff, and LogDebug.

Referenced by combinationsInCond(), l1t::MuCondition::evaluateCondition(), and l1t::CaloCondition::evaluateCondition().

383  {
384  /* // set condtion to true if beginR==endR = default -1 */
385  /* if( beginR==endR && beginR==-1 ){ */
386  /* return true; */
387  /* } */
388 
389  unsigned int compare = obj1Eta - obj2Eta;
390  bool cond = ((compare >> nEtaBits) & 1) ? false : true;
391 
392  unsigned int larger, smaller;
393  if (cond) {
394  larger = obj1Eta;
395  smaller = obj2Eta;
396  } else {
397  larger = obj2Eta;
398  smaller = obj1Eta;
399  }
400 
401  unsigned int diff = ((larger + ((~smaller + 1) & 255)) & 255);
402 
403  unsigned int diff1 = upperR - lowerR;
404  unsigned int diff2 = diff - lowerR;
405  unsigned int diff3 = upperR - diff;
406 
407  bool cond1 = ((diff1 >> nEtaBits) & 1) ? false : true;
408  bool cond2 = ((diff2 >> nEtaBits) & 1) ? false : true;
409  bool cond3 = ((diff3 >> nEtaBits) & 1) ? false : true;
410 
411  LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
412  << "\n\t obj1Eta = " << obj1Eta << "\n\t obj2Eta = " << obj2Eta << "\n\t lowerR = " << lowerR
413  << "\n\t upperR = " << upperR << "\n\t compare = " << compare << "\n\t cond = " << cond
414  << "\n\t diff = " << diff << "\n\t diff1 = " << diff1 << "\n\t cond1 = " << cond1
415  << "\n\t diff2 = " << diff2 << "\n\t cond2 = " << cond2 << "\n\t diff3 = " << diff3
416  << "\n\t cond3 = " << cond3 << std::endl;
417 
418  if (cond1 && (cond2 && cond3))
419  return true;
420  else if (!cond1 && (cond2 || cond3))
421  return true;
422  else {
423  return false;
424  }
425  }
#define LogDebug(id)
Definition: plugin.cc:23
template<class Type1 >
const bool ConditionEvaluation::checkRangeDeltaPhi ( const unsigned int  obj1Phi,
const unsigned int  obj2Phi,
const Type1 &  lowerR,
const Type1 &  upperR 
) const
protected

check if a value is in a given range

Definition at line 428 of file ConditionEvaluation.h.

References funct::abs(), SiPixelRawToDigiRegional_cfi::deltaPhi, and LogDebug.

Referenced by combinationsInCond(), l1t::MuCondition::evaluateCondition(), and l1t::CaloCondition::evaluateCondition().

431  {
432  int deltaPhi = abs(int(obj1Phi) - int(obj2Phi));
433  if (deltaPhi > 71)
434  deltaPhi = 143 - deltaPhi + 1; // Add +1 if the calculation is over 0
435 
436  int diff1 = upperR - lowerR;
437  int diff2 = deltaPhi - lowerR;
438  int diff3 = upperR - deltaPhi;
439 
440  bool cond1 = (diff1 < 0) ? false : true;
441  bool cond2 = (diff2 < 0) ? false : true;
442  bool cond3 = (diff3 < 0) ? false : true;
443 
444  LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
445  << "\n\t obj1Phi = " << obj1Phi << "\n\t obj2Phi = " << obj2Phi
446  << "\n\t deltaPhi = " << deltaPhi << "\n\t lowerR = " << lowerR << "\n\t upperR = " << upperR
447  << "\n\t diff1 = " << diff1 << "\n\t cond1 = " << cond1 << "\n\t diff2 = " << diff2
448  << "\n\t cond2 = " << cond2 << "\n\t diff3 = " << diff3 << "\n\t cond3 = " << cond3
449  << std::endl;
450 
451  // check if value is in range
452  // for begin <= end takes [begin, end]
453  // for begin >= end takes [begin, end] over zero angle!
454  if (cond1 && (cond2 && cond3))
455  return true;
456  else if (!cond1 && (cond2 || cond3))
457  return true;
458  else {
459  return false;
460  }
461  }
#define LogDebug(id)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
template<class Type1 >
const bool ConditionEvaluation::checkRangeEta ( const unsigned int  bitNumber,
const Type1 &  W1beginR,
const Type1 &  W1endR,
const Type1 &  W2beginR,
const Type1 &  W2endR,
const unsigned int  nEtaBits 
) const
protected

check if a value is in a given range and outside of a veto range

Definition at line 235 of file ConditionEvaluation.h.

References L1TBPTX_cfi::bitNumber, and LogDebug.

Referenced by l1t::MuCondition::checkObjectParameter(), l1t::CaloCondition::checkObjectParameter(), and combinationsInCond().

240  {
241  // set condtion to true if beginR==endR = default -1
242  if (W1beginR == W1endR && W1beginR == (Type1)-1) {
243  return true;
244  }
245 
246  unsigned int W1diff1 = W1endR - W1beginR;
247  unsigned int W1diff2 = bitNumber - W1beginR;
248  unsigned int W1diff3 = W1endR - bitNumber;
249 
250  bool W1cond1 = ((W1diff1 >> nEtaBits) & 1) ? false : true;
251  bool W1cond2 = ((W1diff2 >> nEtaBits) & 1) ? false : true;
252  bool W1cond3 = ((W1diff3 >> nEtaBits) & 1) ? false : true;
253 
254  // check if value is in range
255  // for begin <= end takes [begin, end]
256  // for begin >= end takes [begin, end] over zero angle!
257  bool passWindow1 = false;
258  if (W1cond1 && (W1cond2 && W1cond3))
259  passWindow1 = true;
260  else if (!W1cond1 && (W1cond2 || W1cond3))
261  passWindow1 = true;
262  else {
263  passWindow1 = false;
264  }
265 
266  LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
267  << "\n\t bitNumber = " << bitNumber << "\n\t W1beginR = " << W1beginR
268  << "\n\t W1endR = " << W1endR << "\n\t W1diff1 = " << W1diff1
269  << "\n\t W1cond1 = " << W1cond1 << "\n\t W1diff2 = " << W1diff2
270  << "\n\t W1cond2 = " << W1cond2 << "\n\t W1diff3 = " << W1diff3
271  << "\n\t W1cond3 = " << W1cond3 << "\n\t passWindow1 = " << passWindow1 << std::endl;
272 
273  if (W2beginR == W2endR && W2beginR == (Type1)-1) {
274  return passWindow1;
275  }
276 
277  unsigned int W2diff1 = W2endR - W2beginR;
278  unsigned int W2diff2 = bitNumber - W2beginR;
279  unsigned int W2diff3 = W2endR - bitNumber;
280 
281  bool W2cond1 = ((W2diff1 >> nEtaBits) & 1) ? false : true;
282  bool W2cond2 = ((W2diff2 >> nEtaBits) & 1) ? false : true;
283  bool W2cond3 = ((W2diff3 >> nEtaBits) & 1) ? false : true;
284 
285  bool passWindow2 = false;
286  if (W2cond1 && (W2cond2 && W2cond3))
287  passWindow2 = true;
288  else if (!W2cond1 && (W2cond2 || W2cond3))
289  passWindow2 = true;
290  else {
291  passWindow2 = false;
292  }
293 
294  LogDebug("l1t|Global") << "\n\t W2beginR = " << W2beginR << "\n\t W2endR = " << W2endR
295  << "\n\t W2diff1 = " << W2diff1 << "\n\t W2cond1 = " << W2cond1
296  << "\n\t W2diff2 = " << W2diff2 << "\n\t W2cond2 = " << W2cond2
297  << "\n\t W2diff3 = " << W2diff3 << "\n\t W2cond3 = " << W2cond3
298  << "\n\t passWindow2 = " << passWindow2
299  << "\n\t pass W1 || W2 = " << (passWindow1 || passWindow2) << std::endl;
300 
301  if (passWindow1 || passWindow2) {
302  return true;
303  } else {
304  return false;
305  }
306  }
#define LogDebug(id)
template<class Type1 >
const bool ConditionEvaluation::checkRangePhi ( const unsigned int  bitNumber,
const Type1 &  W1beginR,
const Type1 &  W1endR,
const Type1 &  W2beginR,
const Type1 &  W2endR 
) const
protected

check if a value is in a given range and outside of a veto range

Definition at line 310 of file ConditionEvaluation.h.

References L1TBPTX_cfi::bitNumber, and LogDebug.

Referenced by l1t::MuCondition::checkObjectParameter(), l1t::CaloCondition::checkObjectParameter(), combinationsInCond(), and l1t::EnergySumCondition::evaluateCondition().

314  {
315  // set condtion to true if beginR==endR = default -1
316  if (W1beginR == W1endR && W1beginR == (Type1)-1) {
317  return true;
318  }
319 
320  int W1diff1 = W1endR - W1beginR;
321  int W1diff2 = bitNumber - W1beginR;
322  int W1diff3 = W1endR - bitNumber;
323 
324  bool W1cond1 = (W1diff1 < 0) ? false : true;
325  bool W1cond2 = (W1diff2 < 0) ? false : true;
326  bool W1cond3 = (W1diff3 < 0) ? false : true;
327 
328  // check if value is in range
329  // for begin <= end takes [begin, end]
330  // for begin >= end takes [begin, end] over zero angle!
331  bool passWindow1 = false;
332  if (W1cond1 && (W1cond2 && W1cond3))
333  passWindow1 = true;
334  else if (!W1cond1 && (W1cond2 || W1cond3))
335  passWindow1 = true;
336  else {
337  passWindow1 = false;
338  }
339 
340  LogDebug("l1t|Global") << "\n l1t::ConditionEvaluation"
341  << "\n\t bitNumber = " << bitNumber << "\n\t W1beginR = " << W1beginR
342  << "\n\t W1endR = " << W1endR << "\n\t W1diff1 = " << W1diff1
343  << "\n\t W1cond1 = " << W1cond1 << "\n\t W1diff2 = " << W1diff2
344  << "\n\t W1cond2 = " << W1cond2 << "\n\t W1diff3 = " << W1diff3
345  << "\n\t W1cond3 = " << W1cond3 << std::endl;
346 
347  if (W2beginR == W2endR && W2beginR == (Type1)-1) {
348  return passWindow1;
349  }
350 
351  int W2diff1 = W2endR - W2beginR;
352  int W2diff2 = bitNumber - W2beginR;
353  int W2diff3 = W2endR - bitNumber;
354 
355  bool W2cond1 = (W2diff1 < 0) ? false : true;
356  bool W2cond2 = (W2diff2 < 0) ? false : true;
357  bool W2cond3 = (W2diff3 < 0) ? false : true;
358 
359  // check if value is in range
360  // for begin <= end takes [begin, end]
361  // for begin >= end takes [begin, end] over zero angle!
362  bool passWindow2 = false;
363  if (W2cond1 && (W2cond2 && W2cond3))
364  passWindow2 = true;
365  else if (!W2cond1 && (W2cond2 || W2cond3))
366  passWindow2 = true;
367  else {
368  passWindow2 = false;
369  }
370 
371  if (passWindow1 || passWindow2) {
372  return true;
373  } else {
374  return false;
375  }
376  }
#define LogDebug(id)
template<class Type1 , class Type2 >
const bool ConditionEvaluation::checkThreshold ( const Type1 &  thresholdL,
const Type1 &  thresholdH,
const Type2 &  value,
bool  condGEqValue 
) const
protected

check if a value is greater than a threshold or greater-or-equal depending on the value of the condGEqValue flag

Definition at line 154 of file ConditionEvaluation.h.

References TauDecayModes::dec, and LogTrace.

Referenced by l1t::MuCondition::checkObjectParameter(), l1t::CaloCondition::checkObjectParameter(), combinationsInCond(), and l1t::EnergySumCondition::evaluateCondition().

157  {
158  if (value > 0) {
159  LogTrace("L1GlobalTrigger") << " checkThreshold check for condGEqValue = " << condGEqValue
160  << "\n hex: " << std::hex << "threshold = " << thresholdL << " - " << thresholdH
161  << " value = " << value << "\n dec: " << std::dec << "threshold = " << thresholdL
162  << " - " << thresholdH << " value = " << value << std::endl;
163  }
164 
165  if (condGEqValue) {
166  if (value >= (Type2)thresholdL && (Type1)value < thresholdH) {
167  //LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
168  // << std::endl;
169 
170  return true;
171  }
172 
173  return false;
174 
175  } else {
176  if (value == (Type2)thresholdL) {
177  //LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
178  // << std::endl;
179 
180  return true;
181  }
182 
183  return false;
184  }
185  }
Definition: value.py:1
#define LogTrace(id)
CombinationsInCond& l1t::ConditionEvaluation::combinationsInCond ( ) const
inlineprotected
bool l1t::ConditionEvaluation::condLastResult ( ) const
inline
int l1t::ConditionEvaluation::condMaxNumberObjects ( ) const
inline

get / set the maximum number of objects received for the evaluation of the condition

Definition at line 50 of file ConditionEvaluation.h.

References m_condMaxNumberObjects.

Referenced by l1t::EnergySumCondition::copy(), l1t::ExternalCondition::copy(), l1t::MuCondition::copy(), l1t::CaloCondition::copy(), l1t::CorrCondition::copy(), and l1t::CorrWithOverlapRemovalCondition::copy().

virtual const bool l1t::ConditionEvaluation::evaluateCondition ( const int  bxEval) const
pure virtual
void l1t::ConditionEvaluation::evaluateConditionStoreResult ( const int  bxEval)
inline

call evaluateCondition and save last result

Definition at line 60 of file ConditionEvaluation.h.

References evaluateCondition(), and m_condLastResult.

Referenced by l1t::CorrCondition::evaluateCondition(), l1t::CorrWithOverlapRemovalCondition::evaluateCondition(), and l1t::GlobalBoard::runGTL().

virtual const bool evaluateCondition(const int bxEval) const =0
the core function to check if the condition matches
bool m_condLastResult
the last result of evaluateCondition()
CombinationsInCond const& l1t::ConditionEvaluation::getCombinationsInCond ( ) const
inline

get all the object combinations evaluated to true in the condition

Definition at line 75 of file ConditionEvaluation.h.

References m_combinationsInCond, and print().

Referenced by l1t::EnergySumCondition::copy(), l1t::ExternalCondition::copy(), l1t::MuCondition::copy(), l1t::CaloCondition::copy(), l1t::CorrCondition::copy(), l1t::CorrWithOverlapRemovalCondition::copy(), l1t::CorrCondition::evaluateCondition(), and l1t::CorrWithOverlapRemovalCondition::evaluateCondition().

75 { return m_combinationsInCond; }
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
virtual std::string l1t::ConditionEvaluation::getNumericExpression ( ) const
inlinevirtual

get numeric expression

Definition at line 66 of file ConditionEvaluation.h.

References m_condLastResult.

66  {
67  if (m_condLastResult) {
68  return "1";
69  } else {
70  return "0";
71  }
72  }
bool m_condLastResult
the last result of evaluateCondition()
void ConditionEvaluation::print ( std::ostream &  myCout) const
virtual

print condition

Reimplemented in l1t::CorrWithOverlapRemovalCondition, l1t::CaloCondition, l1t::CorrCondition, l1t::EnergySumCondition, l1t::ExternalCondition, and l1t::MuCondition.

Definition at line 32 of file ConditionEvaluation.cc.

References begin, filterCSVwithJSON::copy, end, m_combinationsInCond, m_condLastResult, and m_condMaxNumberObjects.

Referenced by getCombinationsInCond(), l1t::MuCondition::print(), l1t::EnergySumCondition::print(), l1t::ExternalCondition::print(), l1t::CorrCondition::print(), l1t::CaloCondition::print(), and l1t::CorrWithOverlapRemovalCondition::print().

32  {
33  myCout << "\n ConditionEvaluation print...\n" << std::endl;
34  myCout << " Maximum number of objects in condition: " << m_condMaxNumberObjects << std::endl;
35  myCout << " Condition result: " << m_condLastResult << std::endl;
36 
37  CombinationsInCond::const_iterator itVV;
38  std::ostringstream myCout1;
39 
40  for (itVV = (m_combinationsInCond).begin(); itVV != (m_combinationsInCond).end(); itVV++) {
41  myCout1 << "( ";
42 
43  std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator<int>(myCout1, " "));
44 
45  myCout1 << "); ";
46  }
47 
48  myCout << "\n List of combinations passing all requirements for this condition: \n " << myCout1.str() << " \n"
49  << std::endl;
50 }
#define end
Definition: vmac.h:39
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
bool m_condLastResult
the last result of evaluateCondition()
#define begin
Definition: vmac.h:32
void l1t::ConditionEvaluation::setCondMaxNumberObjects ( int  condMaxNumberObjectsValue)
inline

Definition at line 52 of file ConditionEvaluation.h.

References m_condMaxNumberObjects.

52  {
53  m_condMaxNumberObjects = condMaxNumberObjectsValue;
54  }
void l1t::ConditionEvaluation::setVerbosity ( const int  verbosity)
inline

Member Data Documentation

CombinationsInCond l1t::ConditionEvaluation::m_combinationsInCond
mutableprotected
bool l1t::ConditionEvaluation::m_condLastResult
protected
int l1t::ConditionEvaluation::m_condMaxNumberObjects
protected
int l1t::ConditionEvaluation::m_verbosity
protected