I’m trying to use some compiled code in PyROOT. I compile it as standalone code, producing two .so files, and they work with other compiled C ROOT code, but I can’t yet figure out how to make it work in Python. Could someone point out what I’m doing wrong?
my simpleminded script:
from ROOT import gSystem
all fine to here
from ROOT import CalibrationDataInterfaceROOT
gives ImportError: cannot import name CalibrationDataInterfaceROOT
do I need to put “#pragma link” sorts of things into the C code?
how did you compile the C++ code? Did you generate dictionaries for it? You say that you use it from C. For C, python has the ctypes module if need be.
The code have two headers and two source files. From them, the standalone make command that the developers provide creates:
The BTagCalib_Dict.h file has things like
extern G__linked_taginfo G__BTagCalib_DictLN_AnalysiscLcLCalibrationDataInterfaceROOT;
which I guess is the CalibrationDataInterfaceROOT that I’m trying to import.
I just gSystem.Load the libBTagCalib.so file. Do I need to add in the others as well?
I would assume that the .so build from the _Dict.C file is linked against the original library, and that that is the library to load.
The code’s developer has explained to me how it’s to be done! What they do in their Python script is
bjet_SF = ROOT.Analysis.CalibrationDataInterfaceROOT(‘SV0’, ‘EnvTestFile.env’)
Maybe that’s the syntax because CalibrationDataInterfaceROOT in in the Analysis namespace? I’m not sure. Anyway, it works for me now!