Belle II Software  release-08-01-10
SoftwareTriggerDBHandler Class Reference

Helper class for performing up- and downloads of SoftwareTriggerCuts from the database. More...

#include <SoftwareTriggerDBHandler.h>

Collaboration diagram for SoftwareTriggerDBHandler:

Public Member Functions

 SoftwareTriggerDBHandler (const std::string &baseIdentifier)
 Use the default constructor (needed as we delete the copy constructor)
 
void initialize ()
 Download the trigger menu and afterwards the cuts with the given base name and specific names from the database and register them here. More...
 
void checkForChangedDBEntries ()
 Helper function to check for changes in the DB of all cuts registered in the initialize function.
 
const std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > & getCutsWithNames () const
 Get the already downloaded list of constant cuts with their identifiers.
 
bool getAcceptOverridesReject () const
 Return true of the trigger menu is in accept mode.
 

Static Public Member Functions

static std::unique_ptr< SoftwareTriggerCutcreateCutFromDB (const DBRepresentationOfSoftwareTriggerCut &dbCut)
 Helper factory function to generate a unique cut pointer from its representation in the database. More...
 
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. More...
 
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 filter or skim) in the stored results or the total result. More...
 
static std::string makeFullTriggerMenuName (const std::string &baseIdentifier)
 Helper function to compile the full menu identifier from the base name. More...
 
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 name.
 
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. More...
 
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. More...
 
static std::unique_ptr< SoftwareTriggerCutdownload (const std::string &baseCutIdentifier, const std::string &cutIdentifier)
 Download a cut from the database. More...
 
static std::unique_ptr< SoftwareTriggerMenudownloadTriggerMenu (const std::string &baseCutIdentifier)
 Download a trigger menu from the database. More...
 

Static Public Attributes

static const std::string s_dbPackageIdentifier = "software_trigger_cut"
 Common prefix to identify all software trigger cuts in the database.
 
static const std::string s_totalResultIdentifier = "total_result"
 Common suffix to identify all total results in the stored results.
 

Private Member Functions

 SoftwareTriggerDBHandler (const SoftwareTriggerDBHandler &rhs)=delete
 Delete the copy constructor.
 
SoftwareTriggerDBHandleroperator= (SoftwareTriggerDBHandler &rhs)=delete
 Delete the assignment constructror.
 

Private Attributes

std::string m_baseIdentifier = ""
 Base identifier.
 
DBObjPtr< SoftwareTriggerMenum_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.
 
std::map< std::string, std::unique_ptr< const SoftwareTriggerCut > > m_cutsWithIdentifier
 Map of cuts with their identifiers, downloaded from the database.
 

Detailed Description

Helper class for performing up- and downloads of SoftwareTriggerCuts from the database.

In the typical module setup, you would create an instance of this class as a module member, call the initialize function with the cuts you want to process in the module's initialize method and look for changed DB entries in the beginRun function.

In the normal event function of the module, you can get a list of cuts with their names by calling the getCutsWithNames method.

You can also upload new cuts (or new versions of cuts) with the upload function.

In all download and upload methods, you have to provide both a base name and a specific name for the cut. Both names are used (together with a package name) to construct the identifier of the cut (using the getFullCutName method). You can only download cuts from the same set (defined with the same base name), to not mix e.g. level3 and hlt cuts.

Definition at line 38 of file SoftwareTriggerDBHandler.h.

Member Function Documentation

◆ createCutFromDB()

std::unique_ptr< SoftwareTriggerCut > createCutFromDB ( const DBRepresentationOfSoftwareTriggerCut dbCut)
static

Helper factory function to generate a unique cut pointer from its representation in the database.

Was part of the DBRepresentation before, but is now a standalone function.

Definition at line 22 of file SoftwareTriggerDBHandler.cc.

23  {
24  return SoftwareTrigger::SoftwareTriggerCut::compile(dbCut.getCutString(),
25  dbCut.getPreScaleFactor(),
26  dbCut.isRejectCut());
27  }
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...

◆ download()

std::unique_ptr< SoftwareTriggerCut > download ( const std::string &  baseCutIdentifier,
const std::string &  cutIdentifier 
)
static

Download a cut from the database.

This function should only be called from python to interact with/edit single cuts and not from your module to check the cuts (use the initialize method etc. for this).

Parameters
baseCutIdentifierThe base name of the cut to download.
cutIdentifierThe identifier of the cut to download.
Returns
A unique pointer to the downloaded cut or a nullptr of no cut with this name is in the DB.

Definition at line 80 of file SoftwareTriggerDBHandler.cc.

◆ downloadTriggerMenu()

std::unique_ptr< SoftwareTriggerMenu > downloadTriggerMenu ( const std::string &  baseCutIdentifier)
static

Download a trigger menu from the database.

This function should only be called from python to interact with/edit single menus and not from your module to check the cuts (use the initialize method etc. for this).

Parameters
baseCutIdentifierThe base name of the trigger menu to download.
Returns
A unique pointer to the downloaded menu or a nullptr of no menu with this name is in the DB.

Definition at line 93 of file SoftwareTriggerDBHandler.cc.

◆ initialize()

void initialize ( void  )

Download the trigger menu and afterwards the cuts with the given base name and specific names from the database and register them here.

When calling the checkForChangedDBEntries, these cuts will be checked for changes.

To get the cuts with their identifiers, call the getCutsWithNames function.

Definition at line 122 of file SoftwareTriggerDBHandler.cc.

◆ makeFullCutName()

std::string makeFullCutName ( const std::string &  baseCutIdentifier,
const std::string &  cutIdentifier 
)
static

Helper function to compile the full identifier from the base and the specific cut name.

The full name is then created as: <package_identifier>&<base_name>&<cut_name>

Make sure to not include & into the base or cut name.

Definition at line 29 of file SoftwareTriggerDBHandler.cc.

◆ makeFullTriggerMenuName()

std::string makeFullTriggerMenuName ( const std::string &  baseIdentifier)
static

Helper function to compile the full menu identifier from the base name.

The full name is then created as: <package_identifier>&<base_name>

Make sure to not include & into the base name.

Definition at line 43 of file SoftwareTriggerDBHandler.cc.

◆ makeTotalResultName()

std::string makeTotalResultName ( const std::string &  baseIdentifier = "all")
static

Handy function to create the name related to the total result of a specific trigger stage (either filter or skim) in the stored results or the total result.

It is in the form <package_identifier>&<base_name>&total_result

Parameters
baseIdentifierThe baseIdentifier (either filter or skim or all)
Returns
then name.

Definition at line 38 of file SoftwareTriggerDBHandler.cc.

◆ upload()

void upload ( const std::unique_ptr< SoftwareTriggerCut > &  cut,
const std::string &  baseCutIdentifier,
const std::string &  cutIdentifier,
const IntervalOfValidity iov 
)
static

Upload a new (or replace an old version) cut with the given base and specific name.

Neither the base nor the cut name are allowed to have '&' in it. Please make sure that the base name must correspond to the identifiers of the calculation objects created in the SoftwareTriggerModule.

Definition at line 58 of file SoftwareTriggerDBHandler.cc.

◆ uploadTriggerMenu()

void uploadTriggerMenu ( const std::string &  baseCutIdentifier,
const std::vector< std::string > &  cutIdentifiers,
bool  acceptMode,
const IntervalOfValidity iov 
)
static

Upload a new (or replace an old version) trigger menu with the given base and specific names.

Neither the base nor the cut names are allowed to have '&' in it. Please make sure that the base name must correspond to the identifiers of the calculation objects created in the SoftwareTriggerModule and the cut names must correspond to cuts uploaded into the database.

Definition at line 69 of file SoftwareTriggerDBHandler.cc.


The documentation for this class was generated from the following files: