Skip to content

Commit

Permalink
Merge pull request #40096 from cecilecaillol/l1t-1055
Browse files Browse the repository at this point in the history
[L1T] Phase-2, Update Track Selection Emulation to Match Firmware
  • Loading branch information
cmsbuild authored Mar 3, 2023
2 parents adc97a6 + 2d00a3e commit 9b708c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
8 changes: 4 additions & 4 deletions DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ class TTTrack_TrackWord {
return reco::deltaPhi(globalPhi, (sector * sectorWidth));
}

private:
// ----------private member functions --------------
public:
// ----------public member functions --------------
unsigned int countSetBits(unsigned int n) const {
// Adapted from: https://www.geeksforgeeks.org/count-set-bits-in-an-integer/
unsigned int count = 0;
Expand Down Expand Up @@ -314,7 +314,7 @@ class TTTrack_TrackWord {
return (up - bins.begin() - 1);
}

double undigitizeSignedValue(unsigned int twosValue, unsigned int nBits, double lsb) const {
double undigitizeSignedValue(unsigned int twosValue, unsigned int nBits, double lsb, double offset = 0.5) const {
// Check that none of the bits above the nBits-1 bit, in a range of [0, nBits-1], are set.
// This makes sure that it isn't possible for the value represented by `twosValue` to be
// any bigger than ((1 << nBits) - 1).
Expand All @@ -327,7 +327,7 @@ class TTTrack_TrackWord {
}

// Convert to floating point value
return (double(digitizedValue) + 0.5) * lsb;
return (double(digitizedValue) + offset) * lsb;
}

// ----------member data ---------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
process.l1tVertexProducer.debug = options.debug
process.l1tTrackSelectionProducer.processSimulatedTracks = cms.bool(False)
process.l1tTrackSelectionProducer.l1VerticesEmulationInputTag = cms.InputTag("l1tVertexProducer", "l1verticesEmulation")
process.l1tTrackSelectionProducer.debug = options.debug
process.l1tTrackJetsEmulation.VertexInputTag = cms.InputTag("l1tVertexProducer", "l1verticesEmulation")
process.l1tTrackerEmuEtMiss.L1VertexInputTag = cms.InputTag("l1tVertexProducer", "l1verticesEmulation")
process.l1tTrackerEmuEtMiss.debug = options.debug
Expand Down
28 changes: 20 additions & 8 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> {
TTTrack_TrackWord::TrackBitLocations::kRinvMSB - 1, TTTrack_TrackWord::TrackBitLocations::kRinvLSB);
ap_ufixed<TrackBitWidths::kPtSize, TrackBitWidths::kPtMagSize> ptEmulation;
ptEmulation.V = ptEmulationBits.range();
//edm::LogInfo("L1TrackSelectionProducer") << "produce::Emulation track properties::ap_uint(bits) = " << ptEmulationBits.to_string(2)
// << " ap_ufixed(bits) = " << ptEmulation.to_string(2) << " ap_ufixed(float) = " << ptEmulation.to_double();
return ptEmulation.to_double() >= ptMin_;
}

Expand Down Expand Up @@ -156,7 +154,11 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> {
TTTrackWordAbsZ0MaxSelector(double absZ0Max) : absZ0Max_(absZ0Max) {}
TTTrackWordAbsZ0MaxSelector(const edm::ParameterSet& cfg)
: absZ0Max_(cfg.template getParameter<double>("absZ0Max")) {}
bool operator()(const L1Track& t) const { return std::abs(t.getZ0()) <= absZ0Max_; }
bool operator()(const L1Track& t) const {
double floatZ0 = t.undigitizeSignedValue(
t.getZ0Bits(), TTTrack_TrackWord::TrackBitWidths::kZ0Size, TTTrack_TrackWord::stepZ0, 0.0);
return std::abs(floatZ0) <= absZ0Max_;
}

private:
double absZ0Max_;
Expand Down Expand Up @@ -263,7 +265,7 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> {
deltaZMax_(cfg.template getParameter<double>("deltaZMax")) {}
bool operator()(const L1Track& t, const l1t::Vertex& v) const {
size_t etaIndex =
std::lower_bound(deltaZMaxEtaBounds_.begin(), deltaZMaxEtaBounds_.end(), std::abs(t.momentum().eta())) -
std::upper_bound(deltaZMaxEtaBounds_.begin(), deltaZMaxEtaBounds_.end(), std::abs(t.momentum().eta())) -
deltaZMaxEtaBounds_.begin() - 1;
if (etaIndex > deltaZMax_.size() - 1)
etaIndex = deltaZMax_.size() - 1;
Expand All @@ -281,12 +283,18 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> {
: deltaZMaxEtaBounds_(cfg.template getParameter<double>("deltaZMaxEtaBounds")),
deltaZMax_(cfg.template getParameter<double>("deltaZMax")) {}
bool operator()(const L1Track& t, const l1t::VertexWord& v) const {
TTTrack_TrackWord::tanl_t etaEmulationBits = t.getTanlWord();
ap_fixed<TrackBitWidths::kEtaSize, TrackBitWidths::kEtaMagSize> etaEmulation;
etaEmulation.V = etaEmulationBits.range();
size_t etaIndex =
std::lower_bound(deltaZMaxEtaBounds_.begin(), deltaZMaxEtaBounds_.end(), std::abs(t.momentum().eta())) -
std::upper_bound(deltaZMaxEtaBounds_.begin(), deltaZMaxEtaBounds_.end(), std::abs(etaEmulation.to_double())) -
deltaZMaxEtaBounds_.begin() - 1;
if (etaIndex > deltaZMax_.size() - 1)
etaIndex = deltaZMax_.size() - 1;
return std::abs(v.z0() - t.getZ0()) <= deltaZMax_[etaIndex];
l1t::VertexWord::vtxz0_t fixedTkZ0 = t.undigitizeSignedValue(
t.getZ0Bits(), TTTrack_TrackWord::TrackBitWidths::kZ0Size, TTTrack_TrackWord::stepZ0, 0.0);

return std::abs(v.z0() - fixedTkZ0.to_double()) <= deltaZMax_[etaIndex];
}

private:
Expand Down Expand Up @@ -496,9 +504,13 @@ void L1TrackSelectionProducer::printTrackInfo(edm::LogInfo& log, const L1Track&
TTTrack_TrackWord::tanl_t etaEmulationBits = track.getTanlWord();
ap_fixed<TrackBitWidths::kEtaSize, TrackBitWidths::kEtaMagSize> etaEmulation;
etaEmulation.V = etaEmulationBits.range();
log << "\t\t(" << ptEmulation.to_double() << ", " << etaEmulation.to_double() << ", " << track.getPhi() << ", "
double floatTkZ0 = track.undigitizeSignedValue(
track.getZ0Bits(), TTTrack_TrackWord::TrackBitWidths::kZ0Size, TTTrack_TrackWord::stepZ0, 0.0);
double floatTkPhi = track.undigitizeSignedValue(
track.getPhiBits(), TTTrack_TrackWord::TrackBitWidths::kPhiSize, TTTrack_TrackWord::stepPhi0, 0.0);
log << "\t\t(" << ptEmulation.to_double() << ", " << etaEmulation.to_double() << ", " << floatTkPhi << ", "
<< track.getNStubs() << ", " << track.getBendChi2() << ", " << track.getChi2RZ() << ", " << track.getChi2RPhi()
<< ", " << track.getZ0() << ")\n";
<< ", " << floatTkZ0 << ")\n";
}
}

Expand Down

0 comments on commit 9b708c1

Please sign in to comment.