I used TGraphErrors class to plot, when the data points are much larger like in the file upload, the task would be killed, so how many data points can TGraphErrors class use to plot? Silicon.txt (127.2 KB)
Your data file has just 3815 data lines so no problem for a TGraph.
Note, however, that ROOT will not be able to read your data file directly. You need to write a “parser” for this kind of input data (or you need to edit this file and remove everything except data points).
Sorry i made a mistake at describing the problem, i wrote a “parser” to read the data in file “Silicon.txt”,
the .cpp file is upload, i add data to TGraphErrors class object through the AddPoint() function, in the process of running the application, the task would be killed.
So as Wile said, you still need to write a proper parser to read the data file, or (proably easier for you) edit it and leave in it only the 2 columns of data, nothing else, so that it can be read by your macro.
void Plot_CS()
{
auto c1 = new TCanvas("c1","Cross Section Plot",1200,1200);
c1->SetLogx();
c1->SetLogy();
auto gr = new TGraph();
ifstream silicon("Silicon.txt");
std::string line;
// Skip the first 12 lines
for (int i=1;i<=12;i++) getline(silicon,line);
double x,y;
while (getline(silicon,line)) {
sscanf(line.c_str(),"%lg %lg",&x,&y);
if (line.find("/") < 32) continue;
gr->AddPoint(x,y);
}
gr->Draw("AL");
}