All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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...
 
virtual ~RootNTupleCnv ()
 Standard destructor. More...
 
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAdd)
 Converter overrides: Convert the transient object to the requested representation. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAdd, DataObject *pObj)
 Resolve the references of the converted object. More...
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Converter overrides: Update the references of an updated transient object. More...
 
virtual StatusCode fillObjRefs (IOpaqueAddress *, DataObject *)
 Converter overrides: Update the references of an updated transient object. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the transient object: NTuples end here when reading records. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *, DataObject *)
 Converter overrides: Update the references of an updated transient object. More...
 
virtual StatusCode updateRep (IOpaqueAddress *, DataObject *)
 Converter overrides: Update the converted representation of a transient object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *, DataObject *)
 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...
 
virtual ~RootStatCnv ()
 Standard Destructor. More...
 
- Public Member Functions inherited from Gaudi::RootConverter
 RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor. More...
 
virtual ~RootConverter ()
 Standard Destructor. More...
 
virtual long repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
- Public Member Functions inherited from Converter
virtual StatusCode setDataProvider (IDataProviderSvc *svc)
 Set Data provider service. More...
 
virtual SmartIF
< IDataProviderSvc > & 
dataProvider () const
 Get Data provider service. More...
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Set conversion service the converter is connected to. More...
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Get conversion service the converter is connected to. More...
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility. More...
 
virtual SmartIF
< IAddressCreator > & 
addressCreator () const
 Retrieve address creator facility. More...
 
virtual const CLIDobjType () const
 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...
 
 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 extend_interfaces1< IConverter >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IConverter
 DeclareInterfaceID (IConverter, 3, 0)
 InterfaceID. More...
 
virtual ~IConverter ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()
 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...
 
virtual StatusCode initialize ()
 Initialize converter object. More...
 
virtual StatusCode finalize ()
 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
virtual ~Converter ()
 Standard Destructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service. More...
 
SmartIF< IMessageSvc > & messageService () const
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service. More...
 

Additional Inherited Members

- Public Types inherited from Converter
typedef
Gaudi::PluginService::Factory
< IConverter *, ISvcLocator * > 
Factory
 
- Public Types inherited from implements1< IConverter >
typedef implements1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1
< IConverter
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces1< IConverter >
typedef IConverter::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IConverter
enum  Status {
  INVALID_ADDRESS = IInterface::LAST_ERROR+1, INVALID_OBJECT, NO_MEMORY, BAD_STORAGE_TYPE,
  NO_SOURCE_OBJECT, ICONVERSIONSVC_LAST_ERROR
}
 Status code. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Attributes inherited from Gaudi::RootStatCnv
IDataManagerSvcm_dataMgr
 Reference to data manager service to manipulate the TES. More...
 
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...
 

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

56  : RootStatCnv(typ, clid, svc, mgr) {}
RootStatCnv(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Definition: RootStatCnv.cpp:25
virtual Gaudi::RootNTupleCnv::~RootNTupleCnv ( )
inlinevirtual

Standard destructor.

Definition at line 59 of file RootNTupleCnv.h.

59 {}

Member Function Documentation

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

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

Reimplemented from Gaudi::RootConverter.

Definition at line 137 of file RootNTupleCnv.cpp.

137  {
138  StatusCode status = S_FAIL;
139  RootDataConnection* con = 0;
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 ) {
151  auto_ptr<RootNTupleDescriptor> dsc(ptr=new RootNTupleDescriptor());
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 ( 0 == tree ) {
166  return makeError("Failed to access N-Tuple tree:"+cntName);
167  }
168  if ( !par_val.empty() ) {
169  SmartIF<INTupleSvc> ntupleSvc(dataProvider());
170  if ( ntupleSvc.isValid() ) {
171  char c;
172  CLID clid;
173  int siz, typ;
174  string title;
175  NTuple::Tuple* nt = 0;
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*)0);
231  break;
233  status = createItem(tree, nt, is, title, true, (void*)0);
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 = 0;
258  if ( nt ) nt->release();
259  }
260  }
261  }
262  }
263  return status;
264 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:39
Description:
Definition: RootAddress.h:38
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
tuple c
Definition: gaudirun.py:341
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
TTree * getSection(const std::string &sect, bool create=false)
Access TTree section from section name. The section is created if required.
#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:224
virtual const unsigned long * ipar() const
Retrieve integer parameters.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:75
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:101
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:9
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:367
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
virtual SmartIF< IDataProviderSvc > & dataProvider() const
Get Data provider service.
Definition: Converter.cpp:94
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:44
std::string container
Identifier of description.
Definition: RootRefs.h:105
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:58
list i
Definition: ana.py:128
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 
)
virtual

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

Reimplemented from Gaudi::RootConverter.

Definition at line 400 of file RootNTupleCnv.cpp.

400  {
401  IRegistry* pRegistry = pObj->registry();
402  if ( 0 != pRegistry ) {
403  pAddr = pRegistry->address();
404  if ( 0 != pAddr ) {
405  return S_OK;
406  }
407 
408  RootDataConnection* con = 0;
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 ( 0 != 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 = 0;
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 = 0;
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 = 0;
646  }
647  }
648  }
649  return status;
650  }
651  }
652  return S_FAIL;
653 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:39
Description:
Definition: RootAddress.h:38
virtual long type() const =0
Type information of the item.
tuple itm
Definition: ana.py:57
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:391
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
TTree * getSection(const std::string &sect, bool create=false)
Access TTree section from section name. The section is created if required.
std::vector< INTupleItem * > ItemContainer
Definition: INTuple.h:86
virtual const std::string & title() const =0
Object title.
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.
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:224
virtual const std::type_info & typeID() const =0
Compiler type ID.
virtual bool hasIndex() const =0
Is the tuple have an index item?
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
virtual const std::string & name() const =0
Access _Item name.
NTuple interface class definition.
Definition: INTuple.h:80
Persistent reference object.
Definition: RootRefs.h:31
NTuple interface class definition.
Definition: INTuple.h:27
virtual const unsigned long * ipar() const
Retrieve integer parameters.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:58
virtual INTupleItem * indexItem()=0
Pointer to index column (if present, 0 else)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:75
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.
virtual long dim(long i) const =0
Access individual dimensions.
virtual long repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: RootConverter.h:55
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
virtual StatusCode commitOutput(const std::string &outputFile, bool do_commit)
Commit pending output.
Definition: RootCnvSvc.cpp:331
Abstract class describing basic data in an Ntuple.
Definition: NTuple.h:38
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
virtual long ndim() const =0
Dimension.
#define S_OK
virtual ItemContainer & items()=0
Access item container.
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:58
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
virtual const std::string & index() const =0
Access the index _Item.
virtual long length() const =0
Access the buffer length.
virtual const void * buffer() const =0
Access data buffer (CONST)
virtual StatusCode Gaudi::RootNTupleCnv::fillObjRefs ( IOpaqueAddress ,
DataObject  
)
inlinevirtual

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

Reimplemented from Gaudi::RootConverter.

Definition at line 100 of file RootNTupleCnv.h.

StatusCode RootNTupleCnv::fillRepRefs ( IOpaqueAddress pAdd,
DataObject pObj 
)
virtual

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

Reimplemented from Gaudi::RootConverter.

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 = 0;
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:38
TTree * section
Pointer to ROOT TTree (filled for N-tuples only)
Definition: RootAddress.h:43
std::vector< INTupleItem * > ItemContainer
Definition: INTuple.h:86
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:69
NTuple interface class definition.
Definition: INTuple.h:80
virtual const unsigned long * ipar() const
Retrieve integer parameters.
virtual IRegistry * registry() const =0
Update branch name.
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
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:58
Concrete implementation of the IDataConnection interface to access ROOT files.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
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 = 0;
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 == 0 ) {
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 = 0;
342  string *spar = 0;
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;
354  pair<const RootRef*,const RootDataConnection::ContainerSection*> ls = con->getMergeSection(tree->GetName(),entry);
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:39
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.
std::vector< INTupleItem * > ItemContainer
Definition: INTuple.h:86
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.
int dbase
Data members to define object location in the persistent world.
Definition: RootRefs.h:33
Persistent reference object.
Definition: RootRefs.h:31
virtual const std::string * par() const
Retrieve string parameters.
void setClID(const CLID &clid)
Access : Set class ID of the link.
virtual const unsigned long * ipar() const
Retrieve integer 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.
virtual const std::string & criteria() const =0
Access the selection string.
virtual long type() const =0
Access the type of the object.
virtual ItemContainer & items()=0
Access item container.
TTreeFormula * select
Pointer to ROOT select statement (filled for N-tuples only)
Definition: RootAddress.h:41
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 
)
virtual

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

Reimplemented from Converter.

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 ( 0 != tupl && 0 != 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:38
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:80
virtual const std::string * par() const
Retrieve string parameters.
virtual const unsigned long * ipar() const
Retrieve integer 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.
virtual StatusCode Gaudi::RootNTupleCnv::updateObjRefs ( IOpaqueAddress ,
DataObject  
)
inlinevirtual

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

Reimplemented from Converter.

Definition at line 122 of file RootNTupleCnv.h.

virtual StatusCode Gaudi::RootNTupleCnv::updateRep ( IOpaqueAddress ,
DataObject  
)
inlinevirtual

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

Reimplemented from Converter.

Definition at line 134 of file RootNTupleCnv.h.

virtual StatusCode Gaudi::RootNTupleCnv::updateRepRefs ( IOpaqueAddress ,
DataObject  
)
inlinevirtual

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

Reimplemented from Converter.

Definition at line 146 of file RootNTupleCnv.h.


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