Converting single column text files into TH1F for fitting


I’m not very well-versed in C/C++ and I was hoping someone could point me in the right direction:

I’ve got a .dat file which contains only a column of counts, each coming from a specific channel. I intend to read this .dat file and save it as a TH1F .root file, which each row corresponding to a TH1F bin.

I have read Rene Brun’s basic.c and basic2.c, but I can’t seem to get it to work. I have also heard that TGraphs can read text files natively and am not adverse to first reading them in as TGraphs and then converting it into a TH1D (for future fitting).

Thanks in advance for any pointers!

ROOT Version: 6.09/01
Platform: Linux Mint 19.1
Compiler: Not Provided

BTW. There exists the TGraph::Fit method.

1 Like

Thanks! It worked!

And thank you for the tip about the TGraph::Fit method!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.