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"),
162 if (!m_autoCancelMode) {
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");
219 bxMin =
std::max(bxMin, trigTowers->getFirstBX());
220 bxMax =
std::min(bxMax, trigTowers->getLastBX());
223 bxMin =
std::max(bxMin, bmtfMuons->getFirstBX());
224 bxMax =
std::min(bxMax, bmtfMuons->getLastBX());
227 bxMin =
std::max(bxMin, omtfMuons->getFirstBX());
228 bxMax =
std::min(bxMax, omtfMuons->getLastBX());
231 bxMin =
std::max(bxMin, emtfMuons->getFirstBX());
232 bxMax =
std::min(bxMax, emtfMuons->getLastBX());
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(
359 hwPtUnconstrained == 0
361 : (hwPtUnconstrained - 1));
362 outMu.setHwPtUnconstrained(hwPtUnconstrained);
363 outMu.setHwDXY(
mu->hwDXY());
365 if (
mu->hwSignValid()) {
366 outMu.setCharge(1 - 2 *
mu->hwSign());
370 m_debugOut <<
mu->hwCaloPhi() <<
" " <<
mu->hwCaloEta() << std::endl;
371 outMuons->push_back(
bx, outMu);
378 iEvent.
put(
std::move(imdMuonsEMTFPos),
"imdMuonsEMTFPos");
379 iEvent.
put(
std::move(imdMuonsEMTFNeg),
"imdMuonsEMTFNeg");
380 iEvent.
put(
std::move(imdMuonsOMTFPos),
"imdMuonsOMTFPos");
381 iEvent.
put(
std::move(imdMuonsOMTFNeg),
"imdMuonsOMTFNeg");
385 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2) {
386 return (mu1->hwWins() >= mu2->hwWins());
390 MicroGMTConfiguration::InterMuonList::iterator mu1;
392 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
393 (*mu1)->setHwWins(0);
397 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
398 int mu1CancelBit = (*mu1)->hwCancelBit();
399 nCancelled += mu1CancelBit;
402 for (; mu2 != muons.end(); ++mu2) {
403 if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
404 if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
405 (*mu1)->increaseWins();
407 (*mu2)->increaseWins();
409 }
else if (mu1CancelBit != 1) {
410 (*mu1)->increaseWins();
411 }
else if ((*mu2)->hwCancelBit() != 1) {
412 (*mu2)->increaseWins();
417 size_t nMuonsBefore = muons.size();
418 int minWins = nMuonsBefore - nSurvivors;
422 muons.remove_if([&minWins](
auto muon) {
return ((
muon->hwWins() < minWins) || (
muon->hwCancelBit() == 1)); });
427 for (
auto& mu1 : muons) {
429 mu1->setHwRank(rank);
435 std::unique_ptr<MuonBxCollection>&
out,
437 for (
auto&
mu : coll) {
438 interout.push_back(
mu);
440 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
458 int hwPtUnconstrained{
mu->hwPtUnconstrained()};
459 outMu.setPtUnconstrained(hwPtUnconstrained == 0
461 : (hwPtUnconstrained - 1));
462 outMu.setHwPtUnconstrained(hwPtUnconstrained);
463 outMu.setHwDXY(
mu->hwDXY());
465 if (
mu->hwSignValid()) {
466 outMu.setCharge(1 - 2 *
mu->hwSign());
471 out->push_back(bx, outMu);
482 for (
int i = 0;
i < 6; ++
i) {
483 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
484 wedges_pos[
i].reserve(3);
485 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
486 wedges_neg[
i].reserve(3);
488 if (bx < in->getFirstBX() || bx > in->getLastBX())
492 for (
size_t i = 0;
i < in->size(bx); ++
i, ++muIdx) {
493 if (in->at(bx,
i).hwPt() > 0) {
494 int link = in->at(bx,
i).link();
498 if (currentLink != link) {
502 int gPhi = MicroGMTConfiguration::calcGlobalPhi(
503 in->at(bx,
i).hwPhi(), in->at(bx,
i).trackFinderType(), in->at(bx,
i).processor());
504 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
505 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(in->at(bx,
i), gPhi, tfMuonIdx);
506 if (in->at(bx,
i).hwEta() > 0) {
507 out_pos.push_back(out);
508 wedges_pos[in->at(bx,
i).processor()].push_back(out);
510 out_neg.emplace_back(out);
511 wedges_neg[in->at(bx,
i).processor()].push_back(out);
515 for (
int i = 0;
i < 6; ++
i) {
516 if (wedges_pos[
i].
size() > 3)
517 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf+ / omtf+. Wedge " <<
i <<
": Size "
518 << wedges_pos[
i].size() << std::endl;
519 if (wedges_neg[
i].
size() > 3)
520 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf- / omtf-. Wedge " <<
i <<
": Size "
521 << wedges_neg[
i].size() << std::endl;
530 for (
int i = 0;
i < 12; ++
i) {
531 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
532 wedges[
i].reserve(3);
534 if (bx < in->getFirstBX() || bx > in->getLastBX())
538 for (
size_t i = 0;
i < in->size(bx); ++
i, ++muIdx) {
539 if (in->at(bx,
i).hwPt() > 0) {
540 int link = in->at(bx,
i).link();
544 if (currentLink != link) {
548 int gPhi = MicroGMTConfiguration::calcGlobalPhi(
549 in->at(bx,
i).hwPhi(), in->at(bx,
i).trackFinderType(), in->at(bx,
i).processor());
550 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
551 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->at(bx,
i), gPhi, tfMuonIdx);
552 out.emplace_back(outMu);
553 wedges[in->at(bx,
i).processor()].push_back(outMu);
556 for (
int i = 0;
i < 12; ++
i) {
557 if (wedges[
i].
size() > 3)
558 edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size "
559 << wedges[
i].size() << std::endl;
567 std::unique_ptr<L1TMuonGlobalParams_PUBLIC> microGMTParams(
569 if (microGMTParams->pnodes_.empty()) {
580 <<
"\n EMTF-|OMTF-| BMTF |OMTF+|EMTF+| CALO | res 0";
588 <<
"\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 endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void extrapolateMuons(MicroGMTConfiguration::InterMuonList &) const
void setCancelOutBitsOverlapEndcap(GMTInternalWedges &, GMTInternalWedges &, cancelmode)
Cancel-out between overlap and endcap track finders.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
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
void convertMuons(edm::Handle< MicroGMTConfiguration::InputCollection > const &in, MicroGMTConfiguration::InterMuonList &out, GMTInternalWedges &wedges, int bx) const
std::bitset< 12 > m_bmtfInputsToDisable
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setTowerSums(const MicroGMTConfiguration::CaloInputCollection &inputs, int bx)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_overlapTfInputToken
edm::EDGetTokenT< MicroGMTConfiguration::CaloInputCollection > m_caloTowerInputToken
auto const & tracks
cannot be loose
MicroGMTIsolationUnit m_isolationUnit
l1t::cancelmode m_emtfCancelMode
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsO2ORcd > m_o2oProtoToken
std::shared_ptr< MicroGMTRankPtQualLUT > m_rankPtQualityLUT
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
void addDefault(ParameterSetDescription const &psetDescription)
void calculateRank(MicroGMTConfiguration::InterMuonList &muons) const
void sortMuons(MicroGMTConfiguration::InterMuonList &, unsigned) const
void endRun(edm::Run const &, edm::EventSetup const &) override
GMTInternalMuonList InterMuonList
edm::InputTag m_barrelTfInputTag
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
void addMuonsToCollections(MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::unique_ptr< MuonBxCollection > &out, int bx) const
edm::ESGetToken< L1TMuonGlobalParams, L1TMuonGlobalParamsRcd > m_microGMTParamsToken
T const * product() const
T getParameter(std::string const &) const
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
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)
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
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
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
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
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
tuple size
Write out results.
std::bitset< 28 > m_maskedCaloInputs