The Gaudi Framework  v29r3 (fa547fc2)
RootHistCnv::RNTupleCnv Class Referenceabstract

NTuple converter class definition. More...

#include <src/RNTupleCnv.h>

Inheritance diagram for RootHistCnv::RNTupleCnv:
Collaboration diagram for RootHistCnv::RNTupleCnv:

Public Member Functions

StatusCode initialize () override
 Initialize the converter. More...
 
StatusCode finalize () override
 Finalize the converter. More...
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override
 Create the transient representation of an object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddr, DataObject *refpObj) override
 Update the transient object from the other representation. More...
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Convert the transient object to the requested representation. More...
 
StatusCode updateRep (IOpaqueAddress *pAddr, DataObject *pObj) override
 Update the converted representation of a transient object. More...
 
- Public Member Functions inherited from RootHistCnv::RConverter
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Convert the transient object to the requested representation. More...
 
long repSvcType () const override
 
StatusCode error (const std::string &msg)
 
StatusCode regTFile (const std::string, const TFile *)
 
StatusCode findTFile (const std::string, TFile *&)
 
std::string diskDirectory (const std::string &loc)
 
std::string directory (const std::string &loc)
 
void setDirectory (const std::string &loc)
 
void setDiskDirectory (const std::string &loc)
 
StatusCode createDirectory (const std::string &loc)
 
StatusCode createDiskDirectory (const std::string &loc)
 
std::string getDirectory ()
 
std::string convertId (const std::string &) const
 
- 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

 RNTupleCnv (ISvcLocator *svc, const CLID &clid)
 Standard constructor. More...
 
 ~RNTupleCnv () override=default
 Standard destructor. More...
 
virtual StatusCode load (TTree *tree, INTuple *&refpObj)=0
 Create the transient representation of an object. More...
 
virtual StatusCode book (const std::string &desc, INTuple *pObj, TTree *&tree)=0
 Book a new N tuple. More...
 
virtual StatusCode writeData (TTree *rtree, INTuple *pObj)=0
 Write N tuple data. More...
 
virtual StatusCode readData (TTree *rtree, INTuple *pObj, long ievt)=0
 Read N tuple data. More...
 
virtual std::string rootVarType (int)
 Return ROOT type info: More...
 
- Protected Member Functions inherited from RootHistCnv::RConverter
 RConverter (const CLID &clid, ISvcLocator *svc)
 Standard constructor. More...
 
 ~RConverter () override=default
 Standard destructor. More...
 
virtual StatusCode readObject (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create the transient representation of an object. More...
 
virtual TObject * createPersistent (DataObject *pObj)
 Create the persistent representation of an object. More...
 
StatusCode createAddress (DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
 Create address of the transient object according to the requested representation. More...
 
StatusCode createAddress (const std::string &rzdir, const CLID &clid, long id, TObject *pTobj, IOpaqueAddress *&refpAddress)
 
StatusCode createAddress (const std::string &rzdir, const CLID &clid, const std::string &title, TObject *pTobj, IOpaqueAddress *&refpAddress)
 
TDirectory * changeDirectory (DataObject *pObject)
 Switch to object directory (=Parent directory) 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...
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service. More...
 

Protected Attributes

SmartIF< INTupleSvcm_ntupleSvc
 Reference to N tuple service. More...
 
- Protected Attributes inherited from implements< IConverter >
std::atomic_ulong m_refCount
 Reference counter. 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...
 
- Static Public Member Functions inherited from RootHistCnv::RConverter
static long storageType ()
 Inquire storage type. More...
 

Detailed Description

NTuple converter class definition.

Package : RootHistCnv Author : Charles Leggett

Definition at line 25 of file RNTupleCnv.h.

Constructor & Destructor Documentation

RootHistCnv::RNTupleCnv::RNTupleCnv ( ISvcLocator svc,
const CLID clid 
)
protected

Standard constructor.

Definition at line 35 of file RNTupleCnv.cpp.

35 : RConverter( clid, svc ) {}
RConverter(const CLID &clid, ISvcLocator *svc)
Standard constructor.
Definition: RConverter.h:58
RootHistCnv::RNTupleCnv::~RNTupleCnv ( )
overrideprotecteddefault

Standard destructor.

Member Function Documentation

virtual StatusCode RootHistCnv::RNTupleCnv::book ( const std::string desc,
INTuple pObj,
TTree *&  tree 
)
protectedpure virtual

Book a new N tuple.

Implemented in RootHistCnv::RCWNTupleCnv, and RootHistCnv::RRWNTupleCnv.

StatusCode RootHistCnv::RNTupleCnv::createObj ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
)
override

Create the transient representation of an object.

Definition at line 89 of file RNTupleCnv.cpp.

91 {
92  MsgStream log( msgSvc(), "RNTupleCnv" );
93 
94  IRegistry* pReg = pAddress->registry();
95 
96  // log << MSG::WARNING << "adr: " << pAddress->par()[0] << " <> "
97  // << pAddress->par()[1] << " <> " << pAddress->ipar()[0] << " <> "
98  // << pAddress->ipar()[1] << " <> " << hex << rAddr->tObj()
99  // << dec << " <> " << pReg->identifier() << endmsg;
100 
101  std::string ident = pReg->identifier();
102 
103  StatusCode status = readObject( pAddress, refpObject ); // Doesn't do anything
104  if ( status.isSuccess() ) {
105  RootObjAddress* rAddr = dynamic_cast<RootObjAddress*>( pAddress );
106  if ( !rAddr ) {
107  log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
108  return StatusCode::FAILURE;
109  }
110  INTuple* nt = nullptr;
111  TTree* tobj = (TTree*)rAddr->tObj();
112  status = load( tobj, nt );
113  if ( status.isSuccess() ) {
114  refpObject = dynamic_cast<DataObject*>( nt );
115  } else {
116  log << MSG::ERROR << "Problems loading ntuple id: " << pReg->identifier() << endmsg;
117  }
118  }
119  return status;
120 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:103
STL class.
NTuple interface class definition.
Definition: INTuple.h:82
virtual const id_type & identifier() const =0
Full identifier (or key)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
virtual StatusCode load(TTree *tree, INTuple *&refpObj)=0
Create the transient representation of an object.
virtual StatusCode readObject(IOpaqueAddress *pAddr, DataObject *&refpObj)
Create the transient representation of an object.
Definition: RConverter.cpp:256
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode RootHistCnv::RNTupleCnv::createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
override

Convert the transient object to the requested representation.

Definition at line 124 of file RNTupleCnv.cpp.

126 {
127  GlobalDirectoryRestore restore;
128  pAddr = nullptr;
129  try {
130  IRegistry* pReg = pObject->registry();
131  if ( pReg ) {
132  pAddr = pReg->address();
133  if ( !pAddr ) {
134  auto dataMgr = dataProvider().as<IDataManagerSvc>();
135  if ( dataMgr ) {
136  IRegistry* pParentReg = nullptr;
137  StatusCode status = dataMgr->objectParent( pReg, pParentReg );
138  if ( status.isSuccess() ) {
139  IOpaqueAddress* pParAddr = pParentReg->address();
140  if ( pParAddr ) {
141  TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0];
142  if ( pParentDir ) {
143  TTree* pTree = nullptr;
144  std::string dsc = pReg->name().substr( 1 );
145  gDirectory = pParentDir;
146  status = book( dsc, dynamic_cast<INTuple*>( pObject ), pTree );
147  if ( !status.isSuccess() ) {
148  return status;
149  }
150  status = createAddress( pObject, gDirectory, pTree, pAddr );
151  if ( !status.isSuccess() ) {
152  return status;
153  }
154  return writeData( pTree, dynamic_cast<INTuple*>( pObject ) );
155  }
156  }
157  }
158  }
159  } else {
160  TDirectory* pDir = (TDirectory*)pAddr->ipar()[0];
161  RootObjAddress* rAddr = dynamic_cast<RootObjAddress*>( pAddr );
162  if ( !rAddr ) {
163  MsgStream log( msgSvc(), "RNTupleCnv" );
164  log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
165  return StatusCode::FAILURE;
166  }
167  TTree* pTree = (TTree*)rAddr->tObj();
168  gDirectory = pDir;
169  return writeData( pTree, dynamic_cast<INTuple*>( pObject ) );
170  }
171  }
172  } catch ( ... ) {
173  }
174  MsgStream log( msgSvc(), "RNTupleCnv" );
175  log << MSG::ERROR << "Failed to create persistent N-tuple!" << endmsg;
176  return StatusCode::FAILURE;
177 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual StatusCode book(const std::string &desc, INTuple *pObj, TTree *&tree)=0
Book a new N tuple.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:103
virtual const name_type & name() const =0
Name of the directory (or key)
STL class.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:115
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:74
virtual StatusCode writeData(TTree *rtree, INTuple *pObj)=0
Write N tuple data.
T substr(T...args)
Opaque address interface definition.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation. ...
Definition: RConverter.cpp:160
StatusCode RootHistCnv::RNTupleCnv::finalize ( )
override

Finalize the converter.

Definition at line 53 of file RNTupleCnv.cpp.

54 {
55  //-----------------------------------------------------------------------------
57  return Converter::finalize();
58 }
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:54
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
SmartIF< INTupleSvc > m_ntupleSvc
Reference to N tuple service.
Definition: RNTupleCnv.h:60
StatusCode RootHistCnv::RNTupleCnv::initialize ( )
override

Initialize the converter.

Definition at line 40 of file RNTupleCnv.cpp.

41 {
42  //-----------------------------------------------------------------------------
44  if ( status.isSuccess() ) {
45  m_ntupleSvc = serviceLocator()->service( "NTupleSvc" );
46  if ( !m_ntupleSvc ) status = StatusCode::FAILURE;
47  }
48  return status;
49 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:44
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:100
SmartIF< INTupleSvc > m_ntupleSvc
Reference to N tuple service.
Definition: RNTupleCnv.h:60
virtual StatusCode RootHistCnv::RNTupleCnv::load ( TTree *  tree,
INTuple *&  refpObj 
)
protectedpure virtual

Create the transient representation of an object.

Implemented in RootHistCnv::RCWNTupleCnv, and RootHistCnv::RRWNTupleCnv.

virtual StatusCode RootHistCnv::RNTupleCnv::readData ( TTree *  rtree,
INTuple pObj,
long  ievt 
)
protectedpure virtual

Read N tuple data.

Implemented in RootHistCnv::RCWNTupleCnv, and RootHistCnv::RRWNTupleCnv.

std::string RootHistCnv::RNTupleCnv::rootVarType ( int  type)
protectedvirtual

Return ROOT type info:

Definition at line 209 of file RNTupleCnv.cpp.

210 {
211  //-----------------------------------------------------------------------------
212  switch ( type ) {
213  case DataTypeInfo::BOOL:
214  return "/O"; // bool
215  case DataTypeInfo::SHORT:
216  return "/S"; // short
217  case DataTypeInfo::INT:
218  return "/I"; // int
219  case DataTypeInfo::LONG:
220  return "/I"; // long
222  return "/L"; // longlong
224  return "/s"; // ushort
225  case DataTypeInfo::UINT:
226  return "/i"; // uint
227  case DataTypeInfo::ULONG:
228  return "/i"; // ulong
230  return "/l"; // ulonglong
231  case DataTypeInfo::FLOAT:
232  return "/F"; // float
234  return "/D"; // double
235  case DataTypeInfo::CHAR:
236  return "/B"; // char
237  case DataTypeInfo::UCHAR:
238  return "/b"; // char
239  default:
240  return "";
241  }
242  // cannot reach this point
243 }
StatusCode RootHistCnv::RNTupleCnv::updateObj ( IOpaqueAddress pAddr,
DataObject refpObj 
)
override

Update the transient object from the other representation.

Definition at line 62 of file RNTupleCnv.cpp.

64 {
65  MsgStream log( msgSvc(), "RNTupleCnv" );
66 
68 
69  RootObjAddress* rAddr = dynamic_cast<RootObjAddress*>( pAddress );
70 
71  if ( !rAddr ) {
72  log << MSG::ERROR << "Could not dynamic cast to RootObjAddress" << endmsg;
73  return StatusCode::FAILURE;
74  }
75 
76  TTree* rtree = (TTree*)rAddr->tObj();
77 
78  try {
79  unsigned long* info = (unsigned long*)pAddress->ipar();
80  setDirectory( pAddress->par()[0] );
81  status = readData( rtree, dynamic_cast<INTuple*>( pObject ), info[1]++ );
82  } catch ( ... ) {
83  }
84  return status;
85 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
void setDirectory(const std::string &loc)
Definition: RConverter.cpp:113
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:103
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode readData(TTree *rtree, INTuple *pObj, long ievt)=0
Read N tuple data.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode RootHistCnv::RNTupleCnv::updateRep ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Update the converted representation of a transient object.

Definition at line 181 of file RNTupleCnv.cpp.

183 {
184  MsgStream log( msgSvc(), "RNTupleCnv" );
185  if ( pAddr ) {
186  GlobalDirectoryRestore restore;
187  TDirectory* pDir = (TDirectory*)pAddr->ipar()[0];
188  RootObjAddress* rAddr = dynamic_cast<RootObjAddress*>( pAddr );
189  if ( !rAddr ) {
190  log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
191  return StatusCode::FAILURE;
192  }
193  TTree* pTree = (TTree*)rAddr->tObj();
194  if ( pDir && pTree ) {
195  gDirectory->cd( pDir->GetPath() );
196  pTree->Write( "", TObject::kOverwrite );
197  return StatusCode::SUCCESS;
198  }
199  } else {
200  log << MSG::WARNING << "empty ntuple: " << pObj->registry()->identifier() << endmsg;
201  return createRep( pObj, pAddr );
202  }
203  return StatusCode::FAILURE;
204 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:103
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
virtual const id_type & identifier() const =0
Full identifier (or key)
StatusCode createRep(DataObject *pObj, IOpaqueAddress *&refpAddr) override
Convert the transient object to the requested representation.
Definition: RNTupleCnv.cpp:124
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual StatusCode RootHistCnv::RNTupleCnv::writeData ( TTree *  rtree,
INTuple pObj 
)
protectedpure virtual

Write N tuple data.

Implemented in RootHistCnv::RCWNTupleCnv, and RootHistCnv::RRWNTupleCnv.

Member Data Documentation

SmartIF<INTupleSvc> RootHistCnv::RNTupleCnv::m_ntupleSvc
protected

Reference to N tuple service.

Definition at line 60 of file RNTupleCnv.h.


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