9#include <hlt/softwaretrigger/modules/basics/SoftwareTriggerResultPrinterModule.h>
10#include <hlt/softwaretrigger/core/FinalTriggerDecisionCalculator.h>
11#include <mdst/dbobjects/DBRepresentationOfSoftwareTriggerCut.h>
12#include <framework/database/DBObjPtr.h>
17#include <boost/algorithm/string/replace.hpp>
22using namespace SoftwareTrigger;
30 setDescription(
"Write out the software trigger results in an easily accessible summary table to disk.");
33 "file, in which the results of the calculation are stored. Please note that already present files will be overridden. ",
47 if (not debugOutputFile) {
48 B2FATAL(
"Could not open debug output file. Aborting.");
50 auto debugTTree = std::make_unique<TTree>(
"software_trigger_results",
"software_trigger_results");
52 B2FATAL(
"Could not create debug output tree. Aborting.");
59 debugTTree->Branch(
"cut", &cut);
60 debugTTree->Branch(
"prescaled", &prescaled);
61 debugTTree->Branch(
"accept_or_reject", &accepted);
68 unsigned int counter = 0;
70 std::string cutName = cutResult.first;
71 boost::replace_all(cutName,
"&",
"_");
72 debugTTree->Branch(cutName.c_str(), &value.at(counter));
101 const auto& cutName = cutResult.first;
104 value[counter] = NAN;
121 const auto& cutName = cutResult.first;
124 value[counter] = NAN;
141 const auto& cutName = cutResult.first;
144 value[counter] = NAN;
147 value[counter] =
static_cast<double>(
m_prescales[cutName]);
153 debugOutputFile->cd();
154 debugOutputFile->Write();
156 debugOutputFile.reset();
167 if (cutName.find(
"total_result") == std::string::npos) {
172 m_prescales[cutName] = downloadedCut->getPreScaleFactor();
193 B2WARNING(
"Uncaught exception encountered: Trying to access StoreObjPtr object 'TRGSummary' (durability: event), which was not created in exp/run/evt: "
Class for accessing objects in the database.
void setDescription(const std::string &description)
Sets the description of the module.
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...
StoreObjPtr< TRGSummary > m_l1Result
Store Object for reading the l1 result.
std::map< std::string, std::map< SoftwareTriggerCutResult, unsigned int > > m_passedEventsPerTriggerNonPrescaled
Internal map of summed results.
void initialize() override
Require the needed store object.
void event() override
Write out the cuts if wanted and sum them up.
std::string m_param_outputFileName
Output file name for the debug output.
void terminate() override
Store and delete the ttree if it was created. Print out the summed results.
std::map< std::string, std::map< SoftwareTriggerCutResult, unsigned int > > m_passedEventsPerTrigger
Internal map of summed results.
std::map< std::string, unsigned int > m_prescales
Internal map of prescales.
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
EventMetaData is used by processEvent()/processCore().
StoreObjPtr< SoftwareTriggerResult > m_resultStoreObjectPointer
Store Object for reading the trigger decision.
unsigned int m_numberOfEvents
Internal counter for the number of seen events.
SoftwareTriggerResultPrinterModule()
Create a new module instance and set the parameters.
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
SoftwareTriggerCutResult
Enumeration with all possible results of the SoftwareTriggerCut.
@ c_accept
Accept this event.
@ c_reject
Reject this event.
Abstract base class for different kinds of events.