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(
"createTotalResultHistograms", m_param_create_total_result_histograms,
59 "Create total result histogram?",
62 addParam(
"createExpRunEventHistograms", m_param_create_exp_run_event_histograms,
63 "Create exp/run/event histograms?",
66 addParam(
"createHLTUnitHistograms", m_param_create_hlt_unit_histograms,
67 "Create HLT unit histograms?",
70 addParam(
"createErrorFlagHistograms", m_param_create_error_flag_histograms,
71 "Create Error Flag histograms?",
74 addParam(
"histogramDirectoryName", m_param_histogramDirectoryName,
75 "SoftwareTrigger DQM histograms will be put into this directory", m_param_histogramDirectoryName);
80 TDirectory* oldDirectory =
nullptr;
83 oldDirectory = gDirectory;
90 const unsigned int numberOfBins = 50;
91 const double lowerX = 0;
92 const double upperX = 50;
99 const std::string& title = cutIdentifier.first;
101 const std::string& baseIdentifier = mapVal.first;
102 const int numberOfFlags = mapVal.second.size();
104 if (title == baseIdentifier)
106 new TH1F(title.c_str(), (
"Events triggered in HLT " + baseIdentifier).c_str(),
111 new TH1F((baseIdentifier +
"_" + title).c_str(), (
"Events triggered in HLT " + baseIdentifier +
" : " + title).c_str(),
123 new TH1F(
"total_result",
"Total Result of HLT (absolute numbers)", 1, 0, 0));
131 m_l1Histograms.emplace(trigger,
new TH1F(trigger.c_str(), (
"Events triggered in L1 " + trigger).c_str(), 1, 0, 0));
141 new TH1F(
"l1_total_result",
"Events triggered in L1 (total results)", 1, 0, 0));
142 m_l1Histograms[
"l1_total_result"]->SetXTitle(
"Total L1 Cut Result");
149 m_runInfoHistograms.emplace(
"run_number",
new TH1F(
"run_number",
"Run Number", 100, 0, 10000));
150 m_runInfoHistograms.emplace(
"event_number",
new TH1F(
"event_number",
"Event Number", 100, 0, 1
'000'000));
151 m_runInfoHistograms.emplace(
"experiment_number",
new TH1F(
"experiment_number",
"Experiment Number", 50, 0, 50));
195 B2WARNING(
"HLT unit number not found");
206 const std::string& variable = variableNameAndTH1F.first;
207 TH1F* histogram = variableNameAndTH1F.second;
211 B2ERROR(
"Variable " << variable <<
" configured for SoftwareTriggerDQM plotting is not available");
213 const double value =
m_variables->getVariable(variable);
214 histogram->Fill(value);
223 const std::string& title = cutIdentifier.first;
225 const std::string& baseIdentifier = mapVal.first;
226 const auto& cuts = mapVal.second;
232 for (
const std::string& cutTitleIgnored : cutsIgnored) {
233 const std::string& cutNameIgnored = cutTitleIgnored.substr(0, cutTitleIgnored.find(
"\\"));
236 auto const cutEntryIgnored = results.find(fullCutIdentifierIgnored);
238 if (cutEntryIgnored != results.end()) {
239 if (cutEntryIgnored->second > 0) skip =
true;
243 for (
const std::string& cutTitle : cuts) {
244 const std::string& cutName = cutTitle.substr(0, cutTitle.find(
"\\"));
250 auto const cutEntry = results.find(fullCutIdentifier);
252 if (cutEntry != results.end()) {
253 const int cutResult = cutEntry->second;
259 if (title == baseIdentifier) {
261 const int cutResult =
static_cast<int>(
m_triggerResult->getResult(totalCutIdentifier));
275 const std::string& cutName = cutIdentifierPerUnit.substr(0, cutIdentifierPerUnit.find(
"\\"));
279 auto const cutEntry = results.find(fullCutIdentifier);
281 if (cutEntry != results.end()) {
282 const int cutResult = cutEntry->second;
290 const int triggerBit =
m_l1NameLookup->getoutbitnum(l1Trigger.c_str());
291 if (triggerBit < 0) {
292 B2WARNING(
"Could not find"
293 <<
LogVar(
"L1 trigger line", l1Trigger));
298 m_l1Histograms[
"l1_total_result"]->Fill(l1Trigger.c_str(), triggerResult);
301 if (not triggerResult) {
306 const std::string& title = cutIdentifier.first;
308 const std::string& baseIdentifier = mapVal.first;
309 const auto& cuts = mapVal.second;
311 if (title == baseIdentifier) {
312 for (
const std::string& cutTitle : cuts) {
313 const std::string& cutName = cutTitle.substr(0, cutTitle.find(
"\\"));
317 auto const cutEntry = results.find(fullCutIdentifier);
319 if (cutEntry != results.end()) {
320 const int cutResult = cutEntry->second;
342 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_B2LinkPacketCRCError));
344 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_B2LinkEventCRCError));
346 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_HLTCrash));
348 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_ReconstructionAbort));
359 [](
auto & it) { it.second->Reset(); });
361 [](
auto & it) { it.second->Reset(); });
363 [](
auto & it) { it.second->Reset(); });
365 [](
auto & it) { it.second->Reset(); });
367 [](
auto & it) { it.second->Reset(); });