10 #include <hlt/softwaretrigger/modules/dqm/SoftwareTriggerHLTDQMModule.h>
12 #include <TDirectory.h>
14 #include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
15 #include <hlt/softwaretrigger/core/FinalTriggerDecisionCalculator.h>
17 #include <framework/core/ModuleParam.templateDetails.h>
23 using namespace SoftwareTrigger;
29 setDescription(
"Monitor Physics Trigger");
30 setPropertyFlags(c_ParallelProcessingCertified);
33 m_param_variableIdentifiers = {};
35 m_param_cutResultIdentifiers[
"filter"][
"filter"] = {
"total_result"};
37 addParam(
"cutResultIdentifiers", m_param_cutResultIdentifiers,
38 "Which cuts should be reported? Please remember to include the total_result also, if wanted.",
39 m_param_cutResultIdentifiers);
41 addParam(
"cutResultIdentifiersIgnored", m_param_cutResultIdentifiersIgnored,
42 "Which cuts should be ignored? This will display cleaner trigger lines, e.g. to clear them from bhabha contamination. "
43 "Vetoes on skims do not apply in filter plot and vice versa.",
44 m_param_cutResultIdentifiersIgnored);
46 addParam(
"cutResultIdentifiersPerUnit", m_param_cutResultIdentifiersPerUnit,
47 "Which cuts should be reported per unit?",
48 m_param_cutResultIdentifiersPerUnit);
50 addParam(
"variableIdentifiers", m_param_variableIdentifiers,
51 "Which variables should be reported?",
52 m_param_variableIdentifiers);
54 addParam(
"l1Identifiers", m_param_l1Identifiers,
55 "Which l1 identifiers to report?",
56 m_param_l1Identifiers);
58 addParam(
"additionalL1Identifiers", m_param_additionalL1Identifiers,
59 "Which additional l1 identifiers to be added to the l1 total result plot?",
60 m_param_additionalL1Identifiers);
62 addParam(
"createTotalResultHistograms", m_param_create_total_result_histograms,
63 "Create total result histogram?",
66 addParam(
"createExpRunEventHistograms", m_param_create_exp_run_event_histograms,
67 "Create exp/run/event histograms?",
70 addParam(
"createHLTUnitHistograms", m_param_create_hlt_unit_histograms,
71 "Create HLT unit histograms?",
74 addParam(
"createErrorFlagHistograms", m_param_create_error_flag_histograms,
75 "Create Error Flag histograms?",
78 addParam(
"histogramDirectoryName", m_param_histogramDirectoryName,
79 "SoftwareTrigger DQM histograms will be put into this directory", m_param_histogramDirectoryName);
81 addParam(
"pathLocation", m_param_pathLocation,
82 "Location of the module in the path: before filter or after filter", m_param_pathLocation);
87 TDirectory* oldDirectory =
nullptr;
90 oldDirectory = gDirectory;
97 const unsigned int numberOfBins = 50;
98 const double lowerX = 0;
99 const double upperX = 50;
106 const std::string& title = cutIdentifier.first;
108 const std::string& baseIdentifier = mapVal.first;
109 const auto& cuts = mapVal.second;
110 const int numberOfFlags = cuts.size();
113 if (title == baseIdentifier)
115 new TH1F((title +
"_nobhabha").c_str(), (
"Events triggered in HLT " + baseIdentifier).c_str(),
120 new TH1F((baseIdentifier +
"_" + title +
"_nobhabha").c_str(),
121 (
"Events triggered in HLT " + baseIdentifier +
" : " + title).c_str(),
125 if (title == baseIdentifier)
127 new TH1F(title.c_str(), (
"Events triggered in HLT " + baseIdentifier).c_str(),
132 new TH1F((baseIdentifier +
"_" + title).c_str(), (
"Events triggered in HLT " + baseIdentifier +
" : " + title).c_str(),
143 for (
const std::string& cutTitle : cuts) {
152 new TH1F(
"total_result",
"Total Result of HLT (absolute numbers)", 1, 0, 0));
160 m_l1Histograms.emplace(trigger,
new TH1F(trigger.c_str(), (
"Events triggered in L1 " + trigger).c_str(), 1, 0, 0));
170 new TH1F(
"l1_total_result",
"Events triggered in L1 (total results)", 1, 0, 0));
171 m_l1Histograms[
"l1_total_result"]->SetXTitle(
"Total L1 Cut Result");
177 m_l1Histograms[
"l1_total_result"]->SetBins(numberOfL1Flags, 0, numberOfL1Flags);
182 m_l1Histograms[
"l1_total_result"]->GetXaxis()->SetBinLabel(l1Index, l1Trigger.c_str());
186 m_l1Histograms[
"l1_total_result"]->GetXaxis()->SetBinLabel(l1Index, l1Trigger.c_str());
191 m_runInfoHistograms.emplace(
"run_number",
new TH1D(
"run_number",
"Run Number", 100, 0, 10000));
192 m_runInfoHistograms.emplace(
"event_number",
new TH1D(
"event_number",
"Event Number", 100, 0, 1
'000'000));
193 m_runInfoHistograms.emplace(
"experiment_number",
new TH1D(
"experiment_number",
"Experiment Number", 50, 0, 50));
246 B2WARNING(
"HLT unit number not found");
257 const std::string& variable = variableNameAndTH1F.first;
258 TH1F* histogram = variableNameAndTH1F.second;
262 B2ERROR(
"Variable " << variable <<
" configured for SoftwareTriggerDQM plotting is not available");
264 const double value =
m_variables->getVariable(variable);
265 histogram->Fill(value);
274 const std::string& title = cutIdentifier.first;
276 const std::string& baseIdentifier = mapVal.first;
277 const auto& cuts = mapVal.second;
283 for (
const std::string& cutTitleIgnored : cutsIgnored) {
284 const std::string& cutNameIgnored = cutTitleIgnored.substr(0, cutTitleIgnored.find(
"\\"));
287 auto const cutEntryIgnored = results.find(fullCutIdentifierIgnored);
289 if (cutEntryIgnored != results.end()) {
290 if (cutEntryIgnored->second > 0) skip =
true;
295 for (
const std::string& cutTitle : cuts) {
297 const std::string& cutName = cutTitle.substr(0, cutTitle.find(
"\\"));
303 auto const cutEntry = results.find(fullCutIdentifier);
305 if (cutEntry != results.end()) {
306 const int cutResult = cutEntry->second;
307 if (cutResult > 0 and not skip) {
314 if (title == baseIdentifier) {
316 const int cutResult =
static_cast<int>(
m_triggerResult->getResult(totalCutIdentifier));
330 const std::string& cutName = cutIdentifierPerUnit.substr(0, cutIdentifierPerUnit.find(
"\\"));
334 auto const cutEntry = results.find(fullCutIdentifier);
336 if (cutEntry != results.end()) {
337 const int cutResult = cutEntry->second;
349 const int triggerBit =
m_l1NameLookup->getoutbitnum(l1Trigger.c_str());
350 if (triggerBit < 0) {
351 B2WARNING(
"Could not find"
352 <<
LogVar(
"L1 trigger line", l1Trigger));
362 if (not triggerResult) {
367 const std::string& title = cutIdentifier.first;
369 const std::string& baseIdentifier = mapVal.first;
370 const auto& cuts = mapVal.second;
372 if (title == baseIdentifier) {
373 for (
const std::string& cutTitle : cuts) {
374 const std::string& cutName = cutTitle.substr(0, cutTitle.find(
"\\"));
378 auto const cutEntry = results.find(fullCutIdentifier);
380 if (cutEntry != results.end()) {
381 const int cutResult = cutEntry->second;
395 const int triggerBit =
m_l1NameLookup->getoutbitnum(l1Trigger.c_str());
396 if (triggerBit < 0) {
397 B2WARNING(
"Could not find"
398 <<
LogVar(
"L1 trigger line", l1Trigger));
418 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_B2LinkPacketCRCError));
420 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_B2LinkEventCRCError));
422 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_HLTCrash));
424 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_ReconstructionAbort));
435 [](
auto & it) { it.second->Reset(); });
437 [](
auto & it) { it.second->Reset(); });
439 [](
auto & it) { it.second->Reset(); });
441 [](
auto & it) { it.second->Reset(); });
443 [](
auto & it) { it.second->Reset(); });