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,
162 produces<MuonBxCollection>();
163 produces<MuonBxCollection>(
"imdMuonsBMTF");
164 produces<MuonBxCollection>(
"imdMuonsEMTFPos");
165 produces<MuonBxCollection>(
"imdMuonsEMTFNeg");
166 produces<MuonBxCollection>(
"imdMuonsOMTFPos");
167 produces<MuonBxCollection>(
"imdMuonsOMTFNeg");
269 convertMuons(bmtfMuons, internMuonsBmtf, bmtfWedges, bx);
270 splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges, bx);
271 splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges, bx);
321 for (
const auto&
mu : internalMuons) {
322 if (
mu->hwPt() > 0) {
324 int iso =
mu->hwAbsIso() + (
mu->hwRelIso() << 1);
325 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
326 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()};
327 if (
mu->hwSignValid()) {
328 outMu.setCharge(1 - 2 *
mu->hwSign());
333 outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
334 outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
335 outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
336 outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
337 m_debugOut <<
mu->hwCaloPhi() <<
" " <<
mu->hwCaloEta() << std::endl;
338 outMuons->push_back(bx, outMu);
345 iEvent.
put(
std::move(imdMuonsEMTFPos),
"imdMuonsEMTFPos");
346 iEvent.
put(
std::move(imdMuonsEMTFNeg),
"imdMuonsEMTFNeg");
347 iEvent.
put(
std::move(imdMuonsOMTFPos),
"imdMuonsOMTFPos");
348 iEvent.
put(
std::move(imdMuonsOMTFNeg),
"imdMuonsOMTFNeg");
354 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2) {
355 return (mu1->hwWins() >= mu2->hwWins());
360 MicroGMTConfiguration::InterMuonList::iterator mu1;
362 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
363 (*mu1)->setHwWins(0);
367 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
368 int mu1CancelBit = (*mu1)->hwCancelBit();
369 nCancelled += mu1CancelBit;
372 for ( ; mu2 != muons.end(); ++mu2) {
373 if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
374 if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
375 (*mu1)->increaseWins();
377 (*mu2)->increaseWins();
379 }
else if (mu1CancelBit != 1) {
380 (*mu1)->increaseWins();
381 }
else if ((*mu2)->hwCancelBit() != 1) {
382 (*mu2)->increaseWins();
387 size_t nMuonsBefore = muons.size();
388 int minWins = nMuonsBefore - nSurvivors;
392 muons.remove_if([&minWins](
auto muon) {
return ((
muon->hwWins() < minWins) || (
muon->hwCancelBit() == 1)); });
401 for (
auto& mu1 : muons) {
403 mu1->setHwRank(rank);
411 std::unique_ptr<MuonBxCollection>&
out,
int bx)
const 413 for (
auto&
mu : coll) {
414 interout.push_back(
mu);
416 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
418 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()};
419 if (
mu->hwSignValid()) {
420 outMu.setCharge(1 - 2 *
mu->hwSign());
425 out->push_back(bx, outMu);
438 for (
int i = 0;
i < 6; ++
i) {
439 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
440 wedges_pos[
i].reserve(3);
441 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
442 wedges_neg[
i].reserve(3);
444 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
447 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
448 int link = in->
at(bx,
i).
link();
450 if (currentLink != link) {
455 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
456 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
458 out_pos.push_back(out);
461 out_neg.emplace_back(out);
465 for (
int i = 0;
i < 6; ++
i) {
466 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;
467 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;
477 for (
int i = 0;
i < 12; ++
i) {
478 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
479 wedges[
i].reserve(3);
481 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
484 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
485 int link = in->
at(bx,
i).
link();
487 if (currentLink != link) {
492 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
493 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
494 out.emplace_back(outMu);
497 for (
int i = 0;
i < 12; ++
i) {
498 if(wedges[
i].
size() > 3)
edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size " << wedges[
i].size() << std::endl;
508 microGMTParamsRcd.
get(microGMTParamsHandle);
511 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
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
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