#define memorydepth 10 class MY_DATA{ public: Double_t peak; Double_t wvf[memorydepth]; Int_t selection; MY_DATA(); string tobranch = "peak/D:wvf[" + to_string(memorydepth) + "]/D:selection/I"; void setBranchName(Int_t n = memorydepth){ tobranch = "peak/D:wvf[" + to_string(n) + "]/D:selection/I"; } }; MY_DATA::MY_DATA(){ for(Int_t i = 0; iGet("t1"); TBranch *b = t1->GetBranch("data"); b->SetAddress(&data); for(Int_t i = 0; i < t1->GetEntries(); i++){ b->GetEvent(i); cout << data.peak << " "; // no problem here cout << data.selection << "\n"; // no problem here } fread->Close(); }