2 #define ROOTHISTCNV_RCONVERTER_CPP
15 #include "TDirectory.h"
22 std::map<std::string,TFile*> s_fileMap;
36 std::string fil,cur,
s;
46 std::list<std::string> lpath;
49 if ( (p=full.find(
":",0)) != -1 ) {
50 fil = full.substr(0,p);
53 gDirectory->cd(fil.c_str());
56 while ( (p = full.find(
"/",i)) != -1) {
57 s = full.substr(i,p-i);
61 lpath.push_back( full.substr(i,full.length()-
i) );
63 if ( full.substr(0,1) ==
"/") {
67 std::list<std::string>::const_iterator litr;
68 for(litr=lpath.begin(); litr!=lpath.end(); ++litr) {
70 if (! gDirectory->GetKey(litr->c_str()) ) {
71 gDirectory->mkdir(litr->c_str());
73 gDirectory->cd(litr->c_str());
86 long lf1 = loc.find(
"/NTUPLES/");
87 long lf2 = loc.find(
"/stat/");
90 ll = loc.find(
"/",lf1+9);
92 }
else if (lf2 != -1) {
93 ll = loc.find(
"/",lf2+6);
97 log <<
MSG::ERROR <<
"diskDirectory(" << loc <<
")"
98 <<
" --> no leading /NTUPLES/ or /stat/" <<
endmsg;
106 dir = loc.substr(ll,loc.length()-ll);
116 return ( diskDirectory(loc) );
124 std::string full, id;
127 full = diskDirectory( loc );
130 if ( findTFile(loc,tf).isSuccess() ) {
137 std::string cur,sdir;
140 while ( (p = full.find(
"/",i)) != -1) {
141 sdir = full.substr(i,p-i);
142 if (! gDirectory->GetKey(sdir.c_str()) ) {
143 log <<
MSG::ERROR <<
"cannot cd to " << full <<
" from "
144 << gDirectory->GetPath() <<
endmsg;
147 gDirectory->cd(sdir.c_str());
151 gDirectory->cd( full.substr(i,full.length()-
i).c_str() );
165 std::string dir = gDirectory->GetPath();
181 if ( 0 == refpAddr ) {
186 (
unsigned long)(pDir),
187 (
unsigned long)(pTObj),
199 const std::string& title,
225 std::ostringstream obj; obj << id;
226 StatusCode status = createAddress(rzdir, clid, obj.str(), pTobj, refpAddress);
228 unsigned long* ipar = (
unsigned long*)refpAddress->
ipar();
245 StatusCode status = dataMgr->objectParent(pReg, pParentReg);
249 TDirectory* pParentDir = (TDirectory*)pParAddr->
ipar()[0];
251 gDirectory->cd(pParentDir->GetPath());
271 TDirectory* pParentDir = changeDirectory(pObject);
273 TObject* pTObj = createPersistent(pObject);
277 return createAddress(pObject, pParentDir, 0, pAddr);
316 std::map<std::string,TFile*>::const_iterator imap;
317 imap = s_fileMap.find(
id);
319 if ( imap != s_fileMap.end() ) {
320 log <<
MSG::ERROR <<
"cannot register TTree " <<
id
321 <<
": already exists" <<
endmsg;
325 s_fileMap[id] =
const_cast<TFile*
>(tfile);
344 log <<
MSG::ERROR <<
"Directory name does not start with \"/\": "
348 i2 =
id.find(
"/",i1+1);
353 i3 =
id.find(
"/",i2+1);
357 idm =
id.substr(0,i3);
360 std::map<std::string,TFile*>::const_iterator imap;
361 imap = s_fileMap.find(idm);
363 if ( imap == s_fileMap.end() ) {
366 tfile = (*imap).second;
374 if (
id.size() > 0 && isdigit(
id[0]) ) {
382 if (forced )
return std::string(
"h") + id;
std::string getDirectory()
Definition of the MsgStream class used to transmit messages.
std::string diskDirectory(const std::string &loc)
void setDirectory(const std::string &loc)
bool isSuccess() const
Test for a status code of SUCCESS.
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
StatusCode regTFile(const std::string, const TFile *)
virtual const name_type & name() const =0
Name of the directory (or key)
StatusCode findTFile(const std::string, TFile *&)
GAUDI_API Property * getProperty(const IProperty *p, const std::string &name)
simple function which gets the property with given name from the component
StatusCode createDirectory(const std::string &loc)
IRegistry * registry() const
Get pointer to Registry.
TDirectory * changeDirectory(DataObject *pObject)
Switch to object directory (=Parent directory)
bool isValid() const
Allow for check if smart pointer is valid.
virtual TObject * createPersistent(DataObject *pObj)
Create the persistent representation of an object.
This class is used for returning status codes from appropriate routines.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
unsigned int CLID
Class ID definition.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual bool assign(const Property &source)
get the value from another property
std::string directory(const std::string &loc)
StatusCode error(const std::string &msg)
std::string convertId(const std::string &) const
virtual StatusCode readObject(IOpaqueAddress *pAddr, DataObject *&refpObj)
Create the transient representation of an object.
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&refpAddr)
Convert the transient object to the requested representation.
Opaque address interface definition.
A DataObject is the base class of any identifiable object on any data store.
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.
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation. ...
void setDiskDirectory(const std::string &loc)