Perform the check and fill the corresponding histograms.
84 {
85 auto monTimer = Monitored::Timer<std::chrono::duration<float, std::milli>>("TIME_consistencyCheck");
87
88
89
90
91 std::ostringstream ssPassedThresholds;
92 std::unordered_map<TrigCompositeUtils::DecisionID, size_t> tobThresholdCounts;
93 std::unordered_set<std::string> overflowThresholdTypes;
94
96 SG::ReadHandle<TrigCompositeUtils::DecisionContainer>
decisions{decisionsKey, ctx.getExtension<Atlas::ExtendedEventContext>().
proxy()->name()};
98 ATH_MSG_DEBUG(
"No DecisionContainer " << decisionsKey <<
" for threshold type " << thrType <<
" found in this event");
99 continue;
100 }
101 size_t idec{0};
102
103
105 std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
106 static const std::string thresholdsStr{"thresholds"};
107 const bool hasDetail =
d->getDetail(thresholdsStr, passedThresholdIDs);
108 if (!hasDetail) {
109 ATH_MSG_ERROR(
"Detail \"thresholds\" missing from Decision in the container " << decisionsKey);
110 return StatusCode::FAILURE;
111 }
112 bool overflow{false};
113 if (
d->hasDetail<
char>(
"overflow")) {
114 overflow =
static_cast<bool>(
d->getDetail<
char>(
"overflow"));
115 }
116 if (
doDebug()) {ssPassedThresholds.str(
"");}
118 if (overflow) {
120 }
121 if (tobThresholdCounts.find(thrNameHash)==tobThresholdCounts.end()) {
122 tobThresholdCounts[thrNameHash] = 1;
123 }
124 else {
125 tobThresholdCounts[thrNameHash] += 1;
126 }
128 if (!ssPassedThresholds.str().empty()) ssPassedThresholds << ", ";
130 }
131 }
133 namespace RoIDefs = HLTSeedingRoIToolDefs;
135 if (optTob.has_value()) {
136 const RoIDefs::AnyRoIPointer& tob = optTob.value();
137 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] corresponds to TOB with word / et / eta / phi = 0x"
138 << MSG::hex << RoIDefs::roiWord(tob) << MSG::dec << " / " << RoIDefs::roiTobEt(tob)
139 << " / " << RoIDefs::roiEta(tob) << " / " << RoIDefs::roiPhi(tob));
140 } else {
141 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] TOB type not supported by template code for "
142 << "debug printout of word / et / eta / phi");
143 }
144 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] TOB passes " << passedThresholdIDs.size()
145 << " thresholds: " << ssPassedThresholds.str());
146 ++idec;
147 }
148 }
149 }
150
151
152
153
154 std::unordered_map<TrigCompositeUtils::DecisionID, size_t> ctpThresholdCounts;
155
159 ATH_MSG_DEBUG(
"Cannot monitor chain " << chainID <<
" -> " << HLT::Identifier(chainID).
name() <<
", skipping");
160 continue;
161 }
163
164 for (const auto& [thrNameHash, multiplicity] : thresholds) {
165 if (ctpThresholdCounts.find(thrNameHash)==ctpThresholdCounts.end()) {
166 ctpThresholdCounts[thrNameHash] = multiplicity;
167 }
168 else if (multiplicity > ctpThresholdCounts[thrNameHash]) {
169 ctpThresholdCounts[thrNameHash] = multiplicity;
170 }
171 }
172 }
173
174
175
176
177 for (const auto& [thrNameHash, ctpCount] : ctpThresholdCounts) {
178 size_t tobCount{0};
179 bool tooFew{false};
182 ATH_MSG_ERROR(
"Threshold with hash " << thrNameHash <<
" not found in the hash->name map");
183 return StatusCode::FAILURE;
184 }
185 const std::string& thrName =
it->second;
187
188
189 bool overflow{overflowThresholdTypes.find(thrType)!=overflowThresholdTypes.end()};
190 if (overflow) {
191 ATH_MSG_DEBUG(
"Threshold " << thrName <<
" accepted by the CTP with multiplicity " << ctpCount
192 << " is flagged as overflow and thus may be missing TOBs");
193 }
194
195
196 bool missing = (tobThresholdCounts.find(thrNameHash)==tobThresholdCounts.end());
197
198 if (missing) {
201 << " accepted by the CTP with multiplicity " << ctpCount
202 << (overflow ? ", likely due to overflow" : ""));
203
204 } else {
205 ATH_MSG_ERROR(
"No TOBs found passing the threshold " << thrName
206 << " accepted by the CTP with multiplicity " << ctpCount);
207 sc = StatusCode::FAILURE;
208 }
209 }
210 else {
211 tobCount = tobThresholdCounts.at(thrNameHash);
212
213 tooFew = (tobCount < ctpCount);
214 }
215
216 if (tooFew) {
218 ATH_MSG_WARNING(
"Too few (" << tobCount <<
") TOBs found passing the threshold " << thrName
219 << " accepted by the CTP with multiplicity " << ctpCount
220 << (overflow ? ", likely due to overflow" : ""));
221 } else {
222 ATH_MSG_ERROR(
"Too few (" << tobCount <<
") TOBs found passing the threshold " << thrName
223 << " accepted by the CTP with multiplicity " << ctpCount);
224 sc = StatusCode::FAILURE;
225 }
226 }
227
228 if (missing || tooFew) {
229
230 Monitored::Scalar monMissingTOBsIncludingOverflow{"MissingTOBsIncludingOverflow", thrName};
231 if (overflow) {
232 Monitored::Group{
m_monTool, monMissingTOBsIncludingOverflow};
233 }
234 else {
235 Monitored::Scalar monMissingTOBs{"MissingTOBs", thrName};
236 Monitored::Group{
m_monTool, monMissingTOBs, monMissingTOBsIncludingOverflow};
237 }
238 }
239 else {
240 ATH_MSG_DEBUG(
"Check passed. Found " << tobCount <<
" TOBs passing the threshold " << thrName
241 << " accepted by the CTP with multiplicity " << ctpCount);
242 }
243 }
244
245
247 const auto ctpIt = ctpThresholdCounts.find(thrNameHash);
248 size_t ctpCount = (ctpIt==ctpThresholdCounts.cend()) ? 0 : ctpIt->second;
249 const auto tobIt = tobThresholdCounts.find(thrNameHash);
250 size_t tobCount = (tobIt==tobThresholdCounts.cend()) ? 0 : tobIt->second;
251 int tobMinusCtpCount = static_cast<int>(ctpCount) - static_cast<int>(tobCount);
253
254 Monitored::Scalar monThrName{"ThrName", thrName};
255 Monitored::Scalar monCtpCount{"CtpCount", ctpCount};
256 Monitored::Scalar monTobCount{"TobCount", tobCount};
257 Monitored::Scalar monTobMinusCtpCount{"TobMinusCtpCount", tobMinusCtpCount};
258 Monitored::Group{
m_monTool, monThrName, monCtpCount, monTobCount, monTobMinusCtpCount};
259 }
260
263}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
std::unordered_map< TrigCompositeUtils::DecisionID, MultiplicityInfo > m_thresholdMap
Gaudi::Property< std::map< std::string, std::string > > m_thresholdToDecisionMap
std::set< TrigCompositeUtils::DecisionID > m_monitoredThresholds
std::unordered_map< TrigCompositeUtils::DecisionID, std::string > m_thresholdTypes
std::unordered_map< TrigCompositeUtils::DecisionID, unsigned int > MultiplicityInfo
std::unordered_map< TrigCompositeUtils::DecisionID, std::string > m_thresholdNames
ToolHandle< GenericMonitoringTool > m_monTool
bool doDebug() const
Shorter alias for a check whether we are in DEBUG logging mode.
Gaudi::Property< bool > m_errorOnMissingTOB
::StatusCode StatusCode
StatusCode definition for legacy code.
xAOD::TrigComposite Decision
const std::string & initialRecRoIString()