| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# RootHistCnv::RNTupleCnv Class Reference

NTuple converter class definition. More...

`#include <RNTupleCnv.h>`

Inheritance diagram for RootHistCnv::RNTupleCnv:

[legend]
Collaboration diagram for RootHistCnv::RNTupleCnv:

[legend]

List of all members.

## Public Member Functions
virtual StatusCode | initialize ()
| Initialize the converter.
virtual StatusCode | finalize ()
| Finalize the converter.
virtual StatusCode | createObj (IOpaqueAddress *pAddr, DataObject *&refpObj)
| Create the transient representation of an object.
virtual StatusCode | updateObj (IOpaqueAddress *pAddr, DataObject *refpObj)
| Update the transient object from the other representation.
virtual StatusCode | createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
| Convert the transient object to the requested representation.
virtual StatusCode | updateRep (IOpaqueAddress *pAddr, DataObject *pObj)
| Update the converted representation of a transient object.
## Protected Member Functions
| RNTupleCnv (ISvcLocator *svc, const CLID &clid)
| Standard constructor.
virtual | ~RNTupleCnv ()
| Standard destructor.
virtual StatusCode | load (TTree *tree, INTuple *&refpObj)=0
| Create the transient representation of an object.
virtual StatusCode | book (const std::string &desc, INTuple *pObj, TTree *&tree)=0
| Book a new N tuple.
virtual StatusCode | writeData (TTree *rtree, INTuple *pObj)=0
| Write N tuple data.
virtual StatusCode | readData (TTree *rtree, INTuple *pObj, long ievt)=0
| Read N tuple data.
virtual std::string | rootVarType (int)
| Return ROOT type info:.
## Protected Attributes
SmartIF< INTupleSvc > | m_ntupleSvc
| Reference to N tuple service.

## 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 32 of file RNTupleCnv.cpp.

    00033 : RConverter(clid, svc) {
    00034 }

RootHistCnv::RNTupleCnv::~RNTupleCnv | ( |  | ) | `[protected, virtual]`

Standard destructor.

Definition at line 40 of file RNTupleCnv.cpp.

    00040                                                {
    00041 }

## Member Function Documentation

StatusCode RootHistCnv::RNTupleCnv::initialize | ( |  | ) | `[virtual]`

Initialize the converter.

Reimplemented from Converter.

Definition at line 46 of file RNTupleCnv.cpp.

    00046                                                {
    00047 //-----------------------------------------------------------------------------
    00048   StatusCode status = Converter::initialize();
    00049   if ( status.isSuccess() ) {
    00050     m_ntupleSvc = serviceLocator()->service("NTupleSvc");
    00051     if (!m_ntupleSvc.isValid()) status = StatusCode::FAILURE;
    00052   }
    00053   return status;
    00054 }

StatusCode RootHistCnv::RNTupleCnv::finalize | ( | void |  | ) | `[virtual]`

Finalize the converter.

: the release at this point may brake (?)

Reimplemented from Converter.

Definition at line 59 of file RNTupleCnv.cpp.

    00059                                                {
    00060 //-----------------------------------------------------------------------------
    00062   m_ntupleSvc = 0; // release
    00063   return Converter::finalize();
    00064 }

StatusCode RootHistCnv::RNTupleCnv::createObj | ( | IOpaqueAddress * | pAddr,
|  | DataObject *& | refpObj |
| ) |  |  | `[virtual]`

Create the transient representation of an object.

Reimplemented from Converter.

Definition at line 97 of file RNTupleCnv.cpp.

    00100 {
    00101   MsgStream log (msgSvc(), "RNTupleCnv");
    00102
    00103   IRegistry* pReg = pAddress->registry();
    00104
    00105 //    log << MSG::WARNING << "adr: " << pAddress->par()[0] << " <> "
    00106 //        << pAddress->par()[1] << " <> " << pAddress->ipar()[0] << " <> "
    00107 //        << pAddress->ipar()[1] << " <> " << hex << rAddr->tObj()
    00108 //        << dec << " <> " << pReg->identifier() << endmsg;
    00109
    00110   std::string ident = pReg->identifier();
    00111
    00112   StatusCode status = readObject(pAddress, refpObject);  // Doesn't do anything
    00113   if ( status.isSuccess() )   {
    00114     RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddress );
    00115     if (rAddr == 0) {
    00116       log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
    00117       return StatusCode::FAILURE;
    00118     }
    00119     INTuple* nt = 0;
    00120     TTree* tobj = (TTree*) rAddr->tObj();
    00121     status = load(tobj, nt);
    00122     if (status.isSuccess()) {
    00123       refpObject = dynamic_cast<DataObject*>(nt);
    00124     } else {
    00125       log << MSG::ERROR << "Problems loading ntuple id: " << pReg->identifier()
    00126           << endmsg;
    00127     }
    00128   }
    00129   return status;
    00130 }

StatusCode RootHistCnv::RNTupleCnv::updateObj | ( | IOpaqueAddress * | pAddr,
|  | DataObject * | refpObj |
| ) |  |  | `[virtual]`

Update the transient object from the other representation.

Reimplemented from Converter.

Definition at line 68 of file RNTupleCnv.cpp.

    00071 {
    00072   MsgStream log (msgSvc(), "RNTupleCnv");
    00073
    00074   StatusCode status = StatusCode::FAILURE;
    00075
    00076   RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>(pAddress);
    00077
    00078   if (rAddr == 0) {
    00079     log << MSG::ERROR << "Could not dynamic cast to RootObjAddress" << endmsg;
    00080     return StatusCode::FAILURE;
    00081   }
    00082
    00083   TTree* rtree = (TTree*) rAddr->tObj();
    00084
    00085   try   {
    00086     unsigned long* info = (unsigned long*)pAddress->ipar();
    00087     setDirectory(pAddress->par()[0]);
    00088     status = readData(rtree, dynamic_cast<INTuple*>(pObject), info[1]++);
    00089   }
    00090   catch (...)   {
    00091   }
    00092   return status;
    00093 }

StatusCode RootHistCnv::RNTupleCnv::createRep | ( | DataObject * | pObj,
|  | IOpaqueAddress *& | refpAddr |
| ) |  |  | `[virtual]`

Convert the transient object to the requested representation.

Reimplemented from RootHistCnv::RConverter.

Definition at line 134 of file RNTupleCnv.cpp.

    00137 {
    00138   GlobalDirectoryRestore restore;
    00139   pAddr = 0;
    00140   try   {
    00141     IRegistry* pReg = pObject->registry();
    00142     if ( 0 != pReg )    {
    00143       pAddr = pReg->address();
    00144       if ( 0 == pAddr )   {
    00145         SmartIF<IDataManagerSvc> dataMgr(dataProvider());
    00146         if ( dataMgr.isValid() )    {
    00147           IRegistry* pParentReg = 0;
    00148           StatusCode status = dataMgr->objectParent(pReg, pParentReg);
    00149           if ( status.isSuccess() )  {
    00150             IOpaqueAddress* pParAddr = pParentReg->address();
    00151             if ( pParAddr )   {
    00152               TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0];
    00153               if ( pParentDir )   {
    00154                 TTree* pTree = 0;
    00155                 std::string dsc = pReg->name().substr(1);
    00156                 gDirectory = pParentDir;
    00157                 status = book(dsc, dynamic_cast<INTuple*>(pObject), pTree);
    00158                 if ( !status.isSuccess() )   {
    00159                   return status;
    00160                 }
    00161                 status = createAddress(pObject, gDirectory, pTree, pAddr);
    00162                 if ( !status.isSuccess() )   {
    00163                   return status;
    00164                 }
    00165                 return writeData(pTree, dynamic_cast<INTuple*>(pObject));
    00166               }
    00167             }
    00168           }
    00169         }
    00170       }
    00171       else  {
    00172         TDirectory* pDir  = (TDirectory*)pAddr->ipar()[0];
    00173         RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddr );
    00174         if (rAddr == 0) {
    00175           MsgStream log (msgSvc(), "RNTupleCnv");
    00176           log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
    00177           return StatusCode::FAILURE;
    00178         }
    00179         TTree*      pTree = (TTree*) rAddr->tObj();
    00180         gDirectory = pDir;
    00181         return writeData(pTree, dynamic_cast<INTuple*>(pObject));
    00182       }
    00183     }
    00184   }
    00185   catch (...)   {
    00186   }
    00187   MsgStream log (msgSvc(), "RNTupleCnv");
    00188   log << MSG::ERROR << "Failed to create persistent N-tuple!" << endmsg;
    00189   return StatusCode::FAILURE;
    00190 }

StatusCode RootHistCnv::RNTupleCnv::updateRep | ( | IOpaqueAddress * | pAddr,
|  | DataObject * | pObj |
| ) |  |  | `[virtual]`

Update the converted representation of a transient object.

Reimplemented from Converter.

Definition at line 194 of file RNTupleCnv.cpp.

    00197 {
    00198   MsgStream log (msgSvc(), "RNTupleCnv");
    00199   if ( 0 != pAddr )    {
    00200     GlobalDirectoryRestore restore;
    00201     TDirectory* pDir = (TDirectory*)pAddr->ipar()[0];
    00202     RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddr );
    00203     if (rAddr == 0) {
    00204       log << MSG::ERROR << "Could not cast to RootObjAddress" << endmsg;
    00205       return StatusCode::FAILURE;
    00206     }
    00207     TTree* pTree     = (TTree*) rAddr->tObj();
    00208     if ( 0 != pDir && 0 != pTree )  {
    00209       gDirectory->cd(pDir->GetPath());
    00210       pTree->Write("",TObject::kOverwrite);
    00211       return StatusCode::SUCCESS;
    00212     }
    00213   }
    00214   else {
    00215     log << MSG::WARNING << "empty ntuple: " << pObj->registry()->identifier()
    00216         << endmsg;
    00217     return ( createRep(pObj,pAddr) );
    00218   }
    00219   return StatusCode::FAILURE;
    00220 }

virtual StatusCode RootHistCnv::RNTupleCnv::load | ( | TTree * | tree,
|  | INTuple *& | refpObj |
| ) |  |  | `[protected, pure virtual]`

Create the transient representation of an object.

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

virtual StatusCode RootHistCnv::RNTupleCnv::book | ( | const std::string & | desc,
|  | INTuple * | pObj,
|  | TTree *& | tree |
| ) |  |  | `[protected, pure virtual]`

Book a new N tuple.

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

virtual StatusCode RootHistCnv::RNTupleCnv::writeData | ( | TTree * | rtree,
|  | INTuple * | pObj |
| ) |  |  | `[protected, pure virtual]`

Write N tuple data.

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

virtual StatusCode RootHistCnv::RNTupleCnv::readData | ( | TTree * | rtree,
|  | INTuple * | pObj,
|  | long | ievt |
| ) |  |  | `[protected, pure virtual]`

Read N tuple data.

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

std::string RootHistCnv::RNTupleCnv::rootVarType | ( | int | type | ) | `[protected, virtual]`

Return ROOT type info:.

Definition at line 226 of file RNTupleCnv.cpp.

    00226                                                      {
    00227 //-----------------------------------------------------------------------------
    00228   switch( type ) {
    00229   case DataTypeInfo::SHORT:   return "/S";           // short
    00230   case DataTypeInfo::INT:     return "/I";           // int
    00231   case DataTypeInfo::LONG:    return "/I";           // long
    00232   case DataTypeInfo::USHORT:  return "/s";           // ushort
    00233   case DataTypeInfo::UINT:    return "/i";           // uint
    00234   case DataTypeInfo::ULONG:   return "/i";           // ulong
    00235   case DataTypeInfo::FLOAT:   return "/F";           // float
    00236   case DataTypeInfo::DOUBLE:  return "/D";           // double
    00237   default:                    return "";
    00238   }
    00239   // cannot reach this point
    00240 }

## 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:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/RootHistCnv/src/RNTupleCnv.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/RootHistCnv/src/RNTupleCnv.cpp