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 40 of file ConditionEvaluation.h.

Constructor & Destructor Documentation

l1t::ConditionEvaluation::ConditionEvaluation ( )
inline

constructor

Definition at line 46 of file ConditionEvaluation.h.

46  :
48  m_condLastResult(false),
49  m_verbosity(0) {}
int m_verbosity
verbosity level
bool m_condLastResult
the last result of evaluateCondition()
virtual l1t::ConditionEvaluation::~ConditionEvaluation ( )
inlinevirtual

destructor

Definition at line 53 of file ConditionEvaluation.h.

53 {}

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 226 of file ConditionEvaluation.h.

References LogTrace, and m_verbosity.

Referenced by combinationsInCond().

227  {
228 
229  boost::uint64_t oneBit = 1ULL;
230 
231  if (bitNumber >= (sizeof(oneBit)*8)) {
232 
233  if (m_verbosity) {
234 
235  LogTrace("L1GlobalTrigger")
236  << " checkBit " << "\n Bit number = "
237  << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
238  << std::endl;
239  }
240 
241  return false;
242  }
243 
244  oneBit <<= bitNumber;
245 
246  //LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = " << &mask
247  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
248  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
249  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
250  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
251 
252  return (mask & oneBit);
253 }
#define LogTrace(id)
int m_verbosity
verbosity level
unsigned long long uint64_t
Definition: Time.h:15
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 203 of file ConditionEvaluation.h.

References LogDebug.

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

204  {
205 
206  LogDebug("l1t|Global")
207  << "\n l1t::ConditionEvaluation"
208  << "\n\t indexLo = " << indexLo
209  << "\n\t indexHi = " << indexHi
210  << "\n\t index = " << index
211  << std::endl;
212 
213  // set condtion to false if indexLo > indexHi
214  if( indexLo > indexHi ) {
215  return false;
216  }
217  if (index >= indexLo && index <= indexHi) {
218  return true;
219  }
220 
221  return false;
222 }
#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 424 of file ConditionEvaluation.h.

References diffTreeTool::diff, and LogDebug.

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

426  {
427 
428 /* // set condtion to true if beginR==endR = default -1 */
429 /* if( beginR==endR && beginR==-1 ){ */
430 /* return true; */
431 /* } */
432 
433  unsigned int compare = obj1Eta - obj2Eta;
434  bool cond = ( (compare>>nEtaBits) & 1 ) ? false : true;
435 
436  unsigned int larger, smaller;
437  if( cond ){
438  larger = obj1Eta;
439  smaller= obj2Eta;
440  }
441  else{
442  larger = obj2Eta;
443  smaller= obj1Eta;
444  }
445 
446  unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
447 
448  unsigned int diff1 = upperR - lowerR;
449  unsigned int diff2 = diff - lowerR;
450  unsigned int diff3 = upperR - diff;
451 
452  bool cond1 = ( (diff1>>nEtaBits) & 1 ) ? false : true;
453  bool cond2 = ( (diff2>>nEtaBits) & 1 ) ? false : true;
454  bool cond3 = ( (diff3>>nEtaBits) & 1 ) ? false : true;
455 
456  LogDebug("l1t|Global")
457  << "\n l1t::ConditionEvaluation"
458  << "\n\t obj1Eta = " << obj1Eta
459  << "\n\t obj2Eta = " << obj2Eta
460  << "\n\t lowerR = " << lowerR
461  << "\n\t upperR = " << upperR
462  << "\n\t compare = " << compare
463  << "\n\t cond = " << cond
464  << "\n\t diff = " << diff
465  << "\n\t diff1 = " << diff1
466  << "\n\t cond1 = " << cond1
467  << "\n\t diff2 = " << diff2
468  << "\n\t cond2 = " << cond2
469  << "\n\t diff3 = " << diff3
470  << "\n\t cond3 = " << cond3
471  << std::endl;
472 
473  if( cond1 && (cond2 && cond3 ) ) return true;
474  else if( !cond1 && (cond2 || cond3) ) return true;
475  else{
476  return false;
477  }
478 
479  }
#define LogDebug(id)
Definition: plugin.cc:24
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 483 of file ConditionEvaluation.h.

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

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

484  {
485 
486  int deltaPhi = abs(int(obj1Phi)-int(obj2Phi));
487  if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1; // Add +1 if the calculation is over 0
488 
489  int diff1 = upperR - lowerR;
490  int diff2 = deltaPhi - lowerR;
491  int diff3 = upperR - deltaPhi;
492 
493  bool cond1 = ( diff1<0 ) ? false : true;
494  bool cond2 = ( diff2<0 ) ? false : true;
495  bool cond3 = ( diff3<0 ) ? false : true;
496 
497  LogDebug("l1t|Global")
498  << "\n l1t::ConditionEvaluation"
499  << "\n\t obj1Phi = " << obj1Phi
500  << "\n\t obj2Phi = " << obj2Phi
501  << "\n\t deltaPhi = " << deltaPhi
502  << "\n\t lowerR = " << lowerR
503  << "\n\t upperR = " << upperR
504  << "\n\t diff1 = " << diff1
505  << "\n\t cond1 = " << cond1
506  << "\n\t diff2 = " << diff2
507  << "\n\t cond2 = " << cond2
508  << "\n\t diff3 = " << diff3
509  << "\n\t cond3 = " << cond3
510  << std::endl;
511 
512  // check if value is in range
513  // for begin <= end takes [begin, end]
514  // for begin >= end takes [begin, end] over zero angle!
515  if( cond1 && (cond2 && cond3 ) ) return true;
516  else if( !cond1 && (cond2 || cond3) ) return true;
517  else{
518  return false;
519  }
520 
521  }
#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 257 of file ConditionEvaluation.h.

References LogDebug.

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

260  {
261 
262  // set condtion to true if beginR==endR = default -1
263  if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
264  return true;
265  }
266 
267  unsigned int W1diff1 = W1endR - W1beginR;
268  unsigned int W1diff2 = bitNumber - W1beginR;
269  unsigned int W1diff3 = W1endR - bitNumber;
270 
271  bool W1cond1 = ( (W1diff1>>nEtaBits) & 1 ) ? false : true;
272  bool W1cond2 = ( (W1diff2>>nEtaBits) & 1 ) ? false : true;
273  bool W1cond3 = ( (W1diff3>>nEtaBits) & 1 ) ? false : true;
274 
275  // check if value is in range
276  // for begin <= end takes [begin, end]
277  // for begin >= end takes [begin, end] over zero angle!
278  bool passWindow1 = false;
279  if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=true;
280  else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=true;
281  else{
282  passWindow1 = false;
283  }
284 
285 
286 
287  LogDebug("l1t|Global")
288  << "\n l1t::ConditionEvaluation"
289  << "\n\t bitNumber = " << bitNumber
290  << "\n\t W1beginR = " << W1beginR
291  << "\n\t W1endR = " << W1endR
292  << "\n\t W1diff1 = " << W1diff1
293  << "\n\t W1cond1 = " << W1cond1
294  << "\n\t W1diff2 = " << W1diff2
295  << "\n\t W1cond2 = " << W1cond2
296  << "\n\t W1diff3 = " << W1diff3
297  << "\n\t W1cond3 = " << W1cond3
298  << "\n\t passWindow1 = " << passWindow1
299  << std::endl;
300 
301 
302  if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
303  return passWindow1;
304  }
305 
306 
307  unsigned int W2diff1 = W2endR - W2beginR;
308  unsigned int W2diff2 = bitNumber - W2beginR;
309  unsigned int W2diff3 = W2endR - bitNumber;
310 
311  bool W2cond1 = ( (W2diff1>>nEtaBits) & 1 ) ? false : true;
312  bool W2cond2 = ( (W2diff2>>nEtaBits) & 1 ) ? false : true;
313  bool W2cond3 = ( (W2diff3>>nEtaBits) & 1 ) ? false : true;
314 
315  bool passWindow2 = false;
316  if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=true;
317  else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=true;
318  else{
319  passWindow2 = false;
320  }
321 
322 
323  LogDebug("l1t|Global")
324  << "\n\t W2beginR = " << W2beginR
325  << "\n\t W2endR = " << W2endR
326  << "\n\t W2diff1 = " << W2diff1
327  << "\n\t W2cond1 = " << W2cond1
328  << "\n\t W2diff2 = " << W2diff2
329  << "\n\t W2cond2 = " << W2cond2
330  << "\n\t W2diff3 = " << W2diff3
331  << "\n\t W2cond3 = " << W2cond3
332  << "\n\t passWindow2 = " << passWindow2
333  << "\n\t pass W1 || W2 = " << (passWindow1 || passWindow2)
334  << std::endl;
335 
336  if( passWindow1 || passWindow2 ){
337  return true;
338  }
339  else{
340  return false;
341  }
342 
343  }
#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 348 of file ConditionEvaluation.h.

References LogDebug.

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

350  {
351 
352  // set condtion to true if beginR==endR = default -1
353  if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
354  return true;
355  }
356 
357  int W1diff1 = W1endR - W1beginR;
358  int W1diff2 = bitNumber - W1beginR;
359  int W1diff3 = W1endR - bitNumber;
360 
361  bool W1cond1 = ( W1diff1<0 ) ? false : true;
362  bool W1cond2 = ( W1diff2<0 ) ? false : true;
363  bool W1cond3 = ( W1diff3<0 ) ? false : true;
364 
365  // check if value is in range
366  // for begin <= end takes [begin, end]
367  // for begin >= end takes [begin, end] over zero angle!
368  bool passWindow1 = false;
369  if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=true;
370  else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=true;
371  else{
372  passWindow1 = false;
373  }
374 
375  LogDebug("l1t|Global")
376  << "\n l1t::ConditionEvaluation"
377  << "\n\t bitNumber = " << bitNumber
378  << "\n\t W1beginR = " << W1beginR
379  << "\n\t W1endR = " << W1endR
380  << "\n\t W1diff1 = " << W1diff1
381  << "\n\t W1cond1 = " << W1cond1
382  << "\n\t W1diff2 = " << W1diff2
383  << "\n\t W1cond2 = " << W1cond2
384  << "\n\t W1diff3 = " << W1diff3
385  << "\n\t W1cond3 = " << W1cond3
386  << std::endl;
387 
388 
389 
390  if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
391  return passWindow1;
392  }
393 
394 
395  int W2diff1 = W2endR - W2beginR;
396  int W2diff2 = bitNumber - W2beginR;
397  int W2diff3 = W2endR - bitNumber;
398 
399  bool W2cond1 = ( W2diff1<0 ) ? false : true;
400  bool W2cond2 = ( W2diff2<0 ) ? false : true;
401  bool W2cond3 = ( W2diff3<0 ) ? false : true;
402 
403  // check if value is in range
404  // for begin <= end takes [begin, end]
405  // for begin >= end takes [begin, end] over zero angle!
406  bool passWindow2 = false;
407  if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=true;
408  else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=true;
409  else{
410  passWindow2 = false;
411  }
412 
413 
414  if( passWindow1 || passWindow2 ){
415  return true;
416  }
417  else{
418  return false;
419  }
420 
421 
422  }
#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 165 of file ConditionEvaluation.h.

References TauDecayModes::dec, and LogTrace.

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

166  {
167 
168  if (value > 0) {
169  LogTrace("L1GlobalTrigger")
170  << " checkThreshold check for condGEqValue = "
171  << condGEqValue << "\n hex: " << std::hex << "threshold = " << thresholdL << " - " << thresholdH
172  << " value = " << value << "\n dec: " << std::dec << "threshold = " << thresholdL << " - " << thresholdH
173  << " value = " << value << std::endl;
174  }
175 
176  if (condGEqValue) {
177  if (value >= (Type2) thresholdL && (Type1) value < thresholdH) {
178 
179  //LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
180  // << std::endl;
181 
182  return true;
183  }
184 
185  return false;
186 
187  }
188  else {
189 
190  if (value == (Type2) thresholdL ) {
191 
192  //LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
193  // << std::endl;
194 
195  return true;
196  }
197 
198  return false;
199  }
200 }
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 59 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().

59  {
61  }
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 73 of file ConditionEvaluation.h.

References evaluateCondition(), and m_condLastResult.

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

73  {
75  }
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 91 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().

91  {
92  return m_combinationsInCond;
93  }
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 81 of file ConditionEvaluation.h.

References m_condLastResult.

81  {
82  if (m_condLastResult) {
83  return "1";
84  }
85  else {
86  return "0";
87  }
88  }
bool m_condLastResult
the last result of evaluateCondition()
void ConditionEvaluation::print ( std::ostream &  myCout) const
virtual

print condition

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

Definition at line 32 of file ConditionEvaluation.cc.

References begin, popcon2dropbox::copy(), end, m_combinationsInCond, m_condLastResult, and m_condMaxNumberObjects.

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

32  {
33 
34  myCout << "\n ConditionEvaluation print...\n" << std::endl;
35  myCout << " Maximum number of objects in condition: " << m_condMaxNumberObjects << std::endl;
36  myCout << " Condition result: " << m_condLastResult << std::endl;
37 
38  CombinationsInCond::const_iterator itVV;
39  std::ostringstream myCout1;
40 
41  for (itVV = (m_combinationsInCond).begin(); itVV != (m_combinationsInCond).end(); itVV++) {
42 
43  myCout1 << "( ";
44 
45  std::copy((*itVV).begin(), (*itVV).end(), std::ostream_iterator<int> (myCout1, " "));
46 
47  myCout1 << "); ";
48 
49  }
50 
51  myCout
52  << "\n List of combinations passing all requirements for this condition: \n "
53  << myCout1.str()
54  << " \n"
55  << std::endl;
56 
57 }
#define end
Definition: vmac.h:37
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:30
void l1t::ConditionEvaluation::setCondMaxNumberObjects ( int  condMaxNumberObjectsValue)
inline

Definition at line 63 of file ConditionEvaluation.h.

References m_condMaxNumberObjects.

63  {
64  m_condMaxNumberObjects = condMaxNumberObjectsValue;
65  }
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