RDataFrame not able to read branches containing array whose size is of type Short_t

Dear ROOT community,

For repetitive plotting of many branches of a tree, I have been trying to shift my old (very lengthy) code using SetBranchAddress &Cie to the RDataFrame paradigms.
It seems very practical at first, but I met a problem that I could not solve, and ended up going back to the good old lengthy code.
The problem is that the variables that contain arrays of length “Reco_mu_size” cannot be read by the columnar analysis (TTreeReader) if the variable “Reco_mu_size” of the tree is of type Short_t.
So the simple histograming script attached works for variable “Centrality” (which is not an array), but not for variable “Reco_mu_nTrkHits” for example (on the attached .root file). It gives the error:

Error in <TTreeReaderValueBase::CreateProxy()>: The branch Reco_mu_size contains data of type short. It cannot be accessed by a TTreeReaderValue<int> terminate called after throwing an instance of 'std::runtime_error' what(): An error was encountered while processing the data. TTreeReader status code is: 6

I run with ROOT v6.22.02.

This seems like a rather simple functionality to implement, will it be done soon?

P.S: For now I don’t manage to attach my file… But here is the script MWE:

using namespace ROOT;
void test(){
  auto fnAOD = "Oniatree_AOD.root";
  ROOT::RDataFrame d("hionia/myTree", fnAOD);                                                                                                                                               
  auto test2 = d.Histo1D({"","",100,0,100},"Reco_mu_nTrkHits");

  TCanvas *c2 = new TCanvas("c2","c2",1500,1500);

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

@eguiraud could you take a look please?

Hi @gfal,
ouch, I’m sorry for the misadventure!
Reading shorts works in general (see example program attached). The problem seems to be a bug in the type inference performed by RDF: it thinks Reco_mu_nTrkHits is an int but it is a short!

I fixed a similar bug in 6.22/02, could you check whether it’s fixed in the ROOT nightly builds?

Meanwhile, you can probably work around the problem by writing Histo1D<short>(...) instead of Histo1D(...), so that RDF does not have to infer the column type from the dataset.

Let us know if this resolves the issue!

repro.cpp (557 Bytes)

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