Weighted histogram using RDataFrame

Hi all,

I was trying to make a weighted histogram using TTree vs RDataFrame, I followed the usual convention for TTree, tree->Draw(“x>>h(100,0,10)”,“weight*(cut)”)
vs RDataFrame auto h = df.Filter(“cut”).Histo1D({“h”,“h”,100,0,10},“x”, “weight”);

The integral of the 2 histograms are different, (dataframe value is lower). When I draw unweighted versions the numbers match.

Could someone pls point out the potential issue causing this.

Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Thanks for the post. I suspect the entries passing the two selections are different. Did you check that?
The RDF case is filtering based on the value of cut cast to a boolean.


Hi Danilo,
The cuts are identical.

Hi Nibir,

I do not understand. What is “cut” in your dataset? In the TTree::Draw snippet, are you maybe filling the histogram with a weight equal to 0 and not filling in the RDF case?


Hi Danilo, when weight = 0, it will be automatically ignored by the h->Integral function right.

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