| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Gaudi::RootDataConnection Class Reference

Concrete implementation of the IDataConnection interface to access ROOT files. More...

`#include <GaudiRootCnv/RootDataConnection.h>`

Inheritance diagram for Gaudi::RootDataConnection:
[legend]
Collaboration diagram for Gaudi::RootDataConnection:
[legend]

## Classes
class | ContainerSection
| Internal helper class, which described a TBranch section in a ROOT file. More...
class | Tool
| Helper class to facilitate an abstraction layer for reading POOL style files with this package. More...

## Public Types
enum | { ROOT_READ_ERROR = 0x2, ROOT_OPEN_ERROR = 0x4 }
typedef std::vector< std::string > | StringVec
| Type definition for string maps.
typedef std::vector< std::pair < std::string, std::string > > | ParamMap
| Type definition for the parameter map.
typedef std::map< std::string, TTree * > | Sections
| Definition of tree sections.
typedef std::vector < ContainerSection > | ContainerSections
| Definition of container sections to handle merged files.
typedef std::map< std::string, ContainerSections > | MergeSections
| Definition of database section to handle merged files.
typedef std::vector< RootRef > | LinkSections
| Link sections definition.
typedef std::set< const IInterface * > | Clients
| Client set.
Public Types inherited from Gaudi::IDataConnection
enum | IoType { READ =1<<1, UPDATE =1<<2, CREATE =1<<3, RECREATE =(1<<4)+(1<<3) }
| I/O Connection types. More...
enum | IoStatus { BAD_DATA_CONNECTION =4 }
| Status Code on bad file connection. More...

## Public Member Functions
MsgStream & | msgSvc () const
| Allow access to printer service.
Tool * | makeTool ()
| Create file access tool to encapsulate POOL compatibiliy.
| RootDataConnection (const IInterface *own, const std::string &nam, RootConnectionSetup *setup)
| Standard constructor.
virtual | ~RootDataConnection ()
| Standard destructor.
TFile * | file () const
| Direct access to TFile structure.
virtual bool | isConnected () const
| Check if connected to data source.
bool | isWritable () const
| Is the file writable?
Tool * | tool () const
| Access tool.
const MergeSections & | mergeSections () const
| Access merged data section inventory.
const StringVec & | mergeFIDs () const
| Access merged FIDs.
void | addClient (const IInterface *client)
| Add new client to this data source.
size_t | removeClient (const IInterface *client)
| Remove client from this data source.
bool | lookupClient (const IInterface *client) const
| Lookup client for this data source.
void | badWriteError (const std::string &msg) const
| Error handler when bad write statements occur.
std::pair< const RootRef *, const ContainerSection * > | getMergeSection (const std::string &container, int entry) const
| Access link section for single container and entry.
void | enableStatistics (const std::string &section)
| Enable TTreePerStats.
void | saveStatistics (const std::string &statisticsFile)
| Save TTree access statistics if required.
int | loadObj (const std::string &section, const std::string &cnt, unsigned long entry, DataObject *&pObj)
| Load object.
int | loadRefs (const std::string &section, const std::string &cnt, unsigned long entry, RootObjectRefs &refs)
| Load references object.
std::pair< int, unsigned long > | saveObj (const std::string &section, const std::string &cnt, TClass *cl, DataObject *pObj, int buff_siz, int split_lvl, bool fill_missing=false)
| Save object of a given class to section and container.
std::pair< int, unsigned long > | save (const std::string &section, const std::string &cnt, TClass *cl, void *pObj, int buff_siz, int split_lvl, bool fill_missing=false)
| Save object of a given class to section and container.
virtual StatusCode | connectRead ()
| Open data stream in read mode.
virtual StatusCode | connectWrite (IoType typ)
| Open data stream in write mode.
virtual StatusCode | disconnect ()
| Release data stream and release implementation dependent resources.
virtual StatusCode | read (void *const, size_t)
| Read root byte buffer from input stream.
virtual StatusCode | write (const void *, int)
| Write root byte buffer to output stream.
virtual long long int | seek (long long int, int)
| Seek on the file described by ioDesc. Arguments as in ::seek()
TTree * | getSection (const std::string &sect, bool create=false)
| Access TTree section from section name. The section is created if required.
TBranch * | getBranch (const std::string &section, const std::string &branch_name)
| Access data branch by name: Get existing branch in read only mode.
TBranch * | getBranch (const std::string &section, const std::string &branch_name, TClass *cl, void *ptr, int buff_siz, int split_lvl)
| Access data branch by name: Get existing branch in write mode.
void | makeRef (IRegistry *pA, RootRef &ref)
| Create reference object from registry entry.
void | makeRef (const std::string &name, long clid, int tech, const std::string &db, const std::string &cnt, int entry, RootRef &ref)
| Create reference object from values.
int | makeLink (const std::string &p)
| Convert path string to path index.
const std::string & | getDb (int which) const
| Access database/file name from saved index.
const std::string & | getCont (int which) const
| Access container name from saved index.
const std::string & | getLink (int which) const
| Access link name from saved index.
Public Member Functions inherited from Gaudi::IDataConnection
| IDataConnection (const IInterface *own, const std::string &nam)
| Standard constructor.
virtual | ~IDataConnection ()
| Standard destructor.
const std::string & | name () const
| Connection name.
void | setFID (const std::string &fid)
| Set file ID.
const std::string & | fid () const
| Access file id.
const std::string & | pfn () const
| Access physical file name.
void | setPFN (const std::string &fn)
| Set physical file name.
void | ageFile ()
| Increase age of I/O source.
void | resetAge ()
| Reset age.
int | age () const
| Access age counter.
const IInterface * | owner () const
| Owner instance.

## Public Attributes
class Gaudi::RootDataConnection::Tool * | m_tool

## Protected Member Functions
const std::string & | empty () const
| Empty string reference.
StatusCode | saveRefs ()
| Internal helper to save/update reference tables.

## Protected Attributes
RootConnectionSetup * | m_setup
| Reference to the setup structure.
TTreePerfStats * | m_statistics
| I/O read statistics from TTree.
TFile * | m_file
| Reference to ROOT file.
TTree * | m_refs
| Pointer to the reference tree.
Sections | m_sections
| Tree sections in TFile.
StringVec | m_dbs
| Map containing external database file names (fids)
StringVec | m_conts
| Map containing external container names.
StringVec | m_links
| Map containing internal links names.
StringVec | m_mergeFIDs
| Map containing merge FIDs.
ParamMap | m_params
| Parameter map for file parameters.
MergeSections | m_mergeSects
| Database section map for merged files.
LinkSections | m_linkSects
| Database link sections.
Clients | m_clients
| Client list.
std::string | m_empty
| Buffer for empty string reference.
Protected Attributes inherited from Gaudi::IDataConnection
std::string | m_name
| Connection name/identifier.
std::string | m_fid
| File ID of the connection.
std::string | m_pfn
| Physical file name of the connection.
int | m_age
| Age counter.
const IInterface * | m_owner
| Owner pointer.

## Friends
class | Tool

## Detailed Description

Concrete implementation of the IDataConnection interface to access ROOT files.

Author
  M.Frank

Version
  1.0

Date
  20/12/2009

Definition at line 99 of file RootDataConnection.h.

## Member Typedef Documentation

typedef std::set<const IInterface*> Gaudi::RootDataConnection::Clients

Client set.

Definition at line 150 of file RootDataConnection.h.

typedef std::vector<ContainerSection> Gaudi::RootDataConnection::ContainerSections

Definition of container sections to handle merged files.

Definition at line 144 of file RootDataConnection.h.

typedef std::vector<RootRef> Gaudi::RootDataConnection::LinkSections

Link sections definition.

Definition at line 148 of file RootDataConnection.h.

typedef std::map<std::string,ContainerSections> Gaudi::RootDataConnection::MergeSections

Definition of database section to handle merged files.

Definition at line 146 of file RootDataConnection.h.

typedef std::vector<std::pair<std::string,std::string> > Gaudi::RootDataConnection::ParamMap

Type definition for the parameter map.

Definition at line 140 of file RootDataConnection.h.

typedef std::map<std::string,TTree*> Gaudi::RootDataConnection::Sections

Definition of tree sections.

Definition at line 142 of file RootDataConnection.h.

typedef std::vector<std::string> Gaudi::RootDataConnection::StringVec

Type definition for string maps.

Definition at line 138 of file RootDataConnection.h.

## Member Enumeration Documentation

anonymous enum

Enumerator:

  ROOT_READ_ERROR |
  ROOT_OPEN_ERROR |

Definition at line 102 of file RootDataConnection.h.

{ ROOT_READ_ERROR = 0x2,
ROOT_OPEN_ERROR = 0x4
};

## Constructor & Destructor Documentation

RootDataConnection::RootDataConnection | ( | const IInterface * | own,
|  | const std::string & | nam,
|  | RootConnectionSetup * | setup
| ) |  |

Standard constructor.

Definition at line 160 of file RootDataConnection.cpp.

: IDataConnection(owner,fname), m_setup(setup), m_statistics(0), m_tool(0)
{ // 01234567890123456789012345678901234567890
// Check if FID: A82A3BD8-7ECB-DC11-8DC0-000423D950B0
if ( fname.length() == 36 && fname[8]=='-'&&fname[13]=='-'&&fname[18]=='-'&&fname[23]=='-' ) {
m_name = "FID:"+fname;
}
m_setup->addRef();
m_age = 0;
m_file = 0;
m_refs = 0;
addClient(owner);
}

RootDataConnection::~RootDataConnection | ( |  | ) |
| virtual

Standard destructor.

Definition at line 175 of file RootDataConnection.cpp.

{
m_setup->release();
releasePtr(m_tool);
}

## Member Function Documentation

void RootDataConnection::addClient | ( | const IInterface * | client | ) |

Add new client to this data source.

Definition at line 181 of file RootDataConnection.cpp.

{
m_clients.insert(client);
}

void RootDataConnection::badWriteError | ( | const std::string & | msg | ) | const

Error handler when bad write statements occur.

Definition at line 199 of file RootDataConnection.cpp.

{
msgSvc() << MSG::ERROR << "File:" << fid() << "Failed action:" << msg << endmsg;
}

StatusCode RootDataConnection::connectRead | ( |  | ) |
| virtual

Open data stream in read mode.

Connect the file in READ mode.

Implements Gaudi::IDataConnection.

Definition at line 241 of file RootDataConnection.cpp.

{
m_file = TFile::Open(m_pfn.c_str());
if ( m_file && !m_file->IsZombie() ) {
StatusCode sc = StatusCode::FAILURE;
msgSvc() << MSG::DEBUG << "Opened file " << m_pfn << " in mode READ. [" << m_fid << "]" << endmsg << MSG::DEBUG;
if ( msgSvc().isActive() ) m_file->ls();
msgSvc() << MSG::VERBOSE;
if ( msgSvc().isActive() ) m_file->Print();
if ( makeTool() ) {
sc = m_tool->readRefs();
sc.ignore();
if ( sc.getCode() == ROOT_READ_ERROR ) {
IIncidentSvc* inc = m_setup->incidentSvc();
if ( inc ) {
inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
}
}
}
if ( sc.isSuccess() ) {
bool need_fid = m_fid == m_pfn;
string fid = m_fid;
m_mergeFIDs.clear();
for(size_t i=0, n=m_params.size(); i<n; ++i) {
if ( m_params[i].first == "FID" ) {
m_mergeFIDs.push_back(m_params[i].second);
if ( m_params[i].second != m_fid ) {
msgSvc() << MSG::DEBUG << "Check FID param:" << m_params[i].second << endmsg;
//if ( m_fid == m_pfn ) {
m_fid = m_params[i].second;
//}
}
}
}
if ( !need_fid && fid != m_fid ) {
msgSvc() << MSG::ERROR << "FID mismatch:" << fid << "(Catalog) != " << m_fid << "(file)" << endmsg
<< "for PFN:" << m_pfn << endmsg;
return StatusCode::FAILURE;
}
msgSvc() << MSG::DEBUG << "Using FID " << m_fid << " from params table...." << endmsg
<< "for PFN:" << m_pfn << endmsg;
return sc;
}
}
else if ( m_file ) {
deletePtr(m_file);
}
return StatusCode::FAILURE;
}

StatusCode RootDataConnection::connectWrite | ( | IoType | typ | ) |
| virtual

Open data stream in write mode.

Implements Gaudi::IDataConnection.

Definition at line 291 of file RootDataConnection.cpp.

{
int compress = RootConnectionSetup::compression();
msgSvc() << MSG::DEBUG;
switch(typ) {
case CREATE:
resetAge();
m_file = TFile::Open(m_pfn.c_str(),"CREATE","Root event data",compress);
m_refs = new TTree("Refs","Root reference data");
msgSvc() << "Opened file " << m_pfn << " in mode CREATE. [" << m_fid << "]" << endmsg;
m_params.push_back(make_pair("PFN",m_pfn));
if ( m_fid != m_pfn ) {
m_params.push_back(make_pair("FID",m_fid));
}
makeTool();
break;
case RECREATE:
resetAge();
m_file = TFile::Open(m_pfn.c_str(),"RECREATE","Root event data",compress);
msgSvc() << "Opened file " << m_pfn << " in mode RECREATE. [" << m_fid << "]" << endmsg;
m_refs = new TTree("Refs","Root reference data");
m_params.push_back(make_pair("PFN",m_pfn));
if ( m_fid != m_pfn ) {
m_params.push_back(make_pair("FID",m_fid));
}
makeTool();
break;
case UPDATE:
resetAge();
m_file = TFile::Open(m_pfn.c_str(),"UPDATE","Root event data",compress);
msgSvc() << "Opened file " << m_pfn << " in mode UPDATE. [" << m_fid << "]" << endmsg;
if ( m_file && !m_file->IsZombie() ) {
if ( makeTool() ) {
StatusCode sc = m_tool->readRefs();
sc.ignore();
if ( sc.getCode() == ROOT_READ_ERROR ) {
IIncidentSvc* inc = m_setup->incidentSvc();
if ( inc ) {
inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
}
}
return sc;
}
TDirectory::TContext ctxt(m_file);
m_refs = new TTree("Refs","Root reference data");
makeTool();
return StatusCode::SUCCESS;
}
break;
default:
m_refs = 0;
m_file = 0;
return StatusCode::FAILURE;
}
return 0==m_file ? StatusCode::FAILURE : StatusCode::SUCCESS;
}

StatusCode RootDataConnection::disconnect | ( |  | ) |
| virtual

Release data stream and release implementation dependent resources.

Implements Gaudi::IDataConnection.

Definition at line 348 of file RootDataConnection.cpp.

{
if ( m_file ) {
if ( !m_file->IsZombie() ) {
if ( m_file->IsWritable() ) {
msgSvc() << MSG::DEBUG;
TDirectory::TContext ctxt(m_file);
if ( m_refs ) {
if ( !m_tool->saveRefs().isSuccess() ) badWriteError("Saving References");
if ( m_refs->Write() < 0 ) badWriteError("Write Reference branch");
}
for(Sections::iterator i=m_sections.begin(); i!= m_sections.end();++i) {
if ( (*i).second ) {
if ( (*i).second->Write() < 0 ) badWriteError("Write section:"+(*i).first);
msgSvc() << "Disconnect section " << (*i).first << " " << (*i).second->GetName() << endmsg;
}
}
m_sections.clear();
}
msgSvc() << MSG::DEBUG;
if ( msgSvc().isActive() ) m_file->ls();
msgSvc() << MSG::VERBOSE;
if ( msgSvc().isActive() ) m_file->Print();
m_file->Close();
}
msgSvc() << MSG::DEBUG << "Disconnected file " << m_pfn << " " << m_file->GetName() << endmsg;
deletePtr(m_file);
releasePtr(m_tool);
}
return StatusCode::SUCCESS;
}

CSTR RootDataConnection::empty | ( |  | ) | const
| protected

Empty string reference.

Definition at line 487 of file RootDataConnection.cpp.

{
return s_empty;
}

void RootDataConnection::enableStatistics | ( | const std::string & | section | ) |

Enable TTreePerStats.

Definition at line 214 of file RootDataConnection.cpp.

{
if ( 0 == m_statistics ) {
TTree* t=getSection(section,false);
if ( t ) {
m_statistics = new TTreePerfStats((section+"_ioperf").c_str(),t);
return;
}
msgSvc() << MSG::WARNING << "Failed to enable perfstats for tree:" << section << endmsg;
return;
}
msgSvc() << MSG::INFO << "Perfstats are ALREADY ENABLED." << endmsg;
}

TFile* Gaudi::RootDataConnection::file | ( |  | ) | const
| inline

Direct access to TFile structure.

Definition at line 255 of file RootDataConnection.h.

{ return m_file; }

TBranch* Gaudi::RootDataConnection::getBranch | ( | const std::string & | section,
|  | const std::string & | branch_name
| ) |  |
| inline

Access data branch by name: Get existing branch in read only mode.

Definition at line 315 of file RootDataConnection.h.

{ return m_tool->getBranch(section,branch_name); }

TBranch* Gaudi::RootDataConnection::getBranch | ( | const std::string & | section,
|  | const std::string & | branch_name,
|  | TClass * | cl,
|  | void * | ptr,
|  | int | buff_siz,
|  | int | split_lvl
| ) |  |

Access data branch by name: Get existing branch in write mode.

const std::string& Gaudi::RootDataConnection::getCont | ( | int | which | ) | const
| inline

Access container name from saved index.

Definition at line 332 of file RootDataConnection.h.

{ return (which>=0)&&(size_t(which)<m_conts.size()) ? *(m_conts.begin()+which) : empty(); }

CSTR RootDataConnection::getDb | ( | int | which | ) | const

Access database/file name from saved index.

Definition at line 478 of file RootDataConnection.cpp.

{
if ( (which>=0) && (size_t(which)<m_dbs.size()) ) {
if ( *(m_dbs.begin()+which) == s_local ) return m_fid;
return *(m_dbs.begin()+which);
}
return s_empty;
}

const std::string& Gaudi::RootDataConnection::getLink | ( | int | which | ) | const
| inline

Access link name from saved index.

Definition at line 336 of file RootDataConnection.h.

{ return (which>=0)&&(size_t(which)<m_links.size()) ? *(m_links.begin()+which) : empty(); }

pair< const RootRef *, const RootDataConnection::ContainerSection * > RootDataConnection::getMergeSection | ( | const std::string & | container,
|  | int | entry
| ) |  | const

Access link section for single container and entry.

Definition at line 602 of file RootDataConnection.cpp.

{
//size_t idx = cont.find('/',1);
//string container = cont[0]=='/' ? cont.substr(1,idx==string::npos?idx:idx-1) : cont;
MergeSections::const_iterator i=m_mergeSects.find(container);
if ( i != m_mergeSects.end() ) {
size_t cnt = 0;
const ContainerSections& s = (*i).second;
for(ContainerSections::const_iterator j=s.begin(); j != s.end(); ++j,++cnt) {
const ContainerSection& c = *j;
if ( entry >= c.start && entry < (c.start+c.length) ) {
if ( m_linkSects.size() > cnt ) {
if ( msgSvc().isActive() ) {
msgSvc() << MSG::VERBOSE << "MergeSection for:" << container
<< " [" << entry << "]" << endmsg
<< "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
}
return make_pair(&(m_linkSects[cnt]), &c);
}
}
}
}
msgSvc() << MSG::DEBUG << "Return INVALID MergeSection for:" << container
<< " [" << entry << "]" << endmsg
<< "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
return make_pair((const RootRef*)0,(const ContainerSection*)0);
}

TTree * RootDataConnection::getSection | ( | const std::string & | sect,
|  | bool | create = `false`
| ) |  |

Access TTree section from section name. The section is created if required.

Definition at line 380 of file RootDataConnection.cpp.

{
TTree* t = m_sections[section];
if ( !t ) {
t = (TTree*)m_file->Get(section.c_str());
if ( !t && create ) {
TDirectory::TContext ctxt(m_file);
t = new TTree(section.c_str(),"Root data for Gaudi");
}
if ( t ) {
int cacheSize = m_setup->cacheSize;
if ( create ) {
//t->SetAutoFlush(100);
}
if ( section == m_setup->loadSection && cacheSize>-2 ) {
MsgStream& msg = msgSvc();
int learnEntries = m_setup->learnEntries;
t->SetCacheSize(cacheSize);
t->SetCacheLearnEntries(learnEntries);
msg << MSG::DEBUG;
if ( create ) {
msg << "Tree:" << section << "Setting up tree cache:" << cacheSize << endmsg;
}
else {
const StringVec& vB = m_setup->vetoBranches;
const StringVec& cB = m_setup->cacheBranches;
msg << "Tree:" << section << " Setting up tree cache:" << cacheSize << " Add all branches." << endmsg;
msg << "Tree:" << section << " Learn for " << learnEntries << " entries." << endmsg;
if ( cB.size()==0 && vB.size()== 0 ) {
msg << "Adding (default) all branches to tree cache." << endmsg;
t->AddBranchToCache("*",kTRUE);
}
if ( cB.size()==1 && cB[0]=="*" ) {
msg << "Adding all branches to tree cache according to option \"CacheBranches\"." << endmsg;
t->AddBranchToCache("*",kTRUE);
}
else {
StringVec::const_iterator i;
for(TIter it(t->GetListOfBranches()); it.Next(); ) {
const char* n = ((TNamed*)(*it))->GetName();
bool add = false, veto = false;
for(i=cB.begin(); i != cB.end();++i) {
if ( !match_wild(n,(*i).c_str()) ) continue;
add = true;
break;
}
for(i=vB.begin(); !add && i!=vB.end();++i) {
if ( !match_wild(n,(*i).c_str()) ) continue;
veto = true;
break;
}
if ( add && !veto ) {
msg << "Add " << n << " to branch cache." << endmsg;
t->AddBranchToCache(n,kTRUE);
}
else {
msg << "Do not cache branch " << n << endmsg;
}
}
}
}
}
m_sections[section] = t;
}
}
return t;
}

virtual bool Gaudi::RootDataConnection::isConnected | ( |  | ) | const
| inline virtual

Check if connected to data source.

Implements Gaudi::IDataConnection.

Definition at line 257 of file RootDataConnection.h.

{ return m_file != 0; }

bool Gaudi::RootDataConnection::isWritable | ( |  | ) | const
| inline

Is the file writable?

Definition at line 259 of file RootDataConnection.h.

{ return m_file != 0 && m_file->IsWritable(); }

int RootDataConnection::loadObj | ( | const std::string & | section,
|  | const std::string & | cnt,
|  | unsigned long | entry,
|  | DataObject *& | pObj
| ) |  |

Load object.

Definition at line 529 of file RootDataConnection.cpp.

{
TBranch* b = getBranch(section,cnt);
if ( b ) {
TClass* cl = gROOT->GetClass(b->GetClassName(),kTRUE);
if ( cl ) {
int nb = -1;
pObj = (DataObject*)cl->New();
{
DataObjectPush push(pObj);
b->SetAddress(&pObj);
if ( section == m_setup->loadSection ) {
TTree* t = b->GetTree();
if ( Long64_t(entry) != t->GetReadEntry() ) {
t->LoadTree(Long64_t(entry));
}
}
nb = b->GetEntry(entry);
msgSvc() << MSG::VERBOSE;
if ( msgSvc().isActive() ) {
msgSvc() << "Load [" << entry << "] --> " << section
<< ":" << cnt << " " << nb << " bytes."
<< endmsg;
}
if ( nb < 0 ) { // This is definitely an error...ROOT says if reads fail, -1 is issued.
IIncidentSvc* inc = m_setup->incidentSvc();
if ( inc ) {
inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
}
}
else if ( nb == 0 && pObj->clID() == CLID_DataObject) {
TFile* f = b->GetFile();
int vsn = f->GetVersion();
if ( vsn < 52400 ) {
// For Gaudi v21r5 (ROOT 5.24.00b) DataObject::m_version was not written!
// Still this call be well be successful.
nb = 1;
}
else if ( vsn>1000000 && (vsn%1000000)<52400 ) {
// dto. Some POOL files have for unknown reasons a version
// not according to ROOT standards. Hack this explicitly.
nb = 1;
}
}
if ( nb < 0 ) {
delete pObj;
pObj = 0;
}
}
return nb;
}
}
return -1;
}

int RootDataConnection::loadRefs | ( | const std::string & | section,
|  | const std::string & | cnt,
|  | unsigned long | entry,
|  | RootObjectRefs & | refs
| ) |  |

Load references object.

Definition at line 584 of file RootDataConnection.cpp.

{
int nbytes = m_tool->loadRefs(section,cnt,entry,refs);
if ( nbytes < 0 ) {
// This is definitely an error:
// -- Either branch not preesent at all or
// -- ROOT I/O error, which issues -1
IIncidentSvc* inc = m_setup->incidentSvc();
if ( inc ) {
inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
}
}
return nbytes;
}

bool RootDataConnection::lookupClient | ( | const IInterface * | client | ) | const

Lookup client for this data source.

Definition at line 193 of file RootDataConnection.cpp.

{
Clients::const_iterator i=m_clients.find(client);
return i != m_clients.end();
}

int RootDataConnection::makeLink | ( | const std::string & | p | ) |

Convert path string to path index.

Definition at line 467 of file RootDataConnection.cpp.

{
int cnt = 0;
StringVec::iterator ip;
for(ip=m_links.begin();ip!=m_links.end();++ip,++cnt) {
if( (*ip) == p ) return cnt;
}
m_links.push_back(p);
return m_links.size()-1;
}

void RootDataConnection::makeRef | ( | IRegistry * | pA,
|  | RootRef & | ref
| ) |  |

Create reference object from registry entry.

Definition at line 630 of file RootDataConnection.cpp.

{
IOpaqueAddress* pA = pR->address();
makeRef(pR->name(),pA->clID(),pA->svcType(),pA->par()[0],pA->par()[1],-1,ref);
}

void Gaudi::RootDataConnection::makeRef | ( | const std::string & | name,
|  | long | clid,
|  | int | tech,
|  | const std::string & | db,
|  | const std::string & | cnt,
|  | int | entry,
|  | RootRef & | ref
| ) |  |

Create reference object from values.

RootDataConnection::Tool * RootDataConnection::makeTool | ( |  | ) |

Create file access tool to encapsulate POOL compatibiliy.

Definition at line 228 of file RootDataConnection.cpp.

{
releasePtr(m_tool);
if ( !m_refs ) m_refs = (TTree*)m_file->Get("Refs");
if ( m_refs )
m_tool = new RootTool(this);
#ifdef __POOL_COMPATIBILITY
else if ( m_file->Get("##Links") != 0 )
m_tool = new PoolTool(this);
#endif
return m_tool;
}

const StringVec& Gaudi::RootDataConnection::mergeFIDs | ( |  | ) | const
| inline

Access merged FIDs.

Definition at line 265 of file RootDataConnection.h.

{ return m_mergeFIDs; }

const MergeSections& Gaudi::RootDataConnection::mergeSections | ( |  | ) | const
| inline

Access merged data section inventory.

Definition at line 263 of file RootDataConnection.h.

{ return m_mergeSects; }

MsgStream& Gaudi::RootDataConnection::msgSvc | ( |  | ) | const
| inline

Allow access to printer service.

Definition at line 153 of file RootDataConnection.h.

{ return m_setup->msgSvc(); }

virtual StatusCode Gaudi::RootDataConnection::read | ( | void * | const,
|  | size_t |
| ) |  |
| inline virtual

Read root byte buffer from input stream.

Implements Gaudi::IDataConnection.

Definition at line 305 of file RootDataConnection.h.

{ return StatusCode::FAILURE; }

size_t RootDataConnection::removeClient | ( | const IInterface * | client | ) |

Remove client from this data source.

Definition at line 186 of file RootDataConnection.cpp.

{
Clients::iterator i=m_clients.find(client);
if ( i != m_clients.end() ) m_clients.erase(i);
return m_clients.size();
}

pair< int, unsigned long > RootDataConnection::save | ( | const std::string & | section,
|  | const std::string & | cnt,
|  | TClass * | cl,
|  | void * | pObj,
|  | int | buff_siz,
|  | int | split_lvl,
|  | bool | fill_missing = `false`
| ) |  |

Save object of a given class to section and container.

Definition at line 500 of file RootDataConnection.cpp.

{
split_lvl = 0;
TBranch* b = getBranch(section, cnt, cl, (void*)(pObj ? &pObj : 0),buff_siz,split_lvl);
if ( b ) {
Long64_t evt = b->GetEntries();
//msgSvc() << MSG::DEBUG << cnt.c_str() << " Obj:" << (void*)pObj
// << " Split:" << split_lvl << " Buffer size:" << buff_siz << endl;
if ( fill_missing ) {
Long64_t num, nevt = b->GetTree()->GetEntries();
if ( nevt > evt ) {
b->SetAddress(0);
num = nevt - evt;
while( num > 0 ) { b->Fill(); --num; }
msgSvc() << MSG::DEBUG << "Added " << long(nevt-evt)
<< " / Tree: " << nevt << " / Branch: " << b->GetEntries()+1
<< " NULL entries to:" << cnt << endmsg;
evt = b->GetEntries();
}
}
b->SetAddress(&pObj);
return make_pair(b->Fill(),(unsigned long)evt);
}
else if ( 0 != pObj ) {
msgSvc() << MSG::ERROR << "Failed to access branch " << m_name << "/" << cnt << endmsg;
}
return make_pair(-1,~0);
}

pair< int, unsigned long > RootDataConnection::saveObj | ( | const std::string & | section,
|  | const std::string & | cnt,
|  | TClass * | cl,
|  | DataObject * | pObj,
|  | int | buff_siz,
|  | int | split_lvl,
|  | bool | fill_missing = `false`
| ) |  |

Save object of a given class to section and container.

Definition at line 493 of file RootDataConnection.cpp.

{
DataObjectPush push(pObj);
return save(section,cnt,cl,pObj,buff_siz,split_lvl,fill);
}

StatusCode Gaudi::RootDataConnection::saveRefs | ( |  | ) |
| protected

Internal helper to save/update reference tables.

void RootDataConnection::saveStatistics | ( | const std::string & | statisticsFile | ) |

Save TTree access statistics if required.

Definition at line 204 of file RootDataConnection.cpp.

{
if ( m_statistics ) {
m_statistics->Print();
if ( !statisticsFile.empty() )
m_statistics->SaveAs(statisticsFile.c_str());
deletePtr(m_statistics);
}
}

virtual long long int Gaudi::RootDataConnection::seek | ( | long long int | ,
|  | int |
| ) |  |
| inline virtual

Seek on the file described by ioDesc. Arguments as in ::seek()

Implements Gaudi::IDataConnection.

Definition at line 309 of file RootDataConnection.h.

{ return -1; }

Tool* Gaudi::RootDataConnection::tool | ( |  | ) | const
| inline

Access tool.

Definition at line 261 of file RootDataConnection.h.

{ return m_tool; }

virtual StatusCode Gaudi::RootDataConnection::write | ( | const void * | ,
|  | int |
| ) |  |
| inline virtual

Write root byte buffer to output stream.

Implements Gaudi::IDataConnection.

Definition at line 307 of file RootDataConnection.h.

{ return StatusCode::FAILURE; }

## Friends And Related Function Documentation

friend class Tool
| friend

Definition at line 242 of file RootDataConnection.h.

## Member Data Documentation

Clients Gaudi::RootDataConnection::m_clients
| protected

Client list.

Definition at line 182 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_conts
| protected

Map containing external container names.

Definition at line 170 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_dbs
| protected

Map containing external database file names (fids)

Definition at line 168 of file RootDataConnection.h.

std::string Gaudi::RootDataConnection::m_empty
| protected

Buffer for empty string reference.

Definition at line 184 of file RootDataConnection.h.

TFile* Gaudi::RootDataConnection::m_file
| protected

Reference to ROOT file.

Definition at line 162 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_links
| protected

Map containing internal links names.

Definition at line 172 of file RootDataConnection.h.

LinkSections Gaudi::RootDataConnection::m_linkSects
| protected

Database link sections.

Definition at line 180 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_mergeFIDs
| protected

Map containing merge FIDs.

Definition at line 174 of file RootDataConnection.h.

MergeSections Gaudi::RootDataConnection::m_mergeSects
| protected

Database section map for merged files.

Definition at line 178 of file RootDataConnection.h.

ParamMap Gaudi::RootDataConnection::m_params
| protected

Parameter map for file parameters.

Definition at line 176 of file RootDataConnection.h.

TTree* Gaudi::RootDataConnection::m_refs
| protected

Pointer to the reference tree.

Definition at line 164 of file RootDataConnection.h.

Sections Gaudi::RootDataConnection::m_sections
| protected

Tree sections in TFile.

Definition at line 166 of file RootDataConnection.h.

RootConnectionSetup* Gaudi::RootDataConnection::m_setup
| protected

Reference to the setup structure.

Definition at line 158 of file RootDataConnection.h.

TTreePerfStats* Gaudi::RootDataConnection::m_statistics
| protected

I/O read statistics from TTree.

Definition at line 160 of file RootDataConnection.h.

class Gaudi::RootDataConnection::Tool * Gaudi::RootDataConnection::m_tool

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/RootCnv/RootCnv/RootDataConnection.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/RootCnv/src/RootDataConnection.cpp