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,
121 const unsigned int nEtaBits )
const;
124 template<
class Type1>
const bool checkRangePhi(
const unsigned int bitNumber,
125 const Type1& beginR,
const Type1& endR,
126 const Type1& beginVetoR,
const Type1& endVetoR )
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&
threshold,
const Type2&
value,
const bool condGEqValue)
const {
171 if (value >= (Type2) threshold) {
184 if (value == (Type2) threshold) {
198 const unsigned int bitNumber)
const {
202 if (bitNumber >= (
sizeof(oneBit)*8)) {
207 <<
" checkBit " <<
"\n Bit number = "
208 << bitNumber <<
" larger than maximum allowed " <<
sizeof ( oneBit ) * 8
215 oneBit <<= bitNumber;
223 return (mask & oneBit);
229 const Type1& beginR,
const Type1& endR,
230 const Type1& beginVetoR,
const Type1& endVetoR,
231 const unsigned int nEtaBits)
const {
234 if( beginR==endR && beginR==(Type1)-1 ){
238 unsigned int diff1 = endR - beginR;
239 unsigned int diff2 = bitNumber - beginR;
240 unsigned int diff3 = endR - bitNumber;
242 bool cond1 = ( (diff1>>nEtaBits) & 1 ) ?
false :
true;
243 bool cond2 = ( (diff2>>nEtaBits) & 1 ) ?
false :
true;
244 bool cond3 = ( (diff3>>nEtaBits) & 1 ) ?
false :
true;
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
264 bool passWindow =
false;
265 if( cond1 && (cond2 && cond3 ) ) passWindow=
true;
266 else if( !cond1 && (cond2 || cond3) ) passWindow=
true;
272 if( beginVetoR==endVetoR && beginVetoR==(Type1)-1 )
return true;
274 unsigned int diffV1 = endVetoR - beginVetoR;
275 unsigned int diffV2 = bitNumber - beginVetoR;
276 unsigned int diffV3 = endVetoR - bitNumber;
278 bool condV1 = ( (diffV1>>nEtaBits) & 1 ) ?
false :
true;
279 bool condV2 = ( (diffV2>>nEtaBits) & 1 ) ?
false :
true;
280 bool condV3 = ( (diffV3>>nEtaBits) & 1 ) ?
false :
true;
282 if( condV1 && !(condV2 && condV3) )
return true;
283 else if( !condV1 && !(condV2 || condV3) )
return true;
289 LogDebug(
"l1t|Global") <<
"=====> ConditionEvaluation::checkRange: I should never be here." << std::endl;
293 LogDebug(
"l1t|Global") <<
"=====> HELP!! I'm trapped and I cannot escape! AHHHHHH" << std::endl;
301 const Type1& beginR,
const Type1& endR,
302 const Type1& beginVetoR,
const Type1& endVetoR )
const {
305 if( beginR==endR && beginR==(Type1)-1 ){
309 int diff1 = endR - beginR;
310 int diff2 = bitNumber - beginR;
311 int diff3 = endR - bitNumber;
313 bool cond1 = ( diff1<0 ) ?
false :
true;
314 bool cond2 = ( diff2<0 ) ?
false :
true;
315 bool cond3 = ( diff3<0 ) ?
false :
true;
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
335 bool passWindow =
false;
336 if( cond1 && (cond2 && cond3 ) ) passWindow=
true;
337 else if( !cond1 && (cond2 || cond3) ) passWindow=
true;
343 if( beginVetoR==endVetoR && beginVetoR==(Type1)-1 )
return true;
345 int diffV1 = endVetoR - beginVetoR;
346 int diffV2 = bitNumber - beginVetoR;
347 int diffV3 = endVetoR - bitNumber;
349 bool condV1 = ( diffV1<0 ) ?
false :
true;
350 bool condV2 = ( diffV2<0 ) ?
false :
true;
351 bool condV3 = ( diffV3<0 ) ?
false :
true;
353 if( condV1 && !(condV2 && condV3) )
return true;
354 else if( !condV1 && !(condV2 || condV3) )
return true;
360 LogDebug(
"l1t|Global") <<
"=====> ConditionEvaluation::checkRange: I should never be here." << std::endl;
364 LogDebug(
"l1t|Global") <<
"=====> HELP!! I'm trapped and I cannot escape! AHHHHHH" << std::endl;
369 const Type1& lowerR,
const Type1& upperR,
370 const unsigned int nEtaBits )
const {
377 unsigned int compare = obj1Eta - obj2Eta;
378 bool cond = ( (compare>>nEtaBits) & 1 ) ?
false :
true;
390 unsigned int diff = ( ( larger + ((~smaller + 1) & 255) ) & 255);
392 unsigned int diff1 = upperR - lowerR;
393 unsigned int diff2 = diff - lowerR;
394 unsigned int diff3 = upperR -
diff;
396 bool cond1 = ( (diff1>>nEtaBits) & 1 ) ?
false :
true;
397 bool cond2 = ( (diff2>>nEtaBits) & 1 ) ?
false :
true;
398 bool cond3 = ( (diff3>>nEtaBits) & 1 ) ?
false :
true;
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
417 if( cond1 && (cond2 && cond3 ) )
return true;
418 else if( !cond1 && (cond2 || cond3) )
return true;
428 const Type1& lowerR,
const Type1& upperR )
const {
431 if( deltaPhi>71 ) deltaPhi = 143 - deltaPhi + 1;
433 int diff1 = upperR - lowerR;
434 int diff2 = deltaPhi - lowerR;
437 bool cond1 = ( diff1<0 ) ?
false :
true;
438 bool cond2 = ( diff2<0 ) ?
false :
true;
439 bool cond3 = ( diff3<0 ) ?
false :
true;
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
459 if( cond1 && (cond2 && cond3 ) )
return true;
460 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 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)
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
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 unsigned int nEtaBits) const
check if a value is in a given range and outside of a veto range
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...)