Belle II Software  release-05-02-19
SoftwareTriggerDBHandler.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
13 #include <mdst/dbobjects/DBRepresentationOfSoftwareTriggerCut.h>
14 #include <mdst/dbobjects/SoftwareTriggerMenu.h>
15 #include <framework/database/DBObjPtr.h>
16 
17 namespace Belle2 {
22  namespace SoftwareTrigger {
40  class SoftwareTriggerDBHandler {
41  public:
43  static const std::string s_dbPackageIdentifier;
45  static const std::string s_totalResultIdentifier;
46 
52  static std::unique_ptr<SoftwareTriggerCut> createCutFromDB(const DBRepresentationOfSoftwareTriggerCut& dbCut);
53 
61  static std::string makeFullCutName(const std::string& baseCutIdentifier,
62  const std::string& cutIdentifier);
63 
72  static std::string makeTotalResultName(const std::string& baseIdentifier = "all");
73 
81  static std::string makeFullTriggerMenuName(const std::string& baseIdentifier);
82 
88  static bool hasBaseIdentifier(const std::string& cutName, const std::string& baseIdentifier);
89 
95  static void upload(const std::unique_ptr<SoftwareTriggerCut>& cut, const std::string& baseCutIdentifier,
96  const std::string& cutIdentifier, const IntervalOfValidity& iov);
97 
105  static void uploadTriggerMenu(const std::string& baseCutIdentifier,
106  const std::vector<std::string>& cutIdentifiers,
107  bool acceptMode,
108  const IntervalOfValidity& iov);
109 
118  static std::unique_ptr<SoftwareTriggerCut> download(const std::string& baseCutIdentifier, const std::string& cutIdentifier);
119 
127  static std::unique_ptr<SoftwareTriggerMenu> downloadTriggerMenu(const std::string& baseCutIdentifier);
128 
130  explicit SoftwareTriggerDBHandler(const std::string& baseIdentifier) :
131  m_baseIdentifier(baseIdentifier),
133  {
134  initialize();
135  }
136 
144  void initialize();
145 
148 
150  const std::map<std::string, std::unique_ptr<const SoftwareTriggerCut>>& getCutsWithNames() const;
151 
153  bool getAcceptOverridesReject() const;
154 
155  private:
158 
161 
163  std::string m_baseIdentifier = "";
167  std::vector<DBObjPtr<DBRepresentationOfSoftwareTriggerCut>> m_databaseObjects;
169  std::map<std::string, std::unique_ptr<const SoftwareTriggerCut>> m_cutsWithIdentifier;
170  };
171  }
173 }
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::createCutFromDB
static std::unique_ptr< SoftwareTriggerCut > createCutFromDB(const DBRepresentationOfSoftwareTriggerCut &dbCut)
Helper factory function to generate a unique cut pointer from its representation in the database.
Definition: SoftwareTriggerDBHandler.cc:32
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::makeFullCutName
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.
Definition: SoftwareTriggerDBHandler.cc:39
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::getAcceptOverridesReject
bool getAcceptOverridesReject() const
Return true of the trigger menu is in accept mode.
Definition: SoftwareTriggerDBHandler.cc:159
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::s_totalResultIdentifier
static const std::string s_totalResultIdentifier
Common suffix to identify all total results in the stored results.
Definition: SoftwareTriggerDBHandler.h:53
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::hasBaseIdentifier
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 ...
Definition: SoftwareTriggerDBHandler.cc:60
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::operator=
SoftwareTriggerDBHandler & operator=(SoftwareTriggerDBHandler &rhs)=delete
Delete the assignment constructror.
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::download
static std::unique_ptr< SoftwareTriggerCut > download(const std::string &baseCutIdentifier, const std::string &cutIdentifier)
Download a cut from the database.
Definition: SoftwareTriggerDBHandler.cc:90
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler
Helper class for performing up- and downloads of SoftwareTriggerCuts from the database.
Definition: SoftwareTriggerDBHandler.h:48
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::m_softwareTriggerMenu
DBObjPtr< SoftwareTriggerMenu > m_softwareTriggerMenu
Database entry of the software trigger menu.
Definition: SoftwareTriggerDBHandler.h:173
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::m_databaseObjects
std::vector< DBObjPtr< DBRepresentationOfSoftwareTriggerCut > > m_databaseObjects
Database entries of the cuts, which where created in the initialize function.
Definition: SoftwareTriggerDBHandler.h:175
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::uploadTriggerMenu
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.
Definition: SoftwareTriggerDBHandler.cc:79
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::initialize
void initialize()
Download the trigger menu and afterwards the cuts with the given base name and specific names from th...
Definition: SoftwareTriggerDBHandler.cc:132
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::s_dbPackageIdentifier
static const std::string s_dbPackageIdentifier
Common prefix to identify all software trigger cuts in the database.
Definition: SoftwareTriggerDBHandler.h:51
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::m_cutsWithIdentifier
std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > m_cutsWithIdentifier
Map of cuts with their identifiers, downloaded from the database.
Definition: SoftwareTriggerDBHandler.h:177
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::downloadTriggerMenu
static std::unique_ptr< SoftwareTriggerMenu > downloadTriggerMenu(const std::string &baseCutIdentifier)
Download a trigger menu from the database.
Definition: SoftwareTriggerDBHandler.cc:103
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::m_baseIdentifier
std::string m_baseIdentifier
Base identifier.
Definition: SoftwareTriggerDBHandler.h:171
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::makeFullTriggerMenuName
static std::string makeFullTriggerMenuName(const std::string &baseIdentifier)
Helper function to compile the full menu identifier from the base name.
Definition: SoftwareTriggerDBHandler.cc:53
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::SoftwareTriggerDBHandler
SoftwareTriggerDBHandler(const std::string &baseIdentifier)
Use the default constructor (needed as we delete the copy constructor)
Definition: SoftwareTriggerDBHandler.h:138
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::makeTotalResultName
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...
Definition: SoftwareTriggerDBHandler.cc:48
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::upload
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.
Definition: SoftwareTriggerDBHandler.cc:68
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::getCutsWithNames
const std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > & getCutsWithNames() const
Get the already downloaded list of constant cuts with their identifiers.
Definition: SoftwareTriggerDBHandler.cc:164
Belle2::SoftwareTrigger::SoftwareTriggerDBHandler::checkForChangedDBEntries
void checkForChangedDBEntries()
Helper function to check for changes in the DB of all cuts registered in the initialize function.
Definition: SoftwareTriggerDBHandler.cc:114