Root retruns all zeroes, when iterating through branch

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");

    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) {
        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?


TTree* frames; file->GetObject("Frames",frames);

i.e. do not request a specific cycle.


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