8 #include <hlt/softwaretrigger/modules/dqm/SoftwareTriggerHLTDQMModule.h>
10 #include <TDirectory.h>
12 #include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
13 #include <hlt/softwaretrigger/core/FinalTriggerDecisionCalculator.h>
14 #include <hlt/utilities/Units.h>
16 #include <framework/core/ModuleParam.templateDetails.h>
23 using namespace SoftwareTrigger;
38 "Which cuts should be reported? Please remember to include the total_result also, if wanted.",
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.",
47 "Which cuts should be reported per unit?",
51 "Which variables should be reported?",
55 "Which l1 identifiers to report?",
59 "Which additional l1 identifiers to be added to the l1 total result plot?",
63 "Create total result histogram?",
67 "Create exp/run/event histograms?",
71 "Create HLT unit histograms?",
75 "Create Error Flag histograms?",
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));
199 (
"Number of events per HLT unit " +
m_param_pathLocation).c_str(), HLTUnits::max_hlt_units + 1, 0,
200 HLTUnits::max_hlt_units + 1));
203 (
"Number of events per HLT unit " +
m_param_pathLocation).c_str(), HLTUnits::max_hlt_units + 1, 0,
204 HLTUnits::max_hlt_units + 1));
210 (
"Events triggered per unit in HLT : " + cutIdentifierPerUnit).c_str(), HLTUnits::max_hlt_units + 1, 0,
211 HLTUnits::max_hlt_units + 1));
238 file.open(HLTUnits::hlt_unit_file);
245 B2WARNING(
"HLT unit number not found");
256 const std::string& variable = variableNameAndTH1F.first;
257 TH1F* histogram = variableNameAndTH1F.second;
261 B2ERROR(
"Variable " << variable <<
" configured for SoftwareTriggerDQM plotting is not available");
263 const double value =
m_variables->getVariable(variable);
264 histogram->Fill(value);
273 const std::string& title = cutIdentifier.first;
275 const std::string& baseIdentifier = mapVal.first;
276 const auto& cuts = mapVal.second;
282 for (
const std::string& cutTitleIgnored : cutsIgnored) {
283 const std::string& cutNameIgnored = cutTitleIgnored.substr(0, cutTitleIgnored.find(
"\\"));
286 auto const cutEntryIgnored = results.find(fullCutIdentifierIgnored);
288 if (cutEntryIgnored != results.end()) {
289 if (cutEntryIgnored->second > 0) skip =
true;
294 for (
const std::string& cutTitle : cuts) {
296 const std::string& cutName = cutTitle.substr(0, cutTitle.find(
"\\"));
302 auto const cutEntry = results.find(fullCutIdentifier);
304 if (cutEntry != results.end()) {
305 const int cutResult = cutEntry->second;
306 if (cutResult > 0 and not skip) {
313 if (title == baseIdentifier) {
315 const int cutResult =
static_cast<int>(
m_triggerResult->getResult(totalCutIdentifier));
329 const std::string& cutName = cutIdentifierPerUnit.substr(0, cutIdentifierPerUnit.find(
"\\"));
333 auto const cutEntry = results.find(fullCutIdentifier);
335 if (cutEntry != results.end()) {
336 const int cutResult = cutEntry->second;
348 const int triggerBit =
m_l1NameLookup->getoutbitnum(l1Trigger.c_str());
349 if (triggerBit < 0) {
350 B2WARNING(
"Could not find"
351 <<
LogVar(
"L1 trigger line", l1Trigger));
357 }
catch (
const std::exception&) {
358 triggerResult =
false;
366 if (not triggerResult) {
371 const std::string& title = cutIdentifier.first;
373 const std::string& baseIdentifier = mapVal.first;
374 const auto& cuts = mapVal.second;
376 if (title == baseIdentifier) {
377 for (
const std::string& cutTitle : cuts) {
378 const std::string& cutName = cutTitle.substr(0, cutTitle.find(
"\\"));
382 auto const cutEntry = results.find(fullCutIdentifier);
384 if (cutEntry != results.end()) {
385 const int cutResult = cutEntry->second;
399 const int triggerBit =
m_l1NameLookup->getoutbitnum(l1Trigger.c_str());
400 if (triggerBit < 0) {
401 B2WARNING(
"Could not find"
402 <<
LogVar(
"L1 trigger line", l1Trigger));
408 }
catch (
const std::exception&) {
409 triggerResult =
false;
427 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_B2LinkPacketCRCError));
429 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_B2LinkEventCRCError));
431 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_HLTCrash));
433 (
bool)(
m_eventMetaData->getErrorFlag() & EventMetaData::EventErrorFlag::c_ReconstructionAbort));
444 [](
auto & it) { it.second->Reset(); });
446 [](
auto & it) { it.second->Reset(); });
448 [](
auto & it) { it.second->Reset(); });
450 [](
auto & it) { it.second->Reset(); });
452 [](
auto & it) { it.second->Reset(); });
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
static bool getFinalTriggerDecision(const SoftwareTriggerResult &result, bool forgetTotalResult=false)
Calculate the final cut decision using all "total_results" of all sub triggers in the software trigge...
static std::string makeFullCutName(const std::string &baseCutIdentifier, const std::string &cutIdentifier)
Helper function to compile the full identifier from the base and the specific cut name.
static std::string makeTotalResultName(const std::string &baseIdentifier="all")
Handy function to create the name related to the total result of a specific trigger stage (either fil...
std::map< std::string, TH1D * > m_runInfoHistograms
histograms with the run information
std::map< std::string, std::map< std::string, std::vector< std::string > > > m_param_cutResultIdentifiers
Which cuts should be reported? Please remember to include the total_result also, if wanted.
std::map< std::string, TH1F * > m_l1Histograms
histogram with the L1 information
int m_hlt_unit
HLT unit number of the machine used.
void initialize() override
Module functions to be called from main process.
void event() override
Module functions to be called from event process.
StoreObjPtr< SoftwareTriggerResult > m_triggerResult
STM cut results.
SoftwareTriggerHLTDQMModule()
Constructor / Destructor.
std::vector< std::string > m_param_l1Identifiers
Which L1 cuts should be reported?
std::map< std::string, TH1F * > m_cutResultPerUnitHistograms
histograms for the final sw trigger decisions for each base identifier per unit
std::map< std::string, TH1F * > m_triggerVariablesHistograms
histograms for the software trigger variables in all calculators (although maybe not filled)
std::map< std::string, std::vector< std::string > > m_param_cutResultIdentifiersIgnored
Which cuts should be ignored? This can be used to clear trigger lines from e.g. bhabha contamination.
StoreObjPtr< EventMetaData > m_eventMetaData
Event Info.
std::string m_param_pathLocation
Location of the module in the path: before filter or after filter.
DBObjPtr< TRGGDLDBFTDLBits > m_l1NameLookup
Dataobjects.
void beginRun() override
Reset all histogram entries for a new run.
std::map< std::string, TH1F * > m_cutResultHistograms
histograms for the final sw trigger decisions for each base identifier
bool m_param_create_error_flag_histograms
Create error flag histograms?
std::vector< std::string > m_param_additionalL1Identifiers
Which additional L1 cuts should be added to the L1 total result plot?
bool m_param_create_hlt_unit_histograms
Create HLT unit number histograms?
StoreObjPtr< TRGSummary > m_l1TriggerResult
L1 cut results.
std::vector< std::string > m_param_cutResultIdentifiersPerUnit
Which cuts should be reported per unit?
bool m_param_create_total_result_histograms
Create total result histogram?
std::vector< std::string > m_param_variableIdentifiers
Which variables should be reported?
bool m_param_create_exp_run_event_histograms
Create exp/run/event number histograms?
std::string m_param_histogramDirectoryName
Directory to put the generated histograms.
StoreObjPtr< SoftwareTriggerVariables > m_variables
STM cut variables.
void defineHisto() override
Histogram definition.
Class to store variables with their name which were sent to the logging service.
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Abstract base class for different kinds of events.