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::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
 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 &beginR, const Type1 &endR, const Type1 &beginVetoR, const Type1 &endVetoR) 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 &beginR, const Type1 &endR, const Type1 &beginVetoR, const Type1 &endVetoR) 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 &threshold, 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 195 of file ConditionEvaluation.h.

References LogTrace, and m_verbosity.

196  {
197 
198  boost::uint64_t oneBit = 1ULL;
199 
200  if (bitNumber >= (sizeof(oneBit)*8)) {
201 
202  if (m_verbosity) {
203 
204  LogTrace("L1GlobalTrigger")
205  << " checkBit " << "\n Bit number = "
206  << bitNumber << " larger than maximum allowed " << sizeof ( oneBit ) * 8
207  << std::endl;
208  }
209 
210  return false;
211  }
212 
213  oneBit <<= bitNumber;
214 
215  //LogTrace("L1GlobalTrigger") << " checkBit " << "\n mask address = " << &mask
216  // << std::dec << "\n dec: " << "mask = " << mask << " oneBit = " << oneBit
217  // << " bitNumber = " << bitNumber << std::hex << "\n hex: " << "mask = " << mask
218  // << " oneBit = " << oneBit << " bitNumber = " << bitNumber << std::dec
219  // << "\n mask & oneBit result = " << bool ( mask & oneBit ) << std::endl;
220 
221  return (mask & oneBit);
222 }
#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
protected

check if a value is in a given range

Definition at line 365 of file ConditionEvaluation.h.

References compare_using_db::compare, diffTreeTool::diff, and LogDebug.

366  {
367 
368 /* // set condtion to true if beginR==endR = default -1 */
369 /* if( beginR==endR && beginR==-1 ){ */
370 /* return true; */
371 /* } */
372 
373  unsigned int compare = obj1Eta - obj2Eta;
374  bool cond = ( (compare>>7) & 1 ) ? false : true;
375 
376  unsigned int larger, smaller;
377  if( cond ){
378  larger = obj1Eta;
379  smaller= obj2Eta;
380  }
381  else{
382  larger = obj2Eta;
383  smaller= obj1Eta;
384  }
385 
386  unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
387 
388  unsigned int diff1 = upperR - lowerR;
389  unsigned int diff2 = diff - lowerR;
390  unsigned int diff3 = upperR - diff;
391 
392  bool cond1 = ( (diff1>>7) & 1 ) ? false : true;
393  bool cond2 = ( (diff2>>7) & 1 ) ? false : true;
394  bool cond3 = ( (diff3>>7) & 1 ) ? false : true;
395 
396  LogDebug("l1t|Global")
397  << "\n l1t::ConditionEvaluation"
398  << "\n\t obj1Eta = " << obj1Eta
399  << "\n\t obj2Eta = " << obj2Eta
400  << "\n\t lowerR = " << lowerR
401  << "\n\t upperR = " << upperR
402  << "\n\t compare = " << compare
403  << "\n\t cond = " << cond
404  << "\n\t diff = " << diff
405  << "\n\t diff1 = " << diff1
406  << "\n\t cond1 = " << cond1
407  << "\n\t diff2 = " << diff2
408  << "\n\t cond2 = " << cond2
409  << "\n\t diff3 = " << diff3
410  << "\n\t cond3 = " << cond3
411  << std::endl;
412 
413  if( cond1 && (cond2 && cond3 ) ) return true;
414  else if( !cond1 && (cond2 || cond3) ) return true;
415  else{
416  return false;
417  }
418 
419  }
#define LogDebug(id)
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 423 of file ConditionEvaluation.h.

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

424  {
425 
426  int deltaPhi = abs(obj1Phi-obj2Phi);
427  if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1; // Add +1 if the calculation is over 0
428 
429  int diff1 = upperR - lowerR;
430  int diff2 = deltaPhi - lowerR;
431  int diff3 = upperR - deltaPhi;
432 
433  bool cond1 = ( diff1<0 ) ? false : true;
434  bool cond2 = ( diff2<0 ) ? false : true;
435  bool cond3 = ( diff3<0 ) ? false : true;
436 
437  LogDebug("l1t|Global")
438  << "\n l1t::ConditionEvaluation"
439  << "\n\t obj1Phi = " << obj1Phi
440  << "\n\t obj2Phi = " << obj2Phi
441  << "\n\t deltaPhi = " << deltaPhi
442  << "\n\t lowerR = " << lowerR
443  << "\n\t upperR = " << upperR
444  << "\n\t diff1 = " << diff1
445  << "\n\t cond1 = " << cond1
446  << "\n\t diff2 = " << diff2
447  << "\n\t cond2 = " << cond2
448  << "\n\t diff3 = " << diff3
449  << "\n\t cond3 = " << cond3
450  << std::endl;
451 
452  // check if value is in range
453  // for begin <= end takes [begin, end]
454  // for begin >= end takes [begin, end] over zero angle!
455  if( cond1 && (cond2 && cond3 ) ) return true;
456  else if( !cond1 && (cond2 || cond3) ) return true;
457  else{
458  return false;
459  }
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 &  beginR,
const Type1 &  endR,
const Type1 &  beginVetoR,
const Type1 &  endVetoR 
) const
protected

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

Definition at line 226 of file ConditionEvaluation.h.

References LogDebug.

228  {
229 
230  // set condtion to true if beginR==endR = default -1
231  if( beginR==endR && beginR==(Type1)-1 ){
232  return true;
233  }
234 
235  unsigned int diff1 = endR - beginR;
236  unsigned int diff2 = bitNumber - beginR;
237  unsigned int diff3 = endR - bitNumber;
238 
239  bool cond1 = ( (diff1>>7) & 1 ) ? false : true;
240  bool cond2 = ( (diff2>>7) & 1 ) ? false : true;
241  bool cond3 = ( (diff3>>7) & 1 ) ? false : true;
242 
243  LogDebug("l1t|Global")
244  << "\n l1t::ConditionEvaluation"
245  << "\n\t bitNumber = " << bitNumber
246  << "\n\t beginR = " << beginR
247  << "\n\t endR = " << endR
248  << "\n\t beginVetoR = " << beginVetoR
249  << "\n\t endVetoR = " << endVetoR
250  << "\n\t diff1 = " << diff1
251  << "\n\t cond1 = " << cond1
252  << "\n\t diff2 = " << diff2
253  << "\n\t cond2 = " << cond2
254  << "\n\t diff3 = " << diff3
255  << "\n\t cond3 = " << cond3
256  << std::endl;
257 
258  // check if value is in range
259  // for begin <= end takes [begin, end]
260  // for begin >= end takes [begin, end] over zero angle!
261  bool passWindow = false;
262  if( cond1 && (cond2 && cond3 ) ) passWindow=true;
263  else if( !cond1 && (cond2 || cond3) ) passWindow=true;
264  else{
265  return false;
266  }
267 
268  if( passWindow ){
269  if( beginVetoR==endVetoR && beginVetoR==(Type1)-1 ) return true;
270 
271  unsigned int diffV1 = endVetoR - beginVetoR;
272  unsigned int diffV2 = bitNumber - beginVetoR;
273  unsigned int diffV3 = endVetoR - bitNumber;
274 
275  bool condV1 = ( (diffV1>>7) & 1 ) ? false : true;
276  bool condV2 = ( (diffV2>>7) & 1 ) ? false : true;
277  bool condV3 = ( (diffV3>>7) & 1 ) ? false : true;
278 
279  if( condV1 && !(condV2 && condV3) ) return true;
280  else if( !condV1 && !(condV2 || condV3) ) return true;
281  else{
282  return false;
283  }
284  }
285  else{
286  LogDebug("l1t|Global") << "=====> ConditionEvaluation::checkRange: I should never be here." << std::endl;
287  return false;
288  }
289 
290  LogDebug("l1t|Global") << "=====> HELP!! I'm trapped and I cannot escape! AHHHHHH" << std::endl;
291 
292  }
#define LogDebug(id)
template<class Type1 >
const bool ConditionEvaluation::checkRangePhi ( const unsigned int  bitNumber,
const Type1 &  beginR,
const Type1 &  endR,
const Type1 &  beginVetoR,
const Type1 &  endVetoR 
) const
protected

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

Definition at line 297 of file ConditionEvaluation.h.

References LogDebug.

299  {
300 
301  // set condtion to true if beginR==endR = default -1
302  if( beginR==endR && beginR==(Type1)-1 ){
303  return true;
304  }
305 
306  int diff1 = endR - beginR;
307  int diff2 = bitNumber - beginR;
308  int diff3 = endR - bitNumber;
309 
310  bool cond1 = ( diff1<0 ) ? false : true;
311  bool cond2 = ( diff2<0 ) ? false : true;
312  bool cond3 = ( diff3<0 ) ? false : true;
313 
314  LogDebug("l1t|Global")
315  << "\n l1t::ConditionEvaluation"
316  << "\n\t bitNumber = " << bitNumber
317  << "\n\t beginR = " << beginR
318  << "\n\t endR = " << endR
319  << "\n\t beginVetoR = " << beginVetoR
320  << "\n\t endVetoR = " << endVetoR
321  << "\n\t diff1 = " << diff1
322  << "\n\t cond1 = " << cond1
323  << "\n\t diff2 = " << diff2
324  << "\n\t cond2 = " << cond2
325  << "\n\t diff3 = " << diff3
326  << "\n\t cond3 = " << cond3
327  << std::endl;
328 
329  // check if value is in range
330  // for begin <= end takes [begin, end]
331  // for begin >= end takes [begin, end] over zero angle!
332  bool passWindow = false;
333  if( cond1 && (cond2 && cond3 ) ) passWindow=true;
334  else if( !cond1 && (cond2 || cond3) ) passWindow=true;
335  else{
336  return false;
337  }
338 
339  if( passWindow ){
340  if( beginVetoR==endVetoR && beginVetoR==(Type1)-1 ) return true;
341 
342  int diffV1 = endVetoR - beginVetoR;
343  int diffV2 = bitNumber - beginVetoR;
344  int diffV3 = endVetoR - bitNumber;
345 
346  bool condV1 = ( diffV1<0 ) ? false : true;
347  bool condV2 = ( diffV2<0 ) ? false : true;
348  bool condV3 = ( diffV3<0 ) ? false : true;
349 
350  if( condV1 && !(condV2 && condV3) ) return true;
351  else if( !condV1 && !(condV2 || condV3) ) return true;
352  else{
353  return false;
354  }
355  }
356  else{
357  LogDebug("l1t|Global") << "=====> ConditionEvaluation::checkRange: I should never be here." << std::endl;
358  return false;
359  }
360 
361  LogDebug("l1t|Global") << "=====> HELP!! I'm trapped and I cannot escape! AHHHHHH" << std::endl;
362 
363  }
#define LogDebug(id)
template<class Type1 , class Type2 >
const bool ConditionEvaluation::checkThreshold ( const Type1 &  threshold,
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 158 of file ConditionEvaluation.h.

159  {
160 
161  //if (value > 0) {
162  // LogTrace("L1GlobalTrigger") << " threshold check for condGEqValue = "
163  // << condGEqValue << "\n hex: " << std::hex << "threshold = " << threshold
164  // << " value = " << value << "\n dec: " << std::dec << "threshold = " << threshold
165  // << " value = " << value << std::endl;
166  //}
167 
168  if (condGEqValue) {
169  if (value >= (Type2) threshold) {
170 
171  //LogTrace("L1GlobalTrigger") << " condGEqValue: value >= threshold"
172  // << std::endl;
173 
174  return true;
175  }
176 
177  return false;
178 
179  }
180  else {
181 
182  if (value == (Type2) threshold) {
183 
184  //LogTrace("L1GlobalTrigger") << " condGEqValue: value = threshold"
185  // << std::endl;
186 
187  return true;
188  }
189 
190  return false;
191  }
192 }
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::MuCondition::copy(), and l1t::CaloCondition::copy().

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::MuCondition::copy(), and l1t::CaloCondition::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::CaloCondition, and l1t::MuCondition.

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::GtBoard::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::MuCondition::copy(), and l1t::CaloCondition::copy().

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::CaloCondition, and l1t::MuCondition.

Definition at line 36 of file ConditionEvaluation.cc.

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

Referenced by l1t::MuCondition::print(), and l1t::CaloCondition::print().

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

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

98  {
100  }
int m_verbosity
verbosity level
tuple verbosity
Definition: mvaPFMET_cff.py:80

Member Data Documentation

CombinationsInCond l1t::ConditionEvaluation::m_combinationsInCond
mutableprotected

store all the object combinations evaluated to true in the condition

Definition at line 147 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 141 of file ConditionEvaluation.h.

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

int l1t::ConditionEvaluation::m_verbosity
protected

verbosity level

Definition at line 150 of file ConditionEvaluation.h.

Referenced by checkBit(), l1t::MuCondition::copy(), l1t::CaloCondition::copy(), and setVerbosity().