LCCD  1.5.0
DBInterface.hh
1 #ifndef DBInterface_h
2 #define DBInterface_h
3 
4 
5 #include "lccd.h"
6 
7 
8 // forward declarations
9 class ICondDBMgr ;
10 class ICondDBDataAccess;
11 class ICondDBFolderMgr;
12 class ICondDBTagMgr;
13 class ICondDBObject;
14 
15 
16 // LCIO headers
17 #include "lcio.h"
18 #include "EVENT/LCCollection.h"
19 
20 
21 #include <iostream>
22 
23 namespace lccd {
24 
26  typedef std::vector< lcio::LCCollection* > ColVec ;
27 
28 
53  class DBInterface {
54 
55  public:
56 
57  DBInterface( const DBInterface& ) = delete ;
58  DBInterface& operator=( const DBInterface& ) = delete ;
59 
60 
69  DBInterface( const std::string& folder, bool update=false ) ;
70 
78  DBInterface( const std::string& dbInit, const std::string& folder, bool update=false) ;
79 
81  virtual ~DBInterface() ;
82 
85  ICondDBMgr* condDBMgr() { return _condDBmgr ; }
86 
89  ICondDBDataAccess* condDataAccess() { return _condDataAccess ; }
90 
93  ICondDBFolderMgr* condFolderMgr() { return _condFolderMgr ; }
94 
97  ICondDBTagMgr * condTagMgr() { return _condTagMgr ; }
98 
99 
102  const std::string& folderName() { return _folder ; }
103 
106  const std::string& dbName() { return _dbName ; }
107 
108 
111  void storeCollection( LCCDTimeStamp since, LCCDTimeStamp till,
112  lcio::LCCollection* col,
113  const std::string& description ) ;
114 
115 
139  lcio::LCCollection* findCollection( LCCDTimeStamp timeStamp,
140  LCCDTimeStamp& since, LCCDTimeStamp& till,
141  const std::string& tag="" ) ;
142 
143 
144 
169  lcio::LCCollection* findNextValidCollection( LCCDTimeStamp timeStamp,
170  LCCDTimeStamp& since, LCCDTimeStamp& till,
171  const std::string& tag="" ) ;
172 
173 
198  lcio::LCCollection* findLastValidCollection( LCCDTimeStamp timeStamp,
199  LCCDTimeStamp& since, LCCDTimeStamp& till,
200  const std::string& tag="" ) ;
201 
202 
207  lcio::LCCollection* findCollection( LCCDTimeStamp timeStamp,
208  const std::string& tag="" ) ;
209 
215  void findCollections( ColVec& colVec, const std::string& tag="" ) ;
216 
222  void findCollections(ColVec &colVec, LCCDTimeStamp since, LCCDTimeStamp till, const std::string &tag="") ;
223 
229  void findCollections( ColVec& colVec, LCCDTimeStamp timeStamp ) ;
230 
238  void findAllCollections( ColVec& colVec ) ;
239 
245  void tagFolder( const std::string& tagName, const std::string& description="", std::string usingTagName = "");
246 
247 
252  bool folderBranchContainsTag ( const std::string& tagName ) ;
253 
254 
263  void createDBFile( const std::string& tag="" ) ;
264 
265 
273  void createSimpleFile( LCCDTimeStamp timeStamp, const std::string& tag, bool allLayers=false ) ;
274 
285  void dump2File( ) ;
286 
287 
288  protected:
290  void init() ;
291 
295  lcio::LCCollection* collectionFromCondDBObject( ICondDBObject* object, const std::string& tag ) ;
296 
297 
298  // data members
299  ICondDBMgr* _condDBmgr = nullptr ;
300  ICondDBDataAccess* _condDataAccess = nullptr ;
301  ICondDBFolderMgr* _condFolderMgr = nullptr ;
302  ICondDBTagMgr * _condTagMgr = nullptr ;
303 
304 
305  private:
306 
307  std::string _dbInit{} ;
308  std::string _folder{} ;
309  bool _update{} ;
310  std::string _dbName{} ;
311  };
312 
313 } //end namespace
314 
315 #endif // DBInterface_h
316 
Provides a simple interface to the conditions data base for lccd.
Definition: DBInterface.hh:53
const std::string & dbName()
The db name used for this DB access.
Definition: DBInterface.hh:106
ICondDBDataAccess * condDataAccess()
The db access object - use for direct access to the conditions database.
Definition: DBInterface.hh:89
ICondDBTagMgr * condTagMgr()
The tag manager - use for direct access to the conditions database.
Definition: DBInterface.hh:97
lcio::LCCollection * collectionFromCondDBObject(ICondDBObject *object, const std::string &tag)
Creates an LCColleciton from the data in the ICondDBObject.
Definition: DBInterface.cc:446
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...
Definition: DBInterface.cc:192
void tagFolder(const std::string &tagName, const std::string &description="", std::string usingTagName="")
Tag the current HEAD of the database folder as tagName.
Definition: DBInterface.cc:826
void init()
Initializes the database access.
Definition: DBInterface.cc:73
const std::string & folderName()
The folder used for this DB access.
Definition: DBInterface.hh:102
ICondDBMgr * condDBMgr()
The db manager object - use for direct access to the conditions database.
Definition: DBInterface.hh:85
void createDBFile(const std::string &tag="")
Creates an LCIO file with the all conditions data in the folder for the given tag.
Definition: DBInterface.cc:534
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...
Definition: DBInterface.cc:719
void findAllCollections(ColVec &colVec)
Debug Method: Creates collections for all conditions data in current folder.
Definition: DBInterface.cc:412
lcio::long64 LCCDTimeStamp
The timestamp in LCCD is a 64bit int as defined in LCIO.
Definition: lccd.h:24
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...
Definition: DBInterface.cc:223
void dump2File()
Debug Method: Creates an LCIO file with the all conditions data in the folder.
Definition: DBInterface.cc:627
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 ta...
Definition: DBInterface.cc:848
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 - ret...
Definition: DBInterface.cc:255
void storeCollection(LCCDTimeStamp since, LCCDTimeStamp till, lcio::LCCollection *col, const std::string &description)
Stores the given collection in the database.
Definition: DBInterface.cc:135
virtual ~DBInterface()
D&#39;tor.
Definition: DBInterface.cc:67
ICondDBFolderMgr * condFolderMgr()
The folder manager - use for direct access to the conditions database.
Definition: DBInterface.hh:93
std::vector< lcio::LCCollection * > ColVec
Convenience typedef for vector of LCCollection pointers.
Definition: DBInterface.hh:26
void findCollections(ColVec &colVec, const std::string &tag="")
Creates collections for all conditions data for the given tag and adds them to the colvec...
Definition: DBInterface.cc:288