{

 gROOT->Reset();
  gROOT->ProcessLine(".x /work/leverington/beamprofilemonitor/hitdata/Scripts/Scripts_20161126/lhcbStyle.C");



  TFile *_file0_p = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run8.root");
  TGraphErrors * g_0p = 0;
 _file0_p->GetObject("example",g_0p);

 TFile *_file1_p = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run32.root");
 TGraphErrors * g_1p = 0;
 _file1_p->GetObject("example",g_1p);

 TFile *_file0_he = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run35.root");
 TGraphErrors * g_0he = 0;
 _file0_he->GetObject("example",g_0he);

 TFile *_file1_he = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run60.root");
 TGraphErrors * g_1he = 0;
 _file1_he->GetObject("example",g_1he);



 TFile *_file0_c = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run63.root");
TGraphErrors * g_0c = 0;
 _file0_c->GetObject("example",g_0c);
 TFile *_file1_c = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run86.root");
 TGraphErrors * g_1c = 0;
 _file1_c->GetObject("example",g_1c);


 TFile *_file0_o = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run89.root");
TGraphErrors * g_0o = 0;
 _file0_o->GetObject("example",g_0o);
 TFile *_file1_o = TFile::Open("../../HIT_26-11-2016/with_timestamp/SAVE_PiN_run108.root");
 TGraphErrors * g_1o = 0;
 _file1_o->GetObject("example",g_1o);

   TCanvas *c1 = new TCanvas("c1", "canvaspad1", 800, 800);




   gStyle->SetPadBorderMode(0);
   gStyle->SetFrameBorderMode(0);
   Float_t small = 1e-5;
   c1->Divide(2,2,small,small);
  
   c1->cd(1);
   gPad->SetBottomMargin(small);
   gPad->SetRightMargin(small);
   gPad->SetLeftMargin(0.2);

   TMultiGraph * mg_p = new TMultiGraph();
   mg_p->Add(g_0p,"pc");  g_0p->SetMarkerStyle(20);g_0p->SetMarkerColor(kGray);
     mg_p->Add(g_1p,"pc");  g_1p->SetMarkerStyle(20);
   mg_p->Draw("a");
   mg_p->SetTitle("");
   // mg_p->GetXaxis()->SetTitle("Stopping Power / MeV#upointcm^{2}g^{-1}");
   mg_p->GetYaxis()->SetTitle("A_{BPM} / a.u./312#mus"); mg_p->GetYaxis()->SetTitleOffset(1.5);
   mg_p->GetXaxis()->SetRangeUser(4,64);
   mg_p->GetYaxis()->SetRangeUser(-200,3200);
   mg_p->SetMinimum(-200.);
   mg_p->SetMaximum(3200.);
 TLegend * mylegend = new TLegend(0.60,0.8,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(g_0p,"Protons E21 I8","p"); // options: p,l,f
  mylegend->AddEntry(g_1p,"Protons E255 I8","p"); // options: p,l,f
  mylegend->Draw();


   gPad->Modified();

   
   c1->cd(2);
   gPad->SetBottomMargin(small);
   gPad->SetRightMargin(0.2);
   gPad->SetLeftMargin(small);
   TMultiGraph * mg_he = new TMultiGraph();
   mg_he->Add(g_0he,"pc");  g_0he->SetMarkerStyle(21);g_0he->SetMarkerColor(kGray);
   mg_he->Add(g_1he,"pc");  g_1he->SetMarkerStyle(21);
   mg_he->Draw("a");
   mg_he->SetTitle("");
   // mg_he->GetXaxis()->SetTitle("Stopping Power / MeV#upointcm^{2}g^{-1}");
   // mg_he->GetYaxis()->SetTitle("#A_{BPM} / [a.u./312#us]");
   mg_he->GetXaxis()->SetRangeUser(4,64);
   mg_he->GetYaxis()->SetRangeUser(-200,3200);
   mg_he->SetMinimum(-200.);
   mg_he->SetMaximum(3200.);
TLegend * mylegend2 = new TLegend(0.40,0.8,0.7,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(g_0he,"Helium E21 I8","p"); // options: p,l,f
  mylegend2->AddEntry(g_1he,"Helium E255 I8","p"); // options: p,l,f
  mylegend2->Draw();
   gPad->Modified();

  
   c1->cd(3);
   gPad->SetTopMargin(small);
   gPad->SetRightMargin(small);
   gPad->SetLeftMargin(0.2);
   gPad->SetTickx();
   TMultiGraph * mg_c = new TMultiGraph();
   mg_c->Add(g_0c,"pc");  g_0c->SetMarkerStyle(22);g_0c->SetMarkerColor(kGray);
   mg_c->Add(g_1c,"pc");  g_1c->SetMarkerStyle(22);
   mg_c->Draw("a");
   mg_c->SetTitle("");
   mg_c->GetXaxis()->SetTitle("Channel");
     mg_c->GetYaxis()->SetTitle("A_{BPM} / a.u./312#mus");mg_c->GetYaxis()->SetTitleOffset(1.5);
   mg_c->GetXaxis()->SetRangeUser(4,64);
   mg_c->GetYaxis()->SetRangeUser(-200,3200);
   mg_c->SetMinimum(-200.);
   mg_c->SetMaximum(3200.);
TLegend * mylegend3 = new TLegend(0.60,0.85,0.9,0.95);
  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(g_0c,"Carbon E21 I8","p"); // options: p,l,f
  mylegend3->AddEntry(g_1c,"Carbon E255 I8","p"); // options: p,l,f
  mylegend3->Draw();

   gPad->Modified();


   c1->cd(4);
   gPad->SetTopMargin(small);
   gPad->SetRightMargin(0.2);
   gPad->SetLeftMargin(small);
   gPad->SetTickx();
   TMultiGraph * mg_o = new TMultiGraph();
   mg_o->Add(g_0o,"pc");  g_0o->SetMarkerStyle(23);g_0o->SetMarkerColor(kGray);
   mg_o->Add(g_1o,"pc");  g_1o->SetMarkerStyle(23);
   mg_o->Draw("a");
   mg_o->SetTitle("");
   mg_o->GetXaxis()->SetTitle("Channel");
   //mg_o->GetYaxis()->SetTitle("#A_{BPM} / [a.u./312#us]");
   mg_o->GetXaxis()->SetRangeUser(4,64);
   mg_o->GetYaxis()->SetRangeUser(-200,3200);
   mg_o->SetMinimum(-200.);
   mg_o->SetMaximum(3200.);
TLegend * mylegend4 = new TLegend(0.40,0.85,0.7,0.95);
  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(g_0o,"Oxygen E21 I8","p"); // options: p,l,f
  mylegend4->AddEntry(g_1o,"Oxygen E201 I8","p"); // options: p,l,f
  mylegend4->Draw();

   gPad->Modified();

   c1->cd();
   gPad->Modified();
   c1->SaveAs("figs/beamprofileexamples.pdf");
   c1->SaveAs("figs/beamprofileexamples.png");

}   




