16 #include "eformat/SourceIdentifier.h"
46 ATH_MSG_INFO(
"========================================" );
47 ATH_MSG_INFO(
"Initialisation for RoIBuilder algorithm." );
48 ATH_MSG_INFO(
"========================================" );
80 return StatusCode::SUCCESS;
98 CHECK( eventInfoHandle.isValid() );
102 const int evtNum =
static_cast<int>(thisEvent->
eventNumber());
113 Header ctp_rdo_header( eformat::helper::SourceIdentifier( eformat::TDAQ_CTP,
120 std::vector< unsigned int > ctp_rdo_data;
122 bool ctp_simulation_error =
false;
124 CHECK( ctpSlinkHandle.isValid() );
129 ctp_simulation_error =
true;
130 REPORT_MESSAGE( MSG::WARNING ) <<
"CTP size is zero. No header, trailer, data element";
132 ctp_simulation_error =
true;
134 <<
"Found CTP size inconsistency: "
138 <<
" (found/expected)";
142 const std::vector< unsigned int > ctp_rdo_data_inc = ctp_slink->
getDataElements();
143 for(
size_t i(0);
i < ctp_rdo_data_inc.size(); ++
i ) {
145 << MSG::hex << std::setfill(
'0') << std::setw( 8 )
146 << ctp_rdo_data_inc[
i]
147 << MSG::dec << std::setfill(
' ') );
155 if( ctp_simulation_error ) {
158 <<
"Creating empty CTP RDO with error code!";
164 ctp_rdo_header =
Header(std::vector<uint32_t>(ctp_slink->
getHeader()));
169 for (
size_t i(0);
i < ctp_rdo_data.size(); ++
i) {
171 <<
" 0x" << MSG::hex << std::setfill(
'0') << std::setw( 8 )
173 << MSG::dec << std::setfill(
' ') );
183 std::move(ctp_rdo_trailer), ctp_rdo_data );
198 std::vector< EMTauResult > emtau_rdo_result_vector;
201 for(
unsigned int slink = 0; slink < numEMTauSlinks; ++slink ) {
203 eformat::helper::SourceIdentifier
204 emtau_source_id( eformat::TDAQ_CALO_CLUSTER_PROC_ROI, slink );
205 Header emtau_rdo_header( emtau_source_id.code(), evtNum );
206 std::vector< EMTauRoI > emtau_rdo_data;
208 bool emtau_simulation_error =
false;
214 CHECK( handle.isValid() );
215 emtau_slink = handle.cptr();
217 unsigned int icnt = 0;
219 emtau_slink->
begin();
222 for( ; itr !=
end; ++itr ) {
224 if( ( icnt > ( wordsPerHeader + 1 ) ) &&
225 ( icnt <= ( emtau_slink->
size() - wordsPerTrailer - 1 ) ) ) {
227 EMTauRoI emtau_roi( ( *itr )->word() );
228 emtau_rdo_data.push_back( emtau_roi );
235 emtau_simulation_error =
true;
241 Trailer emtau_rdo_trailer( 0, 0 );
242 if( ! emtau_simulation_error ) {
248 EMTauResult emtau_rdo_result( std::move(emtau_rdo_header), std::move(emtau_rdo_trailer),
249 std::move(emtau_rdo_data) );
251 emtau_rdo_result_vector.push_back( emtau_rdo_result );
260 std::vector< JetEnergyResult > jetenergy_rdo_result_vector;
262 for(
unsigned int slink = 0; slink < numJetEnergySlinks; ++slink ) {
264 eformat::helper::SourceIdentifier
265 jetenergy_source_id( eformat::TDAQ_CALO_JET_PROC_ROI, slink );
266 Header jetenergy_rdo_header( jetenergy_source_id.code(), evtNum );
267 std::vector< JetEnergyRoI > jetenergy_rdo_data;
269 bool jetenergy_simulation_error =
false;
274 CHECK( handle.isValid() );
275 jetenergy_slink = handle.cptr();
280 unsigned int icnt = 0;
282 jetenergy_slink->
begin();
284 jetenergy_slink->
end();
285 for( ; itr !=
end; ++itr ) {
288 if( ( icnt > ( wordsPerHeader + 1 ) ) &&
289 ( icnt <= ( jetenergy_slink->
size() - wordsPerTrailer - 1 ) ) ) {
292 jetenergy_rdo_data.push_back( jetenergy_roi );
293 ATH_MSG_DEBUG(
"Jet/Energy RoI = " << MSG::hex << std::setw( 8 )
298 jetenergy_simulation_error =
true;
304 Trailer jetenergy_rdo_trailer( 0, 0 );
305 if( !jetenergy_simulation_error ) {
312 std::move(jetenergy_rdo_trailer),
313 std::move(jetenergy_rdo_data) );
315 jetenergy_rdo_result_vector.push_back( jetenergy_rdo_result );
324 eformat::helper::SourceIdentifier
325 muon_source_id( eformat::TDAQ_MUON_CTP_INTERFACE, 0 );
326 Header muctpi_rdo_header( muon_source_id.code(), evtNum );
327 std::vector< MuCTPIRoI > muctpi_rdo_data;
329 bool muctpi_simulation_error =
false;
334 CHECK( handle.isValid() );
335 muctpi_slink = handle.cptr();
339 unsigned int icnt = 0;
340 std::vector< unsigned int >::const_iterator itr =
342 std::vector< unsigned int >::const_iterator
end =
344 for( ; itr !=
end; ++itr ) {
347 if( ( icnt > ( wordsPerHeader + 1 ) ) &&
349 wordsPerTrailer ) ) ) {
352 muctpi_rdo_data.push_back( muctpi_roi );
358 muctpi_simulation_error =
true;
363 Trailer muctpi_rdo_trailer( 0, 0 );
364 if( ! muctpi_simulation_error ) {
370 MuCTPIResult muctpi_rdo_result( std::move(muctpi_rdo_header), std::move(muctpi_rdo_trailer),
371 std::move(muctpi_rdo_data) );
376 std::unique_ptr<RoIBResult> roib_rdo_result = std::make_unique< RoIBResult>(
377 std::move(muctpi_rdo_result),
378 std::move(ctp_rdo_result),
379 std::move(jetenergy_rdo_result_vector),
380 std::move(emtau_rdo_result_vector) );
383 roib_rdo_result->muCTPIResult().dumpData(
msg(
MSG::DEBUG ) );
393 CHECK( roibHandle.record( std::move( roib_rdo_result ) ) );
396 return StatusCode::SUCCESS;