RootDataFrame Histo1D not filled in properly

I need to do a Histo1D of the values within a vector branch (pT for example).

The histogram should contain values of all the events. However, the histogram seem to be filled with the number of events, not values within the events.

For example. If I have 10 events (vectors) and 5 values within each vector (particles), Histo1D().Integral() will show 10 instead of 50.

How can I fill the histogram properly ?

Kind regards

Please read tips for efficient and successful posting and posting code

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

Hi @imanol097 ,
Histo1D("vector_of_pts") should do what you expect. Maybe note that Integral ignores underflow and overflow bins, if I remember correctly.

Self-contained demo (feel free to modify it so that it reproduces your issue unless you can provide a different self-contained reproducer):

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>
#include <iostream>

int main() {
  // write 1000 vectors of floats to a TTree
      .Define("vector_of_pts", [] { return ROOT::RVec<float>{1.f, 2.f, 3.f}; })
      .Snapshot("t", "myfile.root");

  // fill a single histogram with all entries
  auto h = ROOT::RDataFrame("t", "myfile.root").Histo1D("vector_of_pts");
  std::cout << h->GetEntries() << " " << h->Integral() << std::endl;


Dear @eguiraud, thanks for your quick response.

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