Belle II Software development
SoftwareTriggerVariableManager Class Reference

Variable Manager for the software trigger cuts. More...

#include <SoftwareTriggerVariableManager.h>

Classes

class  SoftwareTriggerVariable
 Class which represents an abstract variable in the SoftwareTriggerVariableManager. More...
 

Public Types

typedef SoftwareTriggerObject Object
 As an object handed in for every cut to be checked, use a map of variable name -> precompiled value.
 
typedef SoftwareTriggerVariable Var
 Use a very slim object for the variables: only draw out the corresponding value from the precompiled map of values.
 
typedef std::variant< double, int, bool > VarVariant
 Typedef for variable return type, can either be double, int or bool in std::variant.
 

Public Member Functions

SoftwareTriggerVariablegetVariable (const std::string &variableName)
 Get the variable with the given name.
 
SoftwareTriggerVariablegetVariable (const std::string &variableName, const std::vector< std::string > &arguments)
 The GeneralCut parses MetaVariables into its variable name and arguments.
 

Static Public Member Functions

static SoftwareTriggerVariableManagerInstance ()
 Make this variable manager a singleton and get the only single instance of the manager.
 

Private Member Functions

 SoftwareTriggerVariableManager ()
 Make the constructor private: only use this class as a singleton.
 
 SoftwareTriggerVariableManager (const SoftwareTriggerVariableManager &)=delete
 Delete the copy constructor: only use this class as a singleton.
 
SoftwareTriggerVariableManageroperator= (SoftwareTriggerVariableManager &rhs)=delete
 Delete the assignment operator: only use this class as a singleton.
 

Private Attributes

std::map< std::string, std::shared_ptr< SoftwareTriggerVariable > > m_variableNameToVariable
 Internal storage of the variables with their name.
 

Detailed Description

Variable Manager for the software trigger cuts.

This class fulfills all the requirement of a variable manager, as stated in the GeneralCut class and can (and should) therefore be used together with it, which is done in the SoftwareTriggerCut.

The idea behind it is as follows: The SoftwareTriggerVariableManager itself does not know on how to calculate your needed variables, but you as the user of the SoftwareTriggerCut has to know. This gives you the opportunity to calculate them differently before or after the full reconstruction (because you may not have all information at hand at all time) or use temporary shared calculation objects when compiling the numbers. Whenever a SoftwareTriggerCut has a variable it it and the check function asks the variable manager for its value, the variable manager will collect this value from the SoftwareTriggerObject (a map from std::string to double) with the given variable name. So you as the user has to make sure that the needed variables can be found in the SoftwareTriggerObject, that you hand in to the checkPreScaled function of the SoftwareTriggerCut.

Definition at line 37 of file SoftwareTriggerVariableManager.h.

Member Typedef Documentation

◆ Object

typedef SoftwareTriggerObject Object

As an object handed in for every cut to be checked, use a map of variable name -> precompiled value.

Definition at line 84 of file SoftwareTriggerVariableManager.h.

◆ Var

Use a very slim object for the variables: only draw out the corresponding value from the precompiled map of values.

Definition at line 89 of file SoftwareTriggerVariableManager.h.

◆ VarVariant

typedef std::variant<double, int, bool> VarVariant

Typedef for variable return type, can either be double, int or bool in std::variant.

Definition at line 92 of file SoftwareTriggerVariableManager.h.

Constructor & Destructor Documentation

◆ SoftwareTriggerVariableManager()

SoftwareTriggerVariableManager ( )
inlineprivate

Make the constructor private: only use this class as a singleton.

Definition at line 121 of file SoftwareTriggerVariableManager.h.

121{ }

Member Function Documentation

◆ getVariable() [1/2]

SoftwareTriggerVariableManager::SoftwareTriggerVariable * getVariable ( const std::string &  variableName)

Get the variable with the given name.

If it is not already present in the internal map of variables, create a new one. Please note, that this function will never mark a variable as undefined, so there is no registration process as in the analysis variable manager. If a variable is defined or not depends only on the SoftwareTriggerObject that is used when checking the cut (and if there is an entry with the same name as the variable in this object).

Definition at line 23 of file SoftwareTriggerVariableManager.cc.

25 {
26 auto lowerBoundIterator = m_variableNameToVariable.lower_bound(variableName);
27 if (lowerBoundIterator == m_variableNameToVariable.end() or lowerBoundIterator->first != variableName) {
28 lowerBoundIterator = m_variableNameToVariable.insert(lowerBoundIterator,
29 {variableName, std::shared_ptr<SoftwareTriggerVariable>(new SoftwareTriggerVariable(variableName))});
30 }
31 return lowerBoundIterator->second.get();
32 }
std::map< std::string, std::shared_ptr< SoftwareTriggerVariable > > m_variableNameToVariable
Internal storage of the variables with their name.

◆ getVariable() [2/2]

SoftwareTriggerVariableManager::SoftwareTriggerVariable * getVariable ( const std::string &  variableName,
const std::vector< std::string > &  arguments 
)

The GeneralCut parses MetaVariables into its variable name and arguments.

GeneralCut requires any VariableManager to get a variable through this parsed state. This overload combines the variableName and vector of strings to the original Metavariable call using boost::algorithm::join and passes it to getVariable(const std::string& variableName)

Definition at line 34 of file SoftwareTriggerVariableManager.cc.

36 {
37 auto fullname = variableName + "(" + boost::algorithm::join(arguments, ", ") + ")";
39 }
SoftwareTriggerVariable * getVariable(const std::string &variableName)
Get the variable with the given name.

◆ Instance()

SoftwareTriggerVariableManager & Instance ( )
static

Make this variable manager a singleton and get the only single instance of the manager.

You can still use it multiple times in different modules, as it depends on the map of values you hand in when checking the cut if the variable is defined or not.

Definition at line 17 of file SoftwareTriggerVariableManager.cc.

18 {
19 static SoftwareTriggerVariableManager instance;
20 return instance;
21 }
SoftwareTriggerVariableManager()
Make the constructor private: only use this class as a singleton.

Member Data Documentation

◆ m_variableNameToVariable

std::map<std::string, std::shared_ptr<SoftwareTriggerVariable> > m_variableNameToVariable
private

Internal storage of the variables with their name.

Definition at line 130 of file SoftwareTriggerVariableManager.h.


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