ATLAS Offline Software
Loading...
Searching...
No Matches
JEMJetSim.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// /***************************************************************************
6// JEMJetSim.cxx - description
7// -------------------
8// begin : Wed Mar 12 2014
9// email : Alan.Watson@CERN.CH
10// ***************************************************************************/
11//
12//
13//================================================
14// JEMJetSim class Implementation
15// ================================================
16//
17//
18//
19
20// Utilities
21
22// This algorithm includes
23#include "JEMJetSim.h"
25
29
35
36
37
38namespace LVL1{
39
40using namespace TrigConf;
41
42//--------------------------------
43// Constructors and destructors
44//--------------------------------
45
47 ( const std::string& name, ISvcLocator* pSvcLocator )
48 : AthAlgorithm( name, pSvcLocator ),
49 m_allTOBs(0),
50 m_JetCMXData(0),
51 m_JetTool("LVL1::L1JEMJetTools/L1JEMJetTools")
52{
53}
54
55
56//---------------------------------
57// initialise()
58//---------------------------------
59
61{
62 ATH_CHECK( m_JetElementInputKey.initialize() );
63 ATH_CHECK( m_JEMTobRoIOutputKey.initialize() );
64 ATH_CHECK( m_JetCMXDataOutputKey.initialize() );
65 ATH_CHECK( m_JetTool.retrieve() );
66 return StatusCode::SUCCESS ;
67}
68
69
70//----------------------------------------------
71// execute() method called once per event
72//----------------------------------------------
73//
74
75
76StatusCode JEMJetSim::execute( )
77{
78
79 /*
80 Retrieve collection of JetElements
81 Fill a std::map of JetInputs from them
82 Loop over crates/modules
83 For each crate, loop over towers and find TOBs
84 form backplane data objects
85 form daq objects
86 */
87
88 //make a message logging stream
89
90 ATH_MSG_DEBUG ( "starting JEMJetSim" );
91
92 // Create containers for this event
93 m_JetCMXData = new DataVector<JetCMXData>; //Container of backplane data objects
94 m_allTOBs = new DataVector<JEMTobRoI>; // Container to hold all TOB RoIs in event
95
96 // Retrieve the JetElementContainer
98
99 if (rh.isValid()) {
100 const DataVector<xAOD::JetElement>* storedJEs = &(*rh);
101 if ( true ) {
102 // Check size of JetElementCollection - zero would indicate a problem
103 if (storedJEs->size() == 0)
104 ATH_MSG_WARNING("Empty JetElementContainer - looks like a problem" );
105
106 // Form JetInputs and put them in a map
107 std::map<int, JetInput*>* inputMap = new std::map<int, JetInput*> ;
108 m_JetTool->mapJetInputs(storedJEs, inputMap);
109
110 // Loop over crates and modules
111 for (int iCrate = 0; iCrate < 2; ++iCrate) {
112 for (int iModule = 0; iModule < 16; ++iModule) {
113
114 // For each module, find TOBs and backplane data
115 std::vector<unsigned int> jetCMXData;
116 m_JetTool->findJEMResults(inputMap,iCrate,iModule,m_allTOBs,jetCMXData);
117 // Push backplane data into output DataVectors
118 JetCMXData* bpData = new JetCMXData(iCrate,iModule,jetCMXData);
119 m_JetCMXData -> push_back(bpData);
120
121 } // loop over modules
122 } // loop over crates
123
125 for (std::map<int, JetInput*>::iterator it = inputMap->begin(); it != inputMap->end(); ++it) {
126 delete (*it).second;
127 }
128 delete inputMap;
129
130 } // found TriggerTowers
131
132 else ATH_MSG_WARNING("Error retrieving JetElements" );
133 }
134 else ATH_MSG_WARNING("No JetElementContainer at " << m_JetElementInputKey );
135
136
137 // Store module readout and backplane results in the TES
140
141 // Clean up at end of event
142 m_JetCMXData = 0;
143 m_allTOBs = 0;
144
145 return StatusCode::SUCCESS;
146}
147
150
151 size_t datasize = m_JetCMXData->size();
152
153 // Store backplane data objects
155 const EventContext& ctx = Gaudi::Hive::currentContext();
156 StatusCode sc = SG::makeHandle(m_JetCMXDataOutputKey, ctx).record( std::unique_ptr<DataVector<JetCMXData>>(m_JetCMXData) );
157 m_JetCMXData = nullptr;
158
159 if (sc.isSuccess()) {
160 ATH_MSG_VERBOSE ( "Stored " << datasize
161 << " JetCMXData at " << m_JetCMXDataOutputKey );
162 }
163 else {
164 ATH_MSG_ERROR("failed to write JetCMXData to "
166 }
167
168 return;
169
170} //end storeBackplaneTOBs
171
172
175
176 size_t n_jetsTobs = m_allTOBs->size();
177
178 const EventContext& ctx = Gaudi::Hive::currentContext();
179 StatusCode sc = SG::makeHandle(m_JEMTobRoIOutputKey, ctx).record( std::unique_ptr<DataVector<JEMTobRoI>>(m_allTOBs) );
180 m_allTOBs = nullptr;
181
182 if (sc.isSuccess()) {
183 ATH_MSG_VERBOSE ( "Stored " << n_jetsTobs
184 << " Jet TOBs at " << m_JEMTobRoIOutputKey );
185 }
186 else {
187 ATH_MSG_ERROR("failed to write JEMTobRoIs to "
189 }
190
191} //end storeModuleRoIs
192
193
194} // end of LVL1 namespace bracket
195
196
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Derived DataVector<T>.
Definition DataVector.h:795
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadHandleKey< xAOD::JetElementContainer > m_JetElementInputKey
Where to find the JetElements.
Definition JEMJetSim.h:81
StatusCode initialize()
Definition JEMJetSim.cxx:60
SG::WriteHandleKey< DataVector< JEMTobRoI > > m_JEMTobRoIOutputKey
Locations of outputs in StoreGate.
Definition JEMJetSim.h:84
DataVector< JetCMXData > * m_JetCMXData
Backplane data objects: CPM outputs to CMX.
Definition JEMJetSim.h:78
StatusCode execute()
Definition JEMJetSim.cxx:76
ToolHandle< LVL1::IL1JEMJetTools > m_JetTool
The essentials - data access, configuration, tools.
Definition JEMJetSim.h:88
void storeBackplaneTOBs()
Store module outputs in TES as inputs to CMX simulation.
SG::WriteHandleKey< DataVector< JetCMXData > > m_JetCMXDataOutputKey
Definition JEMJetSim.h:85
DataVector< JEMTobRoI > * m_allTOBs
TOB RoIs for RoIB input and DAQ output simulation.
Definition JEMJetSim.h:75
JEMJetSim(const std::string &name, ISvcLocator *pSvcLocator)
Definition JEMJetSim.cxx:47
void storeModuleRoIs()
Store TOB RoI objects in the TES.
The JetCMXData object contains the data transferred from the CPM to one of the Jet CMX in the crate.
Definition JetCMXData.h:25
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())