ATLAS Offline Software
RootCollection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ROOTCOLLECTION_ROOTCOLLECTION_H
6 #define ROOTCOLLECTION_ROOTCOLLECTION_H
7 
10 
13 
15 #include "CoralBase/MessageStream.h"
16 
17 #include "GaudiKernel/IFileMgr.h"
18 #include "GaudiKernel/SmartIF.h"
19 #include "Gaudi/PluginService.h"
20 
21 #include <string>
22 #include <vector>
23 
24 class TTree;
25 class TFile;
26 class IFileMgr;
27 
28 
29 namespace pool {
30 
31  class ISession;
32 
33  namespace RootCollection {
34 
35  // compressed data size for buffer auto-resize (negative == bytes)
36  const int TTREE_AUTO_FLUSH = -1*1024*1024;
37 
38  const int TBRANCH_DEF_BUFSIZE = 8*1024;
39 
40  // increase TTree size limit to 100GB
41  const unsigned long long TTREE_MAX_SIZE = 100*1024*1024*1024ULL;
42 
43  class Attribute;
44  class AttributeSpecification;
45 
70  class RootCollection : public ICollection {
71 
72  public:
73  typedef Gaudi::PluginService::Factory<ICollection*( const ICollectionDescription*, ICollection::OpenMode, ISession*)> Factory;
74 
110 
111 
114  pool::ISession* );
115 
118 
120  virtual ICollection::OpenMode openMode() const;
121 
123  virtual void open();
124 
126  virtual bool isOpen() const;
127 
129  virtual void commit( bool restartTransaction = false );
130 
132  virtual void close();
133 
135  virtual const ICollectionDescription& description() const;
136 
139 
142 
145 
146  private:
147 
152 
153  void delayedFileOpen( const std::string& method );
155  void setupTree() const;
158 
159  bool fileCatalogRequired()const;
160  std::string retrievePFN()const;
161  std::string retrieveFID();
162  std::string retrieveUniquePFN(const FileCatalog::FileID& fid);
163  std::string retrieveBestPFN(const FileCatalog::FileID& fid)const;
164  void retrieveFileCatalog()const;
165 
166  void cleanup();
167 
168  public:
169 
170  static const unsigned int c_maxLengthOfStrings = 5000;
171  static const char* const poolOptToRootOpt[];
172  static const Io::IoFlags poolOptToFileMgrOpt[];
173  static const char* const c_tokenBranchName;// = "Token";
174  static const char* const c_attributeListLayoutName;// = "Schema";
175 
176  private:
177 
179 
180  std::string m_name;
181  std::string m_fileName;
183  TTree* m_tree;
184  TFile* m_file;
186  bool m_open;
188 
189  std::unique_ptr<pool::IFileCatalog> m_fileCatalog;
190  coral::MessageStream m_poolOut;
191 
194 
195  SmartIF<IFileMgr> m_fileMgr;
196 
197  };
198  }
199 }
200 #endif
201 
202 
203 
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
pool::RootCollection::RootCollection::m_file
TFile * m_file
Definition: RootCollection.h:184
pool::RootCollection::RootCollection::readAttributeListSpecification
void readAttributeListSpecification() const
pool::ICollectionQuery
Definition: ICollectionQuery.h:27
pool::RootCollection::RootCollection::retrieveFileCatalog
void retrieveFileCatalog() const
pool::RootCollection::RootCollection::m_poolOut
coral::MessageStream m_poolOut
Definition: RootCollection.h:190
pool::RootCollection::RootCollection::c_attributeListLayoutName
static const char *const c_attributeListLayoutName
Definition: RootCollection.h:174
pool::RootCollection::RootCollection::~RootCollection
~RootCollection()
Destructor.
pool::RootCollection::RootCollection::dataEditor
virtual ICollectionDataEditor & dataEditor()
Returns an object used to add, update or delete rows of the collection.
pool::RootCollection::RootCollection::m_mode
ICollection::OpenMode m_mode
Definition: RootCollection.h:182
pool::RootCollection::RootCollection::writeAttributeListSpecification
void writeAttributeListSpecification()
pool::RootCollection::RootCollection::schemaEditor
virtual ICollectionSchemaEditor & schemaEditor()
Returns an object used to modify the collection schema.
pool::ICollectionSchemaEditor
Definition: ICollectionSchemaEditor.h:22
pool::RootCollection::RootCollection::delayedFileOpen
void delayedFileOpen(const std::string &method)
pool::RootCollection::RootCollection::openMode
virtual ICollection::OpenMode openMode() const
Return openMode.
pool::RootCollection::TTREE_MAX_SIZE
const unsigned long long TTREE_MAX_SIZE
Definition: RootCollection.h:41
CollectionDescription.h
pool::FileCatalog::FileID
std::string FileID
Definition: IFileCatalog.h:20
pool
pool namespace
Definition: libname.h:15
IFileCatalog.h
pool::RootCollection::RootCollection::cleanup
void cleanup()
pool::RootCollection::RootCollection::m_session
ISession * m_session
Definition: RootCollection.h:185
pool::RootCollection::RootCollection::m_open
bool m_open
Definition: RootCollection.h:186
pool::RootCollection::RootCollection::m_fileCatalog
std::unique_ptr< pool::IFileCatalog > m_fileCatalog
Definition: RootCollection.h:189
pool::RootCollection::RootCollection::m_fileName
std::string m_fileName
Definition: RootCollection.h:181
pool::RootCollection::RootCollection::poolOptToRootOpt
static const char *const poolOptToRootOpt[]
Definition: RootCollection.h:171
pool::RootCollection::TTREE_AUTO_FLUSH
const int TTREE_AUTO_FLUSH
Definition: RootCollection.h:36
pool::ISession
Definition: ISession.h:31
pool::RootCollection::RootCollection::newQuery
virtual ICollectionQuery * newQuery()
Returns an object used to query the collection.
pool::RootCollection::RootCollection::c_tokenBranchName
static const char *const c_tokenBranchName
Definition: RootCollection.h:173
pool::RootCollection::RootCollection::fileCatalogRequired
bool fileCatalogRequired() const
pool::RootCollection::RootCollectionDataEditor
Definition: RootCollectionDataEditor.h:30
pool::RootCollection::RootCollection
Collection (and CollectionProxy) implementation based on ROOT trees.
Definition: RootCollection.h:70
pool::RootCollection::RootCollection::open
virtual void open()
Explicitly re-opens the collection after it has been closed.
pool::RootCollection::RootCollection::retrieveUniquePFN
std::string retrieveUniquePFN(const FileCatalog::FileID &fid)
pool::RootCollection::RootCollection::m_dataEditor
RootCollectionDataEditor * m_dataEditor
Definition: RootCollection.h:193
pool::ICollection::OpenMode
OpenMode
Enumeration of the possible open modes of the collection.
Definition: ICollection.h:27
pool::RootCollection::RootCollection::poolOptToFileMgrOpt
static const Io::IoFlags poolOptToFileMgrOpt[]
Definition: RootCollection.h:172
pool::CollectionDescription
Definition: CollectionDescription.h:29
pool::RootCollection::RootCollection::isOpen
virtual bool isOpen() const
Checks if the collection is open.
pool::RootCollection::RootCollection::m_name
std::string m_name
Definition: RootCollection.h:180
ICollection.h
pool::RootCollection::RootCollection::m_fileMgr
SmartIF< IFileMgr > m_fileMgr
Definition: RootCollection.h:195
Preparation.mode
mode
Definition: Preparation.py:94
pool::RootCollection::TBRANCH_DEF_BUFSIZE
const int TBRANCH_DEF_BUFSIZE
Definition: RootCollection.h:38
pool::RootCollection::RootCollection::retrievePFN
std::string retrievePFN() const
pool::RootCollection::RootCollection::setupTree
void setupTree() const
pool::RootCollection::RootCollectionSchemaEditor
Definition: RootCollectionSchemaEditor.h:33
pool::RootCollection::RootCollection::RootCollection
RootCollection(const RootCollection &)
copying unimplemented in this class.
pool::RootCollection::RootCollection::Factory
Gaudi::PluginService::Factory< ICollection *(const ICollectionDescription *, ICollection::OpenMode, ISession *)> Factory
Definition: RootCollection.h:73
pool::RootCollection::RootCollection::retrieveBestPFN
std::string retrieveBestPFN(const FileCatalog::FileID &fid) const
pool::RootCollection::RootCollection::close
virtual void close()
Explicitly closes the collection.
pool::RootCollection::RootCollection::commit
virtual void commit(bool restartTransaction=false)
Commits the last changes made to the collection.
RootCollectionSchemaEditor.h
pool::RootCollection::RootCollection::m_tree
TTree * m_tree
Definition: RootCollection.h:183
pool::RootCollection::RootCollection::retrieveFID
std::string retrieveFID()
pool::RootCollection::RootCollection::getCollectionTree
TTree * getCollectionTree()
pool::RootCollection::RootCollection::description
virtual const ICollectionDescription & description() const
Returns an object used to describe the collection properties.
pool::RootCollection::RootCollection::operator=
RootCollection & operator=(const RootCollection &)
copying unimplemented in this class.
pool::RootCollection::RootCollection::c_maxLengthOfStrings
static const unsigned int c_maxLengthOfStrings
Definition: RootCollection.h:170
pool::RootCollection::RootCollection::m_readOnly
bool m_readOnly
Definition: RootCollection.h:187
pool::RootCollection::RootCollection::m_schemaEditor
RootCollectionSchemaEditor * m_schemaEditor
Definition: RootCollection.h:192
RootCollectionDataEditor.h
pool::ICollection
Definition: ICollection.h:24
pool::RootCollection::RootCollection::m_description
CollectionDescription m_description
Definition: RootCollection.h:178
pool::RootCollection::RootCollection::RootCollection
RootCollection(const pool::ICollectionDescription *description, pool::ICollection::OpenMode mode, pool::ISession *)
Constructor.
pool::ICollectionDescription
Definition: ICollectionDescription.h:26
pool::ICollectionDataEditor
Definition: ICollectionDataEditor.h:26