Problem to get cut from root file

I draw several cuts and I save them into root file. My problem is that I do not know how to get them in subroutine.
This is a part of my subroutine

... sprintf(fname,"file.root"); TFile *f = new TFile(fname); if(f->IsZombie()) cout << "Could not open the cur file " << fname << "!" << endl; else { char q_name[3]; for(int=26 ; q<=46 ; q++) { sprintf(q_name,"q%d",q); cut_q[q-26] = (TCutG*)gROOT->GetListOfSpecials()->FindObject(q_name); } } ...
Problem is the line “cut_q[q-26] = (TCutG*)gROOT->GetListOfSpecials()->FindObject(q_name);”. If I write before this line “gROOT->GetListOfSpecials()->ls()”, result is

and that’s all.
I tried also “cut_q[q-26] = (TCutG*)f->GetListOfSpecials()->FindObject(q_name);” but I have an error during compilation.


You need to retrieve the object from the file before they are available anywhere else (i.e. no object except for TDirectory is extracted from the file until explicitly requested). So try: for(int=26 ; q<=46 ; q++) { sprintf(q_name,"q%d",q); f->GetObject(q_name,cut_q[q-26]); }