7 #include "GaudiKernel/IIncidentSvc.h"
8 #include "Gaudi/Property.h"
14 : base_class(
name, pSvcLocator)
29 return StatusCode::SUCCESS;
43 std::unordered_map<std::string,std::string> mapStrNameToTypeName;
46 mapStrNameToTypeName.insert({
stream.getAttribute(
"name"),
stream.getAttribute(
"type")+
"_"+
stream.getAttribute(
"name")});
49 ATH_MSG_ERROR(
"Exception reading stream tag configuration from the HLT menu: " << ex.what());
50 return StatusCode::FAILURE;
54 for (
const std::string&
group :
chain.groups()) {
56 if (
group.starts_with(
"RATE")){
64 if (
it==mapStrNameToTypeName.cend()) {
66 <<
" is missing from menu streams definition");
67 return StatusCode::FAILURE;
69 if (
it->second ==
"express_express") {
81 const int x {
nBinsX(hltMenuHandle)};
84 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);
85 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);
106 std::set<std::string> sequencesSet;
108 ctool->getSequencesNames(sequencesSet);
110 const int xc = sequencesSet.size();
120 return StatusCode::SUCCESS;
128 ATH_MSG_INFO(
"No chains configured, no counts to print" );
129 return StatusCode::SUCCESS;
132 auto fixedWidth = [](
const std::string&
s,
size_t sz) {
133 std::ostringstream
ss;
134 ss << std::setw(
sz) << std::left <<
s;
142 std::map<std::string, std::set<int>> chainToStepsId;
145 for (
const std::string& seqName :
chain.sequencers()){
147 std::smatch stepNameMatch;
148 std::regex_search(seqName.begin(), seqName.end(), stepNameMatch,
std::regex(
"[Ss]tep[0-9]+"));
150 std::string stepName = stepNameMatch[0];
151 stepName[0] = std::toupper(stepName[0]);
154 chainToStepsId[
chain.name()].insert(nstep);
162 auto collToString = [&](
int xbin,
const LockedHandle<TH2>&
hist,
int startOfset=0,
int endOffset=0){
164 const int stepsSize =
hist->GetYaxis()->GetNbins() -
nBaseSteps();
165 for (
int ybin = 1; ybin <=
hist->GetYaxis()->GetNbins()-endOffset; ++ybin) {
166 if (ybin > startOfset) {
169 const std::string
chainName = m_passHistogram->GetXaxis()->GetBinLabel(xbin);
171 if (ybin < 3 || ybin > stepsSize + 2 || chainToStepsId[
chainName].
count(ybin - 2) != 0) {
174 v += fixedWidth(
"-", 11);
177 v += fixedWidth(
" ", 11);
184 v += fixedWidth(
"L1", 11);
185 v += fixedWidth(
"AfterPS", 11);
189 v += fixedWidth(
"Output", 11);
190 v += fixedWidth(
"Express", 11);
192 ATH_MSG_INFO(
"Chains passing step (1st row events & 2nd row decision counts):");
200 for (
int bin = 1;
bin <= (*m_passHistogram)->GetXaxis()->GetNbins(); ++
bin) {
201 const std::string
chainName = m_passHistogram->GetXaxis()->GetBinLabel(
bin);
205 ATH_MSG_INFO( fixedWidth(
"-- #" + chainID +
" Events", 30) << collToString(
bin, m_passHistogram) );
206 ATH_MSG_INFO( fixedWidth(
"-- #" + chainID +
" Features", 30) << collToString(
bin, m_countHistogram , 2, 1 ) );
213 return StatusCode::SUCCESS;
225 return StatusCode::SUCCESS;
244 m_countHistogram->Fill(id2bin->second,
double(
row));
248 return StatusCode::SUCCESS;
253 for (
const std::string&
seq : sequences) {
257 return StatusCode::SUCCESS;
261 const int countOutputRow {
nSteps()-1};
263 for (
const auto&
name : nameToChainsMap) {
265 if (
name.second.find(
id) !=
name.second.end()){
267 m_countHistogram->Fill(
bin, countOutputRow);
269 m_passHistogram->Fill(
bin, countOutputRow);
274 return StatusCode::SUCCESS;
281 ATH_MSG_WARNING(
"Timer is already running. UpdateAfterFork incident called more than once?");
305 if (
d->name() ==
"l1seeded") {
307 }
else if (
d->name() ==
"unprescaled") {
308 unprescaledChains =
d;
312 if (l1SeededChains ==
nullptr || unprescaledChains ==
nullptr) {
313 ATH_MSG_ERROR(
"Unable to read in the summary from the HLTSeeding.");
314 return StatusCode::FAILURE;
324 m_passHistogram->Fill(1,
double(
index + 1));
327 return StatusCode::SUCCESS;
337 std::vector<TrigCompositeUtils::DecisionID> stepSum;
338 std::set<std::string> stepSequences;
339 ctool->getDecisions( stepSum, context );
340 ctool->getSequencesPerEvent( stepSequences, context );
341 ATH_MSG_DEBUG(
" Step " <<
step <<
" decisions (for decisions): " << stepSum.size() );
350 std::vector<TrigCompositeUtils::DecisionID> stepSum;
351 std::set<std::string> stepSequences;
352 ctool->getDecisions( stepSum, context );
353 ATH_MSG_DEBUG(
" Step " <<
step <<
" decisions (for features): " << stepSum.size() );
364 if (!decisionObject) {
365 ATH_MSG_WARNING(
"Unable to locate trigger navigation terminus node. Cannot tell which chains passed the event.");
373 if (!expressDecisionObject) {
374 ATH_MSG_WARNING(
"Unable to locate trigger navigation express terminus node. Cannot tell which chains passed the express stream in this event.");
380 const int countOutputRow {
nSteps()-1};
388 const int countExpressRow {
nSteps()};
395 if (!finalIDs.empty()) {
396 m_passHistogram->Fill(1,
double(countOutputRow));
399 if (!expressFinalIDs.empty()) {
400 m_passHistogram->Fill(1,
double(countExpressRow));
404 return StatusCode::SUCCESS;
416 return hltMenuHandle->
size() + 1;
432 TAxis*
x =
hist->GetXaxis();
433 x->SetBinLabel(1,
"All");
436 std::set<std::string> sortedChainsList;
438 sortedChainsList.insert(
chain.name() );
441 for (
const std::string&
chainName: sortedChainsList ) {
450 x->SetBinLabel(
bin, (
"str_"+
stream.first).c_str());
456 x->SetBinLabel(
bin, (
"str_"+
stream.first).c_str());
462 x->SetBinLabel(
bin, (
"grp_"+
group.first.substr(
group.first.find(
':')+1)).c_str() );
468 TAxis*
y =
hist->GetYaxis();
469 y->SetBinLabel(1,
steps ?
"L1" :
"Input");
470 y->SetBinLabel(2,
"AfterPS");
474 y->SetBinLabel(
y->GetNbins()-1,
"Output");
475 y->SetBinLabel(
y->GetNbins(),
"Express");
477 return StatusCode::SUCCESS;
481 TAxis*
x =
hist->GetXaxis();
485 for (
const std::string& seqName : sequenceSet) {
486 x->SetBinLabel(
bin, seqName.c_str());
491 TAxis*
y =
hist->GetYaxis();
492 y->SetBinLabel(1,
"Rate");
494 return StatusCode::SUCCESS;
499 delete m_bufferHistogram.get();
504 std::unique_ptr<TH2>
h = std::make_unique<TH2F>(histoName.c_str(), histoTitle.c_str(),
x, 1,
x + 1,
y, 1,
y + 1);
505 ATH_CHECK(
histSvc->regShared( registerPath.c_str(), std::move(
h), m_histogram));
507 TH2I * hB =
new TH2I( (histoName +
"Buffer").c_str(), histoTitle.c_str(),
x, 1,
x + 1,
y, 1,
y + 1);
508 m_bufferHistogram.set(hB, &m_mutex);
509 m_bufferHistogram->SetDirectory(0);
511 return StatusCode::SUCCESS;
519 return m_bufferHistogram;
527 m_bufferHistogram->Fill(
x,
y);
548 m_histogram->Reset(
"ICES");
549 m_histogram->Add(m_bufferHistogram.get(), 1./
duration);
550 m_bufferHistogram->Reset(
"ICES");
557 unsigned int newinterval;
558 unsigned int oldinterval;
560 if (m_timeDivider->isPassed(
t, newinterval, oldinterval)) {