// Reads the points from a file and produces a simple graph. int read_graph_txt_MC_data(){ auto c=new TCanvas(); c->SetGridy(); // Read MC from txt file TGraphErrors /////////////////////////////// Whole ECL /////////////////////////// TGraphErrors graph1("./MC.txt","%lg %lg %lg %lg"); // * means not select this column of data graph1.SetTitle("MC;" "#gamma Energy (GeV);" "#sigma of pi0_M_Prefit"); // "#mu of pi0_M_Prefit"); graph1.SetLineWidth(2); graph1.SetLineColor(4); graph1.SetMarkerStyle(20); graph1.SetMarkerColor(kBlue); // graph2.SetDrawOption("P"); // graph1.GetXaxis()->SetRangeUser(0, 2.5); // graph1.GetYaxis()->SetRangeUser(0.13, 0.14); graph1.GetXaxis()->CenterTitle(); graph1.GetYaxis()->CenterTitle(); graph1.GetXaxis()->SetTitleSize(0.05); graph1.GetYaxis()->SetTitleSize(0.05); // graph2.DrawClone("AP"); // Print the data pount graph1.Print(); cout<< "================================================"<< endl; // Read data from txt file TGraphErrors /////////////////////////////// Whole ECL /////////////////////////// TGraphErrors graph2("./data.txt","%lg %lg %lg %lg"); // * means not select this column of data graph2.SetTitle("Data;" "#gamma Energy (GeV);" // "#mu of pi0_M_Prefit"); "#sigma of pi0_M_Prefit"); graph2.SetLineWidth(2); graph2.SetLineColor(2); graph2.SetMarkerStyle(20); graph2.SetMarkerColor(kRed); // graph1.SetDrawOption("P"); // graph2.GetXaxis()->SetRangeUser(0, 2.5); // graph2.GetYaxis()->SetRangeUser(0.13, 0.14); graph2.GetXaxis()->CenterTitle(); graph2.GetYaxis()->CenterTitle(); graph2.GetXaxis()->SetTitleSize(0.05); graph2.GetYaxis()->SetTitleSize(0.05); // graph1.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.GetXaxis()->SetTitle("#gamma Energy (GeV)"); mg.GetYaxis()->SetTitle("#mu (GeV/c^{2})"); // mg.GetYaxis()->SetTitle("#sigma (GeV/c^{2})"); mg.GetXaxis()->CenterTitle(); mg.GetYaxis()->CenterTitle(); // mg.GetXaxis()->SetRangeUser(0, 2.5); mg.GetHistogram()->GetXaxis()->SetLimits(0.,1.5); mg.GetYaxis()->SetRangeUser(0.13, 0.14); //mean // mg.GetYaxis()->SetRangeUser(0, 0.009); //sigma mg.GetXaxis()->SetTitleSize(0.05); mg.GetYaxis()->SetTitleSize(0.05); mg.GetXaxis()->SetLabelSize(0.05); mg.GetYaxis()->SetLabelSize(0.05); mg.GetYaxis()->SetNdivisions(5); mg.DrawClone("AP"); c->Update(); c->GetFrame()->SetBorderSize(12); c->Modified(); // c->SetLogy(); // c->SetLogx(); c->BuildLegend(); return 0; }