Skip to content

Commit

Permalink
Updating L1 Emulation to run and save Tk objects
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminRS committed Sep 8, 2022
1 parent baaf405 commit e6d49f5
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 22 deletions.
26 changes: 4 additions & 22 deletions DataFormats/L1Trigger/interface/TkJetWord.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef FIRMWARE_TkJetWord_h
#define FIRMWARE_TkJetWord_h

// Class to store the 96-bit TkJet word for L1 Track Trigger.
// Author: Emily MacDonald, updated by Benjamin Radburn-Smith (September 2022)

#include <vector>
#include <ap_int.h>
#include <cassert>
Expand Down Expand Up @@ -61,28 +64,7 @@ namespace l1t {
public:
// ----------Constructors --------------------------
TkJetWord() {}
TkJetWord(pt_t pt, glbeta_t eta, glbphi_t phi, z0_t z0, nt_t nt, nx_t nx, tkjetunassigned_t unassigned) {
std::string word = "";
word.append(TkJetBitWidths::kUnassignedSize - (unassigned.to_string().length() - 2), '0');
word = word + (unassigned.to_string().substr(2, unassigned.to_string().length() - 2));
word.append(TkJetBitWidths::kXtSize - (nx.to_string().length() - 2), '0');
word = word + (nx.to_string().substr(2, nx.to_string().length() - 2));
word.append(TkJetBitWidths::kNtSize - (nt.to_string().length() - 2), '0');
word = word + (nt.to_string().substr(2, nt.to_string().length() - 2));
word.append(TkJetBitWidths::kZ0Size - (z0.to_string().length() - 2), '0');
word = word + (z0.to_string().substr(2, z0.to_string().length() - 2));
word.append(TkJetBitWidths::kGlbPhiSize - (phi.to_string().length() - 2), '0');
word = word + (phi.to_string().substr(2, phi.to_string().length() - 2));
word.append(TkJetBitWidths::kGlbEtaSize - (eta.to_string().length() - 2), '0');
word = word + (eta.to_string().substr(2, eta.to_string().length() - 2));
ap_ufixed<kPtSize + 5, kPtMagSize + 5, AP_TRN, AP_SAT> pt_2 = pt;
ap_uint<kPtSize> pt_temp = pt_2 << 5;
word.append(TkJetBitWidths::kPtSize - (pt_temp.to_string().length() - 2), '0');
word = word + (pt_temp.to_string().substr(2, pt_temp.to_string().length() - 2));

tkjetword_bs_t tmp(word);
tkJetWord_ = tmp;
}
TkJetWord(pt_t pt, glbeta_t eta, glbphi_t phi, z0_t z0, nt_t nt, nx_t nx, tkjetunassigned_t unassigned);

~TkJetWord() {}

Expand Down
43 changes: 43 additions & 0 deletions DataFormats/L1Trigger/src/TkJetWord.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Class to store the 96-bit TkJet word for L1 Track Trigger.
// Author: Benjamin Radburn-Smith (September 2022)

#include "DataFormats/L1Trigger/interface/TkJetWord.h"

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

void TkJetWord::setTkJetWord(pt_t pt, glbeta_t eta, glbphi_t phi, z0_t z0, nt_t nt, nx_t nx, tkjetunassigned_t unassigned) {
// pack the TkJet word
unsigned int offset = 0;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kPtSize); b++) {
tkJetWord_.set(b, pt[b - offset]);
}
offset += TkJetBitWidths::kPtSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kGlbEtaSize); b++) {
tkJetWord_.set(b, eta[b - offset]);
}
offset += TkJetBitWidths::kGlbEtaSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kGlbPhiSize); b++) {
tkJetWord_.set(b, phi[b - offset]);
}
offset += TkJetBitWidths::kGlbPhiSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kZ0Size); b++) {
tkJetWord_.set(b, z0[b - offset]);
}
offset += TkJetBitWidths::kZ0Size;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kNtSize); b++) {
tkJetWord_.set(b, nt[b - offset]);
}
offset += TkJetBitWidths::kNtSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kXtSize); b++) {
tkJetWord_.set(b, nx[b - offset]);
}
offset += TkJetBitWidths::kXtSize;
for (unsigned int b = offset; b < (offset + TkJetBitWidths::kUnassignedSize); b++) {
tkJetWord_.set(b, unassigned[b - offset]);
}
}

} //namespace l1t
2 changes: 2 additions & 0 deletions DataFormats/L1Trigger/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,7 @@
</class>
<class name="std::vector<l1t::TkJetWord>"/>
<class name="edm::Wrapper<std::vector<l1t::TkJetWord> >"/>
<class name="edm::Wrapper<l1t::TkJetWordCollection>"/>
<class name="std::bitset<70>"/>

</lcgdict>
10 changes: 10 additions & 0 deletions L1Trigger/Configuration/python/L1Trigger_EventContent_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,16 @@ def _appendPhase2Digis(obj):
'keep *_L1EGammaClusterEmuProducer_*_*',
'keep *_L1VertexFinder_*_*',
'keep *_L1VertexFinderEmulator_*_*',
'keep *_L1TrackJets_*_*',
'keep *_L1TrackJetsExtended_*_*',
'keep *_L1TrackFastJets_*_*',
'keep *_L1TrackerEtMiss_*_*',
'keep *_L1TrackerHTMiss_*_*',
'keep *_L1TrackJetsEmulation_*_*',
'keep *_L1TrackJetsExtendedEmulation_*_*',
'keep *_L1TrackerEmuEtMiss_*_*',
'keep *_L1TrackerEmuHTMiss_*_*',
'keep *_L1TrackerEmuHTMissExtended_*_*',
'keep *_L1TowerCalibration_*_*',
'keep *_L1CaloJet_*_*',
'keep *_L1CaloJetHTT_*_*',
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/Configuration/python/SimL1Emulator_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
# make the input tags consistent with the choice L1VertexFinder above
L1TrackJets.L1PVertexCollection = cms.InputTag("L1VertexFinder", L1VertexFinder.l1VertexCollectionName.value())
L1TrackJetsExtended.L1PVertexCollection = cms.InputTag("L1VertexFinder", L1VertexFinder.l1VertexCollectionName.value())
L1TrackFastJets.L1PrimaryVertexTag = ("L1VertexFinder", L1VertexFinder.l1VertexCollectionName.value())
L1TrackerEtMiss.L1VertexInputTag = cms.InputTag("L1VertexFinder", L1VertexFinder.l1VertexCollectionName.value())
L1TrackerEtMissExtended.L1VertexInputTag = cms.InputTag("L1VertexFinder", L1VertexFinder.l1VertexCollectionName.value())
_phase2_siml1emulator.add(L1TrackJets)
Expand Down

0 comments on commit e6d49f5

Please sign in to comment.