CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::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 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 45 of file ConditionEvaluation.h.

45  :
47  m_condLastResult(false),
48  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 52 of file ConditionEvaluation.h.

52 {}

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

References LogTrace, and m_verbosity.

199  {
200 
201  boost::uint64_t oneBit = 1ULL;
202 
203  if (bitNumber >= (sizeof(oneBit)*8)) {
204 
205  if (m_verbosity) {
206 
207  LogTrace("L1GlobalTrigger")
208  << " checkBit " << "\n Bit number = "
209  << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
210  << std::endl;
211  }
212 
213  return false;
214  }
215 
216  oneBit <<= bitNumber;
217 
218  //LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = " << &mask
219  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
220  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
221  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
222  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
223 
224  return (mask & oneBit);
225 }
#define LogTrace(id)
int m_verbosity
verbosity level
unsigned long long uint64_t
Definition: Time.h:15
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 396 of file ConditionEvaluation.h.

References compare_using_db::compare, mps_update::diff, LogDebug, and smaller.

398  {
399 
400 /* // set condtion to true if beginR==endR = default -1 */
401 /* if( beginR==endR && beginR==-1 ){ */
402 /* return true; */
403 /* } */
404 
405  unsigned int compare = obj1Eta - obj2Eta;
406  bool cond = ( (compare>>nEtaBits) & 1 ) ? false : true;
407 
408  unsigned int larger, smaller;
409  if( cond ){
410  larger = obj1Eta;
411  smaller= obj2Eta;
412  }
413  else{
414  larger = obj2Eta;
415  smaller= obj1Eta;
416  }
417 
418  unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
419 
420  unsigned int diff1 = upperR - lowerR;
421  unsigned int diff2 = diff - lowerR;
422  unsigned int diff3 = upperR - diff;
423 
424  bool cond1 = ( (diff1>>nEtaBits) & 1 ) ? false : true;
425  bool cond2 = ( (diff2>>nEtaBits) & 1 ) ? false : true;
426  bool cond3 = ( (diff3>>nEtaBits) & 1 ) ? false : true;
427 
428  LogDebug("l1t|Global")
429  << "\n l1t::ConditionEvaluation"
430  << "\n\t obj1Eta = " << obj1Eta
431  << "\n\t obj2Eta = " << obj2Eta
432  << "\n\t lowerR = " << lowerR
433  << "\n\t upperR = " << upperR
434  << "\n\t compare = " << compare
435  << "\n\t cond = " << cond
436  << "\n\t diff = " << diff
437  << "\n\t diff1 = " << diff1
438  << "\n\t cond1 = " << cond1
439  << "\n\t diff2 = " << diff2
440  << "\n\t cond2 = " << cond2
441  << "\n\t diff3 = " << diff3
442  << "\n\t cond3 = " << cond3
443  << std::endl;
444 
445  if( cond1 && (cond2 && cond3 ) ) return true;
446  else if( !cond1 && (cond2 || cond3) ) return true;
447  else{
448  return false;
449  }
450 
451  }
#define LogDebug(id)
list diff
Definition: mps_update.py:85
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 455 of file ConditionEvaluation.h.

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

456  {
457 
458  int deltaPhi = abs(int(obj1Phi)-int(obj2Phi));
459  if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1; // Add +1 if the calculation is over 0
460 
461  int diff1 = upperR - lowerR;
462  int diff2 = deltaPhi - lowerR;
463  int diff3 = upperR - deltaPhi;
464 
465  bool cond1 = ( diff1<0 ) ? false : true;
466  bool cond2 = ( diff2<0 ) ? false : true;
467  bool cond3 = ( diff3<0 ) ? false : true;
468 
469  LogDebug("l1t|Global")
470  << "\n l1t::ConditionEvaluation"
471  << "\n\t obj1Phi = " << obj1Phi
472  << "\n\t obj2Phi = " << obj2Phi
473  << "\n\t deltaPhi = " << deltaPhi
474  << "\n\t lowerR = " << lowerR
475  << "\n\t upperR = " << upperR
476  << "\n\t diff1 = " << diff1
477  << "\n\t cond1 = " << cond1
478  << "\n\t diff2 = " << diff2
479  << "\n\t cond2 = " << cond2
480  << "\n\t diff3 = " << diff3
481  << "\n\t cond3 = " << cond3
482  << std::endl;
483 
484  // check if value is in range
485  // for begin <= end takes [begin, end]
486  // for begin >= end takes [begin, end] over zero angle!
487  if( cond1 && (cond2 && cond3 ) ) return true;
488  else if( !cond1 && (cond2 || cond3) ) return true;
489  else{
490  return false;
491  }
492 
493  }
#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 229 of file ConditionEvaluation.h.

References LogDebug.

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

References LogDebug.

322  {
323 
324  // set condtion to true if beginR==endR = default -1
325  if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
326  return true;
327  }
328 
329  int W1diff1 = W1endR - W1beginR;
330  int W1diff2 = bitNumber - W1beginR;
331  int W1diff3 = W1endR - bitNumber;
332 
333  bool W1cond1 = ( W1diff1<0 ) ? false : true;
334  bool W1cond2 = ( W1diff2<0 ) ? false : true;
335  bool W1cond3 = ( W1diff3<0 ) ? false : true;
336 
337  // check if value is in range
338  // for begin <= end takes [begin, end]
339  // for begin >= end takes [begin, end] over zero angle!
340  bool passWindow1 = false;
341  if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=true;
342  else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=true;
343  else{
344  passWindow1 = false;
345  }
346 
347  LogDebug("l1t|Global")
348  << "\n l1t::ConditionEvaluation"
349  << "\n\t bitNumber = " << bitNumber
350  << "\n\t W1beginR = " << W1beginR
351  << "\n\t W1endR = " << W1endR
352  << "\n\t W1diff1 = " << W1diff1
353  << "\n\t W1cond1 = " << W1cond1
354  << "\n\t W1diff2 = " << W1diff2
355  << "\n\t W1cond2 = " << W1cond2
356  << "\n\t W1diff3 = " << W1diff3
357  << "\n\t W1cond3 = " << W1cond3
358  << std::endl;
359 
360 
361 
362  if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
363  return passWindow1;
364  }
365 
366 
367  int W2diff1 = W2endR - W2beginR;
368  int W2diff2 = bitNumber - W2beginR;
369  int W2diff3 = W2endR - bitNumber;
370 
371  bool W2cond1 = ( W2diff1<0 ) ? false : true;
372  bool W2cond2 = ( W2diff2<0 ) ? false : true;
373  bool W2cond3 = ( W2diff3<0 ) ? false : true;
374 
375  // check if value is in range
376  // for begin <= end takes [begin, end]
377  // for begin >= end takes [begin, end] over zero angle!
378  bool passWindow2 = false;
379  if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=true;
380  else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=true;
381  else{
382  passWindow2 = false;
383  }
384 
385 
386  if( passWindow1 || passWindow2 ){
387  return true;
388  }
389  else{
390  return false;
391  }
392 
393 
394  }
#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 160 of file ConditionEvaluation.h.

References TauDecayModes::dec, and LogTrace.

161  {
162 
163  if (value > 0) {
164  LogTrace("L1GlobalTrigger")
165  << " checkThreshold check for condGEqValue = "
166  << condGEqValue << "\n hex: " << std::hex << "threshold = " << thresholdL << " - " << thresholdH
167  << " value = " << value << "\n dec: " << std::dec << "threshold = " << thresholdL << " - " << thresholdH
168  << " value = " << value << std::endl;
169  }
170 
171  if (condGEqValue) {
172  if (value >= (Type2) thresholdL && (Type1) value < thresholdH) {
173 
174  //LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
175  // << std::endl;
176 
177  return true;
178  }
179 
180  return false;
181 
182  }
183  else {
184 
185  if (value == (Type2) thresholdL ) {
186 
187  //LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
188  // << std::endl;
189 
190  return true;
191  }
192 
193  return false;
194  }
195 }
#define LogTrace(id)
CombinationsInCond& l1t::ConditionEvaluation::combinationsInCond ( ) const
inlineprotected

get all the object combinations (to fill it...)

Definition at line 105 of file ConditionEvaluation.h.

References m_combinationsInCond.

105  {
106  return m_combinationsInCond;
107  }
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
bool l1t::ConditionEvaluation::condLastResult ( ) const
inline

get the latest result for the condition

Definition at line 67 of file ConditionEvaluation.h.

References m_condLastResult.

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

67  {
68  return m_condLastResult;
69  }
bool m_condLastResult
the last result of evaluateCondition()
int l1t::ConditionEvaluation::condMaxNumberObjects ( ) const
inline

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

Definition at line 58 of file ConditionEvaluation.h.

References m_condMaxNumberObjects.

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

58  {
60  }
virtual const bool l1t::ConditionEvaluation::evaluateCondition ( const int  bxEval) const
pure virtual

the core function to check if the condition matches

Implemented in l1t::CorrCondition, l1t::CaloCondition, l1t::MuCondition, l1t::EnergySumCondition, and l1t::ExternalCondition.

Referenced by evaluateConditionStoreResult().

void l1t::ConditionEvaluation::evaluateConditionStoreResult ( const int  bxEval)
inline

call evaluateCondition and save last result

Definition at line 72 of file ConditionEvaluation.h.

References evaluateCondition(), and m_condLastResult.

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

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

get all the object combinations evaluated to true in the condition

Definition at line 90 of file ConditionEvaluation.h.

References m_combinationsInCond.

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

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

References m_condLastResult.

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

print condition

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

Definition at line 32 of file ConditionEvaluation.cc.

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

Referenced by l1t::EnergySumCondition::print(), l1t::ExternalCondition::print(), l1t::MuCondition::print(), l1t::CaloCondition::print(), and l1t::CorrCondition::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 62 of file ConditionEvaluation.h.

References m_condMaxNumberObjects.

62  {
63  m_condMaxNumberObjects = condMaxNumberObjectsValue;
64  }
void l1t::ConditionEvaluation::setVerbosity ( const int  verbosity)
inline

Definition at line 98 of file ConditionEvaluation.h.

References m_verbosity, and HLT_25ns10e33_v2_cff::verbosity.

Referenced by l1t::GlobalBoard::runGTL().

98  {
100  }
int m_verbosity
verbosity level

Member Data Documentation

CombinationsInCond l1t::ConditionEvaluation::m_combinationsInCond
mutableprotected

store all the object combinations evaluated to true in the condition

Definition at line 149 of file ConditionEvaluation.h.

Referenced by combinationsInCond(), getCombinationsInCond(), and print().

bool l1t::ConditionEvaluation::m_condLastResult
protected
int l1t::ConditionEvaluation::m_condMaxNumberObjects
protected

maximum number of objects received for the evaluation of the condition usually retrieved from event setup

Definition at line 143 of file ConditionEvaluation.h.

Referenced by l1t::CaloCondition::CaloCondition(), condMaxNumberObjects(), l1t::EnergySumCondition::EnergySumCondition(), l1t::ExternalCondition::ExternalCondition(), l1t::MuCondition::MuCondition(), print(), and setCondMaxNumberObjects().

int l1t::ConditionEvaluation::m_verbosity
protected