7 #include "GaudiKernel/IIncidentSvc.h"
8 #include "Gaudi/Property.h"
15 : base_class(
name, pSvcLocator)
30 return StatusCode::SUCCESS;
44 std::unordered_map<std::string,std::string> mapStrNameToTypeName;
47 mapStrNameToTypeName.insert({
stream.getAttribute(
"name"),
stream.getAttribute(
"type")+
"_"+
stream.getAttribute(
"name")});
50 ATH_MSG_ERROR(
"Exception reading stream tag configuration from the HLT menu: " << ex.what());
51 return StatusCode::FAILURE;
55 for (
const std::string&
group :
chain.groups()) {
65 if (
it==mapStrNameToTypeName.cend()) {
67 <<
" is missing from menu streams definition");
68 return StatusCode::FAILURE;
70 if (
it->second ==
"express_express") {
82 const int x {
nBinsX(hltMenuHandle)};
85 std::unique_ptr<TH2> hSA = std::make_unique<TH2I>(
"SignatureAcceptance",
"Raw acceptance of signatures in;chain;step",
x, 1,
x + 1,
y, 1,
y + 1);
86 std::unique_ptr<TH2> hDC = std::make_unique<TH2I>(
"DecisionCount",
"Positive decisions count per step;chain;step",
x, 1,
x + 1,
y, 1,
y + 1);
107 std::set<std::string> sequencesSet;
109 ctool->getSequencesNames(sequencesSet);
111 const int xc = sequencesSet.size();
121 return StatusCode::SUCCESS;
129 ATH_MSG_INFO(
"No chains configured, no counts to print" );
130 return StatusCode::SUCCESS;
133 auto fixedWidth = [](
const std::string&
s,
size_t sz) {
134 std::ostringstream
ss;
135 ss << std::setw(
sz) << std::left <<
s;
143 std::map<std::string, std::set<int>> chainToStepsId;
146 for (
const std::string& seqName :
chain.sequencers()){
148 std::smatch stepNameMatch;
149 std::regex_search(seqName.begin(), seqName.end(), stepNameMatch,
std::regex(
"[Ss]tep[0-9]+"));
151 std::string stepName = stepNameMatch[0];
152 stepName[0] = std::toupper(stepName[0]);
155 chainToStepsId[
chain.name()].insert(nstep);
163 auto collToString = [&](
int xbin,
const LockedHandle<TH2>&
hist,
int startOfset=0,
int endOffset=0){
165 const int stepsSize =
hist->GetYaxis()->GetNbins() -
nBaseSteps();
166 for (
int ybin = 1; ybin <=
hist->GetYaxis()->GetNbins()-endOffset; ++ybin) {
167 if (ybin > startOfset) {
170 const std::string
chainName = m_passHistogram->GetXaxis()->GetBinLabel(xbin);
172 if (ybin < 3 || ybin > stepsSize + 2 || chainToStepsId[
chainName].
count(ybin - 2) != 0) {
175 v += fixedWidth(
"-", 11);
178 v += fixedWidth(
" ", 11);
185 v += fixedWidth(
"L1", 11);
186 v += fixedWidth(
"AfterPS", 11);
190 v += fixedWidth(
"Output", 11);
191 v += fixedWidth(
"Express", 11);
193 ATH_MSG_INFO(
"Chains passing step (1st row events & 2nd row decision counts):");
201 for (
int bin = 1;
bin <= (*m_passHistogram)->GetXaxis()->GetNbins(); ++
bin) {
202 const std::string
chainName = m_passHistogram->GetXaxis()->GetBinLabel(
bin);
206 ATH_MSG_INFO( fixedWidth(
"-- #" + chainID +
" Events", 30) << collToString(
bin, m_passHistogram) );
207 ATH_MSG_INFO( fixedWidth(
"-- #" + chainID +
" Features", 30) << collToString(
bin, m_countHistogram , 2, 1 ) );
214 return StatusCode::SUCCESS;
226 return StatusCode::SUCCESS;
245 m_countHistogram->Fill(id2bin->second,
double(
row));
249 return StatusCode::SUCCESS;
254 for (
const std::string&
seq : sequences) {
258 return StatusCode::SUCCESS;
262 const int countOutputRow {
nSteps()-1};
264 for (
const auto&
name : nameToChainsMap) {
266 if (
name.second.find(
id) !=
name.second.end()){
268 m_countHistogram->Fill(
bin, countOutputRow);
270 m_passHistogram->Fill(
bin, countOutputRow);
275 return StatusCode::SUCCESS;
282 ATH_MSG_WARNING(
"Timer is already running. UpdateAfterFork incident called more than once?");
306 if (
d->name() ==
"l1seeded") {
308 }
else if (
d->name() ==
"unprescaled") {
309 unprescaledChains =
d;
313 if (l1SeededChains ==
nullptr || unprescaledChains ==
nullptr) {
314 ATH_MSG_ERROR(
"Unable to read in the summary from the HLTSeeding.");
315 return StatusCode::FAILURE;
325 m_passHistogram->Fill(1,
double(
index + 1));
328 return StatusCode::SUCCESS;
338 std::vector<TrigCompositeUtils::DecisionID> stepSum;
339 std::set<std::string> stepSequences;
340 ctool->getDecisions( stepSum );
341 ctool->getSequencesPerEvent( stepSequences );
342 ATH_MSG_DEBUG(
" Step " <<
step <<
" decisions (for decisions): " << stepSum.size() );
351 std::vector<TrigCompositeUtils::DecisionID> stepSum;
352 std::set<std::string> stepSequences;
353 ctool->getDecisions( stepSum );
354 ATH_MSG_DEBUG(
" Step " <<
step <<
" decisions (for features): " << stepSum.size() );
365 if (!decisionObject) {
366 ATH_MSG_WARNING(
"Unable to locate trigger navigation terminus node. Cannot tell which chains passed the event.");
374 if (!expressDecisionObject) {
375 ATH_MSG_WARNING(
"Unable to locate trigger navigation express terminus node. Cannot tell which chains passed the express stream in this event.");
381 const int countOutputRow {
nSteps()-1};
389 const int countExpressRow {
nSteps()};
396 if (!finalIDs.empty()) {
397 m_passHistogram->Fill(1,
double(countOutputRow));
400 if (!expressFinalIDs.empty()) {
401 m_passHistogram->Fill(1,
double(countExpressRow));
405 return StatusCode::SUCCESS;
417 return hltMenuHandle->
size() + 1;
433 TAxis*
x =
hist->GetXaxis();
434 x->SetBinLabel(1,
"All");
437 std::set<std::string> sortedChainsList;
439 sortedChainsList.insert(
chain.name() );
442 for (
const std::string&
chainName: sortedChainsList ) {
451 x->SetBinLabel(
bin, (
"str_"+
stream.first).c_str());
457 x->SetBinLabel(
bin, (
"str_"+
stream.first).c_str());
463 x->SetBinLabel(
bin, (
"grp_"+
group.first.substr(
group.first.find(
':')+1)).c_str() );
469 TAxis*
y =
hist->GetYaxis();
470 y->SetBinLabel(1,
steps ?
"L1" :
"Input");
471 y->SetBinLabel(2,
"AfterPS");
475 y->SetBinLabel(
y->GetNbins()-1,
"Output");
476 y->SetBinLabel(
y->GetNbins(),
"Express");
478 return StatusCode::SUCCESS;
482 TAxis*
x =
hist->GetXaxis();
486 for (
const std::string& seqName : sequenceSet) {
487 x->SetBinLabel(
bin, seqName.c_str());
492 TAxis*
y =
hist->GetYaxis();
493 y->SetBinLabel(1,
"Rate");
495 return StatusCode::SUCCESS;
500 delete m_bufferHistogram.get();
505 std::unique_ptr<TH2>
h = std::make_unique<TH2F>(histoName.c_str(), histoTitle.c_str(),
x, 1,
x + 1,
y, 1,
y + 1);
506 ATH_CHECK(
histSvc->regShared( registerPath.c_str(), std::move(
h), m_histogram));
508 TH2I * hB =
new TH2I( (histoName +
"Buffer").c_str(), histoTitle.c_str(),
x, 1,
x + 1,
y, 1,
y + 1);
509 m_bufferHistogram.set(hB, &m_mutex);
510 m_bufferHistogram->SetDirectory(0);
512 return StatusCode::SUCCESS;
520 return m_bufferHistogram;
528 m_bufferHistogram->Fill(
x,
y);
549 m_histogram->Reset(
"ICES");
550 m_histogram->Add(m_bufferHistogram.get(), 1./
duration);
551 m_bufferHistogram->Reset(
"ICES");
558 unsigned int newinterval;
559 unsigned int oldinterval;
561 if (m_timeDivider->isPassed(
t, newinterval, oldinterval)) {