ATLAS Offline Software
Loading...
Searching...
No Matches
jFEXFPGA.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5//***************************************************************************
6// jFEXFPGA - description
7// -------------------
8// begin : 19 10 2020
9// email : jacob.julian.kempster@cern.ch
10// ***************************************************************************/
11
12#include "jFEXFPGA.h"
13#include "jFEXFormTOBs.h"
14#include "jFEXForwardElecAlgo.h"
15#include "jFEXForwardJetsAlgo.h"
16#include "jFEXLargeRJetAlgo.h"
17#include "jFEXPileupAndNoise.h"
18#include "jFEXSmallRJetAlgo.h"
19#include "jFEXmetAlgo.h"
20#include "jFEXsumETAlgo.h"
21#include "jFEXtauAlgo.h"
22
27#include "L1CaloFEXSim/jTower.h"
28
30
31
32namespace LVL1 {
33
34 // default constructor for persistency
35
36jFEXFPGA::jFEXFPGA(const std::string& type,const std::string& name,const IInterface* parent): AthAlgTool(type,name,parent) {
37 declareInterface<IjFEXFPGA>(this);
38}
39
44
45//================ Initialisation =================================================
46
48
49 ATH_CHECK(m_jTowerContainerKey.initialize());
50 ATH_CHECK(m_l1MenuKey.initialize());
51 ATH_CHECK(m_jFEXtauAlgoTool.retrieve());
52 return StatusCode::SUCCESS;
53}
54
55StatusCode jFEXFPGA::init(int id, int jfexid) {
56 m_id = id;
57 m_jfexid = jfexid;
58
59 return StatusCode::SUCCESS;
60
61}
62
64
65 m_id = -1;
66 m_jfexid = -1;
67 m_tau_tobwords.clear();
68 m_SRJet_tobwords.clear();
69 m_LRJet_tobwords.clear();
70 m_sumET_tobwords.clear();
71 m_Met_tobwords.clear();
74 m_FwdEl_tobwords.clear();
75}
76
77StatusCode jFEXFPGA::execute(jFEXOutputCollection* inputOutputCollection, const std::pair<unsigned int, const std::vector<int>&> & jetCalibrationParameters) {
78
79 // Retrieve the L1 menu configuration
81
82 const TrigConf::L1ThrExtraInfo_jTAU & thr_jTAU = l1Menu->thrExtraInfo().jTAU();
83 const TrigConf::L1ThrExtraInfo_jJ & thr_jJ = l1Menu->thrExtraInfo().jJ();
84 const TrigConf::L1ThrExtraInfo_jLJ & thr_jLJ = l1Menu->thrExtraInfo().jLJ();
85 const TrigConf::L1ThrExtraInfo_jTE & thr_jTE = l1Menu->thrExtraInfo().jTE();
86 const TrigConf::L1ThrExtraInfo_jXE & thr_jXE = l1Menu->thrExtraInfo().jXE();
87
89 if(!jTowerContainer.isValid()) {
90 ATH_MSG_ERROR("Could not retrieve container " << m_jTowerContainerKey.key() );
91 return StatusCode::FAILURE;
92 }
93
94 ATH_CHECK( m_jFEXPileupAndNoiseTool->safetyTest());
96 if(m_jfexid == 0 || m_jfexid == 5) {
98 }
99 else {
101 }
102
103 //Calculating and sustracting pileup
104 const std::vector<int> pileup_rho = m_jFEXPileupAndNoiseTool->CalculatePileup();
105
106 //From the DB
107 ATH_CHECK(m_jFEXPileupAndNoiseTool->ApplyPileup());
108
109 //Noise should be always applied
110 m_jFEXPileupAndNoiseTool->ApplyNoise2Jets(true);
111 m_jFEXPileupAndNoiseTool->ApplyNoise2Met(true);
112 //Getting the values
115 std::unordered_map<int,std::vector<int> > map_Etvalues_FPGA = m_jFEXPileupAndNoiseTool->GetEt_values();
116 std::vector<int> pileup_ID;
117 std::vector<int> pileup_HAD_jet;
118 std::vector<int> pileup_EM_jet;
119 std::vector<int> pileup_Total_jet;
120 std::vector<int> pileup_HAD_met;
121 std::vector<int> pileup_EM_met;
122 std::vector<int> pileup_Total_met;
123 for (auto const& [key, val] : m_map_HAD_Etvalues_FPGA)
124 {
125 pileup_ID.push_back(key);
126 pileup_HAD_jet.push_back(val[0]);
127 pileup_EM_jet.push_back(m_map_EM_Etvalues_FPGA[key][0]);
128 pileup_Total_jet.push_back(map_Etvalues_FPGA[key][0]);
129 pileup_HAD_met.push_back(val[1]);
130 pileup_EM_met.push_back(m_map_EM_Etvalues_FPGA[key][1]);
131 pileup_Total_met.push_back(map_Etvalues_FPGA[key][1]);
132 }
133
134 //saving pileup information
135 inputOutputCollection->addValue_pileup("pileup_FPGAid", m_id);
136 inputOutputCollection->addValue_pileup("pileup_jFEXid", m_jfexid);
137 inputOutputCollection->addValue_pileup("pileup_rho_EM", pileup_rho[0]);
138 inputOutputCollection->addValue_pileup("pileup_rho_HAD1", pileup_rho[1]);
139 inputOutputCollection->addValue_pileup("pileup_rho_HAD2", pileup_rho[2]);
140 inputOutputCollection->addValue_pileup("pileup_rho_HAD3", pileup_rho[3]);
141 inputOutputCollection->addValue_pileup("pileup_rho_FCAL", pileup_rho[4]);
142 inputOutputCollection->addValue_pileup("pileup_map_ID" , std::move(pileup_ID));
143 inputOutputCollection->addValue_pileup("pileup_map_Et_values_HAD_jet" , std::move(pileup_HAD_jet));
144 inputOutputCollection->addValue_pileup("pileup_map_Et_values_EM_jet" , std::move(pileup_EM_jet));
145 inputOutputCollection->addValue_pileup("pileup_map_Et_values_Total_jet", std::move(pileup_Total_jet));
146 inputOutputCollection->addValue_pileup("pileup_map_Et_values_HAD_met" , std::move(pileup_HAD_met));
147 inputOutputCollection->addValue_pileup("pileup_map_Et_values_EM_met" , std::move(pileup_EM_met));
148 inputOutputCollection->addValue_pileup("pileup_map_Et_values_Total_met", std::move(pileup_Total_met));
149 inputOutputCollection->fill_pileup();
150
151 if(m_id==0 || m_id==3) {
152 ATH_CHECK( m_jFEXsumETAlgoTool->safetyTest());
154 ATH_CHECK( m_jFEXmetAlgoTool->safetyTest());
155 ATH_CHECK( m_jFEXmetAlgoTool->reset());
156
157 m_jFEXsumETAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
158 m_jFEXmetAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
159
160 unsigned int bin_pos = thr_jTE.etaBoundary_fw(m_jfex_string[m_jfexid]);
161
162 std::unique_ptr<jFEXTOB> jXE_tob = std::make_unique<jFEXTOB>();
163 uint32_t jXE_tobword = 0;
164
165 std::unique_ptr<jFEXTOB> jTE_tob = std::make_unique<jFEXTOB>();
166 uint32_t jTE_tobword = 0;
167
168
169 int hemisphere = m_id == 0 ? 1 : -1;
170
171 if(m_jfexid > 0 && m_jfexid < 5) {
172
173 //-----------------jFEXsumETAlgo-----------------
175 m_jFEXsumETAlgoTool->buildBarrelSumET();
176
177 //-----------------jFEXmetAlgo-----------------
178 m_jFEXmetAlgoTool->setup(m_jTowersIDs_Thin, hemisphere);
179 m_jFEXmetAlgoTool->buildBarrelmet();
180 }
181 else if(m_jfexid == 0 ) {
182
186 for(int mphi = 0; mphi <= max_phi_it; mphi++) {
187 for(int meta = 0; meta <= max_eta_it; meta++) {
188 flipped_jTowersIDs[mphi][meta]=m_jTowersIDs_Wide[mphi][max_eta_it-meta];
189 }
190 }
191 //-----------------jFEXsumETAlgo-----------------
192 m_jFEXsumETAlgoTool->setup(flipped_jTowersIDs);
193 m_jFEXsumETAlgoTool->buildFWDSumET();
194
195 //-----------------jFEXmetAlgo-----------------
196 m_jFEXmetAlgoTool->setup(flipped_jTowersIDs, hemisphere);
197 m_jFEXmetAlgoTool->buildFWDmet();
198 }
199 else if(m_jfexid == 5) {
200
201 //-----------------jFEXsumETAlgo-----------------
203 m_jFEXsumETAlgoTool->buildFWDSumET();
204
205 //-----------------jFEXmetAlgo-----------------
206 m_jFEXmetAlgoTool->setup(m_jTowersIDs_Wide, hemisphere);
207 m_jFEXmetAlgoTool->buildFWDmet();
208 }
209
210 jXE_tobword = m_IjFEXFormTOBsTool->formMetTOB(m_jFEXmetAlgoTool->GetMetXComponent(), m_jFEXmetAlgoTool->GetMetYComponent(),m_jFEXmetAlgoTool->getjXESat(),thr_jXE.resolutionMeV());
211 jXE_tob->initialize(m_id,m_jfexid,jXE_tobword,thr_jXE.resolutionMeV(),0);
212 m_Met_tobwords.push_back(std::move(jXE_tob));
213
214 std::tuple<int,bool> jTElow;
215 std::tuple<int,bool> jTEhigh;
216
217 // NOTE: Foward FPGA in the C-side is already flipped, however we still need to flip the jFEX module 1 and 2
218 if(m_jfexid == 1 || m_jfexid == 2){
219 jTElow = m_jFEXsumETAlgoTool->getETupperEta(bin_pos);
220 jTEhigh = m_jFEXsumETAlgoTool->getETlowerEta(bin_pos);
221 }
222 else{
223 jTElow = m_jFEXsumETAlgoTool->getETlowerEta(bin_pos);
224 jTEhigh = m_jFEXsumETAlgoTool->getETupperEta(bin_pos);
225 }
226
227 jTE_tobword = m_IjFEXFormTOBsTool->formSumETTOB(jTElow,jTEhigh,thr_jTE.resolutionMeV());
228 jTE_tob->initialize(m_id,m_jfexid,jTE_tobword,thr_jTE.resolutionMeV(),0);
229 m_sumET_tobwords.push_back(std::move(jTE_tob));
230 }
231
232 //-----------jFEXSmallRJet & Large R Jet Algo-----------------
233 ATH_MSG_DEBUG("================ Central Algorithms ================");
234
235 int srJet_seedThresholdMeV = thr_jJ.seedThresholdMeV(m_jfex_string[m_jfexid]); //jFEX internal granularity, i.e., 25 MeV/count
236
237
238 //Central region algorithms
239 if(m_jfexid > 0 && m_jfexid < 5) {
240 m_jFEXSmallRJetAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
241 if(!m_jFEXLargeRJetAlgoTool.empty()) m_jFEXLargeRJetAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
242 m_jFEXtauAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
243
244 for(int mphi = 8; mphi < FEXAlgoSpaceDefs::jFEX_algoSpace_height-8; mphi++) {
246
247 //definition of arrays
248 int TT_seed_ID[3][3]= {{0}};
249 int TT_First_ETring[36]= {0};
250 int First_ETring_it = 0;
251
252 int Jet_SearchWindow[7][7] = {{0}};
253 int Jet_SearchWindowDisplaced[7][7] = {{0}};
254 int largeRCluster_IDs[15][15]= {{0}};
255
256 //filling up array to send them to the algorithms
257 for(int i = -7; i< 8; i++ ) {
258 for(int j = -7; j< 8; j++) {
259
260 if(std::abs(i)<4 && std::abs(j)<4) {
261 Jet_SearchWindow[3 + i][3 + j] = m_jTowersIDs_Thin[mphi + i][meta +j];
262 Jet_SearchWindowDisplaced[3 + i][3 + j] = m_jTowersIDs_Thin[mphi+i+1][meta+j+1];
263 }
264
265 uint deltaR = std::sqrt(std::pow(i,2)+std::pow(j,2));
266
267 if(deltaR<2) {
268 TT_seed_ID[i+1][j+1] = m_jTowersIDs_Thin[mphi +i][meta +j]; // Seed 0.3x0.3 in phi-eta plane
269 }
270 else if(deltaR<4) {
271 TT_First_ETring[First_ETring_it]= m_jTowersIDs_Thin[mphi +i][meta +j]; // First energy ring, will be used as tau ISO
272 ++First_ETring_it;
273
274 }
275 else if(deltaR<8) {
276 largeRCluster_IDs[7 +i][7 +j] = m_jTowersIDs_Thin[mphi + i][meta +j];
277 }
278 }
279 }
280
281 // ******** jJ and jLJ algorithms ********
282 ATH_CHECK( m_jFEXSmallRJetAlgoTool->safetyTest());
283 if(!m_jFEXLargeRJetAlgoTool.empty()) ATH_CHECK( m_jFEXLargeRJetAlgoTool->safetyTest());
284 m_jFEXSmallRJetAlgoTool->setup(Jet_SearchWindow, Jet_SearchWindowDisplaced);
285 if(!m_jFEXLargeRJetAlgoTool.empty()) m_jFEXLargeRJetAlgoTool->setupCluster(largeRCluster_IDs);
286 m_jFEXSmallRJetAlgoTool->buildSeeds();
287
288 bool is_Jet_LM = m_jFEXSmallRJetAlgoTool->isSeedLocalMaxima(srJet_seedThresholdMeV);
289
290 if(is_Jet_LM) {
291
292 //getting the energies
293 int SRj_Et = m_jFEXSmallRJetAlgoTool->getSmallClusterET();
294 int LRj_Et = (m_jFEXLargeRJetAlgoTool.empty()) ? 0 : m_jFEXLargeRJetAlgoTool->getLargeClusterET(SRj_Et,m_jFEXLargeRJetAlgoTool->getRingET());
295 int seed_Et = m_jFEXSmallRJetAlgoTool->getSeedET();
296
297 bool SRj_Sat = m_jFEXSmallRJetAlgoTool->getSRjetSat();
298 bool LRj_Sat = (m_jFEXLargeRJetAlgoTool.empty()) ? false : (SRj_Sat || m_jFEXLargeRJetAlgoTool->getLRjetSat());
299
300 int meta_LM = meta;
301 int mphi_LM = mphi;
302
303
304 //Creating SR TOB
305 uint32_t SRJet_tobword = m_IjFEXFormTOBsTool->formSRJetTOB(m_jfexid, mphi_LM, meta_LM, SRj_Et, SRj_Sat, thr_jJ.resolutionMeV(), thr_jJ.ptMinToTopoMeV(m_jfex_string[m_jfexid]), jetCalibrationParameters);
306
307 std::unique_ptr<jFEXTOB> jJ_tob = std::make_unique<jFEXTOB>();
308 jJ_tob->initialize(m_id,m_jfexid,SRJet_tobword,thr_jJ.resolutionMeV(),m_jTowersIDs_Thin[mphi_LM][meta_LM],seed_Et);
309 if ( SRJet_tobword != 0 ){
310 m_SRJet_tobwords.push_back(std::move(jJ_tob));
311 }
312
313 //Creating LR TOB
314 if(!m_jFEXLargeRJetAlgoTool.empty()) {
315 uint32_t LRJet_tobword = m_IjFEXFormTOBsTool->formLRJetTOB(m_jfexid, mphi_LM, meta_LM, LRj_Et,
316 LRj_Sat, thr_jLJ.resolutionMeV(),
317 thr_jLJ.ptMinToTopoMeV(
319
320 std::unique_ptr <jFEXTOB> jLJ_tob = std::make_unique<jFEXTOB>();
321 jLJ_tob->initialize(m_id, m_jfexid, LRJet_tobword, thr_jLJ.resolutionMeV(),
322 m_jTowersIDs_Thin[mphi_LM][meta_LM], seed_Et);
323 if (LRJet_tobword != 0) m_LRJet_tobwords.push_back(std::move(jLJ_tob));
324 }
325 }
326 // ******** jTau algorithm ********
327
328 ATH_CHECK( m_jFEXtauAlgoTool->safetyTest());
329 m_jFEXtauAlgoTool->setup(TT_seed_ID);
330 bool is_tau_LocalMax = m_jFEXtauAlgoTool->isSeedLocalMaxima();
331
332 // Save TOB is tau is a local maxima
333 if ( is_tau_LocalMax ) {
334
335 //calculates the 1st energy ring
336 m_jFEXtauAlgoTool->setFirstEtRing(TT_First_ETring);
337
338
339 uint32_t jTau_tobword = m_IjFEXFormTOBsTool->formTauTOB(m_jfexid,mphi,meta,m_jFEXtauAlgoTool->getClusterEt(),m_jFEXtauAlgoTool->getFirstEtRing(),m_jFEXtauAlgoTool->getTauSat(),thr_jTAU.resolutionMeV(),thr_jTAU.ptMinToTopoMeV(m_jfex_string[m_jfexid]));
340
341 std::unique_ptr<jFEXTOB> jTau_tob = std::make_unique<jFEXTOB>();
342 jTau_tob->initialize(m_id,m_jfexid,jTau_tobword,thr_jTAU.resolutionMeV(),m_jTowersIDs_Thin[mphi][meta]);
343
344 if ( jTau_tobword != 0 ){
345 m_tau_tobwords.push_back(std::move(jTau_tob));
346 }
347 }
348 }
349 }
350 } //end of if statement for checking if in central jfex modules
351
352 //FCAL region algorithm
353 if(m_jfexid ==0 || m_jfexid ==5) {
354
355 //**********Forward Jets***********************
358 m_jFEXForwardJetsAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
360
361 std::unordered_map<int, jFEXForwardJetsInfo> FCALJets = m_jFEXForwardJetsAlgoTool->calculateJetETs(srJet_seedThresholdMeV);
362 for(std::unordered_map<int, jFEXForwardJetsInfo>::iterator it = FCALJets.begin(); it!=FCALJets.end(); ++it) {
363
364 uint32_t TTID = it->first;
365 jFEXForwardJetsInfo FCALJets = it->second;
366
367 int iphi = FCALJets.getCentreLocalTTPhi();
368 int ieta = FCALJets.getCentreLocalTTEta();
369 int SRJetET = FCALJets.getSeedET() + FCALJets.getFirstEnergyRingET();
370 int LRJetET = SRJetET + FCALJets.getSecondEnergyRingET();
371 int seedET = FCALJets.getSeedET();
372
373 bool SRJ_sat = FCALJets.getSRjetSat();
374
375 uint32_t SRFCAL_Jet_tobword = m_IjFEXFormTOBsTool->formSRJetTOB(m_jfexid, iphi, ieta, SRJetET, SRJ_sat, thr_jJ.resolutionMeV(), thr_jJ.ptMinToTopoMeV(m_jfex_string[m_jfexid]), jetCalibrationParameters);
376
377 std::unique_ptr<jFEXTOB> jJ_tob = std::make_unique<jFEXTOB>();
378 jJ_tob->initialize(m_id,m_jfexid,SRFCAL_Jet_tobword,thr_jJ.resolutionMeV(),TTID,seedET);
379
380 if ( SRFCAL_Jet_tobword != 0 ){
381 m_SRJet_tobwords.push_back(std::move(jJ_tob));
382 }
383
384 if(std::fabs(FCALJets.getCentreTTEta())<2.51 && !m_jFEXLargeRJetAlgoTool.empty()){
385 bool LRJ_sat = FCALJets.getLRjetSat();
386 uint32_t LRFCAL_Jet_tobword = m_IjFEXFormTOBsTool->formLRJetTOB(m_jfexid, iphi, ieta, LRJetET, LRJ_sat, thr_jLJ.resolutionMeV(),thr_jLJ.ptMinToTopoMeV(m_jfex_string[m_jfexid]));
387
388 std::unique_ptr<jFEXTOB> jLJ_tob = std::make_unique<jFEXTOB>();
389 jLJ_tob->initialize(m_id,m_jfexid,LRFCAL_Jet_tobword,thr_jLJ.resolutionMeV(),TTID);
390 if ( LRFCAL_Jet_tobword != 0 ) m_LRJet_tobwords.push_back(std::move(jLJ_tob));
391 }
392
393 }
394 //********** Forward Electrons ***********************
399 std::unordered_map<uint, jFEXForwardElecInfo> ForwardElecs = m_jFEXForwardElecAlgoTool->calculateEDM();
400
403 const TrigConf::L1ThrExtraInfo_jEM & thr_jEM = l1Menu->thrExtraInfo().jEM();
404 const uint jFEXETResolution = thr_jEM.resolutionMeV();//200
405 std::string str_jfexname = m_jfex_string[m_jfexid];
406 uint minEtThreshold = thr_jEM.ptMinToTopoMeV(str_jfexname)/jFEXETResolution;
407 //uint Cval[9] = {1,2,3,20,30,40,20,30,40};//C values for iso, emfr1 and emfr2
408 std::vector<int> Ciso;
409 std::vector<int> Chad1;
410 std::vector<int> Chad2;
411
412 for(std::unordered_map<uint, jFEXForwardElecInfo>::iterator itel = ForwardElecs.begin(); itel!=ForwardElecs.end(); ++itel) {
413 uint32_t TTID = itel->first;
414 jFEXForwardElecInfo elCluster = itel->second;
415 uint meta = elCluster.getCoreIeta();//check whether this is the one used by the Trigger conf
416
417 //retrieve jet rejection thresholds from trigger configuration
418 const auto & wp_loose = thr_jEM.isolation(TrigConf::Selection::WP::LOOSE, meta);
419 const auto & wp_medium = thr_jEM.isolation(TrigConf::Selection::WP::MEDIUM, meta);
420 const auto & wp_tight = thr_jEM.isolation(TrigConf::Selection::WP::TIGHT, meta);
421 Ciso.clear();
422 Chad1.clear();
423 Chad2.clear();
424 Ciso.push_back(wp_loose.iso_fw());
425 Ciso.push_back(wp_medium.iso_fw());
426 Ciso.push_back(wp_tight.iso_fw());
427 Chad1.push_back(wp_loose.frac_fw());
428 Chad1.push_back(wp_medium.frac_fw());
429 Chad1.push_back(wp_tight.frac_fw());
430 Chad2.push_back(wp_loose.frac2_fw());
431 Chad2.push_back(wp_medium.frac2_fw());
432 Chad2.push_back(wp_tight.frac2_fw());
433 int Cval[9] = {Ciso[0], Ciso[1], Ciso[2], Chad1[0], Chad1[1], Chad1[2], Chad2[0], Chad2[1], Chad2[2]};
434
435 elCluster.setup(Cval,jFEXETResolution);
436 elCluster.calcFwdElEDM();
437
438 uint etEM = elCluster.getEt();
439 uint32_t FwdEl_tobword = elCluster.getTobWord();
440
441
442 std::vector<uint32_t> FwdEltob_aux{FwdEl_tobword,TTID};
443 if ( FwdEl_tobword != 0 && etEM>minEtThreshold) m_FwdEl_tobwords.push_back(std::move(FwdEltob_aux));
444 }
445
446 //******************************** TAU **********************************************
448 int max_meta=17;
449
450 if(m_jfexid ==0) {
451 for(int i=0; i<FEXAlgoSpaceDefs::jFEX_algoSpace_height; i++) {
452 for(int j=28; j<(FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width-6); j++) { //lower values of j (j<28) are the Fcals not entering in the jFEX tau range
453 jTowersIDs[i][j-28+8]=m_jTowersIDs_Wide[i][j]; // second argument in m_jTowersIDs is to center the FPGA core area in te same region as the central FPGAs
454 }
455 }
456
457 }
458 else if(m_jfexid ==5 ) {
459
460 // Filling m_jTowersIDs with the m_jTowersIDs_Wide ID values up to 2.5 eta
461 for(int i=0; i<FEXAlgoSpaceDefs::jFEX_algoSpace_height; i++) {
462 for(int j=4; j<17; j++) { //higher values of j (j>16) are the Fcals not entering in the jFEX tau range
463 jTowersIDs[i][j]=m_jTowersIDs_Wide[i][j];
464 }
465 }
466 }
467 ATH_MSG_DEBUG("============================ jFEXtauAlgo ============================");
468 ATH_CHECK( m_jFEXtauAlgoTool->safetyTest());
469 m_jFEXtauAlgoTool->setFPGAEnergy(map_Etvalues_FPGA);
470 for(int mphi = 8; mphi < 24; mphi++) {
471 for(int meta = 8; meta < max_meta; meta++) {
472
473 bool is_tau_LocalMax = m_jFEXtauAlgoTool->isSeedLocalMaxima_fwd(jTowersIDs[mphi][meta]);
474
475 // Save TOB is tau is a local maxima
476 if ( is_tau_LocalMax ) {
477
478 uint32_t jTau_tobword = m_IjFEXFormTOBsTool->formTauTOB(m_jfexid,mphi,meta,m_jFEXtauAlgoTool->getClusterEt(),m_jFEXtauAlgoTool->getFirstEtRing(),m_jFEXtauAlgoTool->getTauSat(),thr_jTAU.resolutionMeV(),thr_jTAU.ptMinToTopoMeV(m_jfex_string[m_jfexid]));
479
480 std::unique_ptr<jFEXTOB> jTau_tob = std::make_unique<jFEXTOB>();
481 jTau_tob->initialize(m_id,m_jfexid,jTau_tobword,thr_jTAU.resolutionMeV(),jTowersIDs[mphi][meta]);
482 if ( jTau_tobword != 0 ){
483 m_tau_tobwords.push_back(std::move(jTau_tob));
484 }
485 }
486 }
487 }
488 } //end of if statement for checking if in central jfex modules
489 return StatusCode::SUCCESS;
490} //end of the execute function
491
493
495 const int cols = sizeof tmp_jTowersIDs_subset[0] / sizeof tmp_jTowersIDs_subset[0][0];
496
497 std::copy(&tmp_jTowersIDs_subset[0][0], &tmp_jTowersIDs_subset[0][0]+(rows*cols),&m_jTowersIDs_Wide[0][0]);
498
499 if (msgLvl(MSG::DEBUG)) {
500 ATH_MSG_DEBUG("\n==== jFEXFPGA ========= FPGA (" << m_id << ") [on jFEX " << m_jfexid << "] IS RESPONSIBLE FOR jTOWERS :");
501
502 for (int thisRow=rows-1; thisRow>=0; thisRow--){
503 for (int thisCol=0; thisCol<cols; thisCol++){
504 if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << m_jTowersIDs_Wide[thisRow][thisCol] << " "); }
505 else { ATH_MSG_DEBUG("| " << m_jTowersIDs_Wide[thisRow][thisCol] << " |"); }
506 }
507 }
508 }
509
510}
511
513
515 const int cols = sizeof tmp_jTowersIDs_subset[0] / sizeof tmp_jTowersIDs_subset[0][0];
516
517 std::copy(&tmp_jTowersIDs_subset[0][0], &tmp_jTowersIDs_subset[0][0]+(rows*cols),&m_jTowersIDs_Thin[0][0]);
518
519 if (msgLvl(MSG::DEBUG)) {
520 //this prints out the jTower IDs that each FPGA is responsible for
521 ATH_MSG_DEBUG("\n==== jFEXFPGA ========= FPGA (" << m_id << ") [on jFEX " << m_jfexid << "] IS RESPONSIBLE FOR jTOWERS :");
522
523 for (int thisRow=rows-1; thisRow>=0; thisRow--) {
524 for (int thisCol=0; thisCol<cols; thisCol++) {
525 if(thisCol != cols-1) {
526 ATH_MSG_DEBUG("| " << m_jTowersIDs_Thin[thisRow][thisCol] << " ");
527 }
528 else {
529 ATH_MSG_DEBUG("| " << m_jTowersIDs_Thin[thisRow][thisCol] << " |");
530 }
531 }
532 }
533 }
534
535}
536
537std::vector <std::unique_ptr<jFEXTOB>> jFEXFPGA::getSmallRJetTOBs()
538{
539 std::vector<std::unique_ptr<jFEXTOB>> tobsSort;
540
541 // We need the copy since we cannot move a member of the class, since it will not be part of it anymore
542 for(auto &j : m_SRJet_tobwords) {
543 tobsSort.push_back(std::move(j));
544 }
545 std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<jFEXTOB>>, std::placeholders::_1, std::placeholders::_2, FEXAlgoSpaceDefs::jJ_etBit, 0x7ff));
546
547 return tobsSort;
548}
549
550std::vector <std::unique_ptr<jFEXTOB>> jFEXFPGA::getLargeRJetTOBs()
551{
552 std::vector<std::unique_ptr<jFEXTOB>> tobsSort;
553
554 // We need the copy since we cannot move a member of the class, since it will not be part of it anymore
555 for(auto &j : m_LRJet_tobwords) {
556 tobsSort.push_back(std::move(j));
557 }
558 std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<jFEXTOB>>, std::placeholders::_1, std::placeholders::_2, FEXAlgoSpaceDefs::jLJ_etBit, 0x1fff));
559
560 return tobsSort;
561}
562
563
564 std::vector <std::vector <uint32_t>> jFEXFPGA::getFwdElTOBs()
565 {
566 auto tobsSort = m_FwdEl_tobwords;
567
568 ATH_MSG_DEBUG("number of Forward Elec tobs: " << tobsSort.size() << " in FPGA: " << m_id<< " before truncation");
569 //sort tobs by their et
570 std::sort (tobsSort.begin(), tobsSort.end(), etFwdElSort);
571
572 return tobsSort;
573 }
574
575
576std::vector <std::unique_ptr<jFEXTOB>> jFEXFPGA::getTauTOBs() {
577
578 std::vector<std::unique_ptr<jFEXTOB>> tobsSort;
579
580 // We need the copy since we cannot move a member of the class, since it will not be part of it anymore
581 for(auto &j : m_tau_tobwords) {
582 tobsSort.push_back(std::move(j));
583 }
584 std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<jFEXTOB>>, std::placeholders::_1, std::placeholders::_2, FEXAlgoSpaceDefs::jTau_etBit, 0x7ff));
585
586 return tobsSort;
587}
588
589std::vector<std::unique_ptr<jFEXTOB>> jFEXFPGA::getSumEtTOBs() {
590
591 std::vector<std::unique_ptr<jFEXTOB>> tobsSort;
592
593 // We need the copy since we cannot move a member of the class, since it will not be part of it anymore
594 for(auto &j : m_sumET_tobwords) {
595 tobsSort.push_back(std::move(j));
596 }
597
598 return tobsSort;
599}
600
601
602
603std::vector<std::unique_ptr<jFEXTOB>> jFEXFPGA::getMetTOBs() {
604
605 std::vector<std::unique_ptr<jFEXTOB>> tobsSort;
606
607 // We need the copy since we cannot move a member of the class, since it will not be part of it anymore
608 for(auto &j : m_Met_tobwords) {
609 tobsSort.push_back(std::move(j));
610 }
611
612 return tobsSort;
613}
614
615
616//Returns the Electromagnetic energy for Jet Algos (NOT MET/SumET)
617int jFEXFPGA::getTTowerET_EM(unsigned int TTID) const {
618
619 if(m_map_EM_Etvalues_FPGA.find(TTID) != m_map_EM_Etvalues_FPGA.end()){
620 return m_map_EM_Etvalues_FPGA.at(TTID)[0];
621 }
622
623 ATH_MSG_DEBUG("In jFEXFPGA::getTTowerET_EM, TTower ID not found in map: " << TTID );
624 return -99999;
625}
626
627
628//Returns the Hadronic energy for Jet Algos (NOT MET/SumET)
629int jFEXFPGA::getTTowerET_HAD(unsigned int TTID) const {
630
631 if(m_map_HAD_Etvalues_FPGA.find(TTID) != m_map_HAD_Etvalues_FPGA.end()){
632 return m_map_HAD_Etvalues_FPGA.at(TTID)[0];
633 }
634
635 ATH_MSG_DEBUG("In jFEXFPGA::getTTowerET_HAD, TTower ID not found in map: " << TTID );
636 return -99999;
637}
638
639
640//Returns the Total TT energy for Jet Algos (NOT MET/SumET)
641int jFEXFPGA::getTTowerET(unsigned int TTID) const {
642
643 return getTTowerET_EM(TTID)+getTTowerET_HAD(TTID);
644}
645
646
647//Returns the Total TT energy for MET/SumÉT Algos
648int jFEXFPGA::getTTowerET_forMET(unsigned int TTID) const {
649
650 int tmp_EM = 0;
651 if(m_map_EM_Etvalues_FPGA.find(TTID) != m_map_EM_Etvalues_FPGA.end()){
652 tmp_EM = m_map_EM_Etvalues_FPGA.at(TTID)[1];
653 }
654 else{
655 ATH_MSG_DEBUG("In jFEXFPGA::getTTowerET_forMET (EM energy), TTower ID not found in map: " << TTID );
656 tmp_EM = -99999;
657 }
658
659
660 int tmp_HAD = 0;
661 if(m_map_HAD_Etvalues_FPGA.find(TTID) != m_map_HAD_Etvalues_FPGA.end()){
662 tmp_HAD = m_map_HAD_Etvalues_FPGA.at(TTID)[1];
663 }
664 else{
665 ATH_MSG_DEBUG("In jFEXFPGA::getTTowerET_forMET (HAD energy), TTower ID not found in map: " << TTID );
666 tmp_HAD = -99999;
667 }
668
669
670 return tmp_EM + tmp_HAD;
671}
672
673
674//Returns de ET of a given TT ID for Algorithm
675int jFEXFPGA::getTTowerET_SG(unsigned int TTID) {
676
677 if(TTID == 0){
678 return -999;
679 }
681 const LVL1::jTower * tmpTower = jTowerContainer->findTower(TTID);
682 return tmpTower->getTotalET();
683}
684
685
686} // end of namespace bracket
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
unsigned int uint
Handle class for reading from StoreGate.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
bool msgLvl(const MSG::Level lvl) const
static constexpr int jFEX_wide_algoSpace_width
static constexpr int jLJ_etBit
static constexpr int jJ_etBit
static constexpr int jFEX_thin_algoSpace_width
static constexpr int jTau_etBit
static constexpr int jFEX_algoSpace_height
static bool etFwdElSort(const std::vector< uint32_t > &i, const std::vector< uint32_t > &j)
Definition jFEXFPGA.h:100
virtual std::vector< std::unique_ptr< jFEXTOB > > getMetTOBs() override
Form a tob word out of the potential candidate MET tob.
Definition jFEXFPGA.cxx:603
std::vector< std::vector< uint32_t > > m_FwdEl_tobwords
Definition jFEXFPGA.h:111
ToolHandle< IjFEXSmallRJetAlgo > m_jFEXSmallRJetAlgoTool
Definition jFEXFPGA.h:121
virtual void reset() override
Definition jFEXFPGA.cxx:63
std::string m_jfex_string[6]
Definition jFEXFPGA.h:132
std::unordered_map< int, std::vector< int > > m_map_EM_Etvalues_FPGA
Definition jFEXFPGA.h:117
ToolHandle< IjFEXPileupAndNoise > m_jFEXPileupAndNoiseTool
Definition jFEXFPGA.h:128
virtual StatusCode execute(jFEXOutputCollection *inputOutputCollection, const std::pair< unsigned int, const std::vector< int > & > &jetCalibrationParameters) override
Definition jFEXFPGA.cxx:77
static bool TOBetSort(const TOBObjectClass &i, const TOBObjectClass &j, uint bits, uint mask)
Internal data.
Definition jFEXFPGA.h:96
ToolHandle< IjFEXForwardJetsAlgo > m_jFEXForwardJetsAlgoTool
Definition jFEXFPGA.h:126
virtual std::vector< std::vector< uint32_t > > getFwdElTOBs() override
sorted Electron tobs
Definition jFEXFPGA.cxx:564
ToolHandle< IjFEXmetAlgo > m_jFEXmetAlgoTool
Definition jFEXFPGA.h:125
virtual std::vector< std::unique_ptr< jFEXTOB > > getLargeRJetTOBs() override
Definition jFEXFPGA.cxx:550
int getTTowerET_forMET(unsigned int TTID) const override
Definition jFEXFPGA.cxx:648
std::vector< std::unique_ptr< jFEXTOB > > m_tau_tobwords
Definition jFEXFPGA.h:102
virtual std::vector< std::unique_ptr< jFEXTOB > > getSumEtTOBs() override
Form a tob word out of the potential candidate SumET tob.
Definition jFEXFPGA.cxx:589
jFEXFPGA(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition jFEXFPGA.cxx:36
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
Definition jFEXFPGA.h:120
std::unordered_map< int, std::vector< int > > m_map_HAD_Etvalues_FPGA
Definition jFEXFPGA.h:116
int m_jTowersIDs_Thin[FEXAlgoSpaceDefs::jFEX_algoSpace_height][FEXAlgoSpaceDefs::jFEX_thin_algoSpace_width]
Definition jFEXFPGA.h:114
virtual ~jFEXFPGA()
Destructor.
Definition jFEXFPGA.cxx:41
int getTTowerET(unsigned int TTID) const override
Definition jFEXFPGA.cxx:641
ToolHandle< IjFEXFormTOBs > m_IjFEXFormTOBsTool
Definition jFEXFPGA.h:129
std::vector< std::unique_ptr< jFEXTOB > > m_sumET_tobwords
Definition jFEXFPGA.h:105
std::vector< std::unique_ptr< jFEXTOB > > m_SRJet_tobwords
Definition jFEXFPGA.h:103
ToolHandle< IjFEXsumETAlgo > m_jFEXsumETAlgoTool
Definition jFEXFPGA.h:124
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition jFEXFPGA.cxx:47
virtual std::vector< std::unique_ptr< jFEXTOB > > getSmallRJetTOBs() override
Form a tob word out of the potential candidate SmallRJet tob.
Definition jFEXFPGA.cxx:537
ToolHandle< IjFEXtauAlgo > m_jFEXtauAlgoTool
Definition jFEXFPGA.h:123
int getTTowerET_HAD(unsigned int TTID) const override
Definition jFEXFPGA.cxx:629
std::vector< std::unique_ptr< jFEXTOB > > m_Met_tobwords
Definition jFEXFPGA.h:106
int getTTowerET_EM(unsigned int TTID) const override
Definition jFEXFPGA.cxx:617
virtual StatusCode init(int id, int efexid) override
Definition jFEXFPGA.cxx:55
std::vector< std::unique_ptr< jFEXTOB > > m_LRJet_tobwords
Definition jFEXFPGA.h:104
virtual void SetTowersAndCells_SG(int[][FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width]) override
Definition jFEXFPGA.cxx:492
int getTTowerET_SG(unsigned int TTID)
Definition jFEXFPGA.cxx:675
SG::ReadHandleKey< LVL1::jTowerContainer > m_jTowerContainerKey
Definition jFEXFPGA.h:119
ToolHandle< IjFEXLargeRJetAlgo > m_jFEXLargeRJetAlgoTool
Definition jFEXFPGA.h:122
int m_jTowersIDs_Wide[FEXAlgoSpaceDefs::jFEX_algoSpace_height][FEXAlgoSpaceDefs::jFEX_wide_algoSpace_width]
Definition jFEXFPGA.h:113
ToolHandle< IjFEXForwardElecAlgo > m_jFEXForwardElecAlgoTool
Definition jFEXFPGA.h:127
virtual std::vector< std::unique_ptr< jFEXTOB > > getTauTOBs() override
Definition jFEXFPGA.cxx:576
void calcFwdElEDM()
Calculate variables for top word.
void setup(int jfex, uint ttid, int neta, int nphi)
void addValue_pileup(std::string, int)
const LVL1::jTower * findTower(int towerID) const
fast find method given identifier.
The jTower class is an interface object for jFEX trigger algorithms The purposes are twofold:
Definition jTower.h:36
int getTotalET() const
Get ET sum of all cells in the jTower in MeV.
Definition jTower.cxx:199
unsigned int resolutionMeV() const
const WorkingPoints_jEM & isolation(TrigConf::Selection::WP wp, int eta) const
unsigned int ptMinToTopoMeV(const std::string &module) const
unsigned int ptMinToTopoMeV(const std::string &module) const
unsigned int seedThresholdMeV(const std::string &module) const
unsigned int ptMinToTopoMeV(const std::string &module) const
unsigned int ptMinToTopoMeV(const std::string &module) const
unsigned int etaBoundary_fw(const std::string &module) const
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
-diff
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.