Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions DataFormats/L1Trigger/interface/TkJetWord.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ namespace l1t {
public:
// ----------constants, enums and typedefs ---------
static constexpr double MAX_Z0 = 30.;
static constexpr double MAX_ETA = 8.;
static constexpr double MAX_ETA = 2 * M_PI;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is max eta 2pi?

Copy link
Copy Markdown
Contributor Author

@ccahoughton ccahoughton May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from the GTT interface document specifying that the max eta for the prompt jet word is 2*pi (see attached screenshot)

Image


enum TkJetBitWidths {
kValidSize = 1,
kPtSize = 16,
kPtMagSize = 11,
kGlbEtaSize = 14,
Expand All @@ -31,13 +32,15 @@ namespace l1t {
kNtSize = 5,
kXtSize = 4,
kDispFlagSize = 1,
kUnassignedSize = 65,
kTkJetWordSize =
kPtSize + kGlbEtaSize + kGlbPhiSize + kZ0Size + kNtSize + kXtSize + kDispFlagSize + kUnassignedSize,
kUnassignedSize = 64,
kTkJetWordSize = kValidSize + kPtSize + kGlbEtaSize + kGlbPhiSize + kZ0Size + kNtSize + kXtSize + kDispFlagSize +
kUnassignedSize,
};

enum TkJetBitLocations {
kPtLSB = 0,
kValidLSB = 0,
kValidMSB = kValidLSB + TkJetBitWidths::kValidSize - 1,
kPtLSB = kValidMSB + 1,
kPtMSB = kPtLSB + TkJetBitWidths::kPtSize - 1,
kGlbPhiLSB = kPtMSB + 1,
kGlbPhiMSB = kGlbPhiLSB + TkJetBitWidths::kGlbPhiSize - 1,
Expand All @@ -55,6 +58,7 @@ namespace l1t {
kUnassignedMSB = kUnassignedLSB + TkJetBitWidths::kUnassignedSize - 1,
};

typedef ap_uint<TkJetBitWidths::kValidSize> tkjetvalid_t;
typedef ap_ufixed<kPtSize, kPtMagSize, AP_TRN, AP_SAT> pt_t;
typedef ap_int<kGlbEtaSize> glbeta_t;
typedef ap_int<kGlbPhiSize> glbphi_t;
Expand All @@ -69,7 +73,8 @@ namespace l1t {
public:
// ----------Constructors --------------------------
TkJetWord() {}
TkJetWord(pt_t pt,
TkJetWord(tkjetvalid_t valid,
pt_t pt,
glbeta_t eta,
glbphi_t phi,
z0_t z0,
Expand All @@ -91,6 +96,11 @@ namespace l1t {

// ----------member functions (getters) ------------
// These functions return arbitarary precision words (lists of bits) for each quantity
tkjetvalid_t validWord() const {
tkjetvalid_t ret;
ret.V = tkJetWord()(TkJetBitLocations::kValidMSB, TkJetBitLocations::kValidLSB);
return ret;
}
pt_t ptWord() const {
pt_t ret;
ret.V = tkJetWord()(TkJetBitLocations::kPtMSB, TkJetBitLocations::kPtLSB);
Expand Down Expand Up @@ -134,6 +144,7 @@ namespace l1t {

// These functions return the packed bits in integer format for each quantity
// Signed quantities have the sign enconded in the left-most bit.
unsigned int validBits() const { return validWord().to_uint(); }
unsigned int ptBits() const { return ptWord().range().to_uint(); }
unsigned int glbEtaBits() const { return glbEtaWord().to_uint(); }
unsigned int glbPhiBits() const { return glbPhiWord().to_uint(); }
Expand All @@ -145,10 +156,11 @@ namespace l1t {

// These functions return the unpacked and converted values
// These functions return real numbers converted from the digitized quantities by unpacking the 64-bit vertex word
bool valid() const { return validWord().to_bool(); }
float pt() const { return ptWord().to_float(); }
float glbeta() const {
return unpackSignedValue(
glbEtaWord(), TkJetBitWidths::kGlbEtaSize, (MAX_ETA) / (1 << TkJetBitWidths::kGlbEtaSize));
glbEtaWord(), TkJetBitWidths::kGlbEtaSize, (2 * MAX_ETA) / (1 << TkJetBitWidths::kGlbEtaSize));
}
float glbphi() const {
return unpackSignedValue(
Expand All @@ -163,7 +175,8 @@ namespace l1t {
unsigned int unassigned() const { return unassignedWord().to_uint(); }

// ----------member functions (setters) ------------
void setTkJetWord(pt_t pt,
void setTkJetWord(tkjetvalid_t valid,
pt_t pt,
glbeta_t eta,
glbphi_t phi,
z0_t z0,
Expand Down
14 changes: 10 additions & 4 deletions DataFormats/L1Trigger/src/TkJetWord.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
#include "DataFormats/L1Trigger/interface/TkJetWord.h"

namespace l1t {
TkJetWord::TkJetWord(pt_t pt,
TkJetWord::TkJetWord(tkjetvalid_t valid,
pt_t pt,
glbeta_t eta,
glbphi_t phi,
z0_t z0,
nt_t nt,
nx_t nx,
dispflag_t dispflag,
tkjetunassigned_t unassigned) {
setTkJetWord(pt, eta, phi, z0, nt, nx, dispflag, unassigned);
setTkJetWord(valid, pt, eta, phi, z0, nt, nx, dispflag, unassigned);
}

void TkJetWord::setTkJetWord(pt_t pt,
void TkJetWord::setTkJetWord(tkjetvalid_t valid,
pt_t pt,
glbeta_t eta,
glbphi_t phi,
z0_t z0,
Expand All @@ -25,6 +27,10 @@ namespace l1t {
tkjetunassigned_t unassigned) {
// pack the TkJet word
unsigned int offset = 0;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kValidSize); b++) {
tkJetWord_.set(b, valid[b - offset]);
}
offset += TkJetBitWidths::kValidSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kPtSize); b++) {
tkJetWord_.set(b, pt[b - offset]);
}
Expand All @@ -50,7 +56,7 @@ namespace l1t {
}
offset += TkJetBitWidths::kXtSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kDispFlagSize); b++) {
tkJetWord_.set(b, nx[b - offset]);
tkJetWord_.set(b, dispflag[b - offset]);
}
offset += TkJetBitWidths::kDispFlagSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kUnassignedSize); b++) {
Expand Down
13 changes: 8 additions & 5 deletions L1Trigger/DemonstratorTools/src/codecs_tkjets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ namespace l1t::demo::codecs {
std::vector<l1t::TkJetWord> tkJets;

for (size_t f = 0; f < frames.size(); f += 2) {
// There is no valid bit in the definition right now.
// Uncomment the next two lines when this is available.
//if (not x.test(TkJetWord::kValidLSB))
// break;

TkJetWord j(
TkJetWord::tkjetvalid_t(
frames[f](TkJetWord::TkJetBitLocations::kValidMSB, TkJetWord::TkJetBitLocations::kValidLSB)),
TkJetWord::pt_t(frames[f](TkJetWord::TkJetBitLocations::kPtMSB, TkJetWord::TkJetBitLocations::kPtLSB)),
TkJetWord::glbphi_t(
frames[f](TkJetWord::TkJetBitLocations::kGlbPhiMSB, TkJetWord::TkJetBitLocations::kGlbPhiLSB)),
Expand All @@ -47,6 +44,12 @@ namespace l1t::demo::codecs {
frames[f](TkJetWord::TkJetBitLocations::kDispFlagMSB, TkJetWord::TkJetBitLocations::kDispFlagLSB)),
TkJetWord::tkjetunassigned_t(
frames[f](TkJetWord::TkJetBitLocations::kUnassignedMSB, TkJetWord::TkJetBitLocations::kUnassignedLSB)));

// There is no valid bit in the definition right now.
// Uncomment the next two lines when this is available.
if (not j.valid())
break;

tkJets.push_back(j);
}

Expand Down
30 changes: 30 additions & 0 deletions L1Trigger/DemonstratorTools/test/gtt/FirmwareGeometryFile.vh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
parameter eta_bin_0 = 14'b11010001001010;
parameter eta_bin_1 = 14'b11010101001110;
parameter eta_bin_2 = 14'b11011001010011;
parameter eta_bin_3 = 14'b11011101011000;
parameter eta_bin_4 = 14'b11100001011100;
parameter eta_bin_5 = 14'b11100101100001;
parameter eta_bin_6 = 14'b11101001100110;
parameter eta_bin_7 = 14'b11101101101011;
parameter eta_bin_8 = 14'b11110001101111;
parameter eta_bin_9 = 14'b11110101110100;
parameter eta_bin_10 = 14'b11111001111001;
parameter eta_bin_11 = 14'b11111101111101;
parameter eta_bin_12 = 14'b00000010000001;
parameter eta_bin_13 = 14'b00000110000110;
parameter eta_bin_14 = 14'b00001010001010;
parameter eta_bin_15 = 14'b00001110001111;
parameter eta_bin_16 = 14'b00010010010100;
parameter eta_bin_17 = 14'b00010110011001;
parameter eta_bin_18 = 14'b00011010011101;
parameter eta_bin_19 = 14'b00011110100010;
parameter eta_bin_20 = 14'b00100010100111;
parameter eta_bin_21 = 14'b00100110101011;
parameter eta_bin_22 = 14'b00101010110000;
parameter eta_bin_23 = 14'b00101110110101;
parameter LowJetTracks_FakeReduction = 4'b0010;
parameter LowJetpT_FakeReduction = 16'b0000011001000000;
parameter HighJetTracks_FakeReduction = 4'b0011;
parameter HighJetpT_FakeReduction = 16'b0000110010000000;
parameter MinJetTracks = 4'b0001;
parameter MinJetpT = 16'b0000000101000000;
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@

process = cms.Process("GTTFileWriter")

process.load('Configuration.Geometry.GeometryExtendedRun4D88Reco_cff')
process.load('Configuration.Geometry.GeometryExtendedRun4D88_cff')
process.load('Configuration.Geometry.GeometryExtendedRun4D110Reco_cff')
process.load('Configuration.Geometry.GeometryExtendedRun4D110_cff')
process.load('Configuration.StandardSequences.MagneticField_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
from Configuration.AlCa.GlobalTag import GlobalTag
Expand Down Expand Up @@ -141,6 +141,7 @@

#Disable internal track selection
process.l1tTrackJetsEmulation.trk_zMax = cms.double(20.46912512) # maximum track z from TrackWord
process.l1tTrackJetsEmulation.export_binmap = cms.bool(True) # creates Jet Finding firmware geometry file

if options.debug:
process.MessageLogger.cerr.INFO.limit = cms.untracked.int32(1000000000)
Expand Down
54 changes: 54 additions & 0 deletions L1Trigger/L1TTrackMatch/plugins/L1TrackJetClustering.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,60 @@ namespace l1ttrackjet {
return phi_bin_;
}

//Geometry writeout for firmware
inline void FirmwareGeometryWriteOut(std::vector<glbeta_intern> eta_bin_centers,
std::vector<glbphi_intern> phi_bin_centers,
int etaBins_,
int lowpTJetMinTrackMultiplicity_,
float lowpTJetThreshold_,
int highpTJetMinTrackMultiplicity_,
float highpTJetThreshold_,
int minTrkJetTrackMultiplicity_,
float minTrkJetpT_) {
ofstream FirmwareGeometryFile;
FirmwareGeometryFile.open("./FirmwareGeometryFile.vh");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be useful add a check here to make sure the file is open


//This loop converts eta bin centers of type glbeta_intern into unsigned ints that can be read
//out as bit words to the geometry file
for (int i = 0; i < etaBins_; i++) {
unsigned int EtaBitInt = DoubleToBit(
eta_bin_centers[i], l1t::TkJetWord::TkJetBitWidths::kGlbEtaSize, l1t::TkJetWord::MAX_ETA * pow(2, -13));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should l1t::TkJetWord::MAX_ETA * pow(2, -13) be derived from kGlbEtaSize to avoid magic numbers? For example: (2 * MAX_ETA) / (1 << kGlbEtaSize)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will change it.

std::bitset<l1t::TkJetWord::TkJetBitWidths::kGlbEtaSize> EtaBitWord(EtaBitInt);
FirmwareGeometryFile << "parameter eta_bin_" << i << " = 14'b" << EtaBitWord << ";" << std::endl;
}

//This code converts the int type track multiplicity values into bitset type to read out
std::bitset<4> lowpTJetMinTrackMultiplicity_bit(lowpTJetMinTrackMultiplicity_);
std::bitset<4> highpTJetMinTrackMultiplicity_bit(highpTJetMinTrackMultiplicity_);
std::bitset<4> minTrkJetTrackMultiplicity_bit(minTrkJetTrackMultiplicity_);

//Here we convert the float type pT cuts into pt_intern type for conversion into bitset type
pt_intern lowpTJetThreshold_converted(lowpTJetThreshold_);
pt_intern highpTJetThreshold_converted(highpTJetThreshold_);
pt_intern minTrkJetpT_converted(minTrkJetpT_);

//Here we turn the converted pT cut values into bitset type
std::bitset<l1t::TkJetWord::TkJetBitWidths::kPtSize> lowpTJetThreshold_bit(
lowpTJetThreshold_converted.range().to_uint());
std::bitset<l1t::TkJetWord::TkJetBitWidths::kPtSize> highpTJetThreshold_bit(
highpTJetThreshold_converted.range().to_uint());
std::bitset<l1t::TkJetWord::TkJetBitWidths::kPtSize> minTrkJetpT_bit(minTrkJetpT_converted.range().to_uint());

//Export the bit words to the geometry file
FirmwareGeometryFile << "parameter LowJetTracks_FakeReduction = 4'b" << lowpTJetMinTrackMultiplicity_bit << ";"
<< std::endl;
FirmwareGeometryFile << "parameter LowJetpT_FakeReduction = 16'b" << lowpTJetThreshold_bit << ";" << std::endl;

FirmwareGeometryFile << "parameter HighJetTracks_FakeReduction = 4'b" << highpTJetMinTrackMultiplicity_bit << ";"
<< std::endl;
FirmwareGeometryFile << "parameter HighJetpT_FakeReduction = 16'b" << highpTJetThreshold_bit << ";" << std::endl;

FirmwareGeometryFile << "parameter MinJetTracks = 4'b" << minTrkJetTrackMultiplicity_bit << ";" << std::endl;
FirmwareGeometryFile << "parameter MinJetpT = 16'b" << minTrkJetpT_bit << ";" << std::endl;

FirmwareGeometryFile.close();
}

// L1 clustering (in eta)
template <typename T, typename Pt, typename Eta, typename Phi>
inline std::vector<T> L1_clustering(T *phislice, int etaBins_, Eta etaStep_) {
Expand Down
Loading