How to use RDataFrame::Histo2D with predefine TH2D


_ROOT Version:6.15


if I defind TH2D first
TH2D * h2 = new TH2D();
how can I use the pre defined histogram in RDataFrame?
RDataFrame d…
d.Histo2D(*h2, “x”, “y”);

Hi,

you should use a histo model (https://root.cern/doc/master/classROOT_1_1RDF_1_1RInterface.html#a1b9d25cf058ce859b97d5dab42837d30), that is

RDataFrame d…
auto myHist2d = d.Histo2D({*h2}, “x”, “y”);

note that h2 is taken as a model and a new histogram is returned wrapped in a RResultPtr.

Cheers,
D

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