All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Gaudi::RootDataConnection Class Reference

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

#include <GaudiRootCnv/RootDataConnection.h>

Inheritance diagram for Gaudi::RootDataConnection:
Collaboration diagram for Gaudi::RootDataConnection:

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 }
 
enum  { ROOT_READ_ERROR = 0x2, ROOT_OPEN_ERROR = 0x4 }
 
typedef std::vector< std::string > StringVec
 Type definition for string maps. More...
 
typedef std::vector< std::pair< std::string, std::string > > ParamMap
 Type definition for the parameter map. More...
 
typedef std::map< std::string, TTree * > Sections
 Definition of tree sections. More...
 
typedef std::vector< ContainerSectionContainerSections
 Definition of container sections to handle merged files. More...
 
typedef std::map< std::string, ContainerSectionsMergeSections
 Definition of database section to handle merged files. More...
 
typedef std::vector< RootRefLinkSections
 Link sections definition. More...
 
typedef std::set< const IInterface * > Clients
 Client set. More...
 
typedef std::vector< std::string > StringVec
 Type definition for string maps. More...
 
typedef std::vector< std::pair< std::string, std::string > > ParamMap
 Type definition for the parameter map. More...
 
typedef std::map< std::string, TTree * > Sections
 Definition of tree sections. More...
 
typedef std::vector< ContainerSectionContainerSections
 Definition of container sections to handle merged files. More...
 
typedef std::map< std::string, ContainerSectionsMergeSections
 Definition of database section to handle merged files. More...
 
typedef std::vector< RootRefLinkSections
 Link sections definition. More...
 
typedef std::set< const IInterface * > Clients
 Client set. More...
 
- Public Types inherited from Gaudi::IDataConnection
enum  IoType {
  READ =1<<1, UPDATE =1<<2, CREATE =1<<3, RECREATE =(1<<4)+(1<<3),
  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, BAD_DATA_CONNECTION =4 }
 Status Code on bad file connection. More...
 
enum  IoType {
  READ =1<<1, UPDATE =1<<2, CREATE =1<<3, RECREATE =(1<<4)+(1<<3),
  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, BAD_DATA_CONNECTION =4 }
 Status Code on bad file connection. More...
 

Public Member Functions

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

Public Attributes

std::unique_ptr< Toolm_tool
 

Protected Member Functions

const std::string & empty () const
 Empty string reference. More...
 
StatusCode saveRefs ()
 Internal helper to save/update reference tables. More...
 
const std::string & empty () const
 Empty string reference. More...
 
StatusCode saveRefs ()
 Internal helper to save/update reference tables. More...
 

Protected Attributes

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

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 100 of file RootDataConnection.h.

Member Typedef Documentation

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

Client set.

Definition at line 151 of file RootDataConnection.h.

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

Client set.

Definition at line 151 of file RootDataConnection.h.

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

Definition of container sections to handle merged files.

Definition at line 145 of file RootDataConnection.h.

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

Definition of container sections to handle merged files.

Definition at line 145 of file RootDataConnection.h.

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

Link sections definition.

Definition at line 149 of file RootDataConnection.h.

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

Link sections definition.

Definition at line 149 of file RootDataConnection.h.

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

Definition of database section to handle merged files.

Definition at line 147 of file RootDataConnection.h.

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

Definition of database section to handle merged files.

Definition at line 147 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 141 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 141 of file RootDataConnection.h.

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

Definition of tree sections.

Definition at line 143 of file RootDataConnection.h.

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

Definition of tree sections.

Definition at line 143 of file RootDataConnection.h.

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

Type definition for string maps.

Definition at line 139 of file RootDataConnection.h.

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

Type definition for string maps.

Definition at line 139 of file RootDataConnection.h.

Member Enumeration Documentation

anonymous enum
Enumerator
ROOT_READ_ERROR 
ROOT_OPEN_ERROR 

Definition at line 103 of file RootDataConnection.h.

anonymous enum
Enumerator
ROOT_READ_ERROR 
ROOT_OPEN_ERROR 

Definition at line 103 of file RootDataConnection.h.

Constructor & Destructor Documentation

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

Standard constructor.

Gaudi::RootDataConnection::~RootDataConnection ( )
overridedefault

Standard destructor.

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

Standard constructor.

Gaudi::RootDataConnection::~RootDataConnection ( )
overridedefault

Standard destructor.

Member Function Documentation

void RootDataConnection::addClient ( const IInterface client)

Add new client to this data source.

Definition at line 165 of file RootDataConnection.cpp.

165  {
166  m_clients.insert(client);
167 }
Clients m_clients
Client list.
void Gaudi::RootDataConnection::addClient ( const IInterface client)

Add new client to this data source.

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

Error handler when bad write statements occur.

Definition at line 183 of file RootDataConnection.cpp.

183  {
184  msgSvc() << MSG::ERROR << "File:" << fid() << "Failed action:" << msg << endmsg;
185 }
const std::string & fid() const
Access file id.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MsgStream & msgSvc() const
Allow access to printer service.
void Gaudi::RootDataConnection::badWriteError ( const std::string &  msg) const

Error handler when bad write statements occur.

StatusCode RootDataConnection::connectRead ( )
virtual

Open data stream in read mode.

Connect the file in READ mode.

Implements Gaudi::IDataConnection.

Definition at line 226 of file RootDataConnection.cpp.

226  {
227  m_file.reset( TFile::Open(m_pfn.c_str()) );
228  if ( !m_file || m_file->IsZombie() ) {
229  m_file.reset();
230  return StatusCode::FAILURE;
231  }
233  msgSvc() << MSG::DEBUG << "Opened file " << m_pfn << " in mode READ. [" << m_fid << "]" << endmsg << MSG::DEBUG;
234  if ( msgSvc().isActive() ) m_file->ls();
235  msgSvc() << MSG::VERBOSE;
236  if ( msgSvc().isActive() ) m_file->Print();
237  if ( makeTool() ) {
238  sc = m_tool->readRefs();
239  sc.ignore();
240 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
241  if ( sc.getCode() == ROOT_READ_ERROR ) {
242  IIncidentSvc* inc = m_setup->incidentSvc();
243  if ( inc ) {
245  }
246  }
247 #endif
248  }
249  if ( !sc.isSuccess() ) return sc;
250  bool need_fid = m_fid == m_pfn;
251  string fid = m_fid;
252  m_mergeFIDs.clear();
253  for(size_t i=0, n=m_params.size(); i<n; ++i) {
254  if ( m_params[i].first == "FID" ) {
255  m_mergeFIDs.push_back(m_params[i].second);
256  if ( m_params[i].second != m_fid ) {
257  msgSvc() << MSG::DEBUG << "Check FID param:" << m_params[i].second << endmsg;
258  //if ( m_fid == m_pfn ) {
259  m_fid = m_params[i].second;
260  //}
261  }
262  }
263  }
264  if ( !need_fid && fid != m_fid ) {
265  msgSvc() << MSG::ERROR << "FID mismatch:" << fid << "(Catalog) != " << m_fid << "(file)" << endmsg
266  << "for PFN:" << m_pfn << endmsg;
267  return StatusCode::FAILURE;
268  }
269  msgSvc() << MSG::DEBUG << "Using FID " << m_fid << " from params table...." << endmsg
270  << "for PFN:" << m_pfn << endmsg;
271  return sc;
272 }
const std::string & fid() const
Access file id.
std::unique_ptr< TFile > m_file
Reference to ROOT file.
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
std::unique_ptr< Tool > m_tool
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string m_fid
File ID of the connection.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
const std::string & pfn() const
Access physical file name.
ParamMap m_params
Parameter map for file parameters.
constexpr double second
StringVec m_mergeFIDs
Map containing merge FIDs.
std::string m_pfn
Physical file name of the connection.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< RootConnectionSetup > m_setup
Reference to the setup structure.
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
Base class for all Incidents (computing events).
Definition: Incident.h:16
MsgStream & msgSvc() const
Allow access to printer service.
void ignore() const
Definition: StatusCode.h:108
list i
Definition: ana.py:128
const std::string CorruptedInputFile
the input file has shown a corruption
Definition: Incident.h:81
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
virtual StatusCode Gaudi::RootDataConnection::connectRead ( )
virtual

Open data stream in read mode.

Implements Gaudi::IDataConnection.

StatusCode RootDataConnection::connectWrite ( IoType  typ)
virtual

Open data stream in write mode.

Implements Gaudi::IDataConnection.

Definition at line 275 of file RootDataConnection.cpp.

275  {
276  int compress = RootConnectionSetup::compression();
277  msgSvc() << MSG::DEBUG;
278  switch(typ) {
279  case CREATE:
280  resetAge();
281  m_file.reset(TFile::Open(m_pfn.c_str(),"CREATE","Root event data",compress));
282  m_refs = new TTree("Refs","Root reference data");
283  msgSvc() << "Opened file " << m_pfn << " in mode CREATE. [" << m_fid << "]" << endmsg;
284  m_params.emplace_back("PFN",m_pfn);
285  if ( m_fid != m_pfn ) {
286  m_params.emplace_back("FID",m_fid);
287  }
288  makeTool();
289  break;
290  case RECREATE:
291  resetAge();
292  m_file.reset(TFile::Open(m_pfn.c_str(),"RECREATE","Root event data",compress));
293  msgSvc() << "Opened file " << m_pfn << " in mode RECREATE. [" << m_fid << "]" << endmsg;
294  m_refs = new TTree("Refs","Root reference data");
295  m_params.emplace_back("PFN",m_pfn);
296  if ( m_fid != m_pfn ) {
297  m_params.emplace_back("FID",m_fid);
298  }
299  makeTool();
300  break;
301  case UPDATE:
302  resetAge();
303  m_file.reset(TFile::Open(m_pfn.c_str(),"UPDATE","Root event data",compress));
304  msgSvc() << "Opened file " << m_pfn << " in mode UPDATE. [" << m_fid << "]" << endmsg;
305  if ( m_file && !m_file->IsZombie() ) {
306  if ( makeTool() ) {
307  StatusCode sc = m_tool->readRefs();
308  sc.ignore();
309  if ( sc.getCode() == ROOT_READ_ERROR ) {
310 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
311  IIncidentSvc* inc = m_setup->incidentSvc();
312  if ( inc ) {
314  }
315 #endif
316  }
317  return sc;
318  }
319  TDirectory::TContext ctxt(m_file.get());
320  m_refs = new TTree("Refs","Root reference data");
321  makeTool();
322  return StatusCode::SUCCESS;
323  }
324  break;
325  default:
326  m_refs = nullptr;
327  m_file.reset();
328  return StatusCode::FAILURE;
329  }
331 }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:93
std::unique_ptr< Tool > m_tool
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string m_fid
File ID of the connection.
static int compression()
Access to global compression level.
const std::string & pfn() const
Access physical file name.
ParamMap m_params
Parameter map for file parameters.
std::string m_pfn
Physical file name of the connection.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
TTree * m_refs
Pointer to the reference tree.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< RootConnectionSetup > m_setup
Reference to the setup structure.
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
void resetAge()
Reset age.
Base class for all Incidents (computing events).
Definition: Incident.h:16
MsgStream & msgSvc() const
Allow access to printer service.
void ignore() const
Definition: StatusCode.h:108
const std::string CorruptedInputFile
the input file has shown a corruption
Definition: Incident.h:81
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
virtual StatusCode Gaudi::RootDataConnection::connectWrite ( IoType  typ)
virtual

Open data stream in write mode.

Implements Gaudi::IDataConnection.

StatusCode RootDataConnection::disconnect ( )
virtual

Release data stream and release implementation dependent resources.

Implements Gaudi::IDataConnection.

Definition at line 334 of file RootDataConnection.cpp.

334  {
335  if ( m_file ) {
336  if ( !m_file->IsZombie() ) {
337  if ( m_file->IsWritable() ) {
338  msgSvc() << MSG::DEBUG;
339  TDirectory::TContext ctxt(m_file.get());
340  if ( m_refs ) {
341  if ( !m_tool->saveRefs().isSuccess() ) badWriteError("Saving References");
342  if ( m_refs->Write() < 0 ) badWriteError("Write Reference branch");
343  }
344  for( auto& i : m_sections ) {
345  if ( i.second ) {
346  if ( i.second->Write() < 0 ) badWriteError("Write section:"+i.first);
347  msgSvc() << "Disconnect section " << i.first << " " << i.second->GetName() << endmsg;
348  }
349  }
350  m_sections.clear();
351  }
352  msgSvc() << MSG::DEBUG;
353  if ( msgSvc().isActive() ) m_file->ls();
354  msgSvc() << MSG::VERBOSE;
355  if ( msgSvc().isActive() ) m_file->Print();
356  m_file->Close();
357  }
358  msgSvc() << MSG::DEBUG << "Disconnected file " << m_pfn << " " << m_file->GetName() << endmsg;
359  m_file.reset();
360  m_tool.reset();
361  }
362  return StatusCode::SUCCESS;
363 }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
std::unique_ptr< Tool > m_tool
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string m_pfn
Physical file name of the connection.
TTree * m_refs
Pointer to the reference tree.
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
Sections m_sections
Tree sections in TFile.
MsgStream & msgSvc() const
Allow access to printer service.
list i
Definition: ana.py:128
void badWriteError(const std::string &msg) const
Error handler when bad write statements occur.
virtual StatusCode Gaudi::RootDataConnection::disconnect ( )
virtual

Release data stream and release implementation dependent resources.

Implements Gaudi::IDataConnection.

const std::string& Gaudi::RootDataConnection::empty ( ) const
protected

Empty string reference.

CSTR RootDataConnection::empty ( ) const
protected

Empty string reference.

Definition at line 468 of file RootDataConnection.cpp.

468  {
469  return s_empty;
470 }
void Gaudi::RootDataConnection::enableStatistics ( const std::string &  section)

Enable TTreePerStats.

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

Enable TTreePerStats.

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

Direct access to TFile structure.

Definition at line 255 of file RootDataConnection.h.

255 { return m_file.get(); }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
TFile* Gaudi::RootDataConnection::file ( ) const
inline

Direct access to TFile structure.

Definition at line 255 of file RootDataConnection.h.

255 { return m_file.get(); }
std::unique_ptr< TFile > m_file
Reference to ROOT 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.

316  { return m_tool->getBranch(section,branch_name); }
std::unique_ptr< Tool > m_tool
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.

316  { return m_tool->getBranch(section,branch_name); }
std::unique_ptr< Tool > m_tool
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.

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.

333  { return (which>=0)&&(size_t(which)<m_conts.size()) ? *(m_conts.begin()+which) : empty(); }
StringVec m_conts
Map containing external container names.
const std::string & empty() const
Empty string reference.
def which(executable)
Definition: BaseTest.py:547
const std::string& Gaudi::RootDataConnection::getCont ( int  which) const
inline

Access container name from saved index.

Definition at line 332 of file RootDataConnection.h.

333  { return (which>=0)&&(size_t(which)<m_conts.size()) ? *(m_conts.begin()+which) : empty(); }
StringVec m_conts
Map containing external container names.
const std::string & empty() const
Empty string reference.
def which(executable)
Definition: BaseTest.py:547
CSTR RootDataConnection::getDb ( int  which) const

Access database/file name from saved index.

Definition at line 459 of file RootDataConnection.cpp.

459  {
460  if ( (which>=0) && (size_t(which)<m_dbs.size()) ) {
461  if ( *(m_dbs.begin()+which) == s_local ) return m_fid;
462  return *(m_dbs.begin()+which);
463  }
464  return s_empty;
465 }
std::string m_fid
File ID of the connection.
def which(executable)
Definition: BaseTest.py:547
StringVec m_dbs
Map containing external database file names (fids)
const std::string& Gaudi::RootDataConnection::getDb ( int  which) const

Access database/file name from saved index.

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

Access link name from saved index.

Definition at line 336 of file RootDataConnection.h.

337  { return (which>=0)&&(size_t(which)<m_links.size()) ? *(m_links.begin()+which) : empty(); }
StringVec m_links
Map containing internal links names.
const std::string & empty() const
Empty string reference.
def which(executable)
Definition: BaseTest.py:547
const std::string& Gaudi::RootDataConnection::getLink ( int  which) const
inline

Access link name from saved index.

Definition at line 336 of file RootDataConnection.h.

337  { return (which>=0)&&(size_t(which)<m_links.size()) ? *(m_links.begin()+which) : empty(); }
StringVec m_links
Map containing internal links names.
const std::string & empty() const
Empty string reference.
def which(executable)
Definition: BaseTest.py:547
std::pair<const RootRef*,const ContainerSection*> Gaudi::RootDataConnection::getMergeSection ( const std::string &  container,
int  entry 
) const

Access link section for single container and entry.

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 587 of file RootDataConnection.cpp.

587  {
588  //size_t idx = cont.find('/',1);
589  //string container = cont[0]=='/' ? cont.substr(1,idx==string::npos?idx:idx-1) : cont;
590  auto i=m_mergeSects.find(container);
591  if ( i != m_mergeSects.end() ) {
592  size_t cnt = 0;
593  const ContainerSections& s = (*i).second;
594  for(auto j=s.cbegin(); j != s.cend(); ++j,++cnt) {
595  const ContainerSection& c = *j;
596  if ( entry >= c.start && entry < (c.start+c.length) ) {
597  if ( m_linkSects.size() > cnt ) {
598  if ( msgSvc().isActive() ) {
599  msgSvc() << MSG::VERBOSE << "MergeSection for:" << container
600  << " [" << entry << "]" << endmsg
601  << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
602  }
603  return { &(m_linkSects[cnt]), &c };
604  }
605  }
606  }
607  }
608  msgSvc() << MSG::DEBUG << "Return INVALID MergeSection for:" << container
609  << " [" << entry << "]" << endmsg
610  << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
611  return { nullptr, nullptr };
612 }
tuple c
Definition: gaudirun.py:392
MergeSections m_mergeSects
Database section map for merged files.
std::vector< ContainerSection > ContainerSections
Definition of container sections to handle merged files.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string m_fid
File ID of the connection.
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::string m_pfn
Physical file name of the connection.
LinkSections m_linkSects
Database link sections.
MsgStream & msgSvc() const
Allow access to printer service.
string s
Definition: gaudirun.py:246
list i
Definition: ana.py:128
TTree* Gaudi::RootDataConnection::getSection ( const std::string &  sect,
bool  create = false 
)

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

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

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

virtual bool Gaudi::RootDataConnection::isConnected ( ) const
inlinevirtual

Check if connected to data source.

Implements Gaudi::IDataConnection.

Definition at line 257 of file RootDataConnection.h.

257 { return bool(m_file); }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
virtual bool Gaudi::RootDataConnection::isConnected ( ) const
inlinevirtual

Check if connected to data source.

Implements Gaudi::IDataConnection.

Definition at line 257 of file RootDataConnection.h.

257 { return bool(m_file); }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
bool Gaudi::RootDataConnection::isWritable ( ) const
inline

Is the file writable?

Definition at line 259 of file RootDataConnection.h.

259 { return m_file && m_file->IsWritable(); }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
bool Gaudi::RootDataConnection::isWritable ( ) const
inline

Is the file writable?

Definition at line 259 of file RootDataConnection.h.

259 { return m_file && m_file->IsWritable(); }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
int Gaudi::RootDataConnection::loadObj ( const std::string &  section,
const std::string &  cnt,
unsigned long  entry,
DataObject *&  pObj 
)

Load object.

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

Load object.

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

Load references object.

Definition at line 567 of file RootDataConnection.cpp.

569 {
570  int nbytes = m_tool->loadRefs(section,cnt,entry,refs);
571 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
572  if ( nbytes < 0 ) {
573  // This is definitely an error:
574  // -- Either branch not preesent at all or
575  // -- ROOT I/O error, which issues -1
576  IIncidentSvc* inc = m_setup->incidentSvc();
577  if ( inc ) {
579  }
580  }
581 #endif
582  return nbytes;
583 }
std::unique_ptr< Tool > m_tool
const std::string & pfn() const
Access physical file name.
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
SmartIF< RootConnectionSetup > m_setup
Reference to the setup structure.
Base class for all Incidents (computing events).
Definition: Incident.h:16
const std::string CorruptedInputFile
the input file has shown a corruption
Definition: Incident.h:81
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:21
int Gaudi::RootDataConnection::loadRefs ( const std::string &  section,
const std::string &  cnt,
unsigned long  entry,
RootObjectRefs refs 
)

Load references object.

bool Gaudi::RootDataConnection::lookupClient ( const IInterface client) const

Lookup client for this data source.

bool RootDataConnection::lookupClient ( const IInterface client) const

Lookup client for this data source.

Definition at line 177 of file RootDataConnection.cpp.

177  {
178  auto i=m_clients.find(client);
179  return i != m_clients.end();
180 }
Clients m_clients
Client list.
list i
Definition: ana.py:128
int Gaudi::RootDataConnection::makeLink ( const std::string &  p)

Convert path string to path index.

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

Convert path string to path index.

void Gaudi::RootDataConnection::makeRef ( IRegistry pA,
RootRef ref 
)

Create reference object from registry entry.

void RootDataConnection::makeRef ( IRegistry pA,
RootRef ref 
)

Create reference object from registry entry.

Definition at line 615 of file RootDataConnection.cpp.

615  {
616  IOpaqueAddress* pA = pR->address();
617  makeRef(pR->name(),pA->clID(),pA->svcType(),pA->par()[0],pA->par()[1],-1,ref);
618 }
virtual const std::string * par() const =0
Retrieve String parameters.
virtual long svcType() const =0
Retrieve service type.
virtual const CLID & clID() const =0
Retrieve class information from link.
void makeRef(IRegistry *pA, RootRef &ref)
Create reference object from registry entry.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
Opaque address interface definition.
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.

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.

Tool* Gaudi::RootDataConnection::makeTool ( )

Create file access tool to encapsulate POOL compatibiliy.

RootDataConnection::Tool * RootDataConnection::makeTool ( )

Create file access tool to encapsulate POOL compatibiliy.

Definition at line 212 of file RootDataConnection.cpp.

212  {
213  if ( !m_refs ) m_refs = (TTree*)m_file->Get("Refs");
214  if ( m_refs )
215  m_tool.reset( new RootTool(this) );
216 #ifdef __POOL_COMPATIBILITY
217  else if ( m_file->Get("##Links") != 0 )
218  m_tool.reset(new PoolTool(this));
219 #endif
220  else
221  m_tool.reset();
222  return m_tool.get();
223 }
std::unique_ptr< TFile > m_file
Reference to ROOT file.
std::unique_ptr< Tool > m_tool
Description:
Definition: RootTool.h:16
TTree * m_refs
Pointer to the reference tree.
const StringVec& Gaudi::RootDataConnection::mergeFIDs ( ) const
inline

Access merged FIDs.

Definition at line 265 of file RootDataConnection.h.

265 { return m_mergeFIDs; }
StringVec m_mergeFIDs
Map containing merge FIDs.
const StringVec& Gaudi::RootDataConnection::mergeFIDs ( ) const
inline

Access merged FIDs.

Definition at line 265 of file RootDataConnection.h.

265 { return m_mergeFIDs; }
StringVec m_mergeFIDs
Map containing merge FIDs.
const MergeSections& Gaudi::RootDataConnection::mergeSections ( ) const
inline

Access merged data section inventory.

Definition at line 263 of file RootDataConnection.h.

263 { return m_mergeSects; }
MergeSections m_mergeSects
Database section map for merged files.
const MergeSections& Gaudi::RootDataConnection::mergeSections ( ) const
inline

Access merged data section inventory.

Definition at line 263 of file RootDataConnection.h.

263 { return m_mergeSects; }
MergeSections m_mergeSects
Database section map for merged files.
MsgStream& Gaudi::RootDataConnection::msgSvc ( ) const
inline

Allow access to printer service.

Definition at line 154 of file RootDataConnection.h.

154 { return m_setup->msgSvc(); }
SmartIF< RootConnectionSetup > m_setup
Reference to the setup structure.
MsgStream& Gaudi::RootDataConnection::msgSvc ( ) const
inline

Allow access to printer service.

Definition at line 154 of file RootDataConnection.h.

154 { return m_setup->msgSvc(); }
SmartIF< RootConnectionSetup > m_setup
Reference to the setup structure.
virtual StatusCode Gaudi::RootDataConnection::read ( void *  const,
size_t   
)
inlinevirtual

Read root byte buffer from input stream.

Implements Gaudi::IDataConnection.

Definition at line 305 of file RootDataConnection.h.

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

Read root byte buffer from input stream.

Implements Gaudi::IDataConnection.

Definition at line 305 of file RootDataConnection.h.

size_t Gaudi::RootDataConnection::removeClient ( const IInterface client)

Remove client from this data source.

size_t RootDataConnection::removeClient ( const IInterface client)

Remove client from this data source.

Definition at line 170 of file RootDataConnection.cpp.

170  {
171  auto i=m_clients.find(client);
172  if ( i != m_clients.end() ) m_clients.erase(i);
173  return m_clients.size();
174 }
Clients m_clients
Client list.
list i
Definition: ana.py:128
std::pair<int,unsigned long> Gaudi::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.

std::pair<int,unsigned long> Gaudi::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.

std::pair<int,unsigned long> Gaudi::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.

std::pair<int,unsigned long> Gaudi::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.

StatusCode Gaudi::RootDataConnection::saveRefs ( )
protected

Internal helper to save/update reference tables.

StatusCode Gaudi::RootDataConnection::saveRefs ( )
protected

Internal helper to save/update reference tables.

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

Save TTree access statistics if required.

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

Save TTree access statistics if required.

virtual long long int Gaudi::RootDataConnection::seek ( long long int  ,
int   
)
inlinevirtual

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

Implements Gaudi::IDataConnection.

Definition at line 309 of file RootDataConnection.h.

309 { return -1; }
virtual long long int Gaudi::RootDataConnection::seek ( long long int  ,
int   
)
inlinevirtual

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

Implements Gaudi::IDataConnection.

Definition at line 309 of file RootDataConnection.h.

309 { return -1; }
Tool* Gaudi::RootDataConnection::tool ( ) const
inline

Access tool.

Definition at line 261 of file RootDataConnection.h.

261 { return m_tool.get(); }
std::unique_ptr< Tool > m_tool
Tool* Gaudi::RootDataConnection::tool ( ) const
inline

Access tool.

Definition at line 261 of file RootDataConnection.h.

261 { return m_tool.get(); }
std::unique_ptr< Tool > m_tool
virtual StatusCode Gaudi::RootDataConnection::write ( const void *  ,
int   
)
inlinevirtual

Write root byte buffer to output stream.

Implements Gaudi::IDataConnection.

Definition at line 307 of file RootDataConnection.h.

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

Write root byte buffer to output stream.

Implements Gaudi::IDataConnection.

Definition at line 307 of file RootDataConnection.h.

Friends And Related Function Documentation

Tool
friend

Definition at line 242 of file RootDataConnection.h.

Member Data Documentation

Clients Gaudi::RootDataConnection::m_clients
protected

Client list.

Definition at line 183 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_conts
protected

Map containing external container names.

Definition at line 171 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_dbs
protected

Map containing external database file names (fids)

Definition at line 169 of file RootDataConnection.h.

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

Buffer for empty string reference.

Definition at line 185 of file RootDataConnection.h.

std::unique_ptr< TFile > Gaudi::RootDataConnection::m_file
protected

Reference to ROOT file.

Definition at line 163 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_links
protected

Map containing internal links names.

Definition at line 173 of file RootDataConnection.h.

LinkSections Gaudi::RootDataConnection::m_linkSects
protected

Database link sections.

Definition at line 181 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_mergeFIDs
protected

Map containing merge FIDs.

Definition at line 175 of file RootDataConnection.h.

MergeSections Gaudi::RootDataConnection::m_mergeSects
protected

Database section map for merged files.

Definition at line 179 of file RootDataConnection.h.

ParamMap Gaudi::RootDataConnection::m_params
protected

Parameter map for file parameters.

Definition at line 177 of file RootDataConnection.h.

TTree * Gaudi::RootDataConnection::m_refs = nullptr
protected

Pointer to the reference tree.

Definition at line 165 of file RootDataConnection.h.

Sections Gaudi::RootDataConnection::m_sections
protected

Tree sections in TFile.

Definition at line 167 of file RootDataConnection.h.

SmartIF< RootConnectionSetup > Gaudi::RootDataConnection::m_setup
protected

Reference to the setup structure.

Definition at line 159 of file RootDataConnection.h.

std::unique_ptr< TTreePerfStats > Gaudi::RootDataConnection::m_statistics
protected

I/O read statistics from TTree.

Definition at line 161 of file RootDataConnection.h.

std::unique_ptr< Tool > Gaudi::RootDataConnection::m_tool

Definition at line 241 of file RootDataConnection.h.


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