73 {
77
79 if(!eTowerContainer.isValid()){
81 return StatusCode::FAILURE;
82 }
83
84
85 SG::ReadHandle<TrigConf::L1Menu> l1Menu (
m_l1MenuKey);
87
88 auto & thr_eEM = l1Menu->thrExtraInfo().eEM();
89 auto & thr_eTAU = l1Menu->thrExtraInfo().eTAU();
90
91 auto emAlgoVersion = thr_eEM.algoVersion();
92 auto tauAlgoVersion = thr_eTAU.algoVersion();
93
94
95
96 int min_eta;
97 int overflow_eta;
99 min_eta = 0;
100 } else {
101 min_eta = 1;
102 }
104 overflow_eta = 6;
105 } else {
106 overflow_eta = 5;
107 }
108
109 for(int ieta = min_eta; ieta < overflow_eta; ieta++) {
110 for(int iphi = 1; iphi < 9; iphi++) {
111
112 int tobtable[3][3]={
116
120
124 };
125
126
129
130
134
135
136 unsigned int ptMinToTopoCounts = thr_eEM.ptMinToTopoCounts();
137
138
140
141
142
147
148 std::vector<unsigned int> threshReta;
149 threshReta.push_back(iso_loose.reta_fw());
150 threshReta.push_back(iso_medium.reta_fw());
151 threshReta.push_back(iso_tight.reta_fw());
152
153 std::vector<unsigned int> threshRhad;
154 threshRhad.push_back(iso_loose.rhad_fw());
155 threshRhad.push_back(iso_medium.rhad_fw());
156 threshRhad.push_back(iso_tight.rhad_fw());
157
158 std::vector<unsigned int> threshWstot;
159 threshWstot.push_back(iso_loose.wstot_fw());
160 threshWstot.push_back(iso_medium.wstot_fw());
161 threshWstot.push_back(iso_tight.wstot_fw());
162
163 ATH_MSG_DEBUG(
"ieta=" << ieta <<
" loose => reta_fw=" << threshReta[0] <<
", rhad_fw=" << threshRhad[0] <<
", wstot_fw=" << threshWstot[0]);
164 ATH_MSG_DEBUG(
"ieta=" << ieta <<
" medium => reta_fw=" << threshReta[1] <<
", rhad_fw=" << threshRhad[1] <<
", wstot_fw=" << threshWstot[1]);
165 ATH_MSG_DEBUG(
"ieta=" << ieta <<
" tight => reta_fw=" << threshReta[2] <<
", rhad_fw=" << threshRhad[2] <<
", wstot_fw=" << threshWstot[2]);
166
167
168 std::vector<unsigned int> RetaCoreEnv;
170 std::vector<unsigned int> RhadEMHad;
172 std::vector<unsigned int> WstotDenNum;
174
175
176 unsigned int RetaWP = 0;
177 unsigned int RhadWP = 0;
178 unsigned int WstotWP = 0;
179
180
181 unsigned int RetaBitS = 3;
182 unsigned int RhadBitS = 3;
183 unsigned int WstotBitS = 5;
184
185 unsigned int maxEtCountsEm = thr_eEM.maxEtCounts(
m_eFexStep);
186 if (eEMTobEt >= maxEtCountsEm){
187 RetaWP = 3;
188 RhadWP = 3;
189 WstotWP = 3;
190 }
191 else{
192 SetIsoWP(RetaCoreEnv,threshReta,RetaWP,RetaBitS);
193 SetIsoWP(RhadEMHad,threshRhad,RhadWP,RhadBitS);
194 SetIsoWP(WstotDenNum,threshWstot,WstotWP,WstotBitS);
195 }
196 int eta_ind = ieta;
197 int phi_ind = iphi - 1;
198
199
200 uint32_t tobword =
m_eFEXFormTOBsTool->formEmTOBWord(
m_id,eta_ind,phi_ind,RhadWP,WstotWP,RetaWP,seed,und,eEMTobEt,ptMinToTopoCounts, emAlgoVersion);
201 std::vector<uint32_t> xtobwords =
m_eFEXFormTOBsTool->formEmxTOBWords(
m_efexid,
m_id,eta_ind,phi_ind,RhadWP,WstotWP,RetaWP,seed,und,eEMTobEt,ptMinToTopoCounts, emAlgoVersion);
202
204
205 tmp_tob->setFPGAID(
m_id);
207 tmp_tob->setEta(ieta);
208 tmp_tob->setPhi(iphi);
209 tmp_tob->setTobword(tobword);
210 tmp_tob->setxTobword0(xtobwords[0]);
211 tmp_tob->setxTobword1(xtobwords[1]);
212
213
214 if (inputOutputCollection->getdooutput() && (tobword != 0) && (eEMTobEt != 0)) {
215 inputOutputCollection->addeFexNumber(
m_efexid);
216 inputOutputCollection->addEMtob(tobword);
217 inputOutputCollection->addValue_eg("WstotNum", tmp_tob->getWstotNum());
218 inputOutputCollection->addValue_eg("WstotDen", tmp_tob->getWstotDen());
219 inputOutputCollection->addValue_eg("RetaNum", tmp_tob->getRetaCore());
220 inputOutputCollection->addValue_eg("RetaDen", tmp_tob->getRetaEnv());
221 inputOutputCollection->addValue_eg("RhadNum", tmp_tob->getRhadEM());
222 inputOutputCollection->addValue_eg("RhadDen", tmp_tob->getRhadHad());
223 inputOutputCollection->addValue_eg(
"haveSeed",
m_eFEXegAlgoTool->hasSeed());
227 inputOutputCollection->addValue_eg(
"eta",
eta);
230 inputOutputCollection->addValue_eg(
"phi",
phi);
231 unsigned int em_et = 9999;
233 inputOutputCollection->addValue_eg("em", em_et);
234 unsigned int had_et = 9999;
236 inputOutputCollection->addValue_eg("had", had_et);
237 inputOutputCollection->fill_eg();
238 }
239
240
241 if ( (tobword != 0) && (eEMTobEt != 0) )
m_emTobObjects.push_back(std::move(tmp_tob));
242
243 }
244 }
245
246
247 for(int ieta = min_eta; ieta < overflow_eta; ieta++)
248 {
249 for(int iphi = 1; iphi < 9; iphi++)
250 {
251 int tobtable[3][3]={
255
259
263 };
264
270
272 {
273 ATH_MSG_FATAL(
"BDT tau algo and heuristic tau algo should agree on seeding for all TOBs");
274 return StatusCode::FAILURE;
275 }
276
278
279
280 unsigned int ptTauMinToTopoCounts = thr_eTAU.ptMinToTopoCounts();
281
283
284
287
288
289
294
295 std::vector<unsigned int> threshRCore;
296 threshRCore.push_back(iso_loose.rCore_fw());
297 threshRCore.push_back(iso_medium.rCore_fw());
298 threshRCore.push_back(iso_tight.rCore_fw());
299
300 std::vector<unsigned int> threshRHad;
301 threshRHad.push_back(iso_loose.rHad_fw());
302 threshRHad.push_back(iso_medium.rHad_fw());
303 threshRHad.push_back(iso_tight.rHad_fw());
304
305
306 std::vector<unsigned int> rCoreVec;
308
309 std::vector<unsigned int> rHadVec;
311
312
313 unsigned int bdtScore = 0;
314 unsigned int bdtCondition = 0;
315 unsigned int bdtRHadWP = 0;
316
317
318 unsigned int rCoreWP = 0;
319 unsigned int rHadWP = 0;
320
321
322 unsigned int RcoreBitS = 3;
323 unsigned int RhadBitS = 3;
324
325 unsigned int maxEtCountsTau = thr_eTAU.maxEtCounts(
m_eFexStep);
326 unsigned int bdtMinEtCounts = thr_eTAU.minIsoEtCounts(
m_eFexStep);
327 if (eTauTobEt >= maxEtCountsTau) {
328 rCoreWP = 3;
329 rHadWP = 3;
330 } else {
331 SetIsoWP(rCoreVec,threshRCore,rCoreWP,RcoreBitS);
332 SetIsoWP(rHadVec,threshRHad,rHadWP,RhadBitS);
333 }
334
335
336
337 std::vector<unsigned int> threshBDT;
338 threshBDT.push_back(iso_loose.rCore_fw());
339 threshBDT.push_back(iso_medium.rCore_fw());
340 threshBDT.push_back(iso_tight.rCore_fw());
341
342 m_eFEXtauBDTAlgoTool->setThresholds(threshRHad, threshBDT, ptTauMinToTopoInEfexCounts, maxEtCountsTau, bdtMinEtCounts, (tauAlgoVersion==2) ? 0x0ff0 : maxEtCountsTau);
343
344
350
352
354
356
358
359 int eta_ind = ieta;
360 int phi_ind = iphi - 1;
361
362
363 std::vector<uint32_t> xtobwords;
364 std::vector<uint32_t> xtobwordsBDT;
365
367 << phi_ind << ", eTauBDTTobEt: " << eTauBDTTobEt
368 << ", eTauTobEt: " << eTauTobEt << ", ptTauMinToTopoCounts: "
369 << ptTauMinToTopoCounts << ", maxEtCountsTau: " << maxEtCountsTau
370 << ", bdtScore: " << bdtScore << " bdtMinEtCounts: " << bdtMinEtCounts << " bdtRHadWP " << bdtRHadWP);
371
372 uint32_t tobwordBDT =
m_eFEXFormTOBsTool->formTauTOBWord(
m_id, eta_ind, phi_ind, eTauBDTTobEt, bdtRHadWP, bdtCondition, bdtSeed,0, ptTauMinToTopoCounts, tauAlgoVersion);
373 xtobwordsBDT =
m_eFEXFormTOBsTool->formTauxTOBWords(
m_efexid,
m_id, eta_ind, phi_ind, eTauBDTTobEt, bdtRHadWP, bdtCondition, bdtSeed, 0, ptTauMinToTopoCounts, tauAlgoVersion, bdtScore);
375 xtobwords =
m_eFEXFormTOBsTool->formTauxTOBWords(
m_efexid,
m_id, eta_ind, phi_ind, eTauTobEt, rHadWP, rCoreWP, seed, und, ptTauMinToTopoCounts, 0, 0);
376
378 tmp_tau_tob->setFPGAID(
m_id);
380 tmp_tau_tob->setEta(ieta);
381 tmp_tau_tob->setPhi(iphi);
382 tmp_tau_tob->setTobword(tobword);
383 tmp_tau_tob->setxTobword0(xtobwords[0]);
384 tmp_tau_tob->setxTobword1(xtobwords[1]);
385
387 tmp_tau_tob_bdt->setFPGAID(
m_id);
388 tmp_tau_tob_bdt->seteFEXID(
m_efexid);
389 tmp_tau_tob_bdt->setEta(ieta);
390 tmp_tau_tob_bdt->setPhi(iphi);
391 tmp_tau_tob_bdt->setTobword(tobwordBDT);
392 tmp_tau_tob_bdt->setxTobword0(xtobwordsBDT[0]);
393 tmp_tau_tob_bdt->setxTobword1(xtobwordsBDT[1]);
394
395
396 if ((inputOutputCollection->getdooutput()) && ( tobword != 0 )) {
397 inputOutputCollection->addValue_tau(
"isCentralTowerSeed",
m_eFEXtauAlgoTool->isCentralTowerSeed());
400 inputOutputCollection->addValue_tau("Eta", ieta);
401 inputOutputCollection->addValue_tau("Phi", iphi);
402 const LVL1::eTower * centerTower = eTowerContainer->findTower(
m_eTowersIDs[iphi][ieta]);
403 const LVL1::eTower * oneOffEtaTower = ieta < 5 ? eTowerContainer->findTower(
m_eTowersIDs[iphi][ieta+1]) :
nullptr;
404 const LVL1::eTower * oneBelowEtaTower = ieta > 0 ? eTowerContainer->findTower(
m_eTowersIDs[iphi][ieta-1]) :
nullptr;
405 inputOutputCollection->addValue_tau(
"CenterTowerEt", centerTower->
getTotalET());
406 inputOutputCollection->addValue_tau(
"OneOffEtaTowerEt", oneOffEtaTower ? oneOffEtaTower->
getTotalET() : 0);
407 inputOutputCollection->addValue_tau(
"OneBelowEtaTowerEt", oneBelowEtaTower ? oneBelowEtaTower->
getTotalET() : 0);
408 inputOutputCollection->addValue_tau(
"FloatEta", centerTower->
eta() * centerTower->
getPosNeg());
409 inputOutputCollection->addValue_tau(
"FloatPhi", centerTower->
phi());
410 inputOutputCollection->addValue_tau("RCoreCore", rCoreVec[0]);
411 inputOutputCollection->addValue_tau("RCoreEnv", rCoreVec[1]);
412 inputOutputCollection->addValue_tau(
"RealRCore",
m_eFEXtauAlgoTool->getRealRCore());
413 inputOutputCollection->addValue_tau("RCoreWP", rCoreWP);
414 inputOutputCollection->addValue_tau("RHadCore", rHadVec[0]);
415 inputOutputCollection->addValue_tau("RHadEnv", rHadVec[1]);
416 inputOutputCollection->addValue_tau(
"RealRHad",
m_eFEXtauAlgoTool->getRealRHad());
418 inputOutputCollection->addValue_tau("RHadWP", rHadWP);
419 inputOutputCollection->addValue_tau("Seed", seed);
420 inputOutputCollection->addValue_tau("UnD", und);
421 inputOutputCollection->addValue_tau("BDTScore", bdtScore);
422 inputOutputCollection->addValue_tau("BDTCondition", bdtCondition);
423 inputOutputCollection->addValue_tau(
"eFEXID",
m_efexid);
424 inputOutputCollection->addValue_tau(
"FPGAID",
m_id);
425
426
427 inputOutputCollection->fill_tau();
428 }
429
432
433 }
434 }
435
436 return StatusCode::SUCCESS;
437}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
const unsigned int m_eFexStep
Internal data.
ToolHandle< eFEXFormTOBs > m_eFEXFormTOBsTool
std::vector< std::unique_ptr< eFEXegTOB > > m_emTobObjects
std::vector< std::unique_ptr< eFEXtauTOB > > m_tauHeuristicTobObjects
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
ToolHandle< eFEXtauAlgoBase > m_eFEXtauAlgoTool
std::vector< std::unique_ptr< eFEXtauTOB > > m_tauBDTTobObjects
virtual void SetIsoWP(const std::vector< unsigned int > &, const std::vector< unsigned int > &, unsigned int &, unsigned int) const
ToolHandle< eFEXegAlgo > m_eFEXegAlgoTool
SG::ReadHandleKey< LVL1::eTowerContainer > m_eTowerContainerKey
ToolHandle< eFEXtauAlgoBase > m_eFEXtauBDTAlgoTool
int getTotalET() const
Get ET sum of all cells in the eTower in MeV.
unsigned int energyInCounts(unsigned int energyMeV, unsigned int energyResolutionMeV)
helper funtion to translate energies into counts