ATLAS Offline Software
eFEXSysSim.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //***************************************************************************
6 // eFEXSysSim - description
7 // -------------------
8 // begin : 12 07 2019
9 // email : jacob.julian.kempster@cern.ch alison.elliot@cern.ch
10 // ***************************************************************************/
11 
13 #include "L1CaloFEXSim/eFEXSim.h"
14 #include "L1CaloFEXSim/eTower.h"
17 
18 #include "StoreGate/WriteHandle.h"
19 #include "StoreGate/ReadHandle.h"
20 
21 #include "TrigConfData/L1Menu.h"
22 
23 #include "xAODTrigger/eFexEMRoI.h"
26 
27 #include "xAODTrigger/eFexTauRoI.h"
30 
31 
32 namespace LVL1 {
33 
34 
35  // default constructor for persistency
36 
37  eFEXSysSim::eFEXSysSim(const std::string& type,const std::string& name,const IInterface* parent):
39  {
40  declareInterface<IeFEXSysSim>(this);
41 
42  }
43 
44 
46  //eFEXSysSim::~eFEXSysSim()
47  //{
48  //}
49 
50  //---------------- Initialisation -------------------------------------------------
51 
53  {
54 
56 
57  ATH_CHECK( m_eFEXSimTool.retrieve() );
58 
59  ATH_CHECK( m_eFexOutKey.initialize() );
60  ATH_CHECK( m_eFexEMxTOBOutKey.initialize() );
61 
62  ATH_CHECK( m_eFexTauActiveOutKey.initialize() );
63  ATH_CHECK( m_eFexTauActivexTOBOutKey.initialize() );
66 
68 
69  ATH_CHECK( m_eFEXFPGATool.retrieve() );
70 
72 
73  return StatusCode::SUCCESS;
74  }
75 
76  //---------------- Finalisation -------------------------------------------------
77 
79  {
80  return StatusCode::SUCCESS;
81  }
82 
83 
85 
86  }
87 
89 
90  m_eFEXCollection.clear();
91  }
92 
93 
94  int eFEXSysSim::calcTowerID(int eta, int phi, int mod) const {
95 
96  return ((64*eta) + phi + mod);
97  }
98 
100 
102  if(!this_eTowerContainer.isValid()){
103  ATH_MSG_FATAL("Could not retrieve eTowerContainer " << m_eTowerContainerSGKey.key());
104  return StatusCode::FAILURE;
105  }
106 
107  // remove TOBs of the previous events from the map
108  m_allEmTobObjects.clear();
110  m_allTauBDTTobObjects.clear();
111 
112  // do mapping with preloaded csv file if it is available
113  if (m_eFEXFPGATowerIdProviderTool->ifhaveinputfile()) {
114  int tmp_eTowersIDs_subset_eFEX[10][18];
115  for (int i_efex{ 0 }; i_efex < 24; i_efex++) {
116  ATH_CHECK(m_eFEXFPGATowerIdProviderTool->getRankedTowerIDineFEX(i_efex, tmp_eTowersIDs_subset_eFEX));
117  m_eFEXSimTool->init(i_efex);
118  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset_eFEX, inputOutputCollection));
119  // Get TOBs from this eFEX
120  m_allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(i_efex, m_eFEXSimTool->getEmTOBs() ));
121  m_allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(i_efex, m_eFEXSimTool->getTauHeuristicTOBs() ));
122  m_allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(i_efex, m_eFEXSimTool->getTauBDTTOBs() ));
123  m_eFEXSimTool->reset();
124  }
125  } else {
126  // We need to split the towers into 3 blocks in eta and 8 blocks in phi.
127 
128  // boundaries in eta: -2.5, -0.8, 0.8, 2.5
129  // REAL boundaries in eta (overlaps must occur for sliding window algorithms!): -2.5, -0.7, -0.9, 0.9, 0.7, 2.5
130  // Written explicitly:
131  // -2.5 -> -0.7
132  // -0.9 -> 0.9
133  // 0.7 -> 2.5
134 
135  // boundaries in phi: 0.2, 1.0, 1.8, 2.6, 3.4, 4.2, 5.0, 5.8
136  // Written explicitly with REAL boundaries in phi (overlaps must occur for sliding window algorithms!)
137  // 0.1 -> 1.1
138  // 0.9 -> 1.9
139  // 1.7 -> 2.7
140  // 2.5 -> 3.5
141  // 3.3 -> 4.3
142  // 4.1 -> 5.1
143  // 4.9 -> 5.9
144  // 5.7 -> 0.3
145 
146  // C-SIDE NEGATIVE EFEXs
147  // DO THE LEFT-MOST (NEGATIVE ETA) EFEXs FIRST
148  int fexcounter = 0;
149  // Example values for eFEX 0
150  //id_modifier + phi + (64 * eta)
151  int emecEta = 24; int emecPhi = 1; int emecMod = 500000;
152  int initialEMEC = calcTowerID(emecEta,emecPhi,emecMod); //501537;
153  int transEta = 14; int transPhi = 1; int transMod = 300000;
154  int initialTRANS = calcTowerID(transEta,transPhi,transMod); //300897;
155  int embEta = 13; int embPhi = 1; int embMod = 100000;
156  int initialEMB = calcTowerID(embEta,embPhi,embMod); //100833;
157  int eFEXa = 0;
158 
159  for (int thisEFEX=eFEXa; thisEFEX<=21; thisEFEX+=3){
160 
161  if(fexcounter > 0){ initialEMEC += 8; initialTRANS += 8; initialEMB += 8; } // TODO // SOMEHOW REMOVE HARD-CODING?
162 
163  // decide which subset of towers (and therefore supercells) should go to the eFEX
164  std::map<int,eTower> tmp_eTowersColl_subset;
165 
166  // let's try doing this with an array initially just containing tower IDs.
167  int tmp_eTowersIDs_subset [10][18];
168 
169  int rows = sizeof tmp_eTowersIDs_subset / sizeof tmp_eTowersIDs_subset[0];
170  int cols = sizeof tmp_eTowersIDs_subset[0] / sizeof tmp_eTowersIDs_subset[0][0];
171 
172  // set the EMEC part
173  for(int thisCol=0; thisCol<10; thisCol++){
174  for(int thisRow=0; thisRow<rows; thisRow++){
175 
176  int towerid = initialEMEC - (thisCol * 64) + thisRow;
177 
178  if( (thisEFEX == 21) && (thisRow >= 7)){ towerid -= 64; };
179 
180  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
181  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
182 
183  }
184  }
185 
186  // set the TRANS part
187  for(int thisRow = 0; thisRow < rows; thisRow++){
188 
189  int towerid = initialTRANS + thisRow;
190 
191  if( (thisEFEX == 21) && (thisRow >= 7)){ towerid -= 64; };
192 
193  tmp_eTowersIDs_subset[thisRow][10] = towerid;
194  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
195 
196  }
197 
198  // set the EMB part
199  for(int thisCol = 11; thisCol < cols; thisCol++){
200  for(int thisRow=0; thisRow<rows; thisRow++){
201 
202  int towerid = initialEMB - ( (thisCol-11) * 64) + thisRow;
203 
204  if( (thisEFEX == 21) && (thisRow >= 7)){ towerid -= 64; };
205 
206  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
207  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
208 
209  }
210  }
211 
212 
213  if(false){
214  ATH_MSG_DEBUG("CONTENTS OF eFEX " << thisEFEX << " :");
215  for (int thisRow=rows-1; thisRow>=0; thisRow--){
216  for (int thisCol=0; thisCol<cols; thisCol++){
217  int tmptowerid = tmp_eTowersIDs_subset[thisRow][thisCol];
218  const float tmptowereta = this_eTowerContainer->findTower(tmptowerid)->eta();
219  const float tmptowerphi = this_eTowerContainer->findTower(tmptowerid)->phi();
220  if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowerphi << "][" << tmptowereta << "]) "); }
221  else { ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) |"); }
222  }
223  }
224  }
225 
226 
227  m_eFEXSimTool->init(thisEFEX);
228  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset, inputOutputCollection));
229  m_allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getEmTOBs() ) ));
230  m_allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauHeuristicTOBs() ) ));
231  m_allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauBDTTOBs() ) ));
232  m_eFEXSimTool->reset();
233 
234  fexcounter++;
235  }
236 
237  // CENTRAL EFEXs
238  // DO THE CENTRAL EFEXs SECOND
239  fexcounter = 0;
240  int embnegEta = 8; int embnegPhi = 1; int embnegMod = 100000;
241  int initialEMB_neg = calcTowerID(embnegEta,embnegPhi,embnegMod); //100513;
242  int embposEta = 0; int embposPhi = 1; int embposMod = 200000;
243  int initialEMB_pos = calcTowerID(embposEta,embposPhi,embposMod); //200001;
244  int eFEXb = 1;
245 
246  for (int thisEFEX=eFEXb; thisEFEX<=22; thisEFEX+=3){
247 
248  if(fexcounter > 0){ initialEMB_neg += 8; initialEMB_pos += 8; }
249 
250  // decide which subset of towers (and therefore supercells) should go to the eFEX
251  std::map<int,eTower> tmp_eTowersColl_subset;
252 
253  // doing this with an array initially just containing tower IDs.
254  int tmp_eTowersIDs_subset [10][18];
255 
256  int rows = sizeof tmp_eTowersIDs_subset / sizeof tmp_eTowersIDs_subset[0];
257  int cols = sizeof tmp_eTowersIDs_subset[0] / sizeof tmp_eTowersIDs_subset[0][0];
258 
259  // set the EMB part
260  for(int thisCol = 0; thisCol < cols; thisCol++){
261  for(int thisRow=0; thisRow<rows; thisRow++){
262  int towerid = -1;
263 
264  int tmp_initEMB = initialEMB_neg;
265 
266  if(thisCol < 9){
267  towerid = tmp_initEMB - ( (thisCol) * 64) + thisRow;
268  }
269  else{
270  tmp_initEMB = initialEMB_pos;
271  towerid = tmp_initEMB + ( (thisCol-9) * 64) + thisRow;
272  }
273 
274  if( (thisEFEX == 22) && (thisRow >= 7)){ towerid -= 64; };
275 
276  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
277 
278  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
279  }
280  }
281 
282 
283  if(false){
284  ATH_MSG_DEBUG("CONTENTS OF eFEX " << thisEFEX << " :");
285  for (int thisRow=rows-1; thisRow>=0; thisRow--){
286  for (int thisCol=0; thisCol<cols; thisCol++){
287  int tmptowerid = tmp_eTowersIDs_subset[thisRow][thisCol];
288  const float tmptowereta = this_eTowerContainer->findTower(tmptowerid)->eta();
289  const float tmptowerphi = this_eTowerContainer->findTower(tmptowerid)->phi();
290  if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) "); }
291  else { ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) |"); }
292  }
293  }
294  }
295 
296  //tool use instead
297  m_eFEXSimTool->init(thisEFEX);
298  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset, inputOutputCollection));
299  m_allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getEmTOBs() ) ));
300  m_allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauHeuristicTOBs() ) ));
301  m_allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauBDTTOBs() ) ));
302  m_eFEXSimTool->reset();
303 
304  fexcounter++;
305  }
306 
307  // POSITIVE EFEXs
308  // LET'S DO THE RIGHT-MOST (POSTITIVE ETA) EFEXs THIRD
309  fexcounter = 0;
310  // Example values for eFEX 0
311  emecEta = 15; emecPhi = 1; emecMod = 600000;
312  initialEMEC = calcTowerID(emecEta,emecPhi,emecMod); //600961;
313  transEta = 14; transPhi = 1; transMod = 400000;
314  initialTRANS = calcTowerID(transEta,transPhi,transMod); //400897;
315  embEta = 7; embPhi = 1; embMod = 200000;
316  initialEMB = calcTowerID(embEta,embPhi,embMod); //200449;
317  int eFEXc = 2;
318 
319  for (int thisEFEX=eFEXc; thisEFEX<=23; thisEFEX+=3){
320 
321  if(fexcounter > 0){ initialEMEC += 8; initialTRANS += 8; initialEMB += 8; }
322 
323  // decide which subset of towers (and therefore supercells) should go to the eFEX
324  std::map<int,eTower> tmp_eTowersColl_subset;
325 
326  // doing this with an array initially just containing tower IDs.
327  int tmp_eTowersIDs_subset [10][18];
328 
329  int rows = sizeof tmp_eTowersIDs_subset / sizeof tmp_eTowersIDs_subset[0];
330  int cols = sizeof tmp_eTowersIDs_subset[0] / sizeof tmp_eTowersIDs_subset[0][0];
331 
332  // set the EMB part
333  for(int thisCol = 0; thisCol < 7; thisCol++){
334  for(int thisRow=0; thisRow<rows; thisRow++){
335  int towerid = initialEMB + ( (thisCol) * 64) + thisRow;
336 
337  if( (thisEFEX == 23) && (thisRow >= 7)){ towerid -= 64; };
338 
339  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
340  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
341  }
342  }
343  // set the TRANS part
344  for(int thisRow = 0; thisRow < rows; thisRow++){
345  int towerid = initialTRANS + thisRow;
346 
347  if( (thisEFEX == 23) && (thisRow >= 7)){ towerid -= 64; };
348 
349  tmp_eTowersIDs_subset[thisRow][7] = towerid;
350  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
351  }
352  // set the EMEC part
353  for(int thisCol=8; thisCol<cols; thisCol++){
354  for(int thisRow=0; thisRow<rows; thisRow++){
355  int towerid = initialEMEC + ( (thisCol-8) * 64) + thisRow;
356 
357  if( (thisEFEX == 23) && (thisRow >= 7)){ towerid -= 64; };
358 
359  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
360  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
361  }
362  }
363 
364  // Debug printout
365  if(false){
366  ATH_MSG_DEBUG("CONTENTS OF eFEX " << thisEFEX << " :");
367  for (int thisRow=rows-1; thisRow>=0; thisRow--){
368  for (int thisCol=0; thisCol<cols; thisCol++){
369  int tmptowerid = tmp_eTowersIDs_subset[thisRow][thisCol];
370  const float tmptowereta = this_eTowerContainer->findTower(tmptowerid)->eta();
371  const float tmptowerphi = this_eTowerContainer->findTower(tmptowerid)->phi();
372  if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) "); }
373  else { ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) |"); }
374  }
375  }
376  }
377 
378  //tool use instead
379  m_eFEXSimTool->init(thisEFEX);
380  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset, inputOutputCollection));
381  m_allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getEmTOBs() ) ));
382  m_allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauHeuristicTOBs() ) ));
383  m_allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauBDTTOBs() ) ));
384  m_eFEXSimTool->reset();
385 
386  fexcounter++;
387  }
388 
389  }//close the non-csv loop over eFEXes
390 
391  // EM TOBs and xTOBs
392 
393  // TOB Containers
394  m_eContainer = std::make_unique<xAOD::eFexEMRoIContainer> ();
395  m_eAuxContainer = std::make_unique<xAOD::eFexEMRoIAuxContainer> ();
396  m_eContainer->setStore(m_eAuxContainer.get());
397 
398  // xTOB Containers
399  m_xeContainer = std::make_unique<xAOD::eFexEMRoIContainer> ();
400  m_xeAuxContainer = std::make_unique<xAOD::eFexEMRoIAuxContainer> ();
401  m_xeContainer->setStore(m_xeAuxContainer.get());
402 
403  // iterate over all Em Tobs and fill xTOB EDM with them
404  for( auto const& [efex, tobObjects] : m_allEmTobObjects ){
405  for(auto &tobObject : tobObjects){
406  m_eFEXFillEDMTool->fillEmEDM(m_xeContainer, efex, tobObject, true);
407  }
408  }
409 
410  // Form list of TOBs, sorted and truncated from each eFEX
411  // Vector to store sorted TOBs from all eFEXes
412  // Note that this step means moving TOBs from the all objects vector, which is why we do it last
413  std::vector<std::unique_ptr<eFEXegTOB>> emTOBs;
414  // Loop through eFEXes and sort TOBs from each
415  auto iter = m_allEmTobObjects.begin();
416  while (iter != m_allEmTobObjects.end()) {
417  std::vector<std::unique_ptr<eFEXegTOB>> tobsSort = std::move(iter->second);
418  // sort tobs by their et (last 12 bits of the 32 bit tob word)
419  std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<eFEXegTOB>>, std::placeholders::_1, std::placeholders::_2, false));
420  // Truncate at 6 TOBs per eFEX
421  if (tobsSort.size() > 6) tobsSort.resize(6);
422  // Append to system TOB list
423  for (unsigned int t = 0; t < tobsSort.size(); ++t) emTOBs.push_back(std::move(tobsSort[t]));
424  // Next eFEX
425  ++iter;
426  }
427 
428  // iterate over sorted eFEX EM TOBs and fill TOB EDM with them
429  for(auto &tobObject : emTOBs){
430  int efex = tobObject->geteFEXID();
431  m_eFEXFillEDMTool->fillEmEDM(m_eContainer, efex, tobObject);
432  }
433 
434  // Match xTOBs to TOBs and set isTOB flags if matched
436 
437  // Record EDMs in StoreGate
438  SG::WriteHandle<xAOD::eFexEMRoIContainer> outputeFexEMxTOBHandle(m_eFexEMxTOBOutKey/*, ctx*/);
439  ATH_MSG_DEBUG(" write: " << outputeFexEMxTOBHandle.key() << " = " << "..." );
440  ATH_CHECK(outputeFexEMxTOBHandle.record(std::move(m_xeContainer),std::move(m_xeAuxContainer)));
441 
442  SG::WriteHandle<xAOD::eFexEMRoIContainer> outputeFexHandle(m_eFexOutKey/*, ctx*/);
443  ATH_MSG_DEBUG(" write: " << outputeFexHandle.key() << " = " << "..." );
444  ATH_CHECK(outputeFexHandle.record(std::move(m_eContainer),std::move(m_eAuxContainer)));
445 
447  ATH_CHECK(l1Menu.isValid());
448 
449  auto & thr_eTAU = l1Menu->thrExtraInfo().eTAU();
450  int activeAlgo = thr_eTAU.algoVersion() == 0 ? xAOD::eFexTauRoI_v1::Heuristic : xAOD::eFexTauRoI_v1::BDT;
451  bool omitAltTauContainer = m_eFexTauAltxTOBOutKey.empty() || m_eFexTauAltOutKey.empty();
452 
453  // Repeat for Tau TOBs and xTOBs
454  if (activeAlgo == xAOD::eFexTauRoI_v1::Heuristic) {
456  if (!omitAltTauContainer) {
458  }
459  } else if (activeAlgo == xAOD::eFexTauRoI_v1::BDT) {
461  if (!omitAltTauContainer) {
463  }
464  }
465 
466  //Send TOBs to bytestream?
467  // ToDo
468  // To implement
469  // {--Implement--}
470 
471  return StatusCode::SUCCESS;
472 
473  }
474 
475  StatusCode eFEXSysSim::StoreTauTOBs(std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >& allTauTobObjects,
478  {
479  std::unique_ptr< xAOD::eFexTauRoIContainer > tauContainer;
480  std::unique_ptr< xAOD::eFexTauRoIAuxContainer > tauAuxContainer;
481  std::unique_ptr< xAOD::eFexTauRoIContainer > xtauContainer;
482  std::unique_ptr< xAOD::eFexTauRoIAuxContainer > xtauAuxContainer;
483 
484  tauContainer = std::make_unique<xAOD::eFexTauRoIContainer> ();
485  tauAuxContainer = std::make_unique<xAOD::eFexTauRoIAuxContainer> ();
486  tauContainer->setStore(tauAuxContainer.get());
487 
488  xtauContainer = std::make_unique<xAOD::eFexTauRoIContainer> ();
489  xtauAuxContainer = std::make_unique<xAOD::eFexTauRoIAuxContainer> ();
490  xtauContainer->setStore(xtauAuxContainer.get());
491 
492  // iterate over all tau TOBs and fill xTOB EDM with them
493  for( auto const& [efex, tobObjects] : allTauTobObjects ){
494  for( auto &tobObject: tobObjects ){
495  m_eFEXFillEDMTool->fillTauEDM(xtauContainer, efex, tobObject, true);
496  }
497  }
498 
499  // Form list of TOBs, sorted and truncated from each eFEX
500  // Vector to store sorted TOBs from all eFEXes
501  // Note that this step means moving TOBs from the all objects vector, which is why we do it last
502  std::vector<std::unique_ptr<eFEXtauTOB>> tauTOBs;
503  // Loop through eFEXes and sort TOBs from each
504  auto iterTau = allTauTobObjects.begin();
505  while (iterTau != allTauTobObjects.end()) {
506  std::vector<std::unique_ptr<eFEXtauTOB>> tobsSort = std::move(iterTau->second);
507  // sort tobs by their et (last 12 bits of the 32 bit tob word)
508  std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<eFEXtauTOB>>, std::placeholders::_1, std::placeholders::_2, true));
509  // Truncate at 6 TOBs per eFEX
510  if (tobsSort.size() > 6) tobsSort.resize(6);
511  // Append to system TOB list
512  for (unsigned int t = 0; t < tobsSort.size(); ++t) tauTOBs.push_back(std::move(tobsSort[t]));
513  // Next eFEX
514  ++iterTau;
515  }
516 
517  // iterate over sorted eFEX Tau TOBs and fill TOB EDM with them
518  for(auto &tobObject : tauTOBs){
519  int efex = tobObject->geteFEXID();
520  m_eFEXFillEDMTool->fillTauEDM(tauContainer, efex, tobObject);
521  }
522 
523  // Match xTOBs and TOBs and set isTOB flags if matched
524  matchTOBs(tauContainer, xtauContainer);
525 
526  // Record containers in StoreGate
527  SG::WriteHandle<xAOD::eFexTauRoIContainer> outputeFexTauxTOBHandle(eFexTauxTOBOutKey/*, ctx*/);
528  ATH_MSG_DEBUG(" write: " << outputeFexTauxTOBHandle.key() << " = " << "..." );
529  ATH_CHECK(outputeFexTauxTOBHandle.record(std::move(xtauContainer), std::move(xtauAuxContainer)));
530 
531  SG::WriteHandle<xAOD::eFexTauRoIContainer> outputeFexTauHandle(eFexTauOutKey/*, ctx*/);
532  ATH_MSG_DEBUG(" write: " << outputeFexTauHandle.key() << " = " << "..." );
533  ATH_CHECK(outputeFexTauHandle.record(std::move(tauContainer), std::move(tauAuxContainer)));
534 
535  return StatusCode::SUCCESS;
536 
537  }
538 } // end of namespace bracket
LVL1::eFEXSysSim::m_eFEXCollection
std::vector< eFEXSim * > m_eFEXCollection
Definition: eFEXSysSim.h:105
LVL1::eFEXSysSim::m_eFexTauActiveOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauActiveOutKey
Definition: eFEXSysSim.h:116
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
eTowerContainer.h
xAOD::eFexTauRoI_v1::BDT
@ BDT
This object is generated by the BDT algorithm.
Definition: eFexTauRoI_v1.h:48
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
LVL1::eFEXSysSim::m_eFexTauActivexTOBOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauActivexTOBOutKey
Definition: eFEXSysSim.h:117
LVL1::eFEXSysSim::execute
virtual StatusCode execute(eFEXOutputCollection *inputOutputCollection) override
Definition: eFEXSysSim.cxx:99
LVL1::eFEXSysSim::StoreTauTOBs
StatusCode StoreTauTOBs(std::map< int, std::vector< std::unique_ptr< eFEXtauTOB >> > &allTauTobObjects, SG::WriteHandleKey< xAOD::eFexTauRoIContainer > &eFexTauxTOBOutKey, SG::WriteHandleKey< xAOD::eFexTauRoIContainer > &eFexTauOutKey)
Definition: eFEXSysSim.cxx:475
eFEXSim.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TrigConf::L1ThrExtraInfo::eTAU
const L1ThrExtraInfo_eTAU & eTAU() const
Definition: L1ThrExtraInfo.cxx:133
LVL1::eFEXSysSim::m_eFEXSimTool
ToolHandle< IeFEXSim > m_eFEXSimTool
Definition: eFEXSysSim.h:107
eFEXTOBxTOBMatching.h
eFexEMRoIAuxContainer.h
TrigConf::L1Menu::thrExtraInfo
const L1ThrExtraInfo & thrExtraInfo() const
Access to extra info for threshold types.
Definition: L1Menu.cxx:307
eFexTauRoIContainer.h
LVL1::eFEXSysSim::m_eContainer
std::unique_ptr< xAOD::eFexEMRoIContainer > m_eContainer
Definition: eFEXSysSim.h:100
LVL1::eFEXSysSim::m_eTowerContainerSGKey
SG::ReadHandleKey< LVL1::eTowerContainer > m_eTowerContainerSGKey
Definition: eFEXSysSim.h:111
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LVL1::matchTOBs
void matchTOBs(T &TOBs, T &xTOBs)
Definition: eFEXTOBxTOBMatching.h:18
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
WriteHandle.h
Handle class for recording to StoreGate.
beamspotnt.cols
list cols
Definition: bin/beamspotnt.py:1114
LVL1::eFEXSysSim::m_eFexTauAltxTOBOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauAltxTOBOutKey
Definition: eFEXSysSim.h:119
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
LVL1::eFEXSysSim::m_allTauHeuristicTobObjects
std::map< int, std::vector< std::unique_ptr< eFEXtauTOB > > > m_allTauHeuristicTobObjects
Definition: eFEXSysSim.h:127
LVL1::eTower::phi
float phi() const
Definition: eTower.h:65
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LVL1::eFEXSysSim::m_eFexEMxTOBOutKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eFexEMxTOBOutKey
Definition: eFEXSysSim.h:115
test_pyathena.parent
parent
Definition: test_pyathena.py:15
LVL1::eFEXSysSim::calcTowerID
virtual int calcTowerID(int eta, int phi, int mod) const override
Definition: eFEXSysSim.cxx:94
LVL1::eFEXSysSim::init
virtual void init() override
Definition: eFEXSysSim.cxx:84
LVL1::eFEXSysSim::eFEXSysSim
eFEXSysSim(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: eFEXSysSim.cxx:37
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::eFexTauRoI_v1::Heuristic
@ Heuristic
This object is generated by the heuristic algorithm.
Definition: eFexTauRoI_v1.h:47
beamspotnt.rows
list rows
Definition: bin/beamspotnt.py:1112
LVL1::eFEXSysSim::m_eFEXFPGATowerIdProviderTool
ToolHandle< IeFEXFPGATowerIdProvider > m_eFEXFPGATowerIdProviderTool
Definition: eFEXSysSim.h:120
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LVL1::eFEXSysSim::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: eFEXSysSim.cxx:78
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
LVL1::eFEXSysSim::m_l1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_l1MenuKey
Definition: eFEXSysSim.h:112
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eFEXSysSim::m_eFexOutKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eFexOutKey
Definition: eFEXSysSim.h:114
TrigConf::L1ThrExtraInfo_eTAU::algoVersion
unsigned int algoVersion() const
Definition: L1ThrExtraInfo.h:283
SG::VarHandleBase::key
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:64
eFexTauRoI.h
LVL1::eFEXSysSim::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: eFEXSysSim.cxx:52
LVL1::eFEXSysSim::m_allEmTobObjects
std::map< int, std::vector< std::unique_ptr< eFEXegTOB > > > m_allEmTobObjects
Definition: eFEXSysSim.h:125
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
LVL1::eFEXSysSim::m_eFexTauAltOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauAltOutKey
Definition: eFEXSysSim.h:118
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
LVL1::eFEXSysSim::m_eAuxContainer
std::unique_ptr< xAOD::eFexEMRoIAuxContainer > m_eAuxContainer
Definition: eFEXSysSim.h:101
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
eFexTauRoIAuxContainer.h
LVL1::eFEXSysSim::m_eFEXFPGATool
ToolHandle< IeFEXFPGA > m_eFEXFPGATool
Definition: eFEXSysSim.h:121
eFexEMRoI.h
LVL1::eTower::eta
float eta() const
Definition: eTower.h:64
LVL1::eFEXSysSim::m_xeContainer
std::unique_ptr< xAOD::eFexEMRoIContainer > m_xeContainer
Definition: eFEXSysSim.h:102
ReadHandle.h
Handle class for reading from StoreGate.
AthAlgTool
Definition: AthAlgTool.h:26
L1Menu.h
LVL1::eFEXSysSim::TOBetSort
static bool TOBetSort(const TOBObjectClass &i, const TOBObjectClass &j, bool isTau)
Internal data.
Definition: eFEXSysSim.h:68
LVL1::eTowerContainer::findTower
const LVL1::eTower * findTower(int towerID) const
fast find method given identifier.
Definition: eTowerContainer.cxx:29
LVL1::eFEXOutputCollection
Definition: eFEXOutputCollection.h:23
eTower.h
value_type
Definition: EDM_MasterSearch.h:11
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
LVL1::eFEXSysSim::m_eFEXFillEDMTool
ToolHandle< IeFEXFillEDM > m_eFEXFillEDMTool
Definition: eFEXSysSim.h:109
LVL1::eFEXSysSim::cleanup
virtual void cleanup() override
Definition: eFEXSysSim.cxx:88
LVL1::eFEXSysSim::m_allTauBDTTobObjects
std::map< int, std::vector< std::unique_ptr< eFEXtauTOB > > > m_allTauBDTTobObjects
Definition: eFEXSysSim.h:128
LVL1::eFEXSysSim::m_xeAuxContainer
std::unique_ptr< xAOD::eFexEMRoIAuxContainer > m_xeAuxContainer
Definition: eFEXSysSim.h:103
eFexEMRoIContainer.h
eFEXSysSim.h