The Gaudi Framework  master (991ff291)
Loading...
Searching...
No Matches
Gaudi::RootNTupleCnv Class Reference

NTuple converter class definition for NTuples writted/read using ROOT. More...

#include <Root/RootNTupleCnv.h>

Inheritance diagram for Gaudi::RootNTupleCnv:
Collaboration diagram for Gaudi::RootNTupleCnv:

Public Member Functions

 RootNTupleCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Standard constructor.
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAdd) override
 Converter overrides: Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAdd, DataObject *pObj) override
 Resolve the references of the converted object.
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Converter overrides: Update the references of an updated transient object.
 
StatusCode fillObjRefs (IOpaqueAddress *, DataObject *) override
 Converter overrides: Update the references of an updated transient object.
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the transient object: NTuples end here when reading records.
 
StatusCode updateObjRefs (IOpaqueAddress *, DataObject *) override
 Converter overrides: Update the references of an updated transient object.
 
StatusCode updateRep (IOpaqueAddress *, DataObject *) override
 Converter overrides: Update the converted representation of a transient object.
 
StatusCode updateRepRefs (IOpaqueAddress *, DataObject *) override
 Converter overrides: Update the converted representation of a transient object.
 
- Public Member Functions inherited from Gaudi::RootStatCnv
 RootStatCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor.
 
- Public Member Functions inherited from Gaudi::RootConverter
 RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor.
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses.
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override
 Converter overrides: Create transient object from persistent data.
 
StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object.
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Converter overrides: Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object.
 
- Public Member Functions inherited from Converter
StatusCode initialize () override
 Initialize the converter.
 
StatusCode finalize () override
 Initialize the converter.
 
StatusCode setDataProvider (IDataProviderSvc *svc) override
 Set Data provider service.
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Get Data provider service.
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Set conversion service the converter is connected to.
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Get conversion service the converter is connected to.
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility.
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility.
 
const CLIDobjType () const override
 Retrieve the class type of objects the converter produces.
 
virtual long i_repSvcType () const
 Retrieve the class type of the data store the converter uses.
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Create the transient representation of an object.
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the created transient object.
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Update the transient object from the other representation.
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an updated transient object.
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the converted object.
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the converted representation of a transient object.
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an already converted object.
 
 Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
 Standard Constructor.
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true) const
 Return a pointer to the service identified by name (or "type/name")
 
- Public Member Functions inherited from implements< IConverter >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
 implements ()=default
 Default constructor.
 
 implements (const implements &)
 Copy constructor (zero the reference count)
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count).
 
unsigned long addRef () const override
 Reference Interface instance.
 
unsigned long release () const override
 Release Interface instance.
 
unsigned long refCount () const override
 Current reference count.
 

Protected Member Functions

StatusCode i__updateObjRoot (RootAddress *rpA, INTuple *tupl, TTree *tree, RootDataConnection *con)
 Update the transient object: NTuples end here when reading records.
 
- Protected Member Functions inherited from Gaudi::RootStatCnv
MsgStreamlog () const
 Helper to use mesage logger.
 
StatusCode initialize () override
 Initialize converter object.
 
StatusCode finalize () override
 Finalize converter object.
 
virtual const std::string containerName (IRegistry *pDir) const
 Retrieve the name of the container a given object is placed into.
 
virtual const std::string fileName (IRegistry *pReg) const
 Retrieve the name of the file a given object is placed into.
 
virtual const std::string topLevel (IRegistry *pReg) const
 Retrieve the full path of the file a given object is placed into.
 
StatusCode makeError (const std::string &msg, bool throw_exception=false) const
 Helper method to issue error messages.
 
StatusCode saveDescription (const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
 Save statistics object description.
 
- Protected Member Functions inherited from Converter
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service.
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service.
 
- Protected Member Functions inherited from implements< IConverter >
unsigned long decRef () const override
 

Additional Inherited Members

- Public Types inherited from Converter
using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>
 
- Public Types inherited from implements< IConverter >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
using iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Protected Attributes inherited from Gaudi::RootStatCnv
SmartIF< IDataManagerSvcm_dataMgr
 Reference to data manager service to manipulate the TES.
 
std::unique_ptr< MsgStreamm_log
 Reference to logger object.
 
- Protected Attributes inherited from Gaudi::RootConverter
RootCnvSvcm_dbMgr
 Conversion service needed for proper operation to forward requests.
 
- Protected Attributes inherited from implements< IConverter >
std::atomic_ulong m_refCount
 Reference counter.
 

Detailed Description

NTuple converter class definition for NTuples writted/read using ROOT.

Description: Definition of the generic converter for row wise and column wise Ntuples.

Author
M.Frank
Version
1.0

Definition at line 44 of file RootNTupleCnv.h.

Constructor & Destructor Documentation

◆ RootNTupleCnv()

Gaudi::RootNTupleCnv::RootNTupleCnv ( long typ,
const CLID & clid,
ISvcLocator * svc,
RootCnvSvc * mgr )
inline

Standard constructor.

Parameters
clid[IN] Class ID of the object type to be converted.
db[IN] Pointer to POOL database interface
svc[IN] Pointer to Gaudi service locator
Returns
Reference to RootNTupleCnv object

Definition at line 58 of file RootNTupleCnv.h.

59 : RootStatCnv( typ, clid, svc, mgr ) {}
RootStatCnv(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.

Member Function Documentation

◆ createObj()

StatusCode RootNTupleCnv::createObj ( IOpaqueAddress * pAddress,
DataObject *& refpObject )
override

Converter overrides: Update the references of an updated transient object.

Parameters
pAddress[IN] Valid pointer to the object's opaque address
refpObject[OUT] Location to store pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 155 of file RootNTupleCnv.cpp.

155 {
156 StatusCode status = S_FAIL;
157 RootDataConnection* con = nullptr;
158 IRegistry* pRegistry = pAddr->registry();
159 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
160 string path = fileName( pRegistry );
161 string cntName = containerName( pRegistry );
162 string* par = const_cast<string*>( pAddr->par() );
163 status = m_dbMgr->connectDatabase( path, IDataConnection::READ, &con );
164 if ( status.isSuccess() ) {
165 string par_val, par_guid;
166 TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription" );
167 if ( b ) {
168 RootNTupleDescriptor* ptr;
169 std::unique_ptr<RootNTupleDescriptor> dsc( ptr = new RootNTupleDescriptor() );
170 b->SetAddress( &ptr );
171 for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
172 int nb = b->GetEntry( i );
173 if ( nb > 1 ) {
174 if ( ptr->container == cntName ) {
175 par_val = ptr->description;
176 break;
177 }
178 }
179 }
180 }
181 par[2] = _tr( cntName );
182 TTree* tree = con->getSection( par[2] );
183 if ( nullptr == tree ) { return makeError( "Failed to access N-Tuple tree:" + cntName ); }
184 if ( !par_val.empty() ) {
185 auto ntupleSvc = dataProvider().as<INTupleSvc>();
186 if ( ntupleSvc ) {
187 char c;
188 CLID clid;
189 int siz, typ;
190 string title;
191 NTuple::Tuple* nt = nullptr;
192 istringstream is( par_val );
193 getline( is, title, ';' ) >> clid >> c >> siz >> c;
194 status = ntupleSvc->create( clid, title, nt );
195 for ( int j = 0; j < siz && status.isSuccess(); j++ ) {
196 is >> c;
197 getline( is, title, ';' ) >> typ >> c;
198 switch ( typ ) {
200 status = createItem( tree, nt, is, title, true, (unsigned char)0 );
201 break;
203 status = createItem( tree, nt, is, title, true, (unsigned short)0 );
204 break;
206 status = createItem( tree, nt, is, title, true, 0u );
207 break;
209 status = createItem( tree, nt, is, title, true, 0ul );
210 break;
212 status = createItem( tree, nt, is, title, true, char( 0 ) );
213 break;
215 status = createItem( tree, nt, is, title, true, short( 0 ) );
216 break;
218 status = createItem( tree, nt, is, title, true, 0 );
219 break;
221 status = createItem( tree, nt, is, title, true, 0l );
222 break;
224 status = createItem( tree, nt, is, title, true, false );
225 break;
227 status = createItem( tree, nt, is, title, true, 0.f );
228 break;
230 status = createItem( tree, nt, is, title, true, 0. );
231 break;
232 /*
233 case DataTypeInfo::NTCHAR:
234 case DataTypeInfo::LONG_NTCHAR:
235 status =
236 createItem(tree, nt, is, title, true, (char*)0);
237 break;
238 case DataTypeInfo::STRING:
239 case DataTypeInfo::LONG_STRING:
240 status =
241 createItem(tree, nt, is, title, true, string(""));
242 break;
243 */
245 status = createItem( tree, nt, is, title, false, static_cast<IOpaqueAddress*>( nullptr ) );
246 break;
248 status = createItem( tree, nt, is, title, true, static_cast<void*>( nullptr ) );
249 break;
251 default:
252 status = S_FAIL;
253 break;
254 }
255 if ( !status.isSuccess() ) {
256 log() << MSG::FATAL << "Error connecting (Unknown) column:" << j << endmsg << par_val << endmsg;
257 return makeError( "createObj[NTuple]> Cannot determine column!" );
258 }
259 }
260 if ( status.isSuccess() && rpA ) {
261 unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
262 log() << MSG::DEBUG << "Created N-tuple with description:" << par_val << endl;
263 ipar[0] = reinterpret_cast<uintptr_t>( con );
264 ipar[1] = ~0x0UL;
265 rpA->section = tree;
266 refpObject = nt;
267 } else {
268 refpObject = nullptr;
269 if ( nt ) nt->release();
270 }
271 }
272 }
273 }
274 return status;
275}
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define S_FAIL
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition Converter.cpp:77
virtual unsigned long release()
release reference to object
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition RootAddress.h:47
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
TTree * getSection(std::string_view sect, bool create=false)
Access TTree section from section name. The section is created if required.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
MsgStream & log() const
Helper to use mesage logger.
Definition RootStatCnv.h:47
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
const unsigned long * ipar() const override
Retrieve integer parameters.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition SmartIF.h:110
bool isSuccess() const
Definition StatusCode.h:314
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
@ FATAL
Definition IMessageSvc.h:22
@ DEBUG
Definition IMessageSvc.h:22
std::string description
Description string.
Definition RootRefs.h:88
std::string container
Identifier of description.
Definition RootRefs.h:92

◆ createRep()

StatusCode RootNTupleCnv::createRep ( DataObject * pObj,
IOpaqueAddress *& refpAdd )
override

Converter overrides: Convert the transient object to the requested representation.

Convert the transient object to the requested representation.

Parameters
pObj[IN] Valid pointer to DataObject
refpAdd[OUT] Location to store pointer to the object's opaque address
Returns
Status code indicating success or failure

Definition at line 391 of file RootNTupleCnv.cpp.

391 {
392 IRegistry* pRegistry = pObj->registry();
393 if ( pRegistry ) {
394 pAddr = pRegistry->address();
395 if ( pAddr ) return S_OK;
396
397 RootDataConnection* con = nullptr;
398 string path = fileName( pRegistry );
399 string cntName = containerName( pRegistry );
400 string secName = cntName;
401 const INTuple* nt = dynamic_cast<const INTuple*>( pObj );
402 StatusCode status = m_dbMgr->connectDatabase( path, IDataConnection::UPDATE, &con );
403 if ( !status.isSuccess() ) { return makeError( "Failed to access Tuple file:" + path ); }
404 TTree* tree = con->getSection( _tr( secName ), true );
405 if ( nullptr != nt ) {
406 const INTuple::ItemContainer& items = nt->items();
407 ostringstream os;
408 size_t item_no;
409 string desc;
410 os << nt->title() << ';' << pObj->clID() << ';' << items.size() << ';';
411 map<string, TBranch*> branches;
412 TBranch* b = nullptr;
413 for ( item_no = 0; item_no < items.size(); ++item_no ) {
414 INTupleItem* it = items[item_no];
415 if ( it->hasIndex() ) {
416 INTupleItem* itm = it->indexItem();
417 const string& n = itm->name();
418 switch ( itm->type() ) {
420 desc = n + "/b";
421 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
422 break;
424 desc = n + "/s";
425 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
426 break;
428 desc = n + "/i";
429 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
430 break;
432 desc = n + "/l";
433 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
434 break;
436 desc = n + "/B";
437 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
438 break;
440 desc = n + "/S";
441 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
442 break;
444 desc = n + "/I";
445 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
446 break;
448 desc = n + "/L";
449 b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
450 break;
451 default:
452 return makeError( "Column " + it->index() + " is not a valid index column!" );
453 }
454 branches[n] = b;
455 }
456 }
457 for ( item_no = 0; item_no < items.size(); ++item_no ) {
458 INTupleItem* it = items[item_no];
459 const string& n = it->name();
460 os << '{' << n << ';' << it->type() << ';' << it->length() << ';' << it->ndim() << ';' << it->hasIndex() << ';';
461 if ( it->hasIndex() ) {
462 os << it->index() << ';';
463 INTupleItem* itm = it->indexItem();
464 switch ( itm->type() ) {
466 putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( itm ) );
467 break;
469 putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( itm ) );
470 break;
472 putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( itm ) );
473 break;
475 putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( itm ) );
476 break;
478 putRange( os, dynamic_cast<NTuple::_Data<char>*>( itm ) );
479 break;
481 putRange( os, dynamic_cast<NTuple::_Data<short>*>( itm ) );
482 break;
484 putRange( os, dynamic_cast<NTuple::_Data<int>*>( itm ) );
485 break;
487 putRange( os, dynamic_cast<NTuple::_Data<long>*>( itm ) );
488 break;
489 default:
490 return makeError( "NTuple:" + pRegistry->name() + " Column " + it->index() +
491 " is not a valid index column!" );
492 }
493 }
494 for ( long k = 0; k < it->ndim(); k++ ) { os << it->dim( k ) << ';'; }
495 desc = n;
496 TClass* cl = nullptr;
497 switch ( it->type() ) {
499 desc = "/C";
500 os << 0 << ';' << 0 << ';';
501 break;
503 desc = "/C";
504 os << 0 << ';' << 0 << ';';
505 break;
507 if ( it->length() == 1 ) {
508 desc = System::typeinfoName( typeid( RootRef ) );
509 os << 0 << ';' << 0 << ';';
510 cl = TClass::GetClass( desc.c_str(), kTRUE );
511 }
512 break;
514 if ( it->length() == 1 ) {
515 os << 0 << ';' << 0 << ';';
516 cl = TClass::GetClass( it->typeID(), kTRUE );
517 }
518 break;
520 desc = "/b";
521 putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( it ) );
522 break;
524 desc = "/s";
525 putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( it ) );
526 break;
528 desc = "/i";
529 putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( it ) );
530 break;
532 desc = "/l";
533 putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( it ) );
534 break;
536 desc = "/B";
537 putRange( os, dynamic_cast<NTuple::_Data<char>*>( it ) );
538 break;
540 desc = "/S";
541 putRange( os, dynamic_cast<NTuple::_Data<short>*>( it ) );
542 break;
544 desc = "/I";
545 putRange( os, dynamic_cast<NTuple::_Data<int>*>( it ) );
546 break;
548 desc = "/L";
549 putRange( os, dynamic_cast<NTuple::_Data<long>*>( it ) );
550 break;
552 desc = "/b";
553 putRange( os, dynamic_cast<NTuple::_Data<bool>*>( it ) );
554 break;
556 desc = "/F";
557 putRange( os, dynamic_cast<NTuple::_Data<float>*>( it ) );
558 break;
560 desc = "/D";
561 putRange( os, dynamic_cast<NTuple::_Data<double>*>( it ) );
562 break;
564 default:
565 return makeError( "Create item[FAIL]: " + it->name() );
566 }
567 os << '}';
568 if ( branches.find( n ) == branches.end() ) {
569 string tmp;
570 char text[32];
571 switch ( it->ndim() ) {
572 case 0:
573 desc = n + desc;
574 break;
575 case 2:
576 snprintf( text, sizeof( text ), "[%ld]", it->dim( 0 ) );
577 tmp = text;
578 [[fallthrough]];
579 case 1:
580 if ( it->hasIndex() ) {
581 INTupleItem* itm = it->indexItem();
582 desc = n + tmp + "[" + itm->name() + "]" + desc;
583 } else {
584 snprintf( text, sizeof( text ), "[%ld]", it->dim( 0 ) );
585 desc = n + tmp + text + desc;
586 }
587 }
588 log() << MSG::DEBUG << "Create branch:" << n << " Desc:" << desc << " of type:" << it->type() << endmsg;
589 switch ( it->type() ) {
591 branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
592 break;
594 branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
595 break;
596 default:
597 branches[n] = tree->Branch( n.c_str(), const_cast<void*>( it->buffer() ), desc.c_str() );
598 break;
599 }
600 }
601 }
602
603 log() << MSG::DEBUG << "Save description:" << path << " -> " << cntName << endmsg << os.str() << endmsg;
604 status = saveDescription( path, cntName, os.str(), "", pObj->clID() );
605 if ( status.isSuccess() ) {
606 status = m_dbMgr->commitOutput( path, true );
607 if ( status.isSuccess() ) {
608 string spar[] = { path, cntName };
609 unsigned long ipar[] = { (unsigned long)con, ~0x0u };
610 status = m_dbMgr->createAddress( repSvcType(), pObj->clID(), spar, ipar, pAddr );
611 if ( status.isSuccess() ) {
612 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
613 if ( rpA ) {
614 ( (unsigned long*)rpA->ipar() )[0] = (unsigned long)con;
615 rpA->section = tree;
616 } else {
617 log() << MSG::ERROR << "cannot dynamic cast to RootAddress" << endmsg;
618 }
619
620 } else {
621 pAddr->release();
622 pAddr = nullptr;
623 }
624 }
625 }
626 return status;
627 }
628 }
629 return S_FAIL;
630}
#define S_OK
IRegistry * registry() const
Get pointer to Registry.
Definition DataObject.h:79
virtual const CLID & clID() const
Retrieve reference to class definition structure.
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
StatusCode saveDescription(const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
Save statistics object description.
std::vector< INTupleItem * > ItemContainer
Definition INTuple.h:93
virtual ItemContainer & items()=0
Access item container.
virtual const std::string & title() const =0
Object title.
virtual long ndim() const =0
Dimension.
virtual const void * buffer() const =0
Access data buffer (CONST)
virtual long dim(long i) const =0
Access individual dimensions.
virtual const std::string & index() const =0
Access the index _Item.
virtual const std::type_info & typeID() const =0
Compiler type ID.
virtual long type() const =0
Type information of the item.
virtual long length() const =0
Access the buffer length.
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
virtual const std::string & name() const =0
Access _Item name.
virtual bool hasIndex() const =0
Is the tuple have an index item?
virtual const name_type & name() const =0
Name of the directory (or key)
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
@ ERROR
Definition IMessageSvc.h:22
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ fillObjRefs()

StatusCode Gaudi::RootNTupleCnv::fillObjRefs ( IOpaqueAddress * ,
DataObject *  )
inlineoverride

Converter overrides: Update the references of an updated transient object.

Parameters
pAddress[IN] Valid pointer to the object's opaque address
pObject[IN] Valid pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 99 of file RootNTupleCnv.h.

99 {
100 return StatusCode::SUCCESS;
101 }
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ fillRepRefs()

StatusCode RootNTupleCnv::fillRepRefs ( IOpaqueAddress * pAdd,
DataObject * pObj )
override

Resolve the references of the converted object.

Parameters
pAdd[IN] Valid pointer to the object's opaque address
pObj[IN] Valid pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 633 of file RootNTupleCnv.cpp.

633 {
634 typedef INTuple::ItemContainer Cont;
635 INTuple* tupl = dynamic_cast<INTuple*>( pObj );
636 IRegistry* pReg = pObj->registry();
637 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
638 if ( tupl && pReg && rpA ) {
639 string cntName = containerName( pReg );
640 unsigned long* ipar = const_cast<unsigned long*>( pAddr->ipar() );
641 RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
642 if ( con ) {
643 TTree* tree = rpA->section;
644 if ( tree ) {
645 Cont& it = tupl->items();
646 size_t k, n = it.size();
647 vector<RootRef*> paddr( n );
648 vector<RootRef> addr( n );
649 for ( k = 0; k < n; ++k ) {
650 IOpaqueAddress* pA = nullptr;
651 Cont::value_type j = it[k];
652 switch ( j->type() ) {
654 pA = ( *(IOpaqueAddress**)j->buffer() );
655 paddr[k] = &addr[k];
656 addr[k].reset();
657 if ( pA ) {
658 con->makeRef( *pA->registry(), addr[k] );
659 addr[k].entry = pA->ipar()[1];
660 }
661 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
662 break;
663 default:
664 break;
665 }
666 }
667 int nb = tree->Fill();
668 if ( nb > 1 ) ++ipar[1];
669 for ( k = 0; k < n; ++k ) it[k]->reset();
671 }
672 return makeError( "fillRepRefs> Failed to access data tree:" + cntName );
673 }
674 return makeError( "fillRepRefs> Failed to access data source!" );
675 }
676 return makeError( "fillRepRefs> Invalid Tuple reference." );
677}
void makeRef(const IRegistry &pA, RootRef &ref)
Create reference object from registry entry.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
virtual IRegistry * registry() const =0
Update branch name.
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ i__updateObjRoot()

StatusCode RootNTupleCnv::i__updateObjRoot ( RootAddress * rpA,
INTuple * tupl,
TTree * tree,
RootDataConnection * con )
protected

Update the transient object: NTuples end here when reading records.

Definition at line 292 of file RootNTupleCnv.cpp.

292 {
293 typedef INTuple::ItemContainer Cont;
294 const string* par = rpA->par();
295 unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
296 ++ipar[1];
297 if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
298 GenericAddress* pA = nullptr;
299 Cont& it = tupl->items();
300 size_t k, n = it.size();
301 vector<RootRef*> paddr( n );
302 vector<RootRef> addr( n );
303 for ( k = 0; k < n; ++k ) {
304 Cont::value_type j = it[k];
305 switch ( j->type() ) {
307 paddr[k] = &addr[k];
308 tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
309 break;
310 default:
311 break;
312 }
313 }
314
315 ULong64_t last = tree->GetEntries();
316 ISelectStatement* sel = tupl->selector();
317 if ( sel ) {
318 string criteria = ( sel && ( sel->type() & ISelectStatement::STRING ) ) ? sel->criteria() : string( "" );
319 if ( !( criteria.length() == 0 || criteria == "*" ) ) {
320 if ( rpA->select == nullptr ) {
321 log() << MSG::DEBUG << "Selection criteria: " << criteria << " " << ipar[1] << endmsg;
322 rpA->select = new TTreeFormula( tree->GetName(), criteria.c_str(), tree );
323 }
324 rpA->select->SetTree( tree );
325 for ( ; ipar[1] < last; ++ipar[1] ) { // loop on all selected entries
326 tree->LoadTree( ipar[1] );
327 rpA->select->GetNdata();
328 if ( fabs( rpA->select->EvalInstance( 0 ) ) > std::numeric_limits<double>::epsilon() ) { break; }
329 log() << MSG::DEBUG << par[0] << "/" << par[1] << " SKIP Entry: " << ipar[1] << endmsg;
330 }
331 }
332 }
333 if ( ipar[1] < last ) {
334 unsigned long entry = ipar[1];
335 if ( tree->GetEntry( entry ) > 1 ) {
336 RootRef* r = nullptr;
337 string* spar = nullptr;
338 for ( k = 0; k < n; ++k ) {
339 Cont::value_type j = it[k];
340 switch ( j->type() ) {
342 r = paddr[k];
343 pA = ( *(GenericAddress**)j->buffer() );
344 if ( pA ) { // Fill only if item is connected!
345 spar = const_cast<string*>( pA->par() );
346 ipar = const_cast<unsigned long*>( pA->ipar() );
347 log() << MSG::DEBUG;
348 pair<const RootRef*, const RootDataConnection::ContainerSection*> ls =
349 con->getMergeSection( tree->GetName(), entry );
350 if ( ls.first ) {
351 if ( ls.first->dbase >= 0 ) {
352 // Now patch the references and links 'en block' to be efficient
353 // First the leafs from the TES
354
355 r->dbase += ls.first->dbase;
356 r->container += ls.first->container;
357 r->link += ls.first->link;
358
359 if ( log().isActive() ) {
360 log() << "Refs: LS [" << entry << "] -> " << ls.first->dbase << "," << ls.first->container << ","
361 << ls.first->link << "," << ls.first->entry << " DB:" << con->getDb( r->dbase ) << endmsg;
362 }
363 }
364 }
365 spar[0] = con->getDb( r->dbase );
366 spar[1] = con->getCont( r->container );
367 spar[2] = con->getLink( r->link );
368 ipar[0] = 0;
369 ipar[1] = r->entry;
370 pA->setClID( r->clid );
371 pA->setSvcType( r->svc );
372 break;
373 }
374 break;
375 default:
376 break;
377 }
378 }
379 return StatusCode::SUCCESS;
380 }
381 log() << MSG::ERROR << "Failed to read data from NTuple tree." << endmsg;
382 return StatusCode::FAILURE;
383 }
384 log() << MSG::INFO << "End of input Ntuple." << endmsg;
385 return StatusCode::FAILURE;
386 }
387 return StatusCode::FAILURE;
388}
TTreeFormula * select
Pointer to ROOT select statement (filled for N-tuples only)
Definition RootAddress.h:45
const std::string & getLink(int which) const
Access link name from saved index.
const std::string & getDb(int which) const
Access database/file name from saved index.
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 & getCont(int which) const
Access container name from saved index.
void setClID(const CLID &clid)
Access : Set class ID of the link.
const std::string * par() const override
Retrieve string parameters.
void setSvcType(long typ)
Access : set the storage type of the class id.
virtual ISelectStatement * selector()=0
Access selector.
@ INFO
Definition IMessageSvc.h:22
int dbase
Data members to define object location in the persistent world.
Definition RootRefs.h:41

◆ updateObj()

StatusCode RootNTupleCnv::updateObj ( IOpaqueAddress * pAddress,
DataObject * pObject )
override

Update the transient object: NTuples end here when reading records.

Parameters
pAddress[IN] Valid pointer to the object's opaque address
pObject[IN] Valid pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 278 of file RootNTupleCnv.cpp.

278 {
279 INTuple* tupl = dynamic_cast<INTuple*>( pObj );
280 RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
281 if ( !tupl || !rpA ) return makeError( "updateObj> Invalid Tuple reference." );
282 RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
283 if ( !con ) return makeError( "updateObj> Failed to access data source!" );
284 TTree* tree = rpA->section;
285 if ( !tree ) return makeError( "Failed to access data tree:" + pAddr->par()[1] );
286 con->resetAge();
287 if ( con->tool()->refs() ) return i__updateObjRoot( rpA, tupl, tree, con );
288 return makeError( "Failed to access reference branch for data tree:" + rpA->par()[1] );
289}
void resetAge()
Reset age.
Tool * tool() const
Access tool.
StatusCode i__updateObjRoot(RootAddress *rpA, INTuple *tupl, TTree *tree, RootDataConnection *con)
Update the transient object: NTuples end here when reading records.

◆ updateObjRefs()

StatusCode Gaudi::RootNTupleCnv::updateObjRefs ( IOpaqueAddress * ,
DataObject *  )
inlineoverride

Converter overrides: Update the references of an updated transient object.

Parameters
pAddress[IN] Valid pointer to the object's opaque address
pObject[IN] Valid pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 120 of file RootNTupleCnv.h.

120 {
121 return StatusCode::SUCCESS;
122 }

◆ updateRep()

StatusCode Gaudi::RootNTupleCnv::updateRep ( IOpaqueAddress * ,
DataObject *  )
inlineoverride

Converter overrides: Update the converted representation of a transient object.

Parameters
pAddress[IN] Valid pointer to the object's opaque address
pObject[IN] Valid pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 132 of file RootNTupleCnv.h.

132 {
133 return StatusCode::SUCCESS;
134 }

◆ updateRepRefs()

StatusCode Gaudi::RootNTupleCnv::updateRepRefs ( IOpaqueAddress * ,
DataObject *  )
inlineoverride

Converter overrides: Update the converted representation of a transient object.

Parameters
pAddress[IN] Valid pointer to the object's opaque address
pObject[IN] Valid pointer to DataObject
Returns
Status code indicating success or failure

Definition at line 144 of file RootNTupleCnv.h.

144 {
145 return StatusCode::SUCCESS;
146 }

The documentation for this class was generated from the following files: