| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
RootHistCnv::RConverter Class Reference

Root Converter. More...

`#include <RConverter.h>`

Inheritance diagram for RootHistCnv::RConverter:
[legend]
Collaboration diagram for RootHistCnv::RConverter:
[legend]

## Public Member Functions
virtual StatusCode | createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
| Convert the transient object to the requested representation.
long | repSvcType () const
| Retrieve the class type of the data store the converter uses.
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 | initialize ()
| Initialize the converter.
virtual StatusCode | finalize ()
| Initialize the converter.
virtual StatusCode | setDataProvider (IDataProviderSvc *svc)
| Set Data provider service.
virtual SmartIF < IDataProviderSvc > & | dataProvider () const
| Get Data provider service.
virtual StatusCode | setConversionSvc (IConversionSvc *svc)
| Set conversion service the converter is connected to.
virtual SmartIF< IConversionSvc > & | conversionSvc () const
| Get conversion service the converter is connected to.
virtual StatusCode | setAddressCreator (IAddressCreator *creator)
| Set address creator facility.
virtual SmartIF < IAddressCreator > & | addressCreator () const
| Retrieve address creator facility.
virtual const CLID & | objType () const
| Retrieve the class type of objects the converter produces.
virtual long | i_repSvcType () const
| Retrieve the class type of the data store the converter uses.
virtual StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
| Create the transient representation of an object.
virtual StatusCode | fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Resolve the references of the created transient object.
virtual StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
| Update the transient object from the other representation.
virtual StatusCode | updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Update the references of an updated transient object.
virtual StatusCode | fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Resolve the references of the converted object.
virtual StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
| Update the converted representation of a transient object.
virtual StatusCode | updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Update the references of an already converted object.
| Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
| Standard Constructor.
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.
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.
SmartIF< IService > | service (const std::string &name, const bool createIf=true) const
| Return a pointer to the service identified by name (or "type/name")

## Static Public Member Functions
static long | storageType ()
| Inquire storage type.

## Protected Member Functions
| RConverter (const CLID &clid, ISvcLocator *svc)
| Standard constructor.
virtual | ~RConverter ()
| Standard destructor.
virtual StatusCode | readObject (IOpaqueAddress *pAddr, DataObject *&refpObj)
| Create the transient representation of an object.
virtual TObject * | createPersistent (DataObject *pObj)
| Create the persistent representation of an object.
StatusCode | createAddress (DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
| Create address of the transient object according to the requested representation.
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)
Protected Member Functions inherited from Converter
virtual | ~Converter ()
| Standard Destructor.
SmartIF< ISvcLocator > & | serviceLocator () const
| Retrieve pointer to service locator.
SmartIF< IMessageSvc > & | msgSvc () const
| Retrieve pointer to message service.
SmartIF< IMessageSvc > & | messageService () const
SmartIF< IDataManagerSvc > & | dataManager () const
| Get Data Manager service.

## Additional Inherited Members
Public Types inherited from Converter
typedef Gaudi::PluginService::Factory1 < IConverter *, ISvcLocator * > | Factory

## Detailed Description

Root Converter.

Author
  Charles Leggett

Definition at line 34 of file RConverter.h.

## Constructor & Destructor Documentation

RootHistCnv::RConverter::RConverter | ( | const CLID & | clid,
|  | ISvcLocator * | svc
| ) |  |
| inline protected

Standard constructor.

Definition at line 59 of file RConverter.h.

: Converter(storageType(), clid, svc) { }

virtual RootHistCnv::RConverter::~RConverter | ( |  | ) |
| inline protected virtual

Standard destructor.

Definition at line 62 of file RConverter.h.

{ }

## Member Function Documentation

TDirectory * RootHistCnv::RConverter::changeDirectory | ( | DataObject * | pObject | ) |
| protected

Switch to object directory (=Parent directory)

Definition at line 236 of file RConverter.cpp.

{
if ( pObject ) {
IRegistry* pReg = pObject->registry();
if ( pReg ) {
SmartIF<IDataManagerSvc> dataMgr(dataProvider());
if ( dataMgr.isValid() ) {
IRegistry* pParentReg = 0;
StatusCode status = dataMgr->objectParent(pReg, pParentReg);
if ( status.isSuccess() ) {
IOpaqueAddress* pParAddr = pParentReg->address();
if ( pParAddr ) {
TDirectory* pParentDir = (TDirectory*)pParAddr->ipar()[0];
if ( pParentDir ) {
gDirectory->cd(pParentDir->GetPath());
return pParentDir;
}
}
}
}
}
}
return 0;
}

std::string RootHistCnv::RConverter::convertId | ( | const std::string & | id | ) | const

Definition at line 370 of file RConverter.cpp.

{
bool forced = false;
if ( id.size() > 0 && isdigit(id[0]) ) {
try {
BooleanProperty tmp;
tmp.assign(SmartIF<IProperty>(conversionSvc())->getProperty( "ForceAlphaIds"));
forced = (bool)tmp;
}
catch ( ... ) { }
}
if (forced ) return std::string("h") + id;
else return id;
}

StatusCode RootHistCnv::RConverter::createAddress | ( | DataObject * | pObject,
|  | TDirectory * | pDir,
|  | TObject * | pTObject,
|  | IOpaqueAddress *& | refpAddr
| ) |  |
| protected

Create address of the transient object according to the requested representation.

Definition at line 171 of file RConverter.cpp.

{
// Get address again....it does not change
IRegistry* pReg = pObj->registry();
if ( 0 != pReg ) {
refpAddr = pReg->address();
if ( 0 == refpAddr ) {
refpAddr = new RootObjAddress(repSvcType(),
objType(),
pReg->name(),
"",
(unsigned long)(pDir),
(unsigned long)(pTObj),
pTObj);
return StatusCode::SUCCESS;
}
}
return StatusCode::FAILURE;
}

StatusCode RootHistCnv::RConverter::createAddress | ( | const std::string & | rzdir,
|  | const CLID & | clid,
|  | long | id,
|  | TObject * | pTobj,
|  | IOpaqueAddress *& | refpAddress
| ) |  |
| protected

Definition at line 218 of file RConverter.cpp.

{
std::ostringstream obj; obj << id;
StatusCode status = createAddress(rzdir, clid, obj.str(), pTobj, refpAddress);
if ( status.isSuccess() ) {
unsigned long* ipar = (unsigned long*)refpAddress->ipar();
ipar[0] = id;
}
return status;
}

StatusCode RootHistCnv::RConverter::createAddress | ( | const std::string & | rzdir,
|  | const CLID & | clid,
|  | const std::string & | title,
|  | TObject * | pTobj,
|  | IOpaqueAddress *& | refpAddress
| ) |  |
| protected

Definition at line 197 of file RConverter.cpp.

{
RootObjAddress* pA = new RootObjAddress(repSvcType(),
clid,
rzdir,
title,
0,
0,
pTObj );
refpAddress = pA;
return StatusCode::SUCCESS;
}

StatusCode RootHistCnv::RConverter::createDirectory | ( | const std::string & | loc | ) |

Definition at line 26 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter::createDir");
// Get rid of leading /NTUPLES
std::string full;
full = diskDirectory( loc );
int p,i;
std::string fil,cur,s;
TDirectory *gDir;
gDir = gDirectory;
TFile *tf;
if ( findTFile(loc,tf).isSuccess() ) {
tf->cd();
}
std::list<std::string> lpath;
i = 1;
if ( (p=full.find(":",0)) != -1 ) {
fil = full.substr(0,p);
i = p+1;
fil += ":/";
gDirectory->cd(fil.c_str());
}
while ( (p = full.find("/",i)) != -1) {
s = full.substr(i,p-i);
lpath.push_back(s);
i = p+1;
}
lpath.push_back( full.substr(i,full.length()-i) );
if ( full.substr(0,1) == "/") {
gDirectory->cd("/");
}
std::list<std::string>::const_iterator litr;
for(litr=lpath.begin(); litr!=lpath.end(); ++litr) {
cur = *litr;
if (! gDirectory->GetKey(litr->c_str()) ) {
gDirectory->mkdir(litr->c_str());
}
gDirectory->cd(litr->c_str());
}
gDirectory = gDir;
return StatusCode::SUCCESS;
}

StatusCode RootHistCnv::RConverter::createDiskDirectory | ( | const std::string & | loc | ) |

TObject * RootHistCnv::RConverter::createPersistent | ( | DataObject * | pObj | ) |
| protected virtual

Create the persistent representation of an object.

Reimplemented in RootHistCnv::RHistogramCnv< T, S, Q >.

Definition at line 302 of file RConverter.cpp.

{
return 0;
}

StatusCode RootHistCnv::RConverter::createRep | ( | DataObject * | pObj,
|  | IOpaqueAddress *& | refpAddr
| ) |  |
| virtual

Convert the transient object to the requested representation.

Reimplemented from Converter.

Reimplemented in RootHistCnv::RFileCnv, RootHistCnv::RNTupleCnv, RootHistCnv::RDirectoryCnv, and RootHistCnv::DirectoryCnv.

Definition at line 264 of file RConverter.cpp.

{
GlobalDirectoryRestore restore;
pAddr = 0;
try {
TDirectory* pParentDir = changeDirectory(pObject);
if ( pParentDir ) {
TObject* pTObj = createPersistent(pObject);
if ( pTObj ) {
pTObj->Write();
delete pTObj;
return createAddress(pObject, pParentDir, 0, pAddr);
}
}
}
catch (...) {
}
MsgStream log (msgSvc(), "RConverter");
log << MSG::ERROR << "Failed to create persistent Object!" << endmsg;
return StatusCode::FAILURE;
}

std::string RootHistCnv::RConverter::directory | ( | const std::string & | loc | ) |

Definition at line 113 of file RConverter.cpp.

{
return ( diskDirectory(loc) );
}

std::string RootHistCnv::RConverter::diskDirectory | ( | const std::string & | loc | ) |

Definition at line 81 of file RConverter.cpp.

{
// Get rid of leading /NTUPLES/{INPUT_STREAM} or /stat/{INPUT_STREAM}
std::string dir;
long lf1 = loc.find("/NTUPLES/");
long lf2 = loc.find("/stat/");
long ll;
if (lf1 != -1) {
ll = loc.find("/",lf1+9);
} else if (lf2 != -1) {
ll = loc.find("/",lf2+6);
} else {
MsgStream log(msgSvc(), "RConverter");
log << MSG::ERROR << "diskDirectory(" << loc << ")"
<< " --> no leading /NTUPLES/ or /stat/" << endmsg;
return loc;
}
// dir = loc.substr(ll+8,loc.length()-ll-8);
if (ll == -1) {
dir = "/";
} else {
dir = loc.substr(ll,loc.length()-ll);
}
return dir;
}

StatusCode RootHistCnv::RConverter::error | ( | const std::string & | msg | ) |

Definition at line 386 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RootHistCnv");
log << MSG::ERROR << msg << endmsg;
return StatusCode::FAILURE;
}

StatusCode RootHistCnv::RConverter::findTFile | ( | const std::string | id,
|  | TFile *& | tfile
| ) |  |

Definition at line 331 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter");
tfile = 0;
std::string idm;
// make sure we only get first two parts of id
int i1,i2,i3;
i1 = id.find("/",0);
if (i1 != 0) {
log << MSG::ERROR << "Directory name does not start with \"/\": "
<< id << endmsg;
return StatusCode::FAILURE;
}
i2 = id.find("/",i1+1);
if (i2 == -1) {
log << MSG::ERROR << "Directory name has only one part: " << id << endmsg;
return StatusCode::FAILURE;
}
i3 = id.find("/",i2+1);
if (i3 == -1) {
idm = id;
} else {
idm = id.substr(0,i3);
}
std::map<std::string,TFile*>::const_iterator imap;
imap = s_fileMap.find(idm);
if ( imap == s_fileMap.end() ) {
return StatusCode::FAILURE;
}
tfile = (*imap).second;
return StatusCode::SUCCESS;
}

std::string RootHistCnv::RConverter::getDirectory | ( |  | ) |

Definition at line 162 of file RConverter.cpp.

{
std::string dir = gDirectory->GetPath();
return (dir);
}

StatusCode RootHistCnv::RConverter::readObject | ( | IOpaqueAddress * | pAddr,
|  | DataObject *& | refpObj
| ) |  |
| protected virtual

Create the transient representation of an object.

Definition at line 289 of file RConverter.cpp.

{
// MsgStream log(msgSvc(), "RConverter::readObject");
// log << MSG::WARNING << pAddr->par()[0] << " <> " << pAddr->par()[1]
// << " <> "
// << pAddr->ipar()[0] << " <> " << pAddr->ipar()[1] << " <> "
// << pAddr->registry()->identifier() << endmsg;
return StatusCode::SUCCESS;
}

StatusCode RootHistCnv::RConverter::regTFile | ( | const std::string | id,
|  | const TFile * | tfile
| ) |  |

Definition at line 309 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter");
std::map<std::string,TFile*>::const_iterator imap;
imap = s_fileMap.find(id);
if ( imap != s_fileMap.end() ) {
log << MSG::ERROR << "cannot register TTree " << id
<< ": already exists" << endmsg;
return StatusCode::FAILURE;
}
s_fileMap[id] = const_cast<TFile*>(tfile);
return StatusCode::SUCCESS;
}

long RootHistCnv::RConverter::repSvcType | ( |  | ) | const
| inline virtual

Retrieve the class type of the data store the converter uses.

Returns
  Class type information about the source data store type the converter will use to retrieve the information.

Implements IConverter.

Definition at line 41 of file RConverter.h.

{ return i_repSvcType(); }

void RootHistCnv::RConverter::setDirectory | ( | const std::string & | loc | ) |

Definition at line 120 of file RConverter.cpp.

{
MsgStream log(msgSvc(), "RConverter");
std::string full, id;
TFile *tf;
full = diskDirectory( loc );
// get associated TFile
if ( findTFile(loc,tf).isSuccess() ) {
tf->cd();
} else {
log << MSG::ERROR << "error getting TFile name " << loc << endmsg;
}
int p,i=1;
std::string cur,sdir;
gDirectory->cd("/");
while ( (p = full.find("/",i)) != -1) {
sdir = full.substr(i,p-i);
if (! gDirectory->GetKey(sdir.c_str()) ) {
log << MSG::ERROR << "cannot cd to " << full << " from "
<< gDirectory->GetPath() << endmsg;
return;
}
gDirectory->cd(sdir.c_str());
i = p+1;
}
gDirectory->cd( full.substr(i,full.length()-i).c_str() );
}

void RootHistCnv::RConverter::setDiskDirectory | ( | const std::string & | loc | ) |

Definition at line 155 of file RConverter.cpp.

{
setDirectory(loc);
}

static long RootHistCnv::RConverter::storageType | ( |  | ) |
| inline static

Inquire storage type.

Definition at line 40 of file RConverter.h.

{ return ROOT_StorageType; }

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/RootHistCnv/src/RConverter.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/RootHistCnv/src/RConverter.cpp