Hi Meta, Meta Binder wrote: > > Dear rooters, > > I create a TFile with two subdirectories: > TFile = histofile.root > TDirectory subdirectories pythia, zjet > > If I open the file in the TBrowser I can perfectly well access the > histograms but I need to to this in a macro. I attached the histofile.root > > my Macro: > > #include <TH2.h> > #include <iostream> > > TH1F *h; > > int plot(){ > > TFile *f = new TFile("histofile.root"); > > pythia->cd(); > > char hname[20]; > > sprintf(hname,"h[%d]",0); > h=(TH1F*)f->Get(hname); > Instead of: h=(TH1F*)f->Get(hname); you should call h=(TH1F*)gDirectory->Get(hname); or if you do not want to cd in the directory, you have to specify the full path h=(TH1F*)f->Get("pythia/h1"); > h->Draw(); > > } > > gives > root [0] > Processing plot.C... > Error: illegal pointer to class object h 0x0 137 FILE:plot.C LINE:27 > *** Interpreter error recovered *** > > second problem: > ----------------------------------------------------------------------- > if I do root histofile.root > > root [0] > Attaching file histofile.root... > root [1] pythia->cd() > (Bool_t)1 > root [2] gDirectory->pwd() > histofile.root:/pythia > root [3] gDirectory->cd() > (Bool_t)1 > root [4] zjet->cd() > Error: Symbol zjet is not defined in current scope Are you sure that the object is called "zjet" and not "zjet " or " zjet" ? Rene Brun > FILE:/tmp/fileihS306_cint LINE:1 > Error: Failed to evaluate zjet->cd()Possible candidates are... > filename line:size busy function type and name > *** Interpreter error recovered *** > > But it is there. I can see it in the TBrowser. > > What do I do wrong? > > Thank you so much. > Meta > > -- > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > "Thank you" means you don't have to, but I'm glad you did! > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Meta Binder FNAL, M.S. 357 > LMU Muenchen Meta Binder > Sektion Physik P.O. Box 500 > Am Coulombwall 1 Batavia, IL 60510 > 85748 Garching > > ph: +49 89 289- 14149 ph: +1 630 840 3696 > fax: +1 630 840 6650
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET