301 int mode_inv = (address >> (30 - 4)) & ((1 << 4) - 1);
303 auto contain = [](
const std::vector<int>& vec,
int elem) {
304 return (
std::find(vec.begin(), vec.end(),
elem) != vec.end());
353 dPhi12 = (address >> (0)) & ((1 << 9) - 1);
354 sign12 = (address >> (0 + 9)) & ((1 << 1) - 1);
355 dTheta12 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
356 CLCT1 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
357 CLCT1Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
358 CLCT2 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
359 CLCT2Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
360 FR1 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
361 FR2 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
362 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
366 dPhi13 = (address >> (0)) & ((1 << 9) - 1);
367 sign13 = (address >> (0 + 9)) & ((1 << 1) - 1);
368 dTheta13 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
369 CLCT1 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
370 CLCT1Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
371 CLCT3 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
372 CLCT3Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
373 FR1 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
374 FR3 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
375 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
379 dPhi14 = (address >> (0)) & ((1 << 9) - 1);
380 sign14 = (address >> (0 + 9)) & ((1 << 1) - 1);
381 dTheta14 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
382 CLCT1 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
383 CLCT1Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
384 CLCT4 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
385 CLCT4Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
386 FR1 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
387 FR4 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
388 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
392 dPhi23 = (address >> (0)) & ((1 << 9) - 1);
393 sign23 = (address >> (0 + 9)) & ((1 << 1) - 1);
394 dTheta23 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
395 CLCT2 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
396 CLCT2Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
397 CLCT3 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
398 CLCT3Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
399 FR2 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
400 FR3 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
401 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
405 dPhi24 = (address >> (0)) & ((1 << 9) - 1);
406 sign24 = (address >> (0 + 9)) & ((1 << 1) - 1);
407 dTheta24 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
408 CLCT2 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
409 CLCT2Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
410 CLCT4 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
411 CLCT4Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
412 FR2 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
413 FR4 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
414 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
418 dPhi34 = (address >> (0)) & ((1 << 9) - 1);
419 sign34 = (address >> (0 + 9)) & ((1 << 1) - 1);
420 dTheta34 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
421 CLCT3 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
422 CLCT3Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
423 CLCT4 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
424 CLCT4Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
425 FR3 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
426 FR4 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
427 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
431 dPhi12 = (address >> (0)) & ((1 << 7) - 1);
432 dPhi23 = (address >> (0 + 7)) & ((1 << 5) - 1);
433 sign12 = (address >> (0 + 7 + 5)) & ((1 << 1) - 1);
434 sign23 = (address >> (0 + 7 + 5 + 1)) & ((1 << 1) - 1);
435 dTheta13 = (address >> (0 + 7 + 5 + 1 + 1)) & ((1 << 3) - 1);
436 CLCT1 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
437 CLCT1Sign = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
438 FR1 = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1)) & ((1 << 1) - 1);
439 theta = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1 + 1)) & ((1 << 5) - 1);
446 dPhi12 = (address >> (0)) & ((1 << 7) - 1);
447 dPhi24 = (address >> (0 + 7)) & ((1 << 5) - 1);
448 sign12 = (address >> (0 + 7 + 5)) & ((1 << 1) - 1);
449 sign24 = (address >> (0 + 7 + 5 + 1)) & ((1 << 1) - 1);
450 dTheta14 = (address >> (0 + 7 + 5 + 1 + 1)) & ((1 << 3) - 1);
451 CLCT1 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
452 CLCT1Sign = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
453 FR1 = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1)) & ((1 << 1) - 1);
454 theta = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1 + 1)) & ((1 << 5) - 1);
461 dPhi13 = (address >> (0)) & ((1 << 7) - 1);
462 dPhi34 = (address >> (0 + 7)) & ((1 << 5) - 1);
463 sign13 = (address >> (0 + 7 + 5)) & ((1 << 1) - 1);
464 sign34 = (address >> (0 + 7 + 5 + 1)) & ((1 << 1) - 1);
465 dTheta14 = (address >> (0 + 7 + 5 + 1 + 1)) & ((1 << 3) - 1);
466 CLCT1 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
467 CLCT1Sign = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
468 FR1 = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1)) & ((1 << 1) - 1);
469 theta = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1 + 1)) & ((1 << 5) - 1);
476 dPhi23 = (address >> (0)) & ((1 << 7) - 1);
477 dPhi34 = (address >> (0 + 7)) & ((1 << 6) - 1);
478 sign23 = (address >> (0 + 7 + 6)) & ((1 << 1) - 1);
479 sign34 = (address >> (0 + 7 + 6 + 1)) & ((1 << 1) - 1);
480 dTheta24 = (address >> (0 + 7 + 6 + 1 + 1)) & ((1 << 3) - 1);
481 CLCT2 = (address >> (0 + 7 + 6 + 1 + 1 + 3)) & ((1 << 2) - 1);
482 CLCT2Sign = (address >> (0 + 7 + 6 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
483 theta = (address >> (0 + 7 + 6 + 1 + 1 + 3 + 2 + 1)) & ((1 << 5) - 1);
490 dPhi12 = (address >> (0)) & ((1 << 7) - 1);
491 dPhi23 = (address >> (0 + 7)) & ((1 << 5) - 1);
492 dPhi34 = (address >> (0 + 7 + 5)) & ((1 << 6) - 1);
493 sign23 = (address >> (0 + 7 + 5 + 6)) & ((1 << 1) - 1);
494 sign34 = (address >> (0 + 7 + 5 + 6 + 1)) & ((1 << 1) - 1);
495 FR1 = (address >> (0 + 7 + 5 + 6 + 1 + 1)) & ((1 << 1) - 1);
496 theta = (address >> (0 + 7 + 5 + 6 + 1 + 1 + 1)) & ((1 << 5) - 1);
507 auto get_signed_int = [](
int var,
int sign) {
return (
sign == 1) ? (var * 1) : (var * -1); };
509 dPhi12 = get_signed_int(dPhi12, sign12);
510 dPhi13 = get_signed_int(dPhi13, sign13);
511 dPhi14 = get_signed_int(dPhi14, sign14);
512 dPhi23 = get_signed_int(dPhi23, sign23);
513 dPhi24 = get_signed_int(dPhi24, sign24);
514 dPhi34 = get_signed_int(dPhi34, sign34);
516 CLCT1 = get_signed_int(CLCT1, CLCT1Sign);
517 CLCT2 = get_signed_int(CLCT2, CLCT2Sign);
518 CLCT3 = get_signed_int(CLCT3, CLCT3Sign);
519 CLCT4 = get_signed_int(CLCT4, CLCT4Sign);
524 bool use_lossy_eta =
true;
527 etaInt &= ((1 << 5) - 1);
535 if (mode_inv == 15) {
536 bool st2_off =
false;
537 bool st3_off =
false;
538 bool st4_off =
false;
540 dPhi13 = dPhi12 + dPhi23;
541 dPhi14 = dPhi13 + dPhi34;
542 dPhi24 = dPhi23 + dPhi34;
544 int sum_st1 =
abs(dPhi12 + dPhi13 + dPhi14);
545 int sum_st2 =
abs(-dPhi12 + dPhi23 + dPhi24);
546 int sum_st3 =
abs(-dPhi13 - dPhi23 + dPhi34);
547 int sum_st4 =
abs(-dPhi14 - dPhi24 - dPhi34);
550 if (sum_st2 > sum_st1 && sum_st2 > sum_st3 && sum_st2 > sum_st4)
552 if (sum_st3 > sum_st1 && sum_st3 > sum_st2 && sum_st3 > sum_st4)
554 if (sum_st4 > sum_st1 && sum_st4 > sum_st2 && sum_st4 > sum_st3)
559 if ((
abs(dPhi12) > 9 ||
abs(dPhi23) > 9 ||
abs(dPhi24) > 9) &&
560 (
abs(dPhi13) < 10 &&
abs(dPhi14) < 10 &&
abs(dPhi34) < 10)) {
566 if ((
abs(dPhi13) > 9 ||
abs(dPhi23) > 9 ||
abs(dPhi34) > 9) &&
567 (
abs(dPhi12) < 10 &&
abs(dPhi14) < 10 &&
abs(dPhi24) < 10)) {
573 if ((
abs(dPhi14) > 9 ||
abs(dPhi24) > 9 ||
abs(dPhi34) > 9) &&
574 (
abs(dPhi12) < 10 &&
abs(dPhi13) < 10 &&
abs(dPhi23) < 10)) {
575 if (
abs(dPhi13) <
abs(dPhi23))
594 sign23 = (dPhi23 > 0) ? 1 : 0;
595 sign34 = (dPhi34 > 0) ? 1 : 0;
597 sign23 = (dPhi23 < 0) ? 1 : 0;
598 sign34 = (dPhi34 < 0) ? 1 : 0;
601 dPhi12 = get_signed_int(
abs(dPhi12), sign12);
602 dPhi23 = get_signed_int(
abs(dPhi23), sign23);
603 dPhi34 = get_signed_int(
abs(dPhi34), sign34);
610 if (mode_inv == 14) {
617 bugged_CLCT2 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
618 bugged_address = address & ~(((1 << 2) - 1) << (0 + 7 + 6 + 1 + 1 + 3));
619 bugged_address |= (bugged_CLCT2 & ((1 << 2) - 1)) << (0 + 7 + 6 + 1 + 1 + 3);
620 bugged_CLCT2 = (bugged_address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
622 CLCT2 = bugged_CLCT2;
623 CLCT2 = get_signed_int(CLCT2, CLCT2Sign);
631 std::vector<int>
variables = {dPhi12, dPhi13, dPhi14, dPhi23, dPhi24, dPhi34, dTheta12, dTheta13,
632 dTheta14, dTheta23, dTheta24, dTheta34, CLCT1, CLCT2, CLCT3, CLCT4,
633 CSCID1, CSCID2, CSCID3, CSCID4, FR1, FR2, FR3, FR4};
635 std::vector<double> tree_data;
636 tree_data.push_back(1.0);
637 tree_data.push_back(eta);
639 for (
int i = 0;
i < 6;
i++) {
640 int mv = mode_variables[mode_inv - 3][
i];
642 int v = variables.at(mv);
643 if (!(mode_inv == 13 &&
i == 3)) {
644 if (not(v != -999)) {
649 tree_data.push_back(v);
651 tree_data.push_back(0);
656 std::cout <<
"mode_inv: " << mode_inv <<
" variables: ";
657 for (
const auto& v : tree_data)
662 auto tree_event = std::make_unique<emtf::Event>();
663 tree_event->predictedValue = 0;
664 tree_event->data = tree_data;
670 float tmp_pt = tree_event->predictedValue;
673 std::cout <<
"mode_inv: " << mode_inv <<
" 1/pT: " << tmp_pt << std::endl;
674 std::cout <<
"dPhi12: " << dPhi12 <<
" dPhi13: " << dPhi13 <<
" dPhi14: " << dPhi14 <<
" dPhi23: " << dPhi23
675 <<
" dPhi24: " << dPhi24 <<
" dPhi34: " << dPhi34 << std::endl;
676 std::cout <<
"dTheta12: " << dTheta12 <<
" dTheta13: " << dTheta13 <<
" dTheta14: " << dTheta14
677 <<
" dTheta23: " << dTheta23 <<
" dTheta24: " << dTheta24 <<
" dTheta34: " << dTheta34 << std::endl;
678 std::cout <<
"CLCT1: " << CLCT1 <<
" CLCT2: " << CLCT2 <<
" CLCT3: " << CLCT3 <<
" CLCT4: " << CLCT4 << std::endl;
679 std::cout <<
"CSCID1: " << CSCID1 <<
" CSCID2: " << CSCID2 <<
" CSCID3: " << CSCID3 <<
" CSCID4: " << CSCID4
681 std::cout <<
"FR1: " << FR1 <<
" FR2: " << FR2 <<
" FR3: " << FR3 <<
" FR4: " << FR4 << std::endl;
685 pt = (tmp_pt == 0) ? tmp_pt : 1.0 / tmp_pt;
694 pt = (tmp_pt == 0) ? tmp_pt : 1.0 / tmp_pt;
void predictEvent(Event *e, unsigned int trees)
int getdPhiFromBin(int dPhiBin, int bits, int max=512) const
Geom::Theta< T > theta() const
int getEtaInt(float eta, int bits=5) const
float getEtaFromEtaInt(int etaInt, int bits=5) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const PtAssignmentEngineAux2016 & aux() const
Abs< T >::type abs(const T &t)
const int(* getModeVariables() const)[6]
def elem(elemtype, innerHTML='', html_class='', kwargs)
std::array< emtf::Forest, 16 > forests_
float getEtaFromThetaInt(int thetaInt, int bits=5) const
std::vector< int > allowedModes_