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.
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
ROOT::RDataFrame(1000)
.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;
}