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  int eFEXSysSim::calcTowerID(int eta, int phi, int mod) const {
77 
78  return ((64*eta) + phi + mod);
79  }
80 
82 
84  if(!this_eTowerContainer.isValid()){
85  ATH_MSG_FATAL("Could not retrieve eTowerContainer " << m_eTowerContainerSGKey.key());
86  return StatusCode::FAILURE;
87  }
88 
89  // remove TOBs of the previous events from the map
90  std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> > allEmTobObjects;
91  std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> > allTauHeuristicTobObjects;
92  std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> > allTauBDTTobObjects;
93 
94  // do mapping with preloaded csv file if it is available
95  if (m_eFEXFPGATowerIdProviderTool->ifhaveinputfile()) {
96  int tmp_eTowersIDs_subset_eFEX[10][18];
97  for (int i_efex{ 0 }; i_efex < 24; i_efex++) {
98  ATH_CHECK(m_eFEXFPGATowerIdProviderTool->getRankedTowerIDineFEX(i_efex, tmp_eTowersIDs_subset_eFEX));
99  m_eFEXSimTool->init(i_efex);
100  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset_eFEX, inputOutputCollection));
101  // Get TOBs from this eFEX
102  allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(i_efex, m_eFEXSimTool->getEmTOBs() ));
103  allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(i_efex, m_eFEXSimTool->getTauHeuristicTOBs() ));
104  allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(i_efex, m_eFEXSimTool->getTauBDTTOBs() ));
105  m_eFEXSimTool->reset();
106  }
107  } else {
108  // We need to split the towers into 3 blocks in eta and 8 blocks in phi.
109 
110  // boundaries in eta: -2.5, -0.8, 0.8, 2.5
111  // REAL boundaries in eta (overlaps must occur for sliding window algorithms!): -2.5, -0.7, -0.9, 0.9, 0.7, 2.5
112  // Written explicitly:
113  // -2.5 -> -0.7
114  // -0.9 -> 0.9
115  // 0.7 -> 2.5
116 
117  // boundaries in phi: 0.2, 1.0, 1.8, 2.6, 3.4, 4.2, 5.0, 5.8
118  // Written explicitly with REAL boundaries in phi (overlaps must occur for sliding window algorithms!)
119  // 0.1 -> 1.1
120  // 0.9 -> 1.9
121  // 1.7 -> 2.7
122  // 2.5 -> 3.5
123  // 3.3 -> 4.3
124  // 4.1 -> 5.1
125  // 4.9 -> 5.9
126  // 5.7 -> 0.3
127 
128  // C-SIDE NEGATIVE EFEXs
129  // DO THE LEFT-MOST (NEGATIVE ETA) EFEXs FIRST
130  int fexcounter = 0;
131  // Example values for eFEX 0
132  //id_modifier + phi + (64 * eta)
133  int emecEta = 24; int emecPhi = 1; int emecMod = 500000;
134  int initialEMEC = calcTowerID(emecEta,emecPhi,emecMod); //501537;
135  int transEta = 14; int transPhi = 1; int transMod = 300000;
136  int initialTRANS = calcTowerID(transEta,transPhi,transMod); //300897;
137  int embEta = 13; int embPhi = 1; int embMod = 100000;
138  int initialEMB = calcTowerID(embEta,embPhi,embMod); //100833;
139  int eFEXa = 0;
140 
141  for (int thisEFEX=eFEXa; thisEFEX<=21; thisEFEX+=3){
142 
143  if(fexcounter > 0){ initialEMEC += 8; initialTRANS += 8; initialEMB += 8; } // TODO // SOMEHOW REMOVE HARD-CODING?
144 
145  // decide which subset of towers (and therefore supercells) should go to the eFEX
146  std::map<int,eTower> tmp_eTowersColl_subset;
147 
148  // let's try doing this with an array initially just containing tower IDs.
149  int tmp_eTowersIDs_subset [10][18];
150 
151  int rows = sizeof tmp_eTowersIDs_subset / sizeof tmp_eTowersIDs_subset[0];
152  int cols = sizeof tmp_eTowersIDs_subset[0] / sizeof tmp_eTowersIDs_subset[0][0];
153 
154  // set the EMEC part
155  for(int thisCol=0; thisCol<10; thisCol++){
156  for(int thisRow=0; thisRow<rows; thisRow++){
157 
158  int towerid = initialEMEC - (thisCol * 64) + thisRow;
159 
160  if( (thisEFEX == 21) && (thisRow >= 7)){ towerid -= 64; };
161 
162  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
163  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
164 
165  }
166  }
167 
168  // set the TRANS part
169  for(int thisRow = 0; thisRow < rows; thisRow++){
170 
171  int towerid = initialTRANS + thisRow;
172 
173  if( (thisEFEX == 21) && (thisRow >= 7)){ towerid -= 64; };
174 
175  tmp_eTowersIDs_subset[thisRow][10] = towerid;
176  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
177 
178  }
179 
180  // set the EMB part
181  for(int thisCol = 11; thisCol < cols; thisCol++){
182  for(int thisRow=0; thisRow<rows; thisRow++){
183 
184  int towerid = initialEMB - ( (thisCol-11) * 64) + thisRow;
185 
186  if( (thisEFEX == 21) && (thisRow >= 7)){ towerid -= 64; };
187 
188  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
189  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
190 
191  }
192  }
193 
194 
195  if(false){
196  ATH_MSG_DEBUG("CONTENTS OF eFEX " << thisEFEX << " :");
197  for (int thisRow=rows-1; thisRow>=0; thisRow--){
198  for (int thisCol=0; thisCol<cols; thisCol++){
199  int tmptowerid = tmp_eTowersIDs_subset[thisRow][thisCol];
200  const float tmptowereta = this_eTowerContainer->findTower(tmptowerid)->eta();
201  const float tmptowerphi = this_eTowerContainer->findTower(tmptowerid)->phi();
202  if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowerphi << "][" << tmptowereta << "]) "); }
203  else { ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) |"); }
204  }
205  }
206  }
207 
208 
209  m_eFEXSimTool->init(thisEFEX);
210  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset, inputOutputCollection));
211  allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getEmTOBs() ) ));
212  allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauHeuristicTOBs() ) ));
213  allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauBDTTOBs() ) ));
214  m_eFEXSimTool->reset();
215 
216  fexcounter++;
217  }
218 
219  // CENTRAL EFEXs
220  // DO THE CENTRAL EFEXs SECOND
221  fexcounter = 0;
222  int embnegEta = 8; int embnegPhi = 1; int embnegMod = 100000;
223  int initialEMB_neg = calcTowerID(embnegEta,embnegPhi,embnegMod); //100513;
224  int embposEta = 0; int embposPhi = 1; int embposMod = 200000;
225  int initialEMB_pos = calcTowerID(embposEta,embposPhi,embposMod); //200001;
226  int eFEXb = 1;
227 
228  for (int thisEFEX=eFEXb; thisEFEX<=22; thisEFEX+=3){
229 
230  if(fexcounter > 0){ initialEMB_neg += 8; initialEMB_pos += 8; }
231 
232  // decide which subset of towers (and therefore supercells) should go to the eFEX
233  std::map<int,eTower> tmp_eTowersColl_subset;
234 
235  // doing this with an array initially just containing tower IDs.
236  int tmp_eTowersIDs_subset [10][18];
237 
238  int rows = sizeof tmp_eTowersIDs_subset / sizeof tmp_eTowersIDs_subset[0];
239  int cols = sizeof tmp_eTowersIDs_subset[0] / sizeof tmp_eTowersIDs_subset[0][0];
240 
241  // set the EMB part
242  for(int thisCol = 0; thisCol < cols; thisCol++){
243  for(int thisRow=0; thisRow<rows; thisRow++){
244  int towerid = -1;
245 
246  int tmp_initEMB = initialEMB_neg;
247 
248  if(thisCol < 9){
249  towerid = tmp_initEMB - ( (thisCol) * 64) + thisRow;
250  }
251  else{
252  tmp_initEMB = initialEMB_pos;
253  towerid = tmp_initEMB + ( (thisCol-9) * 64) + thisRow;
254  }
255 
256  if( (thisEFEX == 22) && (thisRow >= 7)){ towerid -= 64; };
257 
258  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
259 
260  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
261  }
262  }
263 
264 
265  if(false){
266  ATH_MSG_DEBUG("CONTENTS OF eFEX " << thisEFEX << " :");
267  for (int thisRow=rows-1; thisRow>=0; thisRow--){
268  for (int thisCol=0; thisCol<cols; thisCol++){
269  int tmptowerid = tmp_eTowersIDs_subset[thisRow][thisCol];
270  const float tmptowereta = this_eTowerContainer->findTower(tmptowerid)->eta();
271  const float tmptowerphi = this_eTowerContainer->findTower(tmptowerid)->phi();
272  if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) "); }
273  else { ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) |"); }
274  }
275  }
276  }
277 
278  //tool use instead
279  m_eFEXSimTool->init(thisEFEX);
280  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset, inputOutputCollection));
281  allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getEmTOBs() ) ));
282  allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauHeuristicTOBs() ) ));
283  allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauBDTTOBs() ) ));
284  m_eFEXSimTool->reset();
285 
286  fexcounter++;
287  }
288 
289  // POSITIVE EFEXs
290  // LET'S DO THE RIGHT-MOST (POSTITIVE ETA) EFEXs THIRD
291  fexcounter = 0;
292  // Example values for eFEX 0
293  emecEta = 15; emecPhi = 1; emecMod = 600000;
294  initialEMEC = calcTowerID(emecEta,emecPhi,emecMod); //600961;
295  transEta = 14; transPhi = 1; transMod = 400000;
296  initialTRANS = calcTowerID(transEta,transPhi,transMod); //400897;
297  embEta = 7; embPhi = 1; embMod = 200000;
298  initialEMB = calcTowerID(embEta,embPhi,embMod); //200449;
299  int eFEXc = 2;
300 
301  for (int thisEFEX=eFEXc; thisEFEX<=23; thisEFEX+=3){
302 
303  if(fexcounter > 0){ initialEMEC += 8; initialTRANS += 8; initialEMB += 8; }
304 
305  // decide which subset of towers (and therefore supercells) should go to the eFEX
306  std::map<int,eTower> tmp_eTowersColl_subset;
307 
308  // doing this with an array initially just containing tower IDs.
309  int tmp_eTowersIDs_subset [10][18];
310 
311  int rows = sizeof tmp_eTowersIDs_subset / sizeof tmp_eTowersIDs_subset[0];
312  int cols = sizeof tmp_eTowersIDs_subset[0] / sizeof tmp_eTowersIDs_subset[0][0];
313 
314  // set the EMB part
315  for(int thisCol = 0; thisCol < 7; thisCol++){
316  for(int thisRow=0; thisRow<rows; thisRow++){
317  int towerid = initialEMB + ( (thisCol) * 64) + thisRow;
318 
319  if( (thisEFEX == 23) && (thisRow >= 7)){ towerid -= 64; };
320 
321  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
322  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
323  }
324  }
325  // set the TRANS part
326  for(int thisRow = 0; thisRow < rows; thisRow++){
327  int towerid = initialTRANS + thisRow;
328 
329  if( (thisEFEX == 23) && (thisRow >= 7)){ towerid -= 64; };
330 
331  tmp_eTowersIDs_subset[thisRow][7] = towerid;
332  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
333  }
334  // set the EMEC part
335  for(int thisCol=8; thisCol<cols; thisCol++){
336  for(int thisRow=0; thisRow<rows; thisRow++){
337  int towerid = initialEMEC + ( (thisCol-8) * 64) + thisRow;
338 
339  if( (thisEFEX == 23) && (thisRow >= 7)){ towerid -= 64; };
340 
341  tmp_eTowersIDs_subset[thisRow][thisCol] = towerid;
342  tmp_eTowersColl_subset.insert( std::map<int, eTower>::value_type(towerid, *(this_eTowerContainer->findTower(towerid))));
343  }
344  }
345 
346  // Debug printout
347  if(false){
348  ATH_MSG_DEBUG("CONTENTS OF eFEX " << thisEFEX << " :");
349  for (int thisRow=rows-1; thisRow>=0; thisRow--){
350  for (int thisCol=0; thisCol<cols; thisCol++){
351  int tmptowerid = tmp_eTowersIDs_subset[thisRow][thisCol];
352  const float tmptowereta = this_eTowerContainer->findTower(tmptowerid)->eta();
353  const float tmptowerphi = this_eTowerContainer->findTower(tmptowerid)->phi();
354  if(thisCol != cols-1){ ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) "); }
355  else { ATH_MSG_DEBUG("| " << tmptowerid << "([" << tmptowereta << "][" << tmptowerphi << "]) |"); }
356  }
357  }
358  }
359 
360  //tool use instead
361  m_eFEXSimTool->init(thisEFEX);
362  ATH_CHECK(m_eFEXSimTool->NewExecute(tmp_eTowersIDs_subset, inputOutputCollection));
363  allEmTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXegTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getEmTOBs() ) ));
364  allTauHeuristicTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauHeuristicTOBs() ) ));
365  allTauBDTTobObjects.insert( std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >::value_type(thisEFEX, (m_eFEXSimTool->getTauBDTTOBs() ) ));
366  m_eFEXSimTool->reset();
367 
368  fexcounter++;
369  }
370 
371  }//close the non-csv loop over eFEXes
372 
373  // EM TOBs and xTOBs
374 
375  // TOB Containers
376  auto eContainer = std::make_unique<xAOD::eFexEMRoIContainer> ();
377  auto eAuxContainer = std::make_unique<xAOD::eFexEMRoIAuxContainer> ();
378  eContainer->setStore(eAuxContainer.get());
379 
380  // xTOB Containers
381  auto xeContainer = std::make_unique<xAOD::eFexEMRoIContainer> ();
382  auto xeAuxContainer = std::make_unique<xAOD::eFexEMRoIAuxContainer> ();
383  xeContainer->setStore(xeAuxContainer.get());
384 
385  // iterate over all Em Tobs and fill xTOB EDM with them
386  for( auto const& [efex, tobObjects] : allEmTobObjects ){
387  for(auto &tobObject : tobObjects){
388  m_eFEXFillEDMTool->fillEmEDM(xeContainer, efex, tobObject, true);
389  }
390  }
391 
392  // Form list of TOBs, sorted and truncated from each eFEX
393  // Vector to store sorted TOBs from all eFEXes
394  // Note that this step means moving TOBs from the all objects vector, which is why we do it last
395  std::vector<std::unique_ptr<eFEXegTOB>> emTOBs;
396  // Loop through eFEXes and sort TOBs from each
397  auto iter = allEmTobObjects.begin();
398  while (iter != allEmTobObjects.end()) {
399  std::vector<std::unique_ptr<eFEXegTOB>> tobsSort = std::move(iter->second);
400  // sort tobs by their et (last 12 bits of the 32 bit tob word)
401  std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<eFEXegTOB>>, std::placeholders::_1, std::placeholders::_2, false));
402  // Truncate at 6 TOBs per eFEX
403  if (tobsSort.size() > 6) tobsSort.resize(6);
404  // Append to system TOB list
405  for (unsigned int t = 0; t < tobsSort.size(); ++t) emTOBs.push_back(std::move(tobsSort[t]));
406  // Next eFEX
407  ++iter;
408  }
409 
410  // iterate over sorted eFEX EM TOBs and fill TOB EDM with them
411  for(auto &tobObject : emTOBs){
412  int efex = tobObject->geteFEXID();
413  m_eFEXFillEDMTool->fillEmEDM(eContainer, efex, tobObject);
414  }
415 
416  // Match xTOBs to TOBs and set isTOB flags if matched
417  matchTOBs(eContainer, xeContainer);
418 
419  // Record EDMs in StoreGate
420  SG::WriteHandle<xAOD::eFexEMRoIContainer> outputeFexEMxTOBHandle(m_eFexEMxTOBOutKey/*, ctx*/);
421  ATH_MSG_DEBUG(" write: " << outputeFexEMxTOBHandle.key() << " = " << "..." );
422  ATH_CHECK(outputeFexEMxTOBHandle.record(std::move(xeContainer),std::move(xeAuxContainer)));
423 
424  SG::WriteHandle<xAOD::eFexEMRoIContainer> outputeFexHandle(m_eFexOutKey/*, ctx*/);
425  ATH_MSG_DEBUG(" write: " << outputeFexHandle.key() << " = " << "..." );
426  ATH_CHECK(outputeFexHandle.record(std::move(eContainer),std::move(eAuxContainer)));
427 
429  ATH_CHECK(l1Menu.isValid());
430 
431  auto & thr_eTAU = l1Menu->thrExtraInfo().eTAU();
432  int activeAlgo = thr_eTAU.algoVersion() == 0 ? xAOD::eFexTauRoI_v1::Heuristic : xAOD::eFexTauRoI_v1::BDT;
433  bool omitAltTauContainer = m_eFexTauAltxTOBOutKey.empty() || m_eFexTauAltOutKey.empty();
434 
435  // Repeat for Tau TOBs and xTOBs
436  if (activeAlgo == xAOD::eFexTauRoI_v1::Heuristic) {
438  if (!omitAltTauContainer) {
440  }
441  } else if (activeAlgo == xAOD::eFexTauRoI_v1::BDT) {
443  if (!omitAltTauContainer) {
444  ATH_CHECK(StoreTauTOBs(allTauHeuristicTobObjects, m_eFexTauAltxTOBOutKey, m_eFexTauAltOutKey));
445  }
446  }
447 
448  //Send TOBs to bytestream?
449  // ToDo
450  // To implement
451  // {--Implement--}
452 
453  return StatusCode::SUCCESS;
454 
455  }
456 
457  StatusCode eFEXSysSim::StoreTauTOBs(std::map<int, std::vector<std::unique_ptr<eFEXtauTOB>> >& allTauTobObjects,
460  {
461  std::unique_ptr< xAOD::eFexTauRoIContainer > tauContainer;
462  std::unique_ptr< xAOD::eFexTauRoIAuxContainer > tauAuxContainer;
463  std::unique_ptr< xAOD::eFexTauRoIContainer > xtauContainer;
464  std::unique_ptr< xAOD::eFexTauRoIAuxContainer > xtauAuxContainer;
465 
466  tauContainer = std::make_unique<xAOD::eFexTauRoIContainer> ();
467  tauAuxContainer = std::make_unique<xAOD::eFexTauRoIAuxContainer> ();
468  tauContainer->setStore(tauAuxContainer.get());
469 
470  xtauContainer = std::make_unique<xAOD::eFexTauRoIContainer> ();
471  xtauAuxContainer = std::make_unique<xAOD::eFexTauRoIAuxContainer> ();
472  xtauContainer->setStore(xtauAuxContainer.get());
473 
474  // iterate over all tau TOBs and fill xTOB EDM with them
475  for( auto const& [efex, tobObjects] : allTauTobObjects ){
476  for( auto &tobObject: tobObjects ){
477  m_eFEXFillEDMTool->fillTauEDM(xtauContainer, efex, tobObject, true);
478  }
479  }
480 
481  // Form list of TOBs, sorted and truncated from each eFEX
482  // Vector to store sorted TOBs from all eFEXes
483  // Note that this step means moving TOBs from the all objects vector, which is why we do it last
484  std::vector<std::unique_ptr<eFEXtauTOB>> tauTOBs;
485  // Loop through eFEXes and sort TOBs from each
486  auto iterTau = allTauTobObjects.begin();
487  while (iterTau != allTauTobObjects.end()) {
488  std::vector<std::unique_ptr<eFEXtauTOB>> tobsSort = std::move(iterTau->second);
489  // sort tobs by their et (last 12 bits of the 32 bit tob word)
490  std::sort (tobsSort.begin(), tobsSort.end(), std::bind(TOBetSort<std::unique_ptr<eFEXtauTOB>>, std::placeholders::_1, std::placeholders::_2, true));
491  // Truncate at 6 TOBs per eFEX
492  if (tobsSort.size() > 6) tobsSort.resize(6);
493  // Append to system TOB list
494  for (unsigned int t = 0; t < tobsSort.size(); ++t) tauTOBs.push_back(std::move(tobsSort[t]));
495  // Next eFEX
496  ++iterTau;
497  }
498 
499  // iterate over sorted eFEX Tau TOBs and fill TOB EDM with them
500  for(auto &tobObject : tauTOBs){
501  int efex = tobObject->geteFEXID();
502  m_eFEXFillEDMTool->fillTauEDM(tauContainer, efex, tobObject);
503  }
504 
505  // Match xTOBs and TOBs and set isTOB flags if matched
506  matchTOBs(tauContainer, xtauContainer);
507 
508  // Record containers in StoreGate
509  SG::WriteHandle<xAOD::eFexTauRoIContainer> outputeFexTauxTOBHandle(eFexTauxTOBOutKey/*, ctx*/);
510  ATH_MSG_DEBUG(" write: " << outputeFexTauxTOBHandle.key() << " = " << "..." );
511  ATH_CHECK(outputeFexTauxTOBHandle.record(std::move(xtauContainer), std::move(xtauAuxContainer)));
512 
513  SG::WriteHandle<xAOD::eFexTauRoIContainer> outputeFexTauHandle(eFexTauOutKey/*, ctx*/);
514  ATH_MSG_DEBUG(" write: " << outputeFexTauHandle.key() << " = " << "..." );
515  ATH_CHECK(outputeFexTauHandle.record(std::move(tauContainer), std::move(tauAuxContainer)));
516 
517  return StatusCode::SUCCESS;
518 
519  }
520 } // end of namespace bracket
LVL1::eFEXSysSim::m_eFexTauActiveOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauActiveOutKey
Definition: eFEXSysSim.h:103
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
LVL1::eFEXSysSim::m_eFexTauActivexTOBOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauActivexTOBOutKey
Definition: eFEXSysSim.h:104
LVL1::eFEXSysSim::execute
virtual StatusCode execute(eFEXOutputCollection *inputOutputCollection) override
Definition: eFEXSysSim.cxx:81
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:457
eFEXSim.h
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:94
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_eTowerContainerSGKey
SG::ReadHandleKey< LVL1::eTowerContainer > m_eTowerContainerSGKey
Definition: eFEXSysSim.h:98
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:106
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::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:102
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:76
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:107
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
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:99
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eFEXSysSim::m_eFexOutKey
SG::WriteHandleKey< xAOD::eFexEMRoIContainer > m_eFexOutKey
Definition: eFEXSysSim.h:101
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
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
LVL1::eFEXSysSim::m_eFexTauAltOutKey
SG::WriteHandleKey< xAOD::eFexTauRoIContainer > m_eFexTauAltOutKey
Definition: eFEXSysSim.h:105
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
eFexTauRoIAuxContainer.h
LVL1::eFEXSysSim::m_eFEXFPGATool
ToolHandle< IeFEXFPGA > m_eFEXFPGATool
Definition: eFEXSysSim.h:108
eFexEMRoI.h
LVL1::eTower::eta
float eta() const
Definition: eTower.h:64
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:62
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:96
eFexEMRoIContainer.h
eFEXSysSim.h