1 #ifndef L1Trigger_L1TGlobal_ConditionEvaluation_h 2 #define L1Trigger_L1TGlobal_ConditionEvaluation_h 25 #include <boost/cstdint.hpp> 97 virtual void print(std::ostream& myCout)
const;
112 template<
class Type1,
class Type2>
const bool checkThreshold(
const Type1& thresholdL,
const Type1& thresholdH,
113 const Type2&
value,
bool condGEqValue)
const;
116 template<
class Type1>
const bool checkIndex(
const Type1& indexLo,
const Type1& indexHi,
117 const unsigned int index )
const;
120 template<
class Type1>
const bool checkBit(
const Type1&
mask,
const unsigned int bitNumber)
const;
123 template<
class Type1>
const bool checkRangeEta(
const unsigned int bitNumber,
124 const Type1& W1beginR,
const Type1& W1endR,
125 const Type1& W2beginR,
const Type1& W2endR,
126 const unsigned int nEtaBits )
const;
129 template<
class Type1>
const bool checkRangePhi(
const unsigned int bitNumber,
130 const Type1& W1beginR,
const Type1& W1endR,
131 const Type1& W2beginR,
const Type1& W2endR )
const;
135 template<
class Type1>
const bool checkRangeDeltaEta(
const unsigned int obj1Eta,
const unsigned int obj2Eta,
136 const Type1& lowerR,
const Type1& upperR,
137 const unsigned int nEtaBits )
const;
140 template<
class Type1>
const bool checkRangeDeltaPhi(
const unsigned int obj1Phi,
const unsigned int obj2Phi,
141 const Type1& lowerR,
const Type1& upperR )
const;
166 const Type1& thresholdL,
const Type1& thresholdH,
const Type2&
value,
const bool condGEqValue)
const {
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;
177 if (value >= (Type2) thresholdL && (Type1) value < thresholdH) {
190 if (value == (Type2) thresholdL ) {
204 const unsigned int index)
const {
207 <<
"\n l1t::ConditionEvaluation" 208 <<
"\n\t indexLo = " << indexLo
209 <<
"\n\t indexHi = " << indexHi
210 <<
"\n\t index = " << index
214 if( indexLo > indexHi ) {
217 if (index >= indexLo && index <= indexHi) {
227 const unsigned int bitNumber)
const {
231 if (bitNumber >= (
sizeof(oneBit)*8)) {
236 <<
" checkBit " <<
"\n Bit number = " 237 << bitNumber <<
" larger than maximum allowed " <<
sizeof ( oneBit ) * 8
244 oneBit <<= bitNumber;
252 return (mask & oneBit);
258 const Type1& W1beginR,
const Type1& W1endR,
259 const Type1& W2beginR,
const Type1& W2endR,
260 const unsigned int nEtaBits)
const {
263 if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
267 unsigned int W1diff1 = W1endR - W1beginR;
268 unsigned int W1diff2 = bitNumber - W1beginR;
269 unsigned int W1diff3 = W1endR - bitNumber;
271 bool W1cond1 = ( (W1diff1>>nEtaBits) & 1 ) ?
false :
true;
272 bool W1cond2 = ( (W1diff2>>nEtaBits) & 1 ) ?
false :
true;
273 bool W1cond3 = ( (W1diff3>>nEtaBits) & 1 ) ?
false :
true;
278 bool passWindow1 =
false;
279 if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=
true;
280 else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=
true;
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
302 if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
307 unsigned int W2diff1 = W2endR - W2beginR;
308 unsigned int W2diff2 = bitNumber - W2beginR;
309 unsigned int W2diff3 = W2endR - bitNumber;
311 bool W2cond1 = ( (W2diff1>>nEtaBits) & 1 ) ?
false :
true;
312 bool W2cond2 = ( (W2diff2>>nEtaBits) & 1 ) ?
false :
true;
313 bool W2cond3 = ( (W2diff3>>nEtaBits) & 1 ) ?
false :
true;
315 bool passWindow2 =
false;
316 if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=
true;
317 else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=
true;
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)
336 if( passWindow1 || passWindow2 ){
349 const Type1& W1beginR,
const Type1& W1endR,
350 const Type1& W2beginR,
const Type1& W2endR )
const {
353 if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
357 int W1diff1 = W1endR - W1beginR;
358 int W1diff2 = bitNumber - W1beginR;
359 int W1diff3 = W1endR - bitNumber;
361 bool W1cond1 = ( W1diff1<0 ) ?
false :
true;
362 bool W1cond2 = ( W1diff2<0 ) ?
false :
true;
363 bool W1cond3 = ( W1diff3<0 ) ?
false :
true;
368 bool passWindow1 =
false;
369 if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=
true;
370 else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=
true;
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
390 if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
395 int W2diff1 = W2endR - W2beginR;
396 int W2diff2 = bitNumber - W2beginR;
397 int W2diff3 = W2endR - bitNumber;
399 bool W2cond1 = ( W2diff1<0 ) ?
false :
true;
400 bool W2cond2 = ( W2diff2<0 ) ?
false :
true;
401 bool W2cond3 = ( W2diff3<0 ) ?
false :
true;
406 bool passWindow2 =
false;
407 if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=
true;
408 else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=
true;
414 if( passWindow1 || passWindow2 ){
425 const Type1& lowerR,
const Type1& upperR,
426 const unsigned int nEtaBits )
const {
433 unsigned int compare = obj1Eta - obj2Eta;
434 bool cond = ( (compare>>nEtaBits) & 1 ) ?
false :
true;
436 unsigned int larger, smaller;
446 unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
448 unsigned int diff1 = upperR - lowerR;
449 unsigned int diff2 = diff - lowerR;
450 unsigned int diff3 = upperR -
diff;
452 bool cond1 = ( (diff1>>nEtaBits) & 1 ) ?
false :
true;
453 bool cond2 = ( (diff2>>nEtaBits) & 1 ) ?
false :
true;
454 bool cond3 = ( (diff3>>nEtaBits) & 1 ) ?
false :
true;
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
473 if( cond1 && (cond2 && cond3 ) )
return true;
474 else if( !cond1 && (cond2 || cond3) )
return true;
484 const Type1& lowerR,
const Type1& upperR )
const {
487 if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1;
489 int diff1 = upperR - lowerR;
490 int diff2 = deltaPhi - lowerR;
493 bool cond1 = ( diff1<0 ) ?
false :
true;
494 bool cond2 = ( diff2<0 ) ?
false :
true;
495 bool cond3 = ( diff3<0 ) ?
false :
true;
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
515 if( cond1 && (cond2 && cond3 ) )
return true;
516 else if( !cond1 && (cond2 || cond3) )
return true;
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
void evaluateConditionStoreResult(const int bxEval)
call evaluateCondition and save last result
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
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
void setCondMaxNumberObjects(int condMaxNumberObjectsValue)
void setVerbosity(const int verbosity)
virtual void print(std::ostream &myCout) const
print condition
const bool checkThreshold(const Type1 &thresholdL, const Type1 &thresholdH, const Type2 &value, bool condGEqValue) const
bool condLastResult() const
get the latest result for the condition
ConditionEvaluation()
constructor
virtual const bool evaluateCondition(const int bxEval) const =0
the core function to check if the condition matches
virtual std::string getNumericExpression() const
get numeric expression
Abs< T >::type abs(const T &t)
const bool checkBit(const Type1 &mask, const unsigned int bitNumber) const
check if a bit with a given number is set in a mask
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
virtual ~ConditionEvaluation()
destructor
int m_verbosity
verbosity level
unsigned long long uint64_t
int condMaxNumberObjects() const
bool m_condLastResult
the last result of evaluateCondition()
int m_condMaxNumberObjects
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
const bool checkIndex(const Type1 &indexLo, const Type1 &indexHi, const unsigned int index) const
check if a index is in a given range
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
CombinationsInCond & combinationsInCond() const
get all the object combinations (to fill it...)
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