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
104 std::vector<TrigCompositeUtils::DecisionID> passedThresholdIDs;
105 const bool hasDetail =
d->getDetail(
"thresholds", passedThresholdIDs);
106 if (!hasDetail) {
107 ATH_MSG_ERROR(
"Detail \"thresholds\" missing from Decision in the container " << decisionsKey);
108 return StatusCode::FAILURE;
109 }
110 bool overflow{false};
111 if (
d->hasDetail<
char>(
"overflow")) {
112 overflow =
static_cast<bool>(
d->getDetail<
char>(
"overflow"));
113 }
114 if (
doDebug()) {ssPassedThresholds.str(
"");}
116 if (overflow) {
118 }
119 if (tobThresholdCounts.find(thrNameHash)==tobThresholdCounts.end()) {
120 tobThresholdCounts[thrNameHash] = 1;
121 }
122 else {
123 tobThresholdCounts[thrNameHash] += 1;
124 }
126 if (!ssPassedThresholds.str().empty()) ssPassedThresholds << ", ";
128 }
129 }
131 namespace RoIDefs = HLTSeedingRoIToolDefs;
133 if (optTob.has_value()) {
134 const RoIDefs::AnyRoIPointer& tob = optTob.value();
135 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] corresponds to TOB with word / et / eta / phi = 0x"
136 << MSG::hex << RoIDefs::roiWord(tob) << MSG::dec << " / " << RoIDefs::roiTobEt(tob)
137 << " / " << RoIDefs::roiEta(tob) << " / " << RoIDefs::roiPhi(tob));
138 } else {
139 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] TOB type not supported by template code for "
140 << "debug printout of word / et / eta / phi");
141 }
142 ATH_MSG_DEBUG(
"Decision " << decisionsKey <<
"[" << idec <<
"] TOB passes " << passedThresholdIDs.size()
143 << " thresholds: " << ssPassedThresholds.str());
144 ++idec;
145 }
146 }
147 }
148
149
150
151
152 std::unordered_map<TrigCompositeUtils::DecisionID, size_t> ctpThresholdCounts;
153
157 ATH_MSG_DEBUG(
"Cannot monitor chain " << chainID <<
" -> " << HLT::Identifier(chainID).
name() <<
", skipping");
158 continue;
159 }
161
162 for (const auto& [thrNameHash, multiplicity] : thresholds) {
163 if (ctpThresholdCounts.find(thrNameHash)==ctpThresholdCounts.end()) {
164 ctpThresholdCounts[thrNameHash] = multiplicity;
165 }
166 else if (multiplicity > ctpThresholdCounts[thrNameHash]) {
167 ctpThresholdCounts[thrNameHash] = multiplicity;
168 }
169 }
170 }
171
172
173
174
175 for (const auto& [thrNameHash, ctpCount] : ctpThresholdCounts) {
176 size_t tobCount{0};
177 bool tooFew{false};
180 ATH_MSG_ERROR(
"Threshold with hash " << thrNameHash <<
" not found in the hash->name map");
181 return StatusCode::FAILURE;
182 }
183 const std::string& thrName =
it->second;
185
186
187 bool overflow{overflowThresholdTypes.find(thrType)!=overflowThresholdTypes.end()};
188 if (overflow) {
189 ATH_MSG_DEBUG(
"Threshold " << thrName <<
" accepted by the CTP with multiplicity " << ctpCount
190 << " is flagged as overflow and thus may be missing TOBs");
191 }
192
193
194 bool missing = (tobThresholdCounts.find(thrNameHash)==tobThresholdCounts.end());
195
196 if (missing) {
199 << " accepted by the CTP with multiplicity " << ctpCount
200 << (overflow ? ", likely due to overflow" : ""));
201
202 } else {
203 ATH_MSG_ERROR(
"No TOBs found passing the threshold " << thrName
204 << " accepted by the CTP with multiplicity " << ctpCount);
205 sc = StatusCode::FAILURE;
206 }
207 }
208 else {
209 tobCount = tobThresholdCounts.at(thrNameHash);
210
211 tooFew = (tobCount < ctpCount);
212 }
213
214 if (tooFew) {
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" : ""));
219 } else {
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;
223 }
224 }
225
226 if (missing || tooFew) {
227
228 Monitored::Scalar monMissingTOBsIncludingOverflow{"MissingTOBsIncludingOverflow", thrName};
229 if (overflow) {
230 Monitored::Group{
m_monTool, monMissingTOBsIncludingOverflow};
231 }
232 else {
233 Monitored::Scalar monMissingTOBs{"MissingTOBs", thrName};
234 Monitored::Group{
m_monTool, monMissingTOBs, monMissingTOBsIncludingOverflow};
235 }
236 }
237 else {
238 ATH_MSG_DEBUG(
"Check passed. Found " << tobCount <<
" TOBs passing the threshold " << thrName
239 << " accepted by the CTP with multiplicity " << ctpCount);
240 }
241 }
242
243
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);
251
252 Monitored::Scalar monThrName{"ThrName", thrName};
253 Monitored::Scalar monCtpCount{"CtpCount", ctpCount};
254 Monitored::Scalar monTobCount{"TobCount", tobCount};
255 Monitored::Scalar monTobMinusCtpCount{"TobMinusCtpCount", tobMinusCtpCount};
256 Monitored::Group{
m_monTool, monThrName, monCtpCount, monTobCount, monTobMinusCtpCount};
257 }
258
261}
#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()