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,
169 produces<MuonBxCollection>();
170 produces<MuonBxCollection>(
"imdMuonsBMTF");
171 produces<MuonBxCollection>(
"imdMuonsEMTFPos");
172 produces<MuonBxCollection>(
"imdMuonsEMTFNeg");
173 produces<MuonBxCollection>(
"imdMuonsOMTFPos");
174 produces<MuonBxCollection>(
"imdMuonsOMTFNeg");
276 convertMuons(bmtfMuons, internMuonsBmtf, bmtfWedges, bx);
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 int iso =
mu->hwAbsIso() + (
mu->hwRelIso() << 1);
331 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
332 Muon outMu{vec,
mu->hwPt(),
mu->hwEta(),
mu->hwGlobalPhi(), outMuQual,
mu->hwSign(),
mu->hwSignValid(), iso,
mu->tfMuonIndex(), 0,
true,
mu->hwIsoSum(),
mu->hwDPhi(),
mu->hwDEta(),
mu->hwRank()};
333 if (
mu->hwSignValid()) {
334 outMu.setCharge(1 - 2 *
mu->hwSign());
339 outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
340 outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
341 outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
342 outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
343 m_debugOut <<
mu->hwCaloPhi() <<
" " <<
mu->hwCaloEta() << std::endl;
344 outMuons->push_back(bx, outMu);
351 iEvent.
put(
std::move(imdMuonsEMTFPos),
"imdMuonsEMTFPos");
352 iEvent.
put(
std::move(imdMuonsEMTFNeg),
"imdMuonsEMTFNeg");
353 iEvent.
put(
std::move(imdMuonsOMTFPos),
"imdMuonsOMTFPos");
354 iEvent.
put(
std::move(imdMuonsOMTFNeg),
"imdMuonsOMTFNeg");
360 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2) {
361 return (mu1->hwWins() >= mu2->hwWins());
366 MicroGMTConfiguration::InterMuonList::iterator mu1;
368 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
369 (*mu1)->setHwWins(0);
373 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
374 int mu1CancelBit = (*mu1)->hwCancelBit();
375 nCancelled += mu1CancelBit;
378 for ( ; mu2 != muons.end(); ++mu2) {
379 if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
380 if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
381 (*mu1)->increaseWins();
383 (*mu2)->increaseWins();
385 }
else if (mu1CancelBit != 1) {
386 (*mu1)->increaseWins();
387 }
else if ((*mu2)->hwCancelBit() != 1) {
388 (*mu2)->increaseWins();
393 size_t nMuonsBefore = muons.size();
394 int minWins = nMuonsBefore - nSurvivors;
398 muons.remove_if([&minWins](
auto muon) {
return ((
muon->hwWins() < minWins) || (
muon->hwCancelBit() == 1)); });
407 for (
auto& mu1 : muons) {
409 mu1->setHwRank(rank);
417 std::unique_ptr<MuonBxCollection>&
out,
int bx)
const 419 for (
auto&
mu : coll) {
420 interout.push_back(
mu);
422 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
424 Muon outMu{vec,
mu->hwPt(),
mu->hwEta(),
mu->hwGlobalPhi(), outMuQual,
mu->hwSign(),
mu->hwSignValid(), 0, 0, 0,
true, 0,
mu->hwDPhi(),
mu->hwDEta(),
mu->hwRank()};
425 if (
mu->hwSignValid()) {
426 outMu.setCharge(1 - 2 *
mu->hwSign());
431 out->push_back(bx, outMu);
444 for (
int i = 0;
i < 6; ++
i) {
445 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
446 wedges_pos[
i].reserve(3);
447 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
448 wedges_neg[
i].reserve(3);
450 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
453 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
454 int link = in->
at(bx,
i).
link();
456 if (currentLink != link) {
461 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
462 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
464 out_pos.push_back(out);
467 out_neg.emplace_back(out);
471 for (
int i = 0;
i < 6; ++
i) {
472 if(wedges_pos[
i].
size() > 3)
edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf+ / omtf+. Wedge " <<
i <<
": Size " << wedges_pos[
i].size() << std::endl;
473 if(wedges_neg[
i].
size() > 3)
edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for emtf- / omtf-. Wedge " <<
i <<
": Size " << wedges_neg[
i].size() << std::endl;
483 for (
int i = 0;
i < 12; ++
i) {
484 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
485 wedges[
i].reserve(3);
487 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
490 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
491 int link = in->
at(bx,
i).
link();
493 if (currentLink != link) {
498 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
499 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
500 out.emplace_back(outMu);
503 for (
int i = 0;
i < 12; ++
i) {
504 if(wedges[
i].
size() > 3)
edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size " << wedges[
i].size() << std::endl;
514 microGMTParamsRcd.
get(microGMTParamsHandle);
517 if( microGMTParams->pnodes_.empty() ){
const L1TMuonGlobalParams & cast_to_L1TMuonGlobalParams(const L1TMuonGlobalParams_PUBLIC &x)
void beginRun(edm::Run const &, edm::EventSetup const &) override
T getParameter(std::string const &) const
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.
unsigned size(int bx) const
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
MicroGMTIsolationUnit m_isolationUnit
l1t::cancelmode m_emtfCancelMode
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 get(HolderT &iHolder) const
void sortMuons(MicroGMTConfiguration::InterMuonList &, unsigned) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void endRun(edm::Run const &, edm::EventSetup const &) override
const int hwEta() const
Get compressed eta (returned int * 0.010875 = eta)
GMTInternalMuonList InterMuonList
edm::InputTag m_barrelTfInputTag
const int hwPhi() const
Get compressed local phi (returned int * 2*pi/576 = local phi in rad)
edm::InputTag m_endcapTfInputTag
void produce(edm::Event &, const edm::EventSetup &) override
std::bitset< 12 > m_maskedBmtfInputs
const int link() const
Get link on which the MicroGMT receives the candidate.
const tftype trackFinderType() const
Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg) ...
BXVector< Muon > MuonBxCollection
const int processor() const
Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF) ...
void setCancelOutBits(GMTInternalWedges &, tftype, cancelmode)
Cancel out between sectors/wedges in one track finder.
~L1TMuonProducer() override
void addMuonsToCollections(MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::unique_ptr< MuonBxCollection > &out, int bx) 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)
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
L1TMuonProducer(const edm::ParameterSet &)
std::bitset< 12 > m_omtfInputsToDisable
MicroGMTCancelOutUnit m_cancelOutUnit
void initialise(L1TMuonGlobalParamsHelper *)
Initialisation from ES record.
edm::InputTag m_trigTowerTag
void isolatePreSummed(MicroGMTConfiguration::InterMuonList &muons) const
T const * product() const
std::bitset< 28 > m_maskedCaloInputs
const T & at(int bx, unsigned i) const