I have been facing problem reading object declared via ROOT.gInterpreter.Declare in RDataframe. What i wanted to achieved is to pass a std::map consists of string and TH2D histogram into RDataframe via a c++ function through df.Define, where std::map object is defined and declared together custom c++ function:
The cout under loadSF2D works as expected, printing the correct number of bins in x axis; meanwhile the cout under evalFlip does not work and return segfault… How should i declare my SFmap so that it is accessible by evalFlip function? I am not sure how the scope works under gInterpreter environment though.
Looking forward to hear from you.
Cheers,
Siewyan
_ROOT Version: 6.22 Platform: Not Provided Compiler: Not Provided
I think this has little to do with gInterpreter.Declare or RDataframe; the histograms are deleted when the files is closed and goes out of scope, see https://root.cern/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#ownership-by-current-directory-gdirectory .
The simplest solution is to use TFile::Open instead, and not close the file (at least as long as you need the histograms - if you need to control closing the files and deleting the TFile, you need some longer-lived object to do keep track of them), or call SetDirectory(0) on the histograms.
Thanks you very much @pieterdavid and @eguiraud for untangle the problem, and yes, by taking your advise, it is working fine now and it is running with my Rdataframe.