The Gaudi Framework  v30r3 (a5ef0a68)
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 36 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 56 of file RootNTupleCnv.h.

56  : RootStatCnv( typ, clid, svc, mgr )
57  {
58  }
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 118 of file RootNTupleCnv.cpp.

119 {
120  StatusCode status = S_FAIL;
121  RootDataConnection* con = nullptr;
122  IRegistry* pRegistry = pAddr->registry();
123  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
124  string path = fileName( pRegistry );
125  string cntName = containerName( pRegistry );
126  string* par = const_cast<string*>( pAddr->par() );
127  status = m_dbMgr->connectDatabase( path, IDataConnection::READ, &con );
128  if ( status.isSuccess() ) {
129  string par_val, par_guid;
130  TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription" );
131  if ( b ) {
134  b->SetAddress( &ptr );
135  for ( Long64_t i = 0, nent = b->GetEntries(); i < nent; ++i ) {
136  int nb = b->GetEntry( i );
137  if ( nb > 1 ) {
138  if ( ptr->container == cntName ) {
139  par_val = ptr->description;
140  break;
141  }
142  }
143  }
144  }
145  par[2] = _tr( cntName );
146  TTree* tree = con->getSection( par[2] );
147  if ( nullptr == tree ) {
148  return makeError( "Failed to access N-Tuple tree:" + cntName );
149  }
150  if ( !par_val.empty() ) {
151  auto ntupleSvc = dataProvider().as<INTupleSvc>();
152  if ( ntupleSvc ) {
153  char c;
154  CLID clid;
155  int siz, typ;
156  string title;
157  NTuple::Tuple* nt = nullptr;
158  istringstream is( par_val );
159  getline( is, title, ';' ) >> clid >> c >> siz >> c;
160  status = ntupleSvc->create( clid, title, nt );
161  for ( int j = 0; j < siz && status.isSuccess(); j++ ) {
162  is >> c;
163  getline( is, title, ';' ) >> typ >> c;
164  switch ( typ ) {
165  case DataTypeInfo::UCHAR:
166  status = createItem( tree, nt, is, title, true, (unsigned char)0 );
167  break;
169  status = createItem( tree, nt, is, title, true, (unsigned short)0 );
170  break;
171  case DataTypeInfo::UINT:
172  status = createItem( tree, nt, is, title, true, (unsigned int)0 );
173  break;
174  case DataTypeInfo::ULONG:
175  status = createItem( tree, nt, is, title, true, (unsigned long)0 );
176  break;
177  case DataTypeInfo::CHAR:
178  status = createItem( tree, nt, is, title, true, char( 0 ) );
179  break;
180  case DataTypeInfo::SHORT:
181  status = createItem( tree, nt, is, title, true, short( 0 ) );
182  break;
183  case DataTypeInfo::INT:
184  status = createItem( tree, nt, is, title, true, int( 0 ) );
185  break;
186  case DataTypeInfo::LONG:
187  status = createItem( tree, nt, is, title, true, long( 0 ) );
188  break;
189  case DataTypeInfo::BOOL:
190  status = createItem( tree, nt, is, title, true, false );
191  break;
192  case DataTypeInfo::FLOAT:
193  status = createItem( tree, nt, is, title, true, float( 0.0 ) );
194  break;
196  status = createItem( tree, nt, is, title, true, double( 0.0 ) );
197  break;
198  /*
199  case DataTypeInfo::NTCHAR:
200  case DataTypeInfo::LONG_NTCHAR:
201  status =
202  createItem(tree, nt, is, title, true, (char*)0);
203  break;
204  case DataTypeInfo::STRING:
205  case DataTypeInfo::LONG_STRING:
206  status =
207  createItem(tree, nt, is, title, true, string(""));
208  break;
209  */
211  status = createItem( tree, nt, is, title, false, static_cast<IOpaqueAddress*>( nullptr ) );
212  break;
214  status = createItem( tree, nt, is, title, true, static_cast<void*>( nullptr ) );
215  break;
217  default:
218  status = S_FAIL;
219  break;
220  }
221  if ( !status.isSuccess() ) {
222  log() << MSG::FATAL << "Error connecting (Unknown) column:" << j << endmsg << par_val << endmsg;
223  return makeError( "createObj[NTuple]> Cannot determine column!" );
224  }
225  }
226  if ( status.isSuccess() ) {
227  unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
228  log() << MSG::DEBUG << "Created N-tuple with description:" << par_val << endl;
229  ipar[0] = reinterpret_cast<uintptr_t>( con );
230  ipar[1] = ~0x0UL;
231  rpA->section = tree;
232  refpObject = nt;
233  } else {
234  refpObject = nullptr;
235  if ( nt ) nt->release();
236  }
237  }
238  }
239  }
240  return status;
241 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
T empty(T...args)
Description:
Definition: RootAddress.h:37
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
bool isSuccess() const
Definition: StatusCode.h:287
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
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.
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:210
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:115
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:70
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:81
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:407
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:51
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:73
STL class.
std::string container
Identifier of description.
Definition: RootRefs.h:85
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:52
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:209
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 366 of file RootNTupleCnv.cpp.

367 {
368  IRegistry* pRegistry = pObj->registry();
369  if ( pRegistry ) {
370  pAddr = pRegistry->address();
371  if ( pAddr ) return S_OK;
372 
373  RootDataConnection* con = nullptr;
374  string path = fileName( pRegistry );
375  string cntName = containerName( pRegistry );
376  string secName = cntName.c_str();
377  const INTuple* nt = dynamic_cast<const INTuple*>( pObj );
379  if ( !status.isSuccess() ) {
380  return makeError( "Failed to access Tuple file:" + path );
381  }
382  TTree* tree = con->getSection( _tr( secName ), true );
383  if ( nullptr != nt ) {
384  const INTuple::ItemContainer& items = nt->items();
385  ostringstream os;
386  size_t item_no;
387  string desc;
388  os << nt->title() << ';' << pObj->clID() << ';' << items.size() << ';';
389  map<string, TBranch*> branches;
390  TBranch* b = nullptr;
391  for ( item_no = 0; item_no < items.size(); ++item_no ) {
392  INTupleItem* it = items[item_no];
393  if ( it->hasIndex() ) {
394  INTupleItem* itm = it->indexItem();
395  const string& n = itm->name();
396  switch ( itm->type() ) {
397  case DataTypeInfo::UCHAR:
398  desc = n + "/b";
399  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
400  break;
402  desc = n + "/s";
403  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
404  break;
405  case DataTypeInfo::UINT:
406  desc = n + "/i";
407  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
408  break;
409  case DataTypeInfo::ULONG:
410  desc = n + "/l";
411  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
412  break;
413  case DataTypeInfo::CHAR:
414  desc = n + "/B";
415  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
416  break;
417  case DataTypeInfo::SHORT:
418  desc = n + "/S";
419  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
420  break;
421  case DataTypeInfo::INT:
422  desc = n + "/I";
423  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
424  break;
425  case DataTypeInfo::LONG:
426  desc = n + "/L";
427  b = tree->Branch( n.c_str(), const_cast<void*>( itm->buffer() ), desc.c_str() );
428  break;
429  default:
430  return makeError( "Column " + it->index() + " is not a valid index column!" );
431  }
432  branches[n] = b;
433  }
434  }
435  for ( item_no = 0; item_no < items.size(); ++item_no ) {
436  INTupleItem* it = items[item_no];
437  const string& n = it->name();
438  os << '{' << n << ';' << it->type() << ';' << it->length() << ';' << it->ndim() << ';' << it->hasIndex() << ';';
439  if ( it->hasIndex() ) {
440  os << it->index() << ';';
441  INTupleItem* itm = it->indexItem();
442  switch ( itm->type() ) {
443  case DataTypeInfo::UCHAR:
444  putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( itm ) );
445  break;
447  putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( itm ) );
448  break;
449  case DataTypeInfo::UINT:
450  putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( itm ) );
451  break;
452  case DataTypeInfo::ULONG:
453  putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( itm ) );
454  break;
455  case DataTypeInfo::CHAR:
456  putRange( os, dynamic_cast<NTuple::_Data<char>*>( itm ) );
457  break;
458  case DataTypeInfo::SHORT:
459  putRange( os, dynamic_cast<NTuple::_Data<short>*>( itm ) );
460  break;
461  case DataTypeInfo::INT:
462  putRange( os, dynamic_cast<NTuple::_Data<int>*>( itm ) );
463  break;
464  case DataTypeInfo::LONG:
465  putRange( os, dynamic_cast<NTuple::_Data<long>*>( itm ) );
466  break;
467  default:
468  return makeError( "NTuple:" + pRegistry->name() + " Column " + it->index() +
469  " is not a valid index column!" );
470  }
471  }
472  for ( long k = 0; k < it->ndim(); k++ ) {
473  os << it->dim( k ) << ';';
474  }
475  desc = n;
476  TClass* cl = nullptr;
477  switch ( it->type() ) {
479  desc = "/C";
480  os << 0 << ';' << 0 << ';';
481  break;
483  desc = "/C";
484  os << 0 << ';' << 0 << ';';
485  break;
487  if ( it->length() == 1 ) {
488  desc = System::typeinfoName( typeid( RootRef ) );
489  os << 0 << ';' << 0 << ';';
490  cl = TClass::GetClass( desc.c_str(), kTRUE );
491  }
492  break;
494  if ( it->length() == 1 ) {
495  os << 0 << ';' << 0 << ';';
496  cl = TClass::GetClass( it->typeID(), kTRUE );
497  }
498  break;
499  case DataTypeInfo::UCHAR:
500  desc = "/b";
501  putRange( os, dynamic_cast<NTuple::_Data<unsigned char>*>( it ) );
502  break;
504  desc = "/s";
505  putRange( os, dynamic_cast<NTuple::_Data<unsigned short>*>( it ) );
506  break;
507  case DataTypeInfo::UINT:
508  desc = "/i";
509  putRange( os, dynamic_cast<NTuple::_Data<unsigned int>*>( it ) );
510  break;
511  case DataTypeInfo::ULONG:
512  desc = "/l";
513  putRange( os, dynamic_cast<NTuple::_Data<unsigned long>*>( it ) );
514  break;
515  case DataTypeInfo::CHAR:
516  desc = "/B";
517  putRange( os, dynamic_cast<NTuple::_Data<char>*>( it ) );
518  break;
519  case DataTypeInfo::SHORT:
520  desc = "/S";
521  putRange( os, dynamic_cast<NTuple::_Data<short>*>( it ) );
522  break;
523  case DataTypeInfo::INT:
524  desc = "/I";
525  putRange( os, dynamic_cast<NTuple::_Data<int>*>( it ) );
526  break;
527  case DataTypeInfo::LONG:
528  desc = "/L";
529  putRange( os, dynamic_cast<NTuple::_Data<long>*>( it ) );
530  break;
531  case DataTypeInfo::BOOL:
532  desc = "/b";
533  putRange( os, dynamic_cast<NTuple::_Data<bool>*>( it ) );
534  break;
535  case DataTypeInfo::FLOAT:
536  desc = "/F";
537  putRange( os, dynamic_cast<NTuple::_Data<float>*>( it ) );
538  break;
540  desc = "/D";
541  putRange( os, dynamic_cast<NTuple::_Data<double>*>( it ) );
542  break;
544  default:
545  return makeError( "Create item[FAIL]: " + it->name() );
546  }
547  os << '}';
548  if ( branches.find( n ) == branches.end() ) {
549  string tmp;
550  char text[32];
551  switch ( it->ndim() ) {
552  case 0:
553  desc = n + desc;
554  break;
555  case 2:
556  sprintf( text, "[%ld]", it->dim( 0 ) );
557  tmp = text;
558  /* FALLTHROUGH */
559  case 1:
560  if ( it->hasIndex() ) {
561  INTupleItem* itm = it->indexItem();
562  desc = n + tmp + "[" + itm->name() + "]" + desc;
563  } else {
564  sprintf( text, "[%ld]", it->dim( 0 ) );
565  desc = n + tmp + text + desc;
566  }
567  }
568  log() << MSG::DEBUG << "Create branch:" << n << " Desc:" << desc << " of type:" << it->type() << endmsg;
569  switch ( it->type() ) {
571  branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
572  break;
574  branches[n] = tree->Branch( n.c_str(), cl->GetName(), const_cast<void*>( it->buffer() ) );
575  break;
576  default:
577  branches[n] = tree->Branch( n.c_str(), const_cast<void*>( it->buffer() ), desc.c_str() );
578  break;
579  }
580  }
581  }
582 
583  log() << MSG::DEBUG << "Save description:" << path << " -> " << cntName << endmsg << os.str() << endmsg;
584  status = saveDescription( path, cntName, os.str(), "", pObj->clID() );
585  if ( status.isSuccess() ) {
586  status = m_dbMgr->commitOutput( path, true );
587  if ( status.isSuccess() ) {
588  string spar[] = {path, cntName};
589  unsigned long ipar[] = {(unsigned long)con, ~0x0u};
590  status = m_dbMgr->createAddress( repSvcType(), pObj->clID(), spar, ipar, pAddr );
591  if ( status.isSuccess() ) {
592  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
593  ( (unsigned long*)rpA->ipar() )[0] = (unsigned long)con;
594  rpA->section = tree;
595  } else {
596  pAddr->release();
597  pAddr = nullptr;
598  }
599  }
600  }
601  return status;
602  }
603  }
604  return S_FAIL;
605 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
virtual const std::string & name() const =0
Access _Item name.
Description:
Definition: RootAddress.h:37
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:332
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:370
bool isSuccess() const
Definition: StatusCode.h:287
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
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.
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:210
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Definition: RootConverter.h:53
STL class.
StatusCode commitOutput(const std::string &outputFile, bool do_commit) override
Commit pending output.
Definition: RootCnvSvc.cpp:311
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
NTuple interface class definition.
Definition: INTuple.h:82
Persistent reference object.
Definition: RootRefs.h:31
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:62
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:51
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:70
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.
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:39
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:52
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:209
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 98 of file RootNTupleCnv.h.

99  {
100  return StatusCode::SUCCESS;
101  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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 608 of file RootNTupleCnv.cpp.

609 {
610  typedef INTuple::ItemContainer Cont;
611  INTuple* tupl = dynamic_cast<INTuple*>( pObj );
612  IRegistry* pReg = pObj->registry();
613  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
614  if ( tupl && pReg && rpA ) {
615  string cntName = containerName( pReg );
616  unsigned long* ipar = const_cast<unsigned long*>( pAddr->ipar() );
617  RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
618  if ( con ) {
619  TTree* tree = rpA->section;
620  if ( tree ) {
621  Cont& it = tupl->items();
622  size_t k, n = it.size();
623  vector<RootRef*> paddr( n );
624  vector<RootRef> addr( n );
625  for ( k = 0; k < n; ++k ) {
626  IOpaqueAddress* pA = nullptr;
627  Cont::value_type j = it[k];
628  switch ( j->type() ) {
630  pA = ( *(IOpaqueAddress**)j->buffer() );
631  paddr[k] = &addr[k];
632  addr[k].reset();
633  if ( pA ) {
634  con->makeRef( *pA->registry(), addr[k] );
635  addr[k].entry = pA->ipar()[1];
636  }
637  tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
638  break;
639  default:
640  break;
641  }
642  }
643  int nb = tree->Fill();
644  if ( nb > 1 ) ++ipar[1];
645  for ( k = 0; k < n; ++k ) it[k]->reset();
646  return nb > 1 ? StatusCode::SUCCESS : StatusCode::FAILURE;
647  }
648  return makeError( "fillRepRefs> Failed to access data tree:" + cntName );
649  }
650  return makeError( "fillRepRefs> Failed to access data source!" );
651  }
652  return makeError( "fillRepRefs> Invalid Tuple reference." );
653 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
Description:
Definition: RootAddress.h:37
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
virtual IRegistry * registry() const =0
Update branch name.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
NTuple interface class definition.
Definition: INTuple.h:82
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
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
STL class.
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:52
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 264 of file RootNTupleCnv.cpp.

265 {
266  typedef INTuple::ItemContainer Cont;
267  const string* par = rpA->par();
268  unsigned long* ipar = const_cast<unsigned long*>( rpA->ipar() );
269  ++ipar[1];
270  if ( Long64_t( ipar[1] ) <= tree->GetEntries() ) {
271  GenericAddress* pA = nullptr;
272  Cont& it = tupl->items();
273  size_t k, n = it.size();
274  vector<RootRef*> paddr( n );
275  vector<RootRef> addr( n );
276  for ( k = 0; k < n; ++k ) {
277  Cont::value_type j = it[k];
278  switch ( j->type() ) {
280  paddr[k] = &addr[k];
281  tree->SetBranchAddress( j->name().c_str(), &paddr[k] );
282  break;
283  default:
284  break;
285  }
286  }
287 
288  ULong64_t last = tree->GetEntries();
289  ISelectStatement* sel = tupl->selector();
290  if ( sel ) {
291  string criteria = ( sel && ( sel->type() & ISelectStatement::STRING ) ) ? sel->criteria() : string( "" );
292  if ( !( criteria.length() == 0 || criteria == "*" ) ) {
293  if ( rpA->select == nullptr ) {
294  log() << MSG::DEBUG << "Selection criteria: " << criteria << " " << ipar[1] << endmsg;
295  rpA->select = new TTreeFormula( tree->GetName(), criteria.c_str(), tree );
296  }
297  rpA->select->SetTree( tree );
298  for ( ; ipar[1] < last; ++ipar[1] ) { // loop on all selected entries
299  tree->LoadTree( ipar[1] );
300  rpA->select->GetNdata();
301  if ( fabs( rpA->select->EvalInstance( 0 ) ) > std::numeric_limits<float>::epsilon() ) {
302  break;
303  }
304  log() << MSG::DEBUG << par[0] << "/" << par[1] << " SKIP Entry: " << ipar[1] << endmsg;
305  }
306  }
307  }
308  if ( ipar[1] < last ) {
309  unsigned long entry = ipar[1];
310  if ( tree->GetEntry( entry ) > 1 ) {
311  RootRef* r = nullptr;
312  string* spar = nullptr;
313  for ( k = 0; k < n; ++k ) {
314  Cont::value_type j = it[k];
315  switch ( j->type() ) {
317  r = paddr[k];
318  pA = ( *(GenericAddress**)j->buffer() );
319  if ( pA ) { // Fill only if item is connected!
320  spar = (string*)pA->par();
321  ipar = (unsigned long*)pA->ipar();
322  log() << MSG::DEBUG;
324  con->getMergeSection( tree->GetName(), entry );
325  if ( ls.first ) {
326  if ( ls.first->dbase >= 0 ) {
327  // Now patch the references and links 'en block' to be efficient
328  // First the leafs from the TES
329 
330  r->dbase += ls.first->dbase;
331  r->container += ls.first->container;
332  r->link += ls.first->link;
333 
334  if ( log().isActive() ) {
335  log() << "Refs: LS [" << entry << "] -> " << ls.first->dbase << "," << ls.first->container << ","
336  << ls.first->link << "," << ls.first->entry << " DB:" << con->getDb( r->dbase ) << endmsg;
337  }
338  }
339  }
340  spar[0] = con->getDb( r->dbase );
341  spar[1] = con->getCont( r->container );
342  spar[2] = con->getLink( r->link );
343  ipar[0] = 0;
344  ipar[1] = r->entry;
345  pA->setClID( r->clid );
346  pA->setSvcType( r->svc );
347  break;
348  }
349  break;
350  default:
351  break;
352  }
353  }
354  return StatusCode::SUCCESS;
355  }
356  log() << MSG::ERROR << "Failed to read data from NTuple tree." << endmsg;
357  return StatusCode::FAILURE;
358  }
359  log() << MSG::INFO << "End of input Ntuple." << endmsg;
360  return StatusCode::FAILURE;
361  }
362  return StatusCode::FAILURE;
363 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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:95
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:116
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:33
Persistent reference object.
Definition: RootRefs.h:31
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)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T length(T...args)
STL class.
T c_str(T...args)
virtual ItemContainer & items()=0
Access item container.
TTreeFormula * select
Pointer to ROOT select statement (filled for N-tuples only)
Definition: RootAddress.h:41
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:209
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 244 of file RootNTupleCnv.cpp.

245 {
246  INTuple* tupl = dynamic_cast<INTuple*>( pObj );
247  RootAddress* rpA = dynamic_cast<RootAddress*>( pAddr );
248  if ( !tupl || !rpA ) return makeError( "updateObj> Invalid Tuple reference." );
249  RootDataConnection* con = reinterpret_cast<RootDataConnection*>( rpA->ipar()[0] );
250  if ( !con ) return makeError( "updateObj> Failed to access data source!" );
251  TTree* tree = rpA->section;
252  if ( !tree ) return makeError( "Failed to access data tree:" + pAddr->par()[1] );
253  con->resetAge();
254  if ( con->tool()->refs() ) return i__updateObjRoot( rpA, tupl, tree, con );
255 #ifdef __POOL_COMPATIBILITY
256  // POOL compatibility mode:
257  return i__updateObjPool( rpA, tupl, tree, con );
258 #else
259  return makeError( "Failed to access reference branch for data tree:" + rpA->par()[1] );
260 #endif
261 }
Description:
Definition: RootAddress.h:37
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
NTuple interface class definition.
Definition: INTuple.h:82
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 120 of file RootNTupleCnv.h.

121  {
122  return StatusCode::SUCCESS;
123  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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 133 of file RootNTupleCnv.h.

134  {
135  return StatusCode::SUCCESS;
136  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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 146 of file RootNTupleCnv.h.

147  {
148  return StatusCode::SUCCESS;
149  }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87

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