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

Protected Member Functions

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

Additional Inherited Members

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

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 35 of file RootNTupleCnv.h.

Constructor & Destructor Documentation

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 54 of file RootNTupleCnv.h.

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

Member Function Documentation

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 114 of file RootNTupleCnv.cpp.

114  {
115  StatusCode status = S_FAIL;
116  RootDataConnection* con = nullptr;
117  IRegistry* pRegistry = pAddr->registry();
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() );
122  status = m_dbMgr->connectDatabase( path, IDataConnection::READ, &con );
123  if ( status.isSuccess() ) {
124  string par_val, par_guid;
125  TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription" );
126  if ( b ) {
129  b->SetAddress( &ptr );
130  for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
131  int nb = b->GetEntry( i );
132  if ( nb > 1 ) {
133  if ( ptr->container == cntName ) {
134  par_val = ptr->description;
135  break;
136  }
137  }
138  }
139  }
140  par[2] = _tr( cntName );
141  TTree* tree = con->getSection( par[2] );
142  if ( nullptr == tree ) { return makeError( "Failed to access N-Tuple tree:" + cntName ); }
143  if ( !par_val.empty() ) {
144  auto ntupleSvc = dataProvider().as<INTupleSvc>();
145  if ( ntupleSvc ) {
146  char c;
147  CLID clid;
148  int siz, typ;
149  string title;
150  NTuple::Tuple* nt = nullptr;
151  istringstream is( par_val );
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++ ) {
155  is >> c;
156  getline( is, title, ';' ) >> typ >> c;
157  switch ( typ ) {
158  case DataTypeInfo::UCHAR:
159  status = createItem( tree, nt, is, title, true, (unsigned char)0 );
160  break;
162  status = createItem( tree, nt, is, title, true, (unsigned short)0 );
163  break;
164  case DataTypeInfo::UINT:
165  status = createItem( tree, nt, is, title, true, 0u );
166  break;
167  case DataTypeInfo::ULONG:
168  status = createItem( tree, nt, is, title, true, 0ul );
169  break;
170  case DataTypeInfo::CHAR:
171  status = createItem( tree, nt, is, title, true, char( 0 ) );
172  break;
173  case DataTypeInfo::SHORT:
174  status = createItem( tree, nt, is, title, true, short( 0 ) );
175  break;
176  case DataTypeInfo::INT:
177  status = createItem( tree, nt, is, title, true, 0 );
178  break;
179  case DataTypeInfo::LONG:
180  status = createItem( tree, nt, is, title, true, 0l );
181  break;
182  case DataTypeInfo::BOOL:
183  status = createItem( tree, nt, is, title, true, false );
184  break;
185  case DataTypeInfo::FLOAT:
186  status = createItem( tree, nt, is, title, true, 0.f );
187  break;
189  status = createItem( tree, nt, is, title, true, 0. );
190  break;
191  /*
192  case DataTypeInfo::NTCHAR:
193  case DataTypeInfo::LONG_NTCHAR:
194  status =
195  createItem(tree, nt, is, title, true, (char*)0);
196  break;
197  case DataTypeInfo::STRING:
198  case DataTypeInfo::LONG_STRING:
199  status =
200  createItem(tree, nt, is, title, true, string(""));
201  break;
202  */
204  status = createItem( tree, nt, is, title, false, static_cast<IOpaqueAddress*>( nullptr ) );
205  break;
207  status = createItem( tree, nt, is, title, true, static_cast<void*>( nullptr ) );
208  break;
210  default:
211  status = S_FAIL;
212  break;
213  }
214  if ( !status.isSuccess() ) {
215  log() << MSG::FATAL << "Error connecting (Unknown) column:" << j << endmsg << par_val << endmsg;
216  return makeError( "createObj[NTuple]> Cannot determine column!" );
217  }
218  }
219  if ( status.isSuccess() ) {
220  unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
221  log() << MSG::DEBUG << "Created N-tuple with description:" << par_val << endl;
222  ipar[0] = reinterpret_cast<uintptr_t>( con );
223  ipar[1] = ~0x0UL;
224  rpA->section = tree;
225  refpObject = nt;
226  } else {
227  refpObject = nullptr;
228  if ( nt ) nt->release();
229  }
230  }
231  }
232  }
233  return status;
234 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
T empty(T...args)
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
Description:
Definition: RootAddress.h:36
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:41
bool isSuccess() const
Definition: StatusCode.h:267
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:35
T getline(T...args)
T endl(T...args)
#define S_FAIL
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
Definition: RootStatCnv.cpp:87
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:194
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:107
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.
Definition: StatusCode.h:50
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:61
const unsigned long * ipar() const override
Retrieve integer parameters.
std::string description
Description string.
Definition: RootRefs.h:79
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:375
dictionary l
Definition: gaudirun.py:521
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:46
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:68
STL class.
std::string container
Identifier of description.
Definition: RootRefs.h:83
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:46
Concrete implementation of the IDataConnection interface to access ROOT files.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 355 of file RootNTupleCnv.cpp.

355  {
356  IRegistry* pRegistry = pObj->registry();
357  if ( pRegistry ) {
358  pAddr = pRegistry->address();
359  if ( pAddr ) return S_OK;
360 
361  RootDataConnection* con = nullptr;
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 ) {
370  const INTuple::ItemContainer& items = nt->items();
371  ostringstream os;
372  size_t item_no;
373  string desc;
374  os << nt->title() << ';' << pObj->clID() << ';' << items.size() << ';';
375  map<string, TBranch*> branches;
376  TBranch* b = nullptr;
377  for ( item_no = 0; item_no < items.size(); ++item_no ) {
378  INTupleItem* it = items[item_no];
379  if ( it->hasIndex() ) {
380  INTupleItem* itm = it->indexItem();
381  const string& n = itm->name();
382  switch ( itm->type() ) {
383  case DataTypeInfo::UCHAR:
384  desc = n + "/b";
385  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
386  break;
388  desc = n + "/s";
389  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
390  break;
391  case DataTypeInfo::UINT:
392  desc = n + "/i";
393  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
394  break;
395  case DataTypeInfo::ULONG:
396  desc = n + "/l";
397  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
398  break;
399  case DataTypeInfo::CHAR:
400  desc = n + "/B";
401  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
402  break;
403  case DataTypeInfo::SHORT:
404  desc = n + "/S";
405  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
406  break;
407  case DataTypeInfo::INT:
408  desc = n + "/I";
409  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
410  break;
411  case DataTypeInfo::LONG:
412  desc = n + "/L";
413  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
414  break;
415  default:
416  return makeError( "Column " + it->index() + " is not a valid index column!" );
417  }
418  branches[n] = b;
419  }
420  }
421  for ( item_no = 0; item_no < items.size(); ++item_no ) {
422  INTupleItem* it = items[item_no];
423  const string& n = it->name();
424  os << '{' << n << ';' << it->type() << ';' << it->length() << ';' << it->ndim() << ';' << it->hasIndex() << ';';
425  if ( it->hasIndex() ) {
426  os << it->index() << ';';
427  INTupleItem* itm = it->indexItem();
428  switch ( itm->type() ) {
429  case DataTypeInfo::UCHAR:
430  putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( itm ) );
431  break;
433  putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( itm ) );
434  break;
435  case DataTypeInfo::UINT:
436  putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( itm ) );
437  break;
438  case DataTypeInfo::ULONG:
439  putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( itm ) );
440  break;
441  case DataTypeInfo::CHAR:
442  putRange( os, dynamic_cast<NTuple::_Data<char>*>( itm ) );
443  break;
444  case DataTypeInfo::SHORT:
445  putRange( os, dynamic_cast<NTuple::_Data<short>*>( itm ) );
446  break;
447  case DataTypeInfo::INT:
448  putRange( os, dynamic_cast<NTuple::_Data<int>*>( itm ) );
449  break;
450  case DataTypeInfo::LONG:
451  putRange( os, dynamic_cast<NTuple::_Data<long>*>( itm ) );
452  break;
453  default:
454  return makeError( "NTuple:" + pRegistry->name() + " Column " + it->index() +
455  " is not a valid index column!" );
456  }
457  }
458  for ( long k = 0; k < it->ndim(); k++ ) { os << it->dim( k ) << ';'; }
459  desc = n;
460  TClass* cl = nullptr;
461  switch ( it->type() ) {
463  desc = "/C";
464  os << 0 << ';' << 0 << ';';
465  break;
467  desc = "/C";
468  os << 0 << ';' << 0 << ';';
469  break;
471  if ( it->length() == 1 ) {
472  desc = System::typeinfoName( typeid( RootRef ) );
473  os << 0 << ';' << 0 << ';';
474  cl = TClass::GetClass( desc.c_str(), kTRUE );
475  }
476  break;
478  if ( it->length() == 1 ) {
479  os << 0 << ';' << 0 << ';';
480  cl = TClass::GetClass( it->typeID(), kTRUE );
481  }
482  break;
483  case DataTypeInfo::UCHAR:
484  desc = "/b";
485  putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( it ) );
486  break;
488  desc = "/s";
489  putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( it ) );
490  break;
491  case DataTypeInfo::UINT:
492  desc = "/i";
493  putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( it ) );
494  break;
495  case DataTypeInfo::ULONG:
496  desc = "/l";
497  putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( it ) );
498  break;
499  case DataTypeInfo::CHAR:
500  desc = "/B";
501  putRange( os, dynamic_cast<NTuple::_Data<char>*>( it ) );
502  break;
503  case DataTypeInfo::SHORT:
504  desc = "/S";
505  putRange( os, dynamic_cast<NTuple::_Data<short>*>( it ) );
506  break;
507  case DataTypeInfo::INT:
508  desc = "/I";
509  putRange( os, dynamic_cast<NTuple::_Data<int>*>( it ) );
510  break;
511  case DataTypeInfo::LONG:
512  desc = "/L";
513  putRange( os, dynamic_cast<NTuple::_Data<long>*>( it ) );
514  break;
515  case DataTypeInfo::BOOL:
516  desc = "/b";
517  putRange( os, dynamic_cast<NTuple::_Data<bool>*>( it ) );
518  break;
519  case DataTypeInfo::FLOAT:
520  desc = "/F";
521  putRange( os, dynamic_cast<NTuple::_Data<float>*>( it ) );
522  break;
524  desc = "/D";
525  putRange( os, dynamic_cast<NTuple::_Data<double>*>( it ) );
526  break;
528  default:
529  return makeError( "Create item[FAIL]: " + it->name() );
530  }
531  os << '}';
532  if ( branches.find( n ) == branches.end() ) {
533  string tmp;
534  char text[32];
535  switch ( it->ndim() ) {
536  case 0:
537  desc = n + desc;
538  break;
539  case 2:
540  sprintf( text, "[%ld]", it->dim( 0 ) );
541  tmp = text;
542  [[fallthrough]];
543  case 1:
544  if ( it->hasIndex() ) {
545  INTupleItem* itm = it->indexItem();
546  desc = n + tmp + "[" + itm->name() + "]" + desc;
547  } else {
548  sprintf( text, "[%ld]", it->dim( 0 ) );
549  desc = n + tmp + text + desc;
550  }
551  }
552  log() << MSG::DEBUG << "Create branch:" << n << " Desc:" << desc << " of type:" << it->type() << endmsg;
553  switch ( it->type() ) {
555  branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
556  break;
558  branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
559  break;
560  default:
561  branches[n] = tree->Branch( n.c_str(), const_cast<void*>( it->buffer() ), desc.c_str() );
562  break;
563  }
564  }
565  }
566 
567  log() << MSG::DEBUG << "Save description:" << path << " -> " << cntName << endmsg << os.str() << endmsg;
568  status = saveDescription( path, cntName, os.str(), "", pObj->clID() );
569  if ( status.isSuccess() ) {
570  status = m_dbMgr->commitOutput( path, true );
571  if ( status.isSuccess() ) {
572  string spar[] = {path, cntName};
573  unsigned long ipar[] = {(unsigned long)con, ~0x0u};
574  status = m_dbMgr->createAddress( repSvcType(), pObj->clID(), spar, ipar, pAddr );
575  if ( status.isSuccess() ) {
576  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
577  ( (unsigned long*)rpA->ipar() )[0] = (unsigned long)con;
578  rpA->section = tree;
579  } else {
580  pAddr->release();
581  pAddr = nullptr;
582  }
583  }
584  }
585  return status;
586  }
587  }
588  return S_FAIL;
589 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
virtual const std::string & name() const =0
Access _Item name.
Description:
Definition: RootAddress.h:36
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:41
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:347
bool isSuccess() const
Definition: StatusCode.h:267
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:35
virtual const name_type & name() const =0
Name of the directory (or key)
#define S_FAIL
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
Definition: RootStatCnv.cpp:87
T end(T...args)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:194
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Definition: RootConverter.h:49
STL class.
StatusCode commitOutput(const std::string &outputFile, bool do_commit) override
Commit pending output.
Definition: RootCnvSvc.cpp:292
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
NTuple interface class definition.
Definition: INTuple.h:81
Persistent reference object.
Definition: RootRefs.h:30
virtual long ndim() const =0
Dimension.
NTuple interface class definition.
Definition: INTuple.h:27
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:56
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
virtual long length() const =0
Access the buffer length.
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.
Definition: StatusCode.h:50
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:61
const unsigned long * ipar() const override
Retrieve integer parameters.
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.
Definition: RootStatCnv.cpp:99
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
Abstract class describing basic data in an Ntuple.
Definition: NTuple.h:38
virtual long type() const =0
Type information of the item.
virtual const void * buffer() const =0
Access data buffer (CONST)
T find(T...args)
T size(T...args)
STL class.
virtual const std::string & index() const =0
Access the index _Item.
T c_str(T...args)
virtual long dim(long i) const =0
Access individual dimensions.
#define S_OK
virtual ItemContainer & items()=0
Access item container.
virtual bool hasIndex() const =0
Is the tuple have an index item?
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:46
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual const std::type_info & typeID() const =0
Compiler type ID.
Concrete implementation of the IDataConnection interface to access ROOT files.
T sprintf(T...args)
virtual const std::string & title() const =0
Object title.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 95 of file RootNTupleCnv.h.

95  {
96  return StatusCode::SUCCESS;
97  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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 592 of file RootNTupleCnv.cpp.

592  {
593  typedef INTuple::ItemContainer Cont;
594  INTuple* tupl = dynamic_cast<INTuple*>( pObj );
595  IRegistry* pReg = pObj->registry();
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() );
600  RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
601  if ( con ) {
602  TTree* tree = rpA->section;
603  if ( tree ) {
604  Cont& it = tupl->items();
605  size_t k, n = it.size();
606  vector<RootRef*> paddr( n );
607  vector<RootRef> addr( n );
608  for ( k = 0; k < n; ++k ) {
609  IOpaqueAddress* pA = nullptr;
610  Cont::value_type j = it[k];
611  switch ( j->type() ) {
613  pA = ( *(IOpaqueAddress**)j->buffer() );
614  paddr[k] = &addr[k];
615  addr[k].reset();
616  if ( pA ) {
617  con->makeRef( *pA->registry(), addr[k] );
618  addr[k].entry = pA->ipar()[1];
619  }
620  tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
621  break;
622  default:
623  break;
624  }
625  }
626  int nb = tree->Fill();
627  if ( nb > 1 ) ++ipar[1];
628  for ( k = 0; k < n; ++k ) it[k]->reset();
629  return nb > 1 ? StatusCode::SUCCESS : StatusCode::FAILURE;
630  }
631  return makeError( "fillRepRefs> Failed to access data tree:" + cntName );
632  }
633  return makeError( "fillRepRefs> Failed to access data source!" );
634  }
635  return makeError( "fillRepRefs> Invalid Tuple reference." );
636 }
Description:
Definition: RootAddress.h:36
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:41
virtual IRegistry * registry() const =0
Update branch name.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
Definition: RootStatCnv.cpp:87
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
NTuple interface class definition.
Definition: INTuple.h:81
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
const unsigned long * ipar() const override
Retrieve integer parameters.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
STL class.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
void makeRef(const IRegistry &pA, RootRef &ref)
Create reference object from registry entry.
virtual ItemContainer & items()=0
Access item container.
Opaque address interface definition.
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:46
Concrete implementation of the IDataConnection interface to access ROOT files.
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 256 of file RootNTupleCnv.cpp.

256  {
257  typedef INTuple::ItemContainer Cont;
258  const string* par = rpA->par();
259  unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
260  ++ipar[1];
261  if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
262  GenericAddress* pA = nullptr;
263  Cont& it = tupl->items();
264  size_t k, n = it.size();
265  vector<RootRef*> paddr( n );
266  vector<RootRef> addr( n );
267  for ( k = 0; k < n; ++k ) {
268  Cont::value_type j = it[k];
269  switch ( j->type() ) {
271  paddr[k] = &addr[k];
272  tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
273  break;
274  default:
275  break;
276  }
277  }
278 
279  ULong64_t last = tree->GetEntries();
280  ISelectStatement* sel = tupl->selector();
281  if ( sel ) {
282  string criteria = ( sel && ( sel->type() & ISelectStatement::STRING ) ) ? sel->criteria() : string( "" );
283  if ( !( criteria.length() == 0 || criteria == "*" ) ) {
284  if ( rpA->select == nullptr ) {
285  log() << MSG::DEBUG << "Selection criteria: " << criteria << " " << ipar[1] << endmsg;
286  rpA->select = new TTreeFormula( tree->GetName(), criteria.c_str(), tree );
287  }
288  rpA->select->SetTree( tree );
289  for ( ; ipar[1] < last; ++ipar[1] ) { // loop on all selected entries
290  tree->LoadTree( ipar[1] );
291  rpA->select->GetNdata();
292  if ( fabs( rpA->select->EvalInstance( 0 ) ) > std::numeric_limits<float>::epsilon() ) { break; }
293  log() << MSG::DEBUG << par[0] << "/" << par[1] << " SKIP Entry: " << ipar[1] << endmsg;
294  }
295  }
296  }
297  if ( ipar[1] < last ) {
298  unsigned long entry = ipar[1];
299  if ( tree->GetEntry( entry ) > 1 ) {
300  RootRef* r = nullptr;
301  string* spar = nullptr;
302  for ( k = 0; k < n; ++k ) {
303  Cont::value_type j = it[k];
304  switch ( j->type() ) {
306  r = paddr[k];
307  pA = ( *(GenericAddress**)j->buffer() );
308  if ( pA ) { // Fill only if item is connected!
309  spar = (string*)pA->par();
310  ipar = (unsigned long*)pA->ipar();
311  log() << MSG::DEBUG;
313  con->getMergeSection( tree->GetName(), entry );
314  if ( ls.first ) {
315  if ( ls.first->dbase >= 0 ) {
316  // Now patch the references and links 'en block' to be efficient
317  // First the leafs from the TES
318 
319  r->dbase += ls.first->dbase;
320  r->container += ls.first->container;
321  r->link += ls.first->link;
322 
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;
326  }
327  }
328  }
329  spar[0] = con->getDb( r->dbase );
330  spar[1] = con->getCont( r->container );
331  spar[2] = con->getLink( r->link );
332  ipar[0] = 0;
333  ipar[1] = r->entry;
334  pA->setClID( r->clid );
335  pA->setSvcType( r->svc );
336  break;
337  }
338  break;
339  default:
340  break;
341  }
342  }
343  return StatusCode::SUCCESS;
344  }
345  log() << MSG::ERROR << "Failed to read data from NTuple tree." << endmsg;
346  return StatusCode::FAILURE;
347  }
348  log() << MSG::INFO << "End of input Ntuple." << endmsg;
349  return StatusCode::FAILURE;
350  }
351  return StatusCode::FAILURE;
352 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
A select statement can either contain.
const std::string & getDb(int which) const
Access database/file name from saved index.
void setSvcType(long typ)
Access : set the storage type of the class id.
sel
Definition: IOTest.py:93
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:111
const std::string & getLink(int which) const
Access link name from saved index.
Generic Transient Address.
virtual ISelectStatement * selector()=0
Access selector.
STL class.
virtual const std::string & criteria() const =0
Access the selection string.
int dbase
Data members to define object location in the persistent world.
Definition: RootRefs.h:32
Persistent reference object.
Definition: RootRefs.h:30
void setClID(const CLID &clid)
Access : Set class ID of the link.
const unsigned long * ipar() const override
Retrieve integer parameters.
const std::string * par() const override
Retrieve string parameters.
const std::string & getCont(int which) const
Access container name from saved index.
T fabs(T...args)
T length(T...args)
STL class.
T c_str(T...args)
constexpr static const auto FAILURE
Definition: StatusCode.h:86
virtual ItemContainer & items()=0
Access item container.
TTreeFormula * select
Pointer to ROOT select statement (filled for N-tuples only)
Definition: RootAddress.h:39
virtual long type() const =0
Access the type of the object.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(std::string_view container, int entry) const
Access link section for single container and entry.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 237 of file RootNTupleCnv.cpp.

237  {
238  INTuple* tupl = dynamic_cast<INTuple*>( pObj );
239  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
240  if ( !tupl || !rpA ) return makeError( "updateObj> Invalid Tuple reference." );
241  RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
242  if ( !con ) return makeError( "updateObj> Failed to access data source!" );
243  TTree* tree = rpA->section;
244  if ( !tree ) return makeError( "Failed to access data tree:" + pAddr->par()[1] );
245  con->resetAge();
246  if ( con->tool()->refs() ) return i__updateObjRoot( rpA, tupl, tree, con );
247 #ifdef __POOL_COMPATIBILITY
248  // POOL compatibility mode:
249  return i__updateObjPool( rpA, tupl, tree, con );
250 #else
251  return makeError( "Failed to access reference branch for data tree:" + rpA->par()[1] );
252 #endif
253 }
Description:
Definition: RootAddress.h:36
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:41
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
Definition: RootStatCnv.cpp:87
NTuple interface class definition.
Definition: INTuple.h:81
const unsigned long * ipar() const override
Retrieve integer parameters.
const std::string * par() const override
Retrieve string parameters.
Tool * tool() const
Access tool.
void resetAge()
Reset age.
StatusCode i__updateObjRoot(RootAddress *rpA, INTuple *tupl, TTree *tree, RootDataConnection *con)
Update the transient object: NTuples end here when reading records.
Concrete implementation of the IDataConnection interface to access ROOT files.
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 116 of file RootNTupleCnv.h.

116  {
117  return StatusCode::SUCCESS;
118  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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 128 of file RootNTupleCnv.h.

128  {
129  return StatusCode::SUCCESS;
130  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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 140 of file RootNTupleCnv.h.

140  {
141  return StatusCode::SUCCESS;
142  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85

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