| The Gaudi Framework v28r2-patches (bc4ad17a)

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

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

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. 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< ContainerSection > | ContainerSections
| Definition of container sections to handle merged files. More...
typedef std::map< std::string, ContainerSections > | MergeSections
| Definition of database section to handle merged files. More...
typedef std::vector< RootRef > | LinkSections
| 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) }
| 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. More...
Tool * | makeTool ()
| Create file access tool to encapsulate POOL compatibiliy. More...
| RootDataConnection (const IInterface *own, const std::string &nam, std::shared_ptr< RootConnectionSetup > setup)
| Standard constructor. More...
| ~RootDataConnection () override=default
| Standard destructor. More...
TFile * | file () const
| Direct access to TFile structure. More...
bool | isConnected () const override
| Check if connected to data source. More...
bool | isWritable () const
| Is the file writable? More...
Tool * | tool () const
| Access tool. More...
const MergeSections & | mergeSections () const
| Access merged data section inventory. More...
const StringVec & | mergeFIDs () 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...
StatusCode | connectRead () override
| Open data stream in read mode. More...
StatusCode | connectWrite (IoType typ) override
| Open data stream in write mode. More...
StatusCode | disconnect () override
| Release data stream and release implementation dependent resources. More...
StatusCode | read (void *const, size_t) override
| Read root byte buffer from input stream. More...
StatusCode | write (const void *, int) override
| Write root byte buffer to output stream. More...
long long int | seek (long long int, int) override
| 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 IInterface * | owner () const
| Owner instance. More...

## Public Attributes
std::unique_ptr< Tool > | m_tool

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

## Protected Attributes
std::shared_ptr< RootConnectionSetup > | m_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 IInterface * | m_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 92 of file RootDataConnection.h.

## Member Typedef Documentation

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

Client set.

Definition at line 143 of file RootDataConnection.h.

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

Definition of container sections to handle merged files.

Definition at line 137 of file RootDataConnection.h.

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

Link sections definition.

Definition at line 141 of file RootDataConnection.h.

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

Definition of database section to handle merged files.

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

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

Definition of tree sections.

Definition at line 135 of file RootDataConnection.h.

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

Type definition for string maps.

Definition at line 131 of file RootDataConnection.h.

## Member Enumeration Documentation

anonymous enum

Enumerator
ROOT_READ_ERROR |
ROOT_OPEN_ERROR |

Definition at line 95 of file RootDataConnection.h.

95 { ROOT_READ_ERROR = 0x2,
96 ROOT_OPEN_ERROR = 0x4
97 };
Gaudi::RootDataConnection::ROOT_OPEN_ERROR
Definition: RootDataConnection.h:96
Gaudi::RootDataConnection::ROOT_READ_ERROR
Definition: RootDataConnection.h:95

## Constructor & Destructor Documentation

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

Standard constructor.

Definition at line 141 of file RootDataConnection.cpp.

142 : IDataConnection(owner,fname), m_setup(std::move(setup))
143 { // 01234567890123456789012345678901234567890
144 // Check if FID: A82A3BD8-7ECB-DC11-8DC0-000423D950B0
145 if ( fname.length() == 36 && fname[8]=='-'&&fname[13]=='-'&&fname[18]=='-'&&fname[23]=='-' ) {
146 m_name = "FID:"+fname;
147 }
148 m_age = 0;
149 m_file.reset();
150 addClient(owner);
151 }
Gaudi::RootDataConnection::addClient
void addClient(const IInterface *client)
Add new client to this data source.
Definition: RootDataConnection.cpp:154
Gaudi::IDataConnection::m_age
int m_age
Age counter.
Definition: IIODataManager.h:33
Gaudi::IDataConnection::m_name
std::string m_name
Connection name/identifier.
Definition: IIODataManager.h:27
Gaudi::IDataConnection::IDataConnection
IDataConnection(const IInterface *own, std::string nam)
Standard constructor.
Definition: IIODataManager.h:43
std::unique_ptr::reset
T reset(T...args)
std::move
T move(T...args)
Gaudi::IDataConnection::owner
const IInterface * owner() const
Owner instance.
Definition: IIODataManager.h:64
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155

Gaudi::RootDataConnection::~RootDataConnection | ( |  | ) |
| override default

Standard destructor.

## Member Function Documentation

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

Add new client to this data source.

Definition at line 154 of file RootDataConnection.cpp.

154 {
155 m_clients.insert(client);
156 }
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:175
std::set::insert
T insert(T...args)

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

Error handler when bad write statements occur.

Definition at line 172 of file RootDataConnection.cpp.

172 {
173 msgSvc() << MSG::ERROR << "File:" << fid() << "Failed action:" << msg << endmsg;
174 }
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:52
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
MSG::ERROR
Definition: IMessageSvc.h:21
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Open data stream in read mode.

Connect the file in READ mode.

Implements Gaudi::IDataConnection.

Definition at line 215 of file RootDataConnection.cpp.

215 {
216 m_file.reset( TFile::Open(m_pfn.c_str()) );
217 if ( !m_file || m_file->IsZombie() ) {
218 m_file.reset();
219 return StatusCode::FAILURE;
220 }
221 StatusCode sc = StatusCode::FAILURE;
222 msgSvc() << MSG::DEBUG << "Opened file " << m_pfn << " in mode READ. [" << m_fid << "]" << endmsg << MSG::DEBUG;
223 if ( msgSvc().isActive() ) m_file->ls();
224 msgSvc() << MSG::VERBOSE;
225 if ( msgSvc().isActive() ) m_file->Print();
226 if ( makeTool() ) {
227 sc = m_tool->readRefs();
228 sc.ignore();
229 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
230 if ( sc.getCode() == ROOT_READ_ERROR ) {
231 IIncidentSvc* inc = m_setup->incidentSvc();
232 if ( inc ) {
233 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
234 }
235 }
236 #endif
237 }
238 if ( !sc.isSuccess() ) return sc;
239 bool need_fid = m_fid == m_pfn;
240 string fid = m_fid;
241 m_mergeFIDs.clear();
242 for(auto & elem : m_params) {
243 if ( elem.first == "FID" ) {
244 m_mergeFIDs.push_back(elem.second);
245 if ( elem.second != m_fid ) {
246 msgSvc() << MSG::DEBUG << "Check FID param:" << elem.second << endmsg;
247 //if ( m_fid == m_pfn ) {
248 m_fid = elem.second;
249 //}
250 }
251 }
252 }
253 if ( !need_fid && fid != m_fid ) {
254 msgSvc() << MSG::ERROR << "FID mismatch:" << fid << "(Catalog) != " << m_fid << "(file)" << endmsg
255 << "for PFN:" << m_pfn << endmsg;
256 return StatusCode::FAILURE;
257 }
258 msgSvc() << MSG::DEBUG << "Using FID " << m_fid << " from params table...." << endmsg
259 << "for PFN:" << m_pfn << endmsg;
260 return sc;
261 }
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:52
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:91
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
MSG::DEBUG
Definition: IMessageSvc.h:18
MSG::VERBOSE
Definition: IMessageSvc.h:17
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
Gaudi::RootDataConnection::m_params
ParamMap m_params
Parameter map for file parameters.
Definition: RootDataConnection.h:169
Gaudi::RootDataConnection::m_mergeFIDs
StringVec m_mergeFIDs
Map containing merge FIDs.
Definition: RootDataConnection.h:167
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:31
std::vector::push_back
T push_back(T...args)
Gaudi::RootDataConnection::ROOT_READ_ERROR
Definition: RootDataConnection.h:95
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::unique_ptr::reset
T reset(T...args)
std::vector::clear
T clear(T...args)
Gaudi::RootDataConnection::makeTool
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
Definition: RootDataConnection.cpp:201
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
std::string::c_str
T c_str(T...args)
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
MSG::ERROR
Definition: IMessageSvc.h:21
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23

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

Open data stream in write mode.

Implements Gaudi::IDataConnection.

Definition at line 264 of file RootDataConnection.cpp.

264 {
265 int compress = RootConnectionSetup::compression();
266 msgSvc() << MSG::DEBUG;
267 switch(typ) {
268 case CREATE:
269 resetAge();
270 m_file.reset(TFile::Open(m_pfn.c_str(),"CREATE","Root event data",compress));
271 m_refs = new TTree("Refs","Root reference data");
272 msgSvc() << "Opened file " << m_pfn << " in mode CREATE. [" << m_fid << "]" << endmsg;
273 m_params.emplace_back("PFN",m_pfn);
274 if ( m_fid != m_pfn ) {
275 m_params.emplace_back("FID",m_fid);
276 }
277 makeTool();
278 break;
279 case RECREATE:
280 resetAge();
281 m_file.reset(TFile::Open(m_pfn.c_str(),"RECREATE","Root event data",compress));
282 msgSvc() << "Opened file " << m_pfn << " in mode RECREATE. [" << m_fid << "]" << endmsg;
283 m_refs = new TTree("Refs","Root reference data");
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 UPDATE:
291 resetAge();
292 m_file.reset(TFile::Open(m_pfn.c_str(),"UPDATE","Root event data",compress));
293 msgSvc() << "Opened file " << m_pfn << " in mode UPDATE. [" << m_fid << "]" << endmsg;
294 if ( m_file && !m_file->IsZombie() ) {
295 if ( makeTool() ) {
296 StatusCode sc = m_tool->readRefs();
297 sc.ignore();
298 if ( sc.getCode() == ROOT_READ_ERROR ) {
299 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
300 IIncidentSvc* inc = m_setup->incidentSvc();
301 if ( inc ) {
302 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
303 }
304 #endif
305 }
306 return sc;
307 }
308 TDirectory::TContext ctxt(m_file.get());
309 m_refs = new TTree("Refs","Root reference data");
310 makeTool();
311 return StatusCode::SUCCESS;
312 }
313 break;
314 default:
315 m_refs = nullptr;
316 m_file.reset();
317 return StatusCode::FAILURE;
318 }
319 return m_file ? StatusCode::SUCCESS : StatusCode::FAILURE ;
320 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::getCode
unsigned long getCode() const
Get the status code by value.
Definition: StatusCode.h:91
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
Gaudi::RootConnectionSetup::compression
static int compression()
Access to global compression level.
Definition: RootDataConnection.cpp:125
MSG::DEBUG
Definition: IMessageSvc.h:18
Gaudi::IDataConnection::RECREATE
Definition: IIODataManager.h:38
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
Gaudi::RootDataConnection::m_params
ParamMap m_params
Parameter map for file parameters.
Definition: RootDataConnection.h:169
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:31
Gaudi::RootDataConnection::ROOT_READ_ERROR
Definition: RootDataConnection.h:95
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::unique_ptr::reset
T reset(T...args)
Gaudi::RootDataConnection::makeTool
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
Definition: RootDataConnection.cpp:201
Gaudi::IDataConnection::UPDATE
Definition: IIODataManager.h:38
std::unique_ptr::get
T get(T...args)
Gaudi::IDataConnection::CREATE
Definition: IIODataManager.h:38
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
Gaudi::IDataConnection::resetAge
void resetAge()
Reset age.
Definition: IIODataManager.h:60
std::string::c_str
T c_str(T...args)
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106
Gaudi::RootDataConnection::m_refs
TTree * m_refs
Pointer to the reference tree.
Definition: RootDataConnection.h:157
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
std::vector::emplace_back
T emplace_back(T...args)

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

Release data stream and release implementation dependent resources.

Implements Gaudi::IDataConnection.

Definition at line 323 of file RootDataConnection.cpp.

323 {
324 if ( m_file ) {
325 if ( !m_file->IsZombie() ) {
326 if ( m_file->IsWritable() ) {
327 msgSvc() << MSG::DEBUG;
328 TDirectory::TContext ctxt(m_file.get());
329 if ( m_refs ) {
330 if ( !m_tool->saveRefs().isSuccess() ) badWriteError("Saving References");
331 if ( m_refs->Write() < 0 ) badWriteError("Write Reference branch");
332 }
333 for( auto& i : m_sections ) {
334 if ( i.second ) {
335 if ( i.second->Write() < 0 ) badWriteError("Write section:"+i.first);
336 msgSvc() << "Disconnect section " << i.first << " " << i.second->GetName() << endmsg;
337 }
338 }
339 m_sections.clear();
340 }
341 msgSvc() << MSG::DEBUG;
342 if ( msgSvc().isActive() ) m_file->ls();
343 msgSvc() << MSG::VERBOSE;
344 if ( msgSvc().isActive() ) m_file->Print();
345 m_file->Close();
346 }
347 msgSvc() << MSG::DEBUG << "Disconnected file " << m_pfn << " " << m_file->GetName() << endmsg;
348 m_file.reset();
349 m_tool.reset();
350 }
351 return StatusCode::SUCCESS;
352 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233
MSG::DEBUG
Definition: IMessageSvc.h:18
MSG::VERBOSE
Definition: IMessageSvc.h:17
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:31
MsgStream::clear
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
Gaudi::RootDataConnection::m_sections
Sections m_sections
Tree sections in TFile.
Definition: RootDataConnection.h:159
std::unique_ptr::reset
T reset(T...args)
std::unique_ptr::get
T get(T...args)
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155
Gaudi::RootDataConnection::m_refs
TTree * m_refs
Pointer to the reference tree.
Definition: RootDataConnection.h:157
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi::RootDataConnection::badWriteError
void badWriteError(const std::string &msg) const
Error handler when bad write statements occur.
Definition: RootDataConnection.cpp:172

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

Empty string reference.

Definition at line 457 of file RootDataConnection.cpp.

457 {
458 return s_empty;
459 }

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

Enable TTreePerStats.

Definition at line 187 of file RootDataConnection.cpp.

187 {
188 if ( m_statistics ) {
189 TTree* t=getSection(section,false);
190 if ( t ) {
191 m_statistics.reset( new TTreePerfStats((section+"_ioperf").c_str(),t) );
192 return;
193 }
194 msgSvc() << MSG::WARNING << "Failed to enable perfstats for tree:" << section << endmsg;
195 return;
196 }
197 msgSvc() << MSG::INFO << "Perfstats are ALREADY ENABLED." << endmsg;
198 }
Gaudi::RootDataConnection::m_statistics
std::unique_ptr< TTreePerfStats > m_statistics
I/O read statistics from TTree.
Definition: RootDataConnection.h:153
Gaudi::RootDataConnection::getSection
TTree * getSection(const std::string &sect, bool create=false)
Access TTree section from section name. The section is created if required.
Definition: RootDataConnection.cpp:355
std::unique_ptr::reset
T reset(T...args)
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
MSG::WARNING
Definition: IMessageSvc.h:20
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Direct access to TFile structure.

Definition at line 247 of file RootDataConnection.h.

247 { return m_file.get(); }
std::unique_ptr::get
T get(T...args)
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155

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

308 { return m_tool->getBranch(section,branch_name); }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233

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

325 { return (which>=0)&&(size_t(which)<m_conts.size()) ? *(m_conts.begin()+which) : empty(); }
Gaudi::RootDataConnection::m_conts
StringVec m_conts
Map containing external container names.
Definition: RootDataConnection.h:163
Gaudi::RootDataConnection::empty
const std::string & empty() const
Empty string reference.
Definition: RootDataConnection.cpp:457
std::vector::size
T size(T...args)
std::vector::begin
T begin(T...args)
GaudiTesting.BaseTest.which
def which(executable)
Definition: BaseTest.py:535

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

Access database/file name from saved index.

Definition at line 448 of file RootDataConnection.cpp.

448 {
449 if ( (which>=0) && (size_t(which)<m_dbs.size()) ) {
450 if ( *(m_dbs.begin()+which) == s_local ) return m_fid;
451 return *(m_dbs.begin()+which);
452 }
453 return s_empty;
454 }
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
std::vector::size
T size(T...args)
std::vector::begin
T begin(T...args)
GaudiTesting.BaseTest.which
def which(executable)
Definition: BaseTest.py:535
Gaudi::RootDataConnection::m_dbs
StringVec m_dbs
Map containing external database file names (fids)
Definition: RootDataConnection.h:161

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

Access link name from saved index.

Definition at line 328 of file RootDataConnection.h.

329 { return (which>=0)&&(size_t(which)<m_links.size()) ? *(m_links.begin()+which) : empty(); }
Gaudi::RootDataConnection::m_links
StringVec m_links
Map containing internal links names.
Definition: RootDataConnection.h:165
Gaudi::RootDataConnection::empty
const std::string & empty() const
Empty string reference.
Definition: RootDataConnection.cpp:457
std::vector::size
T size(T...args)
std::vector::begin
T begin(T...args)
GaudiTesting.BaseTest.which
def which(executable)
Definition: BaseTest.py:535

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

576 {
577 //size_t idx = cont.find('/',1);
578 //string container = cont[0]=='/' ? cont.substr(1,idx==string::npos?idx:idx-1) : cont;
579 auto i=m_mergeSects.find(container);
580 if ( i != m_mergeSects.end() ) {
581 size_t cnt = 0;
582 const ContainerSections& s = (*i).second;
583 for(auto j=s.cbegin(); j != s.cend(); ++j,++cnt) {
584 const ContainerSection& c = *j;
585 if ( entry >= c.start && entry < (c.start+c.length) ) {
586 if ( m_linkSects.size() > cnt ) {
587 if ( msgSvc().isActive() ) {
588 msgSvc() << MSG::VERBOSE << "MergeSection for:" << container
589 << " [" << entry << "]" << endmsg
590 << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
591 }
592 return { &(m_linkSects[cnt]), &c };
593 }
594 }
595 }
596 }
597 msgSvc() << MSG::DEBUG << "Return INVALID MergeSection for:" << container
598 << " [" << entry << "]" << endmsg
599 << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
600 return { nullptr, nullptr };
601 }
Gaudi::RootDataConnection::m_mergeSects
MergeSections m_mergeSects
Database section map for merged files.
Definition: RootDataConnection.h:171
gaudirun.c
c
Definition: gaudirun.py:391
Gaudi::RootDataConnection::ContainerSections
std::vector< ContainerSection > ContainerSections
Definition of container sections to handle merged files.
Definition: RootDataConnection.h:137
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
MSG::DEBUG
Definition: IMessageSvc.h:18
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
std::map::end
T end(T...args)
MSG::VERBOSE
Definition: IMessageSvc.h:17
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:31
std::map::find
T find(T...args)
std::vector::size
T size(T...args)
Gaudi::RootDataConnection::m_linkSects
LinkSections m_linkSects
Database link sections.
Definition: RootDataConnection.h:173
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
gaudirun.s
string s
Definition: gaudirun.py:245
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

355 {
356 TTree* t = m_sections[section];
357 if ( !t ) {
358 t = (TTree*)m_file->Get(section.c_str());
359 if ( !t && create ) {
360 TDirectory::TContext ctxt(m_file.get());
361 t = new TTree(section.c_str(),"Root data for Gaudi");
362 }
363 if ( t ) {
364 int cacheSize = m_setup->cacheSize;
365 if ( create ) {
366 //t->SetAutoFlush(100);
367 }
368 if ( section == m_setup->loadSection && cacheSize>-2 ) {
369 MsgStream& msg = msgSvc();
370 int learnEntries = m_setup->learnEntries;
371 t->SetCacheSize(cacheSize);
372 t->SetCacheLearnEntries(learnEntries);
373 msg << MSG::DEBUG;
374 if ( create ) {
375 msg << "Tree:" << section << "Setting up tree cache:" << cacheSize << endmsg;
376 }
377 else {
378 const StringVec& vB = m_setup->vetoBranches;
379 const StringVec& cB = m_setup->cacheBranches;
380 msg << "Tree:" << section << " Setting up tree cache:" << cacheSize << " Add all branches." << endmsg;
381 msg << "Tree:" << section << " Learn for " << learnEntries << " entries." << endmsg;
382
383 if ( cB.empty() && vB.empty()) {
384 msg << "Adding (default) all branches to tree cache." << endmsg;
385 t->AddBranchToCache("*",kTRUE);
386 }
387 if ( cB.size()==1 && cB[0]=="*" ) {
388 msg << "Adding all branches to tree cache according to option \"CacheBranches\"." << endmsg;
389 t->AddBranchToCache("*",kTRUE);
390 }
391 else {
392 for(TIter it(t->GetListOfBranches()); it.Next(); ) {
393 const char* n = ((TNamed*)(*it))->GetName();
394 bool add = false, veto = false;
395 for(const auto& i : cB ) {
396 if ( !match_wild(n,(i).c_str()) ) continue;
397 add = true;
398 break;
399 }
400 for(auto i=vB.cbegin(); !add && i!=vB.cend();++i) {
401 if ( !match_wild(n,(*i).c_str()) ) continue;
402 veto = true;
403 break;
404 }
405 if ( add && !veto ) {
406 msg << "Add " << n << " to branch cache." << endmsg;
407 t->AddBranchToCache(n,kTRUE);
408 }
409 else {
410 msg << "Do not cache branch " << n << endmsg;
411 }
412 }
413 }
414 }
415 }
416 m_sections[section] = t;
417 }
418 }
419 return t;
420 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MSG::DEBUG
Definition: IMessageSvc.h:18
Gaudi::RootDataConnection::StringVec
std::vector< std::string > StringVec
Type definition for string maps.
Definition: RootDataConnection.h:131
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
GaudiPython.Persistency.add
def add(instance)
Definition: Persistency.py:32
Gaudi::RootDataConnection::m_sections
Sections m_sections
Tree sections in TFile.
Definition: RootDataConnection.h:159
std::unique_ptr::get
T get(T...args)
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Check if connected to data source.

Implements Gaudi::IDataConnection.

Definition at line 249 of file RootDataConnection.h.

249 { return bool(m_file); }
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155

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

Is the file writable?

Definition at line 251 of file RootDataConnection.h.

251 { return m_file && m_file->IsWritable(); }
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155

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

Load object.

Definition at line 499 of file RootDataConnection.cpp.

499 {
500 TBranch* b = getBranch(section,cnt);
501 if ( b ) {
502 TClass* cl = gROOT->GetClass(b->GetClassName(),kTRUE);
503 if ( cl ) {
504 int nb = -1;
505 pObj = (DataObject*)cl->New();
506 {
507 DataObjectPush push(pObj);
508 b->SetAddress(&pObj);
509 if ( section == m_setup->loadSection ) {
510 TTree* t = b->GetTree();
511 if ( Long64_t(entry) != t->GetReadEntry() ) {
512 t->LoadTree(Long64_t(entry));
513 }
514 }
515 nb = b->GetEntry(entry);
516 msgSvc() << MSG::VERBOSE;
517 if ( msgSvc().isActive() ) {
518 msgSvc() << "Load [" << entry << "] --> " << section
519 << ":" << cnt << " " << nb << " bytes."
520 << endmsg;
521 }
522 if ( nb < 0 ) { // This is definitely an error...ROOT says if reads fail, -1 is issued.
523 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
524 IIncidentSvc* inc = m_setup->incidentSvc();
525 if ( inc ) {
526 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
527 }
528 #endif
529 }
530 else if ( nb == 0 && pObj->clID() == CLID_DataObject) {
531 TFile* f = b->GetFile();
532 int vsn = f->GetVersion();
533 if ( vsn < 52400 ) {
534 // For Gaudi v21r5 (ROOT 5.24.00b) DataObject::m_version was not written!
535 // Still this call be well be successful.
536 nb = 1;
537 }
538 else if ( vsn>1000000 && (vsn%1000000)<52400 ) {
539 // dto. Some POOL files have for unknown reasons a version
540 // not according to ROOT standards. Hack this explicitly.
541 nb = 1;
542 }
543 }
544 if ( nb < 0 ) {
545 delete pObj;
546 pObj = nullptr;
547 }
548 }
549 return nb;
550 }
551 }
552 return -1;
553 }
MSG::VERBOSE
Definition: IMessageSvc.h:17
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
Gaudi::RootDataConnection::getBranch
TBranch * getBranch(const std::string &section, const std::string &branch_name)
Access data branch by name: Get existing branch in read only mode.
Definition: RootDataConnection.h:307
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23

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

Load references object.

Definition at line 556 of file RootDataConnection.cpp.

558 {
559 int nbytes = m_tool->loadRefs(section,cnt,entry,refs);
560 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,33,0)
561 if ( nbytes < 0 ) {
562 // This is definitely an error:
563 // -- Either branch not preesent at all or
564 // -- ROOT I/O error, which issues -1
565 IIncidentSvc* inc = m_setup->incidentSvc();
566 if ( inc ) {
567 inc->fireIncident(Incident(pfn(),IncidentType::CorruptedInputFile));
568 }
569 }
570 #endif
571 return nbytes;
572 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:54
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23

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

Lookup client for this data source.

Definition at line 166 of file RootDataConnection.cpp.

166 {
167 auto i=m_clients.find(client);
168 return i != m_clients.end();
169 }
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:175
std::set::end
T end(T...args)
std::set::find
T find(T...args)

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

Convert path string to path index.

Definition at line 440 of file RootDataConnection.cpp.

440 {
441 auto ip = std::find(std::begin(m_links),std::end(m_links),p);
442 if (ip!=std::end(m_links)) return std::distance(std::begin(m_links),ip);
443 m_links.push_back(p);
444 return m_links.size()-1;
445 }
std::distance
T distance(T...args)
std::end
T end(T...args)
Gaudi::RootDataConnection::m_links
StringVec m_links
Map containing internal links names.
Definition: RootDataConnection.h:165
std::vector::push_back
T push_back(T...args)
std::find
T find(T...args)
std::vector::size
T size(T...args)
std::begin
T begin(T...args)

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

Create reference object from registry entry.

Definition at line 604 of file RootDataConnection.cpp.

604 {
605 IOpaqueAddress* pA = pR->address();
606 makeRef(pR->name(),pA->clID(),pA->svcType(),pA->par()[0],pA->par()[1],-1,ref);
607 }
IOpaqueAddress::clID
virtual const CLID & clID() const =0
Retrieve class information from link.
IOpaqueAddress::par
virtual const std::string * par() const =0
Retrieve String parameters.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
Gaudi::RootDataConnection::makeRef
void makeRef(IRegistry *pA, RootRef &ref)
Create reference object from registry entry.
Definition: RootDataConnection.cpp:604
IOpaqueAddress::svcType
virtual long svcType() const =0
Retrieve service type.
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.

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

201 {
202 if ( !m_refs ) m_refs = (TTree*)m_file->Get("Refs");
203 if ( m_refs )
204 m_tool.reset( new RootTool(this) );
205 #ifdef __POOL_COMPATIBILITY
206 else if ( m_file->Get("##Links") != nullptr )
207 m_tool.reset(new PoolTool(this));
208 #endif
209 else
210 m_tool.reset();
211 return m_tool.get();
212 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233
Gaudi::RootTool
Description:
Definition: RootTool.h:16
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:155
Gaudi::RootDataConnection::m_refs
TTree * m_refs
Pointer to the reference tree.
Definition: RootDataConnection.h:157
Gaudi::PoolTool
Definition: PoolTool.h:18

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

Access merged FIDs.

Definition at line 257 of file RootDataConnection.h.

257 { return m_mergeFIDs; }
Gaudi::RootDataConnection::m_mergeFIDs
StringVec m_mergeFIDs
Map containing merge FIDs.
Definition: RootDataConnection.h:167

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

Access merged data section inventory.

Definition at line 255 of file RootDataConnection.h.

255 { return m_mergeSects; }
Gaudi::RootDataConnection::m_mergeSects
MergeSections m_mergeSects
Database section map for merged files.
Definition: RootDataConnection.h:171

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

Allow access to printer service.

Definition at line 146 of file RootDataConnection.h.

146 { return m_setup->msgSvc(); }
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:151

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

Read root byte buffer from input stream.

Implements Gaudi::IDataConnection.

Definition at line 297 of file RootDataConnection.h.

297 { return StatusCode::FAILURE; }
StatusCode::FAILURE
Definition: StatusCode.h:29

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

Remove client from this data source.

Definition at line 159 of file RootDataConnection.cpp.

159 {
160 auto i=m_clients.find(client);
161 if ( i != m_clients.end() ) m_clients.erase(i);
162 return m_clients.size();
163 }
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:175
std::set::end
T end(T...args)
std::set::erase
T erase(T...args)
std::set::find
T find(T...args)
std::set::size
T size(T...args)

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

470 {
471 split_lvl = 0;
472 TBranch* b = getBranch(section, cnt, cl, pObj ? &pObj : nullptr, buff_siz, split_lvl);
473 if ( b ) {
474 Long64_t evt = b->GetEntries();
475 //msgSvc() << MSG::DEBUG << cnt.c_str() << " Obj:" << (void*)pObj
476 // << " Split:" << split_lvl << " Buffer size:" << buff_siz << endl;
477 if ( fill_missing ) {
478 Long64_t num, nevt = b->GetTree()->GetEntries();
479 if ( nevt > evt ) {
480 b->SetAddress(nullptr);
481 num = nevt - evt;
482 while( num > 0 ) { b->Fill(); --num; }
483 msgSvc() << MSG::DEBUG << "Added " << long(nevt-evt)
484 << " / Tree: " << nevt << " / Branch: " << b->GetEntries()+1
485 << " NULL entries to:" << cnt << endmsg;
486 evt = b->GetEntries();
487 }
488 }
489 b->SetAddress(&pObj);
490 return {b->Fill(),evt};
491 }
492 if ( pObj ) {
493 msgSvc() << MSG::ERROR << "Failed to access branch " << m_name << "/" << cnt << endmsg;
494 }
495 return {-1,~0};
496 }
Gaudi::IDataConnection::m_name
std::string m_name
Connection name/identifier.
Definition: IIODataManager.h:27
MSG::DEBUG
Definition: IMessageSvc.h:18
Gaudi::RootDataConnection::getBranch
TBranch * getBranch(const std::string &section, const std::string &branch_name)
Access data branch by name: Get existing branch in read only mode.
Definition: RootDataConnection.h:307
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:146
MSG::ERROR
Definition: IMessageSvc.h:21
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
IOTest.evt
evt
Definition: IOTest.py:85

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

463 {
464 DataObjectPush push(pObj);
465 return save(section,cnt,cl,pObj,buff_siz,split_lvl,fill);
466 }
Gaudi::Utils::Histos::fill
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:36
Gaudi::RootDataConnection::save
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.
Definition: RootDataConnection.cpp:470

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

177 {
178 if ( m_statistics ) {
179 m_statistics->Print();
180 if ( !statisticsFile.empty() )
181 m_statistics->SaveAs(statisticsFile.c_str());
182 m_statistics.reset();
183 }
184 }
std::string::empty
T empty(T...args)
Gaudi::RootDataConnection::m_statistics
std::unique_ptr< TTreePerfStats > m_statistics
I/O read statistics from TTree.
Definition: RootDataConnection.h:153
std::unique_ptr::reset
T reset(T...args)
std::string::c_str
T c_str(T...args)

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

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

Implements Gaudi::IDataConnection.

Definition at line 301 of file RootDataConnection.h.

301 { return -1; }

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

Access tool.

Definition at line 253 of file RootDataConnection.h.

253 { return m_tool.get(); }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:233

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

Write root byte buffer to output stream.

Implements Gaudi::IDataConnection.

Definition at line 299 of file RootDataConnection.h.

299 { return StatusCode::FAILURE; }
StatusCode::FAILURE
Definition: StatusCode.h:29

## Friends And Related Function Documentation

friend class Tool
| friend

Definition at line 234 of file RootDataConnection.h.

## Member Data Documentation

Clients Gaudi::RootDataConnection::m_clients
| protected

Client list.

Definition at line 175 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_conts
| protected

Map containing external container names.

Definition at line 163 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_dbs
| protected

Map containing external database file names (fids)

Definition at line 161 of file RootDataConnection.h.

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

Buffer for empty string reference.

Definition at line 177 of file RootDataConnection.h.

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

Reference to ROOT file.

Definition at line 155 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_links
| protected

Map containing internal links names.

Definition at line 165 of file RootDataConnection.h.

LinkSections Gaudi::RootDataConnection::m_linkSects
| protected

Database link sections.

Definition at line 173 of file RootDataConnection.h.

StringVec Gaudi::RootDataConnection::m_mergeFIDs
| protected

Map containing merge FIDs.

Definition at line 167 of file RootDataConnection.h.

MergeSections Gaudi::RootDataConnection::m_mergeSects
| protected

Database section map for merged files.

Definition at line 171 of file RootDataConnection.h.

ParamMap Gaudi::RootDataConnection::m_params
| protected

Parameter map for file parameters.

Definition at line 169 of file RootDataConnection.h.

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

Pointer to the reference tree.

Definition at line 157 of file RootDataConnection.h.

Sections Gaudi::RootDataConnection::m_sections
| protected

Tree sections in TFile.

Definition at line 159 of file RootDataConnection.h.

std::shared_ptr<RootConnectionSetup> Gaudi::RootDataConnection::m_setup
| protected

Reference to the setup structure.

Definition at line 151 of file RootDataConnection.h.

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

I/O read statistics from TTree.

Definition at line 153 of file RootDataConnection.h.

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

Definition at line 233 of file RootDataConnection.h.

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

- RootCnv/RootCnv/RootDataConnection.h
- RootCnv/src/RootDataConnection.cpp