#include <src/RootTool.h>
|
| RootTool (RootDataConnection *con) |
| Standard constructor. More...
|
|
TBranch * | getBranch (std::string_view section, std::string_view branch_name) override |
| Access data branch by name: Get existing branch in read only mode. More...
|
|
int | loadRefs (std::string_view section, std::string_view cnt, unsigned long entry, RootObjectRefs &refs) override |
| Load references object from file. More...
|
|
void | addParam (ParamMap &c, char *p) |
| Helper function to read params table. More...
|
|
void | addEntry (StringVec &c, char *val) |
| Helper function to read string tables. More...
|
|
template<class C , class F > |
StatusCode | readBranch (TTree *t, const char *nam, C &v, F pmf) |
| Helper function to read internal file tables. More...
|
|
bool | get (const string &dsc, pair< string, ContainerSection > &e) |
| Analyze the Sections table entries. More...
|
|
void | analyzeMergeMap (StringVec &tmp) |
| Build merge sections from the Sections table entries. More...
|
|
StatusCode | readRefs () override |
| Read reference tables. More...
|
|
string | getEntry (const string &c) |
| Helper function to convert string vectors to branch entries. More...
|
|
string | getParam (const pair< string, string > &p) |
| Helper function to convert parameter vectors to branch entries. More...
|
|
template<class C , class F > |
StatusCode | saveBranch (const char *nam, C &v, F pmf) |
| Helper function to save internal tables. More...
|
|
StatusCode | saveRefs () override |
| Save/update reference tables. More...
|
|
TTree * | refs () const |
|
StringVec & | dbs () const |
|
StringVec & | conts () const |
|
StringVec & | links () const |
|
ParamMap & | params () const |
|
MsgStream & | msgSvc () const |
|
IIncidentSvc * | incidentSvc () const |
|
const std::string & | name () const |
|
Sections & | sections () const |
|
LinkSections & | linkSections () const |
|
MergeSections & | mergeSections () const |
|
virtual | ~Tool ()=default |
| Default destructor. More...
|
|
virtual RootRef | poolRef (size_t) const |
| Internal overload to facilitate the access to POOL files. More...
|
|
Description:
Concrete implementation to read objects from POOL files.
- Author
- M.Frank
- Version
- 1.0
Description:
Concrete implementation to read objects from ROOT files.
- Author
- M.Frank
- Version
- 1.0
Definition at line 26 of file RootTool.h.
◆ RootTool()
Standard constructor.
Definition at line 29 of file RootTool.h.
◆ addEntry()
void Gaudi::RootTool::addEntry |
( |
StringVec & |
c, |
|
|
char * |
val |
|
) |
| |
|
inline |
Helper function to read string tables.
Definition at line 112 of file RootTool.h.
112 {
c.push_back( val ); }
◆ addParam()
void Gaudi::RootTool::addParam |
( |
ParamMap & |
c, |
|
|
char * |
p |
|
) |
| |
|
inline |
Helper function to read params table.
Definition at line 104 of file RootTool.h.
105 char* q =
strchr( p,
'=' );
108 c.emplace_back( p, ++q );
◆ analyzeMergeMap()
void Gaudi::RootTool::analyzeMergeMap |
( |
StringVec & |
tmp | ) |
|
|
inline |
Build merge sections from the Sections table entries.
Definition at line 159 of file RootTool.h.
162 pair<string, ContainerSection> e;
169 r.dbase = r.container = r.link = r.clid = r.svc = r.entry = 0;
170 for (
const auto& i : tmp ) {
172 msg <<
"Added Merge Section:" << e.first <<
endmsg;
173 ms[e.first].push_back( e.second );
174 if ( e.first ==
"Links" )
175 r.link = e.second.start;
176 else if ( e.first ==
"Containers" )
177 r.container = e.second.start;
178 else if ( e.first ==
"Databases" )
179 r.dbase = e.second.start;
180 else if ( e.first ==
"Params" )
181 r.svc = e.second.start;
182 }
else if ( i ==
"[END-OF-SECTION]" ) {
184 if (
msg.isActive() ) {
185 msg <<
"Link Section [" << r.entry <<
"," << ls.size() <<
"] -> D:" << r.dbase <<
" C:" << r.container
186 <<
" L:" << r.link <<
" P:" << r.svc <<
endmsg;
◆ get()
bool Gaudi::RootTool::get |
( |
const string & |
dsc, |
|
|
pair< string, ContainerSection > & |
e |
|
) |
| |
|
inline |
Analyze the Sections table entries.
Definition at line 140 of file RootTool.h.
141 if ( dsc !=
"[END-OF-SECTION]" ) {
142 size_t id1 = dsc.find(
"[CNT=" );
143 size_t id2 = dsc.find(
"[START=" );
144 size_t id3 = dsc.find(
"[LEN=" );
145 if ( id1 != string::npos && id2 != string::npos && id3 != string::npos ) {
146 string cnt = dsc.substr( id1 + 5, id2 - 1 - 5 );
147 int section_start =
std::stoi( dsc.substr( id2 + 7, id3 - id2 - 8 ) );
148 int section_length =
std::stoi( dsc.substr( id3 + 5, dsc.find(
"]", id3 + 5 ) - id3 - 5 ) );
◆ getBranch()
TBranch* Gaudi::RootTool::getBranch |
( |
std::string_view |
section, |
|
|
std::string_view |
branch_name |
|
) |
| |
|
inlineoverridevirtual |
Access data branch by name: Get existing branch in read only mode.
Implements Gaudi::RootDataConnection::Tool.
Definition at line 31 of file RootTool.h.
34 for (
int i = 0,
m =
n.length() - 1; i <
m; ++i )
37 TBranch* b =
t ?
t->GetBranch(
n.c_str() ) :
nullptr;
39 if ( b ) b->SetAutoDelete( kFALSE );
◆ getEntry()
string Gaudi::RootTool::getEntry |
( |
const string & |
c | ) |
|
|
inline |
Helper function to convert string vectors to branch entries.
Definition at line 211 of file RootTool.h.
◆ getParam()
string Gaudi::RootTool::getParam |
( |
const pair< string, string > & |
p | ) |
|
|
inline |
Helper function to convert parameter vectors to branch entries.
Definition at line 213 of file RootTool.h.
213 {
return p.first +
"=" + p.second; }
◆ loadRefs()
int Gaudi::RootTool::loadRefs |
( |
std::string_view |
section, |
|
|
std::string_view |
cnt, |
|
|
unsigned long |
entry, |
|
|
RootObjectRefs & |
refs |
|
) |
| |
|
inlineoverridevirtual |
Load references object from file.
Link manager:
Implements Gaudi::RootDataConnection::Tool.
Definition at line 43 of file RootTool.h.
45 RootObjectRefs* prefs = &
refs;
47 b->SetAddress( &prefs );
48 int nb = b->GetEntry( entry );
54 pair<const RootRef*, const ContainerSection*> ls =
c->
getMergeSection( cnt, entry );
56 if ( ls.first->dbase >= 0 ) {
59 if (
msg.isActive() ) {
60 msg <<
"Refs: LS [" << entry <<
"] -> " << ls.first->dbase <<
"," << ls.first->container <<
","
61 << ls.first->link <<
"," << ls.first->entry <<
endmsg;
63 for (
size_t j = 0,
n =
refs.refs.size();
j <
n; ++
j ) {
64 RootRef& r =
refs.refs[
j];
65 if ( r.entry >= 0 && r.dbase >= 0 ) {
66 int db = r.dbase + ls.first->dbase;
68 if ( r.dbase ) r.dbase += ls.first->dbase;
69 if ( r.container ) r.container += ls.first->container;
70 if ( r.link ) r.link += ls.first->link;
72 auto k =
ms.find(
rc );
73 if ( k !=
ms.end() ) {
74 const auto& cs = ( *k ).second;
75 r.entry = ( ls.first->entry >= 0 && ls.first->entry < (int)cs.size() )
76 ? cs[ls.first->entry].start + r.entry
78 if (
msg.isActive() ) {
79 msg <<
"Add link [" << r.entry <<
"," << ls.first->entry <<
"," << ls.first->container <<
","
80 << r.container <<
"," << r.entry <<
"] to -> " <<
rc <<
endmsg;
84 <<
" Invalid link to " <<
rc <<
endmsg;
92 [&](
int& i ) { i += ls.first->link; } );
◆ readBranch()
template<class C , class F >
StatusCode Gaudi::RootTool::readBranch |
( |
TTree * |
t, |
|
|
const char * |
nam, |
|
|
C & |
v, |
|
|
F |
pmf |
|
) |
| |
|
inline |
Helper function to read internal file tables.
Definition at line 115 of file RootTool.h.
117 TBranch* b =
t->GetBranch( nam );
119 TLeaf*
l = b->GetLeaf( nam );
122 b->SetAddress( text );
124 for ( Long64_t i = 0,
n = b->GetEntries(); i <
n; ++i ) {
125 if ( b->GetEntry( i ) > 0 ) {
126 char* p = (
char*)
l->GetValuePointer();
127 msgSvc() <<
"Add Value[" << b->GetName() <<
"]:" << p <<
endmsg;
128 ( this->*pmf )(
v, p );
◆ readRefs()
◆ saveBranch()
template<class C , class F >
StatusCode Gaudi::RootTool::saveBranch |
( |
const char * |
nam, |
|
|
C & |
v, |
|
|
F |
pmf |
|
) |
| |
|
inline |
Helper function to save internal tables.
Definition at line 216 of file RootTool.h.
218 string val, typ = nam;
220 TDirectory::TContext ctxt(
c->
file() );
221 TBranch* b =
refs()->GetBranch( nam );
222 if ( !b ) b =
refs()->Branch( nam, 0, ( typ +
"/C" ).c_str() );
224 for ( i = b->GetEntries(),
n = Long64_t(
v.size() ); i <
n; ++i ) {
225 val = ( this->*pmf )(
v[
size_t( i )] );
226 b->SetAddress( (
char*)val.c_str() );
◆ saveRefs()
The documentation for this class was generated from the following file:
const std::string & getDb(int which) const
Access database/file name from saved index.
const std::string & getCont(int which) const
Access container name from saved index.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
TFile * file() const
Direct access to TFile structure.
constexpr static const auto SUCCESS
TTree * getSection(std::string_view sect, bool create=false)
Access TTree section from section name. The section is created if required.
const MergeSections & mergeSections() const
Access merged data section inventory.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(std::string_view container, int entry) const
Access link section for single container and entry.
const std::string & fid() const
Access file id.
constexpr static const auto FAILURE