TTreeReader with long long variables

Hi everybody,

I am currently working with a tree containing a leaf of the type unsigned long long.

The error:

Error in <TTreeReaderArrayBase::GetBranchAndLeaf()>: Leaf of type ULong64_t cannot be read by TTreeReaderValue<unsigned long long>.

The issue:

My code:

TFile * ifile = TFile::Open( ifilename.c_str() , "read" );
TTreeReader aReader( "Tree1", ifile );
TTreeReaderArray <unsigned long long> Time(aReader, "Time.det_times");

ROOT Version: 6.24/00
Platform: macOS BigSur, 11.6.2
Compiler: Clang 12.0.5 arm64-apple-darwin20.6.0

Thanks in advance for your help.
Jose A.

Attach your ROOT file for inspection.

Thanks for your reply.

I attach a reduced version of my file, it has a tree called Tree1 with two leafs. Energy.det_e and Time.det_times, both are arrays, int and unsigned long long respectively. For the time leaf I face the problem described above.

output.root (5.8 KB)

Best regards.
Jose A.

@eguiraud I also get this problem on my Linux, even when I try: TTreeReaderArray<ULong64_t>
Note: the problem appears first when one tries: aReader.Next();

BTW. The old ROOT-8952 issue is unrelated to your problem.

Ok, thanks for the fast reply. I will try with other OS or other compiler.
What Linux are you using?

BTW. why?

Hi @Bayes27 ,
it looks like a bug with the specific combination of ULong64_t, TTreeReaderArray and branch with leafname different from the branch name. Things should work e.g. if instead of Time.det_times you make it so that the leaf name and branch name are the same:

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

int main() {
    TFile f("f.root", "recreate");
    TTree t("t", "t");
    ULong64_t x[3] = {1ull, 2ull, 3ull};
    t.Branch("x", &x, "x[3]/l");

  TFile f("f.root");
  TTreeReader r("t", &f);
  // this works!
  TTreeReaderArray<ULong64_t> x(r, "x");
  // this doesn't, although it should:
  // TTreeReaderArray<ULong64_t> x(r, "x.x");


  return 0;

I reported the problem at TTreeReaderArray can't read leafs of ULong64_t type (but branches are fine) · Issue #9758 · root-project/root · GitHub .

Thank you @Wile_E_Coyote for taking a look.

the jira ticket you mention is indeed unrelated, as it has to do with variable sized arrays and leaf counters (i.e. leafs that store the size of the array) of type unsigned long long. Here your array has fixed size and there is no counter.

Thank you very much for your work @eguiraud.

Hope it will be solved in the near future.

Best regards.
Jose A.

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