Re: reading histogram contents

From: Rene Brun <brun_at_pcroot.cern.ch>
Date: Fri, 29 Apr 2005 21:26:26 +0200 (MEST)


Hi,

After the line

       TFile *f = new TFile("histos4.root"); add this line

       TH1 *haccpt = (TH1*)f->Get("haccpt");

At the normal ROOT prompt, the histogram named "haccpt" is automatically read from the current directory. This is not the case when executing a script.

Rene Brun

On Fri, 29 Apr 2005, Lalith
Perera wrote:

>
> Hi,
>
> I am running the following script to read the contents of a
> histogram from a file. But it reads them always as zeros, althogh
> histogram is not empty. I can plot it from the script, which shows the
> filled histogram. Also, When I type the commad interactively
> (ie, like:
>
> root[1] bc= (Float_t)haccpt->GetBinContent(2,0);
> root[2] std::cout << bc << endl; )
>
> it shows the actual value in that bin. Am I missing anything in the
> script?
>
> Thanks
> Lalith
>
> TFile *f = new TFile("histos4.root");
> f->ls();
>
> Int_t j=0;
> Float_t bc;
>
> for(Int_t i=0;i<80;i++)
> {
> bc= (Float_t)haccpt->GetBinContent(i,j);
> std::cout<< i<< " j " << j << " " << bc << endl;
> }
>
> haccpt2->Draw();
>
>
>
>
>
Received on Fri Apr 29 2005 - 21:26:31 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET