diff --git a/DataFormats/L1TParticleFlow/interface/PFTau.h b/DataFormats/L1TParticleFlow/interface/PFTau.h index bce146d69a21e..3cd18553ee6ae 100644 --- a/DataFormats/L1TParticleFlow/interface/PFTau.h +++ b/DataFormats/L1TParticleFlow/interface/PFTau.h @@ -4,6 +4,8 @@ #include #include #include "DataFormats/L1Trigger/interface/L1Candidate.h" +#include "DataFormats/L1TParticleFlow/interface/taus.h" +#include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h" namespace l1t { @@ -72,12 +74,28 @@ namespace l1t { } bool passTightPF() const { return fullIso_ < PFTAU_PF_TIGHT_CUT; } + void set_encodedTau(std::array encodedTau){ + encodedTau_ = encodedTau; + } + std::array 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; + } + + l1gt::Tau getTauGT() const { return TauGT_; } + private: float NNValues_[80]; float iso_; float fullIso_; int id_; float dxy_; + std::array encodedTau_; + l1gt::Tau TauGT_; }; typedef std::vector PFTauCollection; diff --git a/DataFormats/L1TParticleFlow/interface/gt_datatypes.h b/DataFormats/L1TParticleFlow/interface/gt_datatypes.h index 12cec406492f7..d4d0ec3f5e4af 100644 --- a/DataFormats/L1TParticleFlow/interface/gt_datatypes.h +++ b/DataFormats/L1TParticleFlow/interface/gt_datatypes.h @@ -35,6 +35,7 @@ namespace l1gt { // tau fields typedef ap_ufixed<10, 8> tauseed_pt_t; + typedef ap_uint<10> tau_rawid_t; namespace Scales { const int INTPHI_PI = 1 << (phi_t::width - 1); @@ -185,12 +186,12 @@ namespace l1gt { z0_t seed_z0; ap_uint<1> charge; ap_uint<2> type; - iso_t isolation; + tau_rawid_t isolation; ap_uint<2> id0; ap_uint<2> id1; static const int BITWIDTH = 128; - inline ap_uint pack() const { + inline ap_uint pack_ap() const { ap_uint ret; unsigned int start = 0; pack_into_bits(ret, start, valid); @@ -204,6 +205,15 @@ namespace l1gt { pack_into_bits(ret, start, id1); return ret; } + + inline std::array pack() const { + std::array packed; + ap_uint bits = this->pack_ap(); + packed[0] = bits(63, 0); + packed[1] = bits(127, 64); + return packed; + } + }; // struct Tau struct Electron { diff --git a/DataFormats/L1TParticleFlow/src/classes_def.xml b/DataFormats/L1TParticleFlow/src/classes_def.xml index 751de29f934ed..f642b2572d6d3 100644 --- a/DataFormats/L1TParticleFlow/src/classes_def.xml +++ b/DataFormats/L1TParticleFlow/src/classes_def.xml @@ -45,7 +45,7 @@ - + diff --git a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc index 382c97b67a6a2..e06dc3ec25a7d 100644 --- a/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc +++ b/L1Trigger/Phase2L1ParticleFlow/plugins/L1NNTauProducer.cc @@ -43,9 +43,6 @@ class L1NNTauProducer : public edm::stream::EDProducer& outputTaus); - void printParts(std::vector& parts); - - void printTau(uint32_t& iPt, uint32_t& iEta, uint32_t& iPhi, uint32_t& iNN); double fSeedPt_; double fConeSize_; double fTauSize_; @@ -273,10 +270,32 @@ void L1NNTauProducer::makeTau_HW(const l1t::PFCandidate& seed, L1TauEmu::etaphi_t phi = etaphi_t(seed.phi() * L1TauEmu::etaphi_base); math::PtEtaPhiMLorentzVector tempP4( float(pt), float(eta) / L1TauEmu::etaphi_base, float(phi) / L1TauEmu::etaphi_base, float(mass)); + + //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 + 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.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. + + //Convert to GT format and pack to encodedTau of PFTau + l1gt::Tau l1gtTau = l1ctTau.toGT(); + std::array packed_Tau = l1gtTau.pack(); + + l1PFTau.set_TauGT(l1gtTau); + l1PFTau.set_encodedTau(packed_Tau); + iTaus->push_back(l1PFTau); }