Home | News | Documentation | Download

RDataFrame define with string for the custom class

ROOT Version: 6.22/00
Built for linuxx8664gcc on Jun 14 2020, 15:54:05
From tags/v6-22-00@v6-22-00

Recently I am trying to use rdataframe with tree which contains custom class. And I found that I can’t use define and filter with literay string. Take tree2.root which is generated by $ROOTSYS/tutorials/tree/tree2a.C for example, the following code can’t work.

    const auto entries = ROOT::RDataFrame("t2", "/tmp/tree2.root")
        .Define("tot", "track.getot")
        .Count()
        .GetValue();

    std::cout << entries << std::endl;

The output is
Error in TTreeReaderValueBase::CreateProxy(): The branch track.getot contains data of type float. It cannot be accessed by a TTreeReaderValue

It would be a little troublesome, if the rdataframe and custom class can only be combined with lambda function.

Hi @qiutum,
thanks for your report. Things look ok for me in ROOT v6.22/02, can you confirm this is the case? If not, can you provide a full recipe to reproduce the problem on lxplus?

Cheers,
Enrico

Thanks a lot for your quick reply. I’m sorry that I’ve no access to lxplus.
So I download different releases of root directly from root website, which are 6.22.00 and 6.22.02. The platform is “CentOS 7”.

Then I test the following code with 6.22.00 and 6.22.02. The tree2.root is generated with $ROOTSYS/tutorials/tree/tree2a.C

{
        gInterpreter->ProcessLine(".L tree2a.C");
            const auto entries = ROOT::RDataFrame("t2", "tree2.root")
        .Define("tot", "track.getot")
        .Count()
        .GetValue();

    std::cout << entries << std::endl;
}

And I found that v6.22.02 works well and v6.22.00 can not work. The output of v6.22.00 is still Error in <TTreeReaderValueBase::CreateProxy()>: The branch track.getot contains data of type float. It cannot be accessed by a TTreeReaderValue<Gctrak>

Perfect, that’s a bug we fixed in 6.22/02 then (I think it’s ROOT-9674). Please do use 6.22/02, i.e. the latest patch release.

Cheers,
Enrico

1 Like

Thank you very much :grinning:

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