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
(cherry picked from commit e6d49f5)
  • Loading branch information
BenjaminRS authored and ccaillol committed Sep 15, 2022
1 parent 366658e commit 8ec852a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 27 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 @@ -309,5 +309,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 *_l1tEGammaClusterEmuProducer_*_*',
'keep *_l1tVertexFinder_*_*',
'keep *_l1tVertexFinderEmulator_*_*',
'keep *_l1tTrackJets_*_*',
'keep *_l1tTrackJetsExtended_*_*',
'keep *_l1tTrackFastJets_*_*',
'keep *_l1tTrackerEtMiss_*_*',
'keep *_l1tTrackerHTMiss_*_*',
'keep *_l1tTrackJetsEmulation_*_*',
'keep *_l1tTrackJetsExtendedEmulation_*_*',
'keep *_l1tTrackerEmuEtMiss_*_*',
'keep *_l1tTrackerEmuHTMiss_*_*',
'keep *_l1tTrackerEmuHTMissExtended_*_*',
'keep *_l1tTowerCalibration_*_*',
'keep *_l1tCaloJet_*_*',
'keep *_l1tCaloJetHTT_*_*',
Expand Down
10 changes: 5 additions & 5 deletions L1Trigger/Configuration/python/SimL1Emulator_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@
from L1Trigger.L1TTrackMatch.l1tTrackerEtMiss_cfi import *
from L1Trigger.L1TTrackMatch.l1tTrackerHTMiss_cfi import *
# make the input tags consistent with the choice L1VertexFinder above
l1tTrackJets.L1PVertexCollection = ("L1VertexFinder", "l1vertices")
l1tTrackJetsExtended.L1PVertexCollection = ("L1VertexFinder", "l1vertices")
#L1TrackerEtMiss.L1VertexInputTag = ("L1VertexFinder", "l1vertices")
#L1TrackerEtMissExtended.L1VertexInputTag = ("L1VertexFinder", "l1vertices")
l1tTrackJets.L1PVertexCollection = ("l1tVertexFinder", "l1vertices")
L1TrackFastJets.L1PrimaryVertexTag = ("l1tVertexFinder", "l1vertices")
l1tTrackJetsExtended.L1PVertexCollection = ("l1tVertexFinder", "l1vertices")
l1tTrackerEtMiss.L1VertexInputTag = ("l1tVertexFinder", "l1vertices")
l1tTrackerEtMissExtended.L1VertexInputTag = ("l1tVertexFinder", "l1vertices")
_phase2_siml1emulator.add(l1tTrackJets)
_phase2_siml1emulator.add(l1tTrackJetsExtended)
_phase2_siml1emulator.add(l1tTrackFastJets)

_phase2_siml1emulator.add(l1tTrackerEtMiss)
_phase2_siml1emulator.add(l1tTrackerHTMiss)

Expand Down

0 comments on commit 8ec852a

Please sign in to comment.