1 #ifndef L1Trigger_L1TGlobal_ConditionEvaluation_h 2 #define L1Trigger_L1TGlobal_ConditionEvaluation_h 78 virtual void print(std::ostream& myCout)
const;
88 template <
class Type1,
class Type2>
90 const Type1& thresholdH,
92 bool condGEqValue)
const;
95 template <
class Type1>
96 const bool checkIndex(
const Type1& indexLo,
const Type1& indexHi,
const unsigned int index)
const;
99 template <
class Type1>
103 template <
class Type1>
105 const Type1& W1beginR,
107 const Type1& W2beginR,
109 const unsigned int nEtaBits)
const;
112 template <
class Type1>
114 const Type1& W1beginR,
116 const Type1& W2beginR,
117 const Type1& W2endR)
const;
120 template <
class Type1>
122 const unsigned int obj2Eta,
125 const unsigned int nEtaBits)
const;
128 template <
class Type1>
130 const unsigned int obj2Phi,
132 const Type1& upperR)
const;
153 template <
class Type1,
class Type2>
155 const Type1& thresholdH,
157 const bool condGEqValue)
const {
159 LogTrace(
"L1GlobalTrigger") <<
" checkThreshold check for condGEqValue = " << condGEqValue
160 <<
"\n hex: " << std::hex <<
"threshold = " << thresholdL <<
" - " << thresholdH
161 <<
" value = " << value <<
"\n dec: " <<
std::dec <<
"threshold = " << thresholdL
162 <<
" - " << thresholdH <<
" value = " << value << std::endl;
166 if (value >= (Type2)thresholdL && (Type1)value < thresholdH) {
176 if (value == (Type2)thresholdL) {
188 template <
class Type1>
190 const Type1& indexHi,
191 const unsigned int index)
const {
192 LogDebug(
"l1t|Global") <<
"\n l1t::ConditionEvaluation" 193 <<
"\n\t indexLo = " << indexLo <<
"\n\t indexHi = " << indexHi <<
"\n\t index = " << index
197 if (indexLo > indexHi) {
200 if (index >= indexLo && index <= indexHi) {
208 template <
class Type1>
212 if (bitNumber >= (
sizeof(oneBit) * 8)) {
214 LogTrace(
"L1GlobalTrigger") <<
" checkBit " 215 <<
"\n Bit number = " << bitNumber <<
" larger than maximum allowed " 216 <<
sizeof(oneBit) * 8 << std::endl;
230 return (mask & oneBit);
234 template <
class Type1>
236 const Type1& W1beginR,
238 const Type1& W2beginR,
240 const unsigned int nEtaBits)
const {
242 if (W1beginR == W1endR && W1beginR == (Type1)-1) {
246 unsigned int W1diff1 = W1endR - W1beginR;
247 unsigned int W1diff2 = bitNumber - W1beginR;
248 unsigned int W1diff3 = W1endR -
bitNumber;
250 bool W1cond1 = ((W1diff1 >> nEtaBits) & 1) ?
false :
true;
251 bool W1cond2 = ((W1diff2 >> nEtaBits) & 1) ?
false :
true;
252 bool W1cond3 = ((W1diff3 >> nEtaBits) & 1) ?
false :
true;
257 bool passWindow1 =
false;
258 if (W1cond1 && (W1cond2 && W1cond3))
260 else if (!W1cond1 && (W1cond2 || W1cond3))
266 LogDebug(
"l1t|Global") <<
"\n l1t::ConditionEvaluation" 267 <<
"\n\t bitNumber = " << bitNumber <<
"\n\t W1beginR = " << W1beginR
268 <<
"\n\t W1endR = " << W1endR <<
"\n\t W1diff1 = " << W1diff1
269 <<
"\n\t W1cond1 = " << W1cond1 <<
"\n\t W1diff2 = " << W1diff2
270 <<
"\n\t W1cond2 = " << W1cond2 <<
"\n\t W1diff3 = " << W1diff3
271 <<
"\n\t W1cond3 = " << W1cond3 <<
"\n\t passWindow1 = " << passWindow1 << std::endl;
273 if (W2beginR == W2endR && W2beginR == (Type1)-1) {
277 unsigned int W2diff1 = W2endR - W2beginR;
278 unsigned int W2diff2 = bitNumber - W2beginR;
279 unsigned int W2diff3 = W2endR -
bitNumber;
281 bool W2cond1 = ((W2diff1 >> nEtaBits) & 1) ?
false :
true;
282 bool W2cond2 = ((W2diff2 >> nEtaBits) & 1) ?
false :
true;
283 bool W2cond3 = ((W2diff3 >> nEtaBits) & 1) ?
false :
true;
285 bool passWindow2 =
false;
286 if (W2cond1 && (W2cond2 && W2cond3))
288 else if (!W2cond1 && (W2cond2 || W2cond3))
294 LogDebug(
"l1t|Global") <<
"\n\t W2beginR = " << W2beginR <<
"\n\t W2endR = " << W2endR
295 <<
"\n\t W2diff1 = " << W2diff1 <<
"\n\t W2cond1 = " << W2cond1
296 <<
"\n\t W2diff2 = " << W2diff2 <<
"\n\t W2cond2 = " << W2cond2
297 <<
"\n\t W2diff3 = " << W2diff3 <<
"\n\t W2cond3 = " << W2cond3
298 <<
"\n\t passWindow2 = " << passWindow2
299 <<
"\n\t pass W1 || W2 = " << (passWindow1 || passWindow2) << std::endl;
301 if (passWindow1 || passWindow2) {
309 template <
class Type1>
311 const Type1& W1beginR,
313 const Type1& W2beginR,
314 const Type1& W2endR)
const {
316 if (W1beginR == W1endR && W1beginR == (Type1)-1) {
320 int W1diff1 = W1endR - W1beginR;
321 int W1diff2 = bitNumber - W1beginR;
324 bool W1cond1 = (W1diff1 < 0) ?
false :
true;
325 bool W1cond2 = (W1diff2 < 0) ?
false :
true;
326 bool W1cond3 = (W1diff3 < 0) ?
false :
true;
331 bool passWindow1 =
false;
332 if (W1cond1 && (W1cond2 && W1cond3))
334 else if (!W1cond1 && (W1cond2 || W1cond3))
340 LogDebug(
"l1t|Global") <<
"\n l1t::ConditionEvaluation" 341 <<
"\n\t bitNumber = " << bitNumber <<
"\n\t W1beginR = " << W1beginR
342 <<
"\n\t W1endR = " << W1endR <<
"\n\t W1diff1 = " << W1diff1
343 <<
"\n\t W1cond1 = " << W1cond1 <<
"\n\t W1diff2 = " << W1diff2
344 <<
"\n\t W1cond2 = " << W1cond2 <<
"\n\t W1diff3 = " << W1diff3
345 <<
"\n\t W1cond3 = " << W1cond3 << std::endl;
347 if (W2beginR == W2endR && W2beginR == (Type1)-1) {
351 int W2diff1 = W2endR - W2beginR;
352 int W2diff2 = bitNumber - W2beginR;
355 bool W2cond1 = (W2diff1 < 0) ?
false :
true;
356 bool W2cond2 = (W2diff2 < 0) ?
false :
true;
357 bool W2cond3 = (W2diff3 < 0) ?
false :
true;
362 bool passWindow2 =
false;
363 if (W2cond1 && (W2cond2 && W2cond3))
365 else if (!W2cond1 && (W2cond2 || W2cond3))
371 if (passWindow1 || passWindow2) {
378 template <
class Type1>
380 const unsigned int obj2Eta,
383 const unsigned int nEtaBits)
const {
389 unsigned int compare = obj1Eta - obj2Eta;
390 bool cond = ((compare >> nEtaBits) & 1) ?
false :
true;
392 unsigned int larger, smaller;
401 unsigned int diff = ((larger + ((~smaller + 1) & 255)) & 255);
403 unsigned int diff1 = upperR - lowerR;
404 unsigned int diff2 = diff - lowerR;
405 unsigned int diff3 = upperR -
diff;
407 bool cond1 = ((diff1 >> nEtaBits) & 1) ?
false :
true;
408 bool cond2 = ((diff2 >> nEtaBits) & 1) ?
false :
true;
409 bool cond3 = ((diff3 >> nEtaBits) & 1) ?
false :
true;
411 LogDebug(
"l1t|Global") <<
"\n l1t::ConditionEvaluation" 412 <<
"\n\t obj1Eta = " << obj1Eta <<
"\n\t obj2Eta = " << obj2Eta <<
"\n\t lowerR = " << lowerR
413 <<
"\n\t upperR = " << upperR <<
"\n\t compare = " << compare <<
"\n\t cond = " << cond
414 <<
"\n\t diff = " << diff <<
"\n\t diff1 = " << diff1 <<
"\n\t cond1 = " << cond1
415 <<
"\n\t diff2 = " << diff2 <<
"\n\t cond2 = " << cond2 <<
"\n\t diff3 = " << diff3
416 <<
"\n\t cond3 = " << cond3 << std::endl;
418 if (cond1 && (cond2 && cond3))
420 else if (!cond1 && (cond2 || cond3))
427 template <
class Type1>
429 const unsigned int obj2Phi,
431 const Type1& upperR)
const {
434 deltaPhi = 143 - deltaPhi + 1;
436 int diff1 = upperR - lowerR;
437 int diff2 = deltaPhi - lowerR;
440 bool cond1 = (diff1 < 0) ?
false :
true;
441 bool cond2 = (diff2 < 0) ?
false :
true;
442 bool cond3 = (diff3 < 0) ?
false :
true;
444 LogDebug(
"l1t|Global") <<
"\n l1t::ConditionEvaluation" 445 <<
"\n\t obj1Phi = " << obj1Phi <<
"\n\t obj2Phi = " << obj2Phi
446 <<
"\n\t deltaPhi = " << deltaPhi <<
"\n\t lowerR = " << lowerR <<
"\n\t upperR = " << upperR
447 <<
"\n\t diff1 = " << diff1 <<
"\n\t cond1 = " << cond1 <<
"\n\t diff2 = " << diff2
448 <<
"\n\t cond2 = " << cond2 <<
"\n\t diff3 = " << diff3 <<
"\n\t cond3 = " << cond3
454 if (cond1 && (cond2 && cond3))
456 else if (!cond1 && (cond2 || cond3))
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