CMS 3D CMS Logo

JetId.h
Go to the documentation of this file.
1 #ifndef L1TRIGGER_PHASE2L1PARTICLEFLOWS_JETID_H
2 #define L1TRIGGER_PHASE2L1PARTICLEFLOWS_JETID_H
3 
4 #include <string>
8 
9 //HLS4ML compiled emulator modeling
10 #include <string>
11 #include "ap_fixed.h"
12 #include "hls4ml/emulator.h"
13 
14 struct BJetTFCache {
17  }
19  std::unique_ptr<tensorflow::GraphDef> graphDef;
20  tensorflow::Session *session;
21 };
22 
23 class JetId {
24 public:
25  JetId(const std::string &iInput,
26  const std::string &iOutput,
27  const std::shared_ptr<hls4mlEmulator::Model> model,
28  int iNParticles);
29  JetId(const std::string &iInput, const std::string &iOutput, const BJetTFCache *cache, int iNParticles);
30  ~JetId() = default;
31 
32  void setNNVectorVar();
33  float EvaluateNN();
34  ap_fixed<16, 6> EvaluateNNFixed();
35  float compute(const l1t::PFJet &iJet, float vz, bool useRawPt);
36  ap_fixed<16, 6> computeFixed(const l1t::PFJet &iJet, float vz, bool useRawPt);
37 
38 private:
39  std::vector<float> NNvectorVar_;
43  unique_ptr<float[]> fPt_;
44  unique_ptr<float[]> fEta_;
45  unique_ptr<float[]> fPhi_;
46  unique_ptr<float[]> fId_;
47  unique_ptr<int[]> fCharge_;
48  unique_ptr<float[]> fDZ_;
49  unique_ptr<float[]> fDX_;
50  unique_ptr<float[]> fDY_;
51  tensorflow::Session *sessionRef_;
52  std::shared_ptr<hls4mlEmulator::Model> modelRef_;
53 };
54 #endif
ap_fixed< 16, 6 > EvaluateNNFixed()
Definition: JetId.cc:76
unique_ptr< float[]> fDZ_
Definition: JetId.h:48
unique_ptr< float[]> fId_
Definition: JetId.h:46
Definition: JetId.h:23
unique_ptr< float[]> fDX_
Definition: JetId.h:49
ap_fixed< 16, 6 > computeFixed(const l1t::PFJet &iJet, float vz, bool useRawPt)
Definition: JetId.cc:124
GraphDef * loadGraphDef(const std::string &pbFile)
Definition: TensorFlow.cc:129
JetId(const std::string &iInput, const std::string &iOutput, const std::shared_ptr< hls4mlEmulator::Model > model, int iNParticles)
Definition: JetId.cc:5
std::unique_ptr< tensorflow::GraphDef > graphDef
Definition: JetId.h:19
std::vector< float > NNvectorVar_
Definition: JetId.h:39
float compute(const l1t::PFJet &iJet, float vz, bool useRawPt)
Definition: JetId.cc:90
std::string fInput_
Definition: JetId.h:40
void setNNVectorVar()
Definition: JetId.cc:43
unique_ptr< float[]> fPhi_
Definition: JetId.h:45
unique_ptr< float[]> fEta_
Definition: JetId.h:44
bool closeSession(Session *&session)
Definition: TensorFlow.cc:243
Session * createSession()
Definition: TensorFlow.cc:146
std::string fOutput_
Definition: JetId.h:41
unique_ptr< int[]> fCharge_
Definition: JetId.h:47
BJetTFCache(const std::string &graphPath)
Definition: JetId.h:15
float EvaluateNN()
Definition: JetId.cc:66
unique_ptr< float[]> fPt_
Definition: JetId.h:43
tensorflow::Session * session
Definition: JetId.h:20
~JetId()=default
unique_ptr< float[]> fDY_
Definition: JetId.h:50
def cache(function)
Definition: utilities.py:3
std::shared_ptr< hls4mlEmulator::Model > modelRef_
Definition: JetId.h:52
tensorflow::Session * sessionRef_
Definition: JetId.h:51
~BJetTFCache()
Definition: JetId.h:18
int fNParticles_
Definition: JetId.h:42