Skip to content

Commit

Permalink
Merge pull request #103 from gpetruc/merge_l1t_v3p4p50
Browse files Browse the repository at this point in the history
Merge l1t-phase2-v3.4.50
  • Loading branch information
gpetruc authored Dec 7, 2022
2 parents 561f198 + d56f672 commit 912d918
Show file tree
Hide file tree
Showing 58 changed files with 1,222 additions and 757 deletions.
9 changes: 9 additions & 0 deletions DataFormats/L1TMuonPhase2/interface/SAMuon.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "L1Trigger/Phase2L1GMT/interface/Constants.h"

namespace l1t {

Expand All @@ -31,6 +32,14 @@ namespace l1t {
const uint hwBeta() const { return hwBeta_; }
void setBeta(uint beta) { hwBeta_ = beta; }

// For HLT
const double phZ0() const { return Phase2L1GMT::LSBSAz0*hwZ0();}
const double phD0() const { return Phase2L1GMT::LSBSAd0*hwD0();}
const double phPt() const { return Phase2L1GMT::LSBpt*hwPt();}
const double phEta() const { return Phase2L1GMT::LSBeta*hwEta();}
const double phPhi() const { return Phase2L1GMT::LSBphi*hwPhi();}
const int phCharge() const {return pow(-1,hwCharge()); }

const uint64_t word() const { return word_; }
void setWord(uint64_t word) { word_ = word; }
void print() const;
Expand Down
9 changes: 9 additions & 0 deletions DataFormats/L1TMuonPhase2/interface/TrackerMuon.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
#include "DataFormats/L1TMuonPhase2/interface/MuonStub.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "L1Trigger/Phase2L1GMT/interface/Constants.h"

namespace l1t {

Expand Down Expand Up @@ -43,6 +44,14 @@ namespace l1t {
void setMuonRef(const edm::Ref<l1t::RegionalMuonCandBxCollection>& p) { muRef_ = p; }
void setHwIsoSum(int isoSum) { hwIsoSum_ = isoSum; }
void setHwIsoSumAp(int isoSum) { hwIsoSumAp_ = isoSum; }

// For HLT
const double phZ0() const { return Phase2L1GMT::LSBGTz0*hwZ0();}
const double phD0() const { return Phase2L1GMT::LSBGTd0*hwD0();}
const double phPt() const { return Phase2L1GMT::LSBpt*hwPt();}
const double phEta() const { return Phase2L1GMT::LSBeta*hwEta();}
const double phPhi() const { return Phase2L1GMT::LSBphi*hwPhi();}
const int phCharge() const {return pow(-1,hwCharge()); }

const std::array<uint64_t, 2> word() const { return word_; }
void setWord(std::array<uint64_t, 2> word) { word_ = word; }
Expand Down
6 changes: 3 additions & 3 deletions DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class TTTrack_TrackWord {
return reco::deltaPhi(globalPhi, (sector * sectorWidth));
}

private:
public:
// ----------private member functions --------------
unsigned int countSetBits(unsigned int n) const {
// Adapted from: https://www.geeksforgeeks.org/count-set-bits-in-an-integer/
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
18 changes: 10 additions & 8 deletions DataFormats/L1Trigger/interface/MuonShower.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ namespace l1t {
The 2 loose showers case would be mapped onto musOutOfTime0 and musOutOfTime1 later during Run-3
*/

void setMus0(const bool bit) { mus0_ = bit; }
void setMus1(const bool bit) { mus1_ = bit; }
void setOneNominalInTime(const bool bit) { oneNominalInTime_ = bit; }
void setOneTightInTime(const bool bit) { oneTightInTime_ = bit; }
void setMus0(const bool bit) { oneNominalInTime_ = bit; }
void setMus1(const bool bit) { oneTightInTime_ = bit; }
void setMusOutOfTime0(const bool bit) { musOutOfTime0_ = bit; }
void setMusOutOfTime1(const bool bit) { musOutOfTime1_ = bit; }

bool mus0() const { return mus0_; }
bool mus1() const { return mus1_; }
bool mus0() const { return oneNominalInTime_; }
bool mus1() const { return oneTightInTime_; }
bool musOutOfTime0() const { return musOutOfTime0_; }
bool musOutOfTime1() const { return musOutOfTime1_; }

Expand All @@ -69,8 +71,8 @@ namespace l1t {

// useful members for trigger performance studies
// needed at startup Run-3
bool isOneNominalInTime() const { return mus0_; }
bool isOneTightInTime() const { return mus1_; }
bool isOneNominalInTime() const { return oneNominalInTime_; }
bool isOneTightInTime() const { return oneTightInTime_; }
// to be developed during Run-3
bool isTwoLooseInTime() const { return false; }
// these options require more study
Expand All @@ -84,8 +86,8 @@ namespace l1t {
private:
// Run-3 definitions as provided in DN-20-033
// in time and out-of-time qualities. only 2 bits each.
bool mus0_;
bool mus1_;
bool oneNominalInTime_;
bool oneTightInTime_;
bool musOutOfTime0_;
bool musOutOfTime1_;
};
Expand Down
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
8 changes: 5 additions & 3 deletions DataFormats/L1Trigger/interface/VertexWord.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//
// author: Alexx Perloff
// created: March 17, 2021
// modified by: Nick Manganelli
// modified: November 18, 2022
//
///////

Expand All @@ -30,11 +32,11 @@ namespace l1t {
kZ0Size = 15, // Width of z-position
kZ0MagSize = 6, // Width of z-position magnitude (signed)
kNTrackInPVSize = 8, // Width of the multiplicity in the PV (unsigned)
kSumPtSize = 10, // Width of pT
kSumPtMagSize = 8, // Width of pT magnitude (unsigned)
kSumPtSize = 12, // Width of pT
kSumPtMagSize = 10, // Width of pT magnitude (unsigned)
kQualitySize = 3, // Width of the quality field
kNTrackOutPVSize = 10, // Width of the multiplicity outside the PV (unsigned)
kUnassignedSize = 17, // Width of the unassigned bits
kUnassignedSize = 15, // Width of the unassigned bits

kVertexWordSize = kValidSize + kZ0Size + kNTrackInPVSize + kSumPtSize + kQualitySize + kNTrackOutPVSize +
kUnassignedSize, // Width of the vertex word in bits
Expand Down
12 changes: 7 additions & 5 deletions DataFormats/L1Trigger/src/MuonShower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ l1t::MuonShower::MuonShower(bool oneNominalInTime,
: L1Candidate(math::PtEtaPhiMLorentzVector{0., 0., 0., 0.}, 0., 0., 0., 0, 0),
// in this object it makes more sense to the different shower types to
// the 4 bits, so that the object easily interfaces with the uGT emulator
mus0_(oneNominalInTime),
mus1_(oneTightInTime),
oneNominalInTime_(oneNominalInTime),
oneTightInTime_(oneTightInTime),
musOutOfTime0_(false),
musOutOfTime1_(false) {}

l1t::MuonShower::~MuonShower() {}

bool l1t::MuonShower::isValid() const { return mus0_ or mus1_ or musOutOfTime0_ or musOutOfTime1_; }
bool l1t::MuonShower::isValid() const {
return oneNominalInTime_ or oneTightInTime_ or musOutOfTime0_ or musOutOfTime1_;
}

bool l1t::MuonShower::operator==(const l1t::MuonShower& rhs) const {
return (mus0_ == rhs.mus0() and mus1_ == rhs.mus1() and musOutOfTime0_ == rhs.musOutOfTime0() and
musOutOfTime1_ == rhs.musOutOfTime1());
return (oneNominalInTime_ == rhs.isOneNominalInTime() and oneTightInTime_ == rhs.isOneTightInTime() and
musOutOfTime0_ == rhs.musOutOfTime0() and musOutOfTime1_ == rhs.musOutOfTime1());
}
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
5 changes: 4 additions & 1 deletion DataFormats/L1Trigger/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
<class name="l1t::MuonVectorRef"/>
<class name="edm::Wrapper<l1t::MuonVectorRef>"/>

<class name="l1t::MuonShower" ClassVersion="11">
<class name="l1t::MuonShower" ClassVersion="12">
<version ClassVersion="12" checksum="2452991184"/>
<version ClassVersion="11" checksum="3610959089"/>
<version ClassVersion="10" checksum="3869296059"/>
</class>
Expand Down Expand Up @@ -302,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>
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ namespace l1t {
namespace stage2 {
GTCollections::~GTCollections() {
event_.put(std::move(muons_[0]), "Muon");
event_.put(std::move(muonShowers_[0]), "MuonShower");
event_.put(std::move(egammas_[0]), "EGamma");
event_.put(std::move(etsums_[0]), "EtSum");
event_.put(std::move(jets_[0]), "Jet");
event_.put(std::move(taus_[0]), "Tau");

for (int i = 1; i < 6; ++i) {
event_.put(std::move(muons_[i]), "Muon" + std::to_string(i + 1));
event_.put(std::move(muonShowers_[i]), "MuonShower" + std::to_string(i + 1));
event_.put(std::move(egammas_[i]), "EGamma" + std::to_string(i + 1));
event_.put(std::move(etsums_[i]), "EtSum" + std::to_string(i + 1));
event_.put(std::move(jets_[i]), "Jet" + std::to_string(i + 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace l1t {
GTCollections(edm::Event& e)
: L1TObjectCollections(e), algBlk_(new GlobalAlgBlkBxCollection()), extBlk_(new GlobalExtBlkBxCollection()) {
std::generate(muons_.begin(), muons_.end(), [] { return std::make_unique<MuonBxCollection>(); });
std::generate(
muonShowers_.begin(), muonShowers_.end(), [] { return std::make_unique<MuonShowerBxCollection>(); });
std::generate(egammas_.begin(), egammas_.end(), [] { return std::make_unique<EGammaBxCollection>(); });
std::generate(etsums_.begin(), etsums_.end(), [] { return std::make_unique<EtSumBxCollection>(); });
std::generate(jets_.begin(), jets_.end(), [] { return std::make_unique<JetBxCollection>(); });
Expand All @@ -29,6 +31,9 @@ namespace l1t {
~GTCollections() override;

inline MuonBxCollection* getMuons(const unsigned int copy) override { return muons_[copy].get(); };
inline MuonShowerBxCollection* getMuonShowers(const unsigned int copy) override {
return muonShowers_[copy].get();
};
inline EGammaBxCollection* getEGammas(const unsigned int copy) override { return egammas_[copy].get(); };
inline EtSumBxCollection* getEtSums(const unsigned int copy) override { return etsums_[copy].get(); };
inline JetBxCollection* getJets(const unsigned int copy) override { return jets_[copy].get(); };
Expand All @@ -39,6 +44,7 @@ namespace l1t {

private:
std::array<std::unique_ptr<MuonBxCollection>, 6> muons_;
std::array<std::unique_ptr<MuonShowerBxCollection>, 6> muonShowers_;
std::array<std::unique_ptr<EGammaBxCollection>, 6> egammas_;
std::array<std::unique_ptr<EtSumBxCollection>, 6> etsums_;
std::array<std::unique_ptr<JetBxCollection>, 6> jets_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace l1t {
desc.addOptional<edm::InputTag>("GtInputTag")->setComment("for stage2");
desc.addOptional<edm::InputTag>("ExtInputTag")->setComment("for stage2");
desc.addOptional<edm::InputTag>("MuonInputTag")->setComment("for stage2");
desc.addOptional<edm::InputTag>("ShowerInputTag")->setComment("for Run3");
desc.addOptional<edm::InputTag>("EGammaInputTag")->setComment("for stage2");
desc.addOptional<edm::InputTag>("JetInputTag")->setComment("for stage2");
desc.addOptional<edm::InputTag>("TauInputTag")->setComment("for stage2");
Expand Down Expand Up @@ -50,6 +51,7 @@ namespace l1t {

void GTSetup::registerProducts(edm::ProducesCollector prod) {
prod.produces<MuonBxCollection>("Muon");
prod.produces<MuonShowerBxCollection>("MuonShower");
prod.produces<EGammaBxCollection>("EGamma");
prod.produces<EtSumBxCollection>("EtSum");
prod.produces<JetBxCollection>("Jet");
Expand All @@ -58,6 +60,7 @@ namespace l1t {
prod.produces<GlobalExtBlkBxCollection>();
for (int i = 2; i < 7; ++i) { // Collections from boards 2-6
prod.produces<MuonBxCollection>("Muon" + std::to_string(i));
prod.produces<MuonShowerBxCollection>("MuonShower" + std::to_string(i));
prod.produces<EGammaBxCollection>("EGamma" + std::to_string(i));
prod.produces<EtSumBxCollection>("EtSum" + std::to_string(i));
prod.produces<JetBxCollection>("Jet" + std::to_string(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ namespace l1t {
auto tautag = cfg.getParameter<edm::InputTag>("TauInputTag");
auto etsumtag = cfg.getParameter<edm::InputTag>("EtSumInputTag");
auto muontag = cfg.getParameter<edm::InputTag>("MuonInputTag");
auto muonshowertag = cfg.getParameter<edm::InputTag>("ShowerInputLabel");

//cout << "DEBUG: GmtInputTag" << muontag << "\n";

muonToken_ = cc.consumes<MuonBxCollection>(muontag);
muonShowerToken_ = cc.consumes<MuonShowerBxCollection>(muonshowertag);
egammaToken_ = cc.consumes<EGammaBxCollection>(egammatag);
etSumToken_ = cc.consumes<EtSumBxCollection>(etsumtag);
jetToken_ = cc.consumes<JetBxCollection>(jettag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace l1t {
GMTOutputObjectMap gmtObjMap;
std::pair<int, int> muonBx = getMuons(gmtObjMap, event, static_cast<const CommonTokens*>(toks)->getMuonToken());
std::pair<int, int> muonShowerBx{0, 0};
if (fedId_ == 1402 && fwId_ >= 0x7000000) {
if ((fedId_ == 1402 && fwId_ >= 0x7000000) || (fedId_ == 1404 && fwId_ >= 0x00010f01)) {
muonShowerBx = getMuonShowers(gmtObjMap, event, static_cast<const CommonTokens*>(toks)->getMuonShowerToken());
}

Expand Down
Loading

0 comments on commit 912d918

Please sign in to comment.