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...
 
 ~RootNTupleCnv () override=default
 Standard destructor. 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...
 
 ~RootStatCnv () override=default
 Standard Destructor. More...
 
- Public Member Functions inherited from Gaudi::RootConverter
 RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor. More...
 
 ~RootConverter () override=default
 Standard Destructor. 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...
 
 ~implements () override=default
 Virtual destructor. 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...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. 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
 ~Converter () override=default
 Standard Destructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service. More...
 

Additional Inherited Members

- Public Types inherited from Converter
typedef Gaudi::PluginService::Factory< IConverter *, ISvcLocator * > Factory
 
- 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 34 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
Gaudi::RootNTupleCnv::~RootNTupleCnv ( )
overridedefault

Standard destructor.

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

137  {
138  StatusCode status = S_FAIL;
139  RootDataConnection* con = nullptr;
140  IRegistry* pRegistry = pAddr->registry();
141  RootAddress* rpA = dynamic_cast<RootAddress*>(pAddr);
142  string path = fileName(pRegistry);
143  string cntName = containerName(pRegistry);
144  string* par = const_cast<string*>(pAddr->par());
145  status = m_dbMgr->connectDatabase(path,IDataConnection::READ,&con);
146  if ( status.isSuccess() ) {
147  string par_val, par_guid;
148  TBranch* b = con->getBranch("##Descriptors","GaudiStatisticsDescription");
149  if ( b ) {
152  b->SetAddress(&ptr);
153  for(Long64_t i=0, nent = b->GetEntries(); i<nent; ++i) {
154  int nb = b->GetEntry(i);
155  if ( nb > 1 ) {
156  if ( ptr->container == cntName ) {
157  par_val = ptr->description;
158  break;
159  }
160  }
161  }
162  }
163  par[2] = _tr(cntName);
164  TTree* tree = con->getSection(par[2]);
165  if ( nullptr == tree ) {
166  return makeError("Failed to access N-Tuple tree:"+cntName);
167  }
168  if ( !par_val.empty() ) {
169  auto ntupleSvc = dataProvider().as<INTupleSvc>();
170  if ( ntupleSvc ) {
171  char c;
172  CLID clid;
173  int siz, typ;
174  string title;
175  NTuple::Tuple* nt = nullptr;
176  istringstream is(par_val);
177  getline(is, title, ';') >> clid >> c >> siz >> c;
178  status = ntupleSvc->create(clid, title, nt);
179  for ( int j = 0; j < siz && status.isSuccess(); j++ ) {
180  is >> c;
181  getline(is, title, ';') >> typ >> c;
182  switch ( typ )
183  {
184  case DataTypeInfo::UCHAR:
185  status = createItem(tree, nt, is, title, true, (unsigned char)0);
186  break;
188  status = createItem(tree, nt, is, title, true, (unsigned short)0);
189  break;
190  case DataTypeInfo::UINT:
191  status = createItem(tree, nt, is, title, true, (unsigned int)0);
192  break;
193  case DataTypeInfo::ULONG:
194  status = createItem(tree, nt, is, title, true, (unsigned long)0);
195  break;
196  case DataTypeInfo::CHAR:
197  status = createItem(tree, nt, is, title, true, char(0));
198  break;
199  case DataTypeInfo::SHORT:
200  status = createItem(tree, nt, is, title, true, short(0));
201  break;
202  case DataTypeInfo::INT:
203  status = createItem(tree, nt, is, title, true, int(0));
204  break;
205  case DataTypeInfo::LONG:
206  status = createItem(tree, nt, is, title, true, long(0));
207  break;
208  case DataTypeInfo::BOOL:
209  status = createItem(tree, nt, is, title, true, false);
210  break;
211  case DataTypeInfo::FLOAT:
212  status = createItem(tree, nt, is, title, true, float(0.0));
213  break;
215  status = createItem(tree, nt, is, title, true, double(0.0));
216  break;
217  /*
218  case DataTypeInfo::NTCHAR:
219  case DataTypeInfo::LONG_NTCHAR:
220  status =
221  createItem(tree, nt, is, title, true, (char*)0);
222  break;
223  case DataTypeInfo::STRING:
224  case DataTypeInfo::LONG_STRING:
225  status =
226  createItem(tree, nt, is, title, true, string(""));
227  break;
228  */
230  status = createItem(tree, nt, is, title, false, (IOpaqueAddress*)nullptr);
231  break;
233  status = createItem(tree, nt, is, title, true, (void*)nullptr);
234  break;
236  default:
237  status = S_FAIL;
238  break;
239  }
240  if ( !status.isSuccess() ) {
241  log() << MSG::FATAL
242  << "Error connecting (Unknown) column:" << j << endmsg
243  << par_val << endmsg;
244  return makeError("createObj[NTuple]> Cannot determine column!");
245  }
246  }
247  if ( status.isSuccess() ) {
248  unsigned long* ipar = const_cast<unsigned long*>(rpA->ipar());
249  log() << MSG::DEBUG << "Created N-tuple with description:"
250  << par_val << endl;
251  ipar[0] = (unsigned long)con;
252  ipar[1] = ~0x0UL;
253  rpA->section = tree;
254  refpObject = nt;
255  }
256  else {
257  refpObject = nullptr;
258  if ( nt ) nt->release();
259  }
260  }
261  }
262  }
263  return status;
264 }
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
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:36
T getline(T...args)
TTree * getSection(const std::string &sect, bool create=false)
Access TTree section from section name. The section is created if required.
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:97
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:207
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:110
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:67
const unsigned long * ipar() const override
Retrieve integer parameters.
TBranch * getBranch(const std::string &section, const std::string &branch_name)
Access data branch by name: Get existing branch in read only mode.
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:370
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:56
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:92
STL class.
std::string container
Identifier of description.
Definition: RootRefs.h:83
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:50
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:244
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 400 of file RootNTupleCnv.cpp.

400  {
401  IRegistry* pRegistry = pObj->registry();
402  if ( nullptr != pRegistry ) {
403  pAddr = pRegistry->address();
404  if ( nullptr != pAddr ) {
405  return S_OK;
406  }
407 
408  RootDataConnection* con = nullptr;
409  string path = fileName(pRegistry);
410  string cntName = containerName(pRegistry);
411  string secName = cntName.c_str();
412  const INTuple* nt = dynamic_cast<const INTuple*>(pObj);
414  if ( !status.isSuccess() ) {
415  return makeError("Failed to access Tuple file:"+path);
416  }
417  TTree* tree = con->getSection(_tr(secName),true);
418  if ( nullptr != nt ) {
419  const INTuple::ItemContainer& items = nt->items();
420  ostringstream os;
421  size_t item_no;
422  string desc;
423  os << nt->title()<<';'<<pObj->clID()<<';'<<items.size()<< ';';
424  map<string,TBranch*> branches;
425  TBranch* b = nullptr;
426  for(item_no = 0; item_no < items.size(); ++item_no ) {
427  INTupleItem* it = items[item_no];
428  if ( it->hasIndex() ) {
429  INTupleItem* itm = it->indexItem();
430  const string& n = itm->name();
431  switch( itm->type() )
432  {
433  case DataTypeInfo::UCHAR:
434  desc = n+"/b";
435  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
436  break;
438  desc = n+"/s";
439  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
440  break;
441  case DataTypeInfo::UINT:
442  desc = n+"/i";
443  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
444  break;
445  case DataTypeInfo::ULONG:
446  desc = n+"/l";
447  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
448  break;
449  case DataTypeInfo::CHAR:
450  desc = n+"/B";
451  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
452  break;
453  case DataTypeInfo::SHORT:
454  desc = n+"/S";
455  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
456  break;
457  case DataTypeInfo::INT:
458  desc = n+"/I";
459  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
460  break;
461  case DataTypeInfo::LONG:
462  desc = n+"/L";
463  b = tree->Branch(n.c_str(),(void*)itm->buffer(),desc.c_str());
464  break;
465  default:
466  return makeError("Column "+it->index()+" is not a valid index column!");
467  }
468  branches[n] = b;
469  }
470  }
471  for(item_no = 0; item_no < items.size(); ++item_no ) {
472  INTupleItem* it = items[item_no];
473  const string& n = it->name();
474  os << '{'
475  << n << ';'
476  << it->type() << ';'
477  << it->length() << ';'
478  << it->ndim() << ';'
479  << it->hasIndex() << ';';
480  if ( it->hasIndex() ) {
481  os << it->index() << ';';
482  INTupleItem* itm = it->indexItem();
483  switch( itm->type() )
484  {
485  case DataTypeInfo::UCHAR:
486  putRange(os, dynamic_cast<NTuple::_Data<unsigned char>*>(itm));
487  break;
489  putRange(os, dynamic_cast<NTuple::_Data<unsigned short>*>(itm));
490  break;
491  case DataTypeInfo::UINT:
492  putRange(os, dynamic_cast<NTuple::_Data<unsigned int>*>(itm));
493  break;
494  case DataTypeInfo::ULONG:
495  putRange(os, dynamic_cast<NTuple::_Data<unsigned long>*>(itm));
496  break;
497  case DataTypeInfo::CHAR:
498  putRange(os, dynamic_cast<NTuple::_Data<char>*>(itm));
499  break;
500  case DataTypeInfo::SHORT:
501  putRange(os, dynamic_cast<NTuple::_Data<short>*>(itm));
502  break;
503  case DataTypeInfo::INT:
504  putRange(os, dynamic_cast<NTuple::_Data<int>*>(itm));
505  break;
506  case DataTypeInfo::LONG:
507  putRange(os, dynamic_cast<NTuple::_Data<long>*>(itm));
508  break;
509  default:
510  return makeError("NTuple:"+pRegistry->name()+" Column "+it->index()+
511  " is not a valid index column!");
512  }
513  }
514  for ( long k = 0; k < it->ndim(); k++ ) {
515  os << it->dim(k) << ';';
516  }
517  desc = n;
518  TClass* cl = nullptr;
519  switch(it->type())
520  {
522  desc = "/C";
523  os << 0 << ';' << 0 << ';';
524  break;
526  desc = "/C";
527  os << 0 << ';' << 0 << ';';
528  break;
530  if ( it->length() == 1 ) {
531  desc = System::typeinfoName(typeid(RootRef));
532  os << 0 << ';' << 0 << ';';
533  cl = TClass::GetClass(desc.c_str(),kTRUE);
534  }
535  break;
537  if ( it->length() == 1 ) {
538  os << 0 << ';' << 0 << ';';
539  cl = TClass::GetClass(it->typeID(), kTRUE);
540  }
541  break;
542  case DataTypeInfo::UCHAR:
543  desc = "/b";
544  putRange(os, dynamic_cast<NTuple::_Data<unsigned char>*>(it));
545  break;
547  desc = "/s";
548  putRange(os, dynamic_cast<NTuple::_Data<unsigned short>*>(it));
549  break;
550  case DataTypeInfo::UINT:
551  desc = "/i";
552  putRange(os, dynamic_cast<NTuple::_Data<unsigned int>*>(it));
553  break;
554  case DataTypeInfo::ULONG:
555  desc = "/l";
556  putRange(os, dynamic_cast<NTuple::_Data<unsigned long>*>(it));
557  break;
558  case DataTypeInfo::CHAR:
559  desc = "/B";
560  putRange(os, dynamic_cast<NTuple::_Data<char>*>(it));
561  break;
562  case DataTypeInfo::SHORT:
563  desc = "/S";
564  putRange(os, dynamic_cast<NTuple::_Data<short>*>(it));
565  break;
566  case DataTypeInfo::INT:
567  desc = "/I";
568  putRange(os, dynamic_cast<NTuple::_Data<int>*>(it));
569  break;
570  case DataTypeInfo::LONG:
571  desc = "/L";
572  putRange(os, dynamic_cast<NTuple::_Data<long>*>(it));
573  break;
574  case DataTypeInfo::BOOL:
575  desc = "/b";
576  putRange(os, dynamic_cast<NTuple::_Data<bool>*>(it));
577  break;
578  case DataTypeInfo::FLOAT:
579  desc = "/F";
580  putRange(os, dynamic_cast<NTuple::_Data<float>*>(it));
581  break;
583  desc = "/D";
584  putRange(os, dynamic_cast<NTuple::_Data<double>*>(it));
585  break;
587  default:
588  return makeError("Create item[FAIL]: "+it->name());
589  }
590  os << '}';
591  if ( branches.find(n) == branches.end() ) {
592  string tmp;
593  char text[32];
594  switch(it->ndim())
595  {
596  case 0:
597  desc = n+desc;
598  break;
599  case 2:
600  sprintf(text,"[%ld]",it->dim(0));
601  tmp = text;
602  case 1:
603  if ( it->hasIndex() ) {
604  INTupleItem* itm = it->indexItem();
605  desc = n + tmp + "[" + itm->name() + "]" + desc;
606  }
607  else {
608  sprintf(text,"[%ld]",it->dim(0));
609  desc = n + tmp + text + desc;
610  }
611  }
612  log() << MSG::DEBUG << "Create branch:" << n << " Desc:" << desc
613  << " of type:" << it->type() << endmsg;
614  switch(it->type())
615  {
617  branches[n] = tree->Branch(n.c_str(),cl->GetName(),(void*)it->buffer());
618  break;
620  branches[n] = tree->Branch(n.c_str(),cl->GetName(),(void*)it->buffer());
621  break;
622  default:
623  branches[n] = tree->Branch(n.c_str(),(void*)it->buffer(),desc.c_str());
624  break;
625  }
626  }
627  }
628 
629  log() << MSG::DEBUG << "Save description:" << path << " -> " << cntName << endmsg
630  << os.str() << endmsg;
631  status = saveDescription(path,cntName,os.str(),"",pObj->clID());
632  if ( status.isSuccess() ) {
633  status = m_dbMgr->commitOutput(path, true);
634  if ( status.isSuccess() ) {
635  string spar[] = { path, cntName};
636  unsigned long ipar[] = { (unsigned long)con, ~0x0u };
637  status = m_dbMgr->createAddress(repSvcType(),pObj->clID(),spar,ipar,pAddr);
638  if ( status.isSuccess() ) {
639  RootAddress* rpA = dynamic_cast<RootAddress*>(pAddr);
640  ((unsigned long*)rpA->ipar())[0] = (unsigned long)con;
641  rpA->section = tree;
642  }
643  else {
644  pAddr->release();
645  pAddr = nullptr;
646  }
647  }
648  }
649  return status;
650  }
651  }
652  return S_FAIL;
653 }
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:299
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:373
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:36
TTree * getSection(const std::string &sect, bool create=false)
Access TTree section from section name. The section is created if required.
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:97
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:207
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Definition: RootConverter.h:54
STL class.
StatusCode commitOutput(const std::string &outputFile, bool do_commit) override
Commit pending output.
Definition: RootCnvSvc.cpp:313
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
NTuple interface class definition.
Definition: INTuple.h:79
Persistent reference object.
Definition: RootRefs.h:30
virtual long ndim() const =0
Dimension.
NTuple interface class definition.
Definition: INTuple.h:26
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
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:26
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:67
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.
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:37
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:50
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:244
StatusCode Gaudi::RootNTupleCnv::fillObjRefs ( IOpaqueAddress ,
DataObject  
)
inlineoverride

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

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

Definition at line 99 of file RootNTupleCnv.h.

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

656  {
657  typedef INTuple::ItemContainer Cont;
658  INTuple* tupl = dynamic_cast<INTuple*>(pObj);
659  IRegistry* pReg = pObj->registry();
660  RootAddress* rpA = dynamic_cast<RootAddress*>(pAddr);
661  if ( tupl && pReg && rpA ) {
662  string cntName = containerName(pReg);
663  unsigned long* ipar = const_cast<unsigned long*>(pAddr->ipar());
664  RootDataConnection* con = (RootDataConnection*)rpA->ipar()[0];
665  if ( con ) {
666  TTree* tree = rpA->section;
667  if ( tree ) {
668  Cont& it = tupl->items();
669  size_t k, n = it.size();
670  vector<RootRef*> paddr(n);
671  vector<RootRef> addr(n);
672  for(k = 0; k < n; ++k) {
673  IOpaqueAddress* pA = nullptr;
674  Cont::value_type j = it[k];
675  switch( j->type() )
676  {
678  pA = (*(IOpaqueAddress**)j->buffer());
679  paddr[k] = &addr[k];
680  addr[k].reset();
681  if ( pA ) {
682  con->makeRef(pA->registry(),addr[k]);
683  addr[k].entry = pA->ipar()[1];
684  }
685  tree->SetBranchAddress(j->name().c_str(),&paddr[k]);
686  break;
687  default:
688  break;
689  }
690  }
691  int nb = tree->Fill();
692  if ( nb>1 ) ++ipar[1];
693  for(k = 0; k < n; ++k) it[k]->reset();
695  }
696  return makeError("fillRepRefs> Failed to access data tree:"+cntName);
697  }
698  return makeError("fillRepRefs> Failed to access data source!");
699  }
700  return makeError("fillRepRefs> Invalid Tuple reference.");
701 }
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.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
Definition: RootStatCnv.cpp:97
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
NTuple interface class definition.
Definition: INTuple.h:79
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
const unsigned long * ipar() const override
Retrieve integer parameters.
void makeRef(IRegistry *pA, RootRef &ref)
Create reference object from registry entry.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
STL class.
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:50
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 293 of file RootNTupleCnv.cpp.

293  {
294  typedef INTuple::ItemContainer Cont;
295  const string* par = rpA->par();
296  unsigned long* ipar = const_cast<unsigned long*>(rpA->ipar());
297  ++ipar[1];
298  if ( Long64_t(ipar[1]) <= tree->GetEntries() ) {
299  GenericAddress* pA = nullptr;
300  Cont& it = tupl->items();
301  size_t k, n = it.size();
302  vector<RootRef*> paddr(n);
303  vector<RootRef> addr(n);
304  for(k = 0; k < n; ++k) {
305  Cont::value_type j = it[k];
306  switch( j->type() )
307  {
309  paddr[k] = &addr[k];
310  tree->SetBranchAddress(j->name().c_str(),&paddr[k]);
311  break;
312  default:
313  break;
314  }
315  }
316 
317  ULong64_t last = (ULong64_t)tree->GetEntries();
318  ISelectStatement* sel = tupl->selector();
319  if ( sel ) {
320  string criteria = (sel && (sel->type() & ISelectStatement::STRING))
321  ? sel->criteria() : string("");
322  if ( !(criteria.length() == 0 || criteria == "*") ) {
323  if ( rpA->select == nullptr ) {
324  log() << MSG::DEBUG << "Selection criteria: " << criteria << " " << ipar[1] << endmsg;
325  rpA->select = new TTreeFormula(tree->GetName(),criteria.c_str(), tree);
326  }
327  rpA->select->SetTree(tree);
328  for( ; ipar[1] < last; ++ipar[1]) { // loop on all selected entries
329  tree->LoadTree(ipar[1]);
330  rpA->select->GetNdata();
331  if ( fabs(rpA->select->EvalInstance(0)) > std::numeric_limits<float>::epsilon() ) {
332  break;
333  }
334  log() << MSG::DEBUG << par[0] << "/" << par[1] << " SKIP Entry: " << ipar[1] << endmsg;
335  }
336  }
337  }
338  if ( ipar[1] < last ) {
339  unsigned long entry = ipar[1];
340  if ( tree->GetEntry(entry) > 1 ) {
341  RootRef *r = nullptr;
342  string *spar = nullptr;
343  for(k = 0; k < n; ++k) {
344  Cont::value_type j = it[k];
345  switch( j->type() )
346  {
348  r = paddr[k];
349  pA = (*(GenericAddress**)j->buffer());
350  if ( pA ) { // Fill only if item is connected!
351  spar = (string*)pA->par();
352  ipar = (unsigned long*)pA->ipar();
353  log() << MSG::DEBUG;
355  if ( ls.first ) {
356  if ( ls.first->dbase >= 0 ) {
357  // Now patch the references and links 'en block' to be efficient
358  // First the leafs from the TES
359 
360  r->dbase += ls.first->dbase;
361  r->container += ls.first->container;
362  r->link += ls.first->link;
363 
364  if ( log().isActive() ) {
365  log() << "Refs: LS [" << entry << "] -> "
366  << ls.first->dbase << "," << ls.first->container
367  << "," << ls.first->link
368  << "," << ls.first->entry
369  << " DB:" << con->getDb(r->dbase)
370  << endmsg;
371  }
372  }
373  }
374  spar[0] = con->getDb(r->dbase);
375  spar[1] = con->getCont(r->container);
376  spar[2] = con->getLink(r->link);
377  ipar[0] = 0;
378  ipar[1] = r->entry;
379  pA->setClID(r->clid);
380  pA->setSvcType(r->svc);
381  break;
382  }
383  break;
384  default:
385  break;
386  }
387  }
388  return StatusCode::SUCCESS;
389  }
390  log() << MSG::ERROR << "Failed to read data from NTuple tree." << endmsg;
391  return StatusCode::FAILURE;
392  }
393  log() << MSG::INFO << "End of input Ntuple." << endmsg;
394  return StatusCode::FAILURE;
395  }
396  return StatusCode::FAILURE;
397 }
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:84
bool isActive() const
Accessor: is MsgStream active.
Definition: MsgStream.h:128
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.
std::pair< const RootRef *, const ContainerSection * > getMergeSection(const std::string &container, int entry) const
Access link section for single container and entry.
const std::string & getCont(int which) const
Access container name from saved index.
T fabs(T...args)
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:39
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:244
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 267 of file RootNTupleCnv.cpp.

267  {
268  INTuple* tupl = dynamic_cast<INTuple*>(pObj);
269  RootAddress* rpA = dynamic_cast<RootAddress*>(pAddr);
270  if ( nullptr != tupl && nullptr != rpA ) {
271  RootDataConnection* con = (RootDataConnection*)rpA->ipar()[0];
272  if ( con ) {
273  TTree* tree = rpA->section;
274  if ( tree ) {
275  con->resetAge();
276  if ( con->tool()->refs() )
277  return i__updateObjRoot(rpA,tupl,tree,con);
278 #ifdef __POOL_COMPATIBILITY
279  // POOL compatibility mode:
280  return i__updateObjPool(rpA,tupl,tree,con);
281 #else
282  return makeError("Failed to access reference branch for data tree:"+rpA->par()[1]);
283 #endif
284  }
285  return makeError("Failed to access data tree:"+pAddr->par()[1]);
286  }
287  return makeError("updateObj> Failed to access data source!");
288  }
289  return makeError("updateObj> Invalid Tuple reference.");
290 }
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:97
NTuple interface class definition.
Definition: INTuple.h:79
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 121 of file RootNTupleCnv.h.

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.

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


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