Skip to content

Commit

Permalink
Merge pull request #38532 from dinyar/fix/muon_idx_bits
Browse files Browse the repository at this point in the history
Fix bug in muon index bit computation
  • Loading branch information
cmsbuild authored Jun 30, 2022
2 parents 3b20114 + 00db3bf commit 24831aa
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions L1Trigger/L1TMuon/plugins/L1TMuonProducer.cc
Original file line number Diff line number Diff line change
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

0 comments on commit 24831aa

Please sign in to comment.