15 #include <unordered_map>
20 bool vectorContains(
const std::vector<std::string>&
vec,
const std::string&
str) {
32 return StatusCode::SUCCESS;
42 TrigConf::LogicParser logicParser;
53 if (
chain.l1item().empty() ||
chain.l1item().find(
',')!=std::string::npos) {
continue;}
56 std::map<std::string,unsigned int> thresholds = logicParser.parse(
item.definition())->elementsCount();
57 for (
const auto& [thrName, multiplicity] : thresholds) {
69 ATH_MSG_ERROR(
"Exception caught while parsing L1 thresholds for chain " <<
chain.name() <<
": " << ex.what());
70 return StatusCode::FAILURE;
74 for (
const std::shared_ptr<TrigConf::L1Threshold>& thr : l1Menu->thresholds()) {
80 return StatusCode::SUCCESS;
91 std::ostringstream ssPassedThresholds;
92 std::unordered_map<TrigCompositeUtils::DecisionID, size_t> tobThresholdCounts;
93 std::unordered_set<std::string> overflowThresholdTypes;
98 ATH_MSG_DEBUG(
"No DecisionContainer " << decisionsKey <<
" for threshold type " << thrType <<
" found in this event");
104 std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
105 const bool hasDetail =
d->getDetail(
"thresholds", passedThresholdIDs);
107 ATH_MSG_ERROR(
"Detail \"thresholds\" missing from Decision in the container " << decisionsKey);
108 return StatusCode::FAILURE;
110 bool overflow{
false};
111 if (
d->hasDetail<
char>(
"overflow")) {
112 overflow =
static_cast<bool>(
d->getDetail<
char>(
"overflow"));
114 if (
doDebug()) {ssPassedThresholds.str(
"");}
119 if (tobThresholdCounts.find(thrNameHash)==tobThresholdCounts.end()) {
120 tobThresholdCounts[thrNameHash] = 1;
123 tobThresholdCounts[thrNameHash] += 1;
126 if (!ssPassedThresholds.str().empty()) ssPassedThresholds <<
", ";
133 if (optTob.has_value()) {
135 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] corresponds to TOB with word / et / eta / phi = 0x"
139 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] TOB type not supported by template code for "
140 <<
"debug printout of word / et / eta / phi");
142 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] TOB passes " << passedThresholdIDs.size()
143 <<
" thresholds: " << ssPassedThresholds.str());
152 std::unordered_map<TrigCompositeUtils::DecisionID, size_t> ctpThresholdCounts;
162 for (
const auto& [thrNameHash, multiplicity] : thresholds) {
163 if (ctpThresholdCounts.find(thrNameHash)==ctpThresholdCounts.end()) {
164 ctpThresholdCounts[thrNameHash] = multiplicity;
166 else if (multiplicity > ctpThresholdCounts[thrNameHash]) {
167 ctpThresholdCounts[thrNameHash] = multiplicity;
175 for (
const auto& [thrNameHash, ctpCount] : ctpThresholdCounts) {
180 ATH_MSG_ERROR(
"Threshold with hash " << thrNameHash <<
" not found in the hash->name map");
181 return StatusCode::FAILURE;
183 const std::string& thrName =
it->second;
187 bool overflow{overflowThresholdTypes.find(thrType)!=overflowThresholdTypes.end()};
189 ATH_MSG_DEBUG(
"Threshold " << thrName <<
" accepted by the CTP with multiplicity " << ctpCount
190 <<
" is flagged as overflow and thus may be missing TOBs");
194 bool missing = (tobThresholdCounts.find(thrNameHash)==tobThresholdCounts.end());
199 <<
" accepted by the CTP with multiplicity " << ctpCount
200 << (overflow ?
", likely due to overflow" :
""));
203 ATH_MSG_ERROR(
"No TOBs found passing the threshold " << thrName
204 <<
" accepted by the CTP with multiplicity " << ctpCount);
205 sc = StatusCode::FAILURE;
209 tobCount = tobThresholdCounts.at(thrNameHash);
211 tooFew = (tobCount < ctpCount);
216 ATH_MSG_WARNING(
"Too few (" << tobCount <<
") TOBs found passing the threshold " << thrName
217 <<
" accepted by the CTP with multiplicity " << ctpCount
218 << (overflow ?
", likely due to overflow" :
""));
220 ATH_MSG_ERROR(
"Too few (" << tobCount <<
") TOBs found passing the threshold " << thrName
221 <<
" accepted by the CTP with multiplicity " << ctpCount);
222 sc = StatusCode::FAILURE;
226 if (missing || tooFew) {
228 Monitored::Scalar monMissingTOBsIncludingOverflow{
"MissingTOBsIncludingOverflow", thrName};
238 ATH_MSG_DEBUG(
"Check passed. Found " << tobCount <<
" TOBs passing the threshold " << thrName
239 <<
" accepted by the CTP with multiplicity " << ctpCount);
245 const auto ctpIt = ctpThresholdCounts.find(thrNameHash);
246 size_t ctpCount = (ctpIt==ctpThresholdCounts.cend()) ? 0 : ctpIt->second;
247 const auto tobIt = tobThresholdCounts.find(thrNameHash);
248 size_t tobCount = (tobIt==tobThresholdCounts.cend()) ? 0 : tobIt->second;
249 int tobMinusCtpCount =
static_cast<int>(ctpCount) -
static_cast<int>(tobCount);