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

The central user class to manipulate any global constant in any DB object Used to retrieve global parameters from database and access the for update. More...

#include <GlobalParam.h>

Collaboration diagram for GlobalParamVector:

Public Member Functions

 GlobalParamVector (const std::vector< std::string > &components={})
 Constructor. More...
 
 ~GlobalParamVector ()
 Destructor.
 
void construct ()
 Construct all DB objects using default constructors (should be filled with zeros)
 
GlobalParamVectoroperator+= (GlobalParamVector &rhs)
 TODO: operator += to sum two global vectors.
 
void addSubDetectorInterface (std::shared_ptr< IGlobalParamInterface > interface={})
 Add a generic interface (cannot be disabled by 'components' in constructor)
 
template<class DBObjType >
void addDBObj (std::shared_ptr< IGlobalParamInterface > interface={})
 Add a DB object to the vector, optionally with interface. More...
 
bool hasBeenChangedInDB (const std::set< unsigned short > &subset, bool resetChangedState=true)
 Has any DB object in vector changed from last call to this function. More...
 
bool hasBeenChangedInDB (const std::set< unsigned short > &subset={})
 Const version which does not change the state.
 
void updateGlobalParam (double difference, unsigned short uniqueID, unsigned short element, unsigned short param)
 Add 'difference' to param value. More...
 
void setGlobalParam (double value, unsigned short uniqueID, unsigned short element, unsigned short param)
 Set param value. More...
 
double getGlobalParam (unsigned short uniqueID, unsigned short element, unsigned short param)
 Get parameter value. More...
 
std::vector< std::tuple< unsigned short, unsigned short, unsigned short > > listGlobalParams ()
 Create vector of all global parameters maintained by GlobalParamVector.
 
std::vector< TObject * > releaseObjects (bool onlyConstructed=true)
 Get the vector of raw pointers to DB objects Caller takes the ownership of the objects and has to delete them Use for passing the objects to store in DB (not deleted after GlobalParamVector goes out of scope) More...
 
void loadFromDB ()
 Load content of all objects in vector with values valid at current EventMetaData Uses DBObjPtr<DBObjType> to access current data.
 
void loadFromDB (const EventMetaData &event)
 Load content of all objects in vector with values valid for given exp/run/event.
 
void postReadFromResult (std::vector< std::tuple< unsigned short, unsigned short, unsigned short, double >> &result)
 Function calling interfaces to do post processing after reading millepede result into GlobalParamVector.
 
void postHierarchyChanged (GlobalDerivativesHierarchy &hierarchy)
 Function calling interfaces to build alignment hierarchy after constants changed in DB.
 
template<class DBObjType >
DBObjType * getDBObj ()
 Get the raw pointer toa stored object WARNING: Use with caution, returns nullptr if object not registered (e.g. More...
 
template<class DBObjType >
GlobalParamSetAccessgetGlobalParamSet ()
 Get reference to the underlying DB object container You should check the container. More...
 
const std::map< unsigned short, std::unique_ptr< GlobalParamSetAccess > > & getGlobalParamSets () const
 Get map of all contained parameter sets, key = unique id of the set (DB object)
 
const std::vector< std::shared_ptr< IGlobalParamInterface > > & getSubDetectorInterfaces () const
 Get the vector of added interfaces to subdetectors.
 
std::set< unsigned short > getComponentsIDs () const
 Get set of unique ids of all db objects considered.
 

Public Attributes

GlobalParamSet< EmptyGlobalParamSetc_emptyGlobalParamSet {}
 An empty set to which reference is returned if DB object not found Also used e.g. More...
 

Private Attributes

std::map< unsigned short, std::unique_ptr< GlobalParamSetAccess > > m_vector {}
 The vector (well, actually a map) of DB objects.
 
std::vector< std::shared_ptr< IGlobalParamInterface > > m_subDetectorInterfacesVector {}
 Vector of interfaces to run at specific points in the workflow.
 
std::vector< std::string > m_components {}
 Vector of names of DB objects to consider in the vector - if not here and non-empy, ignored by addDBObj()
 
std::set< unsigned short > m_componentsIDs {}
 Vector of UniqueIDs of DB objects to consider in the vector.
 

Detailed Description

The central user class to manipulate any global constant in any DB object Used to retrieve global parameters from database and access the for update.

Finally all objects can be released for storing in the DB. NOTE the objects are not constructed (an thus quite some memory is saved) until you access them. But the monitoring of changes in DB starts since addDBObj<...>() TODO correct constness to not construct on listGlobalParams()

Definition at line 327 of file GlobalParam.h.

Constructor & Destructor Documentation

◆ GlobalParamVector()

GlobalParamVector ( const std::vector< std::string > &  components = {})
explicit

Constructor.

Parameters
componentsvector of string with DB objects default names in the global vector If empty, any component is included by default.

Definition at line 76 of file GlobalParam.cc.

Member Function Documentation

◆ addDBObj()

void addDBObj ( std::shared_ptr< IGlobalParamInterface interface = {})
inline

Add a DB object to the vector, optionally with interface.

Parameters
interfaceshared pointer to an interface added only if this DB object is listed in 'components' or 'components' not specified Does nothing if DB object type already added

Definition at line 371 of file GlobalParam.h.

◆ getDBObj()

DBObjType* getDBObj ( )
inline

Get the raw pointer toa stored object WARNING: Use with caution, returns nullptr if object not registered (e.g.

disabled via 'components')

Definition at line 449 of file GlobalParam.h.

◆ getGlobalParam()

double getGlobalParam ( unsigned short  uniqueID,
unsigned short  element,
unsigned short  param 
)

Get parameter value.

Parameters
uniqueIDuinique id of the DB object
elementid of the element with params inside DB object
paramid of the parameter of the element

Definition at line 96 of file GlobalParam.cc.

◆ getGlobalParamSet()

GlobalParamSetAccess& getGlobalParamSet ( )
inline

Get reference to the underlying DB object container You should check the container.

Returns
GlobalParamSet<DBObjType> or GlobalParamSet<EmptyGlobalParamSet> if DBObjType not in global vector (e.g. because disabled via 'components')

Definition at line 462 of file GlobalParam.h.

◆ hasBeenChangedInDB()

bool hasBeenChangedInDB ( const std::set< unsigned short > &  subset,
bool  resetChangedState = true 
)
inline

Has any DB object in vector changed from last call to this function.

Parameters
subsetset of unique ids of objects we are interested
resetChangedStateshould this call result in hasBeenChangedInDB=true?

Definition at line 387 of file GlobalParam.h.

◆ releaseObjects()

std::vector< TObject * > releaseObjects ( bool  onlyConstructed = true)

Get the vector of raw pointers to DB objects Caller takes the ownership of the objects and has to delete them Use for passing the objects to store in DB (not deleted after GlobalParamVector goes out of scope)

Parameters
onlyConstructedif true, only returns objects which have been actually constructed Objects are not constructed until accessed or copied from DB (or constructed explicitly)

Definition at line 117 of file GlobalParam.cc.

◆ setGlobalParam()

void setGlobalParam ( double  value,
unsigned short  uniqueID,
unsigned short  element,
unsigned short  param 
)

Set param value.

Parameters
valuevalue to set
uniqueIDuinique id of the DB object
elementid of the element with params inside DB object
paramid of the parameter of the element

Definition at line 85 of file GlobalParam.cc.

◆ updateGlobalParam()

void updateGlobalParam ( double  difference,
unsigned short  uniqueID,
unsigned short  element,
unsigned short  param 
)

Add 'difference' to param value.

Parameters
differencevalue to add to current value
uniqueIDuinique id of the DB object
elementid of the element with params inside DB object
paramid of the parameter of the element

Definition at line 78 of file GlobalParam.cc.

Member Data Documentation

◆ c_emptyGlobalParamSet

GlobalParamSet<EmptyGlobalParamSet> c_emptyGlobalParamSet {}

An empty set to which reference is returned if DB object not found Also used e.g.

to terminate hierarchy

Definition at line 331 of file GlobalParam.h.


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