298 int mode_inv = (address >> (30 - 4)) & ((1 << 4) - 1);
300 auto contain = [](
const std::vector<int>& vec,
int elem) {
301 return (
std::find(vec.begin(), vec.end(), elem) != vec.end());
350 dPhi12 = (address >> (0)) & ((1 << 9) - 1);
351 sign12 = (address >> (0 + 9)) & ((1 << 1) - 1);
352 dTheta12 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
353 CLCT1 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
354 CLCT1Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
355 CLCT2 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
356 CLCT2Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
357 FR1 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
358 FR2 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
359 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
363 dPhi13 = (address >> (0)) & ((1 << 9) - 1);
364 sign13 = (address >> (0 + 9)) & ((1 << 1) - 1);
365 dTheta13 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
366 CLCT1 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
367 CLCT1Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
368 CLCT3 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
369 CLCT3Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
370 FR1 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
371 FR3 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
372 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
376 dPhi14 = (address >> (0)) & ((1 << 9) - 1);
377 sign14 = (address >> (0 + 9)) & ((1 << 1) - 1);
378 dTheta14 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
379 CLCT1 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
380 CLCT1Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
381 CLCT4 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
382 CLCT4Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
383 FR1 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
384 FR4 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
385 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
389 dPhi23 = (address >> (0)) & ((1 << 9) - 1);
390 sign23 = (address >> (0 + 9)) & ((1 << 1) - 1);
391 dTheta23 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
392 CLCT2 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
393 CLCT2Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
394 CLCT3 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
395 CLCT3Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
396 FR2 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
397 FR3 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
398 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
402 dPhi24 = (address >> (0)) & ((1 << 9) - 1);
403 sign24 = (address >> (0 + 9)) & ((1 << 1) - 1);
404 dTheta24 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
405 CLCT2 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
406 CLCT2Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
407 CLCT4 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
408 CLCT4Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
409 FR2 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
410 FR4 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
411 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
415 dPhi34 = (address >> (0)) & ((1 << 9) - 1);
416 sign34 = (address >> (0 + 9)) & ((1 << 1) - 1);
417 dTheta34 = (address >> (0 + 9 + 1)) & ((1 << 3) - 1);
418 CLCT3 = (address >> (0 + 9 + 1 + 3)) & ((1 << 2) - 1);
419 CLCT3Sign = (address >> (0 + 9 + 1 + 3 + 2)) & ((1 << 1) - 1);
420 CLCT4 = (address >> (0 + 9 + 1 + 3 + 2 + 1)) & ((1 << 2) - 1);
421 CLCT4Sign = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2)) & ((1 << 1) - 1);
422 FR3 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1)) & ((1 << 1) - 1);
423 FR4 = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1)) & ((1 << 1) - 1);
424 theta = (address >> (0 + 9 + 1 + 3 + 2 + 1 + 2 + 1 + 1 + 1)) & ((1 << 5) - 1);
428 dPhi12 = (address >> (0)) & ((1 << 7) - 1);
429 dPhi23 = (address >> (0 + 7)) & ((1 << 5) - 1);
430 sign12 = (address >> (0 + 7 + 5)) & ((1 << 1) - 1);
431 sign23 = (address >> (0 + 7 + 5 + 1)) & ((1 << 1) - 1);
432 dTheta13 = (address >> (0 + 7 + 5 + 1 + 1)) & ((1 << 3) - 1);
433 CLCT1 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
434 CLCT1Sign = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
435 FR1 = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1)) & ((1 << 1) - 1);
436 theta = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1 + 1)) & ((1 << 5) - 1);
443 dPhi12 = (address >> (0)) & ((1 << 7) - 1);
444 dPhi24 = (address >> (0 + 7)) & ((1 << 5) - 1);
445 sign12 = (address >> (0 + 7 + 5)) & ((1 << 1) - 1);
446 sign24 = (address >> (0 + 7 + 5 + 1)) & ((1 << 1) - 1);
447 dTheta14 = (address >> (0 + 7 + 5 + 1 + 1)) & ((1 << 3) - 1);
448 CLCT1 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
449 CLCT1Sign = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
450 FR1 = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1)) & ((1 << 1) - 1);
451 theta = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1 + 1)) & ((1 << 5) - 1);
458 dPhi13 = (address >> (0)) & ((1 << 7) - 1);
459 dPhi34 = (address >> (0 + 7)) & ((1 << 5) - 1);
460 sign13 = (address >> (0 + 7 + 5)) & ((1 << 1) - 1);
461 sign34 = (address >> (0 + 7 + 5 + 1)) & ((1 << 1) - 1);
462 dTheta14 = (address >> (0 + 7 + 5 + 1 + 1)) & ((1 << 3) - 1);
463 CLCT1 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
464 CLCT1Sign = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
465 FR1 = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1)) & ((1 << 1) - 1);
466 theta = (address >> (0 + 7 + 5 + 1 + 1 + 3 + 2 + 1 + 1)) & ((1 << 5) - 1);
473 dPhi23 = (address >> (0)) & ((1 << 7) - 1);
474 dPhi34 = (address >> (0 + 7)) & ((1 << 6) - 1);
475 sign23 = (address >> (0 + 7 + 6)) & ((1 << 1) - 1);
476 sign34 = (address >> (0 + 7 + 6 + 1)) & ((1 << 1) - 1);
477 dTheta24 = (address >> (0 + 7 + 6 + 1 + 1)) & ((1 << 3) - 1);
478 CLCT2 = (address >> (0 + 7 + 6 + 1 + 1 + 3)) & ((1 << 2) - 1);
479 CLCT2Sign = (address >> (0 + 7 + 6 + 1 + 1 + 3 + 2)) & ((1 << 1) - 1);
480 theta = (address >> (0 + 7 + 6 + 1 + 1 + 3 + 2 + 1)) & ((1 << 5) - 1);
487 dPhi12 = (address >> (0)) & ((1 << 7) - 1);
488 dPhi23 = (address >> (0 + 7)) & ((1 << 5) - 1);
489 dPhi34 = (address >> (0 + 7 + 5)) & ((1 << 6) - 1);
490 sign23 = (address >> (0 + 7 + 5 + 6)) & ((1 << 1) - 1);
491 sign34 = (address >> (0 + 7 + 5 + 6 + 1)) & ((1 << 1) - 1);
492 FR1 = (address >> (0 + 7 + 5 + 6 + 1 + 1)) & ((1 << 1) - 1);
493 theta = (address >> (0 + 7 + 5 + 6 + 1 + 1 + 1)) & ((1 << 5) - 1);
504 auto get_signed_int = [](
int var,
int sign) {
return (
sign == 1) ? (var * 1) : (var * -1); };
506 dPhi12 = get_signed_int(dPhi12, sign12);
507 dPhi13 = get_signed_int(dPhi13, sign13);
508 dPhi14 = get_signed_int(dPhi14, sign14);
509 dPhi23 = get_signed_int(dPhi23, sign23);
510 dPhi24 = get_signed_int(dPhi24, sign24);
511 dPhi34 = get_signed_int(dPhi34, sign34);
513 CLCT1 = get_signed_int(CLCT1, CLCT1Sign);
514 CLCT2 = get_signed_int(CLCT2, CLCT2Sign);
515 CLCT3 = get_signed_int(CLCT3, CLCT3Sign);
516 CLCT4 = get_signed_int(CLCT4, CLCT4Sign);
521 bool use_lossy_eta =
true;
524 etaInt &= ((1 << 5) - 1);
532 if (mode_inv == 15) {
533 bool st2_off =
false;
534 bool st3_off =
false;
535 bool st4_off =
false;
537 dPhi13 = dPhi12 + dPhi23;
538 dPhi14 = dPhi13 + dPhi34;
539 dPhi24 = dPhi23 + dPhi34;
541 int sum_st1 =
abs(dPhi12 + dPhi13 + dPhi14);
542 int sum_st2 =
abs(-dPhi12 + dPhi23 + dPhi24);
543 int sum_st3 =
abs(-dPhi13 - dPhi23 + dPhi34);
544 int sum_st4 =
abs(-dPhi14 - dPhi24 - dPhi34);
547 if (sum_st2 > sum_st1 && sum_st2 > sum_st3 && sum_st2 > sum_st4)
549 if (sum_st3 > sum_st1 && sum_st3 > sum_st2 && sum_st3 > sum_st4)
551 if (sum_st4 > sum_st1 && sum_st4 > sum_st2 && sum_st4 > sum_st3)
556 if ((
abs(dPhi12) > 9 ||
abs(dPhi23) > 9 ||
abs(dPhi24) > 9) &&
557 (
abs(dPhi13) < 10 &&
abs(dPhi14) < 10 &&
abs(dPhi34) < 10)) {
563 if ((
abs(dPhi13) > 9 ||
abs(dPhi23) > 9 ||
abs(dPhi34) > 9) &&
564 (
abs(dPhi12) < 10 &&
abs(dPhi14) < 10 &&
abs(dPhi24) < 10)) {
570 if ((
abs(dPhi14) > 9 ||
abs(dPhi24) > 9 ||
abs(dPhi34) > 9) &&
571 (
abs(dPhi12) < 10 &&
abs(dPhi13) < 10 &&
abs(dPhi23) < 10)) {
572 if (
abs(dPhi13) <
abs(dPhi23))
591 sign23 = (dPhi23 > 0) ? 1 : 0;
592 sign34 = (dPhi34 > 0) ? 1 : 0;
594 sign23 = (dPhi23 < 0) ? 1 : 0;
595 sign34 = (dPhi34 < 0) ? 1 : 0;
598 dPhi12 = get_signed_int(
abs(dPhi12), sign12);
599 dPhi23 = get_signed_int(
abs(dPhi23), sign23);
600 dPhi34 = get_signed_int(
abs(dPhi34), sign34);
607 if (mode_inv == 14) {
614 bugged_CLCT2 = (address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
615 bugged_address = address & ~(((1 << 2) - 1) << (0 + 7 + 6 + 1 + 1 + 3));
616 bugged_address |= (bugged_CLCT2 & ((1 << 2) - 1)) << (0 + 7 + 6 + 1 + 1 + 3);
617 bugged_CLCT2 = (bugged_address >> (0 + 7 + 5 + 1 + 1 + 3)) & ((1 << 2) - 1);
619 CLCT2 = bugged_CLCT2;
620 CLCT2 = get_signed_int(CLCT2, CLCT2Sign);
628 std::vector<int>
variables = {dPhi12, dPhi13, dPhi14, dPhi23, dPhi24, dPhi34, dTheta12, dTheta13,
629 dTheta14, dTheta23, dTheta24, dTheta34, CLCT1, CLCT2, CLCT3, CLCT4,
630 CSCID1, CSCID2, CSCID3, CSCID4, FR1, FR2, FR3, FR4};
632 std::vector<double> tree_data;
633 tree_data.push_back(1.0);
634 tree_data.push_back(eta);
636 for (
int i = 0;
i < 6;
i++) {
637 int mv = mode_variables[mode_inv - 3][
i];
639 int v = variables.at(mv);
640 if (!(mode_inv == 13 &&
i == 3)) {
643 tree_data.push_back(v);
645 tree_data.push_back(0);
650 std::cout <<
"mode_inv: " << mode_inv <<
" variables: ";
651 for (
const auto& v : tree_data)
656 auto tree_event = std::make_unique<emtf::Event>();
657 tree_event->predictedValue = 0;
658 tree_event->data = tree_data;
664 float tmp_pt = tree_event->predictedValue;
667 std::cout <<
"mode_inv: " << mode_inv <<
" 1/pT: " << tmp_pt << std::endl;
668 std::cout <<
"dPhi12: " << dPhi12 <<
" dPhi13: " << dPhi13 <<
" dPhi14: " << dPhi14 <<
" dPhi23: " << dPhi23
669 <<
" dPhi24: " << dPhi24 <<
" dPhi34: " << dPhi34 << std::endl;
670 std::cout <<
"dTheta12: " << dTheta12 <<
" dTheta13: " << dTheta13 <<
" dTheta14: " << dTheta14
671 <<
" dTheta23: " << dTheta23 <<
" dTheta24: " << dTheta24 <<
" dTheta34: " << dTheta34 << std::endl;
672 std::cout <<
"CLCT1: " << CLCT1 <<
" CLCT2: " << CLCT2 <<
" CLCT3: " << CLCT3 <<
" CLCT4: " << CLCT4 << std::endl;
673 std::cout <<
"CSCID1: " << CSCID1 <<
" CSCID2: " << CSCID2 <<
" CSCID3: " << CSCID3 <<
" CSCID4: " << CSCID4
675 std::cout <<
"FR1: " << FR1 <<
" FR2: " << FR2 <<
" FR3: " << FR3 <<
" FR4: " << FR4 << std::endl;
679 pt = (tmp_pt == 0) ? tmp_pt : 1.0 / tmp_pt;
688 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
list var
if using global norm cols_to_minmax = ['t_delta', 't_hmaxNearP','t_emaxNearP', 't_hAnnular', 't_eAnnular','t_pt','t_nVtx','t_ieta','t_eHcal10', 't_eHcal30','t_rhoh','t_eHcal'] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() > 0) else 1.0/200.0)
Abs< T >::type abs(const T &t)
const int(* getModeVariables() const)[6]
std::array< emtf::Forest, 16 > forests_
float getEtaFromThetaInt(int thetaInt, int bits=5) const
std::vector< int > allowedModes_