Reading histograms from a Tree using TTreeReader?

Dear Root experts,

Referring to Memory leak in pyroot, where Philippe kindly provided a workaround to the function related memory leak when reading in histograms from a TTree Branch (last reply before tpoic closed). I would like to know if there is a way to use the TTreeReader mechanism to read in the histograms. I.e. I currently use it like this

  TFile *rtinput =  TFile::Open("tribic2017_idxtest.root");
  TTreeReader theReader("measurements", rtinput);
  TTreeReaderValue<Int_t> gridx(theReader, "gridXbin");
          std::cout <<  *gridx << std::endl;

How can I best read in the histograms in this setting? The corresponding code not using the TTreeReader is in the topic referenced above.

Many thanks,

ROOT Version: 6.14/06
Platform: mac osx 10.14.2
Compiler: clang-1000.11.45.5

TTreeReaderValue<TH1F> th(theReader, "shapeC3"); is not working?

Hiiā€¦ I have a data file in the .zls format. How can I change that to ROOT format?

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