Re: Making histogram from a ascii data file

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Fri, 8 May 2009 08:55:07 +0200


Did you check that the array ydata2 is correctly filled before filling the histogram?
Did you check that the values are in the range [0.64,1.63]?

Rene Brun

Ivan Pulido wrote:
> Hi, Im trying to make a histogram from a plain text data file. I tried
> following instructions from http://root.cern.ch/drupal/content/binned-data
>
> The histrogram I want to make is in 1D, I try to make an array from a
> plain text data file before filling the histogram as suggested in the
> site. Here are the steps/instructions Im following to make this
> happen, please let me know what is wrong. The result is just the
> canvas with no data in it, just the axis, axis tittles and no data.
>
> TH1F* ydata = new TH1F("ydata","times measured; Energy
> (q^2)",100,0.64,1.63);
> float ydata2[100];
> FILE * f = fopen ("tau_ydata.dat","r");
> int i=0;
> while(fscanf(f,"%lf",&ydata2[i]) == 1) i++;
> for (i=0; i<100; ++i) ydata->Fill(ydata2[i]);
> ydata->Draw();
>
> I must tell that the tau_ydata.dat file is read correctly and the
> array ydata2 has the correct values, so I think the problem is filling
> the histogram, since when I draw it Im getting nothing. Please help me
> on this, Im new with ROOT so maybe you can point where to find the
> solution to this or anything, maybe this is not the correct way to do
> it. Thanks for the attention.
Received on Fri May 08 2009 - 08:55:44 CEST

This archive was generated by hypermail 2.2.0 : Fri May 08 2009 - 11:50:01 CEST