Details
-
Bug
-
Status: Closed (View Workflow)
-
High
-
Resolution: Fixed
-
6.11/02
-
None
-
any
Description
Reproducer:
#include <ROOT/TDataFrame.hxx>
|
using namespace ROOT::Experimental; |
|
void writeHistNoInputFile() |
{
|
std::cout << "write hist no input file" << std::endl; |
ROOT::EnableImplicitMT();
|
TDataFrame d(10);
|
auto counter = 0;
|
auto dd = d.Define("x", [&counter]() { return counter++; }); |
auto h = dd.Histo1D("x"); |
|
TFile f("f1.root", "RECREATE"); |
h->SetDirectory(&f);
|
h->Write();
|
}
|
|
void makeDataSet() |
{
|
std::cout << "make dataset" << std::endl; |
TDataFrame d(10);
|
auto counter = 0;
|
auto dd = d.Define("x", [&counter]() { return counter++; }); |
dd.Snapshot<int>("t", "f.root", {"x"}); |
}
|
|
void writeHistWithInputFile() |
{
|
std::cout << "write hist with input file" << std::endl; |
TDataFrame d("t", "f.root"); |
auto h = d.Histo1D("x"); |
|
TFile f("f2.root", "RECREATE"); |
h->SetDirectory(&f);
|
h->Write();
|
}
|
|
int main() |
{
|
writeHistNoInputFile();
|
makeDataSet();
|
writeHistWithInputFile();
|
return 0; |
}
|
The output ROOT file f2.root is empty instead of containing a TDF result histogram.
An error is printed on the console:
write hist no input file
|
make dataset
|
write hist with input file
|
Error in <TROOT::WriteTObject>: The current directory (root) is not associated with a file. The object () has not been written.
|