ATLAS Offline Software
eFEXSim.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 // eFEXSim - description
7 // -------------------
8 // begin : 12 07 2019
9 // email : jacob.julian.kempster@cern.ch
10 // ***************************************************************************/
11 
12 #include "L1CaloFEXSim/eFEXSim.h"
13 #include "L1CaloFEXSim/eTower.h"
14 #include "L1CaloFEXSim/eFEXFPGA.h"
16 
17 namespace LVL1 {
18 
19  eFEXSim::eFEXSim(const std::string& type,const std::string& name,const IInterface* parent):
21  {
22  declareInterface<IeFEXSim>(this);
23  }
24 
25 
26  //---------------- Initialisation -------------------------------------------------
27 
29  {
30  ATH_CHECK( m_eFEXFPGATool.retrieve() );
31  return StatusCode::SUCCESS;
32  }
33 
34  //---------------- Finalisation -------------------------------------------------
35 
37  {
38  return StatusCode::SUCCESS;
39  }
40 
41 
43  {
44  int rows = sizeof m_eTowersIDs / sizeof m_eTowersIDs[0];
45  int cols = sizeof m_eTowersIDs[0] / sizeof m_eTowersIDs[0][0];
46 
47  m_id = -1;
48  m_eFEXFPGACollection.clear();
49  for (int i=0; i<rows; i++){
50  for (int j=0; j<cols; j++){
51  m_eTowersIDs[i][j] = 0;
52  }
53  }
54 
55  }
56 
57  void eFEXSim::init(int id)
58  {
59  m_id = id;
60  }
61 
64  {
65  }
66 
68 
69  }
70 
71 StatusCode eFEXSim::NewExecute(int tmp_eTowersIDs_subset[10][18], eFEXOutputCollection* inputOutputCollection){
72  m_emTobObjects.clear();
74  m_tauBDTTobObjects.clear();
75 
76  std::copy(&tmp_eTowersIDs_subset[0][0], &tmp_eTowersIDs_subset[0][0]+(10*18),&m_eTowersIDs[0][0]);
77 
78  int tmp_eTowersIDs_subset_FPGA[10][6];
79 
80 
81  //FPGA 0----------------------------------------------------------------------------------------------------------------------------------------------
82  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
83  for (int myrow = 0; myrow<10; myrow++){
84  for (int mycol = 0; mycol<6; mycol++){
85  tmp_eTowersIDs_subset_FPGA[myrow][mycol] = tmp_eTowersIDs_subset[myrow][mycol];
86  }
87  }
88  ATH_CHECK(m_eFEXFPGATool->init(0, m_id));
89  m_eFEXFPGATool->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
90  ATH_CHECK(m_eFEXFPGATool->execute(inputOutputCollection));
91  m_emTobObjects.push_back(m_eFEXFPGATool->getEmTOBs());
92  m_tauHeuristicTobObjects.push_back(m_eFEXFPGATool->getTauHeuristicTOBs());
93  m_tauBDTTobObjects.push_back(m_eFEXFPGATool->getTauBDTTOBs());
94  m_eFEXFPGATool->reset();
95  //FPGA 0----------------------------------------------------------------------------------------------------------------------------------------------
96 
97  //FPGA 1----------------------------------------------------------------------------------------------------------------------------------------------
98  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
99  for (int myrow = 0; myrow<10; myrow++){
100  for (int mycol = 4; mycol<10; mycol++){
101  tmp_eTowersIDs_subset_FPGA[myrow][mycol-4] = tmp_eTowersIDs_subset[myrow][mycol];
102  }
103  }
104  ATH_CHECK(m_eFEXFPGATool->init(1, m_id));
105  m_eFEXFPGATool->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
106  ATH_CHECK(m_eFEXFPGATool->execute(inputOutputCollection));
107  m_emTobObjects.push_back(m_eFEXFPGATool->getEmTOBs());
108  m_tauHeuristicTobObjects.push_back(m_eFEXFPGATool->getTauHeuristicTOBs());
109  m_tauBDTTobObjects.push_back(m_eFEXFPGATool->getTauBDTTOBs());
110  m_eFEXFPGATool->reset();
111  //FPGA 1----------------------------------------------------------------------------------------------------------------------------------------------
112 
113 
114  //FPGA 2----------------------------------------------------------------------------------------------------------------------------------------------
115  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
116  for (int myrow = 0; myrow<10; myrow++){
117  for (int mycol = 8; mycol<14; mycol++){
118  tmp_eTowersIDs_subset_FPGA[myrow][mycol-8] = tmp_eTowersIDs_subset[myrow][mycol];
119  }
120  }
121  ATH_CHECK(m_eFEXFPGATool->init(2, m_id));
122  m_eFEXFPGATool->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
123  ATH_CHECK(m_eFEXFPGATool->execute(inputOutputCollection));
124  m_emTobObjects.push_back(m_eFEXFPGATool->getEmTOBs());
125  m_tauHeuristicTobObjects.push_back(m_eFEXFPGATool->getTauHeuristicTOBs());
126  m_tauBDTTobObjects.push_back(m_eFEXFPGATool->getTauBDTTOBs());
127  m_eFEXFPGATool->reset();
128  //FPGA 2----------------------------------------------------------------------------------------------------------------------------------------------
129 
130  //FPGA 3----------------------------------------------------------------------------------------------------------------------------------------------
131  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
132  for (int myrow = 0; myrow<10; myrow++){
133  for (int mycol = 12; mycol<18; mycol++){
134  tmp_eTowersIDs_subset_FPGA[myrow][mycol-12] = tmp_eTowersIDs_subset[myrow][mycol];
135  }
136  }
137  ATH_CHECK(m_eFEXFPGATool->init(3, m_id));
138  m_eFEXFPGATool->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
139  ATH_CHECK(m_eFEXFPGATool->execute(inputOutputCollection));
140  m_emTobObjects.push_back(m_eFEXFPGATool->getEmTOBs());
141  m_tauHeuristicTobObjects.push_back(m_eFEXFPGATool->getTauHeuristicTOBs());
142  m_tauBDTTobObjects.push_back(m_eFEXFPGATool->getTauBDTTOBs());
143  m_eFEXFPGATool->reset();
144  //FPGA 3----------------------------------------------------------------------------------------------------------------------------------------------
145 
146  return StatusCode::SUCCESS;
147 
148 }
149 
150 
151 std::vector<std::unique_ptr<eFEXegTOB>> eFEXSim::getEmTOBs()
152 {
153 
154  std::vector<std::unique_ptr<eFEXegTOB>> tobsSort;
155  //bool first = true;
156 
157  // concatonate tobs from the fpgas
158  // As we're using unique_ptrs here we have to move rather than copy
159  for(auto &j : m_emTobObjects){
160  for (auto &k : j) {
161  tobsSort.push_back(std::move(k));
162  }
163  }
164 
165  ATH_MSG_DEBUG("number of tobs: " <<tobsSort.size() << " in eFEX: " << m_id);
166 
167  // Moving all TOB sorting to eFEXSysSim to allow xTOB generation
168  // Keep this just in case a more subtle need is discovered
169  /*
170  // sort the tobs from the fpgas by their et (last 12 bits of 32 bit word)
171  std::sort (tobsSort.begin(), tobsSort.end(), TOBetSort<eFEXegTOB>);
172 
173  // return the 6 highest ET TOBs from the efex
174  if (tobsSort.size() > 6) tobsSort.resize(6);
175  */
176  return tobsSort;
177 }
178 
179 
180 std::vector<std::unique_ptr<eFEXtauTOB>> eFEXSim::getTauTOBs(std::vector<std::vector<std::unique_ptr<eFEXtauTOB>> >& tauTobObjects)
181 {
182 
183  std::vector<std::unique_ptr<eFEXtauTOB>> tobsSort;
184 
185  // concatenate tobs from the fpgas
186  // As we're using unique_ptrs here we have to move rather than copy
187  for( auto &j : tauTobObjects ){
188  for (auto &k : j) {
189  tobsSort.push_back(std::move(k));
190  }
191  }
192 
193  ATH_MSG_DEBUG("number of tau tobs: " << tobsSort.size() << " in eFEX: " << m_id);
194 
195  // Moving all TOB sorting to eFEXSysSim to allow xTOB generation
196  // Keep this just in case a more subtle need is discovered
197  /*
198  // sort the tobs from the fpgas by their et (last 12 bits of 32 bit word)
199  std::sort( tobsSort.begin(), tobsSort.end(), TOBetSort<eFEXtauTOB>);
200 
201  // return the tob 6 highest ET TOBs from the efex
202  if (tobsSort.size() > 6) tobsSort.resize(6);
203  */
204  return tobsSort;
205 }
206 
207 std::vector<std::unique_ptr<eFEXtauTOB>> eFEXSim::getTauHeuristicTOBs()
208 {
210 }
211 
212 std::vector<std::unique_ptr<eFEXtauTOB>> eFEXSim::getTauBDTTOBs()
213 {
215 }
216 
217 void eFEXSim::SetTowersAndCells_SG(int tmp_eTowersIDs_subset[10][18]){ // METHOD USING ONLY IDS
218 
219  std::copy(&tmp_eTowersIDs_subset[0][0], &tmp_eTowersIDs_subset[0][0]+(10*18),&m_eTowersIDs[0][0]);
220 
221  int tmp_eTowersIDs_subset_FPGA[10][6];
222 
223  //FPGA 0----------------------------------------------------------------------------------------------------------------------------------------------
224  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
225  for (int myrow = 0; myrow<10; myrow++){
226  for (int mycol = 0; mycol<6; mycol++){
227  tmp_eTowersIDs_subset_FPGA[myrow][mycol] = tmp_eTowersIDs_subset[myrow][mycol];
228  }
229  }
230  m_eFEXFPGACollection.at(0)->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
231  //FPGA 0----------------------------------------------------------------------------------------------------------------------------------------------
232 
233  //FPGA 1----------------------------------------------------------------------------------------------------------------------------------------------
234  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
235  for (int myrow = 0; myrow<10; myrow++){
236  for (int mycol = 4; mycol<10; mycol++){
237  tmp_eTowersIDs_subset_FPGA[myrow][mycol-4] = tmp_eTowersIDs_subset[myrow][mycol];
238  }
239  }
240  m_eFEXFPGACollection.at(1)->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
241  //FPGA 1----------------------------------------------------------------------------------------------------------------------------------------------
242 
243 
244  //FPGA 2----------------------------------------------------------------------------------------------------------------------------------------------
245  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
246  for (int myrow = 0; myrow<10; myrow++){
247  for (int mycol = 8; mycol<14; mycol++){
248  tmp_eTowersIDs_subset_FPGA[myrow][mycol-8] = tmp_eTowersIDs_subset[myrow][mycol];
249  }
250  }
251  m_eFEXFPGACollection.at(2)->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
252  //FPGA 2----------------------------------------------------------------------------------------------------------------------------------------------
253 
254  //FPGA 3----------------------------------------------------------------------------------------------------------------------------------------------
255  memset(tmp_eTowersIDs_subset_FPGA, 0, sizeof tmp_eTowersIDs_subset_FPGA);
256  for (int myrow = 0; myrow<10; myrow++){
257  for (int mycol = 12; mycol<18; mycol++){
258  tmp_eTowersIDs_subset_FPGA[myrow][mycol-12] = tmp_eTowersIDs_subset[myrow][mycol];
259  }
260  }
261  m_eFEXFPGACollection.at(3)->SetTowersAndCells_SG(tmp_eTowersIDs_subset_FPGA);
262  //FPGA 3----------------------------------------------------------------------------------------------------------------------------------------------
263 
264 }
265 
266 } // end of namespace bracket
LVL1::eFEXSim::m_emTobObjects
std::vector< std::vector< std::unique_ptr< eFEXegTOB > > > m_emTobObjects
Definition: eFEXSim.h:73
eTowerContainer.h
LVL1::eFEXSim::reset
virtual void reset() override
Definition: eFEXSim.cxx:42
eFEXSim.h
LVL1::eFEXSim::SetTowersAndCells_SG
virtual void SetTowersAndCells_SG(int tmp[10][18]) override
Definition: eFEXSim.cxx:217
LVL1::eFEXSim::getTauHeuristicTOBs
virtual std::vector< std::unique_ptr< eFEXtauTOB > > getTauHeuristicTOBs() override
Definition: eFEXSim.cxx:207
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
LVL1::eFEXSim::NewExecute
virtual StatusCode NewExecute(int tmp[10][18], eFEXOutputCollection *inputOutputCollection) override
Definition: eFEXSim.cxx:71
LVL1::eFEXSim::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: eFEXSim.cxx:28
beamspotnt.cols
list cols
Definition: bin/beamspotnt.py:1114
LVL1::eFEXSim::getTauTOBs
std::vector< std::unique_ptr< eFEXtauTOB > > getTauTOBs(std::vector< std::vector< std::unique_ptr< eFEXtauTOB >> > &tauTobObjects)
Definition: eFEXSim.cxx:180
LVL1::eFEXSim::m_eTowersIDs
int m_eTowersIDs[10][18]
Definition: eFEXSim.h:69
lumiFormat.i
int i
Definition: lumiFormat.py:85
LVL1::eFEXSim::getEmTOBs
virtual std::vector< std::unique_ptr< eFEXegTOB > > getEmTOBs() override
Definition: eFEXSim.cxx:151
LVL1::eFEXSim::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: eFEXSim.cxx:36
LVL1::eFEXSim::execute
virtual void execute() override
Definition: eFEXSim.cxx:67
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::eFEXSim::init
virtual void init(int id) override
Definition: eFEXSim.cxx:57
LVL1::eFEXSim::m_id
int m_id
Internal data.
Definition: eFEXSim.h:68
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1::eFEXSim::m_tauHeuristicTobObjects
std::vector< std::vector< std::unique_ptr< eFEXtauTOB > > > m_tauHeuristicTobObjects
Definition: eFEXSim.h:74
beamspotnt.rows
list rows
Definition: bin/beamspotnt.py:1112
TrigConf::name
Definition: HLTChainList.h:35
LVL1::eFEXSim::getTauBDTTOBs
virtual std::vector< std::unique_ptr< eFEXtauTOB > > getTauBDTTOBs() override
Definition: eFEXSim.cxx:212
LVL1::eFEXSim::m_tauBDTTobObjects
std::vector< std::vector< std::unique_ptr< eFEXtauTOB > > > m_tauBDTTobObjects
Definition: eFEXSim.h:75
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
eFEXFPGA.h
LVL1::eFEXSim::m_eFEXFPGACollection
std::vector< eFEXFPGA * > m_eFEXFPGACollection
Definition: eFEXSim.h:71
LVL1::eFEXSim::m_eFEXFPGATool
ToolHandle< IeFEXFPGA > m_eFEXFPGATool
Definition: eFEXSim.h:77
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LVL1::eFEXSim::~eFEXSim
virtual ~eFEXSim()
Destructor.
Definition: eFEXSim.cxx:63
LVL1::eFEXSim::eFEXSim
eFEXSim(const std::string &type, const std::string &name, const IInterface *parent)
Constructors.
Definition: eFEXSim.cxx:19
calibdata.copy
bool copy
Definition: calibdata.py:27
AthAlgTool
Definition: AthAlgTool.h:26
LVL1::eFEXOutputCollection
Definition: eFEXOutputCollection.h:23
eTower.h
fitman.k
k
Definition: fitman.py:528