Description
TDataFrame deduces he type of TTree branches at runtime using the following logic:
- if branch->InheritsFrom(tbranchelRef), then the type of the branch is branch->GetClassName()
- else we check the last character of branch->GetTitle(), expecting title to be of the form "title/X" where X is a character that designates the branch type
- else the type could not be deduced
There are some cases that are not covered by this logic:
- if the title of the branch is set explicitly by users via branch->SetTitle(), the last character will not represent the type, or worse it could sometimes correspond to a completely different type, leading to errors
- leaflists are not supported by TTreeReaderValue. I am not sure how well we deal with failures to read branches with leaflists (even leaflists of length one, where the variable name is different than the branch name)
Reproducer:
#include <ROOT/TDataFrame.hxx>
|
#include <TTree.h>
|
#include <TFile.h>
|
|
int main() { |
// create file |
{
|
TFile file("f.root", "RECREATE"); |
TTree t("t", "t"); |
float f; |
auto b = t.Branch("f", &f); |
b->SetTitle("customtitle"); |
t.Branch("dontknow", &f, "ff/F"); |
|
t.Fill();
|
t.Write();
|
}
|
|
// read and write file with TDF |
ROOT::Experimental::TDataFrame d("t", "f.root"); |
d.Snapshot("t", "out.root"); |
|
return 0; |
}
|