9 #define ALLOW_ALL_TYPES 33 #define S_OK StatusCode::SUCCESS 34 #define S_FAIL StatusCode::FAILURE 36 using namespace Gaudi;
48 {
return loadLong(is); }
50 {
return loadLong(is); }
52 {
return loadLong(is); }
59 long len, ndim, dim[4], hasIdx, idxLow, idxLen;
60 long dim1 = 1, dim2 = 1;
63 is >> len >>
c >> ndim >>
c >> hasIdx >>
c;
64 if ( hasIdx ) {
getline( is, idxName,
';' ) >> idxLow >>
c >> idxLen >>
c; }
65 for (
int i = 0; i < ndim; i++ ) is >> dim[i] >>
c;
67 TYP low =
null, high =
null;
68 is >> low >>
c >> high >>
c;
75 dim1 = ( hasIdx ) ? idxLen : dim[0];
79 dim1 = ( hasIdx ) ? idxLen : dim[0];
80 dim2 = ( hasIdx ) ? dim[0] : dim[1];
87 TBranch* b = tree->GetBranch( it->
name().
c_str() );
89 b->SetAddress( const_cast<void*>( it->
buffer() ) );
92 return tuple->add( it );
95 return tuple->add( it );
104 static inline string _tr(
string s ) {
107 if ( local.
compare( 0, 7,
"<local>" ) == 0 ) p += 7;
118 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
119 string path = fileName( pRegistry );
120 string cntName = containerName( pRegistry );
121 string*
par = const_cast<string*>( pAddr->
par() );
123 if ( status.isSuccess() ) {
124 string par_val, par_guid;
125 TBranch* b = con->
getBranch(
"##Descriptors",
"GaudiStatisticsDescription" );
129 b->SetAddress( &ptr );
130 for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
131 int nb = b->GetEntry( i );
140 par[2] = _tr( cntName );
142 if (
nullptr == tree ) {
return makeError(
"Failed to access N-Tuple tree:" + cntName ); }
143 if ( !par_val.
empty() ) {
144 auto ntupleSvc = dataProvider().as<
INTupleSvc>();
152 getline( is, title,
';' ) >> clid >>
c >> siz >>
c;
153 status = ntupleSvc->create( clid, title, nt );
154 for (
int j = 0; j < siz && status.isSuccess(); j++ ) {
156 getline( is, title,
';' ) >> typ >>
c;
159 status = createItem( tree, nt, is, title,
true, (
unsigned char)0 );
162 status = createItem( tree, nt, is, title,
true, (
unsigned short)0 );
165 status = createItem( tree, nt, is, title,
true, 0u );
168 status = createItem( tree, nt, is, title,
true, 0ul );
171 status = createItem( tree, nt, is, title,
true,
char( 0 ) );
174 status = createItem( tree, nt, is, title,
true,
short( 0 ) );
177 status = createItem( tree, nt, is, title,
true, 0 );
180 status = createItem( tree, nt, is, title,
true, 0
l );
183 status = createItem( tree, nt, is, title,
true,
false );
186 status = createItem( tree, nt, is, title,
true, 0.f );
189 status = createItem( tree, nt, is, title,
true, 0. );
204 status = createItem( tree, nt, is, title,
false, static_cast<IOpaqueAddress*>(
nullptr ) );
207 status = createItem( tree, nt, is, title,
true, static_cast<void*>(
nullptr ) );
214 if ( !status.isSuccess() ) {
216 return makeError(
"createObj[NTuple]> Cannot determine column!" );
219 if ( status.isSuccess() ) {
220 unsigned long* ipar = const_cast<unsigned long*>( rpA->
ipar() );
222 ipar[0] = reinterpret_cast<uintptr_t>( con );
227 refpObject =
nullptr;
238 INTuple* tupl = dynamic_cast<INTuple*>( pObj );
239 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
240 if ( !tupl || !rpA )
return makeError(
"updateObj> Invalid Tuple reference." );
242 if ( !con )
return makeError(
"updateObj> Failed to access data source!" );
244 if ( !tree )
return makeError(
"Failed to access data tree:" + pAddr->
par()[1] );
246 if ( con->
tool()->
refs() )
return i__updateObjRoot( rpA, tupl, tree, con );
247 #ifdef __POOL_COMPATIBILITY 249 return i__updateObjPool( rpA, tupl, tree, con );
251 return makeError(
"Failed to access reference branch for data tree:" + rpA->
par()[1] );
258 const string*
par = rpA->
par();
259 unsigned long* ipar = const_cast<unsigned long*>( rpA->
ipar() );
261 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
263 Cont& it = tupl->
items();
264 size_t k,
n = it.size();
267 for ( k = 0; k <
n; ++k ) {
268 Cont::value_type j = it[k];
269 switch ( j->type() ) {
272 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
279 ULong64_t last = tree->GetEntries();
283 if ( !( criteria.
length() == 0 || criteria ==
"*" ) ) {
284 if ( rpA->
select ==
nullptr ) {
286 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.
c_str(), tree );
288 rpA->
select->SetTree( tree );
289 for ( ; ipar[1] < last; ++ipar[1] ) {
290 tree->LoadTree( ipar[1] );
297 if ( ipar[1] < last ) {
298 unsigned long entry = ipar[1];
299 if ( tree->GetEntry( entry ) > 1 ) {
301 string* spar =
nullptr;
302 for ( k = 0; k <
n; ++k ) {
303 Cont::value_type j = it[k];
304 switch ( j->type() ) {
309 spar = (
string*)pA->
par();
310 ipar = (
unsigned long*)pA->
ipar();
315 if ( ls.first->dbase >= 0 ) {
319 r->
dbase += ls.first->dbase;
321 r->
link += ls.first->link;
323 if (
log().isActive() ) {
324 log() <<
"Refs: LS [" << entry <<
"] -> " << ls.first->dbase <<
"," << ls.first->container <<
"," 325 << ls.first->link <<
"," << ls.first->entry <<
" DB:" << con->
getDb( r->
dbase ) <<
endmsg;
359 if ( pAddr )
return S_OK;
362 string path = fileName( pRegistry );
363 string cntName = containerName( pRegistry );
364 string secName = cntName.
c_str();
365 const INTuple* nt = dynamic_cast<const INTuple*>( pObj );
367 if ( !status.
isSuccess() ) {
return makeError(
"Failed to access Tuple file:" +
path ); }
368 TTree* tree = con->
getSection( _tr( secName ),
true );
369 if (
nullptr != nt ) {
374 os << nt->
title() <<
';' << pObj->
clID() <<
';' <<
items.size() <<
';';
376 TBranch* b =
nullptr;
377 for ( item_no = 0; item_no <
items.size(); ++item_no ) {
381 const string&
n = itm->
name();
382 switch ( itm->
type() ) {
385 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
389 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
393 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
397 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
401 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
405 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
409 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
413 b = tree->Branch(
n.c_str(), const_cast<void*>( itm->
buffer() ), desc.
c_str() );
416 return makeError(
"Column " + it->
index() +
" is not a valid index column!" );
421 for ( item_no = 0; item_no <
items.size(); ++item_no ) {
423 const string&
n = it->
name();
424 os <<
'{' <<
n <<
';' << it->
type() <<
';' << it->
length() <<
';' << it->
ndim() <<
';' << it->
hasIndex() <<
';';
426 os << it->
index() <<
';';
428 switch ( itm->
type() ) {
454 return makeError(
"NTuple:" + pRegistry->
name() +
" Column " + it->
index() +
455 " is not a valid index column!" );
458 for (
long k = 0; k < it->
ndim(); k++ ) { os << it->
dim( k ) <<
';'; }
460 TClass* cl =
nullptr;
461 switch ( it->
type() ) {
464 os << 0 <<
';' << 0 <<
';';
468 os << 0 <<
';' << 0 <<
';';
471 if ( it->
length() == 1 ) {
473 os << 0 <<
';' << 0 <<
';';
474 cl = TClass::GetClass( desc.
c_str(), kTRUE );
478 if ( it->
length() == 1 ) {
479 os << 0 <<
';' << 0 <<
';';
480 cl = TClass::GetClass( it->
typeID(), kTRUE );
529 return makeError(
"Create item[FAIL]: " + it->
name() );
532 if ( branches.
find(
n ) == branches.
end() ) {
535 switch ( it->
ndim() ) {
546 desc =
n + tmp +
"[" + itm->
name() +
"]" + desc;
549 desc =
n + tmp + text + desc;
553 switch ( it->
type() ) {
555 branches[
n] = tree->Branch(
n.c_str(), cl->GetName(), const_cast<void*>( it->
buffer() ) );
558 branches[
n] = tree->Branch(
n.c_str(), cl->GetName(), const_cast<void*>( it->
buffer() ) );
561 branches[
n] = tree->Branch(
n.c_str(), const_cast<void*>( it->
buffer() ), desc.
c_str() );
568 status = saveDescription(
path, cntName, os.
str(),
"", pObj->
clID() );
570 status = m_dbMgr->commitOutput(
path,
true );
572 string spar[] = {
path, cntName};
573 unsigned long ipar[] = {(
unsigned long)con, ~0x0u};
574 status = m_dbMgr->createAddress( repSvcType(), pObj->
clID(), spar, ipar, pAddr );
576 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
577 ( (
unsigned long*)rpA->
ipar() )[0] = (
unsigned long)con;
594 INTuple* tupl = dynamic_cast<INTuple*>( pObj );
596 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
597 if ( tupl && pReg && rpA ) {
598 string cntName = containerName( pReg );
599 unsigned long* ipar = const_cast<unsigned long*>( pAddr->
ipar() );
604 Cont& it = tupl->
items();
605 size_t k,
n = it.size();
608 for ( k = 0; k <
n; ++k ) {
610 Cont::value_type j = it[k];
611 switch ( j->type() ) {
617 con->makeRef( *pA->
registry(), addr[k] );
618 addr[k].entry = pA->
ipar()[1];
620 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
626 int nb = tree->Fill();
627 if ( nb > 1 ) ++ipar[1];
628 for ( k = 0; k <
n; ++k ) it[k]->reset();
631 return makeError(
"fillRepRefs> Failed to access data tree:" + cntName );
633 return makeError(
"fillRepRefs> Failed to access data source!" );
635 return makeError(
"fillRepRefs> Invalid Tuple reference." );
638 #ifdef __POOL_COMPATIBILITY 648 IOBuffer() =
default;
649 virtual ~IOBuffer() {
664 static inline int load(
int blob, IOBuffer&
s,
void* buff ) {
668 s.swapFromBuffer( buff, len *
sizeof( T ) );
675 inline int load<string>(
int blob, IOBuffer&
s,
void* ptr ) {
677 string* str = (
string*)ptr;
686 const string*
par = rpA->
par();
687 unsigned long* ipar = const_cast<unsigned long*>( rpA->
ipar() );
689 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
690 Cont& it = tupl->
items();
691 size_t k,
n = it.size();
695 for ( k = 0; k <
n; ++k ) {
696 Cont::value_type j = it[k];
697 switch ( j->type() ) {
700 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
703 if (
nullptr == tree->GetBranch( j->name().c_str() ) ) blob_items[k] = 1;
707 ULong64_t last = (ULong64_t)tree->GetEntries();
711 if ( !( criteria.
length() == 0 || criteria ==
"*" ) ) {
712 if ( rpA->
select ==
nullptr ) {
714 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.
c_str(), tree );
716 rpA->
select->SetTree( tree );
718 for ( ; ipar[1] < last; ++ipar[1] ) {
719 tree->LoadTree( ipar[1] );
726 if ( ipar[1] < last ) {
729 tree->GetBranch(
"BlobData" )->SetAddress( &pblob );
730 if ( tree->GetEntry( ipar[1] ) > 1 ) {
733 for ( k = 0; k <
n; ++k ) {
734 Cont::value_type j = it[k];
735 char* buf = (
char*)j->buffer();
736 switch ( j->type() ) {
741 string* spar = (
string*)pA->
par();
742 ipar = (
unsigned long*)pA->
ipar();
747 ipar[1] = addr[k].token.m_oid.second;
760 sc = load<unsigned char>( blob_items[k], blob, buf );
763 sc = load<unsigned short>( blob_items[k], blob, buf );
766 sc = load<unsigned int>( blob_items[k], blob, buf );
769 sc = load<unsigned long>( blob_items[k], blob, buf );
772 sc = load<char>( blob_items[k], blob, buf );
775 sc = load<short>( blob_items[k], blob, buf );
778 sc = load<int>( blob_items[k], blob, buf );
781 sc = load<long>( blob_items[k], blob, buf );
784 sc = load<bool>( blob_items[k], blob, buf );
787 sc = load<float>( blob_items[k], blob, buf );
790 sc = load<double>( blob_items[k], blob, buf );
793 sc = load<string>( blob_items[k], blob, buf );
796 sc = load<char*>( blob_items[k], blob, buf );
810 log() <<
"CANNOT Set Ntuple token: dynamic_cast<GenericAddress*> is NULL";
813 log() <<
"CANNOT Set Ntuple token: invalid address buffer";
virtual const std::string * par() const =0
Retrieve String parameters.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
IRegistry * registry() const
Get pointer to Registry.
virtual long type() const =0
Type information of the item.
const std::string * par() const override
Retrieve string parameters.
A select statement can either contain.
Tool * tool() const
Access tool.
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
void setSvcType(long typ)
Access : set the storage type of the class id.
The stream buffer is a small object collecting object data.
int m_size
Size of buffer.
virtual const std::string & title() const =0
Object title.
constexpr static const auto SUCCESS
virtual const name_type & name() const =0
Name of the directory (or key)
virtual const ItemRange & range() const =0
Access the range if specified.
virtual unsigned long release()=0
release reference to object
const std::string & getDb(int which) const
Access database/file name from saved index.
Generic Transient Address.
virtual ISelectStatement * selector()=0
Access selector.
virtual const std::type_info & typeID() const =0
Compiler type ID.
virtual bool hasIndex() const =0
Is the tuple have an index item?
Shadow class to mimik POOL blobs.
static _Array * create(INTuple *tup, const std::string &name, const std::type_info &info, const std::string &index, long len, TYP min, TYP max, TYP def)
Create instance.
virtual const std::string & name() const =0
Access _Item name.
const long POOL_ROOTKEY_StorageType
NTuple interface class definition.
int dbase
Data members to define object location in the persistent world.
Persistent reference object.
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
NTuple interface class definition.
void setClID(const CLID &clid)
Access : Set class ID of the link.
const std::string & getCont(int which) const
Access container name from saved index.
virtual IRegistry * registry() const =0
Update branch name.
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
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.
const std::string & getLink(int which) const
Access link name from saved index.
virtual long dim(long i) const =0
Access individual dimensions.
std::string description
Description string.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
const long ROOT_StorageType
Abstract class describing basic data in an Ntuple.
unsigned int CLID
Class ID definition.
const long POOL_ROOT_StorageType
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(std::string_view container, int entry) const
Access link section for single container and entry.
Abstract base class which allows the user to interact with the actual N tuple implementation.
StatusCode createRep(DataObject *pObj, IOpaqueAddress *&refpAdd) override
Converter overrides: Convert the transient object to the requested representation.
virtual unsigned long release()
release reference to object
StatusCode fillRepRefs(IOpaqueAddress *pAdd, DataObject *pObj) override
Resolve the references of the converted object.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
const long POOL_ROOTTREE_StorageType
unsigned char * m_buffer
Buffer with object content.
virtual long ndim() const =0
Dimension.
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the transient object: NTuples end here when reading records.
void resetAge()
Reset age.
std::string container
Identifier of description.
constexpr static const auto FAILURE
TYP lower() const
Lower boundary of range.
const unsigned long * ipar() const override
Retrieve integer parameters.
virtual ItemContainer & items()=0
Access item container.
static _Item * create(INTuple *tup, const std::string &name, const std::type_info &info, TYP min, TYP max, TYP def)
Create instance.
TTreeFormula * select
Pointer to ROOT select statement (filled for N-tuples only)
Opaque address interface definition.
StatusCode i__updateObjRoot(RootAddress *rpA, INTuple *tupl, TTree *tree, RootDataConnection *con)
Update the transient object: NTuples end here when reading records.
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Converter overrides: Update the references of an updated transient object.
A DataObject is the base class of any identifiable object on any data store.
Concrete implementation of the IDataConnection interface to access ROOT files.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
Header file for std:chrono::duration-based Counters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual const std::string & index() const =0
Access the index _Item.
static _Matrix * create(INTuple *tup, const std::string &name, const std::type_info &info, const std::string &index, long ncol, long nrow, TYP min, TYP max, TYP def)
Create instance.
TYP upper() const
Upper boundary of range.
virtual long length() const =0
Access the buffer length.
virtual const void * buffer() const =0
Access data buffer (CONST)