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());
418 Muon outMu{vec,
mu->hwPt(),
mu->hwEta(),
mu->hwGlobalPhi(), outMuQual,
mu->hwSign(),
mu->hwSignValid(), -1,
mu->tfMuonIndex(), 0,
true, -1,
mu->hwDPhi(),
mu->hwDEta(),
mu->hwRank()};
419 if (
mu->hwSignValid()) {
420 outMu.setCharge(1 - 2 *
mu->hwSign());
425 outMu.setHwEtaAtVtx(outMu.hwEta());
426 outMu.setHwPhiAtVtx(outMu.hwPhi());
427 outMu.setEtaAtVtx(outMu.eta());
428 outMu.setPhiAtVtx(outMu.phi());
430 out->push_back(bx, outMu);
443 for (
int i = 0;
i < 6; ++
i) {
444 wedges_pos[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
445 wedges_pos[
i].reserve(3);
446 wedges_neg[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
447 wedges_neg[
i].reserve(3);
449 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
452 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
453 int link = in->
at(bx,
i).
link();
455 if (currentLink != link) {
460 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
461 std::shared_ptr<GMTInternalMuon>
out = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
463 out_pos.push_back(out);
466 out_neg.emplace_back(out);
470 for (
int i = 0;
i < 6; ++
i) {
471 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;
472 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;
482 for (
int i = 0;
i < 12; ++
i) {
483 wedges[
i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
484 wedges[
i].reserve(3);
486 if (bx < in->getFirstBX() || bx > in->
getLastBX())
return;
489 for (
size_t i = 0;
i < in->
size(bx); ++
i, ++muIdx) {
490 int link = in->
at(bx,
i).
link();
492 if (currentLink != link) {
497 int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
498 std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->
at(bx,
i), gPhi, tfMuonIdx);
499 out.emplace_back(outMu);
502 for (
int i = 0;
i < 12; ++
i) {
503 if(wedges[
i].
size() > 3)
edm::LogWarning(
"Input Mismatch") <<
" too many inputs per processor for barrel. Wedge " <<
i <<
": Size " << wedges[
i].size() << std::endl;
524 microGMTParamsRcd.
get(microGMTParamsHandle);
528 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