All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

virtual StatusCode initialize ()
 Initialize the converter. More...
 
virtual StatusCode finalize ()
 Finalize the converter. More...
 
virtual StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create the transient representation of an object. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddr, DataObject *refpObj)
 Update the transient object from the other representation. More...
 
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
 Convert the transient object to the requested representation. More...
 
virtual StatusCode updateRep (IOpaqueAddress *pAddr, DataObject *pObj)
 Update the converted representation of a transient object. More...
 
- Public Member Functions inherited from RootHistCnv::RConverter
long repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
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
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...
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the created transient object. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an updated transient object. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 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 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

 RNTupleCnv (ISvcLocator *svc, const CLID &clid)
 Standard constructor. More...
 
virtual ~RNTupleCnv ()
 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...
 
virtual ~RConverter ()
 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
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...
 

Protected Attributes

SmartIF< INTupleSvcm_ntupleSvc
 Reference to N tuple 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 RootHistCnv::RConverter
static long storageType ()
 Inquire storage type. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 

Detailed Description

NTuple converter class definition.

Package : RootHistCnv Author : Charles Leggett

Definition at line 24 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.

36  : RConverter(clid, svc) {
37 }
RConverter(const CLID &clid, ISvcLocator *svc)
Standard constructor.
Definition: RConverter.h:59
RootHistCnv::RNTupleCnv::~RNTupleCnv ( )
protectedvirtual

Standard destructor.

Definition at line 43 of file RNTupleCnv.cpp.

43  {
44 }

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 
)
virtual

Create the transient representation of an object.

Reimplemented from Converter.

Definition at line 100 of file RNTupleCnv.cpp.

103 {
104  MsgStream log (msgSvc(), "RNTupleCnv");
105 
106  IRegistry* pReg = pAddress->registry();
107 
108  // log << MSG::WARNING << "adr: " << pAddress->par()[0] << " <> "
109  // << pAddress->par()[1] << " <> " << pAddress->ipar()[0] << " <> "
110  // << pAddress->ipar()[1] << " <> " << hex << rAddr->tObj()
111  // << dec << " <> " << pReg->identifier() << endmsg;
112 
113  std::string ident = pReg->identifier();
114 
115  StatusCode status = readObject(pAddress, refpObject); // Doesn't do anything
116  if ( status.isSuccess() ) {
117  RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddress );
118  if (rAddr == 0) {
119  log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
120  return StatusCode::FAILURE;
121  }
122  INTuple* nt = 0;
123  TTree* tobj = (TTree*) rAddr->tObj();
124  status = load(tobj, nt);
125  if (status.isSuccess()) {
126  refpObject = dynamic_cast<DataObject*>(nt);
127  } else {
128  log << MSG::ERROR << "Problems loading ntuple id: " << pReg->identifier()
129  << endmsg;
130  }
131  }
132  return status;
133 }
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:75
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:131
NTuple interface class definition.
Definition: INTuple.h:80
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
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:289
virtual const id_type & identifier() const =0
Full identifier (or key)
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode RootHistCnv::RNTupleCnv::createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
virtual

Convert the transient object to the requested representation.

Reimplemented from RootHistCnv::RConverter.

Definition at line 137 of file RNTupleCnv.cpp.

140 {
141  GlobalDirectoryRestore restore;
142  pAddr = 0;
143  try {
144  IRegistry* pReg = pObject->registry();
145  if ( 0 != pReg ) {
146  pAddr = pReg->address();
147  if ( 0 == pAddr ) {
149  if ( dataMgr.isValid() ) {
150  IRegistry* pParentReg = 0;
151  StatusCode status = dataMgr->objectParent(pReg, pParentReg);
152  if ( status.isSuccess() ) {
153  IOpaqueAddress* pParAddr = pParentReg->address();
154  if ( pParAddr ) {
155  TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0];
156  if ( pParentDir ) {
157  TTree* pTree = 0;
158  std::string dsc = pReg->name().substr(1);
159  gDirectory = pParentDir;
160  status = book(dsc, dynamic_cast<INTuple*>(pObject), pTree);
161  if ( !status.isSuccess() ) {
162  return status;
163  }
164  status = createAddress(pObject, gDirectory, pTree, pAddr);
165  if ( !status.isSuccess() ) {
166  return status;
167  }
168  return writeData(pTree, dynamic_cast<INTuple*>(pObject));
169  }
170  }
171  }
172  }
173  }
174  else {
175  TDirectory* pDir = (TDirectory*)pAddr->ipar()[0];
176  RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddr );
177  if (rAddr == 0) {
178  MsgStream log (msgSvc(), "RNTupleCnv");
179  log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
180  return StatusCode::FAILURE;
181  }
182  TTree* pTree = (TTree*) rAddr->tObj();
183  gDirectory = pDir;
184  return writeData(pTree, dynamic_cast<INTuple*>(pObject));
185  }
186  }
187  }
188  catch (...) {
189  }
190  MsgStream log (msgSvc(), "RNTupleCnv");
191  log << MSG::ERROR << "Failed to create persistent N-tuple!" << endmsg;
192  return StatusCode::FAILURE;
193 }
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:75
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:131
virtual const name_type & name() const =0
Name of the directory (or key)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual SmartIF< IDataProviderSvc > & dataProvider() const
Get Data provider service.
Definition: Converter.cpp:94
virtual StatusCode writeData(TTree *rtree, INTuple *pObj)=0
Write N tuple data.
Opaque address interface definition.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation. ...
Definition: RConverter.cpp:171
StatusCode RootHistCnv::RNTupleCnv::finalize ( )
virtual

Finalize the converter.

Fix-Me:
: the release at this point may brake (?)

Reimplemented from Converter.

Definition at line 62 of file RNTupleCnv.cpp.

62  {
63  //-----------------------------------------------------------------------------
65  m_ntupleSvc = 0; // release
66  return Converter::finalize();
67 }
virtual StatusCode finalize()
Initialize the converter.
Definition: Converter.cpp:76
SmartIF< INTupleSvc > m_ntupleSvc
Reference to N tuple service.
Definition: RNTupleCnv.h:58
StatusCode RootHistCnv::RNTupleCnv::initialize ( )
virtual

Initialize the converter.

Reimplemented from Converter.

Definition at line 49 of file RNTupleCnv.cpp.

49  {
50  //-----------------------------------------------------------------------------
52  if ( status.isSuccess() ) {
53  m_ntupleSvc = serviceLocator()->service("NTupleSvc");
54  if (!m_ntupleSvc.isValid()) status = StatusCode::FAILURE;
55  }
56  return status;
57 }
virtual StatusCode initialize()
Initialize the converter.
Definition: Converter.cpp:67
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:126
SmartIF< INTupleSvc > m_ntupleSvc
Reference to N tuple service.
Definition: RNTupleCnv.h:58
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 229 of file RNTupleCnv.cpp.

229  {
230  //-----------------------------------------------------------------------------
231  switch( type ) {
232  case DataTypeInfo::BOOL: return "/O"; // bool
233  case DataTypeInfo::SHORT: return "/S"; // short
234  case DataTypeInfo::INT: return "/I"; // int
235  case DataTypeInfo::LONG: return "/I"; // long
236  case DataTypeInfo::LONGLONG: return "/L"; // longlong
237  case DataTypeInfo::USHORT: return "/s"; // ushort
238  case DataTypeInfo::UINT: return "/i"; // uint
239  case DataTypeInfo::ULONG: return "/i"; // ulong
240  case DataTypeInfo::ULONGLONG: return "/l"; // ulonglong
241  case DataTypeInfo::FLOAT: return "/F"; // float
242  case DataTypeInfo::DOUBLE: return "/D"; // double
243  case DataTypeInfo::CHAR: return "/B"; // char
244  case DataTypeInfo::UCHAR: return "/b"; // char
245  default: return "";
246  }
247  // cannot reach this point
248 }
string type
Definition: gaudirun.py:126
StatusCode RootHistCnv::RNTupleCnv::updateObj ( IOpaqueAddress pAddr,
DataObject refpObj 
)
virtual

Update the transient object from the other representation.

Reimplemented from Converter.

Definition at line 71 of file RNTupleCnv.cpp.

74 {
75  MsgStream log (msgSvc(), "RNTupleCnv");
76 
78 
79  RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>(pAddress);
80 
81  if (rAddr == 0) {
82  log << MSG::ERROR << "Could not dynamic cast to RootObjAddress" << endmsg;
83  return StatusCode::FAILURE;
84  }
85 
86  TTree* rtree = (TTree*) rAddr->tObj();
87 
88  try {
89  unsigned long* info = (unsigned long*)pAddress->ipar();
90  setDirectory(pAddress->par()[0]);
91  status = readData(rtree, dynamic_cast<INTuple*>(pObject), info[1]++);
92  }
93  catch (...) {
94  }
95  return status;
96 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
void setDirectory(const std::string &loc)
Definition: RConverter.cpp:120
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:131
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
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:244
StatusCode RootHistCnv::RNTupleCnv::updateRep ( IOpaqueAddress pAddr,
DataObject pObj 
)
virtual

Update the converted representation of a transient object.

Reimplemented from Converter.

Definition at line 197 of file RNTupleCnv.cpp.

200 {
201  MsgStream log (msgSvc(), "RNTupleCnv");
202  if ( 0 != pAddr ) {
203  GlobalDirectoryRestore restore;
204  TDirectory* pDir = (TDirectory*)pAddr->ipar()[0];
205  RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddr );
206  if (rAddr == 0) {
207  log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
208  return StatusCode::FAILURE;
209  }
210  TTree* pTree = (TTree*) rAddr->tObj();
211  if ( 0 != pDir && 0 != pTree ) {
212  gDirectory->cd(pDir->GetPath());
213  pTree->Write("",TObject::kOverwrite);
214  return StatusCode::SUCCESS;
215  }
216  }
217  else {
218  log << MSG::WARNING << "empty ntuple: " << pObj->registry()->identifier()
219  << endmsg;
220  return ( createRep(pObj,pAddr) );
221  }
222  return StatusCode::FAILURE;
223 }
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:131
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&refpAddr)
Convert the transient object to the requested representation.
Definition: RNTupleCnv.cpp:137
virtual const id_type & identifier() const =0
Full identifier (or key)
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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 58 of file RNTupleCnv.h.


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