9 #define ALLOW_ALL_TYPES 33 #define S_OK StatusCode::SUCCESS 34 #define S_FAIL StatusCode::FAILURE 36 using namespace Gaudi;
49 {
return loadLong(is); }
51 {
return loadLong(is); }
53 {
return loadLong(is); }
60 long len, ndim, dim[4], hasIdx, idxLow, idxLen;
61 long dim1 = 1, dim2 = 1;
64 is >> len >> c >> ndim >> c >> hasIdx >>
c;
66 getline( is, idxName,
';' ) >> idxLow >> c >> idxLen >>
c;
68 for (
int i = 0; i < ndim; i++ ) is >> dim[i] >>
c;
70 TYP low = null, high = null;
71 is >> low >> c >> high >>
c;
78 dim1 = ( hasIdx ) ? idxLen : dim[0];
82 dim1 = ( hasIdx ) ? idxLen : dim[0];
83 dim2 = ( hasIdx ) ? dim[0] : dim[1];
90 TBranch* b = tree->GetBranch( it->
name().
c_str() );
92 b->SetAddress( const_cast<void*>( it->
buffer() ) );
95 return tuple->
add( it );
98 return tuple->
add( it );
108 static inline string _tr(
string s )
112 if ( local.
compare( 0, 7,
"<local>" ) == 0 ) p += 7;
124 string path = fileName( pRegistry );
125 string cntName = containerName( pRegistry );
126 string*
par =
const_cast<string*
>( pAddr->
par() );
129 string par_val, par_guid;
130 TBranch* b = con->
getBranch(
"##Descriptors",
"GaudiStatisticsDescription" );
134 b->SetAddress( &ptr );
135 for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
136 int nb = b->GetEntry( i );
145 par[2] = _tr( cntName );
147 if (
nullptr == tree ) {
148 return makeError(
"Failed to access N-Tuple tree:" + cntName );
150 if ( !par_val.
empty() ) {
151 auto ntupleSvc = dataProvider().as<
INTupleSvc>();
159 getline( is, title,
';' ) >> clid >> c >> siz >>
c;
160 status = ntupleSvc->create( clid, title, nt );
161 for (
int j = 0; j < siz && status.
isSuccess(); j++ ) {
163 getline( is, title,
';' ) >> typ >>
c;
166 status = createItem( tree, nt, is, title,
true, (
unsigned char)0 );
169 status = createItem( tree, nt, is, title,
true, (
unsigned short)0 );
172 status = createItem( tree, nt, is, title,
true, (
unsigned int)0 );
175 status = createItem( tree, nt, is, title,
true, (
unsigned long)0 );
178 status = createItem( tree, nt, is, title,
true,
char( 0 ) );
181 status = createItem( tree, nt, is, title,
true,
short( 0 ) );
184 status = createItem( tree, nt, is, title,
true,
int( 0 ) );
187 status = createItem( tree, nt, is, title,
true,
long( 0 ) );
190 status = createItem( tree, nt, is, title,
true,
false );
193 status = createItem( tree, nt, is, title,
true,
float( 0.0 ) );
196 status = createItem( tree, nt, is, title,
true,
double( 0.0 ) );
211 status = createItem( tree, nt, is, title,
false, static_cast<IOpaqueAddress*>(
nullptr ) );
214 status = createItem( tree, nt, is, title,
true, static_cast<void*>(
nullptr ) );
223 return makeError(
"createObj[NTuple]> Cannot determine column!" );
227 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
229 ipar[0] =
reinterpret_cast<uintptr_t>( con );
234 refpObject =
nullptr;
248 if ( !tupl || !rpA )
return makeError(
"updateObj> Invalid Tuple reference." );
250 if ( !con )
return makeError(
"updateObj> Failed to access data source!" );
252 if ( !tree )
return makeError(
"Failed to access data tree:" + pAddr->
par()[1] );
254 if ( con->
tool()->
refs() )
return i__updateObjRoot( rpA, tupl, tree, con );
255 #ifdef __POOL_COMPATIBILITY 257 return i__updateObjPool( rpA, tupl, tree, con );
259 return makeError(
"Failed to access reference branch for data tree:" + rpA->
par()[1] );
267 const string*
par = rpA->
par();
268 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
270 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
272 Cont& it = tupl->
items();
273 size_t k,
n = it.size();
276 for ( k = 0; k <
n; ++k ) {
277 Cont::value_type j = it[k];
278 switch ( j->type() ) {
281 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
288 ULong64_t last = tree->GetEntries();
292 if ( !( criteria.
length() == 0 || criteria ==
"*" ) ) {
293 if ( rpA->
select ==
nullptr ) {
295 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.
c_str(), tree );
297 rpA->
select->SetTree( tree );
298 for ( ; ipar[1] < last; ++ipar[1] ) {
299 tree->LoadTree( ipar[1] );
308 if ( ipar[1] < last ) {
309 unsigned long entry = ipar[1];
310 if ( tree->GetEntry( entry ) > 1 ) {
312 string* spar =
nullptr;
313 for ( k = 0; k <
n; ++k ) {
314 Cont::value_type j = it[k];
315 switch ( j->type() ) {
320 spar = (
string*)pA->
par();
321 ipar = (
unsigned long*)pA->
ipar();
326 if ( ls.first->dbase >= 0 ) {
330 r->
dbase += ls.first->dbase;
332 r->
link += ls.first->link;
334 if (
log().isActive() ) {
335 log() <<
"Refs: LS [" << entry <<
"] -> " << ls.first->dbase <<
"," << ls.first->container <<
"," 336 << ls.first->link <<
"," << ls.first->entry <<
" DB:" << con->
getDb( r->
dbase ) <<
endmsg;
371 if ( pAddr )
return S_OK;
374 string path = fileName( pRegistry );
375 string cntName = containerName( pRegistry );
376 string secName = cntName.
c_str();
380 return makeError(
"Failed to access Tuple file:" + path );
382 TTree* tree = con->
getSection( _tr( secName ),
true );
383 if (
nullptr != nt ) {
388 os << nt->
title() <<
';' << pObj->
clID() <<
';' << items.
size() <<
';';
390 TBranch* b =
nullptr;
391 for ( item_no = 0; item_no < items.
size(); ++item_no ) {
395 const string&
n = itm->
name();
396 switch ( itm->
type() ) {
399 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
403 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
407 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
411 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
415 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
419 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
423 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
427 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
430 return makeError(
"Column " + it->
index() +
" is not a valid index column!" );
435 for ( item_no = 0; item_no < items.
size(); ++item_no ) {
437 const string&
n = it->
name();
438 os <<
'{' << n <<
';' << it->
type() <<
';' << it->
length() <<
';' << it->
ndim() <<
';' << it->
hasIndex() <<
';';
440 os << it->
index() <<
';';
442 switch ( itm->
type() ) {
468 return makeError(
"NTuple:" + pRegistry->
name() +
" Column " + it->
index() +
469 " is not a valid index column!" );
472 for (
long k = 0; k < it->
ndim(); k++ ) {
473 os << it->
dim( k ) <<
';';
476 TClass* cl =
nullptr;
477 switch ( it->
type() ) {
480 os << 0 <<
';' << 0 <<
';';
484 os << 0 <<
';' << 0 <<
';';
487 if ( it->
length() == 1 ) {
489 os << 0 <<
';' << 0 <<
';';
490 cl = TClass::GetClass( desc.
c_str(), kTRUE );
494 if ( it->
length() == 1 ) {
495 os << 0 <<
';' << 0 <<
';';
496 cl = TClass::GetClass( it->
typeID(), kTRUE );
545 return makeError(
"Create item[FAIL]: " + it->
name() );
548 if ( branches.
find( n ) == branches.
end() ) {
551 switch ( it->
ndim() ) {
562 desc = n + tmp +
"[" + itm->
name() +
"]" + desc;
565 desc = n + tmp + text + desc;
569 switch ( it->
type() ) {
571 branches[
n] = tree->Branch( n.
c_str(), cl->GetName(),
const_cast<void*
>( it->
buffer() ) );
574 branches[
n] = tree->Branch( n.
c_str(), cl->GetName(),
const_cast<void*
>( it->
buffer() ) );
577 branches[
n] = tree->Branch( n.
c_str(),
const_cast<void*
>( it->
buffer() ), desc.
c_str() );
584 status = saveDescription( path, cntName, os.
str(),
"", pObj->
clID() );
586 status = m_dbMgr->commitOutput( path,
true );
588 string spar[] = {
path, cntName};
589 unsigned long ipar[] = {(
unsigned long)con, ~0x0u};
590 status = m_dbMgr->createAddress( repSvcType(), pObj->
clID(), spar, ipar, pAddr );
593 ( (
unsigned long*)rpA->
ipar() )[0] = (
unsigned long)con;
614 if ( tupl && pReg && rpA ) {
615 string cntName = containerName( pReg );
616 unsigned long* ipar =
const_cast<unsigned long*
>( pAddr->
ipar() );
621 Cont& it = tupl->
items();
622 size_t k,
n = it.size();
625 for ( k = 0; k <
n; ++k ) {
627 Cont::value_type j = it[k];
628 switch ( j->type() ) {
635 addr[k].entry = pA->
ipar()[1];
637 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
643 int nb = tree->Fill();
644 if ( nb > 1 ) ++ipar[1];
645 for ( k = 0; k <
n; ++k ) it[k]->reset();
648 return makeError(
"fillRepRefs> Failed to access data tree:" + cntName );
650 return makeError(
"fillRepRefs> Failed to access data source!" );
652 return makeError(
"fillRepRefs> Invalid Tuple reference." );
655 #ifdef __POOL_COMPATIBILITY 667 IOBuffer() =
default;
685 static inline int load(
int blob, IOBuffer& s,
void* buff )
690 s.swapFromBuffer( buff, len *
sizeof( T ) );
697 inline int load<string>(
int blob, IOBuffer&
s,
void* ptr )
700 string* str = (
string*)ptr;
710 const string*
par = rpA->
par();
711 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
713 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
714 Cont& it = tupl->
items();
715 size_t k,
n = it.size();
719 for ( k = 0; k <
n; ++k ) {
720 Cont::value_type j = it[k];
721 switch ( j->type() ) {
724 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
727 if (
nullptr == tree->GetBranch( j->name().c_str() ) ) blob_items[k] = 1;
731 ULong64_t last = (ULong64_t)tree->GetEntries();
735 if ( !( criteria.
length() == 0 || criteria ==
"*" ) ) {
736 if ( rpA->
select ==
nullptr ) {
738 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.
c_str(), tree );
740 rpA->
select->SetTree( tree );
742 for ( ; ipar[1] < last; ++ipar[1] ) {
743 tree->LoadTree( ipar[1] );
752 if ( ipar[1] < last ) {
755 tree->GetBranch(
"BlobData" )->SetAddress( &pblob );
756 if ( tree->GetEntry( ipar[1] ) > 1 ) {
759 for ( k = 0; k <
n; ++k ) {
760 Cont::value_type j = it[k];
761 char* buf = (
char*)j->buffer();
762 switch ( j->type() ) {
767 string* spar = (
string*)pA->
par();
768 ipar = (
unsigned long*)pA->
ipar();
773 ipar[1] = addr[k].token.m_oid.second;
786 sc = load<unsigned char>( blob_items[k], blob, buf );
789 sc = load<unsigned short>( blob_items[k], blob, buf );
792 sc = load<unsigned int>( blob_items[k], blob, buf );
795 sc = load<unsigned long>( blob_items[k], blob, buf );
798 sc = load<char>( blob_items[k], blob, buf );
801 sc = load<short>( blob_items[k], blob, buf );
804 sc = load<int>( blob_items[k], blob, buf );
807 sc = load<long>( blob_items[k], blob, buf );
810 sc = load<bool>( blob_items[k], blob, buf );
813 sc = load<float>( blob_items[k], blob, buf );
816 sc = load<double>( blob_items[k], blob, buf );
819 sc = load<string>( blob_items[k], blob, buf );
822 sc = load<char*>( blob_items[k], blob, buf );
836 log() <<
"CANNOT Set Ntuple token: dynamic_cast<GenericAddress*> is NULL";
839 log() <<
"CANNOT Set Ntuple token: invalid address buffer";
virtual const std::string & name() const =0
Access _Item name.
constexpr static const auto FAILURE
virtual const ItemRange & range() const =0
Access the range if specified.
A select statement can either contain.
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
const std::string & getDb(int which) const
Access database/file name from saved index.
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 StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
virtual IRegistry * registry() const =0
Update branch name.
virtual const name_type & name() const =0
Name of the directory (or key)
const std::string & getLink(int which) const
Access link name from saved index.
virtual unsigned long release()=0
release reference to object
Generic Transient Address.
virtual ISelectStatement * selector()=0
Access selector.
virtual const std::string * par() const =0
Retrieve String parameters.
IRegistry * registry() const
Get pointer to Registry.
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.
const long POOL_ROOTKEY_StorageType
NTuple interface class definition.
virtual const std::string & criteria() const =0
Access the selection string.
int dbase
Data members to define object location in the persistent world.
Persistent reference object.
virtual long ndim() const =0
Dimension.
StreamBuffer & operator>>(StreamBuffer &s, std::vector< T > &v)
NTuple interface class definition.
void setClID(const CLID &clid)
Access : Set class ID of the link.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
virtual long length() const =0
Access the buffer length.
This class is used for returning status codes from appropriate routines.
const unsigned long * ipar() const override
Retrieve integer parameters.
const std::string * par() const override
Retrieve string parameters.
TTree * getSection(boost::string_ref sect, bool create=false)
Access TTree section from section name. The section is created if required.
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
const std::string & getCont(int which) const
Access container name from saved index.
TYP upper() const
Upper boundary of range.
Abstract class describing basic data in an Ntuple.
unsigned int CLID
Class ID definition.
const long POOL_ROOT_StorageType
virtual long type() const =0
Type information of the item.
Tool * tool() const
Access tool.
constexpr static const auto SUCCESS
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
virtual const void * buffer() const =0
Access data buffer (CONST)
StatusCode fillRepRefs(IOpaqueAddress *pAdd, DataObject *pObj) override
Resolve the references of the converted object.
TBranch * getBranch(boost::string_ref section, boost::string_ref branch_name)
Access data branch by name: Get existing branch in read only mode.
const long POOL_ROOTTREE_StorageType
unsigned char * m_buffer
Buffer with object content.
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the transient object: NTuples end here when reading records.
void resetAge()
Reset age.
virtual const std::string & index() const =0
Access the index _Item.
std::string container
Identifier of description.
virtual long dim(long i) const =0
Access individual dimensions.
void makeRef(const IRegistry &pA, RootRef &ref)
Create reference object from registry entry.
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)
virtual bool hasIndex() const =0
Is the tuple have an index item?
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.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(boost::string_ref container, int entry) const
Access link section for single container and entry.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual const std::type_info & typeID() const =0
Compiler type ID.
virtual long type() const =0
Access the type of the 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 std::string & title() const =0
Object title.
Helper functions to set/get the application return code.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
TYP lower() const
Lower boundary of range.
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.