Skip to content

[DF] Fill method does not support arbitrary signatures #9428

@eguiraud

Description

@eguiraud

According to the documentation of RDataFrame's Fill method, the following should be supported:

#include <ROOT/RDataFrame.hxx>
#include <TApplication.h>
#include <TH2D.h>

struct Jet {
  double a, b;
};

struct Boo {
  TH2D h{"", "", 10, 0, 10, 10, 0, 10};

  void Fill(const Jet &j) { h.Fill(j.a, j.b); }

  void Merge(const std::vector<Boo *> &others) {
    TList l;
    for (auto *o : others) {
      l.Add(&o->h);
      h.Merge(&l);
    }
  }

  void Draw() { h.Draw(); }
};

int main() {
  TApplication app("app", nullptr, nullptr);

  auto res = ROOT::RDataFrame(10)
               .Define("Jet", [] { return Jet{1., 2.}; })
               .Fill<Jet>(Boo{}, {"Jet"});
  res->Draw();

  app.Run();
}

Instead, FillParHelper only supports Boo::Fill signatures that take combinations of doubles and collections thereof.

#7499 goes in the right direction in generalizing FillParHelper::Exec but it still needs a fix to allow this general case.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions