| The Gaudi Framework v32r1 (f65d50dc)

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 | Status : StatusCode::code_t { Status::ROOT_READ_ERROR = 0x2, Status::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 *, std::less<> > | 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, std::less<> > | 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, std::string_view nam, std::shared_ptr< RootConnectionSetup > setup)
| Standard constructor. 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 (std::string_view msg) const
| Error handler when bad write statements occur. More...
std::pair< const RootRef *, const ContainerSection * > | getMergeSection (std::string_view container, int entry) const
| Access link section for single container and entry. More...
void | enableStatistics (std::string_view section)
| Enable TTreePerStats. More...
void | saveStatistics (std::string_view statisticsFile)
| Save TTree access statistics if required. More...
int | loadObj (std::string_view section, std::string_view cnt, unsigned long entry, DataObject *&pObj)
| Load object. More...
int | loadRefs (std::string_view section, std::string_view cnt, unsigned long entry, RootObjectRefs &refs)
| Load references object. More...
std::pair< int, unsigned long > | saveObj (std::string_view section, std::string_view 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 (std::string_view section, std::string_view 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 (std::string_view sect, bool create=false)
| Access TTree section from section name. The section is created if required. More...
TBranch * | getBranch (std::string_view section, std::string_view branch_name)
| Access data branch by name: Get existing branch in read only mode. More...
TBranch * | getBranch (std::string_view section, std::string_view 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 (const IRegistry &pA, RootRef &ref)
| Create reference object from registry entry. More...
void | makeRef (std::string_view name, long clid, int tech, std::string_view db, std::string_view cnt, int entry, RootRef &ref)
| Create reference object from values. More...
int | makeLink (std::string_view 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 93 of file RootDataConnection.h.

## Member Typedef Documentation

## ◆ Clients

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

Client set.

Definition at line 141 of file RootDataConnection.h.

## ◆ ContainerSections

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

Definition of container sections to handle merged files.

Definition at line 135 of file RootDataConnection.h.

## ◆ LinkSections

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

Link sections definition.

Definition at line 139 of file RootDataConnection.h.

## ◆ MergeSections

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

Definition of database section to handle merged files.

Definition at line 137 of file RootDataConnection.h.

## ◆ ParamMap

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

Type definition for the parameter map.

Definition at line 131 of file RootDataConnection.h.

## ◆ Sections

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

Definition of tree sections.

Definition at line 133 of file RootDataConnection.h.

## ◆ StringVec

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

Type definition for string maps.

Definition at line 129 of file RootDataConnection.h.

## Member Enumeration Documentation

## ◆ Status

enum Gaudi::RootDataConnection::Status : StatusCode::code_t
| strong

Enumerator
ROOT_READ_ERROR |
ROOT_OPEN_ERROR |

Definition at line 95 of file RootDataConnection.h.

95 : StatusCode::code_t { ROOT_READ_ERROR = 0x2, ROOT_OPEN_ERROR = 0x4 };
StatusCode::code_t
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:52

## Constructor & Destructor Documentation

## ◆ RootDataConnection()

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

Standard constructor.

Definition at line 153 of file RootDataConnection.cpp.

155 : IDataConnection( owner, std::string{fname} )
156 , m_setup( std::move( setup ) ) { // 01234567890123456789012345678901234567890
157 // Check if FID: A82A3BD8-7ECB-DC11-8DC0-000423D950B0
158 if ( fname.size() == 36 && fname[8] == '-' && fname[13] == '-' && fname[18] == '-' && fname[23] == '-' ) {
159 m_name = "FID:";
160 m_name.append( fname.data(), fname.size() );
161 }
162 m_age = 0;
163 m_file.reset();
164 addClient( owner );
165 }
Gaudi::RootDataConnection::addClient
void addClient(const IInterface *client)
Add new client to this data source.
Definition: RootDataConnection.cpp:168
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:45
Gaudi::IDataConnection::owner
const IInterface * owner() const
Owner instance.
Definition: IIODataManager.h:65
std::string
STL class.
std::string::append
T append(T... args)
std::unique_ptr::reset
T reset(T... args)
std::move
T move(T... args)
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:148
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:152

## Member Function Documentation

## ◆ addClient()

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

Add new client to this data source.

Definition at line 168 of file RootDataConnection.cpp.

168 { m_clients.insert( client ); }
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:172
std::set::insert
T insert(T... args)

## ◆ badWriteError()

void RootDataConnection::badWriteError | ( | std::string_view | msg | ) | const

Error handler when bad write statements occur.

Definition at line 184 of file RootDataConnection.cpp.

184 {
185 msgSvc() << MSG::ERROR << "File:" << fid() << "Failed action:" << msg << endmsg;
186 }
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:53
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:144
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
MSG::ERROR
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ connectRead()

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

Open data stream in read mode.

Connect the file in READ mode.

Implements Gaudi::IDataConnection.

Definition at line 225 of file RootDataConnection.cpp.

225 {
226 m_file.reset( TFile::Open( m_pfn.c_str() ) );
227 if ( !m_file || m_file->IsZombie() ) {
228 m_file.reset();
229 return StatusCode::FAILURE;
230 }
231 StatusCode sc = StatusCode::FAILURE;
232 msgSvc() << MSG::DEBUG << "Opened file " << m_pfn << " in mode READ. [" << m_fid << "]" << endmsg << MSG::DEBUG;
233 if ( msgSvc().isActive() ) m_file->ls();
234 msgSvc() << MSG::VERBOSE;
235 if ( msgSvc().isActive() ) m_file->Print();
236 if ( makeTool() ) {
237 sc = m_tool->readRefs();
238 sc.ignore();
239 #if ROOT_VERSION_CODE >= ROOT_VERSION( 5, 33, 0 )
240 if ( sc == Status::ROOT_READ_ERROR ) {
241 IIncidentSvc* inc = m_setup->incidentSvc();
242 if ( inc ) { inc->fireIncident( Incident( pfn(), IncidentType::CorruptedInputFile ) ); }
243 }
244 #endif
245 }
246 if ( !sc.isSuccess() ) return sc;
247 bool need_fid = m_fid == m_pfn;
248 string fid = m_fid;
249 m_mergeFIDs.clear();
250 for ( auto& elem : m_params ) {
251 if ( elem.first == "FID" ) {
252 m_mergeFIDs.push_back( elem.second );
253 if ( elem.second != m_fid ) {
254 msgSvc() << MSG::DEBUG << "Check FID param:" << elem.second << endmsg;
255 // if ( m_fid == m_pfn ) {
256 m_fid = elem.second;
257 //}
258 }
259 }
260 }
261 if ( !need_fid && fid != m_fid ) {
262 msgSvc() << MSG::ERROR << "FID mismatch:" << fid << "(Catalog) != " << m_fid << "(file)" << endmsg
263 << "for PFN:" << m_pfn << endmsg;
264 return StatusCode::FAILURE;
265 }
266 msgSvc() << MSG::DEBUG << "Using FID " << m_fid << " from params table...." << endmsg << "for PFN:" << m_pfn
267 << endmsg;
268 return sc;
269 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:232
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
MSG::DEBUG
Definition: IMessageSvc.h:15
Gaudi::IDataConnection::fid
const std::string & fid() const
Access file id.
Definition: IIODataManager.h:53
MSG::VERBOSE
Definition: IMessageSvc.h:15
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:144
Gaudi::RootDataConnection::m_params
ParamMap m_params
Parameter map for file parameters.
Definition: RootDataConnection.h:166
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:55
Gaudi::RootDataConnection::m_mergeFIDs
StringVec m_mergeFIDs
Map containing merge FIDs.
Definition: RootDataConnection.h:164
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)
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:50
std::unique_ptr::reset
T reset(T... args)
std::vector::clear
T clear(T... args)
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
Gaudi::RootDataConnection::makeTool
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
Definition: RootDataConnection.cpp:212
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:148
std::string::c_str
T c_str(T... args)
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:152
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23

## ◆ connectWrite()

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

Open data stream in write mode.

Implements Gaudi::IDataConnection.

Definition at line 272 of file RootDataConnection.cpp.

272 {
273 int compress = RootConnectionSetup::compression();
274 msgSvc() << MSG::DEBUG;
275 switch ( typ ) {
276 case CREATE:
277 resetAge();
278 m_file.reset( TFile::Open( m_pfn.c_str(), "CREATE", "Root event data", compress ) );
279 m_refs = new TTree( "Refs", "Root reference data" );
280 msgSvc() << "Opened file " << m_pfn << " in mode CREATE. [" << m_fid << "]" << endmsg;
281 m_params.emplace_back( "PFN", m_pfn );
282 if ( m_fid != m_pfn ) { m_params.emplace_back( "FID", m_fid ); }
283 makeTool();
284 break;
285 case RECREATE:
286 resetAge();
287 m_file.reset( TFile::Open( m_pfn.c_str(), "RECREATE", "Root event data", compress ) );
288 msgSvc() << "Opened file " << m_pfn << " in mode RECREATE. [" << m_fid << "]" << endmsg;
289 m_refs = new TTree( "Refs", "Root reference data" );
290 m_params.emplace_back( "PFN", m_pfn );
291 if ( m_fid != m_pfn ) { m_params.emplace_back( "FID", m_fid ); }
292 makeTool();
293 break;
294 case UPDATE:
295 resetAge();
296 m_file.reset( TFile::Open( m_pfn.c_str(), "UPDATE", "Root event data", compress ) );
297 msgSvc() << "Opened file " << m_pfn << " in mode UPDATE. [" << m_fid << "]" << endmsg;
298 if ( m_file && !m_file->IsZombie() ) {
299 if ( makeTool() ) {
300 StatusCode sc = m_tool->readRefs();
301 sc.ignore();
302 if ( sc == Status::ROOT_READ_ERROR ) {
303 #if ROOT_VERSION_CODE >= ROOT_VERSION( 5, 33, 0 )
304 IIncidentSvc* inc = m_setup->incidentSvc();
305 if ( inc ) { inc->fireIncident( Incident( pfn(), IncidentType::CorruptedInputFile ) ); }
306 #endif
307 }
308 return sc;
309 }
310 TDirectory::TContext ctxt( m_file.get() );
311 m_refs = new TTree( "Refs", "Root reference data" );
312 makeTool();
313 return StatusCode::SUCCESS;
314 }
315 break;
316 default:
317 m_refs = nullptr;
318 m_file.reset();
319 return StatusCode::FAILURE;
320 }
321 return m_file ? StatusCode::SUCCESS : StatusCode::FAILURE;
322 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:232
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:144
MSG::DEBUG
Definition: IMessageSvc.h:15
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::IDataConnection::RECREATE
Definition: IIODataManager.h:39
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:144
Gaudi::RootDataConnection::m_params
ParamMap m_params
Parameter map for file parameters.
Definition: RootDataConnection.h:166
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:55
Gaudi::IDataConnection::m_pfn
std::string m_pfn
Physical file name of the connection.
Definition: IIODataManager.h:31
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:50
std::unique_ptr::reset
T reset(T... args)
Gaudi::RootDataConnection::makeTool
Tool * makeTool()
Create file access tool to encapsulate POOL compatibiliy.
Definition: RootDataConnection.cpp:212
Gaudi::IDataConnection::UPDATE
Definition: IIODataManager.h:39
std::unique_ptr::get
T get(T... args)
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
Gaudi::IDataConnection::CREATE
Definition: IIODataManager.h:39
Gaudi::RootDataConnection::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Reference to the setup structure.
Definition: RootDataConnection.h:148
Gaudi::IDataConnection::resetAge
void resetAge()
Reset age.
Definition: IIODataManager.h:61
std::string::c_str
T c_str(T... args)
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:152
Gaudi::RootDataConnection::m_refs
TTree * m_refs
Pointer to the reference tree.
Definition: RootDataConnection.h:154
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
std::vector::emplace_back
T emplace_back(T... args)

## ◆ disconnect()

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

Release data stream and release implementation dependent resources.

Implements Gaudi::IDataConnection.

Definition at line 325 of file RootDataConnection.cpp.

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

## ◆ empty()

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

Empty string reference.

Definition at line 457 of file RootDataConnection.cpp.

457 { return s_empty; }

## ◆ enableStatistics()

void RootDataConnection::enableStatistics | ( | std::string_view | section | ) |

Enable TTreePerStats.

Definition at line 198 of file RootDataConnection.cpp.

198 {
199 if ( m_statistics ) {
200 TTree* t = getSection( section, false );
201 if ( t ) {
202 m_statistics.reset( new TTreePerfStats( ( std::string{section} + "_ioperf" ).c_str(), t ) );
203 return;
204 }
205 msgSvc() << MSG::WARNING << "Failed to enable perfstats for tree:" << section << endmsg;
206 return;
207 }
208 msgSvc() << MSG::INFO << "Perfstats are ALREADY ENABLED." << endmsg;
209 }
Gaudi::RootDataConnection::m_statistics
std::unique_ptr< TTreePerfStats > m_statistics
I/O read statistics from TTree.
Definition: RootDataConnection.h:150
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:144
std::string
STL class.
Gaudi::RootDataConnection::getSection
TTree * getSection(std::string_view sect, bool create=false)
Access TTree section from section name. The section is created if required.
Definition: RootDataConnection.cpp:357
std::unique_ptr::reset
T reset(T... args)
MSG::WARNING
Definition: IMessageSvc.h:15
MSG::INFO
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ file()

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

Direct access to TFile structure.

Definition at line 243 of file RootDataConnection.h.

243 { 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:152

## ◆ getBranch() [1/2]

TBranch* Gaudi::RootDataConnection::getBranch | ( | std::string_view | section,
|  | std::string_view | branch_name
| ) |  |
| inline

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

Definition at line 303 of file RootDataConnection.h.

303 {
304 return m_tool->getBranch( section, branch_name );
305 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:232

## ◆ getBranch() [2/2]

TBranch * RootDataConnection::getBranch | ( | std::string_view | section,
|  | std::string_view | branch_name,
|  | TClass * | cl,
|  | void * | ptr,
|  | int | buff_siz,
|  | int | split_lvl
| ) |  |

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

Definition at line 423 of file RootDataConnection.cpp.

424 {
425 string n = std::string{branch_name};
426 std::replace_if(
427 begin( n ), end( n ), []( const char c ) { return !isalnum( c ); }, '_' );
428 n += ".";
429 TTree* t = getSection( section, true );
430 TBranch* b = t->GetBranch( n.c_str() );
431 if ( !b && cl && m_file->IsWritable() ) {
432 b = t->Branch( n.c_str(), cl->GetName(), (void*)( ptr ? &ptr : nullptr ), buff_siz, split_lvl );
433 }
434 if ( !b ) b = t->GetBranch( std::string{branch_name}.c_str() );
435 if ( b ) b->SetAutoDelete( kFALSE );
436 return b;
437 }
gaudirun.c
c
Definition: gaudirun.py:487
std::isalnum
T isalnum(T... args)
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
std::replace_if
T replace_if(T... args)
Gaudi::RootDataConnection::getSection
TTree * getSection(std::string_view sect, bool create=false)
Access TTree section from section name. The section is created if required.
Definition: RootDataConnection.cpp:357
IOTest.end
def end
Definition: IOTest.py:112
std::string::c_str
T c_str(T... args)
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:152

## ◆ getCont()

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

Access container name from saved index.

Definition at line 323 of file RootDataConnection.h.

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

## ◆ getDb()

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:632
Gaudi::RootDataConnection::m_dbs
StringVec m_dbs
Map containing external database file names (fids)
Definition: RootDataConnection.h:158

## ◆ getLink()

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

Access link name from saved index.

Definition at line 328 of file RootDataConnection.h.

328 {
329 return ( which >= 0 ) && ( size_t( which ) < m_links.size() ) ? *( m_links.begin() + which ) : empty();
330 }
Gaudi::RootDataConnection::m_links
StringVec m_links
Map containing internal links names.
Definition: RootDataConnection.h:162
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:632

## ◆ getMergeSection()

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

Access link section for single container and entry.

Definition at line 564 of file RootDataConnection.cpp.

564 {
565 // size_t idx = cont.find('/',1);
566 // string container = cont[0]=='/' ? cont.substr(1,idx==string::npos?idx:idx-1) : cont;
567 auto i = m_mergeSects.find( container );
568 if ( i != m_mergeSects.end() ) {
569 size_t cnt = 0;
570 const ContainerSections& s = ( *i ).second;
571 for ( auto j = s.cbegin(); j != s.cend(); ++j, ++cnt ) {
572 const ContainerSection& c = *j;
573 if ( entry >= c.start && entry < ( c.start + c.length ) ) {
574 if ( m_linkSects.size() > cnt ) {
575 if ( msgSvc().isActive() ) {
576 msgSvc() << MSG::VERBOSE << "MergeSection for:" << container << " [" << entry << "]" << endmsg
577 << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
578 }
579 return {&( m_linkSects[cnt] ), &c};
580 }
581 }
582 }
583 }
584 msgSvc() << MSG::DEBUG << "Return INVALID MergeSection for:" << container << " [" << entry << "]" << endmsg
585 << "FID:" << m_fid << " -> PFN:" << m_pfn << endmsg;
586 return {nullptr, nullptr};
587 }
Gaudi::RootDataConnection::m_mergeSects
MergeSections m_mergeSects
Database section map for merged files.
Definition: RootDataConnection.h:168
MsgStream::isActive
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:111
gaudirun.c
c
Definition: gaudirun.py:487
Gaudi::RootDataConnection::ContainerSections
std::vector< ContainerSection > ContainerSections
Definition of container sections to handle merged files.
Definition: RootDataConnection.h:135
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
MSG::DEBUG
Definition: IMessageSvc.h:15
std::map::end
T end(T... args)
MSG::VERBOSE
Definition: IMessageSvc.h:15
Gaudi::RootDataConnection::msgSvc
MsgStream & msgSvc() const
Allow access to printer service.
Definition: RootDataConnection.h:144
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)
std::string::cbegin
T cbegin(T... args)
Gaudi::RootDataConnection::m_linkSects
LinkSections m_linkSects
Database link sections.
Definition: RootDataConnection.h:170
gaudirun.s
string s
Definition: gaudirun.py:316
Gaudi::ContainerSection
Definition: merge.C:23
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ getSection()

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

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

Definition at line 357 of file RootDataConnection.cpp.

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

## ◆ isConnected()

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

Check if connected to data source.

Implements Gaudi::IDataConnection.

Definition at line 245 of file RootDataConnection.h.

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

## ◆ isWritable()

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

Is the file writable?

Definition at line 247 of file RootDataConnection.h.

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

## ◆ loadObj()

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

Load object.

Definition at line 497 of file RootDataConnection.cpp.

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

## ◆ loadRefs()

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

Load references object.

Definition at line 547 of file RootDataConnection.cpp.

548 {
549 int nbytes = m_tool->loadRefs( section, cnt, entry, refs );
550 #if ROOT_VERSION_CODE >= ROOT_VERSION( 5, 33, 0 )
551 if ( nbytes < 0 ) {
552 // This is definitely an error:
553 // -- Either branch not preesent at all or
554 // -- ROOT I/O error, which issues -1
555 IIncidentSvc* inc = m_setup->incidentSvc();
556 if ( inc ) { inc->fireIncident( Incident( pfn(), IncidentType::CorruptedInputFile ) ); }
557 }
558 #endif
559 return nbytes;
560 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:232
Gaudi::IDataConnection::pfn
const std::string & pfn() const
Access physical file name.
Definition: IIODataManager.h:55
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:148
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23

## ◆ lookupClient()

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

Lookup client for this data source.

Definition at line 178 of file RootDataConnection.cpp.

178 {
179 auto i = m_clients.find( client );
180 return i != m_clients.end();
181 }
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:172
std::set::end
T end(T... args)
std::set::find
T find(T... args)

## ◆ makeLink()

int RootDataConnection::makeLink | ( | std::string_view | 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( std::string{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:162
std::string
STL class.
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)

## ◆ makeRef() [1/2]

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

Create reference object from registry entry.

Definition at line 590 of file RootDataConnection.cpp.

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

## ◆ makeRef() [2/2]

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

Create reference object from values.

Definition at line 596 of file RootDataConnection.cpp.

597 {
598 auto db = ( dbase == m_fid ? std::string_view{s_local} : dbase );
599 ref.entry = entry;
600
601 int cdb = -1;
602 if ( !db.empty() ) {
603 auto idb = std::find_if( m_dbs.begin(), m_dbs.end(), [&]( const std::string& i ) { return i == db; } );
604 cdb = std::distance( m_dbs.begin(), idb );
605 if ( idb == m_dbs.end() ) m_dbs.push_back( std::string{db} );
606 }
607
608 int ccnt = -1;
609 if ( !cnt.empty() ) {
610 auto icnt = std::find_if( m_conts.begin(), m_conts.end(), [&]( const std::string& i ) { return i == cnt; } );
611 ccnt = std::distance( m_conts.begin(), icnt );
612 if ( icnt == m_conts.end() ) m_conts.push_back( std::string{cnt} );
613 }
614
615 int clnk = -1;
616 if ( !name.empty() ) {
617 auto ilnk = std::find_if( m_links.begin(), m_links.end(), [&]( const std::string& i ) { return i == name; } );
618 clnk = std::distance( m_links.begin(), ilnk );
619 if ( ilnk == m_links.end() ) m_links.push_back( std::string{name} );
620 }
621
622 ref.dbase = cdb;
623 ref.container = ccnt;
624 ref.link = clnk;
625 ref.clid = clid;
626 ref.svc = tech;
627 if ( ref.svc == POOL_ROOT_StorageType || ref.svc == POOL_ROOTKEY_StorageType ||
628 ref.svc == POOL_ROOTTREE_StorageType ) {
629 ref.svc = ROOT_StorageType;
630 }
631 }
std::string::empty
T empty(T... args)
std::distance
T distance(T... args)
Gaudi::IDataConnection::m_fid
std::string m_fid
File ID of the connection.
Definition: IIODataManager.h:29
std::vector::end
T end(T... args)
Gaudi::RootDataConnection::m_links
StringVec m_links
Map containing internal links names.
Definition: RootDataConnection.h:162
std::string
STL class.
compareRootHistos.ref
string ref
Definition: compareRootHistos.py:14
POOL_ROOTKEY_StorageType
const long POOL_ROOTKEY_StorageType
Definition: ClassID.h:69
std::vector::push_back
T push_back(T... args)
Gaudi::RootDataConnection::m_conts
StringVec m_conts
Map containing external container names.
Definition: RootDataConnection.h:160
Gaudi::IDataConnection::name
const std::string & name() const
Connection name.
Definition: IIODataManager.h:49
ROOT_StorageType
const long ROOT_StorageType
Definition: ClassID.h:52
POOL_ROOT_StorageType
const long POOL_ROOT_StorageType
Definition: ClassID.h:68
std::find_if
T find_if(T... args)
POOL_ROOTTREE_StorageType
const long POOL_ROOTTREE_StorageType
Definition: ClassID.h:70
std::vector::begin
T begin(T... args)
Gaudi::RootDataConnection::m_dbs
StringVec m_dbs
Map containing external database file names (fids)
Definition: RootDataConnection.h:158

## ◆ makeTool()

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 ) m_tool.reset( new RootTool( this ) );
215 #ifdef __POOL_COMPATIBILITY
216 else if ( m_file->Get( "##Links" ) != nullptr )
217 m_tool.reset( new PoolTool( this ) );
218 #endif
219 else
220 m_tool.reset();
221 return m_tool.get();
222 }
Gaudi::RootDataConnection::m_tool
std::unique_ptr< Tool > m_tool
Definition: RootDataConnection.h:232
Gaudi::RootTool
Description:
Definition: RootTool.h:16
Gaudi::RootDataConnection::m_file
std::unique_ptr< TFile > m_file
Reference to ROOT file.
Definition: RootDataConnection.h:152
Gaudi::RootDataConnection::m_refs
TTree * m_refs
Pointer to the reference tree.
Definition: RootDataConnection.h:154
Gaudi::PoolTool
Definition: PoolTool.h:17

## ◆ mergeFIDs()

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

Access merged FIDs.

Definition at line 253 of file RootDataConnection.h.

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

## ◆ mergeSections()

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

Access merged data section inventory.

Definition at line 251 of file RootDataConnection.h.

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

## ◆ msgSvc()

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

Allow access to printer service.

Definition at line 144 of file RootDataConnection.h.

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

## ◆ read()

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

Read root byte buffer from input stream.

Implements Gaudi::IDataConnection.

Definition at line 293 of file RootDataConnection.h.

293 { return StatusCode::FAILURE; }
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## ◆ removeClient()

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

Remove client from this data source.

Definition at line 171 of file RootDataConnection.cpp.

171 {
172 auto i = m_clients.find( client );
173 if ( i != m_clients.end() ) m_clients.erase( i );
174 return m_clients.size();
175 }
Gaudi::RootDataConnection::m_clients
Clients m_clients
Client list.
Definition: RootDataConnection.h:172
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)

## ◆ save()

pair< int, unsigned long > RootDataConnection::save | ( | std::string_view | section,
|  | std::string_view | 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 467 of file RootDataConnection.cpp.

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

## ◆ saveObj()

pair< int, unsigned long > RootDataConnection::saveObj | ( | std::string_view | section,
|  | std::string_view | 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 460 of file RootDataConnection.cpp.

461 {
462 DataObjectPush push( pObj );
463 return save( section, cnt, cl, pObj, buff_siz, split_lvl, fill );
464 }
Gaudi::RootDataConnection::save
std::pair< int, unsigned long > save(std::string_view section, std::string_view 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:467
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:35

## ◆ saveRefs()

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

Internal helper to save/update reference tables.

## ◆ saveStatistics()

void RootDataConnection::saveStatistics | ( | std::string_view | statisticsFile | ) |

Save TTree access statistics if required.

Definition at line 189 of file RootDataConnection.cpp.

189 {
190 if ( m_statistics ) {
191 m_statistics->Print();
192 if ( !statisticsFile.empty() ) m_statistics->SaveAs( std::string{statisticsFile}.c_str() );
193 m_statistics.reset();
194 }
195 }
Gaudi::RootDataConnection::m_statistics
std::unique_ptr< TTreePerfStats > m_statistics
I/O read statistics from TTree.
Definition: RootDataConnection.h:150
std::string
STL class.
std::unique_ptr::reset
T reset(T... args)
std::string::c_str
T c_str(T... args)

## ◆ seek()

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

297 { return -1; }

## ◆ tool()

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

Access tool.

Definition at line 249 of file RootDataConnection.h.

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

## ◆ write()

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

Write root byte buffer to output stream.

Implements Gaudi::IDataConnection.

Definition at line 295 of file RootDataConnection.h.

295 { return StatusCode::FAILURE; }
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86

## Friends And Related Function Documentation

## ◆ Tool

friend class Tool
| friend

Definition at line 233 of file RootDataConnection.h.

## Member Data Documentation

## ◆ m_clients

Clients Gaudi::RootDataConnection::m_clients
| protected

Client list.

Definition at line 172 of file RootDataConnection.h.

## ◆ m_conts

StringVec Gaudi::RootDataConnection::m_conts
| protected

Map containing external container names.

Definition at line 160 of file RootDataConnection.h.

## ◆ m_dbs

StringVec Gaudi::RootDataConnection::m_dbs
| protected

Map containing external database file names (fids)

Definition at line 158 of file RootDataConnection.h.

## ◆ m_empty

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

Buffer for empty string reference.

Definition at line 174 of file RootDataConnection.h.

## ◆ m_file

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

Reference to ROOT file.

Definition at line 152 of file RootDataConnection.h.

## ◆ m_links

StringVec Gaudi::RootDataConnection::m_links
| protected

Map containing internal links names.

Definition at line 162 of file RootDataConnection.h.

## ◆ m_linkSects

LinkSections Gaudi::RootDataConnection::m_linkSects
| protected

Database link sections.

Definition at line 170 of file RootDataConnection.h.

## ◆ m_mergeFIDs

StringVec Gaudi::RootDataConnection::m_mergeFIDs
| protected

Map containing merge FIDs.

Definition at line 164 of file RootDataConnection.h.

## ◆ m_mergeSects

MergeSections Gaudi::RootDataConnection::m_mergeSects
| protected

Database section map for merged files.

Definition at line 168 of file RootDataConnection.h.

## ◆ m_params

ParamMap Gaudi::RootDataConnection::m_params
| protected

Parameter map for file parameters.

Definition at line 166 of file RootDataConnection.h.

## ◆ m_refs

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

Pointer to the reference tree.

Definition at line 154 of file RootDataConnection.h.

## ◆ m_sections

Sections Gaudi::RootDataConnection::m_sections
| protected

Tree sections in TFile.

Definition at line 156 of file RootDataConnection.h.

## ◆ m_setup

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

Reference to the setup structure.

Definition at line 148 of file RootDataConnection.h.

## ◆ m_statistics

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

I/O read statistics from TTree.

Definition at line 150 of file RootDataConnection.h.

## ◆ m_tool

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

Definition at line 232 of file RootDataConnection.h.

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

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