1 #define ROOTHISTCNV_RCONVERTER_CPP
4 #include "GaudiKernel/IDataProviderSvc.h"
5 #include "GaudiKernel/IDataManagerSvc.h"
6 #include "GaudiKernel/IRegistry.h"
7 #include "GaudiKernel/SmartIF.h"
8 #include "GaudiKernel/DataObject.h"
9 #include "GaudiKernel/MsgStream.h"
13 #include "TDirectory.h"
20 std::map<std::string,TFile*> s_fileMap;
32 std::string fil,cur,
s;
33 TDirectory *gDir = gDirectory;
40 std::vector<std::string> lpath;
43 auto p=full.find(
":",0);
44 if ( p != std::string::npos ) {
45 fil = full.substr(0,p);
48 gDirectory->cd(fil.c_str());
51 while ( (p = full.find(
"/",i)) != std::string::npos ) {
52 s = full.substr(i,p-i);
56 lpath.push_back( full.substr(i) );
58 if ( full.compare(0,1,
"/") == 0 ) gDirectory->cd(
"/");
60 for(
const auto& litr : lpath ) {
62 if (! gDirectory->GetKey(litr.c_str()) ) {
63 gDirectory->mkdir(litr.c_str());
65 gDirectory->cd(litr.c_str());
78 long lf1 = loc.find(
"/NTUPLES/");
79 long lf2 = loc.find(
"/stat/");
82 ll = loc.find(
"/",lf1+9);
84 }
else if (lf2 != -1) {
85 ll = loc.find(
"/",lf2+6);
89 log <<
MSG::ERROR <<
"diskDirectory(" << loc <<
")"
90 <<
" --> no leading /NTUPLES/ or /stat/" <<
endmsg;
108 return diskDirectory(loc);
118 std::string full = diskDirectory( loc );
121 if ( findTFile(loc,tf).isSuccess() ) {
128 std::string cur,sdir;
131 while ( (p = full.find(
"/",i)) != -1) {
132 sdir = full.substr(i,p-i);
133 if (! gDirectory->GetKey(sdir.c_str()) ) {
134 log <<
MSG::ERROR <<
"cannot cd to " << full <<
" from "
135 << gDirectory->GetPath() <<
endmsg;
138 gDirectory->cd(sdir.c_str());
142 gDirectory->cd( full.substr(i).c_str() );
156 return gDirectory->GetPath();
176 (
unsigned long)(pDir),
177 (
unsigned long)(pTObj),
189 const std::string& title,
215 auto obj = std::to_string(
id);
216 StatusCode status = createAddress(rzdir, clid, obj, pTobj, refpAddress);
218 unsigned long* ipar = (
unsigned long*)refpAddress->
ipar();
235 StatusCode status = dataMgr->objectParent(pReg, pParentReg);
239 TDirectory* pParentDir = (TDirectory*)pParAddr->
ipar()[0];
241 gDirectory->cd(pParentDir->GetPath());
261 TDirectory* pParentDir = changeDirectory(pObject);
263 TObject* pTObj = createPersistent(pObject);
267 return createAddress(pObject, pParentDir, 0, pAddr);
303 auto imap = s_fileMap.find(
id);
304 if ( imap != s_fileMap.end() ) {
306 log <<
MSG::ERROR <<
"cannot register TTree " <<
id
307 <<
": already exists" <<
endmsg;
310 s_fileMap[id] =
const_cast<TFile*
>(tfile);
329 log <<
MSG::ERROR <<
"Directory name does not start with \"/\": "
333 i2 =
id.find(
"/",i1+1);
338 i3 =
id.find(
"/",i2+1);
342 idm =
id.substr(0,i3);
345 auto imap = s_fileMap.find(idm);
347 tfile = imap->second;
355 if (
id.size() > 0 && isdigit(
id[0]) ) {
359 forced = tmp.
value();
363 if (forced )
return "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)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
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 *&)
const char *PyHelper() getProperty(IInterface *p, char *name)
StatusCode createDirectory(const std::string &loc)
IRegistry * registry() const
Get pointer to Registry.
TDirectory * changeDirectory(DataObject *pObject)
Switch to object directory (=Parent directory)
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.
const TYPE & value() const
explicit conversion
bool assign(const Property &source) override
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.
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)