21 TBranch*
getBranch( std::string_view section, std::string_view branch_name )
override {
24 for (
int i = 0,
m =
n.length() - 1; i <
m; ++i )
25 if ( !isalnum(
n[i] ) )
n[i] =
'_';
27 TBranch* b = t ? t->GetBranch(
n.c_str() ) :
nullptr;
28 if ( !b ) b = t ? t->GetBranch(
std::string{branch_name}.
c_str() ) :
nullptr;
29 if ( b ) b->SetAutoDelete( kFALSE );
37 b->SetAddress( &prefs );
38 int nb = b->GetEntry( entry );
44 pair<const RootRef*, const ContainerSection*> ls =
c->
getMergeSection( cnt, entry );
46 if ( ls.first->dbase >= 0 ) {
49 if (
msg.isActive() ) {
50 msg <<
"Refs: LS [" << entry <<
"] -> " << ls.first->dbase <<
"," << ls.first->container <<
"," 51 << ls.first->link <<
"," << ls.first->entry <<
endmsg;
53 for (
size_t j = 0,
n =
refs.refs.size(); j <
n; ++j ) {
56 int db = r.
dbase + ls.first->dbase;
60 if ( r.
link ) r.
link += ls.first->link;
62 auto k =
ms.find(
rc );
63 if ( k !=
ms.end() ) {
64 const auto& cs = ( *k ).second;
65 r.
entry = ( ls.first->entry >= 0 && ls.first->entry < (int)cs.size() )
66 ? cs[ls.first->entry].start + r.
entry 68 if (
msg.isActive() ) {
69 msg <<
"Add link [" << r.
entry <<
"," << ls.first->entry <<
"," << ls.first->container <<
"," 74 <<
" Invalid link to " <<
rc <<
endmsg;
82 [&](
int& i ) { i += ls.first->link; } );
95 char* q = strchr( p,
'=' );
98 c.emplace_back( p, ++q );
104 template <
class C,
class F>
107 TBranch* b = t->GetBranch( nam );
109 TLeaf*
l = b->GetLeaf( nam );
112 b->SetAddress( text );
114 for ( Long64_t i = 0,
n = b->GetEntries(); i <
n; ++i ) {
115 if ( b->GetEntry( i ) > 0 ) {
116 char* p = (
char*)
l->GetValuePointer();
117 msgSvc() <<
"Add Value[" << b->GetName() <<
"]:" << p <<
endmsg;
118 ( this->*pmf )( v, p );
120 sc = RootDataConnection::Status::ROOT_READ_ERROR;
127 return RootDataConnection::Status::ROOT_READ_ERROR;
130 bool get(
const string& dsc, pair<string, ContainerSection>& e ) {
131 if ( dsc !=
"[END-OF-SECTION]" ) {
132 size_t id1 = dsc.find(
"[CNT=" );
133 size_t id2 = dsc.find(
"[START=" );
134 size_t id3 = dsc.find(
"[LEN=" );
135 if ( id1 != string::npos && id2 != string::npos && id3 != string::npos ) {
136 string cnt = dsc.substr( id1 + 5, id2 - 1 - 5 );
137 int section_start =
std::stoi( dsc.substr( id2 + 7, id3 - id2 - 8 ) );
138 int section_length =
std::stoi( dsc.substr( id3 + 5, dsc.find(
"]", id3 + 5 ) - id3 - 5 ) );
152 pair<string, ContainerSection> e;
160 for (
const auto& i : tmp ) {
162 msg <<
"Added Merge Section:" << e.first <<
endmsg;
163 ms[e.first].push_back( e.second );
164 if ( e.first ==
"Links" )
165 r.
link = e.second.start;
166 else if ( e.first ==
"Containers" )
168 else if ( e.first ==
"Databases" )
169 r.
dbase = e.second.start;
170 else if ( e.first ==
"Params" )
171 r.
svc = e.second.start;
172 }
else if ( i ==
"[END-OF-SECTION]" ) {
174 if (
msg.isActive() ) {
185 TTree* t = (TTree*)
c->
file()->Get(
"Sections" );
203 string getParam(
const pair<string, string>& p ) {
return p.first +
"=" + p.second; }
205 template <
class C,
class F>
208 string val, typ = nam;
210 TDirectory::TContext ctxt(
c->
file() );
211 TBranch* b =
refs()->GetBranch( nam );
212 if ( !b ) b =
refs()->Branch( nam, 0, ( typ +
"/C" ).c_str() );
214 for ( i = b->GetEntries(),
n = Long64_t( v.size() ); i <
n; ++i ) {
215 val = ( this->*pmf )( v[
size_t( i )] );
216 b->SetAddress( (
char*)val.c_str() );
Definition of the MsgStream class used to transmit messages.
const MergeSections & mergeSections() const
Access merged data section inventory.
constexpr static const auto SUCCESS
const std::string & fid() const
Access file id.
const std::string & getDb(int which) const
Access database/file name from saved index.
Persistent reference object containing all leafs and links corresponding to a Gaudi DataObject.
int dbase
Data members to define object location in the persistent world.
Persistent reference object.
const std::string & getCont(int which) const
Access container name from saved index.
TTree * getSection(std::string_view sect, bool create=false)
Access TTree section from section name. The section is created if required.
This class is used for returning status codes from appropriate routines.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(std::string_view container, int entry) const
Access link section for single container and entry.
constexpr static const auto FAILURE
TFile * file() const
Direct access to TFile structure.
Concrete implementation of the IDataConnection interface to access ROOT files.
Header file for std:chrono::duration-based Counters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.