6 #include "eformat/DetectorMask.h"
7 #include "eformat/SourceIdentifier.h"
8 #include "eformat/Problem.h"
14 std::string hexRobId(
"0x ");
15 std::to_chars(hexRobId.data()+2, hexRobId.data()+hexRobId.size(),
num, 16);
16 hexRobId.resize(
std::min(10
ul,hexRobId.find(
' ')));
20 struct FractionPerLBNMonitor {
26 ~FractionPerLBNMonitor() {
38 const ToolHandle<GenericMonitoringTool>&
tool;
42 std::vector<eformat::FragmentProblem> problems;
43 rob->problems(problems);
44 s << problems.size() <<
" problems: [";
45 bool firstProblem{
true};
46 for (eformat::FragmentProblem problem : problems) {
47 if (firstProblem) {firstProblem=
false;}
49 s << eformat::helper::FragmentProblemDictionary.string(problem);
53 std::string robIdsToString(
const std::vector<uint32_t>& robIds) {
54 std::ostringstream
ss;
57 for (
const uint32_t robId : robIds) {
60 ss <<
"0x" << std::hex << robId << std::dec;
87 const std::vector<uint32_t>&
ids = decoderTool->robIds();
104 <<
"\" but needs to be one of [\"None\", \"Warning\", \"Error\", \"Fatal\"]");
105 return StatusCode::FAILURE;
107 return StatusCode::SUCCESS;
113 return StatusCode::SUCCESS;
122 return StatusCode::SUCCESS;
130 const eformat::helper::DetectorMask detectorMask{
metadata->getDetectorMask(),
metadata->getDetectorMask2()};
134 const eformat::helper::SourceIdentifier sid{robId};
135 if (!detectorMask.is_set(sid.subdetector_id())) {
137 ATH_MSG_WARNING(
"ROB ID 0x" << MSG::hex << robId << MSG::dec <<
" was requested for decoding, "
138 <<
"but the SubDetector " << sid.human_detector() <<
" is disabled in "
139 <<
"the detector mask. Will not require this ROB ID to be present in every event.");
144 return StatusCode::SUCCESS;
154 return StatusCode::SUCCESS;
170 std::string toolName{decoderTool->name().substr(decoderTool->name().rfind(
'.')+1)};
178 ATH_CHECK(decoderTool->convertFromBS(vrobfForTool, eventContext));
180 ATH_MSG_ERROR(
"Exception in " << toolName <<
"::convertFromBS: " << ex.what());
181 return StatusCode::FAILURE;
188 return StatusCode::SUCCESS;
194 const std::vector<uint32_t>&
ids,
195 std::string_view toolName,
196 const EventContext& eventContext)
const {
199 return (std::find(ids.cbegin(),ids.cend(),rob->source_id()) != ids.cend());
202 std::string missingFractionName{
"MissingROBFraction_"};
203 missingFractionName.append(toolName);
204 FractionPerLBNMonitor monMissingFraction{std::move(missingFractionName), eventContext.eventID().lumi_block(),
static_cast<float>(
ids.size()),
m_monTool};
207 if (
ids.size() !=
out.size()) {
211 if (std::find_if(
out.cbegin(),
out.cend(),eqRobId) ==
out.cend()) {
212 ++monMissingFraction;
213 std::string hexRobId = u32toHexString(
id);
215 ATH_MSG_DEBUG(
"Missing ROBFragment with ID " << hexRobId <<
" ("
216 << eformat::helper::SourceIdentifier(
id).human() <<
") requested by " << toolName
217 <<
" but it is allowed to be missing due to the detector mask or the "
222 ATH_MSG_ERROR(
"Missing ROBFragment with ID " << hexRobId <<
" ("
223 << eformat::helper::SourceIdentifier(
id).human() <<
") requested by " << toolName);
231 return StatusCode::FAILURE;
234 ATH_MSG_DEBUG(
"Found " <<
out.size() <<
" out of " <<
ids.size() <<
" ROBFragments requested by " << toolName);
235 return StatusCode::SUCCESS;
240 std::string_view toolName,
241 const EventContext& eventContext)
const {
246 std::string corruptedFractionName{
"CorruptedROBFraction_"};
247 std::string errorFractionName{
"ErroneousROBFraction_"};
248 corruptedFractionName.append(toolName);
249 errorFractionName.append(toolName);
250 FractionPerLBNMonitor monCorruptedFraction{std::move(corruptedFractionName), eventContext.eventID().lumi_block(),
static_cast<float>(
robs.size()),
m_monTool};
251 FractionPerLBNMonitor monErrorFraction{std::move(errorFractionName), eventContext.eventID().lumi_block(),
static_cast<float>(
robs.size()),
m_monTool};
261 sc = StatusCode::FAILURE;
268 ++monCorruptedFraction;
269 const uint32_t id{rob->rob_source_id()};
270 std::string hexRobId = u32toHexString(
id);
276 std::ostringstream
ss;
277 ss <<
"ROBFragment with ID " << hexRobId <<
" (" << eformat::helper::SourceIdentifier(
id).human()
278 <<
") requested by " << toolName <<
" has corrupted data with ";
279 printRobProblems(
ss, rob);
285 const uint32_t id{rob->rob_source_id()};
286 std::string hexRobId = u32toHexString(
id);
292 std::ostringstream
ss;
293 ss <<
"ROBFragment with ID " << hexRobId <<
" (" << eformat::helper::SourceIdentifier(
id).human()
294 <<
") requested by " << toolName <<
" has non-zero status 0x" << std::hex << rob->status()[0] << std::dec;