// Reads the points from a file and produces a simple graph. int read_graph_txt(){ auto c=new TCanvas(); //c->SetGrid(); // Read data from txt file TGraphErrors TGraphErrors graph1("./mean_variation.txt","%lg %lg %lg %lg"); // * means not select this column of data graph1.SetTitle("Mean Variation_data;" "#gamma Energy (GeV);" "#mu of pi0_M_Prefit"); graph1.SetLineWidth(2); graph1.SetLineColor(4); graph1.SetMarkerStyle(20); graph1.SetMarkerColor(kBlue); graph1.SetDrawOption("P"); // graph.GetXaxis()->SetRangeUser(0.0, 0.015); // graph.GetYaxis()->SetRangeUser(0.12, 0.15); graph1.GetXaxis()->CenterTitle(); graph1.GetYaxis()->CenterTitle(); graph1.GetXaxis()->SetTitleSize(0.04); graph1.GetYaxis()->SetTitleSize(0.04); // graph1.DrawClone("AP"); // Print the data pount graph1.Print(); cout<< "================================================"<< endl; // Read MC from txt file TGraphErrors TGraphErrors graph2("./mean_variation_new_single_gauss.txt","%lg %lg %lg %lg"); // * means not select this column of data graph2.SetTitle("Mean Variation_MC;" "#gamma Energy (GeV);" "#mu of pi0_M_Prefit"); graph2.SetLineWidth(2); graph2.SetLineColor(4); graph2.SetMarkerStyle(20); graph2.SetMarkerColor(kRed); // graph2.SetDrawOption("P"); // graph.GetXaxis()->SetRangeUser(0.0, 0.015); // graph.GetYaxis()->SetRangeUser(0.12, 0.15); graph2.GetXaxis()->CenterTitle(); graph2.GetYaxis()->CenterTitle(); graph2.GetXaxis()->SetTitleSize(0.04); graph2.GetYaxis()->SetTitleSize(0.04); // graph2.DrawClone("AP"); // Print the data pount graph2.Print(); cout<< "================================================"<< endl; // MultiGraph // TMultiGraph *mg = new TMultiGraph(); TMultiGraph (mg); mg.Add(graph1); //, "L" mg.Add(graph2); mg.Draw("APL"); c->Update(); c->GetFrame()->SetBorderSize(12); c->Modified(); // c->SetLogy(); // c->SetLogx(); return 0; }