Read a .txt file and create a graph

Hello, I am trying to read a file with 9 columns to create an TGraphAsymmErrors.
I was using:

ifstream infile;
infile.open(“data.txt”);

but it is getting too complicated and the code wasn’t working. I want to read all 9 columns. Can someone tell me an easier way to do this?

ps.: I also want to have the values of the graph to calculate some other quantities, so it’s not useful to use:

TGraph MyGraph = new TGraph(“MyData.txt”);
MyGraph->Draw("A
");

because I need the data.

You can easily retrieve the data in a TGraph using GetX and GetY

You may also want to investigate TTree::ReadFile.

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