Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
None
-
None
-
None
-
all
Description
It can happen that the size of C arrays stored in branches varies a lot from event to event. It can happen also that a very small array becomes suddently very big. This triggers a reallocation of the buffer ROOT uses internally to hold the read content.
When snapshotting, RDataFrame, sets the addresses of the output tree only once at the 1st event processed (per slot). This of course can lead to the persistification of corrupted values.
|
int gen()
|
{
|
TFile f("genFile.root", "RECREATE");
|
TTree t("t", "t");
|
const auto maxSize = 12;
|
int s;
|
float arr[maxSize];
|
t.Branch("nelements", &s, "nelements/I");
|
t.Branch("arr", arr, "arr[nelements]/F");
|
for (auto i : ROOT::TSeqI(maxSize))
|
{
|
s = i;
|
for (int j = 0; j < i; ++j)
|
arr[j] = j * j;
|
t.Fill();
|
}
|
t.Write();
|
f.Close();
|
return 0;
|
}
|
void read(const char *filename)
|
{
|
ROOT::RDataFrame r("t", filename);
|
auto marr = r.Max("arr");
|
std::cout << "Max of arr is " << *marr << endl;
|
}
|
void snapshot()
|
{
|
ROOT::RDataFrame r("t", "genFile.root");
|
r.Snapshot<int, ROOT::RVec<float>>("t", "genFile2.root", \{"nelements", "arr"});
|
}
|
void genFile()
|
{
|
gen();
|
read("genFile.root");
|
snapshot();
|
read("genFile2.root");
|
}
|
|