How draw histo from directory

From: Tadeusz Pytlos (pytlos@fizwe5.fic.uni.lodz.pl)
Date: Tue May 26 1998 - 17:30:27 MEST


Dear Rooters,
The TBrowser is a very nice device, but I need to draw a histogram 
from directory in the formal way. I failed trying it in this way
 
....
   TFile *hfile=new TFile("prob.root");
   top->cd();
   plane6->cd();
   page = new TCanvas("page","Probability",0,0,500,700);
   page->SetFillColor(10);
   page->Divide(1,1);

   Int_t kpad,ans;
   char padname[20];

   kpad=0;
   sprintf(padname,"page_%d",kpad+1);
   TPad *pad = (TPad*)page->GetPrimitive(padname);
   pad->cd();
   pad->SetGrid();
   pad->SetLogy();
   pad->GetFrame()->SetFillColor(42);
   pad->GetFrame()->SetBorderMode(-1);
   pad->GetFrame()->SetBorderSize(5);
   pad->Draw();

   char hname[20];
   TH1 *h;

   sprintf(hname,"h%d",kpad+12);
   h=(TH1F*)hfile.Get(hname);
   h.SetLineWidth(2);
   h.SetLineStyle(1);
   h.SetLineColor(1);
   h.SetXTitle("k");
   h.SetYTitle("N");
   h.SetMinimum(1e-1);
   h.Draw();
....
}
The error was just

Processing prob1.C...
Error: illegal pointer to class object h 0x0 321
FILE:/home/pytlos/usr/kret/stat33/./prob1.C LINE:90
NULL
*** Interpreter error recovered ***

How modify my macro?
********************* 


Next thing. What wrong with f.pwd()? Example below. 

root [0] TFile *f=new TFile("prob.root")
root [1] f.ls()
TFile**         prob.root
 TFile*         prob.root
  KEY: TDirectory       top;1   top
root [2] f.pwd()
prob.root:/
root [3] .pwd
Current directory: prob.root:/
Current style:     Default
root [4] top.cd()
root [5] f.ls()
TFile**         prob.root
 TFile*         prob.root
  TDirectory*           top     top
   KEY: TDirectory      plane6;1        plane6
  KEY: TDirectory       top;1   top
root [6] f.pwd()
prob.root:/
root [7] .pwd
Current directory: prob.root:/top
Current style:     Default
root [8] plane6.cd()
root [9] f.ls()
TFile**         prob.root
 TFile*         prob.root
  TDirectory*           top     top
   TDirectory*          plane6  plane6
   ......
    KEY: TH1S   h12;1   h12
   KEY: TDirectory      plane6;1        plane6
  KEY: TDirectory       top;1   top
root [10] f.pwd()
prob.root:/
root [11] .pwd
Current directory: prob.root:/top/plane6
Current style:     Default
root [12] 



Thank in advance,
              Tadeusz

--
Tadeusz Pytlos        
mailto:pytlos@fizwe5.fic.uni.lodz.pl 
Lodz, Poland                                                 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:33 MET