Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions L1Trigger/Phase2L1ParticleFlow/interface/taus/TauNNIdHW.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@

#include <cstdio>
#include <complex>
#include <memory>

#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/tau_parameters.h"
#include "L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h"
#include "ap_fixed.h"
#include "ap_int.h"
#include "hls4ml/emulator.h"

#include "DataFormats/L1TParticleFlow/interface/layer1_emulator.h"
#include "DataFormats/L1TParticleFlow/interface/PFCandidate.h"

typedef ap_ufixed<16, 14> pt_t;
typedef ap_fixed<10, 4> etaphi_t;

// Tau NN returns two values
struct Tau_NN_Result {
result_t nn_pt_correction;
result_t nn_id;
};

namespace L1TauEmu {
// Input/output precision of the NNPuppiTauModel hls4ml network, matching the
// model's defines.h (kept here since the weights/layer code now live in the
// externally-built NNPuppiTauModel package, not in-tree). Named distinctively
// (not input_t/result_t) and namespaced to avoid clashing with the generic
// typedefs other hls4ml model headers define at global scope.
typedef ap_fixed<16, 10> tauinput_t;
typedef ap_fixed<16, 6> tauresult_t;

// Data types and constants used in the FPGA and FPGA-optimized functions
//etaphi_base maps physical eta phi units onto bits
//This way, the least significant bit of etaphi_t is exactly 0.01
Expand Down Expand Up @@ -132,14 +136,20 @@ namespace L1TauEmu {

}; // namespace L1TauEmu

// Tau NN returns two values
struct Tau_NN_Result {
L1TauEmu::tauresult_t nn_pt_correction;
L1TauEmu::tauresult_t nn_id;
};

class TauNNIdHW {
public:
TauNNIdHW();
~TauNNIdHW();
TauNNIdHW(const std::shared_ptr<hls4mlEmulator::Model> model);
~TauNNIdHW() = default;

void initialize(const std::string &iName, int iNParticles);
void SetNNVectorVar();
input_t *NNVectorVar() { return NNvectorVar_.data(); }
L1TauEmu::tauinput_t *NNVectorVar() { return NNvectorVar_.data(); }
Tau_NN_Result EvaluateNN();
Tau_NN_Result compute(const l1t::PFCandidate &iSeed, std::vector<l1t::PFCandidate> &iParts);
//void print();
Expand All @@ -153,7 +163,8 @@ class TauNNIdHW {
//FILE *file_;

private:
std::vector<input_t> NNvectorVar_;
std::vector<L1TauEmu::tauinput_t> NNvectorVar_;
std::shared_ptr<hls4mlEmulator::Model> modelRef_;
};

#endif
70 changes: 0 additions & 70 deletions L1Trigger/Phase2L1ParticleFlow/interface/taus/defines.h

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading