9 #include "Gaudi/Interfaces/IOptionsSvc.h"
12 #include "hltinterface/DataCollector.h"
15 #include "eformat/Status.h"
23 static const size_t MAX_ROBFRAGMENTS = 4096;
26 base_class(
name, pSvcLocator)
32 ATH_MSG_INFO(
"HltROBDataProviderSvc::" << __FUNCTION__ <<
": name = " <<
name());
64 if (tmpsrc.human_detector() !=
"UNKNOWN") {
72 if (tmpsrc.human_detector() !=
"UNKNOWN") {
81 eformat::helper::SourceIdentifier tmpsrc(
it.first);
82 ATH_MSG_INFO(
" RobId=0x" << MSG::hex <<
it.first <<
" -> in Sub Det = " << tmpsrc.human_detector());
84 for (
auto it_status:
it.second) {
87 << MSG::hex << std::setfill(
'0' ) << std::setw(8) << tmpstatus.code()
88 <<
" Generic Part=0x" << std::setw(4) << tmpstatus.generic()
89 <<
" Specific Part=0x" << std::setw(4) << tmpstatus.specific() << MSG::dec);
96 eformat::helper::SourceIdentifier tmpsrc(
it.first, 0);
97 ATH_MSG_INFO(
" SubDetId=0x" << MSG::hex <<
it.first <<
" -> " << tmpsrc.human_detector());
98 for (
auto it_status :
it.second) {
101 << MSG::hex << std::setfill(
'0' ) << std::setw(8) << tmpstatus.code()
102 <<
" Generic Part=0x" << std::setw(4) << tmpstatus.generic()
103 <<
" Specific Part=0x" << std::setw(4) << tmpstatus.specific() << MSG::dec);
108 bool robOKSconfigFound =
false;
112 if ((jobOptionsSvc.retrieve()).isFailure()) {
115 if (jobOptionsSvc->has(
"DataFlowConfig.DF_Enabled_ROB_IDs") &&
116 m_enabledROBs.fromString(jobOptionsSvc->get(
"DataFlowConfig.DF_Enabled_ROB_IDs")).isSuccess()) {
117 robOKSconfigFound =
true;
119 << MSG::dec <<
m_enabledROBs.value().size() <<
" enabled ROB IDs.");
129 ATH_MSG_INFO(
" ---> The list of enabled ROBs has size = 0. No check will be performed ");
133 <<
". It was read from the partition database." );
136 <<
". It was read from job options." );
152 ATH_MSG_INFO(
" The following sub-detectors or sub-detector groups are configured for prefetching : Number = "
156 eformat::SubDetector
sd(
static_cast<eformat::SubDetector
>(
it));
157 eformat::helper::SourceIdentifier tmpsrc(
sd, 0);
158 ATH_MSG_INFO(
" SubDetId = 0x" << MSG::hex << std::setw(2) << (
int)
it << MSG::dec <<
" -> Group : "
159 << tmpsrc.human_group()
160 <<
" -> SubDetector : " << tmpsrc.human_detector() );
162 eformat::SubDetectorGroup sg(
static_cast<eformat::SubDetectorGroup
>(
it));
163 ATH_MSG_INFO(
" SubDetGroup = 0x" << MSG::hex << std::setw(1) << (
int)
it << MSG::dec <<
" -> Group : "
164 << eformat::helper::SubDetectorGroupDictionary.
string(sg));
170 eformat::helper::SourceIdentifier tmpsrc(rob);
189 return(StatusCode::SUCCESS);
195 return StatusCode::SUCCESS;
202 const std::string_view callerName)
204 ATH_MSG_VERBOSE(
"start of " << __FUNCTION__ <<
": Number of ROB Ids to add = " << robIds.size()
205 <<
" caller name = " << callerName);
209 std::vector<uint32_t> robIds_missing ;
212 std::vector<const ROBF*> robFragments_inCache ;
218 if (!robIds_missing.empty()) {
219 ATH_MSG_DEBUG( __FUNCTION__ <<
": Number of ROB Ids to reserve with DCM = " << robIds_missing.size());
226 auto mon_robres_nROBs =
Monitored::Scalar(
"NUMBER_ROBReserveData",robIds_missing.size());
230 <<
"Failed to reserve ROB data, caught an unexpected exception: " << ex.what());
233 <<
"Failed to reserve ROB data, caught an unexpected exception.");
241 ATH_MSG_FATAL(
"Obsolete method HltROBDataProviderSvc::setNextEvent(const EventContext& context, const std::vector<ROBF>& result) called "
242 <<
"\n context = " << context <<
" number of ROB fragments = " <<
result.size() );
273 size_t number_robs =
re->children(robF,MAX_ROBFRAGMENTS);
274 if (number_robs == MAX_ROBFRAGMENTS) {
275 ATH_MSG_ERROR(
"ROB buffer overflow: ROBs found = " << number_robs
276 <<
" Max. number of ROBs allowed = " << MAX_ROBFRAGMENTS);
278 std::vector<ROBF> rob_fragments;
279 rob_fragments.reserve(number_robs);
281 for (
size_t irob = 0; irob < number_robs; irob++) {
282 rob_fragments.push_back(
ROBF(robF[irob]));
285 const size_t nRobs = rob_fragments.size();
306 const std::vector<uint32_t>& robIds, std::vector<const ROBF*>& robFragments,
307 const std::string_view callerName)
316 ATH_MSG_VERBOSE(
"start of " << __FUNCTION__ <<
": Number of ROB Ids to get = " << robIds.size()
317 <<
" caller name = " << callerName);
320 std::vector<uint32_t> robIds_missing ;
326 if (robIds_missing.empty()) {
327 ATH_MSG_DEBUG( __FUNCTION__ <<
": All requested ROB Ids were found in the cache. ");
332 ATH_MSG_DEBUG( __FUNCTION__ <<
": Number of ROB Ids to retrieve with DCM = " << robIds_missing.size());
334 typedef std::vector<hltinterface::DCM_ROBInfo> ROBInfoVec;
335 ROBInfoVec vRobInfos;
338 vRobInfos.reserve( robIds_missing.size() ) ;
348 <<
"Failed to collect ROBs, caught an unexpected exception: " << ex.what()
349 <<
". Throwing hltonl::Exception::EventSourceCorrupted" );
353 <<
"Failed to collect ROBs, caught an unexpected exception. "
354 <<
"Throwing hltonl::Exception::EventSourceCorrupted" );
359 std::vector<ROBF> robFragments_missing;
360 robFragments_missing.reserve( vRobInfos.size() );
361 for(ROBInfoVec::const_iterator
it=vRobInfos.begin();
it!=vRobInfos.end(); ++
it) {
362 ATH_MSG_DEBUG(__FUNCTION__ <<
" ROB Id = 0x" << MSG::hex <<
it->robFragment.source_id() << MSG::dec
364 robFragments_missing.push_back(
it->robFragment );
371 for (
const ROBF* robFrag : robFragments) {
376 std::set<uint32_t> robIds_ignored;
380 for (
const hltinterface::DCM_ROBInfo& robInfo : vRobInfos) {
384 if (robIds_ignored.find(robInfo.robFragment.source_id()) != robIds_ignored.end()) {
395 std::set<uint32_t> robIds_disabled;
399 for (
uint32_t robId : robIds_disabled) {
430 robData.rob_size = robFrag.fragment_size_word();
431 robData.rob_status_word = robFrag.nstatus() ? robFrag.status()[0] : 0;
432 robData.rob_history = robStatus;
478 ATH_MSG_VERBOSE(
"start of " << __FUNCTION__ <<
" caller name = " << callerName);
488 typedef std::vector<hltinterface::DCM_ROBInfo> ROBInfoVec;
489 ROBInfoVec vRobInfos ;
493 vRobInfos.reserve( MAX_ROBFRAGMENTS ) ;
501 ATH_MSG_DEBUG( __FUNCTION__ <<
": Number of received ROB Ids = " << vRobInfos.size() );
503 auto mon_col_nROBs =
Monitored::Scalar(
"NUMBER_CollectAllROBs",vRobInfos.size());
507 <<
"Failed to collect complete event, caught an unexpected exception: " << ex.what()
508 <<
". Throwing hltonl::Exception::EventSourceCorrupted" );
512 <<
"Failed to collect complete event, caught an unexpected exception. "
513 <<
"Throwing hltonl::Exception::EventSourceCorrupted" );
518 std::vector<ROBF> robFragments_missing;
519 robFragments_missing.reserve( vRobInfos.size() );
520 for(ROBInfoVec::const_iterator
it=vRobInfos.begin();
it!=vRobInfos.end(); ++
it) {
521 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id = 0x" << MSG::hex <<
it->robFragment.source_id() << MSG::dec
523 robFragments_missing.push_back(
it->robFragment );
531 return vRobInfos.size();
548 if (rob->nstatus() == 0) {
549 rob_it_status = &null_status;
552 rob->status(rob_it_status);
556 eformat::helper::SourceIdentifier tmpsrc(rob->rob_source_id());
561 for (
auto it_status: (*map_it_rob).second) {
562 if (*rob_it_status == it_status) {
563 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id = 0x" << MSG::hex << tmpsrc.code()
564 <<
" with status = 0x" << *rob_it_status << MSG::dec
565 <<
" removed due to ROB filter rule.");
574 for (
auto it_status: (*map_it_subdet).second) {
575 if (*rob_it_status == it_status) {
576 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id = 0x" << MSG::hex << tmpsrc.code()
577 <<
" with status = 0x" << *rob_it_status << MSG::dec
578 <<
" removed due to SubDet filter rule.");
589 cache->
event =
nullptr;
594 { cache->
robmap.clear(); }
598 std::vector<const ROBF*>& robFragments_inCache,
599 std::vector<uint32_t>& robIds_missing,
600 std::optional<std::reference_wrapper<std::set<uint32_t>>> robIds_disabled )
602 ATH_MSG_VERBOSE(
"start of " << __FUNCTION__ <<
" number of ROB Ids to check = " << robIds_toCheck.size());
605 robFragments_inCache.clear();
606 robIds_missing.clear();
609 robFragments_inCache.reserve( robIds_toCheck.size() );
610 robIds_missing.reserve( robIds_toCheck.size() );
613 for (
uint32_t id : robIds_toCheck) {
617 if (missing_it != robIds_missing.end()) {
618 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id : 0x" << MSG::hex <<
id << MSG::dec <<
" is already on the list of missing IDs.");
623 { ROBMAP::const_iterator map_it = cache->
robmap.find(
id);
624 if (map_it != cache->
robmap.end()) {
625 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id 0x" << MSG::hex <<
id << MSG::dec
627 robFragments_inCache.push_back( &(map_it->second) );
634 std::vector<uint32_t>::const_iterator rob_enabled_it =
637 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id : 0x" << MSG::hex <<
id << MSG::dec
638 <<
" will be not added, since it is not on the list of enabled ROBs.");
639 if (robIds_disabled) {
640 robIds_disabled->get().insert(
id);
647 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id : 0x" << MSG::hex <<
id << MSG::dec <<
" is missing ");
648 robIds_missing.push_back(
id ) ;
653 std::optional<std::reference_wrapper<std::set<uint32_t>>> robIds_ignored)
655 ATH_MSG_VERBOSE(
"start of " << __FUNCTION__ <<
" number of ROB fragments to add = " << robFragments.size());
657 for (
const ROBF& rob : robFragments) {
661 ATH_MSG_VERBOSE(__FUNCTION__ <<
" Id = 0x" << std::hex <<
id << std::dec );
664 if ( (eformat::helper::SourceIdentifier(
id).module_id() != 0) &&
665 (eformat::helper::SourceIdentifier(
id).subdetector_id() == eformat::TDAQ_LVL2) ) {
666 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(
id).subdetector_id(),0).code();
668 ATH_MSG_ERROR(__FUNCTION__ <<
" Inconsistent flag for masking L2/EF module IDs");
671 }
else if ( (eformat::helper::SourceIdentifier(
id).module_id() != 0) &&
672 (eformat::helper::SourceIdentifier(
id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) &&
674 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(
id).subdetector_id(),0).code();
678 { ROBMAP::const_iterator
it = cache->
robmap.find(
id);
680 ATH_MSG_VERBOSE(__FUNCTION__ <<
" Duplicate ROB Id 0x" << MSG::hex <<
id << MSG::dec
688 if (rob.nstatus() > 0) {
690 rob.status(it_status);
692 ATH_MSG_VERBOSE(__FUNCTION__ <<
" ROB Id = 0x" << MSG::hex <<
id << std::setfill(
'0')
693 <<
" with Generic Status Code = 0x" << std::setw(4) << tmpstatus.generic()
694 <<
" and Specific Status Code = 0x" << std::setw(4) << tmpstatus.specific() << MSG::dec
697 if (robIds_ignored) {
698 robIds_ignored->get().insert(
id);
705 ATH_MSG_VERBOSE(__FUNCTION__ <<
" Empty ROB Id = 0x" << MSG::hex <<
id << MSG::dec
711 { cache->
robmap.insert(std::make_pair(
id,std::move(rob))); }