300 int mode_inv = (address >> (30-4)) & ((1<<4)-1);
302 auto contain = [](
const std::vector<int>& vec,
int elem) {
303 return (
std::find(vec.begin(), vec.end(),
elem) != vec.end());
352 dPhi12 = (address >> (0)) & ((1<<9)-1);
353 sign12 = (address >> (0+9)) & ((1<<1)-1);
354 dTheta12 = (address >> (0+9+1)) & ((1<<3)-1);
355 CLCT1 = (address >> (0+9+1+3)) & ((1<<2)-1);
356 CLCT1Sign = (address >> (0+9+1+3+2)) & ((1<<1)-1);
357 CLCT2 = (address >> (0+9+1+3+2+1)) & ((1<<2)-1);
358 CLCT2Sign = (address >> (0+9+1+3+2+1+2)) & ((1<<1)-1);
359 FR1 = (address >> (0+9+1+3+2+1+2+1)) & ((1<<1)-1);
360 FR2 = (address >> (0+9+1+3+2+1+2+1+1)) & ((1<<1)-1);
361 theta = (address >> (0+9+1+3+2+1+2+1+1+1)) & ((1<<5)-1);
365 dPhi13 = (address >> (0)) & ((1<<9)-1);
366 sign13 = (address >> (0+9)) & ((1<<1)-1);
367 dTheta13 = (address >> (0+9+1)) & ((1<<3)-1);
368 CLCT1 = (address >> (0+9+1+3)) & ((1<<2)-1);
369 CLCT1Sign = (address >> (0+9+1+3+2)) & ((1<<1)-1);
370 CLCT3 = (address >> (0+9+1+3+2+1)) & ((1<<2)-1);
371 CLCT3Sign = (address >> (0+9+1+3+2+1+2)) & ((1<<1)-1);
372 FR1 = (address >> (0+9+1+3+2+1+2+1)) & ((1<<1)-1);
373 FR3 = (address >> (0+9+1+3+2+1+2+1+1)) & ((1<<1)-1);
374 theta = (address >> (0+9+1+3+2+1+2+1+1+1)) & ((1<<5)-1);
378 dPhi14 = (address >> (0)) & ((1<<9)-1);
379 sign14 = (address >> (0+9)) & ((1<<1)-1);
380 dTheta14 = (address >> (0+9+1)) & ((1<<3)-1);
381 CLCT1 = (address >> (0+9+1+3)) & ((1<<2)-1);
382 CLCT1Sign = (address >> (0+9+1+3+2)) & ((1<<1)-1);
383 CLCT4 = (address >> (0+9+1+3+2+1)) & ((1<<2)-1);
384 CLCT4Sign = (address >> (0+9+1+3+2+1+2)) & ((1<<1)-1);
385 FR1 = (address >> (0+9+1+3+2+1+2+1)) & ((1<<1)-1);
386 FR4 = (address >> (0+9+1+3+2+1+2+1+1)) & ((1<<1)-1);
387 theta = (address >> (0+9+1+3+2+1+2+1+1+1)) & ((1<<5)-1);
391 dPhi23 = (address >> (0)) & ((1<<9)-1);
392 sign23 = (address >> (0+9)) & ((1<<1)-1);
393 dTheta23 = (address >> (0+9+1)) & ((1<<3)-1);
394 CLCT2 = (address >> (0+9+1+3)) & ((1<<2)-1);
395 CLCT2Sign = (address >> (0+9+1+3+2)) & ((1<<1)-1);
396 CLCT3 = (address >> (0+9+1+3+2+1)) & ((1<<2)-1);
397 CLCT3Sign = (address >> (0+9+1+3+2+1+2)) & ((1<<1)-1);
398 FR2 = (address >> (0+9+1+3+2+1+2+1)) & ((1<<1)-1);
399 FR3 = (address >> (0+9+1+3+2+1+2+1+1)) & ((1<<1)-1);
400 theta = (address >> (0+9+1+3+2+1+2+1+1+1)) & ((1<<5)-1);
404 dPhi24 = (address >> (0)) & ((1<<9)-1);
405 sign24 = (address >> (0+9)) & ((1<<1)-1);
406 dTheta24 = (address >> (0+9+1)) & ((1<<3)-1);
407 CLCT2 = (address >> (0+9+1+3)) & ((1<<2)-1);
408 CLCT2Sign = (address >> (0+9+1+3+2)) & ((1<<1)-1);
409 CLCT4 = (address >> (0+9+1+3+2+1)) & ((1<<2)-1);
410 CLCT4Sign = (address >> (0+9+1+3+2+1+2)) & ((1<<1)-1);
411 FR2 = (address >> (0+9+1+3+2+1+2+1)) & ((1<<1)-1);
412 FR4 = (address >> (0+9+1+3+2+1+2+1+1)) & ((1<<1)-1);
413 theta = (address >> (0+9+1+3+2+1+2+1+1+1)) & ((1<<5)-1);
417 dPhi34 = (address >> (0)) & ((1<<9)-1);
418 sign34 = (address >> (0+9)) & ((1<<1)-1);
419 dTheta34 = (address >> (0+9+1)) & ((1<<3)-1);
420 CLCT3 = (address >> (0+9+1+3)) & ((1<<2)-1);
421 CLCT3Sign = (address >> (0+9+1+3+2)) & ((1<<1)-1);
422 CLCT4 = (address >> (0+9+1+3+2+1)) & ((1<<2)-1);
423 CLCT4Sign = (address >> (0+9+1+3+2+1+2)) & ((1<<1)-1);
424 FR3 = (address >> (0+9+1+3+2+1+2+1)) & ((1<<1)-1);
425 FR4 = (address >> (0+9+1+3+2+1+2+1+1)) & ((1<<1)-1);
426 theta = (address >> (0+9+1+3+2+1+2+1+1+1)) & ((1<<5)-1);
430 dPhi12 = (address >> (0)) & ((1<<7)-1);
431 dPhi23 = (address >> (0+7)) & ((1<<5)-1);
432 sign12 = (address >> (0+7+5)) & ((1<<1)-1);
433 sign23 = (address >> (0+7+5+1)) & ((1<<1)-1);
434 dTheta13 = (address >> (0+7+5+1+1)) & ((1<<3)-1);
435 CLCT1 = (address >> (0+7+5+1+1+3)) & ((1<<2)-1);
436 CLCT1Sign = (address >> (0+7+5+1+1+3+2)) & ((1<<1)-1);
437 FR1 = (address >> (0+7+5+1+1+3+2+1)) & ((1<<1)-1);
438 theta = (address >> (0+7+5+1+1+3+2+1+1)) & ((1<<5)-1);
445 dPhi12 = (address >> (0)) & ((1<<7)-1);
446 dPhi24 = (address >> (0+7)) & ((1<<5)-1);
447 sign12 = (address >> (0+7+5)) & ((1<<1)-1);
448 sign24 = (address >> (0+7+5+1)) & ((1<<1)-1);
449 dTheta14 = (address >> (0+7+5+1+1)) & ((1<<3)-1);
450 CLCT1 = (address >> (0+7+5+1+1+3)) & ((1<<2)-1);
451 CLCT1Sign = (address >> (0+7+5+1+1+3+2)) & ((1<<1)-1);
452 FR1 = (address >> (0+7+5+1+1+3+2+1)) & ((1<<1)-1);
453 theta = (address >> (0+7+5+1+1+3+2+1+1)) & ((1<<5)-1);
460 dPhi13 = (address >> (0)) & ((1<<7)-1);
461 dPhi34 = (address >> (0+7)) & ((1<<5)-1);
462 sign13 = (address >> (0+7+5)) & ((1<<1)-1);
463 sign34 = (address >> (0+7+5+1)) & ((1<<1)-1);
464 dTheta14 = (address >> (0+7+5+1+1)) & ((1<<3)-1);
465 CLCT1 = (address >> (0+7+5+1+1+3)) & ((1<<2)-1);
466 CLCT1Sign = (address >> (0+7+5+1+1+3+2)) & ((1<<1)-1);
467 FR1 = (address >> (0+7+5+1+1+3+2+1)) & ((1<<1)-1);
468 theta = (address >> (0+7+5+1+1+3+2+1+1)) & ((1<<5)-1);
475 dPhi23 = (address >> (0)) & ((1<<7)-1);
476 dPhi34 = (address >> (0+7)) & ((1<<6)-1);
477 sign23 = (address >> (0+7+6)) & ((1<<1)-1);
478 sign34 = (address >> (0+7+6+1)) & ((1<<1)-1);
479 dTheta24 = (address >> (0+7+6+1+1)) & ((1<<3)-1);
480 CLCT2 = (address >> (0+7+6+1+1+3)) & ((1<<2)-1);
481 CLCT2Sign = (address >> (0+7+6+1+1+3+2)) & ((1<<1)-1);
482 theta = (address >> (0+7+6+1+1+3+2+1)) & ((1<<5)-1);
489 dPhi12 = (address >> (0)) & ((1<<7)-1);
490 dPhi23 = (address >> (0+7)) & ((1<<5)-1);
491 dPhi34 = (address >> (0+7+5)) & ((1<<6)-1);
492 sign23 = (address >> (0+7+5+6)) & ((1<<1)-1);
493 sign34 = (address >> (0+7+5+6+1)) & ((1<<1)-1);
494 FR1 = (address >> (0+7+5+6+1+1)) & ((1<<1)-1);
495 theta = (address >> (0+7+5+6+1+1+1)) & ((1<<5)-1);
507 auto get_signed_int = [](
int var,
int sign) {
508 return (
sign == 1) ? (var * 1) : (var * -1);
511 dPhi12 = get_signed_int(dPhi12, sign12);
512 dPhi13 = get_signed_int(dPhi13, sign13);
513 dPhi14 = get_signed_int(dPhi14, sign14);
514 dPhi23 = get_signed_int(dPhi23, sign23);
515 dPhi24 = get_signed_int(dPhi24, sign24);
516 dPhi34 = get_signed_int(dPhi34, sign34);
518 CLCT1 = get_signed_int(CLCT1, CLCT1Sign);
519 CLCT2 = get_signed_int(CLCT2, CLCT2Sign);
520 CLCT3 = get_signed_int(CLCT3, CLCT3Sign);
521 CLCT4 = get_signed_int(CLCT4, CLCT4Sign);
526 bool use_lossy_eta =
true;
529 etaInt &= ((1<<5)-1);
538 if (mode_inv == 15) {
539 bool st2_off =
false;
540 bool st3_off =
false;
541 bool st4_off =
false;
543 dPhi13 = dPhi12 + dPhi23;
544 dPhi14 = dPhi13 + dPhi34;
545 dPhi24 = dPhi23 + dPhi34;
547 int sum_st1 =
abs( dPhi12 + dPhi13 + dPhi14);
548 int sum_st2 =
abs(-dPhi12 + dPhi23 + dPhi24);
549 int sum_st3 =
abs(-dPhi13 - dPhi23 + dPhi34);
550 int sum_st4 =
abs(-dPhi14 - dPhi24 - dPhi34);
553 if (sum_st2 > sum_st1 && sum_st2 > sum_st3 && sum_st2 > sum_st4) st2_off =
true;
554 if (sum_st3 > sum_st1 && sum_st3 > sum_st2 && sum_st3 > sum_st4) st3_off =
true;
555 if (sum_st4 > sum_st1 && sum_st4 > sum_st2 && sum_st4 > sum_st3) st4_off =
true;
560 (
abs(dPhi12) > 9 ||
abs(dPhi23) > 9 ||
abs(dPhi24) > 9) &&
561 (
abs(dPhi13) < 10 &&
abs(dPhi14) < 10 &&
abs(dPhi34) < 10)
569 (
abs(dPhi13) > 9 ||
abs(dPhi23) > 9 ||
abs(dPhi34) > 9) &&
570 (
abs(dPhi12) < 10 &&
abs(dPhi14) < 10 &&
abs(dPhi24) < 10)
578 (
abs(dPhi14) > 9 ||
abs(dPhi24) > 9 ||
abs(dPhi34) > 9 ) &&
579 (
abs(dPhi12) < 10 &&
abs(dPhi13) < 10 &&
abs(dPhi23) < 10)
581 if (
abs(dPhi13) <
abs(dPhi23))
600 sign23 = (dPhi23 > 0) ? 1 : 0;
601 sign34 = (dPhi34 > 0) ? 1 : 0;
603 sign23 = (dPhi23 < 0) ? 1 : 0;
604 sign34 = (dPhi34 < 0) ? 1 : 0;
607 dPhi12 = get_signed_int(
abs(dPhi12), sign12);
608 dPhi23 = get_signed_int(
abs(dPhi23), sign23);
609 dPhi34 = get_signed_int(
abs(dPhi34), sign34);
616 if (mode_inv == 14) {
623 bugged_CLCT2 = (address >> (0+7+5+1+1+3)) & ((1<<2)-1);
624 bugged_address = address & ~(((1<<2)-1) << (0+7+6+1+1+3));
625 bugged_address |= (bugged_CLCT2 & ((1<<2)-1)) << (0+7+6+1+1+3);
626 bugged_CLCT2 = (bugged_address >> (0+7+5+1+1+3)) & ((1<<2)-1);
628 CLCT2 = bugged_CLCT2;
629 CLCT2 = get_signed_int(CLCT2, CLCT2Sign);
639 dPhi12, dPhi13, dPhi14, dPhi23, dPhi24, dPhi34, dTheta12, dTheta13, dTheta14, dTheta23, dTheta24, dTheta34,
640 CLCT1, CLCT2, CLCT3, CLCT4, CSCID1, CSCID2, CSCID3, CSCID4, FR1, FR2, FR3, FR4
643 std::vector<double> tree_data;
644 tree_data.push_back(1.0);
645 tree_data.push_back(eta);
647 for (
int i=0;
i<6;
i++) {
648 int mv = mode_variables[mode_inv-3][
i];
650 int v = variables.at(mv);
651 if (!(mode_inv == 13 &&
i == 3)) {
655 tree_data.push_back(v);
657 tree_data.push_back(0);
662 std::cout <<
"mode_inv: " << mode_inv <<
" variables: ";
663 for (
const auto& v: tree_data)
668 auto tree_event = std::make_unique<emtf::Event>();
669 tree_event->predictedValue = 0;
670 tree_event->data = tree_data;
676 float tmp_pt = tree_event->predictedValue;
679 std::cout <<
"mode_inv: " << mode_inv <<
" 1/pT: " << tmp_pt << std::endl;
680 std::cout <<
"dPhi12: " << dPhi12 <<
" dPhi13: " << dPhi13 <<
" dPhi14: " << dPhi14
681 <<
" dPhi23: " << dPhi23 <<
" dPhi24: " << dPhi24 <<
" dPhi34: " << dPhi34 << std::endl;
682 std::cout <<
"dTheta12: " << dTheta12 <<
" dTheta13: " << dTheta13 <<
" dTheta14: " << dTheta14
683 <<
" dTheta23: " << dTheta23 <<
" dTheta24: " << dTheta24 <<
" dTheta34: " << dTheta34 << std::endl;
684 std::cout <<
"CLCT1: " << CLCT1 <<
" CLCT2: " << CLCT2 <<
" CLCT3: " << CLCT3 <<
" CLCT4: " << CLCT4 << std::endl;
685 std::cout <<
"CSCID1: " << CSCID1 <<
" CSCID2: " << CSCID2 <<
" CSCID3: " << CSCID3 <<
" CSCID4: " << CSCID4 << std::endl;
686 std::cout <<
"FR1: " << FR1 <<
" FR2: " << FR2 <<
" FR3: " << FR3 <<
" FR4: " << FR4 << std::endl;
690 pt = (tmp_pt == 0) ? tmp_pt : 1.0/tmp_pt;
691 if (pt<0.0) pt = 1.0;
692 if (pt>200.0) pt = 200.0;
695 if (tmp_pt < 0.0) tmp_pt = 1.0/7000;
696 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_