22 #include "hls4ml/emulator.h" 59 m_gtAXOL1TLTemplate =
cp.gtAXOL1TLTemplate();
62 m_condMaxNumberObjects =
cp.condMaxNumberObjects();
63 m_condLastResult =
cp.condLastResult();
64 m_combinationsInCond =
cp.getCombinationsInCond();
66 m_verbosity =
cp.m_verbosity;
89 bool condResult =
false;
90 int useBx = bxEval + m_gtAXOL1TLTemplate->condRelativeBx();
93 std::string AXOL1TLmodelversion = m_AXOL1TLmodelversion;
94 hls4mlEmulator::ModelLoader
loader(AXOL1TLmodelversion);
95 std::shared_ptr<hls4mlEmulator::Model>
model;
97 cout <<
"loading model... " << AXOL1TLmodelversion << std::endl;
105 const int NMuons = 4;
106 const int NJets = 10;
107 const int NEgammas = 4;
111 const int MuVecSize = 12;
112 const int JVecSize = 30;
113 const int EGVecSize = 12;
114 const int EtSumVecSize = 3;
117 const int NInputs = 57;
120 ap_fixed<18, 13> fillzero = 0.0;
123 ap_fixed<18, 13> ADModelInput[NInputs] = {};
126 ap_fixed<18, 13> MuInput[MuVecSize];
127 ap_fixed<18, 13> JetInput[JVecSize];
128 ap_fixed<18, 13> EgammaInput[EGVecSize];
129 ap_fixed<18, 13> EtSumInput[EtSumVecSize];
132 std::array<ap_fixed<10, 7>, 13>
result;
133 ap_ufixed<18, 14> loss;
134 std::pair<std::array<ap_fixed<10, 7>, 13>, ap_ufixed<18, 14>>
139 int NCandMu = candMuVec->
size(useBx);
140 int NCandJet = candJetVec->
size(useBx);
141 int NCandEG = candEGVec->
size(useBx);
142 int NCandEtSum = candEtSumVec->
size(useBx);
145 std::fill(EtSumInput, EtSumInput + EtSumVecSize, fillzero);
146 std::fill(MuInput, MuInput + MuVecSize, fillzero);
147 std::fill(JetInput, JetInput + JVecSize, fillzero);
148 std::fill(EgammaInput, EgammaInput + EGVecSize, fillzero);
149 std::fill(ADModelInput, ADModelInput + NInputs, fillzero);
154 if (NCandEtSum > 0) {
155 for (
int iEtSum = 0; iEtSum < NCandEtSum; iEtSum++) {
158 ((candEtSumVec->
at(useBx, iEtSum))->
hwPt()) / 2;
160 EtSumInput[2] = (candEtSumVec->
at(useBx, iEtSum))->
hwPhi();
167 for (
int iEG = 0; iEG < NCandEG; iEG++) {
168 if (iEG < NEgammas) {
169 EgammaInput[0 + (3 * iEG)] = ((candEGVec->
at(useBx, iEG))->
hwPt()) /
171 EgammaInput[1 + (3 * iEG)] = (candEGVec->
at(useBx, iEG))->
hwEta();
172 EgammaInput[2 + (3 * iEG)] = (candEGVec->
at(useBx, iEG))->
hwPhi();
179 for (
int iMu = 0; iMu < NCandMu; iMu++) {
181 MuInput[0 + (3 * iMu)] = ((candMuVec->
at(useBx, iMu))->
hwPt()) /
183 MuInput[1 + (3 * iMu)] = (candMuVec->
at(useBx, iMu))->
hwEta();
184 MuInput[2 + (3 * iMu)] = (candMuVec->
at(useBx, iMu))->
hwPhi();
191 for (
int iJet = 0; iJet < NCandJet; iJet++) {
193 JetInput[0 + (3 * iJet)] = ((candJetVec->
at(useBx, iJet))->
hwPt()) /
195 JetInput[1 + (3 * iJet)] = (candJetVec->
at(useBx, iJet))->
hwEta();
196 JetInput[2 + (3 * iJet)] = (candJetVec->
at(useBx, iJet))->
hwPhi();
203 for (
int idET = 0; idET < EtSumVecSize; idET++) {
204 ADModelInput[
index++] = EtSumInput[idET];
206 for (
int idEG = 0; idEG < EGVecSize; idEG++) {
207 ADModelInput[
index++] = EgammaInput[idEG];
209 for (
int idMu = 0; idMu < MuVecSize; idMu++) {
210 ADModelInput[
index++] = MuInput[idMu];
212 for (
int idJ = 0; idJ < JVecSize; idJ++) {
213 ADModelInput[
index++] = JetInput[idJ];
217 model->prepare_input(ADModelInput);
219 model->read_result(&ADModelResult);
221 result = ADModelResult.first;
222 loss = ADModelResult.second;
223 score = ((loss).to_float()) * 16.0;
227 int nObjInCond = m_gtAXOL1TLTemplate->nrObjects();
229 if (iCondition >= nObjInCond || iCondition < 0) {
236 bool condGEqVal = m_gtAXOL1TLTemplate->condGEq();
237 bool passCondition =
false;
241 condResult |= passCondition;
249 m_AXOL1TLmodelversion = modelversionname;
253 myCout <<
"Dummy Print for AXOL1TLCondition" << std::endl;
254 m_gtAXOL1TLTemplate->print(myCout);
void print(std::ostream &myCout) const override
print condition
~AXOL1TLCondition() override
void setModelVersion(const std::string modelversionname)
unsigned size(int bx) const
void setGtAXOL1TLTemplate(const AXOL1TLTemplate *)
const T & at(int bx, unsigned i) const
virtual void print(std::ostream &myCout) const
print condition
void copy(const AXOL1TLCondition &cp)
copy function for copy constructor and operator=
AXOL1TLCondition & operator=(const AXOL1TLCondition &)
void setuGtB(const GlobalBoard *)
set the pointer to uGT GlobalBoard
const bool evaluateCondition(const int bxEval) const override
the core function to check if the condition matches