March 14, 2023, 3:22pm
In running this code:
std::unique_ptr<TFile> inf( TFile::Open("ifile.root"));
TTree *tcrs = inf->Get<TTree>("poker_crs");
TTree *thcal= inf->Get<TTree>("poker_hcal");
auto h1 = d.Histo1D("dene");
auto h2 = d.Histo1D("hcal.dene");
TFile *fout=new TFile("ofile.root","recreate");
I encountered this error:
TROOT::WriteTObject: The current directory (Rint) is not associated with a file. The object (dene) has not been written.
Error in TROOT::WriteTObject: The current directory (Rint) is not associated with a file. The object (hcal.dene) has not been written.
You can find the ifile.root file here:
I have noticed that If I remove line 3 “ROOT::EnableImplicitMT();” the code works.
It seems similar to what was reported in:
I have issues analyzing a tree with a friend tree using the RDF with ImplicitMT enabled. The reason seems to be that the trees are not saved in the same directory in the file. Here is a code which demonstrates the behavior:
// Setting up trees
auto f = TFile::Open("myfile.root", "RECREATE");
TNtuple* t = new TNtuple("main", "", "val");
But this problem should have been fixed for the ROOT version (6.24/06) that I use.
Do you have any advice or suggestions?
ROOT Version: 6.24/06
Platform: Linux CentOS7
Compiler: gcc (GCC) 11.2.0
Is there any reason why the quoted line is commented out? Alternatively, you should be able to replace the
Write() calls on
March 14, 2023, 4:31pm
The quoted line is commented out because I was trying to make some changes.
Even if I add it to the code I get the same error I reported.
I have tried to replace the
Write() command with
WriteObject() but I find these errors:
Please try by actually passing a
TH1D* to the function, as the error suggests:
March 15, 2023, 10:02am
@vpadulan and @jalopezg,
Thanks for your help, the code now works.