Re: [ROOT] ROOT: Drawing histo saved in a file.root

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Sep 17 2002 - 15:42:28 MEST


Hi Davide,

Replace the line:
     TH1F* ModRMS[i] =   (TH1F*)gROOT->Get(name);
by
     TH1F* ModRMS[i] =   (TH1F*)f->Get(name);

Rene Brun

On Tue, 17 Sep 2002, Davide Gerbaudo wrote:

> 
> Hi 
> I'm having some troubles opening some TH1F I saved in a file .root .
> If I try to list objects it seems that they're in gDirectory really, and
> even when I create pointers to access them it does not give any error
> message. 
> But if I try to draw them it doesn't work and it says it's an illegal
> pointer. I tought that I did it like in "A simple fitting example" but
> maybe I'm  forgetting something. 
> Thank you very much in advance
> 
>    Davide Gerbaudo
> ___________________________________________________
> {
> gROOT->Reset();
> 
> char name[50];
> int i,j,k;
> int NbApv = 4;
> 
> TH1F* ModRMS[4];
> 
> char *histosFileName;
> histosFileName = "histoNOISE_090602_150833.root";
> 
> // Open the file containing histos
> 
> TFile *f = new TFile(histosFileName, "READ");
> 
> //cout<<f.GetNkeys();     // here it seems to see objects
> //f.ls();
> //gDirectory->ls();
> 
> //(h_ModMeanPed 0)->Draw();     // but I can't access directly to them
> //TH1F *ModRMS = ((TH1F*)gROOT->FindObject("ModRMS 0"))->Draw();
> //--------------------------
> //  creating pointers to histos in the file
> //-------------------------
> for(i=0;i<4;i++)
>   {
>     sprintf(&name[i], "h_ModRMS%2d", i);
>     TH1F* ModRMS[i] =   (TH1F*)gROOT->Get(name);    
>   } 
> //ModRMS[0]->Draw();
> //  or
> ModRMS[1]->Draw();
> f.Close();
> cout<<"\n";
> }
> 
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET