Skip to content

Commit

Permalink
Compute muon index bits using idx from dataformat
Browse files Browse the repository at this point in the history
We currently compute the muon index within the link from the position in
the vector, however this is packed densely and during cosmics the EMTF
always sends muon stubs in third position (even if the second position
is free), causing a mismatch in index bits. Therefore we now assign the
muon index on the link in the uGMT unpacker and use that index if it is
set.
  • Loading branch information
dinyar committed May 22, 2022
1 parent 76b5f38 commit b8f784b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions DataFormats/L1TMuon/interface/RegionalMuonCand.h
Expand Up @@ -53,6 +53,7 @@ namespace l1t {
m_hwSign(0),
m_hwSignValid(0),
m_hwQuality(0),
m_muIdx(-1),
m_dataword(0) {
setTFIdentifiers(0, bmtf);
};
Expand All @@ -67,6 +68,7 @@ namespace l1t {
m_hwSign(sign),
m_hwSignValid(signvalid),
m_hwQuality(quality),
m_muIdx(-1),
m_dataword(0) {
setTFIdentifiers(processor, trackFinder);
// set default track addresses
Expand Down Expand Up @@ -115,6 +117,7 @@ namespace l1t {
m_hwSign(sign),
m_hwSignValid(signvalid),
m_hwQuality(quality),
m_muIdx(-1),
m_trackAddress(trackAddress),
m_dataword(0) {
setTFIdentifiers(processor, trackFinder);
Expand Down Expand Up @@ -144,6 +147,8 @@ namespace l1t {
void setTFIdentifiers(int processor, tftype trackFinder);
// this is left to still be compatible with OMTF
void setLink(int link) { m_link = link; };
// Set the muon index on the link (i.e., 0, 1, or 2)
void setMuIdx(short muIdx) { m_muIdx = muIdx; };
// Set the 64 bit word from two 32 words. bits 0-31->lsbs, bits 32-63->msbs
void setDataword(uint32_t msbs, uint32_t lsbs) { m_dataword = (((uint64_t)msbs) << 32) + lsbs; };
// Set the 64 bit word coming from HW directly
Expand Down Expand Up @@ -177,6 +182,8 @@ namespace l1t {
const int link() const { return m_link; };
/// Get processor ID on which the candidate was found (0..5 for OMTF/EMTF; 0..11 for BMTF)
const int processor() const { return m_processor; };
// Get muon index (i.e., 0, 1, or 2)
const short muIdx() const { return m_muIdx; };
/// Get track-finder which found the muon (bmtf, emtf_pos/emtf_neg or omtf_pos/omtf_neg)
const tftype trackFinderType() const { return m_trackFinder; };
/// Get HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
Expand Down Expand Up @@ -211,6 +218,7 @@ namespace l1t {
int m_hwQuality;
int m_link;
int m_processor;
short m_muIdx;
tftype m_trackFinder;
std::map<int, int> m_trackAddress;

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1TMuon/src/RegionalMuonCand.cc
Expand Up @@ -28,7 +28,7 @@ namespace l1t {
return m_hwPt == rhs.hwPt() && m_hwPtUnconstrained == rhs.hwPtUnconstrained() && m_hwDXY == rhs.hwDXY() &&
m_hwPhi == rhs.hwPhi() && m_hwEta == rhs.hwEta() && m_hwHF == (bool)rhs.hwHF() && m_hwSign == rhs.hwSign() &&
m_hwSignValid == rhs.hwSignValid() && m_hwQuality == rhs.hwQual() && m_link == rhs.link() &&
m_processor == rhs.processor() && m_trackFinder == rhs.trackFinderType() &&
m_muIdx == rhs.muIdx() && m_processor == rhs.processor() && m_trackFinder == rhs.trackFinderType() &&
m_trackAddress == rhs.trackAddress();
}

Expand Down
Expand Up @@ -66,7 +66,7 @@ namespace l1t {
if (startIdx + nWords_ <= payload.size()) {
// Unpacking showers.
// The shower from uGMT is transmitted via four links, each link
// carrying on of the bits of the shower. We therefore have to
// carrying one of the bits of the shower. We therefore have to
// determine which link we're looking at and act accordingly.
// Output links are odd and input links are even.
int link_offset{0}; // This is correct for the uGT unpacker
Expand Down
Expand Up @@ -107,6 +107,7 @@ namespace l1t {
}

RegionalMuonCand mu;
mu.setMuIdx(nWord / 2);

RegionalMuonRawDigiTranslator::fillRegionalMuonCand(
mu, raw_data_00_31, raw_data_32_63, processor, trackFinder, isKbmtf_, useEmtfDisplacementInfo_);
Expand Down
10 changes: 7 additions & 3 deletions L1Trigger/L1TMuon/plugins/L1TMuonProducer.cc
Expand Up @@ -531,8 +531,9 @@ void L1TMuonProducer::convertMuons(const edm::Handle<MicroGMTConfiguration::Inpu
wedges[i] = std::vector<std::shared_ptr<GMTInternalMuon>>();
wedges[i].reserve(3);
}
if (bx < in->getFirstBX() || bx > in->getLastBX())
if (bx < in->getFirstBX() || bx > in->getLastBX()) {
return;
}
int muIdx = 0;
int currentLink = 0;
for (size_t i = 0; i < in->size(bx); ++i, ++muIdx) {
Expand All @@ -547,16 +548,19 @@ void L1TMuonProducer::convertMuons(const edm::Handle<MicroGMTConfiguration::Inpu
}
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;
// 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.
short muIdxDF = in->at(bx, i).muIdx();
int tfMuonIdx = 3 * (currentLink - 36) + ((muIdxDF != -1) ? muIdxDF : muIdx);
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);
}
}
for (int i = 0; i < 12; ++i) {
if (wedges[i].size() > 3)
if (wedges[i].size() > 3) {
edm::LogWarning("Input Mismatch") << " too many inputs per processor for barrel. Wedge " << i << ": Size "
<< wedges[i].size() << std::endl;
}
}
}

Expand Down

0 comments on commit b8f784b

Please sign in to comment.