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 string path = fileName( pRegistry );
119 string cntName = containerName( pRegistry );
120 string*
par =
const_cast<string*
>( pAddr->
par() );
123 string par_val, par_guid;
124 TBranch* b = con->
getBranch(
"##Descriptors",
"GaudiStatisticsDescription" );
128 b->SetAddress( &ptr );
129 for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
130 int nb = b->GetEntry( i );
139 par[2] = _tr( cntName );
141 if (
nullptr == tree ) {
return makeError(
"Failed to access N-Tuple tree:" + cntName ); }
142 if ( !par_val.
empty() ) {
143 auto ntupleSvc = dataProvider().as<
INTupleSvc>();
151 getline( is, title,
';' ) >> clid >> c >> siz >>
c;
152 status = ntupleSvc->create( clid, title, nt );
153 for (
int j = 0; j < siz && status.
isSuccess(); j++ ) {
155 getline( is, title,
';' ) >> typ >>
c;
158 status = createItem( tree, nt, is, title,
true, (
unsigned char)0 );
161 status = createItem( tree, nt, is, title,
true, (
unsigned short)0 );
164 status = createItem( tree, nt, is, title,
true, 0u );
167 status = createItem( tree, nt, is, title,
true, 0ul );
170 status = createItem( tree, nt, is, title,
true,
char( 0 ) );
173 status = createItem( tree, nt, is, title,
true,
short( 0 ) );
176 status = createItem( tree, nt, is, title,
true, 0 );
179 status = createItem( tree, nt, is, title,
true, 0
l );
182 status = createItem( tree, nt, is, title,
true,
false );
185 status = createItem( tree, nt, is, title,
true, 0.f );
188 status = createItem( tree, nt, is, title,
true, 0. );
203 status = createItem( tree, nt, is, title,
false, static_cast<IOpaqueAddress*>(
nullptr ) );
206 status = createItem( tree, nt, is, title,
true, static_cast<void*>(
nullptr ) );
215 return makeError(
"createObj[NTuple]> Cannot determine column!" );
219 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
221 ipar[0] =
reinterpret_cast<uintptr_t>( con );
226 refpObject =
nullptr;
239 if ( !tupl || !rpA )
return makeError(
"updateObj> Invalid Tuple reference." );
241 if ( !con )
return makeError(
"updateObj> Failed to access data source!" );
243 if ( !tree )
return makeError(
"Failed to access data tree:" + pAddr->
par()[1] );
245 if ( con->
tool()->
refs() )
return i__updateObjRoot( rpA, tupl, tree, con );
246 #ifdef __POOL_COMPATIBILITY 248 return i__updateObjPool( rpA, tupl, tree, con );
250 return makeError(
"Failed to access reference branch for data tree:" + rpA->
par()[1] );
257 const string*
par = rpA->
par();
258 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
260 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
262 Cont& it = tupl->
items();
263 size_t k,
n = it.size();
266 for ( k = 0; k <
n; ++k ) {
267 Cont::value_type j = it[k];
268 switch ( j->type() ) {
271 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
278 ULong64_t last = tree->GetEntries();
282 if ( !( criteria.
length() == 0 || criteria ==
"*" ) ) {
283 if ( rpA->
select ==
nullptr ) {
285 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.
c_str(), tree );
287 rpA->
select->SetTree( tree );
288 for ( ; ipar[1] < last; ++ipar[1] ) {
289 tree->LoadTree( ipar[1] );
296 if ( ipar[1] < last ) {
297 unsigned long entry = ipar[1];
298 if ( tree->GetEntry( entry ) > 1 ) {
300 string* spar =
nullptr;
301 for ( k = 0; k <
n; ++k ) {
302 Cont::value_type j = it[k];
303 switch ( j->type() ) {
308 spar = (
string*)pA->
par();
309 ipar = (
unsigned long*)pA->
ipar();
314 if ( ls.first->dbase >= 0 ) {
318 r->
dbase += ls.first->dbase;
320 r->
link += ls.first->link;
322 if (
log().isActive() ) {
323 log() <<
"Refs: LS [" << entry <<
"] -> " << ls.first->dbase <<
"," << ls.first->container <<
"," 324 << ls.first->link <<
"," << ls.first->entry <<
" DB:" << con->
getDb( r->
dbase ) <<
endmsg;
358 if ( pAddr )
return S_OK;
361 string path = fileName( pRegistry );
362 string cntName = containerName( pRegistry );
363 string secName = cntName.
c_str();
366 if ( !status.
isSuccess() ) {
return makeError(
"Failed to access Tuple file:" + path ); }
367 TTree* tree = con->
getSection( _tr( secName ),
true );
368 if (
nullptr != nt ) {
373 os << nt->
title() <<
';' << pObj->
clID() <<
';' << items.
size() <<
';';
375 TBranch* b =
nullptr;
376 for ( item_no = 0; item_no < items.
size(); ++item_no ) {
380 const string&
n = itm->
name();
381 switch ( itm->
type() ) {
384 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
388 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
392 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
396 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
400 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
404 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
408 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
412 b = tree->Branch( n.
c_str(),
const_cast<void*
>( itm->
buffer() ), desc.
c_str() );
415 return makeError(
"Column " + it->
index() +
" is not a valid index column!" );
420 for ( item_no = 0; item_no < items.
size(); ++item_no ) {
422 const string&
n = it->
name();
423 os <<
'{' << n <<
';' << it->
type() <<
';' << it->
length() <<
';' << it->
ndim() <<
';' << it->
hasIndex() <<
';';
425 os << it->
index() <<
';';
427 switch ( itm->
type() ) {
453 return makeError(
"NTuple:" + pRegistry->
name() +
" Column " + it->
index() +
454 " is not a valid index column!" );
457 for (
long k = 0; k < it->
ndim(); k++ ) { os << it->
dim( k ) <<
';'; }
459 TClass* cl =
nullptr;
460 switch ( it->
type() ) {
463 os << 0 <<
';' << 0 <<
';';
467 os << 0 <<
';' << 0 <<
';';
470 if ( it->
length() == 1 ) {
472 os << 0 <<
';' << 0 <<
';';
473 cl = TClass::GetClass( desc.
c_str(), kTRUE );
477 if ( it->
length() == 1 ) {
478 os << 0 <<
';' << 0 <<
';';
479 cl = TClass::GetClass( it->
typeID(), kTRUE );
528 return makeError(
"Create item[FAIL]: " + it->
name() );
531 if ( branches.
find( n ) == branches.
end() ) {
534 switch ( it->
ndim() ) {
545 desc = n + tmp +
"[" + itm->
name() +
"]" + desc;
548 desc = n + tmp + text + desc;
552 switch ( it->
type() ) {
554 branches[
n] = tree->Branch( n.
c_str(), cl->GetName(),
const_cast<void*
>( it->
buffer() ) );
557 branches[
n] = tree->Branch( n.
c_str(), cl->GetName(),
const_cast<void*
>( it->
buffer() ) );
560 branches[
n] = tree->Branch( n.
c_str(),
const_cast<void*
>( it->
buffer() ), desc.
c_str() );
567 status = saveDescription( path, cntName, os.
str(),
"", pObj->
clID() );
569 status = m_dbMgr->commitOutput( path,
true );
571 string spar[] = {
path, cntName};
572 unsigned long ipar[] = {(
unsigned long)con, ~0x0u};
573 status = m_dbMgr->createAddress( repSvcType(), pObj->
clID(), spar, ipar, pAddr );
576 ( (
unsigned long*)rpA->
ipar() )[0] = (
unsigned long)con;
596 if ( tupl && pReg && rpA ) {
597 string cntName = containerName( pReg );
598 unsigned long* ipar =
const_cast<unsigned long*
>( pAddr->
ipar() );
603 Cont& it = tupl->
items();
604 size_t k,
n = it.size();
607 for ( k = 0; k <
n; ++k ) {
609 Cont::value_type j = it[k];
610 switch ( j->type() ) {
617 addr[k].entry = pA->
ipar()[1];
619 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
625 int nb = tree->Fill();
626 if ( nb > 1 ) ++ipar[1];
627 for ( k = 0; k <
n; ++k ) it[k]->reset();
630 return makeError(
"fillRepRefs> Failed to access data tree:" + cntName );
632 return makeError(
"fillRepRefs> Failed to access data source!" );
634 return makeError(
"fillRepRefs> Invalid Tuple reference." );
637 #ifdef __POOL_COMPATIBILITY 647 IOBuffer() =
default;
648 virtual ~IOBuffer() {
663 static inline int load(
int blob, IOBuffer& s,
void* buff ) {
667 s.swapFromBuffer( buff, len *
sizeof( T ) );
674 inline int load<string>(
int blob, IOBuffer&
s,
void* ptr ) {
676 string* str = (
string*)ptr;
685 const string*
par = rpA->
par();
686 unsigned long* ipar =
const_cast<unsigned long*
>( rpA->
ipar() );
688 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
689 Cont& it = tupl->
items();
690 size_t k,
n = it.size();
694 for ( k = 0; k <
n; ++k ) {
695 Cont::value_type j = it[k];
696 switch ( j->type() ) {
699 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
702 if (
nullptr == tree->GetBranch( j->name().c_str() ) ) blob_items[k] = 1;
706 ULong64_t last = (ULong64_t)tree->GetEntries();
710 if ( !( criteria.
length() == 0 || criteria ==
"*" ) ) {
711 if ( rpA->
select ==
nullptr ) {
713 rpA->
select =
new TTreeFormula( tree->GetName(), criteria.
c_str(), tree );
715 rpA->
select->SetTree( tree );
717 for ( ; ipar[1] < last; ++ipar[1] ) {
718 tree->LoadTree( ipar[1] );
725 if ( ipar[1] < last ) {
728 tree->GetBranch(
"BlobData" )->SetAddress( &pblob );
729 if ( tree->GetEntry( ipar[1] ) > 1 ) {
732 for ( k = 0; k <
n; ++k ) {
733 Cont::value_type j = it[k];
734 char* buf = (
char*)j->buffer();
735 switch ( j->type() ) {
740 string* spar = (
string*)pA->
par();
741 ipar = (
unsigned long*)pA->
ipar();
746 ipar[1] = addr[k].token.m_oid.second;
759 sc = load<unsigned char>( blob_items[k], blob, buf );
762 sc = load<unsigned short>( blob_items[k], blob, buf );
765 sc = load<unsigned int>( blob_items[k], blob, buf );
768 sc = load<unsigned long>( blob_items[k], blob, buf );
771 sc = load<char>( blob_items[k], blob, buf );
774 sc = load<short>( blob_items[k], blob, buf );
777 sc = load<int>( blob_items[k], blob, buf );
780 sc = load<long>( blob_items[k], blob, buf );
783 sc = load<bool>( blob_items[k], blob, buf );
786 sc = load<float>( blob_items[k], blob, buf );
789 sc = load<double>( blob_items[k], blob, buf );
792 sc = load<string>( blob_items[k], blob, buf );
795 sc = load<char*>( blob_items[k], blob, buf );
809 log() <<
"CANNOT Set Ntuple token: dynamic_cast<GenericAddress*> is NULL";
812 log() <<
"CANNOT Set Ntuple token: invalid address buffer";
virtual const std::string & name() const =0
Access _Item name.
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.
constexpr static const auto SUCCESS
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.
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.
constexpr static const auto FAILURE
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.