Skip to content

Commit

Permalink
Formating new GT codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Duchstf authored Apr 16, 2023
2 parents 741f236 + 3dcd0ec commit 7c2e09f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
12 changes: 4 additions & 8 deletions DataFormats/L1TParticleFlow/interface/PFTau.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,14 @@ namespace l1t {
}
bool passTightPF() const { return fullIso_ < PFTAU_PF_TIGHT_CUT; }

void set_encodedTau(std::array<uint64_t, 2> encodedTau){
encodedTau_ = encodedTau;
}
std::array<uint64_t, 2> encodedTau() const {return encodedTau_; }
void set_encodedTau(std::array<uint64_t, 2> encodedTau) { encodedTau_ = encodedTau; }
std::array<uint64_t, 2> encodedTau() const { return encodedTau_; }

//l1gt::Tau getHWTauGT() const { return l1ct::Tau::unpack_gt(encodedTau_); }

//Return the l1gt Tau object for now
void set_TauGT(l1gt::Tau TauGT){
TauGT_ = TauGT;
}

void set_TauGT(l1gt::Tau TauGT) { TauGT_ = TauGT; }

l1gt::Tau getTauGT() const { return TauGT_; }

private:
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 @@ -213,7 +213,7 @@ namespace l1gt {
packed[1] = bits(127, 64);
return packed;
}

}; // struct Tau

struct Electron {
Expand Down
19 changes: 19 additions & 0 deletions DataFormats/L1TParticleFlow/interface/taus.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "DataFormats/L1TParticleFlow/interface/datatypes.h"
#include "DataFormats/L1TParticleFlow/interface/bit_encoding.h"
#include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h"

namespace l1ct {

Expand Down Expand Up @@ -87,6 +88,7 @@ namespace l1ct {
pack_into_bits(ret, start, hwIsoOrMVA);
return ret;
}

inline static Tau unpack(const ap_uint<BITWIDTH> &src) {
Tau ret;
unsigned int start = 0;
Expand All @@ -102,6 +104,23 @@ namespace l1ct {
unpack_from_bits(src, start, ret.hwIsoOrMVA);
return ret;
}

l1gt::Tau toGT() const {
l1gt::Tau t;
t.valid = hwPt != 0;

t.v3.pt = CTtoGT_pt(hwPt);
t.v3.phi = CTtoGT_phi(hwPhi);
t.v3.eta = CTtoGT_eta(hwEta);

t.seed_pt = hwSeedPt;
t.seed_z0 = hwSeedZ0;
t.charge = hwCharge;

t.type = hwType;
t.isolation = hwRawId;
return t;
}
};

inline void clear(Tau &c) { c.clear(); }
Expand Down
16 changes: 8 additions & 8 deletions L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,31 +271,31 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed,
math::PtEtaPhiMLorentzVector tempP4(
float(pt), float(eta) / L1TauEmu::etaphi_base, float(phi) / L1TauEmu::etaphi_base, float(mass));

//Make
//Make
l1t::PFTau l1PFTau(tempP4, pNNVec, NN, 0, lId);
l1PFTau.setZ0(float(z0) * 0.05); //L1TauEmu::z0_base);
l1PFTau.setDxy(float(dxy) * 0.05); //L1TauEmu::dxy_base);

//Firmware Tau
//Firmware Tau
l1ct::Tau l1ctTau;
l1ctTau.hwPt = l1ct::pt_t(pt); //l1gt is <16,11> and currently <16,14>
l1ctTau.hwEta = l1ct::eta_t(seed.eta()/l1ct::Scales::ETAPHI_LSB);
l1ctTau.hwPhi = l1ct::phi_t(seed.phi()/l1ct::Scales::ETAPHI_LSB);
l1ctTau.hwPt = l1ct::pt_t(pt); //l1gt is <16,11> and currently <16,14>
l1ctTau.hwEta = l1ct::eta_t(seed.eta() / l1ct::Scales::ETAPHI_LSB);
l1ctTau.hwPhi = l1ct::phi_t(seed.phi() / l1ct::Scales::ETAPHI_LSB);

l1ctTau.hwSeedPt = seed.pt();
l1ctTau.hwSeedZ0 = seed.hwZ0();
l1ctTau.hwCharge = seed.charge();

l1ctTau.hwType = l1ct::Tau::type_t(lId);
l1ctTau.hwRawId = ap_uint<10>(NN*1024); //NN Output is ap_fixed<16, 8> so need to cast.
l1ctTau.hwRawId = ap_uint<10>(NN * 1024); //NN Output is ap_fixed<16, 8> so need to cast.

//Convert to GT format and pack to encodedTau of PFTau
l1gt::Tau l1gtTau = l1ctTau.toGT();
std::array<uint64_t, 2> packed_Tau = l1gtTau.pack();

l1PFTau.set_TauGT(l1gtTau);
l1PFTau.set_encodedTau(packed_Tau);

iTaus->push_back(l1PFTau);
}

Expand Down

0 comments on commit 7c2e09f

Please sign in to comment.