Draw histogram using Histo1D from Float16_t branches

Dear Expert,

I met this problem about a root file with Float16_t branches. If print the tree, the result will like the following:

root [1] Events->Print()
******************************************************************************
*Tree    :Events    : Events                                                 *
*Entries :  1975041 : Total =       477109888 bytes  File  Size =  335974760 *
*        :          : Tree compression factor =   1.42                       *
******************************************************************************
*Br    0 :weight    : weight/f                                               *
*Entries :  1975041 : Total  Size=    5987177 bytes  File Size  =      94456 *
*Baskets :      650 : Basket Size=      32000 bytes  Compression=  63.25     *
*............................................................................*
*Br    1 :dsid      : dsid/i                                                 *
*Entries :  1975041 : Total  Size=    7970959 bytes  File Size  =     116900 *
*Baskets :      758 : Basket Size=      32000 bytes  Compression=  68.05     *
*............................................................................*
...
*............................................................................*
*Br   48 :deta_2mu2bj : deta_2mu2bj/f                                        *
*Entries :  1975041 : Total  Size=    5990442 bytes  File Size  =    4741822 *
*Baskets :      650 : Basket Size=      32000 bytes  Compression=   1.26     *
*............................................................................*
...

But if open this file with RDataFrame and try to generate a histogram, the error occurs.

rdf = R.RDataFrame('Events',file)
hi = rdf.Histo1D('deta_2mu2bj','weight')
c = R.TCanvas()
hi.Draw()
c.SaveAs('test.png')
Error in <TTreeReaderValueBase::CreateProxy()>: The branch deta_2mu2bj contains data of type Float16_t, which does not have a dictionary.

I wonder if there’s anything wrong with the configuration or some other problems exist.

Thanks for your help!
Licheng
_ROOT Version:ROOT 6.24/02

I think @eguiraud can help you.

Thanks!
And I found there’s a similar question not closed about http://root-forum.cern.ch/t/float16-t-in-ttreereadervalue/39826 from @Roberto_RIBATTI. And this two topic can share the same answer.

Hi @Licheng_ZHANG ,
and welcome to the ROOT forum!

It looks like TTreeReader, that RDataFrame uses internally to read your data, still does not support Float16_t. Here is a self-contained reproducer that only depends on TTreeReader:

#include <TFile.h>
#include <TTreeReader.h>

int main() {
  {
    TFile f("f16.root", "recreate");
    TTree t("t", "t");
    float x = 42.f;
    t.Branch("x", &x, "x/f");
    t.Fill();
    t.Write();
  }

  {
    TFile f("f16.root");
    TTreeReader r("t", &f);
    TTreeReaderValue<Float16_t> rv(r, "x");
    r.Next();
  }
}

@Axel @pcanal is this expected to work?

Cheers,
Enrico

Yes it should work (i.e. it should be supported). There seems to be a test for this (or similar?) in tree/treeplayer/test/leafs.cxx

It does not work, see script above :smiley:

EDIT: this is now [TTreeReader] Cannot read Float16_t branch · Issue #10645 · root-project/root · GitHub

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