 |
Belle II Software
release-05-01-25
|
10 #include <framework/database/DBImportObjPtr.h>
11 #include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
13 #include <boost/algorithm/string/predicate.hpp>
20 namespace SoftwareTrigger {
27 dbCut.getPreScaleFactor(),
32 const std::string& cutIdentifier)
34 assert(baseCutIdentifier.find(
"&") == std::string::npos);
35 assert(cutIdentifier.find(
"&") == std::string::npos);
47 assert(baseIdentifier.find(
"&") == std::string::npos);
54 assert(baseIdentifier.find(
"&") == std::string::npos);
55 assert(std::count(cutName.begin(), cutName.end(),
'&') == 2);
57 return boost::starts_with(cutName,
makeFullCutName(baseIdentifier,
""));
63 B2ASSERT(
"The name " <<
s_totalResultIdentifier <<
" is already used for the total result of each trigger stage. "
65 const std::string& fullCutName =
makeFullCutName(baseCutIdentifier, cutIdentifier);
67 cutToUpload.
construct(cut->getPreScaleFactor(), cut->isRejectCut(), cut->decompile());
72 const std::vector<std::string>& cutIdentifiers,
78 menuToUpload.
construct(cutIdentifiers, acceptMode);
83 const std::string& cutIdentifier)
85 const std::string& fullCutName =
makeFullCutName(baseCutIdentifier, cutIdentifier);
94 std::unique_ptr<SoftwareTriggerMenu>
100 return std::make_unique<SoftwareTriggerMenu>(*downloadedMenu);
116 if (databaseCutEntry.hasChanged()) {
117 B2ASSERT(
"The name of the database entry changed! This is not handled properly by the module.",
126 B2ASSERT(
"Could not find a valid trigger name with this "
135 B2DEBUG(20,
"Initializing SoftwareTrigger DB with baseIdentifier " <<
m_baseIdentifier <<
" and " << cutIdentifiers.size() <<
138 for (
const std::string& cutIdentifier : cutIdentifiers) {
139 B2DEBUG(20,
"-> with CutIndentifier " << cutIdentifier);
146 B2FATAL(
"There is no DB object with the name " << fullIdentifier);
A class that describes the interval of experiments/runs for which an object in the database is valid.
static std::unique_ptr< SoftwareTriggerCut > createCutFromDB(const DBRepresentationOfSoftwareTriggerCut &dbCut)
Helper factory function to generate a unique cut pointer from its representation in the database.
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.
bool getAcceptOverridesReject() const
Return true of the trigger menu is in accept mode.
static const std::string s_totalResultIdentifier
Common suffix to identify all total results in the stored results.
void construct(Args &&... params)
Construct an object of type T in this DBImportObjPtr using the provided constructor arguments.
bool import(const IntervalOfValidity &iov)
Import the object to database.
static bool hasBaseIdentifier(const std::string &cutName, const std::string &baseIdentifier)
Check if a given cut name in the form <package_identifier>&<base_name>&<cut_name> has the given base ...
static std::unique_ptr< SoftwareTriggerCut > download(const std::string &baseCutIdentifier, const std::string &cutIdentifier)
Download a cut from the database.
Class for accessing objects in the database.
DBObjPtr< SoftwareTriggerMenu > m_softwareTriggerMenu
Database entry of the software trigger menu.
std::vector< DBObjPtr< DBRepresentationOfSoftwareTriggerCut > > m_databaseObjects
Database entries of the cuts, which where created in the initialize function.
static void uploadTriggerMenu(const std::string &baseCutIdentifier, const std::vector< std::string > &cutIdentifiers, bool acceptMode, const IntervalOfValidity &iov)
Upload a new (or replace an old version) trigger menu with the given base and specific names.
void initialize()
Download the trigger menu and afterwards the cuts with the given base name and specific names from th...
static const std::string s_dbPackageIdentifier
Common prefix to identify all software trigger cuts in the database.
Abstract base class for different kinds of events.
std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > m_cutsWithIdentifier
Map of cuts with their identifiers, downloaded from the database.
static std::unique_ptr< SoftwareTriggerMenu > downloadTriggerMenu(const std::string &baseCutIdentifier)
Download a trigger menu from the database.
std::string m_baseIdentifier
Base identifier.
Class for importing a single object to the database.
static std::string makeFullTriggerMenuName(const std::string &baseIdentifier)
Helper function to compile the full menu identifier from the base 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...
static void upload(const std::unique_ptr< SoftwareTriggerCut > &cut, const std::string &baseCutIdentifier, const std::string &cutIdentifier, const IntervalOfValidity &iov)
Upload a new (or replace an old version) cut with the given base and specific name.
const std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > & getCutsWithNames() const
Get the already downloaded list of constant cuts with their identifiers.
static std::unique_ptr< SoftwareTriggerCut > compile(const std::string &cut_string, const unsigned int prescaleFactor, const bool rejectCut=false)
Compile a new SoftwareTriggerCut from a cut string (by using the GeneralCut::compile function) and an...
void checkForChangedDBEntries()
Helper function to check for changes in the DB of all cuts registered in the initialize function.