Hello,
I have a question about Fill method, when using custom classes in RDataFrame.
Lets say I have RDataFrame with columns jet_pt, jet_eta and jet_phi columns, and create a column with the following class:
struct Jet{ double pt,eta,phi;};
auto newDF = inputDF
.Define("new_jet", [](float pt, float eta, float phi){Jet j;j.pt = pt; j.eta = eta; j.phi = phi; return j;}, {"jet_pt", "jet_eta", "jet_phi"})
now, I would like to fill 2D histogram with this class.:
newDF.Fill(Boo(), {"new_jet"});
where Boo() will inherit from TH2D and will have customized Fill method:
void Fill(Jet j) { hh->Fill(j.pt, j.phi); }
I am able to create this custom Fill method where I can pass it like two double values (found a solution here), but when I try to pass it a custom class, I get error about some Exec() function unable to convert Jet to double.
I know I can extract the class variables before the Fill like this:
newDF
.Define("new_jet_pt", [](Jet j({return jet.pt'}), "new_jet")
.Define("new_jet_phi", [](Jet j({return jet.phi'}), "new_jet");
with custom Fill:
.Fill(double pt, double phi) { hh->Fill(pt, phi); }
but that would make Jet class obsolete (I want this for a much more complicated class)
Thank you
Martin
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided