1 #ifndef L1Trigger_L1TGlobal_ConditionEvaluation_h
2 #define L1Trigger_L1TGlobal_ConditionEvaluation_h
24 #include <boost/cstdint.hpp>
96 virtual void print(std::ostream& myCout)
const;
111 template<
class Type1,
class Type2>
const bool checkThreshold(
const Type1& thresholdL,
const Type1& thresholdH,
112 const Type2&
value,
bool condGEqValue)
const;
115 template<
class Type1>
const bool checkBit(
const Type1& mask,
const unsigned int bitNumber)
const;
118 template<
class Type1>
const bool checkRangeEta(
const unsigned int bitNumber,
119 const Type1& W1beginR,
const Type1& W1endR,
120 const Type1& W2beginR,
const Type1& W2endR,
121 const unsigned int nEtaBits )
const;
124 template<
class Type1>
const bool checkRangePhi(
const unsigned int bitNumber,
125 const Type1& W1beginR,
const Type1& W1endR,
126 const Type1& W2beginR,
const Type1& W2endR )
const;
130 template<
class Type1>
const bool checkRangeDeltaEta(
const unsigned int obj1Eta,
const unsigned int obj2Eta,
131 const Type1& lowerR,
const Type1& upperR,
132 const unsigned int nEtaBits )
const;
135 template<
class Type1>
const bool checkRangeDeltaPhi(
const unsigned int obj1Phi,
const unsigned int obj2Phi,
136 const Type1& lowerR,
const Type1& upperR )
const;
161 const Type1& thresholdL,
const Type1& thresholdH,
const Type2&
value,
const bool condGEqValue)
const {
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;
172 if (value >= (Type2) thresholdL && (Type1) value < thresholdH) {
185 if (value == (Type2) thresholdL ) {
199 const unsigned int bitNumber)
const {
203 if (bitNumber >= (
sizeof(oneBit)*8)) {
208 <<
" checkBit " <<
"\n Bit number = "
209 << bitNumber <<
" larger than maximum allowed " <<
sizeof ( oneBit ) * 8
216 oneBit <<= bitNumber;
224 return (mask & oneBit);
230 const Type1& W1beginR,
const Type1& W1endR,
231 const Type1& W2beginR,
const Type1& W2endR,
232 const unsigned int nEtaBits)
const {
235 if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
239 unsigned int W1diff1 = W1endR - W1beginR;
240 unsigned int W1diff2 = bitNumber - W1beginR;
241 unsigned int W1diff3 = W1endR - bitNumber;
243 bool W1cond1 = ( (W1diff1>>nEtaBits) & 1 ) ?
false :
true;
244 bool W1cond2 = ( (W1diff2>>nEtaBits) & 1 ) ?
false :
true;
245 bool W1cond3 = ( (W1diff3>>nEtaBits) & 1 ) ?
false :
true;
250 bool passWindow1 =
false;
251 if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=
true;
252 else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=
true;
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
274 if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
279 unsigned int W2diff1 = W2endR - W2beginR;
280 unsigned int W2diff2 = bitNumber - W2beginR;
281 unsigned int W2diff3 = W2endR - bitNumber;
283 bool W2cond1 = ( (W2diff1>>nEtaBits) & 1 ) ?
false :
true;
284 bool W2cond2 = ( (W2diff2>>nEtaBits) & 1 ) ?
false :
true;
285 bool W2cond3 = ( (W2diff3>>nEtaBits) & 1 ) ?
false :
true;
287 bool passWindow2 =
false;
288 if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=
true;
289 else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=
true;
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)
308 if( passWindow1 || passWindow2 ){
321 const Type1& W1beginR,
const Type1& W1endR,
322 const Type1& W2beginR,
const Type1& W2endR )
const {
325 if( W1beginR==W1endR && W1beginR==(Type1)-1 ){
329 int W1diff1 = W1endR - W1beginR;
330 int W1diff2 = bitNumber - W1beginR;
331 int W1diff3 = W1endR - bitNumber;
333 bool W1cond1 = ( W1diff1<0 ) ?
false :
true;
334 bool W1cond2 = ( W1diff2<0 ) ?
false :
true;
335 bool W1cond3 = ( W1diff3<0 ) ?
false :
true;
340 bool passWindow1 =
false;
341 if( W1cond1 && (W1cond2 && W1cond3 ) ) passWindow1=
true;
342 else if( !W1cond1 && (W1cond2 || W1cond3) ) passWindow1=
true;
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
362 if( W2beginR==W2endR && W2beginR==(Type1)-1 ){
367 int W2diff1 = W2endR - W2beginR;
368 int W2diff2 = bitNumber - W2beginR;
369 int W2diff3 = W2endR - bitNumber;
371 bool W2cond1 = ( W2diff1<0 ) ?
false :
true;
372 bool W2cond2 = ( W2diff2<0 ) ?
false :
true;
373 bool W2cond3 = ( W2diff3<0 ) ?
false :
true;
378 bool passWindow2 =
false;
379 if( W2cond1 && (W2cond2 && W2cond3 ) ) passWindow2=
true;
380 else if( !W2cond1 && (W2cond2 || W2cond3) ) passWindow2=
true;
386 if( passWindow1 || passWindow2 ){
397 const Type1& lowerR,
const Type1& upperR,
398 const unsigned int nEtaBits )
const {
405 unsigned int compare = obj1Eta - obj2Eta;
406 bool cond = ( (compare>>nEtaBits) & 1 ) ?
false :
true;
418 unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
420 unsigned int diff1 = upperR - lowerR;
421 unsigned int diff2 = diff - lowerR;
422 unsigned int diff3 = upperR -
diff;
424 bool cond1 = ( (diff1>>nEtaBits) & 1 ) ?
false :
true;
425 bool cond2 = ( (diff2>>nEtaBits) & 1 ) ?
false :
true;
426 bool cond3 = ( (diff3>>nEtaBits) & 1 ) ?
false :
true;
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
445 if( cond1 && (cond2 && cond3 ) )
return true;
446 else if( !cond1 && (cond2 || cond3) )
return true;
456 const Type1& lowerR,
const Type1& upperR )
const {
459 if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1;
461 int diff1 = upperR - lowerR;
462 int diff2 = deltaPhi - lowerR;
465 bool cond1 = ( diff1<0 ) ?
false :
true;
466 bool cond2 = ( diff2<0 ) ?
false :
true;
467 bool cond3 = ( diff3<0 ) ?
false :
true;
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
487 if( cond1 && (cond2 && cond3 ) )
return true;
488 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 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()
virtual const bool evaluateCondition(const int bxEval) const =0
the core function to check if the condition matches
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
volatile std::atomic< bool > shutdown_flag false
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