Dear ROOTers,
I am trying the RDataFrame with a complex TTree filled with custom objects (deriving from TObject), à la Event example class.
The objects have been split - or at least this is my hypothesis, I have not done this data file - in elementary and array branches. This is an extract of tree->Print()
:
*............................................................................*
*Br 51 :noise_pulses_in[260] : Short_t *
*Entries : 5 : Total Size= 3260 bytes File Size = 213 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 12.75 *
*............................................................................*
*Br 52 :peaks : Int_t peaks_ *
*Entries : 5 : Total Size= 29788 bytes File Size = 121 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 53 :peaks.fUniqueID : UInt_t fUniqueID[peaks_] *
*Entries : 5 : Total Size= 4524 bytes File Size = 146 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 26.84 *
*............................................................................*
*Br 54 :peaks.fBits : UInt_t fBits[peaks_] *
*Entries : 5 : Total Size= 4504 bytes File Size = 148 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 26.45 *
*............................................................................*
*Br 55 :peaks.area : Float_t area[peaks_] *
*Entries : 5 : Total Size= 4499 bytes File Size = 3914 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
RDataFrame
can make plots with Histo1D
of the array variable peaks.area
:
gSystem->Load("event_classes.so") // see comments later
ROOT::RDataFrame d5("tree5", "only5events.root");
auto h1 = d5.Histo1D("peaks.area"); h1->Draw(); // works
However using the Define
and Foreach
features does not work:
d5.Foreach( [](std::vector<Float_t> areas) { if (areas.size()) std::cout << areas[0] << std::endl; } , {"peaks.area"} )
Error in <TTreeReaderValueBase::GetBranchDataType()>: Must use TTreeReaderArray to access a member of an object that is stored in a collection.
Error in <TTreeReaderValueBase::CreateProxy()>: The branch peaks.area contains data of type {UNDETERMINED TYPE}, which does not have a dictionary.
Please note in the first snippet that I have also loaded the dictionary of the class (I got the piece of code defining the classes and I have compiled it with gSystem->CompileMacro
), but I get the same error message as when I do not load the dictionary.
Am I doing some wrong?
Thanks,
Matteo
ROOT Version: 6.14/02
Platform: Debian 9
Compiler: gcc 6.3.0-18+deb9u1