The Gaudi Framework  v31r0 (aeb156f0)
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 113 of file RootNTupleCnv.cpp.

113  {
114  StatusCode status = S_FAIL;
115  RootDataConnection* con = nullptr;
116  IRegistry* pRegistry = pAddr->registry();
117  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
118  string path = fileName( pRegistry );
119  string cntName = containerName( pRegistry );
120  string* par = const_cast<string*>( pAddr->par() );
121  status = m_dbMgr->connectDatabase( path, IDataConnection::READ, &con );
122  if ( status.isSuccess() ) {
123  string par_val, par_guid;
124  TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription" );
125  if ( b ) {
128  b->SetAddress( &ptr );
129  for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
130  int nb = b->GetEntry( i );
131  if ( nb > 1 ) {
132  if ( ptr->container == cntName ) {
133  par_val = ptr->description;
134  break;
135  }
136  }
137  }
138  }
139  par[2] = _tr( cntName );
140  TTree* tree = con->getSection( par[2] );
141  if ( nullptr == tree ) { return makeError( "Failed to access N-Tuple tree:" + cntName ); }
142  if ( !par_val.empty() ) {
143  auto ntupleSvc = dataProvider().as<INTupleSvc>();
144  if ( ntupleSvc ) {
145  char c;
146  CLID clid;
147  int siz, typ;
148  string title;
149  NTuple::Tuple* nt = nullptr;
150  istringstream is( par_val );
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++ ) {
154  is >> c;
155  getline( is, title, ';' ) >> typ >> c;
156  switch ( typ ) {
157  case DataTypeInfo::UCHAR:
158  status = createItem( tree, nt, is, title, true, (unsigned char)0 );
159  break;
161  status = createItem( tree, nt, is, title, true, (unsigned short)0 );
162  break;
163  case DataTypeInfo::UINT:
164  status = createItem( tree, nt, is, title, true, 0u );
165  break;
166  case DataTypeInfo::ULONG:
167  status = createItem( tree, nt, is, title, true, 0ul );
168  break;
169  case DataTypeInfo::CHAR:
170  status = createItem( tree, nt, is, title, true, char( 0 ) );
171  break;
172  case DataTypeInfo::SHORT:
173  status = createItem( tree, nt, is, title, true, short( 0 ) );
174  break;
175  case DataTypeInfo::INT:
176  status = createItem( tree, nt, is, title, true, 0 );
177  break;
178  case DataTypeInfo::LONG:
179  status = createItem( tree, nt, is, title, true, 0l );
180  break;
181  case DataTypeInfo::BOOL:
182  status = createItem( tree, nt, is, title, true, false );
183  break;
184  case DataTypeInfo::FLOAT:
185  status = createItem( tree, nt, is, title, true, 0.f );
186  break;
188  status = createItem( tree, nt, is, title, true, 0. );
189  break;
190  /*
191  case DataTypeInfo::NTCHAR:
192  case DataTypeInfo::LONG_NTCHAR:
193  status =
194  createItem(tree, nt, is, title, true, (char*)0);
195  break;
196  case DataTypeInfo::STRING:
197  case DataTypeInfo::LONG_STRING:
198  status =
199  createItem(tree, nt, is, title, true, string(""));
200  break;
201  */
203  status = createItem( tree, nt, is, title, false, static_cast<IOpaqueAddress*>( nullptr ) );
204  break;
206  status = createItem( tree, nt, is, title, true, static_cast<void*>( nullptr ) );
207  break;
209  default:
210  status = S_FAIL;
211  break;
212  }
213  if ( !status.isSuccess() ) {
214  log() << MSG::FATAL << "Error connecting (Unknown) column:" << j << endmsg << par_val << endmsg;
215  return makeError( "createObj[NTuple]> Cannot determine column!" );
216  }
217  }
218  if ( status.isSuccess() ) {
219  unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
220  log() << MSG::DEBUG << "Created N-tuple with description:" << par_val << endl;
221  ipar[0] = reinterpret_cast<uintptr_t>( con );
222  ipar[1] = ~0x0UL;
223  rpA->section = tree;
224  refpObject = nt;
225  } else {
226  refpObject = nullptr;
227  if ( nt ) nt->release();
228  }
229  }
230  }
231  }
232  return status;
233 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
T empty(T...args)
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
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.
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.
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:517
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:46
TBranch * getBranch(boost::string_ref section, boost::string_ref branch_name)
Access data branch by name: Get existing branch in read only mode.
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 354 of file RootNTupleCnv.cpp.

354  {
355  IRegistry* pRegistry = pObj->registry();
356  if ( pRegistry ) {
357  pAddr = pRegistry->address();
358  if ( pAddr ) return S_OK;
359 
360  RootDataConnection* con = nullptr;
361  string path = fileName( pRegistry );
362  string cntName = containerName( pRegistry );
363  string secName = cntName.c_str();
364  const INTuple* nt = dynamic_cast<const INTuple*>( pObj );
366  if ( !status.isSuccess() ) { return makeError( "Failed to access Tuple file:" + path ); }
367  TTree* tree = con->getSection( _tr( secName ), true );
368  if ( nullptr != nt ) {
369  const INTuple::ItemContainer& items = nt->items();
370  ostringstream os;
371  size_t item_no;
372  string desc;
373  os << nt->title() << ';' << pObj->clID() << ';' << items.size() << ';';
374  map<string, TBranch*> branches;
375  TBranch* b = nullptr;
376  for ( item_no = 0; item_no < items.size(); ++item_no ) {
377  INTupleItem* it = items[item_no];
378  if ( it->hasIndex() ) {
379  INTupleItem* itm = it->indexItem();
380  const string& n = itm->name();
381  switch ( itm->type() ) {
382  case DataTypeInfo::UCHAR:
383  desc = n + "/b";
384  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
385  break;
387  desc = n + "/s";
388  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
389  break;
390  case DataTypeInfo::UINT:
391  desc = n + "/i";
392  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
393  break;
394  case DataTypeInfo::ULONG:
395  desc = n + "/l";
396  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
397  break;
398  case DataTypeInfo::CHAR:
399  desc = n + "/B";
400  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
401  break;
402  case DataTypeInfo::SHORT:
403  desc = n + "/S";
404  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
405  break;
406  case DataTypeInfo::INT:
407  desc = n + "/I";
408  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
409  break;
410  case DataTypeInfo::LONG:
411  desc = n + "/L";
412  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
413  break;
414  default:
415  return makeError( "Column " + it->index() + " is not a valid index column!" );
416  }
417  branches[n] = b;
418  }
419  }
420  for ( item_no = 0; item_no < items.size(); ++item_no ) {
421  INTupleItem* it = items[item_no];
422  const string& n = it->name();
423  os << '{' << n << ';' << it->type() << ';' << it->length() << ';' << it->ndim() << ';' << it->hasIndex() << ';';
424  if ( it->hasIndex() ) {
425  os << it->index() << ';';
426  INTupleItem* itm = it->indexItem();
427  switch ( itm->type() ) {
428  case DataTypeInfo::UCHAR:
429  putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( itm ) );
430  break;
432  putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( itm ) );
433  break;
434  case DataTypeInfo::UINT:
435  putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( itm ) );
436  break;
437  case DataTypeInfo::ULONG:
438  putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( itm ) );
439  break;
440  case DataTypeInfo::CHAR:
441  putRange( os, dynamic_cast<NTuple::_Data<char>*>( itm ) );
442  break;
443  case DataTypeInfo::SHORT:
444  putRange( os, dynamic_cast<NTuple::_Data<short>*>( itm ) );
445  break;
446  case DataTypeInfo::INT:
447  putRange( os, dynamic_cast<NTuple::_Data<int>*>( itm ) );
448  break;
449  case DataTypeInfo::LONG:
450  putRange( os, dynamic_cast<NTuple::_Data<long>*>( itm ) );
451  break;
452  default:
453  return makeError( "NTuple:" + pRegistry->name() + " Column " + it->index() +
454  " is not a valid index column!" );
455  }
456  }
457  for ( long k = 0; k < it->ndim(); k++ ) { os << it->dim( k ) << ';'; }
458  desc = n;
459  TClass* cl = nullptr;
460  switch ( it->type() ) {
462  desc = "/C";
463  os << 0 << ';' << 0 << ';';
464  break;
466  desc = "/C";
467  os << 0 << ';' << 0 << ';';
468  break;
470  if ( it->length() == 1 ) {
471  desc = System::typeinfoName( typeid( RootRef ) );
472  os << 0 << ';' << 0 << ';';
473  cl = TClass::GetClass( desc.c_str(), kTRUE );
474  }
475  break;
477  if ( it->length() == 1 ) {
478  os << 0 << ';' << 0 << ';';
479  cl = TClass::GetClass( it->typeID(), kTRUE );
480  }
481  break;
482  case DataTypeInfo::UCHAR:
483  desc = "/b";
484  putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( it ) );
485  break;
487  desc = "/s";
488  putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( it ) );
489  break;
490  case DataTypeInfo::UINT:
491  desc = "/i";
492  putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( it ) );
493  break;
494  case DataTypeInfo::ULONG:
495  desc = "/l";
496  putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( it ) );
497  break;
498  case DataTypeInfo::CHAR:
499  desc = "/B";
500  putRange( os, dynamic_cast<NTuple::_Data<char>*>( it ) );
501  break;
502  case DataTypeInfo::SHORT:
503  desc = "/S";
504  putRange( os, dynamic_cast<NTuple::_Data<short>*>( it ) );
505  break;
506  case DataTypeInfo::INT:
507  desc = "/I";
508  putRange( os, dynamic_cast<NTuple::_Data<int>*>( it ) );
509  break;
510  case DataTypeInfo::LONG:
511  desc = "/L";
512  putRange( os, dynamic_cast<NTuple::_Data<long>*>( it ) );
513  break;
514  case DataTypeInfo::BOOL:
515  desc = "/b";
516  putRange( os, dynamic_cast<NTuple::_Data<bool>*>( it ) );
517  break;
518  case DataTypeInfo::FLOAT:
519  desc = "/F";
520  putRange( os, dynamic_cast<NTuple::_Data<float>*>( it ) );
521  break;
523  desc = "/D";
524  putRange( os, dynamic_cast<NTuple::_Data<double>*>( it ) );
525  break;
527  default:
528  return makeError( "Create item[FAIL]: " + it->name() );
529  }
530  os << '}';
531  if ( branches.find( n ) == branches.end() ) {
532  string tmp;
533  char text[32];
534  switch ( it->ndim() ) {
535  case 0:
536  desc = n + desc;
537  break;
538  case 2:
539  sprintf( text, "[%ld]", it->dim( 0 ) );
540  tmp = text;
541  /* FALLTHROUGH */
542  case 1:
543  if ( it->hasIndex() ) {
544  INTupleItem* itm = it->indexItem();
545  desc = n + tmp + "[" + itm->name() + "]" + desc;
546  } else {
547  sprintf( text, "[%ld]", it->dim( 0 ) );
548  desc = n + tmp + text + desc;
549  }
550  }
551  log() << MSG::DEBUG << "Create branch:" << n << " Desc:" << desc << " of type:" << it->type() << endmsg;
552  switch ( it->type() ) {
554  branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
555  break;
557  branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
558  break;
559  default:
560  branches[n] = tree->Branch( n.c_str(), const_cast<void*>( it->buffer() ), desc.c_str() );
561  break;
562  }
563  }
564  }
565 
566  log() << MSG::DEBUG << "Save description:" << path << " -> " << cntName << endmsg << os.str() << endmsg;
567  status = saveDescription( path, cntName, os.str(), "", pObj->clID() );
568  if ( status.isSuccess() ) {
569  status = m_dbMgr->commitOutput( path, true );
570  if ( status.isSuccess() ) {
571  string spar[] = {path, cntName};
572  unsigned long ipar[] = {(unsigned long)con, ~0x0u};
573  status = m_dbMgr->createAddress( repSvcType(), pObj->clID(), spar, ipar, pAddr );
574  if ( status.isSuccess() ) {
575  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
576  ( (unsigned long*)rpA->ipar() )[0] = (unsigned long)con;
577  rpA->section = tree;
578  } else {
579  pAddr->release();
580  pAddr = nullptr;
581  }
582  }
583  }
584  return status;
585  }
586  }
587  return S_FAIL;
588 }
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:309
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.
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
TTree * getSection(boost::string_ref sect, bool create=false)
Access TTree section from section name. The section is created if required.
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 591 of file RootNTupleCnv.cpp.

591  {
592  typedef INTuple::ItemContainer Cont;
593  INTuple* tupl = dynamic_cast<INTuple*>( pObj );
594  IRegistry* pReg = pObj->registry();
595  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
596  if ( tupl && pReg && rpA ) {
597  string cntName = containerName( pReg );
598  unsigned long* ipar = const_cast<unsigned long*>( pAddr->ipar() );
599  RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
600  if ( con ) {
601  TTree* tree = rpA->section;
602  if ( tree ) {
603  Cont& it = tupl->items();
604  size_t k, n = it.size();
605  vector<RootRef*> paddr( n );
606  vector<RootRef> addr( n );
607  for ( k = 0; k < n; ++k ) {
608  IOpaqueAddress* pA = nullptr;
609  Cont::value_type j = it[k];
610  switch ( j->type() ) {
612  pA = ( *(IOpaqueAddress**)j->buffer() );
613  paddr[k] = &addr[k];
614  addr[k].reset();
615  if ( pA ) {
616  con->makeRef( *pA->registry(), addr[k] );
617  addr[k].entry = pA->ipar()[1];
618  }
619  tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
620  break;
621  default:
622  break;
623  }
624  }
625  int nb = tree->Fill();
626  if ( nb > 1 ) ++ipar[1];
627  for ( k = 0; k < n; ++k ) it[k]->reset();
628  return nb > 1 ? StatusCode::SUCCESS : StatusCode::FAILURE;
629  }
630  return makeError( "fillRepRefs> Failed to access data tree:" + cntName );
631  }
632  return makeError( "fillRepRefs> Failed to access data source!" );
633  }
634  return makeError( "fillRepRefs> Invalid Tuple reference." );
635 }
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 255 of file RootNTupleCnv.cpp.

255  {
256  typedef INTuple::ItemContainer Cont;
257  const string* par = rpA->par();
258  unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
259  ++ipar[1];
260  if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
261  GenericAddress* pA = nullptr;
262  Cont& it = tupl->items();
263  size_t k, n = it.size();
264  vector<RootRef*> paddr( n );
265  vector<RootRef> addr( n );
266  for ( k = 0; k < n; ++k ) {
267  Cont::value_type j = it[k];
268  switch ( j->type() ) {
270  paddr[k] = &addr[k];
271  tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
272  break;
273  default:
274  break;
275  }
276  }
277 
278  ULong64_t last = tree->GetEntries();
279  ISelectStatement* sel = tupl->selector();
280  if ( sel ) {
281  string criteria = ( sel && ( sel->type() & ISelectStatement::STRING ) ) ? sel->criteria() : string( "" );
282  if ( !( criteria.length() == 0 || criteria == "*" ) ) {
283  if ( rpA->select == nullptr ) {
284  log() << MSG::DEBUG << "Selection criteria: " << criteria << " " << ipar[1] << endmsg;
285  rpA->select = new TTreeFormula( tree->GetName(), criteria.c_str(), tree );
286  }
287  rpA->select->SetTree( tree );
288  for ( ; ipar[1] < last; ++ipar[1] ) { // loop on all selected entries
289  tree->LoadTree( ipar[1] );
290  rpA->select->GetNdata();
291  if ( fabs( rpA->select->EvalInstance( 0 ) ) > std::numeric_limits<float>::epsilon() ) { break; }
292  log() << MSG::DEBUG << par[0] << "/" << par[1] << " SKIP Entry: " << ipar[1] << endmsg;
293  }
294  }
295  }
296  if ( ipar[1] < last ) {
297  unsigned long entry = ipar[1];
298  if ( tree->GetEntry( entry ) > 1 ) {
299  RootRef* r = nullptr;
300  string* spar = nullptr;
301  for ( k = 0; k < n; ++k ) {
302  Cont::value_type j = it[k];
303  switch ( j->type() ) {
305  r = paddr[k];
306  pA = ( *(GenericAddress**)j->buffer() );
307  if ( pA ) { // Fill only if item is connected!
308  spar = (string*)pA->par();
309  ipar = (unsigned long*)pA->ipar();
310  log() << MSG::DEBUG;
312  con->getMergeSection( tree->GetName(), entry );
313  if ( ls.first ) {
314  if ( ls.first->dbase >= 0 ) {
315  // Now patch the references and links 'en block' to be efficient
316  // First the leafs from the TES
317 
318  r->dbase += ls.first->dbase;
319  r->container += ls.first->container;
320  r->link += ls.first->link;
321 
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;
325  }
326  }
327  }
328  spar[0] = con->getDb( r->dbase );
329  spar[1] = con->getCont( r->container );
330  spar[2] = con->getLink( r->link );
331  ipar[0] = 0;
332  ipar[1] = r->entry;
333  pA->setClID( r->clid );
334  pA->setSvcType( r->svc );
335  break;
336  }
337  break;
338  default:
339  break;
340  }
341  }
342  return StatusCode::SUCCESS;
343  }
344  log() << MSG::ERROR << "Failed to read data from NTuple tree." << endmsg;
345  return StatusCode::FAILURE;
346  }
347  log() << MSG::INFO << "End of input Ntuple." << endmsg;
348  return StatusCode::FAILURE;
349  }
350  return StatusCode::FAILURE;
351 }
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
std::pair< const RootRef *, const ContainerSection * > getMergeSection(boost::string_ref container, int entry) const
Access link section for single container and entry.
virtual long type() const =0
Access the type of the object.
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 236 of file RootNTupleCnv.cpp.

236  {
237  INTuple* tupl = dynamic_cast<INTuple*>( pObj );
238  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
239  if ( !tupl || !rpA ) return makeError( "updateObj> Invalid Tuple reference." );
240  RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
241  if ( !con ) return makeError( "updateObj> Failed to access data source!" );
242  TTree* tree = rpA->section;
243  if ( !tree ) return makeError( "Failed to access data tree:" + pAddr->par()[1] );
244  con->resetAge();
245  if ( con->tool()->refs() ) return i__updateObjRoot( rpA, tupl, tree, con );
246 #ifdef __POOL_COMPATIBILITY
247  // POOL compatibility mode:
248  return i__updateObjPool( rpA, tupl, tree, con );
249 #else
250  return makeError( "Failed to access reference branch for data tree:" + rpA->par()[1] );
251 #endif
252 }
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: