68 virtual void endJob() ;
75 static bool compareMuons(
const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu1,
76 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2);
96 std::unique_ptr<MuonBxCollection>& out,
163 produces<MuonBxCollection>();
164 produces<MuonBxCollection>(
"imdMuonsBMTF");
165 produces<MuonBxCollection>(
"imdMuonsEMTFPos");
166 produces<MuonBxCollection>(
"imdMuonsEMTFNeg");
167 produces<MuonBxCollection>(
"imdMuonsOMTFPos");
168 produces<MuonBxCollection>(
"imdMuonsOMTFNeg");
270 convertMuons(bmtfMuons, internMuonsBmtf, bmtfWedges, bx);
271 splitAndConvertMuons(emtfMuons, internMuonsEmtfPos, internMuonsEmtfNeg, emtfPosWedges, emtfNegWedges, bx);
272 splitAndConvertMuons(omtfMuons, internMuonsOmtfPos, internMuonsOmtfNeg, omtfPosWedges, omtfNegWedges, bx);
322 for (
const auto&
mu : internalMuons) {
323 if (
mu->hwPt() > 0) {
325 int iso =
mu->hwAbsIso() + (
mu->hwRelIso() << 1);
326 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
327 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()};
328 if (
mu->hwSignValid()) {
329 outMu.setCharge(1 - 2 *
mu->hwSign());
334 outMu.setHwEtaAtVtx(MicroGMTConfiguration::calcMuonHwEtaExtra(outMu));
335 outMu.setHwPhiAtVtx(MicroGMTConfiguration::calcMuonHwPhiExtra(outMu));
336 outMu.setEtaAtVtx(MicroGMTConfiguration::calcMuonEtaExtra(outMu));
337 outMu.setPhiAtVtx(MicroGMTConfiguration::calcMuonPhiExtra(outMu));
338 m_debugOut <<
mu->hwCaloPhi() <<
" " <<
mu->hwCaloEta() << std::endl;
339 outMuons->push_back(bx, outMu);
346 iEvent.
put(
std::move(imdMuonsEMTFPos),
"imdMuonsEMTFPos");
347 iEvent.
put(
std::move(imdMuonsEMTFNeg),
"imdMuonsEMTFNeg");
348 iEvent.
put(
std::move(imdMuonsOMTFPos),
"imdMuonsOMTFPos");
349 iEvent.
put(
std::move(imdMuonsOMTFNeg),
"imdMuonsOMTFNeg");
355 const std::shared_ptr<MicroGMTConfiguration::InterMuon>& mu2) {
356 return (mu1->hwWins() >= mu2->hwWins());
361 MicroGMTConfiguration::InterMuonList::iterator mu1;
363 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
364 (*mu1)->setHwWins(0);
368 for (mu1 = muons.begin(); mu1 != muons.end(); ++mu1) {
369 int mu1CancelBit = (*mu1)->hwCancelBit();
370 nCancelled += mu1CancelBit;
373 for ( ; mu2 != muons.end(); ++mu2) {
374 if (mu1CancelBit != 1 && (*mu2)->hwCancelBit() != 1) {
375 if ((*mu1)->hwRank() >= (*mu2)->hwRank()) {
376 (*mu1)->increaseWins();
378 (*mu2)->increaseWins();
380 }
else if (mu1CancelBit != 1) {
381 (*mu1)->increaseWins();
382 }
else if ((*mu2)->hwCancelBit() != 1) {
383 (*mu2)->increaseWins();
388 size_t nMuonsBefore = muons.size();
389 int minWins = nMuonsBefore - nSurvivors;
393 muons.remove_if([&minWins](
auto muon) {
return ((
muon->hwWins() < minWins) || (
muon->hwCancelBit() == 1)); });
402 for (
auto& mu1 : muons) {
404 mu1->setHwRank(rank);
412 std::unique_ptr<MuonBxCollection>&
out,
int bx)
const 414 for (
auto&
mu : coll) {
415 interout.push_back(
mu);
417 int outMuQual = MicroGMTConfiguration::setOutputMuonQuality(
mu->hwQual(),
mu->trackFinderType(),
mu->hwHF());
419 Muon outMu{vec,
mu->hwPt(),
mu->hwEta(),
mu->hwGlobalPhi(), outMuQual,
mu->hwSign(),
mu->hwSignValid(), -1, 0, 0,
true, 0,
mu->hwDPhi(),
mu->hwDEta(),
mu->hwRank()};
420 if (
mu->hwSignValid()) {
421 outMu.setCharge(1 - 2 *
mu->hwSign());
426 out->push_back(bx, outMu);
439 for (
int i = 0;
i < 6; ++
i) {
440 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
441 wedges_pos[
i].reserve(3);
442 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
443 wedges_neg[
i].reserve(3);
445 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
448 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
449 int link = in->
at(bx,
i).
link();
451 if (currentLink != link) {
456 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
457 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
459 out_pos.push_back(out);
462 out_neg.emplace_back(out);
466 for (
int i = 0;
i < 6; ++
i) {
467 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;
468 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;
478 for (
int i = 0;
i < 12; ++
i) {
479 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
480 wedges[
i].reserve(3);
482 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
485 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
486 int link = in->
at(bx,
i).
link();
488 if (currentLink != link) {
493 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
494 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
495 out.emplace_back(outMu);
498 for (
int i = 0;
i < 12; ++
i) {
499 if(wedges[
i].
size() > 3)
edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size " << wedges[
i].size() << std::endl;
520 microGMTParamsRcd.
get(microGMTParamsHandle);
524 edm::LogError(
"L1TMuonProducer") <<
"Could not retrieve parameters from Event Setup" << std::endl;
T getParameter(std::string const &) const
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
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
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
virtual void endRun(edm::Run const &, edm::EventSetup const &)
virtual void produce(edm::Event &, const edm::EventSetup &)
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
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
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
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.
void addMuonsToCollections(MicroGMTConfiguration::InterMuonList &coll, MicroGMTConfiguration::InterMuonList &interout, std::unique_ptr< MuonBxCollection > &out, int bx) const
edm::EDGetTokenT< MicroGMTConfiguration::InputCollection > m_barrelTfInputToken
std::bitset< 12 > m_maskedEmtfInputs
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
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
std::bitset< 28 > m_maskedCaloInputs
const T & at(int bx, unsigned i) const