{
 
  gROOT->ProcessLine(".x lhcbStyle.C");

  TCanvas c1_mg1_e1;

  TGraphErrors * ge1_p1 = new TGraphErrors("inlistE255_p_bpm1_diff.txt","%lg %lg %lg");
  TGraphErrors * ge1_p2 = new TGraphErrors("inlistE21_p_bpm1_diff.txt","%lg %lg %lg");
  TGraphErrors * ge1_ic1 = new TGraphErrors("inlistE255_p_ic1_diff.txt","%lg %lg %lg");
  TGraphErrors * ge1_ic2 = new TGraphErrors("inlistE21_p_ic1_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e1 = new TMultiGraph();
  mg_e1->Add(ge1_p1,"pc");  ge1_p1->SetMarkerStyle(20);ge1_p1->SetLineStyle(3);
  mg_e1->Add(ge1_p2,"pc"); ge1_p2->SetMarkerStyle(24);ge1_p2->SetLineStyle(3);
   mg_e1->Add(ge1_ic1,"p"); ge1_ic1->SetMarkerStyle(29);
   mg_e1->Add(ge1_ic2,"p"); ge1_ic2->SetMarkerStyle(30);
  mg_e1->Draw("a");
  mg_e1->SetTitle(" ");
  mg_e1->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
  mg_e1->GetYaxis()->SetTitle("#sqrt{2}#upoint #sigma(A_{1}-A_{2}) / (A_{1}+A_{2})");
  //  mg_e1->GetXaxis()->SetRangeUser(0,600);
  //mg_e1->GetYaxis()->SetRangeUser(0,1);
  mg_e1->SetMinimum(0.);
  mg_e1->SetMaximum(0.18);


  
  TLegend *mylegend = new TLegend(0.60,0.6,0.9,0.9);
  mylegend->SetFillColor(0); // white background
  mylegend->SetTextFont(22);
  mylegend->SetBorderSize(0); // get rid of the box
  mylegend->SetTextSize(0.045); // set text size
  mylegend->AddEntry(ge1_p1,"BPM (221 MeV)","pl"); // options: p,l,f
  mylegend->AddEntry(ge1_p2,"BPM (70 MeV)","pl"); // options: p,l,f
  mylegend->AddEntry(ge1_ic1,"IC (221 MeV)","p"); // options: p,l,f
  mylegend->AddEntry(ge1_ic2,"IC (70 MeV)","p"); // options: p,l,f
  mylegend->Draw();
  gPad->Modified();
  c1_mg1_e1.SaveAs("figs/inlist_p_bpm_diff.pdf");
  c1_mg1_e1.SaveAs("figs/inlist_p_bpm_diff.png");
  c1_mg1_e1.SaveAs("figs/inlist_p_bpm_diff.C");

 TCanvas c1_mg1_e2;

  TGraphErrors * ge2_p1 = new TGraphErrors("inlistE255_c_bpm1_diff.txt","%lg %lg %lg");
  TGraphErrors * ge2_p2 = new TGraphErrors("inlistE21_c_bpm1_diff.txt","%lg %lg %lg");
  TGraphErrors * ge2_ic1 = new TGraphErrors("inlistE255_c_ic1_diff.txt","%lg %lg %lg");
  TGraphErrors * ge2_ic2 = new TGraphErrors("inlistE21_c_ic1_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e2 = new TMultiGraph();
  mg_e2->Add(ge2_p1,"pc");  ge2_p1->SetMarkerStyle(22);ge2_p1->SetLineStyle(3);
  mg_e2->Add(ge2_p2,"pc"); ge2_p2->SetMarkerStyle(26);ge2_p2->SetLineStyle(3);
   mg_e2->Add(ge2_ic1,"p"); ge2_ic1->SetMarkerStyle(29);
   mg_e2->Add(ge2_ic2,"p"); ge2_ic2->SetMarkerStyle(30);
  mg_e2->Draw("a");
  mg_e2->SetTitle(" ");
  mg_e2->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
  mg_e2->GetYaxis()->SetTitle("#sqrt{2}#upoint #sigma(A_{1}-A_{2}) / (A_{1}+A_{2})");
  //  mg_e2->GetXaxis()->SetRangeUser(0,600);
  //mg_e2->GetYaxis()->SetRangeUser(0,1);
  mg_e2->SetMinimum(0.);
  mg_e2->SetMaximum(0.1);
 TLegend * mylegend2 = new TLegend(0.60,0.6,0.9,0.9);
  mylegend2->SetFillColor(0); // white background
  mylegend2->SetTextFont(22);
  mylegend2->SetBorderSize(0); // get rid of the box
  mylegend2->SetTextSize(0.045); // set text size
  mylegend2->AddEntry(ge2_p1,"BPM (430 MeV/u)","pl"); // options: p,l,f
  mylegend2->AddEntry(ge2_p2,"BPM (130 MeV/u)","pl"); // options: p,l,f
  mylegend2->AddEntry(ge2_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  mylegend2->AddEntry(ge2_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegend2->Draw();
  gPad->Modified();
  c1_mg1_e2.SaveAs("figs/inlist_c_bpm_diff.pdf");
  c1_mg1_e2.SaveAs("figs/inlist_c_bpm_diff.png");
  c1_mg1_e2.SaveAs("figs/inlist_c_bpm_diff.C");



  ///////////////////////////////////////////////
 TCanvas c1_mg1_e3;

  TGraphErrors * ge3_p1 = new TGraphErrors("inlistE255_p_posfit_diff.txt","%lg %lg %lg");
  TGraphErrors * ge3_p2 = new TGraphErrors("inlistE21_p_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge3_c1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge3_c2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e3 = new TMultiGraph();
  mg_e3->Add(ge3_p1,"pc");  ge3_p1->SetMarkerStyle(20);ge3_p1->SetLineStyle(3);
  mg_e3->Add(ge3_p2,"pc"); ge3_p2->SetMarkerStyle(24);ge3_p2->SetLineStyle(3);
  //  mg_e3->Add(ge3_ic1,"p"); ge3_ic1->SetMarkerStyle(29);
  //  mg_e3->Add(ge3_ic2,"p"); ge3_ic2->SetMarkerStyle(30);
  mg_e3->Draw("a");
  mg_e3->SetTitle(" ");
  mg_e3->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
  mg_e3->GetYaxis()->SetTitle("#sigma(X_{1}-X_{2})/#sqrt{2} / mm");
  //  mg_e3->GetXaxis()->SetRangeUser(0,600);
  //mg_e3->GetYaxis()->SetRangeUser(0,1);
  mg_e3->SetMinimum(0.);
  // mg_e3->SetMaximum(0.1);
  TLegend *mylegend3 = new TLegend(0.60,0.6,0.9,0.9);
  mylegend3->SetFillColor(0); // white background
  mylegend3->SetTextFont(22);
  mylegend3->SetBorderSize(0); // get rid of the box
  mylegend3->SetTextSize(0.045); // set text size
  mylegend3->AddEntry(ge3_p1,"BPM (221 MeV)","pl"); // options: p,l,f
  mylegend3->AddEntry(ge3_p2,"BPM (70 MeV)","pl"); // options: p,l,f
  //  mylegend3->AddEntry(ge3_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  //  mylegend3->AddEntry(ge3_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegend3->Draw();
  gPad->Modified();
  c1_mg1_e3.SaveAs("figs/inlist_p_posfit_diff.pdf");
  c1_mg1_e3.SaveAs("figs/inlist_p_posfit_diff.png");
  c1_mg1_e3.SaveAs("figs/inlist_p_possfit_diff.C");

 TCanvas c1_mg1_e4;

  TGraphErrors * ge4_p1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  TGraphErrors * ge4_p2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge4_c1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge4_c2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e4 = new TMultiGraph();
  mg_e4->Add(ge4_p1,"pc");  ge4_p1->SetMarkerStyle(22);ge4_p1->SetLineStyle(3);
  mg_e4->Add(ge4_p2,"pc"); ge4_p2->SetMarkerStyle(26);ge4_p2->SetLineStyle(3);
  //  mg_e4->Add(ge4_ic1,"p"); ge4_ic1->SetMarkerStyle(29);
  //  mg_e4->Add(ge4_ic2,"p"); ge4_ic2->SetMarkerStyle(30);
  mg_e4->Draw("a");
  mg_e4->SetTitle(" ");
  mg_e4->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
  mg_e4->GetYaxis()->SetTitle("#sigma(X_{1}-X_{2})/#sqrt{2}  / mm");
  //  mg_e4->GetXaxis()->SetRangeUser(0,600);
  //mg_e4->GetYaxis()->SetRangeUser(0,1);
  mg_e4->SetMinimum(0.);
  // mg_e4->SetMaximum(0.1);
  TLegend *mylegend4 = new TLegend(0.60,0.6,0.9,0.9);
  mylegend4->SetFillColor(0); // white background
  mylegend4->SetTextFont(22);
  mylegend4->SetBorderSize(0); // get rid of the box
  mylegend4->SetTextSize(0.045); // set text size
  mylegend4->AddEntry(ge4_p1,"BPM (430 MeV/u)","pl"); // options: p,l,f
  mylegend4->AddEntry(ge4_p2,"BPM (130 MeV/u)","pl"); // options: p,l,f
  //  mylegend4->AddEntry(ge4_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  //  mylegend4->AddEntry(ge4_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegend4->Draw();
  gPad->Modified();
 c1_mg1_e4.SaveAs("figs/inlist_c_posfit_diff.pdf");
  c1_mg1_e4.SaveAs("figs/inlist_c_posfit_diff.png");
  c1_mg1_e4.SaveAs("figs/inlist_c_possfit_diff.C");

 
  ///////////////////////////////////////////////
 TCanvas c1_mg1_e5;

  TGraphErrors * ge5_p1 = new TGraphErrors("inlistE255_p_focusfit_diff.txt","%lg %lg %lg");
  TGraphErrors * ge5_p2 = new TGraphErrors("inlistE21_p_focusfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge5_c1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge5_c2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e5 = new TMultiGraph();
  mg_e5->Add(ge5_p1,"pc");  ge5_p1->SetMarkerStyle(20);ge5_p1->SetLineStyle(3);
  mg_e5->Add(ge5_p2,"pc"); ge5_p2->SetMarkerStyle(24);ge5_p2->SetLineStyle(3);
  //  mg_e5->Add(ge5_ic1,"p"); ge5_ic1->SetMarkerStyle(29);
  //  mg_e5->Add(ge5_ic2,"p"); ge5_ic2->SetMarkerStyle(30);
  mg_e5->Draw("a");
  mg_e5->SetTitle(" ");
  mg_e5->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
  //mg_e5->GetYaxis()->SetTitle("#sqrt{2}#upoint#sigma(F_{1}-F_{2})/(F_{1}+F_{2})");
  mg_e5->GetYaxis()->SetTitle("#sigma(F_{1}-F_{2})/#sqrt{2}  / mm");

  //  mg_e5->GetXaxis()->SetRangeUser(0,600);
  //mg_e5->GetYaxis()->SetRangeUser(0,1);
  mg_e5->SetMinimum(0.);
  // mg_e5->SetMaximum(0.1);
 TLegend * mylegend5 = new TLegend(0.60,0.6,0.9,0.9);
  mylegend5->SetFillColor(0); // white background
  mylegend5->SetTextFont(22);
  mylegend5->SetBorderSize(0); // get rid of the box
  mylegend5->SetTextSize(0.045); // set text size
  mylegend5->AddEntry(ge5_p1,"BPM (221 MeV)","pl"); // options: p,l,f
  mylegend5->AddEntry(ge5_p2,"BPM (70 MeV)","pl"); // options: p,l,f
  //  mylegend5->AddEntry(ge5_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  //  mylegend5->AddEntry(ge5_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegend5->Draw();
  gPad->Modified();
  c1_mg1_e5.SaveAs("figs/inlist_p_focusfit_diff.pdf");
  c1_mg1_e5.SaveAs("figs/inlist_p_focusfit_diff.png");
  c1_mg1_e5.SaveAs("figs/inlist_p_focusfit_diff.C");


 TCanvas c1_mg1_e6;

  TGraphErrors * ge6_p1 = new TGraphErrors("inlistE255_c_focusfit_diff.txt","%lg %lg %lg");
  TGraphErrors * ge6_p2 = new TGraphErrors("inlistE21_c_focusfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge6_c1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge6_c2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e6 = new TMultiGraph();
  mg_e6->Add(ge6_p1,"pc");  ge6_p1->SetMarkerStyle(22);ge6_p1->SetLineStyle(3);
  mg_e6->Add(ge6_p2,"pc"); ge6_p2->SetMarkerStyle(26);ge6_p2->SetLineStyle(3);
  //  mg_e6->Add(ge6_ic1,"p"); ge6_ic1->SetMarkerStyle(29);
  //  mg_e6->Add(ge6_ic2,"p"); ge6_ic2->SetMarkerStyle(30);
  mg_e6->Draw("a");
  mg_e6->SetTitle(" ");
  mg_e6->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
   mg_e6->GetYaxis()->SetTitle("#sqrt{2}#upoint#sigma(F_{1}-F_{2})/(F_{1}+F_{2})");
   mg_e6->GetYaxis()->SetTitle("#sigma(F_{1}-F_{2})/#sqrt{2}  / mm");

  //  mg_e6->GetXaxis()->SetRangeUser(0,600);
  //mg_e6->GetYaxis()->SetRangeUser(0,1);
  mg_e6->SetMinimum(0.);
  // mg_e6->SetMaximum(0.1);
 TLegend * mylegend6 = new TLegend(0.60,0.6,0.9,0.9);
  mylegend6->SetFillColor(0); // white background
  mylegend6->SetTextFont(22);
  mylegend6->SetBorderSize(0); // get rid of the box
  mylegend6->SetTextSize(0.045); // set text size
  mylegend6->AddEntry(ge6_p1,"BPM (430 MeV/u)","pl"); // options: p,l,f
  mylegend6->AddEntry(ge6_p2,"BPM (130 MeV/u)","pl"); // options: p,l,f
  //  mylegend6->AddEntry(ge6_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  //  mylegend6->AddEntry(ge6_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegend6->Draw();
  gPad->Modified();
  c1_mg1_e6.SaveAs("figs/inlist_c_focusfit_diff.pdf");
  c1_mg1_e6.SaveAs("figs/inlist_c_focusfit_diff.png");
  c1_mg1_e6.SaveAs("figs/inlist_c_focusfit_diff.C");


 TCanvas c1_mg1_e7;

  TGraphErrors * ge7_p1 = new TGraphErrors("inlistE255_c_peakfit.txt","%lg %lg %lg");
  TGraphErrors * ge7_p2 = new TGraphErrors("inlistE21_c_peakfit.txt","%lg %lg %lg");
  // TGraphErrors * ge7_c1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge7_c2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e7 = new TMultiGraph();
  mg_e7->Add(ge7_p1,"pc");  ge7_p1->SetMarkerStyle(22);ge7_p1->SetLineStyle(1);
  mg_e7->Add(ge7_p2,"pc"); ge7_p2->SetMarkerStyle(26);ge7_p2->SetLineStyle(1);
  //  mg_e7->Add(ge7_ic1,"p"); ge7_ic1->SetMarkerStyle(29);
  //  mg_e7->Add(ge7_ic2,"p"); ge7_ic2->SetMarkerStyle(30);
  mg_e7->Draw("a");
  mg_e7->SetTitle(" ");
  mg_e7->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
   mg_e7->GetYaxis()->SetTitle("SNR");
   //mg_e7->GetYaxis()->SetTitle("#sigma(F_{1}-F_{2})/#sqrt{2}");

  //  mg_e7->GetXaxis()->SetRangeUser(0,600);
  //mg_e7->GetYaxis()->SetRangeUser(0,1);
  mg_e7->SetMinimum(1.);
  gPad->SetLogy();
  // mg_e7->SetMaximum(0.1);
  TLegend *mylegende7 = new TLegend(0.60,0.2,0.9,0.5);
  mylegende7->SetFillColor(0); // white background
  mylegende7->SetTextFont(22);
  mylegende7->SetBorderSize(0); // get rid of the box
  mylegende7->SetTextSize(0.045); // set text size
  mylegende7->AddEntry(ge7_p1,"BPM (430 MeV/u)","p"); // options: p,l,f
  mylegende7->AddEntry(ge7_p2,"BPM (130 MeV/u)","p"); // options: p,l,f
  //  mylegend6->AddEntry(ge7_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  //  mylegend6->AddEntry(ge7_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegende7->Draw();
  gPad->Modified();
  c1_mg1_e7.SaveAs("figs/inlist_c_peakfit.pdf");
  c1_mg1_e7.SaveAs("figs/inlist_c_peakfit.png");
  c1_mg1_e7.SaveAs("figs/inlist_c_peakfit.C");




 TCanvas c1_mg1_e8;

  TGraphErrors * ge8_p1 = new TGraphErrors("inlistE255_p_peakfit.txt","%lg %lg %lg");
  TGraphErrors * ge8_p2 = new TGraphErrors("inlistE21_p_peakfit.txt","%lg %lg %lg");
  // TGraphErrors * ge8_c1 = new TGraphErrors("inlistE255_c_posfit_diff.txt","%lg %lg %lg");
  // TGraphErrors * ge8_c2 = new TGraphErrors("inlistE21_c_posfit_diff.txt","%lg %lg %lg");
  TMultiGraph * mg_e8 = new TMultiGraph();
  mg_e8->Add(ge8_p1,"pc");  ge8_p1->SetMarkerStyle(20);ge8_p1->SetLineStyle(1);
  mg_e8->Add(ge8_p2,"pc"); ge8_p2->SetMarkerStyle(24);ge8_p2->SetLineStyle(1);
  //  mg_e8->Add(ge8_ic1,"p"); ge8_ic1->SetMarkerStyle(29);
  //  mg_e8->Add(ge8_ic2,"p"); ge8_ic2->SetMarkerStyle(30);
  mg_e8->Draw("a");
  mg_e8->SetTitle(" ");
  mg_e8->GetXaxis()->SetTitle("Intensity / 10^{6}s^{-1}");
   mg_e8->GetYaxis()->SetTitle("SNR");
   //mg_e8->GetYaxis()->SetTitle("#sigma(F_{1}-F_{2})/#sqrt{2}");

  //  mg_e8->GetXaxis()->SetRangeUser(0,600);
  //mg_e8->GetYaxis()->SetRangeUser(0,1);
  mg_e8->SetMinimum(1.);
  gPad->SetLogy();
  // mg_e8->SetMaximum(0.1);
  TLegend * mylegende8 = new TLegend(0.60,0.2,0.9,0.5);
  mylegende8->SetFillColor(0); // white background
  mylegende8->SetTextFont(22);
  mylegende8->SetBorderSize(0); // get rid of the box
  mylegende8->SetTextSize(0.045); // set text size
  mylegende8->AddEntry(ge8_p1,"BPM (221 MeV/u)","p"); // options: p,l,f
  mylegende8->AddEntry(ge8_p2,"BPM (70 MeV/u)","p"); // options: p,l,f
  //  mylegend6->AddEntry(ge8_ic1,"IC (430 MeV/u)","p"); // options: p,l,f
  //  mylegend6->AddEntry(ge8_ic2,"IC (130 MeV/u)","p"); // options: p,l,f
  mylegende8->Draw();
  gPad->Modified();
  c1_mg1_e8.SaveAs("figs/inlist_p_peakfit.pdf");
  c1_mg1_e8.SaveAs("figs/inlist_p_peakfit.png");
  c1_mg1_e8.SaveAs("figs/inlist_p_peakfit.C");

 


}
