LCCD  1.5.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lccd::DBInterface Class Reference

Provides a simple interface to the conditions data base for lccd. More...

#include <DBInterface.hh>

Public Member Functions

 DBInterface (const DBInterface &)=delete
 
DBInterfaceoperator= (const DBInterface &)=delete
 
 DBInterface (const std::string &folder, bool update=false)
 Default c'tor, uses lccd::getDBInitString() to determine the db initialization, i.e. More...
 
 DBInterface (const std::string &dbInit, const std::string &folder, bool update=false)
 Open the database specified in dbInit. More...
 
virtual ~DBInterface ()
 D'tor.
 
ICondDBMgr * condDBMgr ()
 The db manager object - use for direct access to the conditions database.
 
ICondDBDataAccess * condDataAccess ()
 The db access object - use for direct access to the conditions database. More...
 
ICondDBFolderMgr * condFolderMgr ()
 The folder manager - use for direct access to the conditions database. More...
 
ICondDBTagMgr * condTagMgr ()
 The tag manager - use for direct access to the conditions database.
 
const std::string & folderName ()
 The folder used for this DB access.
 
const std::string & dbName ()
 The db name used for this DB access.
 
void storeCollection (LCCDTimeStamp since, LCCDTimeStamp till, lcio::LCCollection *col, const std::string &description)
 Stores the given collection in the database.
 
lcio::LCCollection * findCollection (LCCDTimeStamp timeStamp, LCCDTimeStamp &since, LCCDTimeStamp &till, const std::string &tag="")
 Retrieves the collection for the given point in time - returns NULL if no data is found. More...
 
lcio::LCCollection * findNextValidCollection (LCCDTimeStamp timeStamp, LCCDTimeStamp &since, LCCDTimeStamp &till, const std::string &tag="")
 Retrieves the next valid collection from the given point in time, searching forward in time - returns NULL if no data is found. More...
 
lcio::LCCollection * findLastValidCollection (LCCDTimeStamp timeStamp, LCCDTimeStamp &since, LCCDTimeStamp &till, const std::string &tag="")
 Retrieves the last valid collection before the given point in time, searching backwards in time - returns NULL if no data is found. More...
 
lcio::LCCollection * findCollection (LCCDTimeStamp timeStamp, const std::string &tag="")
 Retrieves the collection for the given point in time - returns NULL if it no data is found. More...
 
void findCollections (ColVec &colVec, const std::string &tag="")
 Creates collections for all conditions data for the given tag and adds them to the colvec. More...
 
void findCollections (ColVec &colVec, LCCDTimeStamp since, LCCDTimeStamp till, const std::string &tag="")
 Creates collections for all conditions data for the given time range and tag. More...
 
void findCollections (ColVec &colVec, LCCDTimeStamp timeStamp)
 Creates collections for all conditions data for the given timestamp. More...
 
void findAllCollections (ColVec &colVec)
 Debug Method: Creates collections for all conditions data in current folder. More...
 
void tagFolder (const std::string &tagName, const std::string &description="", std::string usingTagName="")
 Tag the current HEAD of the database folder as tagName. More...
 
bool folderBranchContainsTag (const std::string &tagName)
 Checks if the folder given in the constructor or one of its sub folders is already tagged with the tag given in tagName. More...
 
void createDBFile (const std::string &tag="")
 Creates an LCIO file with the all conditions data in the folder for the given tag. More...
 
void createSimpleFile (LCCDTimeStamp timeStamp, const std::string &tag, bool allLayers=false)
 Creates an LCIO file with one event that has a collection with the conditions data for the given time stamp and tag (use "" for the current HEAD). More...
 
void dump2File ()
 Debug Method: Creates an LCIO file with the all conditions data in the folder. More...
 

Protected Member Functions

void init ()
 Initializes the database access.
 
lcio::LCCollection * collectionFromCondDBObject (ICondDBObject *object, const std::string &tag)
 Creates an LCColleciton from the data in the ICondDBObject. More...
 

Protected Attributes

ICondDBMgr * _condDBmgr = nullptr
 
ICondDBDataAccess * _condDataAccess = nullptr
 
ICondDBFolderMgr * _condFolderMgr = nullptr
 
ICondDBTagMgr * _condTagMgr = nullptr
 

Detailed Description

Provides a simple interface to the conditions data base for lccd.

The functionality corresponds to a subset of the ConditionsDB API for user's ( and lccd developer's) convenience. Most of the usual tasks can be handled through this interface.
If needed access to the relevant manager objects of ConditionsDB is provided.
Every DBInterface object is attached to one particular folder in a particular database.
The methods createDBFile() and createSimpleFile() can be used to produce LCIO files with conditions data as input for the corresponding conditions handlers in a reconstrcution program.
They also provide an easy way to browse the database horizontally (by tag) or vertically (by time stamp).

20090109, B.Lutz DESY: added functions: void findCollections(ColVec &colVec, LCCDTimeStamp since, LCCDTimeStamp till, const std::string &tag="") ; void dump2File( ) ; void findAllCollections( ColVec& colVec ) ;

Author
F.Gaede, DESY
Version
Id:
DBInterface.hh,v 1.11 2009-01-09 10:20:58 gaede Exp

Constructor & Destructor Documentation

lccd::DBInterface::DBInterface ( const std::string &  folder,
bool  update = false 
)

Default c'tor, uses lccd::getDBInitString() to determine the db initialization, i.e.

as defined by the environment variable $LCCD_DB_INIT. In update mode the folder is created if it doesn't exist - provided the database user has the proper privileges.

Parameters
folder,:the folder used for this db access
update,:open db in update mode, default: false

References init().

lccd::DBInterface::DBInterface ( const std::string &  dbInit,
const std::string &  folder,
bool  update = false 
)

Open the database specified in dbInit.

In update mode the folder is created if it doesn't exist - provided the database user has the proper privileges.

Parameters
folder,:the folder used for this db access
update,:open db in update mode, default: false

References init().

Member Function Documentation

lcio::LCCollection * lccd::DBInterface::collectionFromCondDBObject ( ICondDBObject *  object,
const std::string &  tag 
)
protected
ICondDBDataAccess* lccd::DBInterface::condDataAccess ( )
inline

The db access object - use for direct access to the conditions database.

Referenced by findAllCollections(), findCollection(), findCollections(), findLastValidCollection(), findNextValidCollection(), and storeCollection().

ICondDBFolderMgr* lccd::DBInterface::condFolderMgr ( )
inline

The folder manager - use for direct access to the conditions database.

void lccd::DBInterface::createDBFile ( const std::string &  tag = "")

Creates an LCIO file with the all conditions data in the folder for the given tag.

The collections are sorted w.r.t. their validity time intervall and attached to consecutive events. The run header holds a map of validity time intervalls to events. in the parameters DBSince and DBTill.
The name of the file will be of the form "conddb_COLNAME_TAG_YYYYMMDD_HHMMSS.slcio" where the specified time is the creation time. This file can be used by the DBFileHandler.

References lccd::DBFOLDER, lccd::DBNAME, lccd::DBSINCE, lccd::DBTAG, lccd::DBTILL, and findCollections().

void lccd::DBInterface::createSimpleFile ( LCCDTimeStamp  timeStamp,
const std::string &  tag,
bool  allLayers = false 
)

Creates an LCIO file with one event that has a collection with the conditions data for the given time stamp and tag (use "" for the current HEAD).


If allLayers==true then in addition to the specified collection, all collections in the database for this timestamp are added to the event with name COLNAME_layer_LAYERNUM. The name of the file will be of the form "conddb_COLNAME_TAG_TIMESTAMP.slcio" This file can be used by the SimpleFileHandler.

References lccd::DBFOLDER, lccd::DBLAYER, lccd::DBNAME, lccd::DBTAG, lccd::DBTIMESTAMP, findCollection(), and findCollections().

void lccd::DBInterface::dump2File ( )

Debug Method: Creates an LCIO file with the all conditions data in the folder.


This file does not respect tags. It is not meant to be used with the DBFileHandler.

The collections are sorted w.r.t. their validity time intervall and attached to consecutive events. The run header holds a map of validity time intervalls to events. in the parameters DBSince and DBTill.
The name of the file will be of the form "conddb_COLNAME_YYYYMMDD_HHMMSS.slcio" where the specified time is the creation time.

Warning
This file does not respect tags. It is not meant ot be used with the DBFileHandler.

References lccd::DBFOLDER, lccd::DBNAME, lccd::DBSINCE, lccd::DBTILL, and findAllCollections().

void lccd::DBInterface::findAllCollections ( ColVec colVec)

Debug Method: Creates collections for all conditions data in current folder.


This does not respect tags.

Description parameters are added to the collections as in findCollection() plus DBLayer.

Warning
This does not respect tags.

References collectionFromCondDBObject(), and condDataAccess().

Referenced by dump2File().

lcio::LCCollection * lccd::DBInterface::findCollection ( LCCDTimeStamp  timeStamp,
LCCDTimeStamp since,
LCCDTimeStamp till,
const std::string &  tag = "" 
)

Retrieves the collection for the given point in time - returns NULL if no data is found.


This expects the LCIO collection type to be decoded in the object description:
"LCIO_COL_TYPE: some description" - storeCollection() does this automatically.
Some parameters are added to the collection:

  • DBName: name of the (MySQL) database
  • DBFolder: data base folder
  • DBTag: the tag used for the query - possibly HEAD at that time.
  • DBQueryTime: the time the conditions data was extracted from the data base.
  • DBInsertionTime: the time the conditions data was inserted into the data base.
  • DBSince: the start of the vaidity intervall
  • DBTill: the end of the validity intervall
  • DBLayer: the layer number of this data set

DBQueryTime, DBInsertionTime, DBSince and DBTill are string vectors with two elements: the 64bit time stamp and the date in human readable format.

Parameters
timeStamp,:the point in time for which the conditions data is valid
since,:return the begin of the validity interval
end,:return the end of the validity interval
tag,:the tag to be used for the query, if omitted HEAD is used

References collectionFromCondDBObject(), and condDataAccess().

Referenced by createSimpleFile(), findCollection(), and lccd::DBCondHandler::update().

lcio::LCCollection * lccd::DBInterface::findCollection ( LCCDTimeStamp  timeStamp,
const std::string &  tag = "" 
)

Retrieves the collection for the given point in time - returns NULL if it no data is found.


Same as above, except that no information on the validity interval is returned.

References findCollection().

void lccd::DBInterface::findCollections ( ColVec colVec,
const std::string &  tag = "" 
)

Creates collections for all conditions data for the given tag and adds them to the colvec.

The collections are ordered w.r.t. to their validity time.
Description parameters are added to the collections as in findCollection().

References collectionFromCondDBObject(), and condDataAccess().

Referenced by createDBFile(), and createSimpleFile().

void lccd::DBInterface::findCollections ( ColVec colVec,
LCCDTimeStamp  since,
LCCDTimeStamp  till,
const std::string &  tag = "" 
)

Creates collections for all conditions data for the given time range and tag.

The result is added to the colvec. The collections are ordered w.r.t. to their validity time.
Description parameters are added to the collections as in findCollection().

References collectionFromCondDBObject(), and condDataAccess().

void lccd::DBInterface::findCollections ( ColVec colVec,
LCCDTimeStamp  timeStamp 
)

Creates collections for all conditions data for the given timestamp.

The collections are ordered w.r.t. to the layer number in the database.
Description parameters are added to the collections as in findCollection() plus DBLayer.

References collectionFromCondDBObject(), and condDataAccess().

lcio::LCCollection * lccd::DBInterface::findLastValidCollection ( LCCDTimeStamp  timeStamp,
LCCDTimeStamp since,
LCCDTimeStamp till,
const std::string &  tag = "" 
)

Retrieves the last valid collection before the given point in time, searching backwards in time - returns NULL if no data is found.


This expects the LCIO collection type to be decoded in the object description:
"LCIO_COL_TYPE: some description" - storeCollection() does this automatically.
Some parameters are added to the collection:

  • DBName: name of the (MySQL) database
  • DBFolder: data base folder
  • DBTag: the tag used for the query - possibly HEAD at that time.
  • DBQueryTime: the time the conditions data was extracted from the data base.
  • DBInsertionTime: the time the conditions data was inserted into the data base.
  • DBSince: the start of the vaidity intervall
  • DBTill: the end of the validity intervall
  • DBLayer: the layer number of this data set

DBQueryTime, DBInsertionTime, DBSince and DBTill are string vectors with two elements: the 64bit time stamp and the date in human readable format.

Parameters
timeStamp,:the point in time from which to search backwards for conditions data
since,:return the begin of the validity interval of the conditions data returned
end,:return the end of the validity interval of the conditions data returned
tag,:the tag to be used for the query, if omitted HEAD is used

References collectionFromCondDBObject(), and condDataAccess().

Referenced by lccd::DBCondHandler::update().

lcio::LCCollection * lccd::DBInterface::findNextValidCollection ( LCCDTimeStamp  timeStamp,
LCCDTimeStamp since,
LCCDTimeStamp till,
const std::string &  tag = "" 
)

Retrieves the next valid collection from the given point in time, searching forward in time - returns NULL if no data is found.


This expects the LCIO collection type to be decoded in the object description:
"LCIO_COL_TYPE: some description" - storeCollection() does this automatically.
Some parameters are added to the collection:

  • DBName: name of the (MySQL) database
  • DBFolder: data base folder
  • DBTag: the tag used for the query - possibly HEAD at that time.
  • DBQueryTime: the time the conditions data was extracted from the data base.
  • DBInsertionTime: the time the conditions data was inserted into the data base.
  • DBSince: the start of the vaidity intervall
  • DBTill: the end of the validity intervall
  • DBLayer: the layer number of this data set

DBQueryTime, DBInsertionTime, DBSince and DBTill are string vectors with two elements: the 64bit time stamp and the date in human readable format.

Parameters
timeStamp,:the point in time from which to search foward for conditions data
since,:return the begin of the validity interval of the conditions data returned
end,:return the end of the validity interval of the conditions data returned
tag,:the tag to be used for the query, if omitted HEAD is used

References collectionFromCondDBObject(), and condDataAccess().

Referenced by lccd::DBCondHandler::update().

bool lccd::DBInterface::folderBranchContainsTag ( const std::string &  tagName)

Checks if the folder given in the constructor or one of its sub folders is already tagged with the tag given in tagName.

Result is "true" if the tag was already applied to the folder or a sub folder.

References condTagMgr().

Referenced by tagFolder().

void lccd::DBInterface::tagFolder ( const std::string &  tagName,
const std::string &  description = "",
std::string  usingTagName = "" 
)

Tag the current HEAD of the database folder as tagName.

If the argument usingTagName is provided and refers to an existing tag this tag will be duplicated as tagName.
This can be used to provide a common tag with the same name for several folders of conditions data that have been tagged before with different names.

References condTagMgr(), and folderBranchContainsTag().


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