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

References LogTrace, and m_verbosity.

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

References compare(), diffTreeTool::diff, LogDebug, and smaller.

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

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

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

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

Definition at line 228 of file ConditionEvaluation.h.

References LogDebug.

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

References LogDebug.

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

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

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

Definition at line 36 of file ConditionEvaluation.cc.

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

Referenced by l1t::EnergySumCondition::print(), 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 HLT_25ns14e33_v1_cff::verbosity.

Referenced by l1t::GtBoard::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::MuCondition::MuCondition(), print(), and setCondMaxNumberObjects().

int l1t::ConditionEvaluation::m_verbosity
protected