Skip to content

Commit

Permalink
Merge l1t-phase2-v64
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetruc committed May 24, 2023
2 parents 3aa9d3c + 79a60e3 commit 17743fc
Show file tree
Hide file tree
Showing 72 changed files with 2,094 additions and 1,547 deletions.
4 changes: 3 additions & 1 deletion DataFormats/L1TCorrelator/interface/TkElectron.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ namespace l1t {

float trkzVtx() const { return trkzVtx_; }
double trackCurvature() const { return trackCurvature_; }

float idScore() const { return idScore_; }
// ---------- member functions ---------------------------

void setTrkzVtx(float TrkzVtx) { trkzVtx_ = TrkzVtx; }
void setTrackCurvature(double trackCurvature) { trackCurvature_ = trackCurvature; }
void setIdScore(float score) { idScore_ = score; }

private:
edm::Ptr<L1TTTrackType> trkPtr_;
float trkzVtx_;
double trackCurvature_;
float idScore_;
};
} // namespace l1t
#endif
3 changes: 2 additions & 1 deletion DataFormats/L1TCorrelator/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
<class name="edm::Wrapper<std::vector<l1t::L1CaloTkTau> >"/>
<class name="edm::Ref<std::vector<l1t::L1CaloTkTau>,l1t::L1CaloTkTau,edm::refhelper::FindUsingAdvance<std::vector<l1t::L1CaloTkTau>,l1t::L1CaloTkTau> >"/>

<class name="l1t::TkElectron" ClassVersion="5">
<class name="l1t::TkElectron" ClassVersion="6">
<version ClassVersion="6" checksum="3899336964"/>
<version ClassVersion="5" checksum="965807884"/>
<version ClassVersion="4" checksum="3922083203"/>
<version ClassVersion="3" checksum="3970647299"/>
Expand Down
46 changes: 38 additions & 8 deletions DataFormats/L1TMuonPhase2/interface/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,32 @@ namespace Phase2L1GMT {
// Bitwidth for standalone muons to CL1 and GT
const int BITSSAZ0 = 5;
const int BITSSAD0 = 7;
const int BITSSAQUALITY = 4;
const int BITSSAQUAL = 4;

// Bitwidth for dataformat to GT
const int BITSGTPT = 16;
const int BITSGTPHI = 13;
const int BITSGTETA = 14;
const int BITSGTZ0 = 10;
const int BITSGTD0 = 10;
const int BITSGTQUALITY = 8;
const int BITSGTQUAL = 8;
const int BITSGTISO = 4;
const int BITSGTBETA = 4;

// Bitwidth for Tau->3mu object
const int BITSTMPT = 8;
const int BITSTMPHI = 8;
const int BITSTMETA = 8;
const int BITSTMMASS2 = 8;
const int BITSTMTYPE = 6;
const int BITSTMIDX = 4;
const int BITSTMQUAL = 4;

const float maxCurv_ = 0.00855; // 2 GeV pT Rinv is in cm
const float maxPhi_ = 1.026; // relative to the center of the sector
const float maxTanl_ = 8.0;
const float maxZ0_ = 30.;
const float maxD0_ = 15.4;
const float maxZ0_ = 25.6;
const float maxD0_ = 15.36;
// Updated barrelLimit according to Karol, https://indico.cern.ch/event/1113802/#1-phase2-gmt-performance-and-i
const int barrelLimit0_ = 1.4 / 0.00076699039 / 8;
const int barrelLimit1_ = 1.1 / 0.00076699039 / 8;
Expand All @@ -81,12 +91,32 @@ namespace Phase2L1GMT {
const float LSBpt = 0.03125;
const float LSBphi = 2. * M_PI / pow(2, BITSPHI);
const float LSBeta = 2. * M_PI / pow(2, BITSETA);
const float LSBGTz0 = 2. * maxZ0_ / pow(2, BITSZ0);
const float LSBGTd0 = 2. * maxD0_ / pow(2, BITSD0);
const float LSBSAz0 = 1.875;
const float LSBSAd0 = 3.85;
const float LSBGTz0 = 0.05; // 0.5mm, in sync with GTT and Correlator
const float LSBGTd0 = 0.03; // from GT interface doc
const float LSBSAz0 = 1.6; // 0.05 * 32 cm, with range +- 25.6
const float LSBSAd0 = 3.84; // 0.03 * 128 cm, with range +- 245.76

typedef ap_uint<64> wordtype;
typedef ap_uint<1> valid_gt_t; //valid
typedef ap_uint<1> q_gt_t; //charge
typedef ap_uint<BITSGTPT> pt_gt_t; //pt of tracker muon
typedef ap_int<BITSGTPHI> phi_gt_t; //phi of tracker muon
typedef ap_int<BITSGTETA> eta_gt_t; //eta of tracker muon
typedef ap_int<BITSGTZ0> z0_gt_t; //z0 of tracker muon
typedef ap_int<BITSGTD0> d0_gt_t; //d0 of tracker muon
typedef ap_uint<BITSGTISO> iso_gt_t; //isolation of tracker muon
typedef ap_uint<BITSGTBETA> beta_gt_t; //beta of tracker muon
typedef ap_uint<BITSGTQUAL> qual_gt_t; //quality of tracker muon

//Standalone muon datatype
typedef ap_uint<1> valid_sa_t; //valid
typedef ap_uint<BITSGTPT> pt_sa_t; //pt of standalone muon
typedef ap_int<BITSGTPHI> phi_sa_t; //phi of standalone muon
typedef ap_int<BITSGTETA> eta_sa_t; //eta of standalone muon
typedef ap_int<BITSSAZ0> z0_sa_t; //z0 of standalone muon
typedef ap_int<BITSSAD0> d0_sa_t; //d0 of standalone muon
typedef ap_uint<1> q_sa_t; //charge of standalone muon
typedef ap_uint<BITSSAQUAL> qual_sa_t; //quality of standalone muon

inline uint64_t twos_complement(long long int v, uint bits) {
uint64_t mask = (1 << bits) - 1;
Expand Down
10 changes: 10 additions & 0 deletions DataFormats/L1TMuonPhase2/interface/SAMuon.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ namespace l1t {
const uint hwBeta() const { return hwBeta_; }
void setBeta(uint beta) { hwBeta_ = beta; }

// For GT, returning ap_ type
const Phase2L1GMT::valid_sa_t apValid() const { return Phase2L1GMT::valid_sa_t(hwPt() > 0); };
const Phase2L1GMT::pt_sa_t apPt() const { return Phase2L1GMT::pt_sa_t(hwPt()); };
const Phase2L1GMT::phi_sa_t apPhi() const { return Phase2L1GMT::phi_sa_t(hwPhi()); };
const Phase2L1GMT::eta_sa_t apEta() const { return Phase2L1GMT::eta_sa_t(hwEta()); };
const Phase2L1GMT::z0_sa_t apZ0() const { return Phase2L1GMT::z0_sa_t(hwZ0()); };
const Phase2L1GMT::d0_sa_t apD0() const { return Phase2L1GMT::d0_sa_t(hwD0()); };
const Phase2L1GMT::q_sa_t apCharge() const { return Phase2L1GMT::q_sa_t(hwCharge()); };
const Phase2L1GMT::qual_sa_t apQual() const { return Phase2L1GMT::qual_sa_t(hwQual()); };

// For HLT
const double phZ0() const { return Phase2L1GMT::LSBSAz0 * hwZ0(); }
const double phD0() const { return Phase2L1GMT::LSBSAd0 * hwD0(); }
Expand Down
18 changes: 15 additions & 3 deletions DataFormats/L1TMuonPhase2/interface/TrackerMuon.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace l1t {
~TrackerMuon() override;

const edm::Ptr<L1TTTrackType>& trkPtr() const { return trkPtr_; }
const edm::Ref<l1t::RegionalMuonCandBxCollection>& muonRef() const { return muRef_; }
const std::vector<l1t::RegionalMuonCandRef>& muonRef() const { return muRef_; }

const bool hwCharge() const { return hwCharge_; }
const int hwZ0() const { return hwZ0_; }
Expand All @@ -41,10 +41,22 @@ namespace l1t {
const int hwIsoSumAp() const { return hwIsoSumAp_; }
const uint hwBeta() const { return hwBeta_; }
void setBeta(uint beta) { hwBeta_ = beta; }
void setMuonRef(const edm::Ref<l1t::RegionalMuonCandBxCollection>& p) { muRef_ = p; }
void setMuonRef(const std::vector<l1t::RegionalMuonCandRef>& p) { muRef_ = p; }
void setHwIsoSum(int isoSum) { hwIsoSum_ = isoSum; }
void setHwIsoSumAp(int isoSum) { hwIsoSumAp_ = isoSum; }

// For GT, returning ap_ type
const Phase2L1GMT::valid_gt_t apValid() const { return Phase2L1GMT::valid_gt_t(hwPt() > 0); };
const Phase2L1GMT::pt_gt_t apPt() const { return Phase2L1GMT::pt_gt_t(hwPt()); };
const Phase2L1GMT::phi_gt_t apPhi() const { return Phase2L1GMT::phi_gt_t(hwPhi()); };
const Phase2L1GMT::eta_gt_t apEta() const { return Phase2L1GMT::eta_gt_t(hwEta()); };
const Phase2L1GMT::z0_gt_t apZ0() const { return Phase2L1GMT::z0_gt_t(hwZ0()); };
const Phase2L1GMT::d0_gt_t apD0() const { return Phase2L1GMT::d0_gt_t(hwD0()); };
const Phase2L1GMT::q_gt_t apCharge() const { return Phase2L1GMT::q_gt_t(hwCharge()); };
const Phase2L1GMT::qual_gt_t apQual() const { return Phase2L1GMT::qual_gt_t(hwQual()); };
const Phase2L1GMT::iso_gt_t apIso() const { return Phase2L1GMT::iso_gt_t(hwIso()); };
const Phase2L1GMT::beta_gt_t apBeta() const { return Phase2L1GMT::beta_gt_t(hwBeta()); };

// For HLT
const double phZ0() const { return Phase2L1GMT::LSBGTz0 * hwZ0(); }
const double phD0() const { return Phase2L1GMT::LSBGTd0 * hwD0(); }
Expand Down Expand Up @@ -76,7 +88,7 @@ namespace l1t {
//Store the eneryg sum for isolation with ap_type
int hwIsoSumAp_;

edm::Ref<l1t::RegionalMuonCandBxCollection> muRef_;
std::vector<l1t::RegionalMuonCandRef> muRef_;
MuonStubRefVector stubs_;
};
} // namespace l1t
Expand Down
3 changes: 2 additions & 1 deletion DataFormats/L1TMuonPhase2/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<class name="edm::Wrapper<std::vector<l1t::MuonStub > >"/>
<class name="edm::Ref<l1t::MuonStubCollection>" splitLevel="0"/>

<class name="l1t::TrackerMuon" ClassVersion="3">
<class name="l1t::TrackerMuon" ClassVersion="4">
<version ClassVersion="4" checksum="3437073036"/>
<version ClassVersion="3" checksum="2397458791"/>
</class>
<class name="std::vector<l1t::TrackerMuon>"/>
Expand Down
6 changes: 5 additions & 1 deletion DataFormats/L1TParticleFlow/interface/PFCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ namespace l1t {

void setZ0(float z0) { setVertex(reco::Particle::Point(0, 0, z0)); }
void setDxy(float dxy) { dxy_ = dxy; }
void setCaloEta(float caloeta) { caloEta_ = caloeta; }
void setCaloPhi(float calophi) { caloPhi_ = calophi; }

float z0() const { return vz(); }
float dxy() const { return dxy_; }
float caloEta() const { return caloEta_; }
float caloPhi() const { return caloPhi_; }

int16_t hwZ0() const { return hwZ0_; }
int16_t hwDxy() const { return hwDxy_; }
Expand All @@ -70,7 +74,7 @@ namespace l1t {
PFClusterRef clusterRef_;
PFTrackRef trackRef_;
MuonRef muonRef_;
float dxy_, puppiWeight_;
float dxy_, puppiWeight_, caloEta_, caloPhi_;

int16_t hwZ0_, hwDxy_;
uint16_t hwTkQuality_, hwPuppiWeight_, hwEmID_;
Expand Down
17 changes: 15 additions & 2 deletions DataFormats/L1TParticleFlow/interface/PFCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ namespace l1t {
float ptError = 0,
int hwpt = 0,
int hweta = 0,
int hwphi = 0)
int hwphi = 0,
float absZBarycenter = 0.,
float sigmaRR = 0.)
: L1Candidate(PolarLorentzVector(pt, eta, phi, 0), hwpt, hweta, hwphi, /*hwQuality=*/isEM ? 1 : 0),
hOverE_(hOverE),
ptError_(ptError) {
ptError_(ptError),
absZBarycenter_(absZBarycenter),
sigmaRR_(sigmaRR) {
setPdgId(isEM ? 22 : 130); // photon : non-photon(K0)
}
PFCluster(
Expand All @@ -37,6 +41,12 @@ namespace l1t {
float hOverE() const { return hOverE_; }
void setHOverE(float hOverE) { hOverE_ = hOverE; }

void setSigmaRR(float sigmaRR) { sigmaRR_ = sigmaRR; }
float absZBarycenter() const { return absZBarycenter_; }

void setAbsZBarycenter(float absZBarycenter) { absZBarycenter_ = absZBarycenter; }
float sigmaRR() const { return sigmaRR_; }

float emEt() const {
if (hOverE_ == -1)
return 0;
Expand Down Expand Up @@ -68,6 +78,9 @@ namespace l1t {

private:
float hOverE_, ptError_, egVsPionMVAOut_, egVsPUMVAOut_;
// HGC dedicated quantities (0ed by default)
float absZBarycenter_, sigmaRR_;

ConstituentsAndFractions constituents_;
};

Expand Down
19 changes: 16 additions & 3 deletions DataFormats/L1TParticleFlow/interface/PFJet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/L1TParticleFlow/interface/PFCandidate.h"
#include "DataFormats/Common/interface/Ptr.h"
#include "DataFormats/L1TParticleFlow/interface/jets.h"
#include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h"

namespace l1t {

Expand Down Expand Up @@ -38,13 +40,24 @@ namespace l1t {
edm::Ptr<l1t::PFCandidate> daughterPtr(size_type i) const { return constituents_[i]; }

// Get and set the encodedJet_ bits. The Jet is encoded in 128 bits as a 2-element array of uint64_t
std::array<uint64_t, 2> encodedJet() { return encodedJet_; }
void setEncodedJet(std::array<uint64_t, 2> jet) { encodedJet_ = jet; }
// We store encodings both for Correlator internal usage and for Global Trigger
enum class HWEncoding { CT, GT };
typedef std::array<uint64_t, 2> PackedJet;
const PackedJet& encodedJet(const HWEncoding encoding = HWEncoding::GT) const {
return encodedJet_[static_cast<int>(encoding)];
}
void setEncodedJet(const HWEncoding encoding, const PackedJet jet) {
encodedJet_[static_cast<int>(encoding)] = jet;
}

// Accessors to HW objects with ap_* types from encoded words
l1gt::Jet getHWJetGT() const { return l1gt::Jet::unpack(encodedJet(HWEncoding::GT)); }
l1ct::Jet getHWJetCT() const { return l1ct::Jet::unpack(encodedJet(HWEncoding::CT)); }

private:
float rawPt_;
Constituents constituents_;
std::array<uint64_t, 2> encodedJet_ = {{0, 0}};
std::array<PackedJet, 2> encodedJet_ = {{{{0, 0}}, {{0, 0}}}};
};

typedef std::vector<l1t::PFJet> PFJetCollection;
Expand Down
30 changes: 30 additions & 0 deletions DataFormats/L1TParticleFlow/interface/bit_encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,34 @@ inline void l1pf_pattern_unpack(const ap_uint<NB> data[], T objs[N]) {
}
}

template <unsigned int N, unsigned int OFFS = 0, typename T, int NB>
inline void l1pf_pattern_pack_slim(const T objs[N], ap_uint<NB> data[]) {
#ifdef __SYNTHESIS__
#pragma HLS inline
#pragma HLS inline region recursive
#endif
assert(T::BITWIDTH_SLIM <= NB);
for (unsigned int i = 0; i < N; ++i) {
#ifdef __SYNTHESIS__
#pragma HLS unroll
#endif
data[i + OFFS] = objs[i].pack_slim();
}
}

template <unsigned int N, unsigned int OFFS = 0, typename T, int NB>
inline void l1pf_pattern_unpack_slim(const ap_uint<NB> data[], T objs[N]) {
#ifdef __SYNTHESIS__
#pragma HLS inline
#pragma HLS inline region recursive
#endif
assert(T::BITWIDTH_SLIM <= NB);
for (unsigned int i = 0; i < N; ++i) {
#ifdef __SYNTHESIS__
#pragma HLS unroll
#endif
objs[i] = T::unpack(data[i + OFFS]);
}
}

#endif
17 changes: 17 additions & 0 deletions DataFormats/L1TParticleFlow/interface/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ namespace l1ct {
typedef ap_uint<10> em2calo_dr_t;
typedef ap_uint<13> tk2calo_dq_t;
typedef ap_uint<4> egquality_t;
typedef ap_uint<3> stub_t;
typedef ap_ufixed<10, 1, AP_TRN, AP_SAT> srrtot_t;
typedef ap_uint<8> meanz_t; // mean - MEANZ_OFFSET(= 320 cm)
typedef ap_ufixed<10, 5, AP_TRN, AP_SAT> hoe_t;
typedef ap_uint<4> redChi2Bin_t;

// FIXME: adjust range 10-11bits -> 1/4 - 1/2TeV is probably more than enough for all reasonable use cases
typedef ap_ufixed<11, 9, AP_TRN, AP_SAT> iso_t;

Expand Down Expand Up @@ -149,6 +155,11 @@ namespace l1ct {
constexpr float Z0_LSB = 0.05;
constexpr float DXY_LSB = 0.05;
constexpr float PUPPIW_LSB = 1.0 / 256;
constexpr float MEANZ_OFFSET = 320.;
constexpr float SRRTOT_LSB = 0.0019531250; // pow(2, -9)
constexpr unsigned int SRRTOT_SCALE = 64; // pow(2, 6)
constexpr float HOE_LSB = 0.031250000; // pow(2, -5)

inline float floatPt(pt_t pt) { return pt.to_float(); }
inline float floatPt(dpt_t pt) { return pt.to_float(); }
inline float floatPt(pt2_t pt2) { return pt2.to_float(); }
Expand All @@ -164,6 +175,9 @@ namespace l1ct {
inline float floatDxy(dxy_t dxy) { return dxy.to_float() * DXY_LSB; }
inline float floatPuppiW(puppiWgt_t puppiw) { return puppiw.to_float() * PUPPIW_LSB; }
inline float floatIso(iso_t iso) { return iso.to_float(); }
inline float floatSrrTot(srrtot_t srrtot) { return srrtot.to_float() / SRRTOT_SCALE; };
inline float floatMeanZ(meanz_t meanz) { return meanz + MEANZ_OFFSET; };
inline float floatHoe(hoe_t hoe) { return hoe.to_float(); };

inline pt_t makePt(int pt) { return ap_ufixed<16, 14>(pt) >> 2; }
inline dpt_t makeDPt(int dpt) { return ap_fixed<18, 16>(dpt) >> 2; }
Expand Down Expand Up @@ -194,6 +208,9 @@ namespace l1ct {
inline iso_t makeIso(float iso) { return iso_t(0.25 * round(iso * 4)); }

inline int makeDR2FromFloatDR(float dr) { return ceil(dr * dr / ETAPHI_LSB / ETAPHI_LSB); }
inline srrtot_t makeSrrTot(float var) { return srrtot_t(SRRTOT_LSB * round(var * SRRTOT_SCALE / SRRTOT_LSB)); };
inline meanz_t makeMeanZ(float var) { return round(var - MEANZ_OFFSET); };
inline hoe_t makeHoe(float var) { return hoe_t(HOE_LSB * round(var / HOE_LSB)); };

inline float maxAbsEta() { return ((1 << (eta_t::width - 1)) - 1) * ETAPHI_LSB; }
inline float maxAbsPhi() { return ((1 << (phi_t::width - 1)) - 1) * ETAPHI_LSB; }
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1TParticleFlow/interface/gt_datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace l1gt {
typedef ap_uint<1> valid_t;

// E/gamma fields
typedef ap_fixed<11, 9> iso_t;
typedef ap_ufixed<11, 9> iso_t;
typedef ap_uint<4> egquality_t;

// tau fields
Expand Down
Loading

0 comments on commit 17743fc

Please sign in to comment.