This problem seems quite simple. You have a typing error: Replace; TH1F *ZEST_LAST_HISTS[hidx] = (TH1F *) gROOT -> FindOBject(hname); by TH1F *ZEST_LAST_HISTS[hidx] = (TH1F *) gROOT -> FindObject(hname); I would also recomment you use gDirectory->Get instead of gROOT->FindObject It will be more efficient. Rene Brun lijowski@cosray2.wustl.edu wrote: > > Hello, > > I have a multiple histograms spread over three subdirectories > in the root file. I have a following test program to read > each histogram from one subdirectory inside the loops but with > no luck except at the beginning when I read a single histogram. > > I appreciate any help. > > Michal Lijowski > > // Tests reading array of histograms from the *.root file > > { > gROOT -> Reset(); > > TFile *cfile = > (TFile*)gROOT->GetListOfFiles()->FindObject("charge_hists.root.6"); > if (!cfile) { > cfile = new TFile("charge_hists.root.6", "READ"); > } > > // cfile -> ls(); > > cfile -> cd("charge_hists.root.6:/TOP/ZEST_LAST_HISTS"); > cfile -> pwd(); > > TH1F *h1 = (TH1F *) gROOT -> FindObject("ZEST_LAST"); > h1 -> Draw(); > > Int_t N_TEL = 4; > char ctel[2], hname[30]; > > Int_t N_STACK_DET = 9; > Int_t Range_min = 2; > Int_t nhists = (N_STACK_DET - Range_min + 1) * N_TEL + 1; > printf(" nhists = %d\n", nhists); > > TH1F *ZEST_LAST_hists[nhists]; > > Int_t hidx = 0; > > for (Int_t itel = 0; itel < N_TEL; itel++) { > ctel[0] = '\0'; > if (itel == 0) strcat(ctel, "A"); > if (itel == 1) strcat(ctel, "B"); > if (itel == 2) strcat(ctel, "C"); > if (itel == 3) strcat(ctel, "D"); > for (Int_t rr = Range_min; rr < N_STACK_DET; rr++) { > hname[0] = '\0'; > sprintf(hname, "ZEST_LAST_%s_Range_%1d", ctel, rr); > TH1F *ZEST_LAST_HISTS[hidx] = (TH1F *) gROOT -> FindOBject(hname); > // ZEST_LAST_HISTS[hidx] -> (TH1F *) cfile -> Get(hname); > ZEST_LAST_HISTS[hidx] -> Draw(); > hidx++; > } > } > } > > This is a log file. > > ******************************************* > * * > * W E L C O M E to R O O T * > * * > * Version 2.00/11 28 August 1998 * > * * > * You are welcome to visit our Web site * > * http://root.cern.ch * > * * > ******************************************* > > CINT/ROOT C/C++ Interpreter version 5.13.69, Aug 22 1998 > Type ? for help. Commands must be C++ statements. > Enclose multiple statements between { }. > charge_hists.root.6:/ > Warning in <MakeDefCanvas>: creating a default canvas with name c1 > Error: Can't call TROOT::FindOBject() in current scope FILE:/export/home/lijowski/ace/cris/flight/root/./test_TDirectory.C LINE:42 > nhists = 33 > ZEST_LAST_A_Range_2 > *** Interpreter error recovered ***
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:37 MET