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) {
208 template <
class Type1>
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;
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;
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;
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 {
436 int diff1 = upperR - 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))