Skip to content

Commit

Permalink
Unpack displaced pT from OMTF at the uGMT inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dinyar committed Mar 31, 2024
1 parent 426ee1c commit 7b2ef4d
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace l1t {
for (auto imu = muons->begin(); imu != muons->end(); imu++) {
if (imu->processor() + 1 == board_id) {
uint32_t firstWord(0), lastWord(0);
RegionalMuonRawDigiTranslator::generatePackedDataWords(*imu, firstWord, lastWord, isKalman_, false);
RegionalMuonRawDigiTranslator::generatePackedDataWords(*imu, firstWord, lastWord, isKalman_, false, false);
payloadMap_[bmtfBlockID].push_back(firstWord); //imu->link()*2+1
payloadMap_[bmtfBlockID].push_back(lastWord); //imu->link()*2+1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace l1t {

RegionalMuonCand muCand;
RegionalMuonRawDigiTranslator::fillRegionalMuonCand(
muCand, raw_first, raw_secnd, processor, tftype::bmtf, isKalman, false);
muCand, raw_first, raw_secnd, processor, tftype::bmtf, isKalman, false, false);

if (muCand.hwPt() == 0) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace l1t {
if (fed == 1402) {
auto gmt_in_packer = static_pointer_cast<l1t::stage2::RegionalMuonGMTPacker>(
PackerFactory::get()->make("stage2::RegionalMuonGMTPacker"));
if (fw >= 0x8010000) {
gmt_in_packer->setUseOmtfDisplacementInfo();
}
if (fw >= 0x8000000) {
gmt_in_packer->setUseEmtfLooseShowers();
}
Expand Down Expand Up @@ -103,6 +106,9 @@ namespace l1t {
// input muons on links 36-71
auto gmt_in_unp = static_pointer_cast<l1t::stage2::RegionalMuonGMTUnpacker>(
UnpackerFactory::get()->make("stage2::RegionalMuonGMTUnpacker"));
if (fw >= 0x8010000) {
gmt_in_unp->setUseEmtfDisplacementInfo();
}
if (fw >= 0x8000000) {
gmt_in_unp->setUseEmtfLooseShowers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ namespace l1t {
uint32_t msw{0};
uint32_t lsw{0};

RegionalMuonRawDigiTranslator::generatePackedDataWords(mu, lsw, msw, isKbmtf_, useEmtfDisplacementInfo_);
RegionalMuonRawDigiTranslator::generatePackedDataWords(
mu, lsw, msw, isKbmtf_, useOmtfDisplacementInfo_, useEmtfDisplacementInfo_);

buf.at(frameIdx++) = lsw;
buf.at(frameIdx++) = msw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace l1t {
public:
Blocks pack(const edm::Event&, const PackerTokens*) override;
void setIsKbmtf() { isKbmtf_ = true; };
void setUseOmtfDisplacementInfo() { useOmtfDisplacementInfo_ = true; };
void setUseEmtfDisplacementInfo() { useEmtfDisplacementInfo_ = true; };
void setUseEmtfNominalTightShowers() { useEmtfNominalTightShowers_ = true; };
void setUseEmtfLooseShowers() { useEmtfLooseShowers_ = true; };
Expand Down Expand Up @@ -42,6 +43,7 @@ namespace l1t {
static constexpr size_t wordsPerBx_ = 6; // number of 32 bit words per BX

bool isKbmtf_{false};
bool useOmtfDisplacementInfo_{false};
bool useEmtfDisplacementInfo_{false};
bool useEmtfNominalTightShowers_{false};
bool useEmtfLooseShowers_{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,14 @@ namespace l1t {
RegionalMuonCand mu;
mu.setMuIdx(nWord / 2);

RegionalMuonRawDigiTranslator::fillRegionalMuonCand(
mu, raw_data_00_31, raw_data_32_63, processor, trackFinder, isKbmtf_, useEmtfDisplacementInfo_);
RegionalMuonRawDigiTranslator::fillRegionalMuonCand(mu,
raw_data_00_31,
raw_data_32_63,
processor,
trackFinder,
isKbmtf_,
useOmtfDisplacementInfo_,
useEmtfDisplacementInfo_);

LogDebug("L1T") << "Mu" << nWord / 2 << ": eta " << mu.hwEta() << " phi " << mu.hwPhi() << " pT "
<< mu.hwPt() << " qual " << mu.hwQual() << " sign " << mu.hwSign() << " sign valid "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace l1t {
public:
bool unpack(const Block& block, UnpackerCollections* coll) override;
void setIsKbmtf() { isKbmtf_ = true; }
void setUseOmtfDisplacementInfo() { useOmtfDisplacementInfo_ = true; }
void setUseEmtfDisplacementInfo() { useEmtfDisplacementInfo_ = true; }
void setUseEmtfNominalTightShowers() { useEmtfNominalTightShowers_ = true; }
void setUseEmtfLooseShowers() { useEmtfLooseShowers_ = true; }
Expand All @@ -20,6 +21,7 @@ namespace l1t {
static constexpr unsigned bxzs_enable_shift_ = 1;

bool isKbmtf_{false};
bool useOmtfDisplacementInfo_{false};
bool useEmtfDisplacementInfo_{false};
bool useEmtfNominalTightShowers_{false};
bool useEmtfLooseShowers_{false};
Expand Down
19 changes: 15 additions & 4 deletions L1Trigger/L1TMuon/interface/RegionalMuonRawDigiTranslator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ namespace l1t {
int proc,
tftype tf,
bool isKbmtf,
bool useOmtfDisplacementInfo,
bool useEmtfDisplacementInfo);
static void fillRegionalMuonCand(RegionalMuonCand& mu,
uint64_t dataword,
int proc,
tftype tf,
bool isKbmtf,
bool useOmtfDisplacementInfo,
bool useEmtfDisplacementInfo);
static void fillRegionalMuonCand(
RegionalMuonCand& mu, uint64_t dataword, int proc, tftype tf, bool isKbmtf, bool useEmtfDisplacementInfo);
static bool fillRegionalMuonShower(RegionalMuonShower& muShower,
std::vector<uint32_t> bxPayload,
int proc,
Expand All @@ -26,13 +32,17 @@ namespace l1t {
uint32_t& raw_data_00_31,
uint32_t& raw_data_32_63,
bool isKbmtf,
bool useOmtfDisplacementInfo,
bool useEmtfDisplacementInfo);
static void generatePackedShowerPayload(const RegionalMuonShower& shower,
std::array<uint32_t, 6>& payload,
bool useEmtfNominalTightShowers,
bool useEmtfLooseShowers);
static uint64_t generate64bitDataWord(const RegionalMuonCand& mu, bool isKbmtf, bool useEmtfDisplacementInfo);
static int generateRawTrkAddress(const RegionalMuonCand&, bool isKalman);
static uint64_t generate64bitDataWord(const RegionalMuonCand& mu,
bool isKbmtf,
bool useOmtfDisplacementInfo,
bool useEmtfDisplacementInfo);
static int generateRawTrkAddress(const RegionalMuonCand&, bool isKalman, bool useOmtfDisplacementInfo);

static constexpr unsigned ptMask_ = 0x1FF;
static constexpr unsigned ptShift_ = 0;
Expand All @@ -53,6 +63,7 @@ namespace l1t {
static constexpr unsigned emtfDxyShift_ = 29;
static constexpr unsigned ptUnconstrainedMask_ = 0xFF;
static constexpr unsigned bmtfPtUnconstrainedShift_ = 23;
static constexpr unsigned kOmtfPtUnconstrainedShift_ = 18;
static constexpr unsigned emtfPtUnconstrainedShift_ = 20;
static constexpr unsigned trackAddressMask_ = 0x1FFFFFFF;
static constexpr unsigned trackAddressShift_ = 2;
Expand Down
31 changes: 22 additions & 9 deletions L1Trigger/L1TMuon/src/RegionalMuonRawDigiTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand(RegionalMuonCand&
const int proc,
const tftype tf,
const bool isKbmtf,
const bool useOmtfDisplacementInfo,
const bool useEmtfDisplacementInfo) {
// translations as defined in DN-15-017
mu.setHwPt((raw_data_00_31 >> ptShift_) & ptMask_);
Expand Down Expand Up @@ -87,11 +88,15 @@ void l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand(RegionalMuonCand&
mu.setTrackSubAddress(RegionalMuonCand::kBX, (rawTrackAddress >> emtfTrAddrBxShift_) & emtfTrAddrBxMask_);
}
} else if (tf == omtf_neg || tf == omtf_pos) {
mu.setTrackSubAddress(RegionalMuonCand::kLayers,
(rawTrackAddress >> omtfTrAddrLayersShift_) & omtfTrAddrLayersMask_);
mu.setTrackSubAddress(RegionalMuonCand::kZero, 0);
mu.setTrackSubAddress(RegionalMuonCand::kWeight,
(rawTrackAddress >> omtfTrAddrWeightShift_) & omtfTrAddrWeightMask_);
if (useOmtfDisplacementInfo) { // In Run-3 2024 we receive displaced muon information from OMTF
mu.setHwPtUnconstrained((raw_data_32_63 >> kOmtfPtUnconstrainedShift_) & ptUnconstrainedMask_);
} else {
mu.setTrackSubAddress(RegionalMuonCand::kLayers,
(rawTrackAddress >> omtfTrAddrLayersShift_) & omtfTrAddrLayersMask_);
mu.setTrackSubAddress(RegionalMuonCand::kZero, 0);
mu.setTrackSubAddress(RegionalMuonCand::kWeight,
(rawTrackAddress >> omtfTrAddrWeightShift_) & omtfTrAddrWeightMask_);
}
} else {
std::map<int, int> trackAddr;
trackAddr[0] = rawTrackAddress;
Expand All @@ -107,13 +112,15 @@ void l1t::RegionalMuonRawDigiTranslator::fillRegionalMuonCand(RegionalMuonCand&
const int proc,
const tftype tf,
const bool isKbmtf,
const bool useOmtfDisplacementInfo,
const bool useEmtfDisplacementInfo) {
fillRegionalMuonCand(mu,
(uint32_t)(dataword & 0xFFFFFFFF),
(uint32_t)((dataword >> 32) & 0xFFFFFFFF),
proc,
tf,
isKbmtf,
useOmtfDisplacementInfo,
useEmtfDisplacementInfo);
}

Expand Down Expand Up @@ -166,6 +173,7 @@ void l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords(const RegionalM
uint32_t& raw_data_00_31,
uint32_t& raw_data_32_63,
const bool isKbmtf,
const bool useOmtfDisplacementInfo,
const bool useEmtfDisplacementInfo) {
int abs_eta = mu.hwEta();
if (abs_eta < 0) {
Expand All @@ -181,13 +189,15 @@ void l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords(const RegionalM
(mu.hwPhi() < 0) << phiSignShift_;

// generate the raw track address from the subaddresses
int rawTrkAddr = generateRawTrkAddress(mu, isKbmtf);
int rawTrkAddr = generateRawTrkAddress(mu, isKbmtf, useOmtfDisplacementInfo);

raw_data_32_63 = mu.hwSign() << signShift_ | mu.hwSignValid() << signValidShift_ |
(rawTrkAddr & trackAddressMask_) << trackAddressShift_;
if (isKbmtf && mu.trackFinderType() == bmtf) {
raw_data_32_63 |= (mu.hwPtUnconstrained() & ptUnconstrainedMask_) << bmtfPtUnconstrainedShift_ |
(mu.hwDXY() & dxyMask_) << bmtfDxyShift_;
} else if (useOmtfDisplacementInfo && (mu.trackFinderType() == omtf_pos || mu.trackFinderType() == omtf_neg)) {
raw_data_32_63 |= (mu.hwPtUnconstrained() & ptUnconstrainedMask_) << kOmtfPtUnconstrainedShift_;
} else if (useEmtfDisplacementInfo && (mu.trackFinderType() == emtf_pos || mu.trackFinderType() == emtf_neg)) {
raw_data_32_63 |= (mu.hwPtUnconstrained() & ptUnconstrainedMask_) << emtfPtUnconstrainedShift_ |
(mu.hwDXY() & dxyMask_) << emtfDxyShift_;
Expand All @@ -196,15 +206,18 @@ void l1t::RegionalMuonRawDigiTranslator::generatePackedDataWords(const RegionalM

uint64_t l1t::RegionalMuonRawDigiTranslator::generate64bitDataWord(const RegionalMuonCand& mu,
const bool isKbmtf,
const bool useOmtfDisplacementInfo,
const bool useEmtfDisplacementInfo) {
uint32_t lsw;
uint32_t msw;

generatePackedDataWords(mu, lsw, msw, isKbmtf, useEmtfDisplacementInfo);
generatePackedDataWords(mu, lsw, msw, isKbmtf, useOmtfDisplacementInfo, useEmtfDisplacementInfo);
return (((uint64_t)msw) << 32) + lsw;
}

int l1t::RegionalMuonRawDigiTranslator::generateRawTrkAddress(const RegionalMuonCand& mu, const bool isKalman) {
int l1t::RegionalMuonRawDigiTranslator::generateRawTrkAddress(const RegionalMuonCand& mu,
const bool isKalman,
const bool useOmtfDisplacementInfo) {
int tf = mu.trackFinderType();
int rawTrkAddr = 0;
if (tf == bmtf) {
Expand Down Expand Up @@ -253,7 +266,7 @@ int l1t::RegionalMuonRawDigiTranslator::generateRawTrkAddress(const RegionalMuon
<< " subaddresses. Check the data format. Setting track address to 0.";
rawTrkAddr = 0;
}
} else if (tf == omtf_neg || tf == omtf_pos) {
} else if ((tf == omtf_neg || tf == omtf_pos) && !useOmtfDisplacementInfo) {
// protection against a track address map with the wrong size
if (mu.trackAddress().size() == RegionalMuonCand::kNumOmtfSubAddr) {
rawTrkAddr = (mu.trackSubAddress(RegionalMuonCand::kLayers) & omtfTrAddrLayersMask_) << omtfTrAddrLayersShift_ |
Expand Down
2 changes: 1 addition & 1 deletion L1Trigger/L1TNtuples/src/L1AnalysisL1UpgradeTfMuon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void L1Analysis::L1AnalysisL1UpgradeTfMuon::SetTfMuon(const l1t::RegionalMuonCan
}
l1upgradetfmuon_.tfMuonDecodedTrAdd.push_back(decoded_track_address);
l1upgradetfmuon_.tfMuonHwTrAdd.push_back(
l1t::RegionalMuonRawDigiTranslator::generateRawTrkAddress(*it, isRun3_));
l1t::RegionalMuonRawDigiTranslator::generateRawTrkAddress(*it, isRun3_, isRun3_));
l1upgradetfmuon_.nTfMuons++;
}
}
Expand Down

0 comments on commit 7b2ef4d

Please sign in to comment.