Is there a way to automatically add/define any missing columns in RDataFrame? We’re analyzing data with different detectors/columns in the input tree for different runs and would like to be able to use one single helper to analyze all of it instead of having to write multiple variants of it for the different combinations of columns present in the input tree.
In TProof we’ve been using something like
if(tree->SetBranchAddress("TMyClass", &myClass) == Three::kMissingBranch) {
myClass = new TMyClass;
}
for every detector/column used in the selector. That way if a detector was not present in the input tree, a new, empty detector would be used (which means no histograms involving this detector were filled).
I’m not sure how to do this for helpers used in RDataFrame. I can try and book the helper and catch the exception to determine which columns might be missing, but I don’t know how to create a new column with an empty detector-object. Using Class::GetClass("TMyClass")->New()
in a lambda to define a new column does not work as this creates a void pointer (which can’t be dereferenced) instead of an object. Nor can I use something like []() { return *static_cast<TMyBase>(TClass::GetClass("TMyClass")->New()); })
to define a new column as I then get a mismatch between it being used as TMyClass
but advertised by the Define call as TMyBase
.
Is there a way to do this in RDataFrame?