![]() |
|
|
Generated: 8 Jan 2009 |
#include <RNTupleCnv.h>


Package : RootHistCnv Author : Charles Leggett
Definition at line 24 of file RNTupleCnv.h.
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 | |
| INTupleSvc * | m_ntupleSvc |
| Reference to N tuple service. | |
| RootHistCnv::RNTupleCnv::RNTupleCnv | ( | ISvcLocator * | svc, | |
| const CLID & | clid | |||
| ) | [protected] |
Standard constructor.
Definition at line 32 of file RNTupleCnv.cpp.
00033 : RConverter(clid, svc), m_ntupleSvc(0) { 00034 }
| RootHistCnv::RNTupleCnv::~RNTupleCnv | ( | ) | [protected, virtual] |
| 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 status = serviceLocator()->getService( "NTupleSvc", IID_INTupleSvc, 00051 *pp_cast<IInterface>(&m_ntupleSvc)); 00052 } 00053 return status; 00054 }
| StatusCode RootHistCnv::RNTupleCnv::finalize | ( | void | ) | [virtual] |
Finalize the converter.
Reimplemented from Converter.
Definition at line 59 of file RNTupleCnv.cpp.
00059 { 00060 //----------------------------------------------------------------------------- 00061 if ( m_ntupleSvc != 0 ) { 00062 // m_ntupleSvc->release(); 00063 } 00064 m_ntupleSvc = 0; 00065 return Converter::finalize(); 00066 }
| StatusCode RootHistCnv::RNTupleCnv::createObj | ( | IOpaqueAddress * | pAddr, | |
| DataObject *& | refpObj | |||
| ) | [virtual] |
Create the transient representation of an object.
Reimplemented from Converter.
Definition at line 99 of file RNTupleCnv.cpp.
00102 { 00103 MsgStream log (msgSvc(), "RNTupleCnv"); 00104 00105 IRegistry* pReg = pAddress->registry(); 00106 00107 // log << MSG::WARNING << "adr: " << pAddress->par()[0] << " <> " 00108 // << pAddress->par()[1] << " <> " << pAddress->ipar()[0] << " <> " 00109 // << pAddress->ipar()[1] << " <> " << hex << rAddr->tObj() 00110 // << dec << " <> " << pReg->identifier() << endreq; 00111 00112 std::string ident = pReg->identifier(); 00113 00114 StatusCode status = readObject(pAddress, refpObject); // Doesn't do anything 00115 if ( status.isSuccess() ) { 00116 RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddress ); 00117 if (rAddr == 0) { 00118 log << MSG::ERROR << "Could not cast to RootObjAddress" << endreq; 00119 return StatusCode::FAILURE; 00120 } 00121 INTuple* nt = 0; 00122 TTree* tobj = (TTree*) rAddr->tObj(); 00123 status = load(tobj, nt); 00124 if (status.isSuccess()) { 00125 refpObject = dynamic_cast<DataObject*>(nt); 00126 } else { 00127 log << MSG::ERROR << "Problems loading ntuple id: " << pReg->identifier() 00128 << endreq; 00129 } 00130 } 00131 return status; 00132 }
| StatusCode RootHistCnv::RNTupleCnv::updateObj | ( | IOpaqueAddress * | pAddr, | |
| DataObject * | refpObj | |||
| ) | [virtual] |
Update the transient object from the other representation.
Reimplemented from Converter.
Definition at line 70 of file RNTupleCnv.cpp.
00073 { 00074 MsgStream log (msgSvc(), "RNTupleCnv"); 00075 00076 StatusCode status = StatusCode::FAILURE; 00077 00078 RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>(pAddress); 00079 00080 if (rAddr == 0) { 00081 log << MSG::ERROR << "Could not dynamic cast to RootObjAddress" << endreq; 00082 return StatusCode::FAILURE; 00083 } 00084 00085 TTree* rtree = (TTree*) rAddr->tObj(); 00086 00087 try { 00088 unsigned long* info = (unsigned long*)pAddress->ipar(); 00089 setDirectory(pAddress->par()[0]); 00090 status = readData(rtree, dynamic_cast<INTuple*>(pObject), info[1]++); 00091 } 00092 catch (...) { 00093 } 00094 return status; 00095 }
| StatusCode RootHistCnv::RNTupleCnv::createRep | ( | DataObject * | pObj, | |
| IOpaqueAddress *& | refpAddr | |||
| ) | [virtual] |
Convert the transient object to the requested representation.
Reimplemented from RootHistCnv::RConverter.
Definition at line 136 of file RNTupleCnv.cpp.
00139 { 00140 GlobalDirectoryRestore restore; 00141 pAddr = 0; 00142 try { 00143 IRegistry* pReg = pObject->registry(); 00144 if ( 0 != pReg ) { 00145 pAddr = pReg->address(); 00146 if ( 0 == pAddr ) { 00147 SmartIF<IDataManagerSvc> dataMgr(dataProvider()); 00148 if ( dataMgr.isValid() ) { 00149 IRegistry* pParentReg = 0; 00150 StatusCode status = dataMgr->objectParent(pReg, pParentReg); 00151 if ( status.isSuccess() ) { 00152 IOpaqueAddress* pParAddr = pParentReg->address(); 00153 if ( pParAddr ) { 00154 TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0]; 00155 if ( pParentDir ) { 00156 TTree* pTree = 0; 00157 std::string dsc = pReg->name().substr(1); 00158 gDirectory = pParentDir; 00159 status = book(dsc, dynamic_cast<INTuple*>(pObject), pTree); 00160 if ( !status.isSuccess() ) { 00161 return status; 00162 } 00163 status = createAddress(pObject, gDirectory, pTree, pAddr); 00164 if ( !status.isSuccess() ) { 00165 return status; 00166 } 00167 return writeData(pTree, dynamic_cast<INTuple*>(pObject)); 00168 } 00169 } 00170 } 00171 } 00172 } 00173 else { 00174 TDirectory* pDir = (TDirectory*)pAddr->ipar()[0]; 00175 RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddr ); 00176 if (rAddr == 0) { 00177 MsgStream log (msgSvc(), "RNTupleCnv"); 00178 log << MSG::ERROR << "Could not cast to RootObjAddress" << endreq; 00179 return StatusCode::FAILURE; 00180 } 00181 TTree* pTree = (TTree*) rAddr->tObj(); 00182 gDirectory = pDir; 00183 return writeData(pTree, dynamic_cast<INTuple*>(pObject)); 00184 } 00185 } 00186 } 00187 catch (...) { 00188 } 00189 MsgStream log (msgSvc(), "RNTupleCnv"); 00190 log << MSG::ERROR << "Failed to create persistent N-tuple!" << endmsg; 00191 return StatusCode::FAILURE; 00192 }
| StatusCode RootHistCnv::RNTupleCnv::updateRep | ( | IOpaqueAddress * | pAddr, | |
| DataObject * | pObj | |||
| ) | [virtual] |
Update the converted representation of a transient object.
Reimplemented from Converter.
Definition at line 196 of file RNTupleCnv.cpp.
00199 { 00200 MsgStream log (msgSvc(), "RNTupleCnv"); 00201 if ( 0 != pAddr ) { 00202 GlobalDirectoryRestore restore; 00203 TDirectory* pDir = (TDirectory*)pAddr->ipar()[0]; 00204 RootObjAddress *rAddr = dynamic_cast<RootObjAddress*>( pAddr ); 00205 if (rAddr == 0) { 00206 log << MSG::ERROR << "Could not cast to RootObjAddress" << endreq; 00207 return StatusCode::FAILURE; 00208 } 00209 TTree* pTree = (TTree*) rAddr->tObj(); 00210 if ( 0 != pDir && 0 != pTree ) { 00211 gDirectory->cd(pDir->GetPath()); 00212 pTree->Write("",TObject::kOverwrite); 00213 return StatusCode::SUCCESS; 00214 } 00215 } 00216 else { 00217 log << MSG::WARNING << "empty ntuple: " << pObj->registry()->identifier() 00218 << endreq; 00219 return ( createRep(pObj,pAddr) ); 00220 } 00221 return StatusCode::FAILURE; 00222 }
| 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] |
| virtual StatusCode RootHistCnv::RNTupleCnv::writeData | ( | TTree * | rtree, | |
| INTuple * | pObj | |||
| ) | [protected, pure virtual] |
| virtual StatusCode RootHistCnv::RNTupleCnv::readData | ( | TTree * | rtree, | |
| INTuple * | pObj, | |||
| long | ievt | |||
| ) | [protected, pure virtual] |
| std::string RootHistCnv::RNTupleCnv::rootVarType | ( | int | type | ) | [protected, virtual] |
Return ROOT type info:.
Definition at line 228 of file RNTupleCnv.cpp.
00228 { 00229 //----------------------------------------------------------------------------- 00230 switch( type ) { 00231 case DataTypeInfo::SHORT: return "/S"; // short 00232 case DataTypeInfo::INT: return "/I"; // int 00233 case DataTypeInfo::LONG: return "/I"; // long 00234 case DataTypeInfo::USHORT: return "/s"; // ushort 00235 case DataTypeInfo::UINT: return "/i"; // uint 00236 case DataTypeInfo::ULONG: return "/i"; // ulong 00237 case DataTypeInfo::FLOAT: return "/F"; // float 00238 case DataTypeInfo::DOUBLE: return "/D"; // double 00239 default: return ""; 00240 } 00241 return ""; 00242 }
INTupleSvc* RootHistCnv::RNTupleCnv::m_ntupleSvc [protected] |