16 #include "eformat/SourceIdentifier.h"
32 ATH_MSG_INFO(
"========================================" );
33 ATH_MSG_INFO(
"Initialisation for RoIBuilder algorithm." );
34 ATH_MSG_INFO(
"========================================" );
66 return StatusCode::SUCCESS;
84 CHECK( eventInfoHandle.isValid() );
88 const int evtNum =
static_cast<int>(thisEvent->
eventNumber());
99 Header ctp_rdo_header( eformat::helper::SourceIdentifier( eformat::TDAQ_CTP,
106 std::vector< unsigned int > ctp_rdo_data;
108 bool ctp_simulation_error =
false;
110 CHECK( ctpSlinkHandle.isValid() );
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: "
124 <<
" (found/expected)";
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 ) {
131 << MSG::hex << std::setfill(
'0') << std::setw( 8 )
132 << ctp_rdo_data_inc[
i]
133 << MSG::dec << std::setfill(
' ') );
141 if( ctp_simulation_error ) {
144 <<
"Creating empty CTP RDO with error code!";
150 ctp_rdo_header =
Header(std::vector<uint32_t>(ctp_slink->
getHeader()));
155 for (
size_t i(0);
i < ctp_rdo_data.size(); ++
i) {
157 <<
" 0x" << MSG::hex << std::setfill(
'0') << std::setw( 8 )
159 << MSG::dec << std::setfill(
' ') );
169 std::move(ctp_rdo_trailer), ctp_rdo_data );
184 std::vector< EMTauResult > emtau_rdo_result_vector;
187 for(
unsigned int slink = 0; slink < numEMTauSlinks; ++slink ) {
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;
194 bool emtau_simulation_error =
false;
200 CHECK( handle.isValid() );
201 emtau_slink = handle.cptr();
203 unsigned int icnt = 0;
205 emtau_slink->
begin();
208 for( ; itr !=
end; ++itr ) {
210 if( ( icnt > ( wordsPerHeader + 1 ) ) &&
211 ( icnt <= ( emtau_slink->
size() - wordsPerTrailer - 1 ) ) ) {
213 EMTauRoI emtau_roi( ( *itr )->word() );
214 emtau_rdo_data.push_back( emtau_roi );
221 emtau_simulation_error =
true;
227 Trailer emtau_rdo_trailer( 0, 0 );
228 if( ! emtau_simulation_error ) {
234 EMTauResult emtau_rdo_result( std::move(emtau_rdo_header), std::move(emtau_rdo_trailer),
235 std::move(emtau_rdo_data) );
237 emtau_rdo_result_vector.push_back( std::move(emtau_rdo_result) );
246 std::vector< JetEnergyResult > jetenergy_rdo_result_vector;
248 for(
unsigned int slink = 0; slink < numJetEnergySlinks; ++slink ) {
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;
255 bool jetenergy_simulation_error =
false;
260 CHECK( handle.isValid() );
261 jetenergy_slink = handle.cptr();
266 unsigned int icnt = 0;
268 jetenergy_slink->
begin();
270 jetenergy_slink->
end();
271 for( ; itr !=
end; ++itr ) {
274 if( ( icnt > ( wordsPerHeader + 1 ) ) &&
275 ( icnt <= ( jetenergy_slink->
size() - wordsPerTrailer - 1 ) ) ) {
278 jetenergy_rdo_data.push_back( jetenergy_roi );
279 ATH_MSG_DEBUG(
"Jet/Energy RoI = " << MSG::hex << std::setw( 8 )
284 jetenergy_simulation_error =
true;
290 Trailer jetenergy_rdo_trailer( 0, 0 );
291 if( !jetenergy_simulation_error ) {
298 std::move(jetenergy_rdo_trailer),
299 std::move(jetenergy_rdo_data) );
301 jetenergy_rdo_result_vector.push_back( std::move(jetenergy_rdo_result) );
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;
315 bool muctpi_simulation_error =
false;
320 CHECK( handle.isValid() );
321 muctpi_slink = handle.cptr();
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 ) {
333 if( ( icnt > ( wordsPerHeader + 1 ) ) &&
335 wordsPerTrailer ) ) ) {
338 muctpi_rdo_data.push_back( muctpi_roi );
344 muctpi_simulation_error =
true;
349 Trailer muctpi_rdo_trailer( 0, 0 );
350 if( ! muctpi_simulation_error ) {
356 MuCTPIResult muctpi_rdo_result( std::move(muctpi_rdo_header), std::move(muctpi_rdo_trailer),
357 std::move(muctpi_rdo_data) );
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) );
369 roib_rdo_result->muCTPIResult().dumpData(
msg(
MSG::DEBUG ) );
379 CHECK( roibHandle.record( std::move( roib_rdo_result ) ) );
382 return StatusCode::SUCCESS;