Currently, I use the following script to read .root file
#include <iostream>
#include <fstream>
#include <string>
void read_tree() {
TFile* file = TFile::Open("my_file.root");
TTree* frames = (TTree*)file->Get("Frames;1/fr");
frames.Print();
Long64_t size = frames->GetEntries();
std::cout << size << std::endl;
Int_t ids = 0;
frames->SetBranchAddress("id", &ids);
for (Long64_t index=0; index < 20; ++index) {
frames->GetEntry(index);
std::cout << ids << std::endl;
}
}
Usually this works fine and i got read all the values. However, on this particular my_file.root, I get printed all 0!
The size variable above is ok, and contains correct value.
Is there are any problem with file I got, or I am missing something?