Belle II Software development
SoftwareTriggerDBHandler.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
11#include <mdst/dbobjects/DBRepresentationOfSoftwareTriggerCut.h>
12#include <mdst/dbobjects/SoftwareTriggerMenu.h>
13#include <framework/database/DBObjPtr.h>
14
15namespace Belle2 {
20 namespace SoftwareTrigger {
39 public:
41 static const std::string s_dbPackageIdentifier;
43 static const std::string s_totalResultIdentifier;
44
50 static std::unique_ptr<SoftwareTriggerCut> createCutFromDB(const DBRepresentationOfSoftwareTriggerCut& dbCut);
51
59 static std::string makeFullCutName(const std::string& baseCutIdentifier,
60 const std::string& cutIdentifier);
61
70 static std::string makeTotalResultName(const std::string& baseIdentifier = "all");
71
79 static std::string makeFullTriggerMenuName(const std::string& baseIdentifier);
80
86 static bool hasBaseIdentifier(const std::string& cutName, const std::string& baseIdentifier);
87
93 static void upload(const std::unique_ptr<SoftwareTriggerCut>& cut, const std::string& baseCutIdentifier,
94 const std::string& cutIdentifier, const IntervalOfValidity& iov);
95
103 static void uploadTriggerMenu(const std::string& baseCutIdentifier,
104 const std::vector<std::string>& cutIdentifiers,
105 bool acceptMode,
106 const IntervalOfValidity& iov);
107
116 static std::unique_ptr<SoftwareTriggerCut> download(const std::string& baseCutIdentifier, const std::string& cutIdentifier);
117
125 static std::unique_ptr<SoftwareTriggerMenu> downloadTriggerMenu(const std::string& baseCutIdentifier);
126
128 explicit SoftwareTriggerDBHandler(const std::string& baseIdentifier) :
129 m_baseIdentifier(baseIdentifier),
131 {
132 initialize();
133 }
134
142 void initialize();
143
146
148 const std::map<std::string, std::unique_ptr<const SoftwareTriggerCut>>& getCutsWithNames() const;
149
151 bool getAcceptOverridesReject() const;
152
153 private:
156
159
161 std::string m_baseIdentifier = "";
165 std::vector<DBObjPtr<DBRepresentationOfSoftwareTriggerCut>> m_databaseObjects;
167 std::map<std::string, std::unique_ptr<const SoftwareTriggerCut>> m_cutsWithIdentifier;
168 };
169 }
171}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
Class to handle storing SoftwareTriggerCuts in the database.
A class that describes the interval of experiments/runs for which an object in the database is valid.
Helper class for performing up- and downloads of SoftwareTriggerCuts from the database.
static std::unique_ptr< SoftwareTriggerMenu > downloadTriggerMenu(const std::string &baseCutIdentifier)
Download a trigger menu from the database.
static std::string makeFullTriggerMenuName(const std::string &baseIdentifier)
Helper function to compile the full menu identifier from the base name.
void initialize()
Download the trigger menu and afterwards the cuts with the given base name and specific names from th...
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.
const std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > & getCutsWithNames() const
Get the already downloaded list of constant cuts with their identifiers.
static const std::string s_totalResultIdentifier
Common suffix to identify all total results in the stored results.
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.
bool getAcceptOverridesReject() const
Return true of the trigger menu is in accept mode.
SoftwareTriggerDBHandler & operator=(SoftwareTriggerDBHandler &rhs)=delete
Delete the assignment constructror.
static std::unique_ptr< SoftwareTriggerCut > createCutFromDB(const DBRepresentationOfSoftwareTriggerCut &dbCut)
Helper factory function to generate a unique cut pointer from its representation in the database.
std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > m_cutsWithIdentifier
Map of cuts with their identifiers, downloaded from the database.
SoftwareTriggerDBHandler(const std::string &baseIdentifier)
Use the default constructor (needed as we delete the copy constructor)
DBObjPtr< SoftwareTriggerMenu > m_softwareTriggerMenu
Database entry of the software trigger menu.
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 ...
std::vector< DBObjPtr< DBRepresentationOfSoftwareTriggerCut > > m_databaseObjects
Database entries of the cuts, which where created in the initialize function.
void checkForChangedDBEntries()
Helper function to check for changes in the DB of all cuts registered in the initialize function.
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.
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 const std::string s_dbPackageIdentifier
Common prefix to identify all software trigger cuts in the database.
SoftwareTriggerDBHandler(const SoftwareTriggerDBHandler &rhs)=delete
Delete the copy constructor.
static std::unique_ptr< SoftwareTriggerCut > download(const std::string &baseCutIdentifier, const std::string &cutIdentifier)
Download a cut from the database.
Abstract base class for different kinds of events.