71 static bool compareMuons(
const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu1,
72 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2);
94 std::unique_ptr<MuonBxCollection>&
out,
144 : m_debugOut(
"test/debug/iso_debug.dat"),
174 m_microGMTParamsToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsRcd, edm::Transition::BeginRun>();
175 m_o2oProtoToken = esConsumes<L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd, edm::Transition::BeginRun>();
178 produces<MuonBxCollection>();
179 produces<MuonBxCollection>(
"imdMuonsBMTF");
180 produces<MuonBxCollection>(
"imdMuonsEMTFPos");
181 produces<MuonBxCollection>(
"imdMuonsEMTFNeg");
182 produces<MuonBxCollection>(
"imdMuonsOMTFPos");
183 produces<MuonBxCollection>(
"imdMuonsOMTFNeg");
277 splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges,
bx);
278 splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges,
bx);
327 for (
const auto&
mu : internalMuons) {
328 if (
mu->hwPt() > 0) {
330 (
mu->hwPt() - 1) * 0.5,
mu->hwEta() * 0.010875,
mu->hwGlobalPhi() * 0.010908, 0.0};
331 int iso =
mu->hwAbsIso() + (
mu->hwRelIso() << 1);
332 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
350 outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
351 outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
352 outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
353 outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
357 outMu.setPtUnconstrained(
362 outMu.setHwDXY(
mu->hwDXY());
364 if (
mu->hwSignValid()) {
365 outMu.setCharge(1 - 2 *
mu->hwSign());
369 m_debugOut <<
mu->hwCaloPhi() <<
" " <<
mu->hwCaloEta() << std::endl;
370 outMuons->push_back(
bx, outMu);
384 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2) {
385 return (mu1->hwWins() >= mu2->hwWins());
389 MicroGMTConfiguration::InterMuonList::iterator mu1;
391 for (mu1 =
muons.begin(); mu1 !=
muons.end(); ++mu1) {
392 (*mu1)->setHwWins(0);
395 for (mu1 =
muons.begin(); mu1 !=
muons.end(); ++mu1) {
396 int mu1CancelBit = (*mu1)->hwCancelBit();
399 for (; mu2 !=
muons.end(); ++mu2) {
400 if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
401 if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
402 (*mu1)->increaseWins();
404 (*mu2)->increaseWins();
406 }
else if (mu1CancelBit != 1) {
407 (*mu1)->increaseWins();
408 }
else if ((*mu2)->hwCancelBit() != 1) {
409 (*mu2)->increaseWins();
414 size_t nMuonsBefore =
muons.size();
415 int minWins = nMuonsBefore - nSurvivors;
419 muons.remove_if([&minWins](
auto muon) {
return ((
muon->hwWins() < minWins) || (
muon->hwCancelBit() == 1)); });
424 for (
auto& mu1 :
muons) {
426 mu1->setHwRank(rank);
432 std::unique_ptr<MuonBxCollection>&
out,
434 for (
auto&
mu : coll) {
435 interout.push_back(
mu);
437 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
460 outMu.setHwDXY(
mu->hwDXY());
462 if (
mu->hwSignValid()) {
463 outMu.setCharge(1 - 2 *
mu->hwSign());
468 out->push_back(
bx, outMu);
479 for (
int i = 0;
i < 6; ++
i) {
480 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
481 wedges_pos[
i].reserve(3);
482 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
483 wedges_neg[
i].reserve(3);
485 if (bx < in->getFirstBX() ||
bx >
in->getLastBX())
489 for (
size_t i = 0;
i <
in->size(
bx); ++
i, ++muIdxAuto) {
490 if (
in->at(
bx,
i).hwPt() > 0) {
491 int link =
in->at(
bx,
i).link();
495 if (currentLink != link) {
499 int gPhi = MicroGMTConfiguration::calcGlobalPhi(
500 in->at(
bx,
i).hwPhi(),
in->at(
bx,
i).trackFinderType(),
in->at(
bx,
i).processor());
502 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(
in->at(
bx,
i), gPhi, tfMuonIdx);
503 if (
in->at(
bx,
i).hwEta() > 0) {
504 out_pos.push_back(
out);
505 wedges_pos[
in->at(
bx,
i).processor()].push_back(
out);
507 out_neg.emplace_back(
out);
508 wedges_neg[
in->at(
bx,
i).processor()].push_back(
out);
512 for (
int i = 0;
i < 6; ++
i) {
513 if (wedges_pos[
i].
size() > 3)
514 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf+ / omtf+. Wedge " <<
i <<
": Size " 515 << wedges_pos[
i].size() << std::endl;
516 if (wedges_neg[
i].
size() > 3)
517 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf- / omtf-. Wedge " <<
i <<
": Size " 518 << wedges_neg[
i].size() << std::endl;
527 for (
int i = 0;
i < 12; ++
i) {
528 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
529 wedges[
i].reserve(3);
531 if (bx < in->getFirstBX() ||
bx >
in->getLastBX()) {
536 for (
size_t i = 0;
i <
in->size(
bx); ++
i, ++muIdxAuto) {
537 if (
in->at(
bx,
i).hwPt() > 0) {
538 int link =
in->at(
bx,
i).link();
542 if (currentLink != link) {
546 int gPhi = MicroGMTConfiguration::calcGlobalPhi(
547 in->at(
bx,
i).hwPhi(),
in->at(
bx,
i).trackFinderType(),
in->at(
bx,
i).processor());
549 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(
in->at(
bx,
i), gPhi, tfMuonIdx);
550 out.emplace_back(outMu);
551 wedges[
in->at(
bx,
i).processor()].push_back(outMu);
554 for (
int i = 0;
i < 12; ++
i) {
555 if (wedges[
i].
size() > 3) {
556 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size " 557 << wedges[
i].size() << std::endl;
564 if (
mu.muIdx() != -1) {
565 return 3 * (currentLink - 36) +
mu.muIdx();
567 return 3 * (currentLink - 36) + muIdxAuto;
575 std::unique_ptr<L1TMuonGlobalParams_PUBLIC> microGMTParams(
577 if (microGMTParams->pnodes_.empty()) {
588 <<
"\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
596 <<
"\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
const L1TMuonGlobalParams & cast_to_L1TMuonGlobalParams(const L1TMuonGlobalParams_PUBLIC &x)
Log< level::Info, true > LogVerbatim
void beginRun(edm::Run const &, edm::EventSetup const &) override
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
void setCancelOutBitsOverlapBarrel(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and barrel track finders.
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_endcapTfInputToken
std::unique_ptr< L1TMuonGlobalParamsHelper > microGMTParamsHelper
std::bitset< 12 > m_bmtfInputsToDisable
void convertMuons(edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out, GMTInternalWedges &wedges, int bx) const
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
int computeMuonIdx(const RegionalMuonCand &mu, int currentLink, int muIdxAuto) const
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_overlapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollection > m_caloTowerInputToken
MicroGMTIsolationUnit m_isolationUnit
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
l1t::cancelmode m_emtfCancelMode
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd > m_o2oProtoToken
void calculateRank(MicroGMTConfiguration::InterMuonList &muons) const
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankPtQualityLUT
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
void sortMuons(MicroGMTConfiguration::InterMuonList &, unsigned) const
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
static ReturnType create(const std::string &filename, const int fwVersion, const unsigned ptFactor, const unsigned qualFactor)
edm::InputTag m_overlapTfInputTag
std::bitset< 12 > m_emtfInputsToDisable
T const * product() const
void addDefault(ParameterSetDescription const &psetDescription)
void addMuonsToCollections(MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::unique_ptr< MuonBxCollection > &out, int bx) const
#define DEFINE_FWK_MODULE(type)
void splitAndConvertMuons(edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out_pos, MicroGMTConfiguration::InterMuonList &out_neg, GMTInternalWedges &wedges_pos, GMTInternalWedges &wedges_neg, int bx) const
GMTInternalMuonList InterMuonList
edm::InputTag m_barrelTfInputTag
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
edm::InputTag m_endcapTfInputTag
void produce(edm::Event &, const edm::EventSetup &) override
std::bitset< 12 > m_maskedBmtfInputs
BXVector< Muon > MuonBxCollection
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~L1TMuonProducer() override
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsRcd > m_microGMTParamsToken
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
std::bitset< 12 > m_maskedEmtfInputs
const L1TMuonGlobalParams_PUBLIC & cast_to_L1TMuonGlobalParams_PUBLIC(const L1TMuonGlobalParams &x)
l1t::cancelmode m_bmtfCancelMode
static bool compareMuons(const std::shared_ptr< MicroGMTConfiguration::InterMuon > &mu1, const std::shared_ptr< MicroGMTConfiguration::InterMuon > &mu2)
std::map< int, std::vector< std::shared_ptr< GMTInternalMuon > > > GMTInternalWedges
std::bitset< 72 > m_maskedInputs
std::bitset< 12 > m_maskedOmtfInputs
std::bitset< 72 > m_inputsToDisable
std::bitset< 28 > m_caloInputsToDisable
L1TMuonProducer(const edm::ParameterSet &)
std::bitset< 12 > m_omtfInputsToDisable
Log< level::Warning, false > LogWarning
MicroGMTCancelOutUnit m_cancelOutUnit
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
edm::InputTag m_trigTowerTag
std::bitset< 28 > m_maskedCaloInputs