RDataFrame creation without giving nentries in advance

Dear Users,

I am interested in the possibility to create a RDataFrame without knowing in advance the number of entries.
So I would like to know wich is the constructor form.
Thank you in advance

ROOT Version: 6.32.00
Platform: Ubuntu 22.04
Compiler: gcc 11.4.0


Try maybe with the default constructor. RDataframe d;
And then call d.Fill(…) every time you want to add an entry

Thank you for this suggestion.
I tried with the following declaration:
ROOT::RDataFrame test;
and it yields me the following error:
error: no matching function for call to ‘ROOT::RDataFrame::RDataFrame()’

In addition, I would be interested in the process to construct/insert values in the RDataFrame created this way.
To my knowledge both Define and Foreach automatically iterate on the nentries which are supposed to be known in advance.
Thanks

Maybe try setting 0 as number of entries, and then call Fill ?

Thanks, creating RDataFrame test(0); works.
But I dont understand how to use command Fill, since it has not been created as a ttree.
Define and Foreach loop over 0 entries.

Could you provide a snippet of code?

Thank

Ohh, I see, I was wrong. The Fill method is for filling eg a histogram from the already created RDataFrame.

I am not an expert on this class, but I think RDataFrame is just an interface to a TTree or another data source (CSV file, Numpy array, etc.). You need to “fill” the Datasource (ROOT: ROOT::RDF::RDataSource Class Reference), not the RDataFrame. @vpadulan might confirm.

So I guess in your case you would need to do:

TTree t;
t.Fill(your_event1);
t.Fill(your_event2);
RDataFrame r(t.GetEntries(), …);

Thank you but the way you propose requires:

  1. the creation of a TTree
  2. the creation of a RDataFrame after
    so I create two things and the first one is just to know how much is the second.
    I hope there is a smarter way
    Thank you anyway for your time
    Bye

Hmm, according to Dataframes - ROOT

an RDataFrame is a class to analyze data stored in a TTree, or data stored in a CSV file.

It’s not a substitute of the TTree (or CSV file) itself. It’s not an “RDataSet”. It’s a tool (“a frame”) to analyze already stored data, not a tool to store (add) new data.

Maybe, what you want is this class: ROOT: ROOT 7 ntuple tutorials rather than RDataFrame