Creating TH1Fs using RDataFrame

I am trying to see if I can replace some code that creates a number of TF1s using RDataFrame in order to take advantage of the lazy execution and parallelism, but it seems like only TH1Ds can be easily created (i.e., double precision instead of single precision). Is that true? This is my first attempt to use RDataFrame.

Hi jmitrevs,
I think you mean TH1F, TF1 is a function object.
It’s true that RDF only has dedicated methods that create TH*D, but it also has a generic Fill method that you can use to fill your own TH1F's.

You can see an example usage in our tutorials, specifically df005_fillAnyObject.C.

Cheers,
Enrico

Hi Enrico,

Thanks. I did mean TH1F, of course. I noticed there is no df005_fillAnyObject.py. Can one use the Fill method in PyROOT?

Jovan

Hi,
currently not, because the C++ method takes a forwarding reference and those type of function arguments are not supported by pyROOT.
It should become available in the future.

By the way, if I may ask, why is a TH1D not ok for your usecase?

Cheers,
Enrico

Hi,

I probably will try that. I was wanting not to change the output format from what is now used so that the changes would be self-contained. I am not sure if the parts reading the root file expect to read TH1Fs or if TH1Ds are also fine. The trees used to fill the histograms are all with floats.

Jovan

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.