Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12_3_X] Fix bug in muon index bit computation #38533

Merged
merged 1 commit into from Jul 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions L1Trigger/L1TMuon/plugins/L1TMuonProducer.cc
Expand Up @@ -90,6 +90,8 @@ class L1TMuonProducer : public edm::stream::EDProducer<> {
GMTInternalWedges& wedges,
int bx) const;

int computeMuonIdx(const RegionalMuonCand& mu, int currentLink, int muIdxAuto) const;

void addMuonsToCollections(MicroGMTConfiguration::InterMuonList& coll,
MicroGMTConfiguration::InterMuonList& interout,
std::unique_ptr<MuonBxCollection>& out,
Expand Down Expand Up @@ -487,21 +489,21 @@ void L1TMuonProducer::splitAndConvertMuons(const edm::Handle<MicroGMTConfigurati
}
if (bx < in->getFirstBX() || bx > in->getLastBX())
return;
int muIdx = 0;
int muIdxAuto = 0;
int currentLink = 0;
for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
for (size_t i = 0; i < in->size(bx); ++i, ++muIdxAuto) {
if (in->at(bx, i).hwPt() > 0) {
int link = in->at(bx, i).link();
if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) {
continue; // only process if input link is enabled and not masked
}
if (currentLink != link) {
muIdx = 0;
muIdxAuto = 0;
currentLink = link;
}
int gPhi = MicroGMTConfiguration::calcGlobalPhi(
in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
int tfMuonIdx = 3 * (currentLink - 36) + muIdx;
int tfMuonIdx{computeMuonIdx(in->at(bx, i), currentLink, muIdxAuto)};
std::shared_ptr<GMTInternalMuon> out = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
if (in->at(bx, i).hwEta() > 0) {
out_pos.push_back(out);
Expand Down Expand Up @@ -534,23 +536,21 @@ void L1TMuonProducer::convertMuons(const edm::Handle<MicroGMTConfiguration::Inpu
if (bx < in->getFirstBX() || bx > in->getLastBX()) {
return;
}
int muIdx = 0;
int muIdxAuto = 0;
int currentLink = 0;
for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
for (size_t i = 0; i < in->size(bx); ++i, ++muIdxAuto) {
if (in->at(bx, i).hwPt() > 0) {
int link = in->at(bx, i).link();
if (m_inputsToDisable.test(link) || m_maskedInputs.test(link)) {
continue; // only process if input link is enabled and not masked
}
if (currentLink != link) {
muIdx = 0;
muIdxAuto = 0;
currentLink = link;
}
int gPhi = MicroGMTConfiguration::calcGlobalPhi(
in->at(bx, i).hwPhi(), in->at(bx, i).trackFinderType(), in->at(bx, i).processor());
// If the muon index was set in the data format we should use that. Otherwise we use the value computed from the position in the vector.
int muIdxDF{in->at(bx, i).muIdx()};
int tfMuonIdx{3 * (currentLink - 36) + ((muIdxDF != -1) ? muIdxDF : muIdx)};
int tfMuonIdx{computeMuonIdx(in->at(bx, i), currentLink, muIdxAuto)};
std::shared_ptr<GMTInternalMuon> outMu = std::make_shared<GMTInternalMuon>(in->at(bx, i), gPhi, tfMuonIdx);
out.emplace_back(outMu);
wedges[in->at(bx, i).processor()].push_back(outMu);
Expand All @@ -564,6 +564,15 @@ void L1TMuonProducer::convertMuons(const edm::Handle<MicroGMTConfiguration::Inpu
}
}

int L1TMuonProducer::computeMuonIdx(const RegionalMuonCand& mu, int currentLink, int muIdxAuto) const {
// If the muon index was set in the data format we should use that. Otherwise we use the value computed from the position in the vector.
if (mu.muIdx() != -1) {
return 3 * (currentLink - 36) + mu.muIdx();
} else {
return 3 * (currentLink - 36) + muIdxAuto;
}
}

// ------------ method called when starting to processes a run ------------
void L1TMuonProducer::beginRun(edm::Run const& run, edm::EventSetup const& iSetup) {
edm::ESHandle<L1TMuonGlobalParams> microGMTParamsHandle = iSetup.getHandle(m_microGMTParamsToken);
Expand Down