Hi everyone,
This may be some wishful thinking, but I’m wondering if there is a way to convert at pyroot TFile in memory to a c++ TFile in memory so I can pass it from python to a c++ function I have wrapped. I’ve made a simple wrapper of of a c++ class using the popular ctypes hack. I have a cpp file sort of like the one below.
Foo.cc:
class Foo{
public:
void bar(TFile* f){
// some stuff with f
}
};
extern "C" {
Foo* Foo_new(){ return new Foo(); }
void Foo_bar(Foo* foo, TFile* f){ foo->bar(f); }
}
}
Which I can compile into a shared library with:
g++ -o Foo.so -shared -fPIC Foo.cc
It would be awesome if I could call this from python with something like:
from ctypes import cdll
import ROOT as rt
lib = cdll.LoadLibrary('./Foo.so')
class Foo(object):
def __init__(self):
self.obj = lib.Foo_new()
def bar(self, f):
lib.Foo_bar(self.obj, f)
f = rt.TFile("rando_file.root", "NEW")
f_c = f.pyrootTFileToCppTFile() // is there anything like this??
foo = Foo()
foo.bar(f_c)
Is it possible to “unwrap” a pyroot TFile in this way or am I just another foolish newbie?
Thanks!
Please read tips for efficient and successful posting and posting code
ROOT Version: 5.34/07
Platform: Ubuntu 16.04.6
_Compiler: g++ 49.3-13ubuntu2