LCCD  1.3.1
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 
65  DBInterface( const std::string& folder, bool update=false ) ;
66 
74  DBInterface( const std::string& dbInit, const std::string& folder, bool update=false) ;
75 
77  virtual ~DBInterface() ;
78 
81  ICondDBMgr* condDBMgr() { return _condDBmgr ; }
82 
85  ICondDBDataAccess* condDataAccess() { return _condDataAccess ; }
86 
89  ICondDBFolderMgr* condFolderMgr() { return _condFolderMgr ; }
90 
93  ICondDBTagMgr * condTagMgr() { return _condTagMgr ; }
94 
95 
98  const std::string& folderName() { return _folder ; }
99 
102  const std::string& dbName() { return _dbName ; }
103 
104 
107  void storeCollection( LCCDTimeStamp since, LCCDTimeStamp till,
108  lcio::LCCollection* col,
109  const std::string& description ) ;
110 
111 
135  lcio::LCCollection* findCollection( LCCDTimeStamp timeStamp,
136  LCCDTimeStamp& since, LCCDTimeStamp& till,
137  const std::string& tag="" ) ;
138 
139 
140 
165  lcio::LCCollection* findNextValidCollection( LCCDTimeStamp timeStamp,
166  LCCDTimeStamp& since, LCCDTimeStamp& till,
167  const std::string& tag="" ) ;
168 
169 
194  lcio::LCCollection* findLastValidCollection( LCCDTimeStamp timeStamp,
195  LCCDTimeStamp& since, LCCDTimeStamp& till,
196  const std::string& tag="" ) ;
197 
198 
203  lcio::LCCollection* findCollection( LCCDTimeStamp timeStamp,
204  const std::string& tag="" ) ;
205 
211  void findCollections( ColVec& colVec, const std::string& tag="" ) ;
212 
218  void findCollections(ColVec &colVec, LCCDTimeStamp since, LCCDTimeStamp till, const std::string &tag="") ;
219 
225  void findCollections( ColVec& colVec, LCCDTimeStamp timeStamp ) ;
226 
234  void findAllCollections( ColVec& colVec ) ;
235 
241  void tagFolder( const std::string& tagName, const std::string& description="", std::string usingTagName = "");
242 
243 
248  bool folderBranchContainsTag ( const std::string& tagName ) ;
249 
250 
259  void createDBFile( const std::string& tag="" ) ;
260 
261 
269  void createSimpleFile( LCCDTimeStamp timeStamp, const std::string& tag, bool allLayers=false ) ;
270 
281  void dump2File( ) ;
282 
283 
284  protected:
286  void init() ;
287 
291  lcio::LCCollection* collectionFromCondDBObject( ICondDBObject* object, const std::string& tag ) ;
292 
293 
294  // data members
295  ICondDBMgr* _condDBmgr ;
296  ICondDBDataAccess* _condDataAccess ;
297  ICondDBFolderMgr* _condFolderMgr ;
298  ICondDBTagMgr * _condTagMgr ;
299 
300 
301  private:
302 
303  std::string _dbInit ;
304  std::string _folder ;
305  bool _update ;
306  std::string _dbName ;
307  };
308 
309 } //end namespace
310 
311 #endif // DBInterface_h
312 
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:102
ICondDBDataAccess * condDataAccess()
The db access object - use for direct access to the conditions database.
Definition: DBInterface.hh:85
ICondDBTagMgr * condTagMgr()
The tag manager - use for direct access to the conditions database.
Definition: DBInterface.hh:93
lcio::LCCollection * collectionFromCondDBObject(ICondDBObject *object, const std::string &tag)
Creates an LCColleciton from the data in the ICondDBObject.
Definition: DBInterface.cc:447
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:193
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:828
void init()
Initializes the database access.
Definition: DBInterface.cc:73
const std::string & folderName()
The folder used for this DB access.
Definition: DBInterface.hh:98
ICondDBMgr * condDBMgr()
The db manager object - use for direct access to the conditions database.
Definition: DBInterface.hh:81
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:536
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:721
void findAllCollections(ColVec &colVec)
Debug Method: Creates collections for all conditions data in current folder.
Definition: DBInterface.cc:413
DBInterface(const std::string &folder, bool update=false)
Default c'tor, uses lccd::getDBInitString() to determine the db initialization, i.e.
Definition: DBInterface.cc:49
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:224
void dump2File()
Debug Method: Creates an LCIO file with the all conditions data in the folder.
Definition: DBInterface.cc:629
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:850
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:256
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'tor.
Definition: DBInterface.cc:67
ICondDBFolderMgr * condFolderMgr()
The folder manager - use for direct access to the conditions database.
Definition: DBInterface.hh:89
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:289