74 static bool compareMuons(
const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu1,
75 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2);
95 std::unique_ptr<MuonBxCollection>&
out,
145 : m_debugOut(
"test/debug/iso_debug.dat"),
175 m_microGMTParamsToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd, edm::Transition::BeginRun>();
176 m_o2oProtoToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd, edm::Transition::BeginRun>();
179 produces<MuonBxCollection>();
180 produces<MuonBxCollection>(
"imdMuonsBMTF");
181 produces<MuonBxCollection>(
"imdMuonsEMTFPos");
182 produces<MuonBxCollection>(
"imdMuonsEMTFNeg");
183 produces<MuonBxCollection>(
"imdMuonsOMTFPos");
184 produces<MuonBxCollection>(
"imdMuonsOMTFNeg");
278 splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges,
bx);
279 splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges,
bx);
328 for (
const auto&
mu : internalMuons) {
329 if (
mu->hwPt() > 0) {
331 (
mu->hwPt() - 1) * 0.5,
mu->hwEta() * 0.010875,
mu->hwGlobalPhi() * 0.010908, 0.0};
332 int iso =
mu->hwAbsIso() + (
mu->hwRelIso() << 1);
333 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
351 outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
352 outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
353 outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
354 outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
357 int hwPtUnconstrained{
mu->hwPtUnconstrained()};
358 outMu.setPtUnconstrained(hwPtUnconstrained == 0 ? 0
359 : (hwPtUnconstrained - 1) * 0.5);
360 outMu.setHwPtUnconstrained(hwPtUnconstrained);
361 outMu.setHwDXY(
mu->hwDXY());
363 if (
mu->hwSignValid()) {
364 outMu.setCharge(1 - 2 *
mu->hwSign());
368 m_debugOut <<
mu->hwCaloPhi() <<
" " <<
mu->hwCaloEta() << std::endl;
369 outMuons->push_back(
bx, outMu);
383 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2) {
384 return (mu1->hwWins() >= mu2->hwWins());
388 MicroGMTConfiguration::InterMuonList::iterator mu1;
390 for (mu1 =
muons.begin(); mu1 !=
muons.end(); ++mu1) {
391 (*mu1)->setHwWins(0);
395 for (mu1 =
muons.begin(); mu1 !=
muons.end(); ++mu1) {
396 int mu1CancelBit = (*mu1)->hwCancelBit();
397 nCancelled += mu1CancelBit;
400 for (; mu2 !=
muons.end(); ++mu2) {
401 if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
402 if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
403 (*mu1)->increaseWins();
405 (*mu2)->increaseWins();
407 }
else if (mu1CancelBit != 1) {
408 (*mu1)->increaseWins();
409 }
else if ((*mu2)->hwCancelBit() != 1) {
410 (*mu2)->increaseWins();
415 size_t nMuonsBefore =
muons.size();
416 int minWins = nMuonsBefore - nSurvivors;
420 muons.remove_if([&minWins](
auto muon) {
return ((
muon->hwWins() < minWins) || (
muon->hwCancelBit() == 1)); });
425 for (
auto& mu1 :
muons) {
427 mu1->setHwRank(rank);
433 std::unique_ptr<MuonBxCollection>&
out,
435 for (
auto&
mu : coll) {
436 interout.push_back(
mu);
438 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
456 int hwPtUnconstrained{
mu->hwPtUnconstrained()};
457 outMu.setPtUnconstrained(hwPtUnconstrained == 0 ? 0 : (hwPtUnconstrained - 1) * 0.5);
458 outMu.setHwPtUnconstrained(hwPtUnconstrained);
459 outMu.setHwDXY(
mu->hwDXY());
461 if (
mu->hwSignValid()) {
462 outMu.setCharge(1 - 2 *
mu->hwSign());
467 out->push_back(
bx, outMu);
478 for (
int i = 0;
i < 6; ++
i) {
479 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
480 wedges_pos[
i].reserve(3);
481 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
482 wedges_neg[
i].reserve(3);
484 if (bx < in->getFirstBX() ||
bx >
in->getLastBX())
488 for (
size_t i = 0;
i <
in->size(
bx); ++
i, ++muIdx) {
489 if (
in->at(
bx,
i).hwPt() > 0) {
494 if (currentLink !=
link) {
498 int gPhi = MicroGMTConfiguration::calcGlobalPhi(
499 in->at(
bx,
i).hwPhi(),
in->at(
bx,
i).trackFinderType(),
in->at(
bx,
i).processor());
500 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
501 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(
in->at(
bx,
i), gPhi, tfMuonIdx);
502 if (
in->at(
bx,
i).hwEta() > 0) {
503 out_pos.push_back(
out);
504 wedges_pos[
in->at(
bx,
i).processor()].push_back(
out);
506 out_neg.emplace_back(
out);
507 wedges_neg[
in->at(
bx,
i).processor()].push_back(
out);
511 for (
int i = 0;
i < 6; ++
i) {
512 if (wedges_pos[
i].
size() > 3)
513 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf+ / omtf+. Wedge " <<
i <<
": Size "
514 << wedges_pos[
i].size() << std::endl;
515 if (wedges_neg[
i].
size() > 3)
516 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf- / omtf-. Wedge " <<
i <<
": Size "
517 << wedges_neg[
i].size() << std::endl;
526 for (
int i = 0;
i < 12; ++
i) {
527 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
528 wedges[
i].reserve(3);
530 if (bx < in->getFirstBX() ||
bx >
in->getLastBX())
534 for (
size_t i = 0;
i <
in->size(
bx); ++
i, ++muIdx) {
535 if (
in->at(
bx,
i).hwPt() > 0) {
540 if (currentLink !=
link) {
544 int gPhi = MicroGMTConfiguration::calcGlobalPhi(
545 in->at(
bx,
i).hwPhi(),
in->at(
bx,
i).trackFinderType(),
in->at(
bx,
i).processor());
546 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
547 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(
in->at(
bx,
i), gPhi, tfMuonIdx);
548 out.emplace_back(outMu);
549 wedges[
in->at(
bx,
i).processor()].push_back(outMu);
552 for (
int i = 0;
i < 12; ++
i) {
553 if (wedges[
i].
size() > 3)
554 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size "
555 << wedges[
i].size() << std::endl;
563 std::unique_ptr<L1TMuonGlobalParams_PUBLIC> microGMTParams(
565 if (microGMTParams->pnodes_.empty()) {
576 <<
"\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
584 <<
"\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";