72 {
73
74
78
79
80
81
82
84 CHECK( eventInfoHandle.isValid() );
86
87
88 const int evtNum =
static_cast<int>(thisEvent->
eventNumber());
90
91
93
94
95
97
98
99 Header ctp_rdo_header( eformat::helper::SourceIdentifier( eformat::TDAQ_CTP,
101
102
104
105
106 std::vector< unsigned int > ctp_rdo_data;
107
108 bool ctp_simulation_error = false;
110 CHECK( ctpSlinkHandle.isValid() );
111 const LVL1CTP::CTPSLink* ctp_slink = ctpSlinkHandle.cptr();
112
113
115 ctp_simulation_error = true;
116 REPORT_MESSAGE( MSG::WARNING ) <<
"CTP size is zero. No header, trailer, data element";
118 ctp_simulation_error = true;
120 << "Found CTP size inconsistency: "
122
124 << " (found/expected)";
125
126
127 if(
msgLvl( MSG::DEBUG ) ) {
128 const std::vector< unsigned int > ctp_rdo_data_inc = ctp_slink->
getDataElements();
129 for(
size_t i(0);
i < ctp_rdo_data_inc.size(); ++
i ) {
130 ATH_MSG_DEBUG(
"broken CTP RoI = " << std::setw( 2 ) << i <<
' '
131 << MSG::hex << std::setfill('0') << std::setw( 8 )
132 << ctp_rdo_data_inc[i]
133 << MSG::dec << std::setfill(' ') );
134 }
135 }
136 } else {
139 }
140
141 if( ctp_simulation_error ) {
142
144 << "Creating empty CTP RDO with error code!";
145 ctp_rdo_trailer.setSimulationError();
146
147 } else {
148
149
150 ctp_rdo_header = Header(std::vector<uint32_t>(ctp_slink->
getHeader()));
151
152
154 if(
msgLvl( MSG::DEBUG ) ) {
155 for (
size_t i(0);
i < ctp_rdo_data.size(); ++
i) {
156 ATH_MSG_DEBUG(
"CTP RoI = " << MSG::dec << std::setw( 2 ) << i
157 << " 0x" << MSG::hex << std::setfill('0') << std::setw( 8 )
158 << ctp_rdo_data[i]
159 << MSG::dec << std::setfill(' ') );
160 }
161 }
162
163
165 }
166
167
169 std::move(ctp_rdo_trailer), ctp_rdo_data );
171
172
173
174
177
179
180
181
183
184 std::vector< EMTauResult > emtau_rdo_result_vector;
185
186
188
189 eformat::helper::SourceIdentifier
190 emtau_source_id( eformat::TDAQ_CALO_CLUSTER_PROC_ROI, slink );
191 Header emtau_rdo_header( emtau_source_id.code(), evtNum );
192 std::vector< EMTauRoI > emtau_rdo_data;
193
194 bool emtau_simulation_error = false;
195 const DataVector< LVL1CTP::SlinkWord >* emtau_slink = 0;
196
201 emtau_slink =
handle.cptr();
202
203 unsigned int icnt = 0;
205 emtau_slink->
begin();
208 for( ; itr !=
end; ++itr ) {
209 ++icnt;
212
213 EMTauRoI emtau_roi( ( *itr )->word() );
214 emtau_rdo_data.push_back( emtau_roi );
216 << emtau_roi.roIWord() );
217 }
218 }
219
220 } else {
221 emtau_simulation_error = true;
223 }
224
225
226
227 Trailer emtau_rdo_trailer( 0, 0 );
228 if( ! emtau_simulation_error ) {
229 emtau_rdo_trailer.setNumDataWords( emtau_rdo_data.size() );
230 } else {
231 emtau_rdo_trailer.setSimulationError();
232 }
233
234 EMTauResult emtau_rdo_result( std::move(emtau_rdo_header), std::move(emtau_rdo_trailer),
235 std::move(emtau_rdo_data) );
236
237 emtau_rdo_result_vector.push_back( std::move(emtau_rdo_result) );
238 }
239
241
242
243
245
246 std::vector< JetEnergyResult > jetenergy_rdo_result_vector;
247
249
250 eformat::helper::SourceIdentifier
251 jetenergy_source_id( eformat::TDAQ_CALO_JET_PROC_ROI, slink );
252 Header jetenergy_rdo_header( jetenergy_source_id.code(), evtNum );
253 std::vector< JetEnergyRoI > jetenergy_rdo_data;
254
255 bool jetenergy_simulation_error = false;
256 const DataVector< LVL1CTP::SlinkWord >* jetenergy_slink = 0;
257
261 jetenergy_slink =
handle.cptr();
262
265
266 unsigned int icnt = 0;
268 jetenergy_slink->
begin();
270 jetenergy_slink->
end();
271 for( ; itr !=
end; ++itr ) {
272
273 ++icnt;
276
277 JetEnergyRoI jetenergy_roi( ( *itr )->word() );
278 jetenergy_rdo_data.push_back( jetenergy_roi );
279 ATH_MSG_DEBUG(
"Jet/Energy RoI = " << MSG::hex << std::setw( 8 )
280 << jetenergy_roi.roIWord() );
281 }
282 }
283 } else {
284 jetenergy_simulation_error = true;
285 }
286
287
288
289
290 Trailer jetenergy_rdo_trailer( 0, 0 );
291 if( !jetenergy_simulation_error ) {
292 jetenergy_rdo_trailer.setNumDataWords( jetenergy_rdo_data.size() );
293 } else {
294 jetenergy_rdo_trailer.setSimulationError();
295 }
296
297 JetEnergyResult jetenergy_rdo_result( std::move(jetenergy_rdo_header),
298 std::move(jetenergy_rdo_trailer),
299 std::move(jetenergy_rdo_data) );
300
301 jetenergy_rdo_result_vector.push_back( std::move(jetenergy_rdo_result) );
302 }
303
305
306
307
309
310 eformat::helper::SourceIdentifier
311 muon_source_id( eformat::TDAQ_MUON_CTP_INTERFACE, 0 );
312 Header muctpi_rdo_header( muon_source_id.code(), evtNum );
313 std::vector< MuCTPIRoI > muctpi_rdo_data;
314
315 bool muctpi_simulation_error = false;
316 const L1MUINT::MuCTPIToRoIBSLink* muctpi_slink = 0;
317
321 muctpi_slink =
handle.cptr();
324
325 unsigned int icnt = 0;
326 std::vector< unsigned int >::const_iterator itr =
328 std::vector< unsigned int >::const_iterator
end =
330 for( ; itr !=
end; ++itr ) {
331
332 ++icnt;
336
337 MuCTPIRoI muctpi_roi( *itr );
338 muctpi_rdo_data.push_back( muctpi_roi );
340 << muctpi_roi.roIWord() );
341 }
342 }
343 } else {
344 muctpi_simulation_error = true;
345 }
346
347
348
349 Trailer muctpi_rdo_trailer( 0, 0 );
350 if( ! muctpi_simulation_error ) {
351 muctpi_rdo_trailer.setNumDataWords( muctpi_rdo_data.size() );
352 } else {
353 muctpi_rdo_trailer.setSimulationError();
354 }
355
356 MuCTPIResult muctpi_rdo_result( std::move(muctpi_rdo_header), std::move(muctpi_rdo_trailer),
357 std::move(muctpi_rdo_data) );
358
359
360
361
362 std::unique_ptr<RoIBResult> roib_rdo_result = std::make_unique< RoIBResult>(
363 std::move(muctpi_rdo_result),
364 std::move(ctp_rdo_result),
365 std::move(jetenergy_rdo_result_vector),
366 std::move(emtau_rdo_result_vector) );
367 if(
msgLvl( MSG::DEBUG ) ) {
369 roib_rdo_result->muCTPIResult().dumpData(
msg( MSG::DEBUG ) );
370
371
373 }
374
375
376
377
379 CHECK( roibHandle.record( std::move( roib_rdo_result ) ) );
380
381 return StatusCode::SUCCESS;
382 }
#define ATH_MSG_VERBOSE(x)
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
const std::vector< unsigned int > & getMuCTPIToRoIBWords() const
const std::vector< uint32_t > & getCTPToRoIBWords() const
get full raw data content
unsigned int getNumWordsPerCTPSLink() const
unsigned int getCTPVersionNumber() const
retrieve CTP version number
const std::vector< uint32_t > getTrailer() const
get raw trailer content
const std::vector< uint32_t > getDataElements() const
get raw data content
bool getAccept() const
get standard trigger accept
const std::vector< uint32_t > getHeader() const
get raw header content
Gaudi::Property< bool > m_doCalo
SG::ReadHandleKeyArray< SlinkWordDV > m_caloEMTauLocation
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::WriteHandleKey< RoIBResult > m_roibRDOLocation
Gaudi::Property< bool > m_doMuon
SG::ReadHandleKey< L1MUINT::MuCTPIToRoIBSLink > m_muctpiSLinkLocation
SG::ReadHandleKeyArray< SlinkWordDV > m_caloJetEnergyLocation
SG::ReadHandleKey< LVL1CTP::CTPSLink > m_ctpSLinkLocation
uint64_t eventNumber() const
The current event's event number.
StatusCode accept(const xAOD::Muon *mu)
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
static const unsigned int wordsPerTrailer
static const unsigned int wordsPerHeader
static const unsigned int numEMTauSlinks
static const unsigned int numJetEnergySlinks
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
EventInfo_v1 EventInfo
Definition of the latest event info version.
CTPResult_v1 CTPResult
Define the latest version of the CTPResult class.