void plot_phires(void) { TTree *t = new TTree("t","GPU Fit Results"); // can, fit, thrown // p, theta, phi t->ReadFile("spherical_output.txt", "can_p/F:can_phi:can_theta:fit_p:fit_phi:fit_theta:thrown_p:thrown_phi:thrown_theta"); TCanvas *c1 = new TCanvas("c1"); c1->SetTicks(); TH1D *res_can = new TH1D("res_can", "", 100, -1.0, 1.0); TH1D *res_fit = (TH1D*)res_can->Clone("res_fit"); res_can->SetLineColor(kRed); res_fit->SetLineColor(kBlue); res_can->SetXTitle("Radians Error"); res_can->SetYTitle("Number of Events"); t->Project("res_fit", "(fit_phi-thrown_phi)"); t->Project("res_can", "(can_phi-thrown_phi)"); res_can->SetStats(0); res_can->Fit("gaus"); res_fit->Fit("gaus"); res_can->GetFunction("gaus")->SetLineColor(kRed); res_fit->GetFunction("gaus")->SetLineColor(kBlue); res_can->Draw(); res_fit->Draw("same"); float mean_tc = res_can->GetFunction("gaus")->GetParameter(1); float mean_tf = res_fit->GetFunction("gaus")->GetParameter(1); float sigma_tc = res_can->GetFunction("gaus")->GetParameter(2); float sigma_tf = res_fit->GetFunction("gaus")->GetParameter(2); char str_tc[256]; char str_tf[256]; char str_tc_2[256]; char str_tf_2[256]; sprintf(str_tc, "#mu_{candidate} = %3.3f radians error", mean_tc); sprintf(str_tf, "#mu_{fit} = %3.3f radians error", mean_tf); sprintf(str_tc_2, "#sigma_{candidate} = %3.3f percent resolution", sigma_tc*100); sprintf(str_tf_2, "#sigma_{fit} = %3.3f percent resolution", sigma_tf*100); TLatex *lab_tc = new TLatex(-0.05, 65, str_tc); lab_tc->SetTextSize(0.036); lab_tc->SetTextColor(kRed); lab_tc->Draw(); TLatex *lab_wb = new TLatex(-0.05, 60, str_tf); lab_wb->SetTextSize(0.036); lab_wb->SetTextColor(kBlue); lab_wb->Draw(); TLatex *lab_tc = new TLatex(-0.05, 55, str_tc_2); lab_tc->SetTextSize(0.036); lab_tc->SetTextColor(kRed); lab_tc->Draw(); TLatex *lab_wb = new TLatex(-0.05, 50, str_tf_2); lab_wb->SetTextSize(0.036); lab_wb->SetTextColor(kBlue); lab_wb->Draw(); TLegend *leg = new TLegend(0.15, 0.688, 0.38, 0.86); leg->AddEntry(res_can, "Candidate"); leg->AddEntry(res_fit, "Fit"); leg->Draw(); c1->SaveAs("plot_phires.png"); c1->SaveAs("plot_phires.pdf"); }