1 #ifndef GlobalTrigger_ConditionEvaluation_h
2 #define GlobalTrigger_ConditionEvaluation_h
24 #include <boost/cstdint.hpp>
96 virtual void print(std::ostream& myCout)
const;
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& beginR,
const Type1& endR,
120 const Type1& beginVetoR,
const Type1& endVetoR )
const;
123 template<
class Type1>
const bool checkRangePhi(
const unsigned int bitNumber,
124 const Type1& beginR,
const Type1& endR,
125 const Type1& beginVetoR,
const Type1& endVetoR )
const;
129 template<
class Type1>
const bool checkRangeDeltaEta(
const unsigned int obj1Eta,
const unsigned int obj2Eta,
130 const Type1& lowerR,
const Type1& upperR )
const;
133 template<
class Type1>
const bool checkRangeDeltaPhi(
const unsigned int obj1Phi,
const unsigned int obj2Phi,
134 const Type1& lowerR,
const Type1& upperR )
const;
159 const Type1&
threshold,
const Type2&
value,
const bool condGEqValue)
const {
169 if (value >= (Type2) threshold) {
182 if (value == (Type2) threshold) {
196 const unsigned int bitNumber)
const {
200 if (bitNumber >= (
sizeof(oneBit)*8)) {
205 <<
" checkBit " <<
"\n Bit number = "
206 << bitNumber <<
" larger than maximum allowed " <<
sizeof ( oneBit ) * 8
213 oneBit <<= bitNumber;
221 return (mask & oneBit);
227 const Type1& beginR,
const Type1& endR,
228 const Type1& beginVetoR,
const Type1& endVetoR )
const {
231 if( beginR==endR && beginR==(Type1)-1 ){
235 unsigned int diff1 = endR - beginR;
236 unsigned int diff2 = bitNumber - beginR;
237 unsigned int diff3 = endR - bitNumber;
239 bool cond1 = ( (diff1>>7) & 1 ) ?
false :
true;
240 bool cond2 = ( (diff2>>7) & 1 ) ?
false :
true;
241 bool cond3 = ( (diff3>>7) & 1 ) ?
false :
true;
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
261 bool passWindow =
false;
262 if( cond1 && (cond2 && cond3 ) ) passWindow=
true;
263 else if( !cond1 && (cond2 || cond3) ) passWindow=
true;
269 if( beginVetoR==endVetoR && beginVetoR==(Type1)-1 )
return true;
271 unsigned int diffV1 = endVetoR - beginVetoR;
272 unsigned int diffV2 = bitNumber - beginVetoR;
273 unsigned int diffV3 = endVetoR - bitNumber;
275 bool condV1 = ( (diffV1>>7) & 1 ) ?
false :
true;
276 bool condV2 = ( (diffV2>>7) & 1 ) ?
false :
true;
277 bool condV3 = ( (diffV3>>7) & 1 ) ?
false :
true;
279 if( condV1 && !(condV2 && condV3) )
return true;
280 else if( !condV1 && !(condV2 || condV3) )
return true;
286 LogDebug(
"l1t|Global") <<
"=====> ConditionEvaluation::checkRange: I should never be here." << std::endl;
290 LogDebug(
"l1t|Global") <<
"=====> HELP!! I'm trapped and I cannot escape! AHHHHHH" << std::endl;
298 const Type1& beginR,
const Type1& endR,
299 const Type1& beginVetoR,
const Type1& endVetoR )
const {
302 if( beginR==endR && beginR==(Type1)-1 ){
306 int diff1 = endR - beginR;
307 int diff2 = bitNumber - beginR;
308 int diff3 = endR - bitNumber;
310 bool cond1 = ( diff1<0 ) ?
false :
true;
311 bool cond2 = ( diff2<0 ) ?
false :
true;
312 bool cond3 = ( diff3<0 ) ?
false :
true;
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
332 bool passWindow =
false;
333 if( cond1 && (cond2 && cond3 ) ) passWindow=
true;
334 else if( !cond1 && (cond2 || cond3) ) passWindow=
true;
340 if( beginVetoR==endVetoR && beginVetoR==(Type1)-1 )
return true;
342 int diffV1 = endVetoR - beginVetoR;
343 int diffV2 = bitNumber - beginVetoR;
344 int diffV3 = endVetoR - bitNumber;
346 bool condV1 = ( diffV1<0 ) ?
false :
true;
347 bool condV2 = ( diffV2<0 ) ?
false :
true;
348 bool condV3 = ( diffV3<0 ) ?
false :
true;
350 if( condV1 && !(condV2 && condV3) )
return true;
351 else if( !condV1 && !(condV2 || condV3) )
return true;
357 LogDebug(
"l1t|Global") <<
"=====> ConditionEvaluation::checkRange: I should never be here." << std::endl;
361 LogDebug(
"l1t|Global") <<
"=====> HELP!! I'm trapped and I cannot escape! AHHHHHH" << std::endl;
366 const Type1& lowerR,
const Type1& upperR )
const {
373 unsigned int compare = obj1Eta - obj2Eta;
374 bool cond = ( (compare>>7) & 1 ) ?
false :
true;
376 unsigned int larger, smaller;
386 unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
388 unsigned int diff1 = upperR - lowerR;
389 unsigned int diff2 = diff - lowerR;
390 unsigned int diff3 = upperR -
diff;
392 bool cond1 = ( (diff1>>7) & 1 ) ?
false :
true;
393 bool cond2 = ( (diff2>>7) & 1 ) ?
false :
true;
394 bool cond3 = ( (diff3>>7) & 1 ) ?
false :
true;
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
413 if( cond1 && (cond2 && cond3 ) )
return true;
414 else if( !cond1 && (cond2 || cond3) )
return true;
424 const Type1& lowerR,
const Type1& upperR )
const {
427 if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1;
429 int diff1 = upperR - lowerR;
430 int diff2 = deltaPhi - lowerR;
433 bool cond1 = ( diff1<0 ) ?
false :
true;
434 bool cond2 = ( diff2<0 ) ?
false :
true;
435 bool cond3 = ( diff3<0 ) ?
false :
true;
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
455 if( cond1 && (cond2 && cond3 ) )
return true;
456 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
void setCondMaxNumberObjects(int condMaxNumberObjectsValue)
void setVerbosity(const int verbosity)
virtual void print(std::ostream &myCout) const
print condition
bool condLastResult() const
get the latest result for the condition
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
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
const bool checkThreshold(const Type1 &threshold, const Type2 &value, bool condGEqValue) const
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
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 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
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...)