27#include <TTreePerfStats.h>
77 "configure output files to be more reproducible" };
80 "ROOT630ForwardCompatibility",
false,
81 "When opening a file for CREATE or RECREATE, enable ROOT 6.30 forward compatibility "
82 "(i.e. write a file that is readable with ROOT 6.24). Requires ROOT >= 6.30.06, see "
83 "<https://github.com/root-project/root/issues/14793>." };
150 typedef std::vector<std::pair<std::string, std::string>>
ParamMap;
152 typedef std::map<std::string, TTree*, std::less<>>
Sections;
156 typedef std::map<std::string, ContainerSections, std::less<>>
MergeSections;
197 const std::string&
empty()
const;
226 TTree*
refs()
const {
return c->m_refs; }
233 const std::string&
name()
const {
return c->m_name; }
241 virtual TBranch*
getBranch( std::string_view section, std::string_view n ) = 0;
250 virtual int loadRefs( std::string_view section, std::string_view cnt,
unsigned long entry,
279 size_t removeClient(
const IInterface* client );
281 bool lookupClient(
const IInterface* client )
const;
284 void badWriteError( std::string_view msg )
const;
287 std::pair<const RootRef*, const ContainerSection*> getMergeSection( std::string_view container,
int entry )
const;
290 void enableStatistics( std::string_view section );
292 void saveStatistics( std::string_view statisticsFile );
295 int loadObj( std::string_view section, std::string_view cnt,
unsigned long entry,
DataObject*& pObj );
298 int loadRefs( std::string_view section, std::string_view cnt,
unsigned long entry,
RootObjectRefs& refs );
301 std::pair<int, unsigned long> saveObj( std::string_view section, std::string_view cnt, TClass* cl,
DataObject* pObj,
302 int minBufferSize,
int maxBufferSize,
int approxEventsPerBasket,
303 int split_lvl,
bool fill_missing =
false );
305 std::pair<int, unsigned long> save( std::string_view section, std::string_view cnt, TClass* cl,
void* pObj,
306 int minBufferSize,
int maxBufferSize,
int approxEventsPerBasket,
int split_lvl,
307 bool fill_missing =
false );
312 StatusCode connectWrite( IoType typ )
override;
320 long long int seek(
long long int,
int )
override {
return -1; }
323 TTree* getSection( std::string_view sect,
bool create =
false );
326 TBranch*
getBranch( std::string_view section, std::string_view branch_name ) {
327 return m_tool->getBranch( section, branch_name );
330 TBranch* getBranch( std::string_view section, std::string_view branch_name, TClass* cl,
void* ptr,
int buff_siz,
336 void makeRef( std::string_view name,
long clid,
int tech, std::string_view db, std::string_view cnt,
int entry,
340 int makeLink( std::string_view p );
343 const std::string& getDb(
int which )
const;
346 const std::string&
getCont(
int which )
const {
347 return ( which >= 0 ) && ( size_t( which ) <
m_conts.size() ) ? *(
m_conts.begin() + which ) :
empty();
351 const std::string&
getLink(
int which )
const {
352 return ( which >= 0 ) && ( size_t( which ) <
m_links.size() ) ? *(
m_links.begin() + which ) :
empty();
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
A DataObject is the base class of any identifiable object on any data store.
ABC describing basic data connection.
Implementation of property with value of concrete type.
StringVec cacheBranches
Vector of strings with branches to be cached for input files.
RootConnectionSetup()=default
Standard constructor.
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
void setMessageSvc(MsgStream *m)
Set message service reference.
static int compression()
Access to global compression level.
StringVec vetoBranches
Vector of strings with branches to NOT be cached for input files.
MsgStream & msgSvc() const
Retrieve message service.
Gaudi::Property< bool > produceReproducibleFiles
std::string loadSection
RootCnvSvc Property: Root data cache size.
int learnEntries
RootCnvSvc Property: ROOT cache learn entries.
int cacheSize
RootCnvSvc Property: Root data cache size.
static StatusCode setCompression(std::string_view compression)
Set the global compression level.
std::unique_ptr< MsgStream > m_msgSvc
Reference to message service.
Gaudi::Property< bool > root630ForwardCompatibility
std::vector< std::string > StringVec
Type definition for string maps.
IIncidentSvc * incidentSvc() const
Retrieve incident service.
Sections m_sections
Tree sections in TFile.
LinkSections m_linkSects
Database link sections.
std::map< std::string, TTree *, std::less<> > Sections
Definition of tree sections.
StatusCode read(void *const, size_t) override
Read root byte buffer from input stream.
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
long long int seek(long long int, int) override
Seek on the file described by ioDesc. Arguments as in seek()
StringVec m_links
Map containing internal links names.
const std::string & empty() const
Empty string reference.
const std::string & getLink(int which) const
Access link name from saved index.
std::string m_empty
Buffer for empty string reference.
MsgStream & msgSvc() const
Allow access to printer service.
std::vector< std::string > StringVec
Type definition for string maps.
std::vector< ContainerSection > ContainerSections
Definition of container sections to handle merged files.
RootDataConnection(const IInterface *own, std::string_view nam, std::shared_ptr< RootConnectionSetup > setup)
Standard constructor.
Tool * tool() const
Access tool.
StatusCode saveRefs()
Internal helper to save/update reference tables.
std::vector< RootRef > LinkSections
Link sections definition.
std::unique_ptr< TTreePerfStats > m_statistics
I/O read statistics from TTree.
std::unique_ptr< Tool > m_tool
Clients m_clients
Client list.
bool isConnected() const override
Check if connected to data source.
ParamMap m_params
Parameter map for file parameters.
std::unique_ptr< TFile > m_file
Reference to ROOT file.
TFile * file() const
Direct access to TFile structure.
MergeSections m_mergeSects
Database section map for merged files.
bool isWritable() const
Is the file writable?
std::map< std::string, ContainerSections, std::less<> > MergeSections
Definition of database section to handle merged files.
std::set< const IInterface * > Clients
Client set.
StringVec m_conts
Map containing external container names.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
StatusCode write(const void *, int) override
Write root byte buffer to output stream.
StringVec m_mergeFIDs
Map containing merge FIDs.
StringVec m_dbs
Map containing external database file names (fids)
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
const MergeSections & mergeSections() const
Access merged data section inventory.
const StringVec & mergeFIDs() const
Access merged FIDs.
IIncidentSvc * incidentSvc() const
std::vector< std::pair< std::string, std::string > > ParamMap
Type definition for the parameter map.
TTree * m_refs
Pointer to the reference tree.
const std::string & getCont(int which) const
Access container name from saved index.
The interface implemented by the IncidentSvc service.
Definition of the basic interface.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition of the MsgStream class used to transmit messages.
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
unsigned long code_t
type of StatusCode value
constexpr static const auto FAILURE
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Internal helper class, which described a TBranch section in a ROOT file.
ContainerSection(const ContainerSection &s)
Copy constructor.
ContainerSection(int s, int l)
Initializing constructor.
int length
The length of the section.
ContainerSection & operator=(const ContainerSection &s)
Assignment operator to copy objects.
ContainerSection()
Default constructor.
int start
The start entry of the section.
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject.
Persistent reference object.