示例#1
0
void gyieldsp()
{
//=========Macro generated from canvas: c1/c1
//=========  (Fri Jul 31 19:31:43 2015) by ROOT version6.05/01
   TCanvas *c1 = new TCanvas("c1", "c1",0,23,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.16);
   c1->SetRightMargin(0.04);
   c1->SetTopMargin(0.08);
   c1->SetBottomMargin(0.12);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad1
   TPad *pad1 = new TPad("pad1", "pad1",0,0.26,1,1);
   pad1->Draw();
   pad1->cd();
   pad1->Range(-3.5,-6.621622,2.75,158.9189);
   pad1->SetFillColor(0);
   pad1->SetBorderMode(0);
   pad1->SetBorderSize(2);
   pad1->SetTickx(1);
   pad1->SetTicky(1);
   pad1->SetLeftMargin(0.16);
   pad1->SetRightMargin(0.04);
   pad1->SetTopMargin(0.1142857);
   pad1->SetBottomMargin(0.04);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   
   Double_t Graph0_fx3021[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph0_fy3021[10] = {
   103.56,
   105.744,
   103.4081,
   100.0093,
   97.03688,
   94.36609,
   90.5471,
   82.43278,
   65.82142,
   43.43165};
   Double_t Graph0_felx3021[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fely3021[10] = {
   7.299733,
   7.206486,
   6.824632,
   6.594841,
   6.406375,
   6.079494,
   5.746822,
   5.225105,
   4.165823,
   2.787035};
   Double_t Graph0_fehx3021[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fehy3021[10] = {
   5.988963,
   6.218694,
   6.307709,
   6.368316,
   5.847823,
   5.655323,
   5.083818,
   4.561256,
   3.722445,
   2.542957};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(10,Graph0_fx3021,Graph0_fy3021,Graph0_felx3021,Graph0_fehx3021,Graph0_fely3021,Graph0_fehy3021);
   grae->SetName("Graph0");
   grae->SetTitle("Graph");

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ffff00");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->SetMarkerSize(0);
   
   TH1F *Graph_Graph3021 = new TH1F("Graph_Graph3021","Graph",100,-2.5,2.5);
   Graph_Graph3021->SetMinimum(0);
   Graph_Graph3021->SetMaximum(140);
   Graph_Graph3021->SetDirectory(0);
   Graph_Graph3021->SetStats(0);
   Graph_Graph3021->SetLineStyle(0);
   Graph_Graph3021->SetMarkerStyle(20);
   Graph_Graph3021->GetXaxis()->SetNdivisions(505);
   Graph_Graph3021->GetXaxis()->SetLabelFont(42);
   Graph_Graph3021->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetXaxis()->SetLabelSize(0);
   Graph_Graph3021->GetXaxis()->SetTitleSize(0.07142857);
   Graph_Graph3021->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph3021->GetXaxis()->SetTitleFont(42);
   Graph_Graph3021->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]");
   Graph_Graph3021->GetYaxis()->SetLabelFont(42);
   Graph_Graph3021->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetYaxis()->SetLabelSize(0.07142857);
   Graph_Graph3021->GetYaxis()->SetTitleSize(0.07142857);
   Graph_Graph3021->GetYaxis()->SetTitleOffset(1.05);
   Graph_Graph3021->GetYaxis()->SetTitleFont(42);
   Graph_Graph3021->GetZaxis()->SetLabelFont(42);
   Graph_Graph3021->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3021->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3021->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3021);
   
   grae->Draw("a2");
   
   Double_t Graph1_fx3022[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph1_fy3022[10] = {
   103.56,
   105.744,
   103.4081,
   100.0093,
   97.03688,
   94.36609,
   90.5471,
   82.43278,
   65.82142,
   43.43165};
   Double_t Graph1_felx3022[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fely3022[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fehx3022[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fehy3022[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   grae = new TGraphAsymmErrors(10,Graph1_fx3022,Graph1_fy3022,Graph1_felx3022,Graph1_fehx3022,Graph1_fely3022,Graph1_fehy3022);
   grae->SetName("Graph1");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->SetMarkerSize(0);
   grae->Draw("z");
   
   Double_t Graph2_fx3023[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph2_fy3023[10] = {
   91.59545,
   95.26883,
   95.65156,
   95.47892,
   95.94693,
   96.02597,
   93.3635,
   84.56484,
   65.95871,
   42.11706};
   Double_t Graph2_felx3023[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fely3023[10] = {
   8.336985,
   8.261181,
   7.634488,
   6.438496,
   6.661149,
   6.164321,
   6.1019,
   4.954787,
   4.773841,
   2.599375};
   Double_t Graph2_fehx3023[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fehy3023[10] = {
   8.262572,
   7.14746,
   6.62492,
   6.725295,
   5.946212,
   5.838684,
   5.077774,
   5.257491,
   3.443198,
   2.602454};
   grae = new TGraphAsymmErrors(10,Graph2_fx3023,Graph2_fy3023,Graph2_felx3023,Graph2_fehx3023,Graph2_fely3023,Graph2_fehy3023);
   grae->SetName("Graph2");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   grae->SetFillColor(ci);
   grae->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   grae->SetLineColor(ci);
   grae->SetLineStyle(7);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_Graph3023 = new TH1F("Graph_Graph3023","Graph",100,-2.88,2.88);
   Graph_Graph3023->SetMinimum(33.22782);
   Graph_Graph3023->SetMaximum(108.7062);
   Graph_Graph3023->SetDirectory(0);
   Graph_Graph3023->SetStats(0);
   Graph_Graph3023->SetLineStyle(0);
   Graph_Graph3023->SetMarkerStyle(20);
   Graph_Graph3023->GetXaxis()->SetLabelFont(42);
   Graph_Graph3023->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph3023->GetXaxis()->SetTitleFont(42);
   Graph_Graph3023->GetYaxis()->SetLabelFont(42);
   Graph_Graph3023->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph3023->GetYaxis()->SetTitleFont(42);
   Graph_Graph3023->GetZaxis()->SetLabelFont(42);
   Graph_Graph3023->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3023);
   
   grae->Draw("2");
   
   Double_t Graph3_fx3024[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph3_fy3024[10] = {
   91.59545,
   95.26883,
   95.65156,
   95.47892,
   95.94693,
   96.02597,
   93.3635,
   84.56484,
   65.95871,
   42.11706};
   Double_t Graph3_felx3024[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fely3024[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph3_fehx3024[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fehy3024[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   grae = new TGraphAsymmErrors(10,Graph3_fx3024,Graph3_fy3024,Graph3_felx3024,Graph3_fehx3024,Graph3_fely3024,Graph3_fehy3024);
   grae->SetName("Graph3");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   grae->SetFillColor(ci);
   grae->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   grae->SetLineColor(ci);
   grae->SetLineStyle(7);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->Draw("z");
   
   Double_t Graph4_fx1011[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph4_fy1011[10] = {
   108.0732,
   102.2597,
   100.2246,
   101.796,
   105.3416,
   99.73788,
   98.62062,
   85.94448,
   62.90271,
   44.47931};
   Double_t Graph4_fex1011[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1011[10] = {
   6.667786,
   4.792637,
   3.765295,
   3.224798,
   3.479167,
   3.377478,
   3.07273,
   3.40604,
   2.800731,
   2.87761};
   TGraphErrors *gre = new TGraphErrors(10,Graph4_fx1011,Graph4_fy1011,Graph4_fex1011,Graph4_fey1011);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->Draw("||");
   
   Double_t gyieldsp_exp_statonly_1_fx1012[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t gyieldsp_exp_statonly_1_fy1012[10] = {
   108.0732,
   102.2597,
   100.2246,
   101.796,
   105.3416,
   99.73788,
   98.62062,
   85.94448,
   62.90271,
   44.47931};
   Double_t gyieldsp_exp_statonly_1_fex1012[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t gyieldsp_exp_statonly_1_fey1012[10] = {
   2.814265,
   2.293805,
   2.181326,
   2.056934,
   2.054972,
   2.059018,
   2.050204,
   2.01317,
   1.754638,
   1.667829};
   gre = new TGraphErrors(10,gyieldsp_exp_statonly_1_fx1012,gyieldsp_exp_statonly_1_fy1012,gyieldsp_exp_statonly_1_fex1012,gyieldsp_exp_statonly_1_fey1012);
   gre->SetName("gyieldsp_exp_statonly_1");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(1.2);
   
   TH1F *Graph_gyieldsp_exp_statonly_11012 = new TH1F("Graph_gyieldsp_exp_statonly_11012","Graph",100,-2.64,2.64);
   Graph_gyieldsp_exp_statonly_11012->SetMinimum(36.00388);
   Graph_gyieldsp_exp_statonly_11012->SetMaximum(117.6951);
   Graph_gyieldsp_exp_statonly_11012->SetDirectory(0);
   Graph_gyieldsp_exp_statonly_11012->SetStats(0);
   Graph_gyieldsp_exp_statonly_11012->SetLineStyle(0);
   Graph_gyieldsp_exp_statonly_11012->SetMarkerStyle(20);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleOffset(1.1);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleOffset(1.5);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_gyieldsp_exp_statonly_11012);
   
   gre->Draw("pz");
   
   TLegend *leg = new TLegend(0.6,0.1,0.9,0.3142857,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.05714286);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph4","Data","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph0","CT10","lf");

   ci = TColor::GetColor("#ffff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(4);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","CT10+EPS09","lf");

   ci = TColor::GetColor("#009900");
   entry->SetFillColor(ci);
   entry->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   entry->SetLineColor(ci);
   entry->SetLineStyle(7);
   entry->SetLineWidth(4);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(-2.35,125,-0.35,140,"br");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(13);
   pt->SetTextFont(42);
   pt->SetTextSize(0.05714286);
   TText *AText = pt->AddText("Luminosity uncertainty: 3.5%");
   pt->Draw();
   
   pt = new TPaveText(0.27,0.2,0.5,0.3428571,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(13);
   pt->SetTextFont(42);
   pt->SetTextSize(0.05714286);
   AText = pt->AddText("W^{+} #rightarrow #font[12]{l}^{+} + #nu");
   AText = pt->AddText("p_{T}^{#font[12]{l}} > 25 GeV/c");
   pt->Draw();
      tex = new TLatex(0.96,0.9177143," #sqrt{s_{NN}} = 5.02 TeV");
tex->SetNDC();
   tex->SetTextAlign(31);
   tex->SetTextFont(42);
   tex->SetTextSize(0.05714286);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.16,0.9177143,"pPb 34.6 nb^{-1}");
tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.05714286);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.924,0.8476571,"CMS");
tex->SetNDC();
   tex->SetTextAlign(33);
   tex->SetTextFont(61);
   tex->SetTextSize(0.06857143);
   tex->SetLineWidth(2);
   tex->Draw();
   
   TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5);
   Graph_copy->SetMinimum(0);
   Graph_copy->SetMaximum(140);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);
   Graph_copy->SetLineStyle(0);
   Graph_copy->SetMarkerStyle(20);
   Graph_copy->GetXaxis()->SetNdivisions(505);
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelOffset(0.007);
   Graph_copy->GetXaxis()->SetLabelSize(0);
   Graph_copy->GetXaxis()->SetTitleSize(0.07142857);
   Graph_copy->GetXaxis()->SetTitleOffset(1.1);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]");
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelOffset(0.007);
   Graph_copy->GetYaxis()->SetLabelSize(0.07142857);
   Graph_copy->GetYaxis()->SetTitleSize(0.07142857);
   Graph_copy->GetYaxis()->SetTitleOffset(1.05);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelOffset(0.007);
   Graph_copy->GetZaxis()->SetLabelSize(0.05);
   Graph_copy->GetZaxis()->SetTitleSize(0.06);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   pad1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: pad2
   TPad *pad2 = new TPad("pad2", "pad2",0,0,1,0.288);
   pad2->Draw();
   pad2->cd();
   pad2->Range(-3.5,0.35,2.75,1.35);
   pad2->SetFillColor(0);
   pad2->SetFillStyle(4000);
   pad2->SetBorderMode(0);
   pad2->SetBorderSize(2);
   pad2->SetTickx(1);
   pad2->SetTicky(1);
   pad2->SetLeftMargin(0.16);
   pad2->SetRightMargin(0.04);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.4);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameBorderMode(0);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameBorderMode(0);
   
   TH1F *Graph = new TH1F("Graph","Graph",100,-2.5,2.5);
   Graph->SetMinimum(0.75);
   Graph->SetMaximum(1.35);
   Graph->SetDirectory(0);
   Graph->SetStats(0);
   Graph->SetLineStyle(0);
   Graph->SetMarkerStyle(20);
   Graph->GetXaxis()->SetTitle("#eta_{lab}");
   Graph->GetXaxis()->SetNdivisions(505);
   Graph->GetXaxis()->SetLabelFont(42);
   Graph->GetXaxis()->SetLabelOffset(0.007);
   Graph->GetXaxis()->SetLabelSize(0.1666667);
   Graph->GetXaxis()->SetTitleSize(0.1666667);
   Graph->GetXaxis()->SetTitleOffset(1.1);
   Graph->GetXaxis()->SetTitleFont(42);
   Graph->GetYaxis()->SetTitle("Ratio ");
   Graph->GetYaxis()->SetNdivisions(503);
   Graph->GetYaxis()->SetLabelFont(42);
   Graph->GetYaxis()->SetLabelOffset(0.007);
   Graph->GetYaxis()->SetLabelSize(0.1666667);
   Graph->GetYaxis()->SetTitleSize(0.1666667);
   Graph->GetYaxis()->SetTitleOffset(0.45);
   Graph->GetYaxis()->SetTitleFont(42);
   Graph->GetZaxis()->SetLabelFont(42);
   Graph->GetZaxis()->SetLabelOffset(0.007);
   Graph->GetZaxis()->SetLabelSize(0.05);
   Graph->GetZaxis()->SetTitleSize(0.06);
   Graph->GetZaxis()->SetTitleFont(42);
   Graph->Draw("");
   
   Double_t Graph0_fx1013[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph0_fy1013[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t Graph0_fex1013[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fey1013[10] = {
   0.0644708,
   0.06365122,
   0.06354681,
   0.06481966,
   0.06320752,
   0.0622177,
   0.05991862,
   0.05949606,
   0.06001632,
   0.06142499};
   gre = new TGraphErrors(10,Graph0_fx1013,Graph0_fy1013,Graph0_fex1013,Graph0_fey1013);
   gre->SetName("Graph0");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   gre->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   gre->SetLineColor(ci);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   
   TH1F *Graph_Graph1013 = new TH1F("Graph_Graph1013","Graph",100,-2.88,2.88);
   Graph_Graph1013->SetMinimum(0.9222164);
   Graph_Graph1013->SetMaximum(1.077784);
   Graph_Graph1013->SetDirectory(0);
   Graph_Graph1013->SetStats(0);
   Graph_Graph1013->SetLineStyle(0);
   Graph_Graph1013->SetMarkerStyle(20);
   Graph_Graph1013->GetXaxis()->SetLabelFont(42);
   Graph_Graph1013->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1013->GetXaxis()->SetTitleFont(42);
   Graph_Graph1013->GetYaxis()->SetLabelFont(42);
   Graph_Graph1013->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1013->GetYaxis()->SetTitleFont(42);
   Graph_Graph1013->GetZaxis()->SetLabelFont(42);
   Graph_Graph1013->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1013);
   
   gre->Draw("2");
   
   Double_t Graph1_fx1014[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph1_fy1014[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t Graph1_fex1014[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fey1014[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(10,Graph1_fx1014,Graph1_fy1014,Graph1_fex1014,Graph1_fey1014);
   gre->SetName("Graph1");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   gre->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   gre->SetLineColor(ci);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   gre->Draw("z");
   
   Double_t Graph2_fx1015[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph2_fy1015[10] = {
   0.8844678,
   0.9009383,
   0.9249909,
   0.9547005,
   0.9887677,
   1.01759,
   1.031104,
   1.025864,
   1.002086,
   0.9697318};
   Double_t Graph2_fex1015[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fey1015[10] = {
   0.05296218,
   0.042007,
   0.03326947,
   0.02116912,
   0.0170915,
   0.01890429,
   0.01672622,
   0.01681633,
   0.01541551,
   0.01597539};
   gre = new TGraphErrors(10,Graph2_fx1015,Graph2_fy1015,Graph2_fex1015,Graph2_fey1015);
   gre->SetName("Graph2");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   gre->SetFillColor(ci);
   gre->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   gre->SetLineColor(ci);
   gre->SetLineStyle(7);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1015 = new TH1F("Graph_Graph1015","Graph",100,-2.88,2.88);
   Graph_Graph1015->SetMinimum(0.8098732);
   Graph_Graph1015->SetMaximum(1.069463);
   Graph_Graph1015->SetDirectory(0);
   Graph_Graph1015->SetStats(0);
   Graph_Graph1015->SetLineStyle(0);
   Graph_Graph1015->SetMarkerStyle(20);
   Graph_Graph1015->GetXaxis()->SetLabelFont(42);
   Graph_Graph1015->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1015->GetXaxis()->SetTitleFont(42);
   Graph_Graph1015->GetYaxis()->SetLabelFont(42);
   Graph_Graph1015->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1015->GetYaxis()->SetTitleFont(42);
   Graph_Graph1015->GetZaxis()->SetLabelFont(42);
   Graph_Graph1015->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1015);
   
   gre->Draw("2");
   
   Double_t Graph3_fx1016[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph3_fy1016[10] = {
   0.8844678,
   0.9009383,
   0.9249909,
   0.9547005,
   0.9887677,
   1.01759,
   1.031104,
   1.025864,
   1.002086,
   0.9697318};
   Double_t Graph3_fex1016[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fey1016[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(10,Graph3_fx1016,Graph3_fy1016,Graph3_fex1016,Graph3_fey1016);
   gre->SetName("Graph3");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   gre->SetFillColor(ci);
   gre->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   gre->SetLineColor(ci);
   gre->SetLineStyle(7);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->Draw("z");
   
   Double_t Graph4_fx1017[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph4_fy1017[10] = {
   1.043581,
   0.9670498,
   0.9692137,
   1.017865,
   1.085583,
   1.056925,
   1.089164,
   1.042601,
   0.9556571,
   1.024122};
   Double_t Graph4_fex1017[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1017[10] = {
   0.06438575,
   0.04532301,
   0.03641199,
   0.03224499,
   0.03585407,
   0.03579123,
   0.03393516,
   0.041319,
   0.04255045,
   0.06625605};
   gre = new TGraphErrors(10,Graph4_fx1017,Graph4_fy1017,Graph4_fex1017,Graph4_fey1017);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->Draw("||");
   
   Double_t Graph5_fx1018[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph5_fy1018[10] = {
   1.043581,
   0.9670498,
   0.9692137,
   1.017865,
   1.085583,
   1.056925,
   1.089164,
   1.042601,
   0.9556571,
   1.024122};
   Double_t Graph5_fex1018[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph5_fey1018[10] = {
   0.02717523,
   0.02169205,
   0.02109434,
   0.02056743,
   0.02117723,
   0.02181947,
   0.02264241,
   0.02442196,
   0.02665755,
   0.03840124};
   gre = new TGraphErrors(10,Graph5_fx1018,Graph5_fy1018,Graph5_fex1018,Graph5_fey1018);
   gre->SetName("Graph5");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1018 = new TH1F("Graph_Graph1018","Graph",100,-2.64,2.64);
   Graph_Graph1018->SetMinimum(0.9107189);
   Graph_Graph1018->SetMaximum(1.130087);
   Graph_Graph1018->SetDirectory(0);
   Graph_Graph1018->SetStats(0);
   Graph_Graph1018->SetLineStyle(0);
   Graph_Graph1018->SetMarkerStyle(20);
   Graph_Graph1018->GetXaxis()->SetLabelFont(42);
   Graph_Graph1018->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1018->GetXaxis()->SetTitleFont(42);
   Graph_Graph1018->GetYaxis()->SetLabelFont(42);
   Graph_Graph1018->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1018->GetYaxis()->SetTitleFont(42);
   Graph_Graph1018->GetZaxis()->SetLabelFont(42);
   Graph_Graph1018->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1018);
   
   gre->Draw("pz");
   
   TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5);
   Graph_copy->SetMinimum(0.75);
   Graph_copy->SetMaximum(1.35);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);
   Graph_copy->SetLineStyle(0);
   Graph_copy->SetMarkerStyle(20);
   Graph_copy->GetXaxis()->SetTitle("#eta_{lab}");
   Graph_copy->GetXaxis()->SetNdivisions(505);
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelOffset(0.007);
   Graph_copy->GetXaxis()->SetLabelSize(0.1666667);
   Graph_copy->GetXaxis()->SetTitleSize(0.1666667);
   Graph_copy->GetXaxis()->SetTitleOffset(1.1);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("Ratio ");
   Graph_copy->GetYaxis()->SetNdivisions(503);
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelOffset(0.007);
   Graph_copy->GetYaxis()->SetLabelSize(0.1666667);
   Graph_copy->GetYaxis()->SetTitleSize(0.1666667);
   Graph_copy->GetYaxis()->SetTitleOffset(0.45);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelOffset(0.007);
   Graph_copy->GetZaxis()->SetLabelSize(0.05);
   Graph_copy->GetZaxis()->SetTitleSize(0.06);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   pad2->Modified();
   c1->cd();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
示例#2
0
文件: phi2.C 项目: camendola/macro
void phi2(double pt1min, double pt2min, double METmin){


  TLegend* leg = new TLegend(0.13,0.6,0.87,0.87);
  leg->SetNColumns(3);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);

  TFile *data =  TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ");
  TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ");
  TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ");
  TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ");
  TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ");
  TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ");
  TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ");
  TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ");


  TFile *bkg1 =  TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ"); 
  TFile *bkg2 =  TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ");
  TFile *bkg3 =  TFile::Open("./25ns_2246inv_v3/GJets.root","READ");  
  TFile *bkg4 =  TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ");
  TFile *bkg5 =  TFile::Open("./25ns_2246inv_v3/QCD.root","READ");
  TFile *bkg6 =  TFile::Open("./25ns_2246inv_v3/VH.root","READ");
  TFile *bkg7 =  TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ");
  TFile *bkg8 =  TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ");
  TFile *bkg9 =  TFile::Open("./25ns_2246inv_v3/TGJets.root","READ");
  TFile *bkg10 =  TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ");
  TFile *bkg11 =  TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ");
  TFile *bkg12 =  TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ");
 
  TTree *tree_data = (TTree*) data->Get("DiPhotonTree");

  TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree"); 
  TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree"); 
  TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree"); 
  TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree"); 
  TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree"); 
  TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree");
  TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree");  


  TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree");
  TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree");
  TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree");
  TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree");
  TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree");
  TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree");
  TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree");
  TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree");
  TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree");
  TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree");
  TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree");
  TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree");

  TCanvas *c1 = new TCanvas("c1","",500,600);
  TPad *mainPad = new TPad("mainPad","",0,0.3,1,1); 
  TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3);
  mainPad->SetBottomMargin(0.015);
 
  
  smallPad->SetTopMargin(0.05); 
smallPad->SetBottomMargin(0.25); 

  c1->cd();
  
  mainPad->Draw();
  mainPad->cd(); 
 
  
  
  
  
  
  
  gPad->SetLogy();  
  
  TCut mggmax = "mgg<180";
  TCut mggmin = "mgg>100";
  TCut pt1Cut = Form("pt1/mgg>%lf",pt1min);
  TCut pt2Cut = Form("pt2/mgg>%lf",pt2min);
  TCut METCut = Form("t1pfmet>%lf",METmin);
  TCut eveto1 = "eleveto1 == 1";
  TCut eveto2 = "eleveto2 == 1";
  TCut eveto = eveto1 && eveto2;
  TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))";  
  TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))";  
  
  tree_data->Draw("(phi2)>>hdata(20,-4,4)",(mggmax && mggmin && metF&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata");
  
  
  tree_sig1->Draw("(phi2)>>h1(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1");
  tree_sig2->Draw("(phi2)>>h2(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2");
  tree_sig3->Draw("(phi2)>>h3(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3");
  tree_sig4->Draw("(phi2)>>h4(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4");
  tree_sig5->Draw("(phi2)>>h5(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5");
  tree_sig6->Draw("(phi2)>>h6(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6");
  tree_sig7->Draw("(phi2)>>h7(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7");
  
  
  tree_bkg1->Draw("(phi2)>>hbkg1(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1");
  tree_bkg2->Draw("(phi2)>>hbkg2(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));  
  TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2");
  tree_bkg3->Draw("(phi2)>>hbkg3(20,-4,4)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto));  
  TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3");
  tree_bkg4->Draw("(phi2)>>hbkg4(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto)); //weight also on BR = 0.002 if using the 50ns samples
  TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4");
  tree_bkg5->Draw("(phi2)>>hbkg5(20,-4,4)","weight"*(mggmin && mggmax && genmatch&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5");
  tree_bkg6->Draw("(phi2)>>hbkg6(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6");
  tree_bkg7->Draw("(phi2)>>hbkg7(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7");
  tree_bkg8->Draw("(phi2)>>hbkg8(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8");
  tree_bkg9->Draw("(phi2)>>hbkg9(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9");
  tree_bkg10->Draw("(phi2)>>hbkg10(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10");
  tree_bkg11->Draw("(phi2)>>hbkg11(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11");
  tree_bkg12->Draw("(phi2)>>hbkg12(20,-4,4)","weight"*(mggmin && mggmax&& METCut &&pt1Cut && pt2Cut&& eveto));
  TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12");
  
  hdata->SetMarkerColor(kBlack);
  hdata->SetMarkerStyle(20);
  hdata->SetLineColor(kBlack);
  
  h1->SetLineColor(kRed+3);
  h2->SetLineColor(kRed+1);
  h3->SetLineColor(kRed);
  h4->SetLineColor(kPink+2);
  h5->SetLineColor(kPink+4);
  h6->SetLineColor(kPink+7);
  h7->SetLineColor(kMagenta+2);
 
  h1->SetLineWidth(2);
  h2->SetLineWidth(2);  
  h3->SetLineWidth(2);
  h4->SetLineWidth(2);
  h5->SetLineWidth(2);
 h6->SetLineWidth(2);
 h7->SetLineWidth(2);
  




  THStack *hs= new THStack("hs","");
  hbkg7->SetFillColor(kGreen+2);
  hbkg6->SetFillColor(kGreen);
  hbkg8->SetFillColor(kYellow);
  hbkg4->SetFillColor(kOrange);
  hbkg9->SetFillColor(kOrange+7);
  hbkg10->SetFillColor(kOrange+4);
  hbkg11->SetFillColor(kCyan);
  hbkg12->SetFillColor(kCyan+1);
  hbkg5->SetFillColor(kBlue+2);
  hbkg2->SetFillColor(kBlue);
  hbkg3->SetFillColor(kMagenta-2);
  hbkg1->SetFillColor(kViolet);

  hbkg1->SetLineColor(kBlack);
  hbkg2->SetLineColor(kBlack);
  hbkg3->SetLineColor(kBlack);
  hbkg4->SetLineColor(kBlack);
  hbkg5->SetLineColor(kBlack);
  hbkg6->SetLineColor(kBlack);
  hbkg7->SetLineColor(kBlack);
  hbkg8->SetLineColor(kBlack);
  hbkg9->SetLineColor(kBlack);
  hbkg10->SetLineColor(kBlack);
  hbkg11->SetLineColor(kBlack);
  hbkg12->SetLineColor(kBlack);

  hs->Add(hbkg7);
  hs->Add(hbkg6);
  hs->Add(hbkg8);
  hs->Add(hbkg4);
  hs->Add(hbkg9);
  hs->Add(hbkg10);
  hs->Add(hbkg11);
  hs->Add(hbkg12);
  hs->Add(hbkg2);
  hs->Add(hbkg5);
  hs->Add(hbkg3);
  hs->Add(hbkg1);






  
  TH1F *hsum = (TH1F*)hbkg1->Clone("hsum");
  hsum->Add(hbkg2);
  hsum->Add(hbkg3);
  hsum->Add(hbkg4);
  hsum->Add(hbkg5);
  hsum->Add(hbkg6);
  hsum->Add(hbkg7);
  hsum->Add(hbkg8);
  hsum->Add(hbkg9);
  hsum->Add(hbkg10);
  hsum->Add(hbkg11);
  hsum->Add(hbkg12);

  hs->SetMaximum(1000000);
  hs->SetMinimum(0.1);
  hs->SetTitle("");
  hs->Draw("HIST"); 

  hsum->SetMarkerStyle(1);
  hsum->SetFillColor(kGray+3);
  hsum->SetFillStyle(3002);
  hsum->Draw("same e2");
  h2->Draw("same hist");
  h3->Draw("same hist"); 
  h4->Draw("same hist");
  h1->Draw("same hist");
  h5->Draw("same hist"); 
 h6->Draw("same hist"); 
 h7->Draw("same hist"); 

  hdata->Draw("same E1");
  
  hs->GetXaxis()->SetLabelOffset(999);
  hs->GetYaxis()->SetTitle("Events/0.4");  
  hs->GetYaxis()->SetTitleOffset(1.2);  
  gPad->Modified();
  
  leg->AddEntry(hdata,"Data","lep");
     
  
  
  leg->AddEntry(hbkg1,"#gamma #gamma","f");
leg->AddEntry(h1,"m_{Z'} = 600 GeV","l");                                                                               

  leg->AddEntry(hbkg2,"Drell Yann","f");
 
  leg->AddEntry(hbkg3,"#gamma + Jets","f");
leg->AddEntry(h2,"m_{Z'} = 800 GeV","l");                                                                               

  leg->AddEntry(hbkg5,"QCD","f");
  
  leg->AddEntry(hbkg4,"ggH","f");
 leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l");                                                                    
 
  leg->AddEntry(hbkg6,"VH","f");
 
  leg->AddEntry(hbkg7,"ttH","f");

 leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l");                                                                    
  leg->AddEntry(hbkg8,"VBF H","f");
  leg->AddEntry(hbkg9,"t + #gamma + Jets","f");
leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l");                                                            
leg->AddEntry(hbkg10,"tt + #gamma +Jets","f");
  leg->AddEntry(hbkg11,"#gamma+W","f");
leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l");     
  leg->AddEntry(hbkg12,"#gamma+Z","f");
  leg->AddEntry(hsum,"Bkg uncertainty","f");

 leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l");                            
 leg->Draw("same");
  
  c1->cd(); 
  smallPad->Draw(); 
  smallPad->cd();

  TGraphErrors *gr = new TGraphErrors(0);
  double integralData=hdata->Integral();
  double integralBKG=hsum->Integral();
  double error, ratio;
  for(int w=1; w<20; w++){
    if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){
      
      gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w)));
      ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w));
      error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w));
      std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl;
      gr->SetPointError(w, hdata->GetBinWidth(w)/2,error);
    }else{
      gr->SetPoint(w, hdata->GetBinCenter(w),10);
    } 
  }

  
  
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  gr->GetHistogram()->SetMaximum(2);
  gr->GetHistogram()->SetMinimum(0.1);
  
  gStyle->SetTextSize(14);
  gROOT->ForceStyle();
  
  gr->GetXaxis()->SetLabelFont(43);
  gr->GetXaxis()->SetLabelSize(15);
  gr->GetYaxis()->SetLabelFont(43);
  gr->GetYaxis()->SetLabelSize(15);
  
  gr->GetXaxis()->SetLimits(-4,4);
  
  
  gPad->SetGrid();
  gStyle->SetStripDecimals(kTRUE);
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(0.7);
  
  
  gr->Draw("AZP");
  gr->GetXaxis()->SetTitle("#phi_{2}");
  gr->GetXaxis()->SetTitleSize(0.1);
  gr->GetYaxis()->SetTitleSize(0.1);
  gr->GetYaxis()->SetNdivisions(505);
 
  gr->GetXaxis()->SetTitleOffset(1);
  gr->GetYaxis()->SetTitle("Data/MC"); 
  gr->GetYaxis()->SetTitleOffset(0.4);
  gr->SetTitle(""); 
  smallPad->Update();
  TF1* line = new TF1("line","1",-4,4);
  line->SetLineColor(kRed);
  line->SetLineWidth(2);
  line->Draw("L same");
  gr->Draw("ZP SAME");
  

  if(pt1min==0 && pt2min == 0 && METmin == 0){
    c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/phi2.png");
    c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/phi2.pdf");
  }
  if(pt1min==0.65 && pt2min == 0.25){
    c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/phi2_optcuts_MET%.0lf.png",METmin));
    c1->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/phi2_optcuts_MET%.0lf.pdf",METmin));
  }
  


}
v8233pt_compare()
{
  gROOT->Reset();
  gROOT->SetStyle("MyStyle");
MyStyle->SetPadLeftMargin(0.25);
MyStyle->SetTitleOffset(4.5,"y");
//  gROOT->LoadMacro("v2pt_12cen_MyDef.C");
  // gROOT->LoadMacro("MyDef.C");
  gStyle->SetTextFont(43);
  gStyle->SetLabelFont(43,"x");
  gStyle->SetLabelFont(43,"y");
  gStyle->SetLabelFont(43,"z");
  gStyle->SetTitleFont(43,"x");
  gStyle->SetTitleFont(43,"y");
  gStyle->SetTitleFont(43,"z");
  gStyle->SetEndErrorSize(0);

  double textsize = 19;

//int   mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray};
int   mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray};
int   mcol2[4]={6,2,4,8};

//int   msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}};
int   msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}};


//float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1};
float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6};
float msiz2[4]={1.5,1.5,1.5,1.5};
//
// arrays
//
const int Mfiles=50;
int   ndp[Mfiles];
char *cfn[Mfiles];
char *cft[Mfiles];
const int Mpoints=40;
double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints];
double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints];
double nxa[Mfiles][Mpoints],nxe[Mfiles][Mpoints];
double nya[Mfiles][Mpoints],nye[Mfiles][Mpoints];

double aexl[Mfiles][Mpoints],aexh[Mfiles][Mpoints];
double aeyl[Mfiles][Mpoints],aeyh[Mfiles][Mpoints];



double ra[Mfiles][Mpoints],re[Mfiles][Mpoints];

const int Mpads=14;


char  *htit[Mpads];
char  *atit[Mpads][3];
double ptit[Mpads][2];
double hxmin[Mpads],hxmax[Mpads];
double hymin[Mpads],hymax[Mpads];
double lxmin[Mpads],lxmax[Mpads];
double lymin[Mpads],lymax[Mpads];


 
  //
  // Data input
  //
  char *cjob="v2pt_12cen_4x3";
  int i=-1;


  // histogram parameter
  htit[0]="0-5%";
  htit[1]="5-10%";
  htit[2]="10-15%";
  htit[3]="15-20%";
  htit[4]="20-25%";
  htit[5]="25-30%";
  htit[6]="30-35%";
  htit[7]="35-40%";
  htit[8]="40-50%";
  htit[9]="50-60%";
  htit[10]="60-70%";
  htit[11]="70-80%";
  for (int ip=0;ip<Mpads;ip++)
  {
    //  hxmin[ip]=0.0; hxmax[ip]=11.9;
    hxmin[ip]=0.0001; hxmax[ip]=10.8;
    hymin[ip]=0.0001; hymax[ip]=0.049;
    lxmin[ip]=0.08; lxmax[ip]=0.35;
    lymin[ip]=0.4; lymax[ip]=0.65;
    ptit[ip][0]=5.0; ptit[ip][1]=0.04;// position legends 
    atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{8}{#Psi_{233}}";
  }
  //
  // Read data and create vector files
  //

  double tmp;
  const int nw=12;
  const int npt=15;
  ifstream inEP;
  inEP.open("../../edec18trkQReCent_5020/outv8233_corrFlow.txt");
  for(int i=0; i<nw; i++){
      inEP>>tmp; inEP>>tmp;
    for(int j=0; j<npt+5; j++){
      inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j];
      xe[i][j]=0.0;
    }
  }
  inEP.close();

  ifstream inSP;
  inSP.open("../outv8233_corrFlow.txt");
  for(int i=0; i<nw; i++){
      inSP>>tmp; inSP>>tmp;
    for(int j=0; j<npt+5; j++){
      inSP>>tmp; inSP>>tmp; inSP>>nxa[i][j]; inSP>>tmp; inSP>>nya[i][j]; inSP>>nye[i][j];
      nxe[i][j]=0.0;
    }
  }
  inSP.close();


  TCanvas *can=new TCanvas("can","can",10,10,1050*0.9,800*0.85);

  can->Divide(4,3,0,0); //sticks the pads with no space inbetween 
  
  TH1D *h1[nw];
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);
    if(iw==3||iw==7||iw==11) gPad->SetRightMargin(0.02);
    char ch1[8];
    sprintf(ch1,"h1_%d",iw);
    h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]);
    h1[iw]->SetMinimum(hymin[iw]); h1[iw]->SetMaximum(hymax[iw]);
    h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle(atit[iw][1]);
    h1[iw]->GetXaxis()->CenterTitle(1);
    h1[iw]->GetYaxis()->CenterTitle(1);

    // futz with the axes
    h1[iw]->GetYaxis()->SetNdivisions(606);
    h1[iw]->GetXaxis()->SetNdivisions(606);

      h1[iw]->GetYaxis()->SetTitleSize(textsize);
      //h1[iw]->GetYaxis()->SetTitleOffset(3.5);
      h1[iw]->GetYaxis()->SetLabelSize(textsize);
      h1[iw]->GetXaxis()->SetTitleSize(textsize);
      h1[iw]->GetXaxis()->SetTitleOffset(3.0);
      h1[iw]->GetXaxis()->SetLabelSize(textsize);
     // h1[iw]->GetXaxis()->SetLabelOffset(1.2);

    h1[iw]->Draw();
  }
  //
  // Draw! 
  //
  cout << "Now Draw!" << endl;
  TGraphErrors *ge;
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);

    //
    if (iw==0)
    {
      tex=new TLatex(1.5,0.04,"CMS PbPb #sqrt{s_{NN}}=2.76TeV");
      tex->SetTextSize(textsize);
      //tex->Draw();
      tex=new TLatex(1.5,0.035,"|#eta|<2.4");
      tex->SetTextSize(textsize);
      tex->Draw();
    }
    if (iw < 4) tex=new TLatex(ptit[iw][0]+2,0.035,htit[iw]);
    else tex=new TLatex(ptit[iw][0],ptit[iw][1],htit[iw]);
    if ( iw == 0)   tex->SetTextSize(textsize);
    else if (iw == 8) tex->SetTextSize(textsize);
    else  tex->SetTextSize(textsize);
    tex->Draw();
    //
    // Legend
    //
    TLegend *leg = new TLegend(lxmin[iw],lymin[iw],lxmax[iw],lymax[iw]);
    leg->SetTextSize(textsize);
    //
    // Read data
    //
    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=1;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(19,&xa[j][0],&ya[j][0],&xe[j][0],&ye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(msty[im][1]);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"v_{8}{#Psi_{233}} 5.02 TeV","p");
    }
    if (iw==1) leg->Draw();

    for (int im=0;im<1;im++)
    {
      int j=im*12+iw;
      int col=2;
      //if (ndp[j]==0) continue;
      ge=new TGraphErrors(19,&nxa[j][0],&nya[j][0],&nxe[j][0],&nye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(25);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      ge->Draw("pe");
      leg->AddEntry(ge,"v_{8}{#Psi_{233}} 2.76 TeV","p");
    }

  }
  cout << "end of process" << endl;
  can->cd();
  can->Print("./figures/v8233_pt_10cen.png");
  can->Print("./figures/v8233_pt_10cen.pdf");
}
示例#4
0
int main(int argc, char** argv) {
  
  gROOT->SetStyle("Plain");
  gStyle->SetPalette(1);

  TApplication* theApp = new TApplication("example",&argc, argv);

  // load ntuple
  TChain *chain = new TChain ("myanalysis/EcalAnalysisTree","EcalAnalysisTree") ;
  //FIXME  EcalTreeContent treeVars;
  //  setBranchAddresses(chain, treeVars);  
  chain->Add("/gwpool/users/deguio/NTUPLES/SpikesCommissioning2010_GOODCOLL_May6_MERGED.root");   //dal run 134520: 7TeV phase 2

  int nEntries = (int)chain->GetEntries() ;
  cout << "FOUND " << nEntries  << " ENTRIES\n" << endl;;
  
 
  //ecalVariables variables
  unsigned int runId;
  unsigned int eventId;
  unsigned int eventNaiveId;
 
  int nEcalRecHits;
  float ecalRecHitType[100];
  float ecalRecHitEnergy[100];
  float ecalRecHitIEta[100];
  float ecalRecHitIPhi[100];
  float ecalRecHitTime[100];
  int ecalRecHitRawId[100];
  float ecalRecHitChi2[100];
  float ecalRecHitOutOfTimeChi2[100];
  int ecalRecHitRecoFlag[100];
  float ecalRecHitMatrixFlag[100][5][5];
  float ecalRecHitMatrix[100][5][5];
  float ecalRecHitR9[100];
  float ecalRecHitS4oS1[100];
  int ecalDigis[100][10];
  int ecalGainId[100][10];
  int techL1Bit[64];
  int algoL1Bit[128];

  // Set branch addresses.
  chain -> SetBranchAddress("runId",                     &runId);
  chain -> SetBranchAddress("eventId",                   &eventId);
  chain -> SetBranchAddress("eventNaiveId",              &eventNaiveId);
  chain -> SetBranchAddress("nEcalRecHits",              &nEcalRecHits);
  chain -> SetBranchAddress("ecalRecHitType",            ecalRecHitType);
  chain -> SetBranchAddress("ecalRecHitEnergy",          ecalRecHitEnergy);
  chain -> SetBranchAddress("ecalRecHitIEta",            ecalRecHitIEta);
  chain -> SetBranchAddress("ecalRecHitIPhi",            ecalRecHitIPhi);
  chain -> SetBranchAddress("ecalRecHitTime",            ecalRecHitTime);
  chain -> SetBranchAddress("ecalRecHitRawId",           ecalRecHitRawId);
  chain -> SetBranchAddress("ecalRecHitChi2",            ecalRecHitChi2);
  chain -> SetBranchAddress("ecalRecHitOutOfTimeChi2",   ecalRecHitOutOfTimeChi2);
  chain -> SetBranchAddress("ecalRecHitRecoFlag",        ecalRecHitRecoFlag);
  chain -> SetBranchAddress("ecalRecHitMatrixFlag",      ecalRecHitMatrixFlag);
  chain -> SetBranchAddress("ecalRecHitMatrix",          ecalRecHitMatrix);
  chain -> SetBranchAddress("ecalRecHitR9",              ecalRecHitR9);
  chain -> SetBranchAddress("ecalRecHitS4oS1",           ecalRecHitS4oS1);
  chain -> SetBranchAddress("ecalDigis",                 ecalDigis);
  chain -> SetBranchAddress("ecalGainId",                ecalGainId);
  chain -> SetBranchAddress("techL1Bit",                 techL1Bit);
  chain -> SetBranchAddress("algoL1Bit",                 algoL1Bit);

  
  char outfileName[100];
  sprintf(outfileName,"6May_fase_0ns.root");
  
  TFile* saving = new TFile (outfileName,"recreate") ;
  saving->mkdir("shapes");
  saving->cd ("shapes") ;

  TGraphErrors* gsample;

  char gname[100];
  char gnameCanvas[100];
  char gtitle[100];
  int ievt=0;  
  float EcalPhase;
  float tau = 43.;

  TH1F* spikeTime = new TH1F("spikeTime","spikeTime",100,-20.,20.);
  TH1F* goodTime = new TH1F("goodTime","goodTime",100,-20.,20);
  TH1F* spikeR9_goodDisc_Time = new TH1F("spikeR9_goodDisc_Time","spikeR9_goodDisc_Time",100,-20.,20);
  TH1F* goodR9_spikeDisc_Time = new TH1F("goodR9_spikeDisc_Time","goodR9_spikeDisc_Time",100,-20.,20);

  TH1F* deltaChi2 = new TH1F("deltaChi2","deltaChi2", 500, -50., 50.);
  TH1F* L_disc_spi = new TH1F("L_disc_spi","L_disc_spi", 200,0.,1.1);
  TH1F* L_disc_sci = new TH1F("L_disc_sci","L_disc_sci", 200,0.,1.1);

  TH2F* L_disc_vsTime_sci = new TH2F("L_disc_vsTime_sci","L_disc_vsTime_sci", 500,-50.,50.,110,0.,1.1);
  TH2F* L_disc_vsR9 = new TH2F("L_disc_vsR9","L_disc_vsR9", 110,0.,1.1,200,-0.5,1.5);
  TH2F* L_disc_vsTime_spi = new TH2F("L_disc_vsTime_spi","L_disc_vsTime_spi", 500,-50.,50.,110,0.,1.1);

  TH1F* sigmaIEtaIEtaDistr = new TH1F("sigmaIEtaIEtaDistr","sigmaIEtaIEtaDistr",10000.,0.,1000.);
  
  TGraph* eff = new TGraph;

  TGraph* effChi2;
  TGraph* effChi2OutOfTime;

  int nSpiTot = 0;
  int nSciTot = 0;
  int nSpiLdiscCut[100];
  int nSciLdiscCut[100];
  int nSpiChi2Cut[100];
  int nSciChi2Cut[100];
  int nSpiChi2OutOfTimeCut[100];
  int nSciChi2OutOfTimeCut[100];
  
  for (int count = 0; count < 100; ++count)
    {
      nSpiLdiscCut[count] = 0;
      nSciLdiscCut[count] = 0;
      nSpiChi2Cut[count] = 0;
      nSciChi2Cut[count] = 0;
      nSpiChi2OutOfTimeCut[count] = 0;
      nSciChi2OutOfTimeCut[count] = 0;
    }
  

  //loop over the events
  //for (int entry = 0 ; entry < nEntries; ++entry) {
  for (int entry = 0 ; entry < 150000; ++entry) {
    
    chain->GetEntry(entry) ;
    if (entry%10000==0) cout << "    Analyzing entry " << entry << endl;
    
    //only 0ns phase
    if (runId > 134520) continue;
    
    for (int ihit =0 ; ihit < nEcalRecHits; ihit++)
      {
	if (ecalRecHitEnergy[ihit] < 3. ) continue;      // E>3 GeV
	//if (ecalRecHitRecoFlag[ihit] == 2) continue;     // not outOfTime
	//if (fabs(ecalRecHitTime[ihit]) > 4.) continue;     // not outOfTime
	if (ecalRecHitType[ihit] != 0) continue;         // solo barrel
	
	bool goodcluster = true;  //tutti i cristalli intorno accesi e buoni!
	double e_5x5 = 0.;
	double meanDEta = 0;
	double meanDPhi = 0;
	for (int xx = 0; xx < 5; ++xx)
	  {
	    for (int yy = 0; yy < 5; ++yy)
	      {
		if((ecalRecHitMatrixFlag[ihit][xx][yy] > 2 && ecalRecHitMatrixFlag[ihit][xx][yy] != 10) || ecalRecHitMatrixFlag[ihit][xx][yy] == -9999 )
		  { 
		    goodcluster = false;
		    break;
		  }
		e_5x5 += ecalRecHitMatrix[ihit][xx][yy];
		meanDEta += ecalRecHitMatrix[ihit][xx][yy] * fabs(xx - 2);
		meanDPhi += ecalRecHitMatrix[ihit][xx][yy] * fabs(yy - 2);
	      }
	    if(goodcluster == false)
	      break;
	  }

	meanDEta /= e_5x5;
	meanDPhi /= e_5x5;
	
	// check gain switch
	bool gainSwitch = false;
	for (int isample = 0; isample < 10 ; isample++){
	  if ((isample > 0 && ecalGainId[ihit][isample] != ecalGainId[ihit][isample-1]) || ecalGainId[ihit][isample] !=1 ) 
	    {
	      gainSwitch = true;
	      break;
	    }
	}
	
	// select on beam activity and gain and goodquality
	if ((techL1Bit[40]+techL1Bit[41])==0) continue;
	if (gainSwitch) continue;    // reject pulses beyond G12
	if (goodcluster == false) continue;

	//if all good -> cluster shape eval	
	double numeratorIEtaIEta = 0;
	double numeratorIEtaIPhi = 0;
	double numeratorIPhiIPhi = 0;
	double denominator     = 0;
	for (int xx = 0; xx < 5; ++xx)
	  for (int yy = 0; yy < 5; ++yy)
	    {
	      double dEta = fabs(xx - 2) - meanDEta;

	      //double w = std::max(0.0, w0 + log(ecalRecHitMatrix[ihit][xx][yy] / e_5x5));
	      double w = std::max(0.0, log(ecalRecHitMatrix[ihit][xx][yy] / e_5x5));

	      denominator += w;
	      numeratorIEtaIEta += w * dEta*dEta;
	    }

	double covIEtaIEta = 0.01745*0.01745 * numeratorIEtaIEta / denominator;
	double sigmaIEtaIEta = sqrt(covIEtaIEta);

	sigmaIEtaIEtaDistr->Fill(sigmaIEtaIEta);

	// graphs
	gsample = new TGraphErrors();
	sprintf(gtitle,"shape_Run%d_Evt%d",runId,eventId );
	sprintf(gname,"shape_%d",ievt);
	gsample->SetName(gname);
	gsample->SetTitle(gtitle);
	
	float ped = (ecalDigis[ihit][0] + ecalDigis[ihit][1] + ecalDigis[ihit][2])/3;
	
	int imax = 0;
	int maxAmpl = 0;
	int ithr = 0;
	for (int isample = 0; isample < 10 ; isample++)
	  {
	    // cerca il primo sample sopra soglia per definire il range di FIT
	    if (ecalDigis[ihit][isample] >= ped+7.)
	      ithr = isample;
	    
	    if (ecalDigis[ihit][isample] >= maxAmpl) 
	      {
		imax = isample;
		maxAmpl = ecalDigis[ihit][isample] ;
	      }
	    gsample->SetPoint(isample, double(isample)*25.,ecalDigis[ihit][isample]);      
	    gsample->SetPointError(isample,0.,0.9);      
	  }
	
	
	//tengo solo se il primo sopra soglia e' il quarto o il quinto
	//if (ithr > 4 || ithr < 3) continue;
	
	// fit functions	    
	//Ecal Shape with FLOATING phase TB shape
	//TF1 *fpulseShape = new TF1("fpulseShape",pulseShape,ithr*25-5.,240.,3);
	TF1 *fpulseShape = new TF1("fpulseShape",pulseShape,0.,240.,3);
	fpulseShape->SetLineColor(3);
	if (ecalRecHitS4oS1[ihit]>0.95) fpulseShape->SetLineColor(2);
	fpulseShape->SetParName(0,"Ped");
	fpulseShape->SetParName(1,"A");
	fpulseShape->SetParName(2,"T0");
	fpulseShape->FixParameter(0,ped); // ped
	fpulseShape->SetParameter(1,maxAmpl - ped); // ampl
	fpulseShape->SetParameter(2,imax*25.); // T0
	//fpulseShape->SetParLimits(2,2*25., 7*25.); // T0 lim
	fpulseShape->SetParLimits(2,0*25., 10*25.); // T0 lim
	gsample->Fit("fpulseShape","QSR+") ;
	
	// electonic pulse
	TF1 *fSinglePulse = new TF1("fSinglePulse",abnormalShape,0.,240.,4);
	//TF1 *fSinglePulse = new TF1("fSinglePulse",abnormalShape,ithr*25-5.,240.,4);
	//TF1 *fSinglePulse = new TF1("fSinglePulse",spikeShape,ithr*25-5.,230.,4);  //marti - alessio
	fSinglePulse->SetLineColor(4);
	fSinglePulse->SetParName(0,"Ped");
	fSinglePulse->SetParName(1,"A");
	fSinglePulse->SetParName(2,"T0");
	fSinglePulse->SetParName(3,"tau");
	fSinglePulse->FixParameter(0,ped); // ped
	fSinglePulse->SetParameter(1,maxAmpl - ped);  // amp
	fSinglePulse->SetParameter(2,imax*25.- tau); // T0
	fSinglePulse->FixParameter(3,tau); // tau  = 40.5
	gsample->Fit("fSinglePulse","QSR+")    ;
	
	//minimo taglio di qualita' sul fit
	float bloodi_sci = TMath::Prob(fpulseShape->GetChisquare(),fpulseShape->GetNDF());
	float bloodi_spi = TMath::Prob(fSinglePulse->GetChisquare(),fSinglePulse->GetNDF());
	
	if(bloodi_sci <= 0.00 && bloodi_spi <= 0.00) continue;
	
	//provo a discriminare
	//chi2
	float chi2sci = fpulseShape->GetChisquare()/fpulseShape->GetNDF();
	float chi2spi = fSinglePulse->GetChisquare()/fSinglePulse->GetNDF();
	float deltachi2 = chi2spi-chi2sci; //if deltaChi2<0 -> spike
	
	
	
	//likelihood
	float Ldisc = 1./(1.+exp(-deltachi2/2.));
	
	if(bloodi_sci <= 0.00) Ldisc = -0.2;
	if(bloodi_spi <= 0.00) Ldisc = 1.2;
	
	
	deltaChi2->Fill(deltachi2);
	L_disc_vsR9->Fill(ecalRecHitR9[ihit],Ldisc);
	
	
	if(ecalRecHitS4oS1[ihit] > 0.95) 
	  {
	    ++nSpiTot;
	    L_disc_spi->Fill(Ldisc);
	    L_disc_vsTime_spi->Fill(ecalRecHitTime[ihit],Ldisc);
	  }
	else if (ecalRecHitS4oS1[ihit] < 0.80)
	  {
	    if (fabs(ecalRecHitTime[ihit]) > 4.) continue;     // not outOfTime FIXME
	    ++nSciTot;
	    L_disc_sci->Fill(Ldisc);
	    L_disc_vsTime_sci->Fill(ecalRecHitTime[ihit],Ldisc);
	  }
	
	for (int nn = 0; nn < 100; ++nn)
	  {
	    float discCut = (float)(nn+1)/100.;
	    if(Ldisc > discCut && ecalRecHitS4oS1[ihit] > 0.95) ++nSpiLdiscCut[nn];
	    if(Ldisc > discCut && ecalRecHitS4oS1[ihit] < 0.80) ++nSciLdiscCut[nn];
	    
	    float chi2Cut = (float)(nn+1) * 65/100.;
	    
	    if(ecalRecHitChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] > 0.95) ++nSpiChi2Cut[nn];
	    if(ecalRecHitOutOfTimeChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] > 0.95) ++nSpiChi2OutOfTimeCut[nn];
	    
	    
	    if(ecalRecHitChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] < 0.80) ++nSciChi2Cut[nn];
	    if(ecalRecHitOutOfTimeChi2[ihit] < chi2Cut && ecalRecHitS4oS1[ihit] > 0.80) ++nSciChi2OutOfTimeCut[nn];
	  }
	
	
	ievt++;
	
	delete gsample;
	delete fpulseShape;
	delete fSinglePulse;
	
      }//recHits
  }//event
  effChi2 = new TGraph();
  effChi2OutOfTime = new TGraph();
  
  //eff plots
  for (int nn = 0; nn < 100; ++nn)
    {
      eff->SetPoint(nn, (float)nSciLdiscCut[nn]/(float)nSciTot, 1. - (float)nSpiLdiscCut[nn]/(float)nSpiTot);
      
      effChi2->SetPoint(nn, (float)nSciChi2Cut[nn]/(float)nSciTot, 1. - (float)nSpiChi2Cut[nn]/(float)nSpiTot);
      effChi2OutOfTime->SetPoint(nn, (float)nSciChi2OutOfTimeCut[nn]/(float)nSciTot, 1. - (float)nSpiChi2OutOfTimeCut[nn]/(float)nSpiTot);
      
    }
  
  TCanvas* quadranti = new TCanvas("quadranti","quadranti");
  quadranti->Divide(2,2);
  
  quadranti->cd(1);
  goodTime->GetXaxis()->SetTitle("Time (ns)");
  goodTime->Draw();

  quadranti->cd(2);
  spikeR9_goodDisc_Time->GetXaxis()->SetTitle("Time (ns)");
  spikeR9_goodDisc_Time->Draw();

  quadranti->cd(3);
  goodR9_spikeDisc_Time->GetXaxis()->SetTitle("Time (ns)");
  goodR9_spikeDisc_Time->Draw();

  quadranti->cd(4);
  spikeTime->GetXaxis()->SetTitle("Time (ns)");
  spikeTime->Draw();

  goodTime->Write();
  spikeR9_goodDisc_Time->Write();
  goodR9_spikeDisc_Time->Write();
  spikeTime->Write();

  TCanvas* c1 = new TCanvas("L_disc_vsR9","L_disc_vsR9");
  L_disc_vsR9->GetXaxis()->SetTitle("R9");
  L_disc_vsR9->GetYaxis()->SetTitle("disc = #frac{1}{1 + L1/L2}");
  L_disc_vsR9->Draw("colz");

  TCanvas* c2 = new TCanvas("L_disc","L_disc");
  c2->SetLogy();
  c2->SetGridy();
  L_disc_spi->GetXaxis()->SetTitle("disc = #frac{1}{1 + L1/L2}");
  L_disc_spi->SetLineColor(2);
  //L_disc_sci->SetFillColor(2);  
  L_disc_spi->DrawNormalized();
  L_disc_sci->SetLineColor(3);
  //L_disc_sci->SetFillColor(3);  
  L_disc_sci->DrawNormalized("same");

  deltaChi2->Write();
  L_disc_vsR9->Write();
  L_disc_spi->Write();
  L_disc_sci->Write();


  saving->cd();
  effChi2->Write();
  effChi2OutOfTime->Write();

  sigmaIEtaIEtaDistr->Draw();
  sigmaIEtaIEtaDistr->Write();

  saving->Close () ;
  theApp->Run();
}
int postprocessing(int etaBin){

  // For looking at different systematic uncertainties independently
  bool flav = false;
  bool PU = false;
  bool PES = false;
  bool MC = false;
  bool JEC = true;

  TString etaString;   
  char pdfFile[100];

  TString path = "plots_2012/PF_L1CHS/";
  TString rootFiles;
  
  
  // Read the MC files and all systematic error files
  rootFiles.Form("mc/root_files_3sigma/Resolution_for_%i_eta_bin_PFCHS_mc.root",etaBin);
  TGraphErrors* JERMC = readTGraphErrors(path+rootFiles,"Graph;1","Graph;1");
  
  path = "plots_2012/PF_L1CHS/systematicUncertaintiesMC/";
  /*
  rootFiles.Form("JetPartonFlavorUncer/root_files/Resolution_for_%i_eta_bin_quark_PF_mc.root",etaBin);  
  TGraph* sysJetFlavorQuark = readTGraph(path+rootFiles,"Graph;1","Graph;1");   
  rootFiles.Form("JetPartonFlavorUncer/root_files/Resolution_for_%i_eta_bin_gluon_PF_mc.root",etaBin);  
  TGraph* sysJetFlavorGluon = readTGraph(path+rootFiles,"Graph;1","Graph;1");
 
  
  rootFiles.Form("PUuncertanties/root_files_data_le_10/Resolution_for_%i_eta_bin_PF_data.root",etaBin);  
  TGraph* sysJetPUle10 = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("PUuncertanties/root_files_data_gt_10_le_15/Resolution_for_%i_eta_bin_PF_data.root",etaBin);  
  TGraph* sysJetPUgt10 = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("PUuncertanties/root_files_data_gt_15_le_20/Resolution_for_%i_eta_bin_PF_data.root",etaBin);  
  TGraph* sysJetPUgt15 = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("PUuncertanties/root_files_data_gt_20/Resolution_for_%i_eta_bin_PF_data.root",etaBin);  
  TGraph* sysJetPUgt20 = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  */
  /*
  rootFiles.Form("plots_2012/PF_L1FastJet/mc/root_files/Resolution_for_%i_eta_bin_PUle10_PF_mc.root",etaBin);  
  TGraph* sysJetPUle10 = readTGraph(rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("plots_2012/PF_L1FastJet/mc/root_files/Resolution_for_%i_eta_bin_PUgt10le15_PF_mc.root",etaBin);  
  TGraph* sysJetPUgt10 = readTGraph(rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("plots_2012/PF_L1FastJet/mc/root_files/Resolution_for_%i_eta_bin_PUgt15le20_PF_mc.root",etaBin);  
  TGraph* sysJetPUgt15 = readTGraph(rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("plots_2012/PF_L1FastJet/mc/root_files/Resolution_for_%i_eta_bin_PUgt20_PF_mc.root",etaBin);  
  TGraph* sysJetPUgt20 = readTGraph(rootFiles,"Graph;1","Graph;1");
  */
  /*
  
  rootFiles.Form("ResImbUncertainties/root_files_lower_bound/Resolution_for_%i_eta_bin_PF_data.root",etaBin);  
  TGraph* sysMClow = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("ResImbUncertainties/root_files_upper_bound/Resolution_for_%i_eta_bin_PF_data.root",etaBin);    
  TGraph* sysMCup = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  */  
  rootFiles.Form("JECUncertainties/root_files_mc_lower_bound/Resolution_for_%i_eta_bin_PFCHS_mc.root",etaBin);    
  TGraphErrors* sysJEClow = readTGraphErrors(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("JECUncertainties/root_files_mc_upper_bound/Resolution_for_%i_eta_bin_PFCHS_mc.root",etaBin);    
  TGraphErrors* sysJECup = readTGraphErrors(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("PESUncertainties/root_files_mc_lower_bound/Resolution_for_%i_eta_bin_PFCHS_mc.root",etaBin);  
  TGraph* sysPESlow = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  rootFiles.Form("PESUncertainties/root_files_mc_upper_bound/Resolution_for_%i_eta_bin_PFCHS_mc.root",etaBin);  
  TGraph* sysPESup = readTGraph(path+rootFiles,"Graph;1","Graph;1");
  
  sprintf(pdfFile,"Resolution_for_%d_eta_bin_PF_data_mc_comparison.pdf",etaBin);
  if(etaBin == 1)      etaString = "Jet Energy Resolution for |#eta|<0.5";
  else if(etaBin == 2) etaString = "Jet Energy Resolution for 0.5<|#eta|<1.1";
  else if(etaBin == 3) etaString = "Jet Energy Resolution for 1.1<|#eta|<1.7";
  else if(etaBin == 4) etaString = "Jet Energy Resolution for 1.7<|#eta|<2.3";
  else if(etaBin == 5) etaString = "Jet Energy Resolution for 2.3<|#eta|<5.0";
  
  
 
  //const int numEntries = JERMC->GetN();
  cout<<endl<<"Number of entries in JERMC = "<<numEntries<<endl<<endl;
  
  
  double xMC[numEntries] = {0};
  double yMC[numEntries] = {0};
  double xMCError[numEntries] = {0};
  double yMCError[numEntries]  = {0};
  
   
  // loop over pt bins for every systematic uncertainty
  int idxMC = 0;
  for(int i=0; i<numEntries; i++){

    JERMC     -> GetPoint(i,xMC[idxMC],yMC[idxMC]);
    xMCError[idxMC] = JERMC -> GetErrorX(i);
    yMCError[idxMC] = JERMC -> GetErrorY(i);

    cout<<"xMC["<<idxMC<<"] = "<<xMC[idxMC]<<endl;
    cout<<"yMC["<<idxMC<<"] = "<<yMC[idxMC]<<endl;
    cout<<"xMCError["<<idxMC<<"] = "<<xMCError[idxMC]<<endl;
    cout<<"yMCError["<<idxMC<<"] = "<<yMCError[idxMC]<<endl;
    idxMC += 1;
  }
  cout<<endl;

  double xJECUp[numEntries] = {0};
  double yJECUp[numEntries] = {0};
  double xJECErrorUp[numEntries] = {0};
  double yJECErrorUp[numEntries] = {0};
  double xJECLow[numEntries] = {0};
  double yJECLow[numEntries] = {0};
  double xJECErrorLow[numEntries] = {0};
  double yJECErrorLow[numEntries] = {0};
  double yJECsysUp[numEntries] = {0};
  double yJECErrorsysUp[numEntries] = {0};
  double yJECsysLow[numEntries] = {0};
  double yJECErrorsysLow[numEntries] = {0};
  double sysUncertaintyJEC[numEntries] = {0};
  double sysUncertaintyJECError[numEntries] = {0};
  
    
  if(JEC){


    // Plot upper and lower uncertainty and compare if they are compatible
    for(int i=0; i<numEntries; i++){
      sysJECup  -> GetPoint(i,xJECUp[i],yJECUp[i]);
      sysJEClow -> GetPoint(i,xJECLow[i],yJECLow[i]);
   
      xJECErrorUp[i]  = sysJECup -> GetErrorX(i);
      yJECErrorUp[i]  = sysJECup -> GetErrorY(i);
      xJECErrorLow[i] = sysJEClow -> GetErrorX(i);
      yJECErrorLow[i]  = sysJEClow -> GetErrorY(i);

      cout<<"xJECUp["<<i<<"] = "<<xJECUp[i]<<endl;
      cout<<"xJECLow["<<i<<"] = "<<xJECLow[i]<<endl;  
      cout<<"xMC["<<i<<"] = "<<xMC[i]<<endl;     
      cout<<"yMC["<<i<<"] = "<<yMC[i]<<endl;
      cout<<"yJECUp["<<i<<"] = "<<yJECUp[i]<<endl;
      cout<<"yJECLow["<<i<<"] = "<<yJECLow[i]<<endl<<endl;

      // Calculate delta with JEC Res*(1+delta)
      yJECsysUp[i]  = std::abs(yJECUp[i]/yMC[i] - 1.);
      yJECsysLow[i] = std::abs(yJECLow[i]/yMC[i] - 1.);
      yJECErrorsysUp[i] = TMath::Sqrt(TMath::Power(1./yMC[i],2)*TMath::Power(yJECErrorUp[i],2));
      yJECErrorsysLow[i] = TMath::Sqrt(TMath::Power(1./yMC[i],2)*TMath::Power(yJECErrorLow[i],2));
      

      if(yJECsysUp[i] != yJECsysUp[i]) cout<<"yJECsysUp:  i = "<<i<<endl;
      if(yJECErrorsysUp[i] != yJECErrorsysUp[i]) cout<<"yJECErrorsysUp:  i = "<<i<<endl;
      if(yJECsysLow[i] != yJECsysLow[i]) cout<<"yJECsysLow:  i = "<<i<<endl;
      if(yJECErrorsysLow[i] != yJECErrorsysLow[i]) cout<<"yJECErrorsysLow:  i = "<<i<<endl;
      if(xMC[i] != xMC[i]) cout<<"xMC: i = "<<i<<endl;
      if(xMCError[i] != xMCError[i]) cout<<"xMCError: i = "<<i<<endl;


      //Calculate for every pt bin a symmetric error for JEC
      if((yJECUp[i]<yMC[i] && yJECLow[i]>yMC[i]) || (yJECUp[i]>yMC[i] && yJECLow[i]<yMC[i])){
	
	sysUncertaintyJEC[i] = (std::abs(yJECUp[i]-yJECLow[i])/2.)/yMC[i];
	sysUncertaintyJECError[i] = TMath::Sqrt(TMath::Power(1./(2.*yMC[i]),2)*(TMath::Power(yJECErrorUp[i],2)+TMath::Power(yJECErrorLow[i],2))+TMath::Power(std::abs(yJECUp[i]-yJECLow[i])/(2.*TMath::Power(yMC[i],2)),2)*TMath::Power(yMCError[i],2));
	cout<<"enclosing JER!"<<endl<<endl<<endl;
      }
      else{

	if(std::abs(1-yJECUp[i]/yMC[i]) > std::abs(1-yJECLow[i]/yMC[i])) {
	  sysUncertaintyJEC[i] = std::abs((yJECUp[i]-yMC[i])/2.)/yMC[i];
	  
	  sysUncertaintyJECError[i] = TMath::Sqrt(TMath::Power(1./(2.*yMC[i]),2)*TMath::Power(yJECErrorUp[i],2)+TMath::Power(yJECUp[i]/(2*TMath::Power(yMC[i],2)),2)*TMath::Power(yMCError[i],2));

	}
	else{
	  sysUncertaintyJEC[i] = std::abs((yJECLow[i]-yMC[i]))/2./yMC[i];
	  sysUncertaintyJECError[i] = TMath::Sqrt(TMath::Power(1./(2.*yMC[i]),2)*TMath::Power(yJECErrorLow[i],2)+TMath::Power(yJECLow[i]/(2*TMath::Power(yMC[i],2)),2)*TMath::Power(yMCError[i],2));

	}
	cout<<"NOT enclosing JER!"<<endl<<endl;

	cout<<"yMCError["<<i<<"] = "<<yMCError[i]<<endl;
	cout<<"yJECErrorUp["<<i<<"] = "<<yJECErrorUp[i]<<endl;
	cout<<"yJECErrorLow["<<i<<"] = "<<yJECErrorLow[i]<<endl<<endl<<endl<<endl;
      }
      
      cout<<"sysUncertaintyJECError[i] = "<<sysUncertaintyJECError[i]<<endl;
    }

    TCanvas *cJEC3 = new TCanvas("cJEC3",etaString,200,10,500,500);
    cJEC3 -> SetLeftMargin(0.17);
    cJEC3 -> cd();
    TGraphErrors* sysUncertaintyFinal = new TGraphErrors(numEntries,xJECUp,sysUncertaintyJEC,xJECErrorUp,sysUncertaintyJECError);
    TF1* f1 = new TF1("name","pol0",0,600);
    sysUncertaintyFinal -> Fit("name","");
    cout<<endl<<"chi2 = "<<f1 -> GetChisquare()<<endl<<endl; 
    sysUncertaintyFinal -> SetTitle("Final Relative JEC Uncertainty");
    sysUncertaintyFinal -> GetXaxis()->SetTitle("p_{T}^{#gamma}");
    sysUncertaintyFinal -> GetYaxis()->SetTitleOffset(1.5);
    sysUncertaintyFinal -> GetYaxis()->SetTitle("rel. Uncertainty");
    sysUncertaintyFinal -> SetMarkerStyle(22);
    sysUncertaintyFinal -> SetMaximum(0.1);
    sysUncertaintyFinal -> SetMarkerSize(1);
    sysUncertaintyFinal -> SetMarkerColor(1);
    sysUncertaintyFinal -> SetLineColor(1);
    sysUncertaintyFinal -> Draw("AP");

    TLatex*  info   = new TLatex();
    char legname[100] = {0};
    info->SetTextFont(132);
    info-> SetNDC();
    info->SetTextSize(0.040);
    sprintf(legname,"#splitline{#chi^{2} = %4.2f}{dof = %i}",f1 -> GetChisquare(),f1 -> GetNDF());
    info->DrawLatex(0.60,0.80,legname);
    
    delete info;
    info   = new TLatex();
    info->SetTextFont(132);
    info-> SetNDC();
    info->SetTextSize(0.040);
    sprintf(legname,"#splitline{sys Uncer. = %4.3f}{stat Error = %4.3f}",f1 -> GetParameter(0),f1 -> GetParError(0));
    info->DrawLatex(0.60,0.6,legname);
    
    
    TGraphErrors* JECsysUp = new TGraphErrors(numEntries,xJECUp,yJECsysUp,xJECErrorUp,yJECErrorsysUp);
    TGraphErrors* JECsysLow = new TGraphErrors(numEntries,xJECLow,yJECsysLow,xJECErrorLow,yJECErrorsysLow);

    TCanvas *cJEC = new TCanvas("cJEC",etaString,200,10,500,500);
    cJEC -> SetLeftMargin(0.17);
    cJEC -> cd();

    JECsysUp->SetTitle("JEC Uncertainty");
    JECsysUp->GetYaxis()->SetTitle("|JER(#pm #Delta)/JER - 1|");
    JECsysUp->GetYaxis()->SetTitleOffset(1.5);
    JECsysUp->GetXaxis()->SetTitle("photonPt");

    JECsysUp -> SetMarkerStyle(22);
    JECsysUp -> SetMarkerSize(1);
    JECsysUp -> SetMarkerColor(3);
    JECsysUp -> SetLineColor(3);
    JECsysUp -> Draw("AP");
    JECsysLow -> SetMarkerStyle(20);
    JECsysLow -> SetMarkerColor(2);
    JECsysLow -> SetLineColor(2);
    JECsysLow -> Draw("sameP");

    TLegend *legend  = new TLegend(0.6,0.8,0.9,0.9);
    legend -> SetFillColor(0);
    legend -> SetTextSize(0.033);
    legend -> AddEntry(JECsysUp,"JEC(1+#Delta)","l");
    legend -> AddEntry(JECsysLow,"JEC(1-#Delta)","l");
    legend -> Draw("same");
    sprintf(pdfFile,"Delta_JEC_Uncertainties_for_%d_eta_bin_PFCHS_mc.pdf",etaBin);
    cJEC->SaveAs(path + "JECUncertainties/plots_mc/" +pdfFile);

    TCanvas *cJEC2 = new TCanvas("cJEC2",etaString,200,10,500,500);
    cJEC2 -> SetLeftMargin(0.17);
    cJEC2 -> cd();

    JERMC -> GetFunction("fResolution") -> SetLineColor(1);
    JERMC->SetMarkerStyle(21);
    JERMC->SetMarkerSize(1);
    JERMC ->SetMinimum(0.04);
    JERMC->SetMaximum(0.11);
    JERMC->Draw("AP");
    sysJECup -> SetMarkerStyle(22);
    sysJECup -> SetMarkerColor(3);
    sysJECup -> SetLineColor(3);
    sysJECup -> GetFunction("fResolution") -> SetLineColor(3);
    sysJECup -> Draw("sameP");
    sysJEClow -> GetFunction("fResolution") -> SetLineColor(2);
    sysJEClow -> SetMarkerStyle(20);
    sysJEClow -> SetMarkerColor(2);
    sysJEClow -> SetLineColor(2);
    sysJEClow -> Draw("sameP");
    delete legend;
    legend  = new TLegend(0.6,0.8,0.9,0.9);
    legend -> SetFillColor(0);
    legend -> SetTextSize(0.033);
    legend -> AddEntry(JERMC,"JEC","l");
    legend -> AddEntry(sysJECup,"JEC(1+#Delta)","l");
    legend -> AddEntry(sysJEClow,"JEC(1-#Delta)","l");
    legend -> Draw("same");

    sprintf(pdfFile,"Resolutions_JEC_Uncertainties_for_%d_eta_bin_PFCHS_mc.pdf",etaBin);
    cJEC2->SaveAs(path + "JECUncertainties/plots_mc/" +pdfFile);


 
  }

  //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  // PES Uncertainty

  double xPESUp[numEntries] = {0};
  double yPESUp[numEntries] = {0};
  double xPESErrorUp[numEntries] = {0};
  double yPESErrorUp[numEntries] = {0};
  double xPESLow[numEntries] = {0};
  double yPESLow[numEntries] = {0};
  double xPESErrorLow[numEntries] = {0};
  double yPESErrorLow[numEntries] = {0};
  double yPESsysUp[numEntries] = {0};
  double yPESErrorsysUp[numEntries] = {0};
  double yPESsysLow[numEntries] = {0};
  double yPESErrorsysLow[numEntries] = {0};
  
    
  if(PES){


    // Plot upper and lower uncertainty and compare if they are compatible

    for(int i=0; i<numEntries; i++){
      sysPESup  -> GetPoint(i,xPESUp[i],yPESUp[i]);
      sysPESlow -> GetPoint(i,xPESLow[i],yPESLow[i]);
   
      xPESErrorUp[i]  = sysPESup -> GetErrorX(i);
      yPESErrorUp[i]  = sysPESup -> GetErrorY(i);
      xPESErrorLow[i] = sysPESlow -> GetErrorX(i);
      yPESErrorLow[i]  = sysPESlow -> GetErrorY(i);

      cout<<"xPESUp["<<i<<"] = "<<xPESUp[i]<<endl;
      cout<<"xPESLow["<<i<<"] = "<<xPESLow[i]<<endl;     
      cout<<"yMC["<<i<<"] = "<<yMC[i]<<endl;
      cout<<"yPESUp["<<i<<"] = "<<yPESUp[i]<<endl;
      cout<<"yPESLow["<<i<<"] = "<<yPESLow[i]<<endl<<endl;

      // Calculate delta with PES Res*(1+delta)
      yPESsysUp[i]  = std::abs(yPESUp[i]/yMC[i] - 1.);
      yPESsysLow[i] = std::abs(yPESLow[i]/yMC[i] - 1.);
      yPESErrorsysUp[i] = TMath::Sqrt(TMath::Power(1./yMC[i],2)*TMath::Power(yPESErrorUp[i],2));
      yPESErrorsysLow[i] = TMath::Sqrt(TMath::Power(1./yMC[i],2)*TMath::Power(yPESErrorLow[i],2));
      

      if(yPESsysUp[i] != yPESsysUp[i]) cout<<"yPESsysUp:  i = "<<i<<endl;
      if(yPESErrorsysUp[i] != yPESErrorsysUp[i]) cout<<"yPESErrorsysUp:  i = "<<i<<endl;
      if(yPESsysLow[i] != yPESsysLow[i]) cout<<"yPESsysLow:  i = "<<i<<endl;
      if(yPESErrorsysLow[i] != yPESErrorsysLow[i]) cout<<"yPESErrorsysLow:  i = "<<i<<endl;
      if(xMC[i] != xMC[i]) cout<<"xMC: i = "<<i<<endl;
      if(xMCError[i] != xMCError[i]) cout<<"xMCError: i = "<<i<<endl;
      

    }
    
    TGraphErrors* PESsysUp = new TGraphErrors(numEntries,xPESUp,yPESsysUp,xPESErrorUp,yPESErrorsysUp);
    TGraphErrors* PESsysLow = new TGraphErrors(numEntries,xPESLow,yPESsysLow,xPESErrorLow,yPESErrorsysLow);

    TCanvas *cPES = new TCanvas("cPES",etaString,200,10,500,500);
    cPES -> SetLeftMargin(0.17);
    cPES -> cd();

    PESsysUp->SetTitle("PES Uncertainty");
    PESsysUp->GetYaxis()->SetTitle("|JER(#pm #Delta)/JER - 1|");
    PESsysUp->GetYaxis()->SetTitleOffset(1.1);
    PESsysUp->GetXaxis()->SetTitle("photonPt");

    PESsysUp -> SetMarkerStyle(22);
    PESsysUp -> SetMarkerSize(1);
    PESsysUp -> SetMarkerColor(3);
    PESsysUp -> SetLineColor(3);
    PESsysUp -> Draw("AP");
    PESsysLow -> SetMarkerStyle(20);
    PESsysLow -> SetMarkerColor(2);
    PESsysLow -> SetLineColor(2);
    PESsysLow -> Draw("sameP");

    TLegend *legend  = new TLegend(0.6,0.8,0.9,0.9);
    legend -> SetFillColor(0);
    legend -> SetTextSize(0.033);
    legend -> AddEntry(PESsysUp,"PES(1+#Delta)","l");
    legend -> AddEntry(PESsysLow,"PES(1-#Delta)","l");
    legend -> Draw("same");
    sprintf(pdfFile,"Delta_PES_Uncertainties_for_%d_eta_bin_PFCHS_mc.pdf",etaBin);
    cPES->SaveAs(path + "PESUncertainties/plots_mc/" +pdfFile);

    TCanvas *cPES2 = new TCanvas("cPES2",etaString,200,10,500,500);
    cPES2 -> SetLeftMargin(0.17);
    cPES2 -> cd();

    JERMC -> GetFunction("fResolution") -> SetLineColor(1);
    JERMC->SetMarkerStyle(21);
    JERMC->SetMarkerSize(1);
    JERMC ->SetMinimum(0.05);
    JERMC->SetMaximum(0.13);
    JERMC->Draw("AP");
    sysPESup -> SetMarkerStyle(22);
    sysPESup -> SetMarkerColor(3);
    sysPESup -> SetLineColor(3);
    sysPESup -> GetFunction("fResolution") -> SetLineColor(3);
    sysPESup -> Draw("sameP");
    sysPESlow -> GetFunction("fResolution") -> SetLineColor(2);
    sysPESlow -> SetMarkerStyle(20);
    sysPESlow -> SetMarkerColor(2);
    sysPESlow -> SetLineColor(2);
    sysPESlow -> Draw("sameP");
    delete legend;
    legend  = new TLegend(0.6,0.8,0.9,0.9);
    legend -> SetFillColor(0);
    legend -> SetTextSize(0.033);
    legend -> AddEntry(JERMC,"PES","l");
    legend -> AddEntry(sysPESup,"PES(1+#Delta)","l");
    legend -> AddEntry(sysPESlow,"PES(1-#Delta)","l");
    legend -> Draw("same");

    sprintf(pdfFile,"Resolutions_PES_Uncertainties_for_%d_eta_bin_PFCHS_mc.pdf",etaBin);
    cPES2->SaveAs(path + "PESUncertainties/plots_mc/" +pdfFile);


 
  }
 
  return 0;
    /*
    //Plot

  // 5.) Symmetrize JEC uncertanty 
  
  idxData=0;
  idx1 = 0;
  idx2 = 0;
  while(idxData<numEntries){
    sysJECup -> GetPoint(idx1,xAux1,yAux1);
    sysJEClow -> GetPoint(idx2,xAux2,yAux2);
   
    cout<<"idx1 = "<<idx1<<endl;
    cout<<"idx2 = "<<idx2<<endl;
    cout<<"xJECup["<<idx1<<"] = "<<xAux1<<endl;
    cout<<"xJEClow["<<idx2<<"] = "<<xAux2<<endl;
    if(abs(xAux1-xAux2)/xAux1>0.1){
      if(xAux1>xAux2) idx2 += 1;
      else idx1 += 1;
      cout<<"Error JEC sys!!"<<endl;
      continue;
    }
    if(abs(xAux1-xData[idxData])/xData[idxData]<0.1){
      yJEC[idxData] = abs(yAux1-yAux2)/2.;
      cout<<"yJEC["<<idxData<<"] = "<<yJEC[idxData]<<endl;
      idxData += 1;
      idx1 += 1;
      idx2 += 1;
    }
    else if(abs(xAux1-xData[idxData])/xData[idxData]>0.1 && xAux1<xData[idxData]){
      idx1 += 1;
      idx2 += 1;
      continue;
    }
    else{
      cout<<"Error in JEC!!!!"<<endl;
      return 0;
    }
  }
  }
    

  //Calculate all systematic uncertainties (add in quadrature)
  for(int i=0; i<numEntries; i++){
    xSys[i] = 0;
    ySys[i] = sqrt(yPU[i]*yPU[i] + yErrorJetFlavor[i]*yErrorJetFlavor[i] +  yPES[i]*yPES[i] + yResImb[i]*yResImb[i] + yJEC[i]*yJEC[i]);
    cout<<endl<<"xData["<<i<<"] = "<<xData[i]<<endl;
    cout<<"yData["<<i<<"] = "<<yData[i]<<endl;
    cout<<"xSys["<<i<<"] = "<<xSys[i]<<endl;
    cout<<"ySys["<<i<<"] = "<<ySys[i]<<endl;
  }

   

  TGraphErrors* JERDataSys = new TGraphErrors(numEntries,xData,yData,xSys,ySys);
  TGraphErrors* JERMCSys   = new TGraphErrors(numEntries,xMC,yMC,xMCSys,yMCSys);

  

  // Plot resolution graph for one eta bin with sys error
  TCanvas *c = new TCanvas("c",etaString,200,10,500,500);
  c -> SetLeftMargin(0.17);
  c -> cd();
  
  //TMultiGraph* mg = new TMultiGraph();
  //mg -> SetTitle(etaString);


   //  Res_2012ABC->SetMarkerColor(kBlue-3);
   
  //Res_2012AB->SetXTitle("|#eta|");
  //Res_2012AB->GetXaxis()->SetRangeUser(0., 5.);
  //Res_2012AB->SetYTitle("Data/MC ratio (const fit)");
  //Res_2012AB->GetYaxis()->SetRangeUser(0.8, 1.5);
  //Res_2012AB->SetMarkerStyle(21);
  //Res_2012AB->SetMarkerSize(1.4);
  //Res_2012AB->SetLineColor(kPink-3);
  //Res_2012AB->SetMarkerColor(kPink-3);
  //Res_2012AB->Draw("e1p");

  if(PU && flav && PES && JEC && MC) etaString += " - all sys Uncertainties";
  if(PU && !flav && !PES && !JEC && !MC) etaString += " - only PU uncert.";
  if(!PU && flav && !PES && !JEC && !MC) etaString += " - only flavor uncert.";
  if(!PU && !flav && PES && !JEC && !MC) etaString += " - only PES uncert.";
  if(!PU && !flav && !PES && JEC && !MC) etaString += " - only JEC uncert.";
  if(!PU && !flav && !PES && !JEC && MC) etaString += " - only MC uncert.";

  JERData -> SetTitle(etaString);

  JERData -> GetXaxis() -> SetTitle("p_{T}^{#gamma}");
  JERData -> GetYaxis() -> SetTitleOffset(2.0); 
  JERData -> GetYaxis() -> SetTitle("JER");
  JERDataSys -> SetMinimum(-0.1);
  JERDataSys -> SetMaximum(0.3);   
  JERData -> SetMarkerStyle(20); 
  JERData->SetMarkerSize(1.4);
  JERData -> SetMinimum(-0.05);
  JERData -> SetMaximum(0.25);   
  //JERData -> SetMarkerColor(2); 
  //JERData -> SetLineColor(2); 
  JERDataSys->SetMarkerStyle(20);
  JERDataSys->SetMarkerSize(1.4);
  JERDataSys->SetFillColor(kGray);
  JERDataSys->SetFillStyle(3001);
  JERDataSys->SetLineColor(kGray);
  
  //JERDataSys -> Draw("a3");
  JERData -> Draw("AP"); 
  JERDataSys->DrawClone("e3p");
  JERData -> Draw("e1psame");  
  c -> SaveAs(pdfFile);

  //TLegend *legend  = new TLegend(0.6,0.8,0.9,0.9);
  //legend -> SetFillColor(0);
  //legend -> SetTextSize(0.033);
  //legend -> AddEntry(JERData,"Data","l");
  //legend -> AddEntry(JERMC,"MC","l");
  
  //mg -> Add(JERData);
  //mg -> Add(JERDataSys);
  //mg -> Draw("AP");
  
  //mg -> GetXaxis() -> SetTitle("p_{T}^{#gamma}");
  //mg -> GetYaxis() -> SetTitleOffset(2.0); 
  //mg -> GetYaxis()->SetLimits(-0.4,0.3); 
  //mg -> GetXaxis()->SetLimits(0.,600.);
  
  
  //mg -> GetYaxis() -> SetTitle("JER");
  //mg -> SetMinimum(-0.1);
  //mg -> SetMaximum(0.3);   
  
  //legend -> Draw("same");
  //c -> SaveAs(pdfFile);
  
  //return 0;
  // --------------------------------  Ratio Plot for Resolution  ----------------------------------------
  
  double *xRatio = new double[numEntries];
  double *yRatio = new double[numEntries];
  double *xRatioError = new double[numEntries];
  double *yRatioError = new double[numEntries];
  

  // Get points in MC
  idxData = 0;
  idx = 0;
  while(idxData<numEntries){
    
    JERMC   -> GetPoint(idx,xAux1,yAux1);
    
    if(abs(xAux1-xData[idxData])/xData[idxData]<0.1){
      xMC[idxData] = xAux1;
      yMC[idxData] = yAux1;
      xMCError[idxData] = JERMC -> GetErrorX(idx);
      yMCError[idxData] = JERMC -> GetErrorY(idx);
      cout<<"xMC["<<idxData<<"] = "<<xMC[idxData]<<endl;
      cout<<"yMC["<<idxData<<"] = "<<yMC[idxData]<<endl;
      idxData += 1;
    }

    idx += 1;
    
  }

  cout<<endl;
   
 
  for(int i=0; i<numEntries; i++){

    cout<<endl<<"xMC["<<i<<"] = "<<xMC[i]<<endl;
    cout<<"yMC["<<i<<"] = "<<yMC[i]<<endl;
    cout<<"yMCError["<<i<<"] = "<<yMCError[i]<<endl;
    cout<<"xData["<<i<<"] = "<<xData[i]<<endl;
    cout<<"yData["<<i<<"] = "<<yData[i]<<endl;
    cout<<"yDataError["<<i<<"] = "<<yDataError[i]<<endl;
  
    xRatio[i] = 1./2.*(xData[i] + xMC[i]);
    yRatio[i] = yData[i]/yMC[i];
    

    // Statistical Error
    xRatioError[i] = 1./2.*TMath::Sqrt(TMath::Power(xDataError[i],2)+TMath::Power(xMCError[i],2));
    yRatioError[i] = TMath::Sqrt(TMath::Power((1./yMC[i]),2)*TMath::Power(yDataError[i],2)+TMath::Power((yData[i]/(TMath::Power(yMC[i],2))),2)*TMath::Power(yMCError[i],2));
    
  }

  TString ratioName;

  //TGraphErrors *Ratio = new TGraphErrors(10,axcomp,aycomp,axcompError,aycompError);
  TGraphErrors *Ratio = new TGraphErrors(numEntries,xRatio,yRatio,xRatioError,yRatioError);
  Ratio -> GetXaxis()->SetLimits(0,600);
  if(etaBin == 1 )     ratioName = "Ratio between Data and MC for |#eta|<0.5";
  else if(etaBin == 2) ratioName = "Ratio between Data and MC for 0.5<|#eta|<1.1";
  else if(etaBin == 3) ratioName = "Ratio between Data and MC for 1.1<|#eta|<1.7";
  else if(etaBin == 4) ratioName = "Ratio between Data and MC for 1.7<|#eta|<2.3";
  else if(etaBin == 5) ratioName = "Ratio between Data and MC for 2.3<|#eta|<5.0";
 
  Ratio -> SetTitle(ratioName); 
  Ratio -> GetXaxis() -> SetTitle("Photon pT");
  Ratio -> GetXaxis() -> SetTitleOffset(1.1); 
  Ratio -> GetYaxis() -> SetTitle("Ratio of JER (DATA/MC)");
  Ratio -> GetYaxis() -> SetTitleOffset(1.2);   

  TF1* f1 = new TF1("name","pol0",0,600);   
  Ratio -> Fit("name","");
  cout<<"ChiSquare = "<<f1 -> GetChisquare()<<endl;
  TLegend *legend  = 0;
  legend = new TLegend(0.55,0.8,0.9,0.9);
  legend -> SetFillColor(0);
  char legname[100];
  double fitPar = f1 -> GetParameter(0);
  sprintf(legname," %4.3f #pm %4.3f", f1 -> GetParameter(0), f1->GetParError(0));
  legend -> SetHeader(legname);
  TCanvas *c11 = new TCanvas("c11",ratioName,200,10,500,500);
  c11 -> cd();
  Ratio -> SetMinimum(0.5);
  Ratio -> SetMaximum(2.0);
  

  // Draw info boxes
  Ratio  -> Draw("AP"); 
  legend -> Draw("same");
  TLatex*  info   = new TLatex();
  info->SetTextFont(132);
  info-> SetNDC();
  info->SetTextSize(0.035);
  sprintf(legname,"#splitline{#chi^{2} = %4.2f}{dof = %i}",f1 -> GetChisquare(),f1 -> GetNDF());
  info->DrawLatex(0.22,0.84,legname);
  
  sprintf(pdfFile,"Ratio_Resolution_for_%d_eta_bin_PF_data_comparison.pdf",etaBin);
  c11 -> SaveAs(pdfFile);

  //delete JERMC;
  //delete JERData;
  //delete f1;
  //delete Ratio;
  //-------------------------------------------------- Ratio Plot with systematic Uncertainties -------------------------------------------------------------------
  
  // Make the fit with all points moved by systematic uncertainties up / down
  double *yRatioUp = new double[numEntries];
  double *yRatioLow = new double[numEntries];
  double *yRatioErrorUp = new double[numEntries];
  double *yRatioErrorLow = new double[numEntries];

  for(int i=0; i<numEntries; i++){

    yRatioUp[i] = (yData[i] + ySys[i])/yMC[i];
    yRatioLow[i] = (yData[i] - ySys[i])/yMC[i];

    // Statistical Error
    xRatioError[i] = 1./2.*TMath::Sqrt(TMath::Power(xDataError[i],2)+TMath::Power(xMCError[i],2));
    yRatioError[i] = TMath::Sqrt(TMath::Power((1./yMC[i]),2)*TMath::Power(yDataError[i],2)+TMath::Power((yData[i]/(TMath::Power(yMC[i],2))),2)*TMath::Power(yMCError[i],2));
    yRatioErrorUp[i] = TMath::Sqrt(TMath::Power((1./yMC[i]),2)*TMath::Power(yDataError[i],2)+TMath::Power(((yData[i]-ySys[i])/(TMath::Power(yMC[i],2))),2)*TMath::Power(yMCError[i],2));
    yRatioErrorLow[i] = TMath::Sqrt(TMath::Power((1./yMC[i]),2)*TMath::Power(yDataError[i],2)+TMath::Power(((yData[i]-ySys[i])/(TMath::Power(yMC[i],2))),2)*TMath::Power(yMCError[i],2));

  }

  TGraphErrors *RatioUp = new TGraphErrors(numEntries,xRatio,yRatioUp,xRatioError,yRatioErrorUp);
  TGraphErrors *RatioLow = new TGraphErrors(numEntries,xRatio,yRatioLow,xRatioError,yRatioErrorLow);
      
  RatioUp -> Fit("name","");
  double fitParUp = f1->GetParameter(0);
  cout<<"fitParUp = "<<fitParUp<<endl;
  RatioLow -> Fit("name","");
  double fitParLow = f1->GetParameter(0);
  cout<<"fitParLow = "<<fitParLow<<endl;

  double *x = new double[numEntries];
  double *y = new double[numEntries];
  double *exl = new double[numEntries];
  double *exh = new double[numEntries];
  double *eyl = new double[numEntries];
  double *eyh = new double[numEntries];

  for(int i=0; i<numEntries; i++){
    x[i] = xRatio[i];
    y[i] = fitPar;
    exl[i] = 0;
    exh[i] = 0;
    eyl[i] = fitPar-fitParLow;
    eyh[i] = fitParUp-fitPar;

  }
  cout<<endl<<"sys ERROR = "<<(fitParUp-fitParLow)/fitPar<<endl;

  TGraphAsymmErrors *sysBorders = new TGraphAsymmErrors(numEntries,x,y,exl,exh,eyl,eyh);
  TCanvas *c12 = new TCanvas("c12",ratioName,200,10,500,500);
  c12 -> cd();
  Ratio -> SetMinimum(0.6);
  Ratio -> SetMaximum(1.3);
  sysBorders ->SetMarkerStyle(20);
  sysBorders ->SetMarkerSize(1.4);
  sysBorders ->SetFillColor(kGray);
  sysBorders ->SetFillStyle(3001);
  sysBorders ->SetLineColor(kGray);

  Ratio  -> Draw("AP"); 
  sysBorders ->DrawClone("e3");  
 
  sprintf(pdfFile,"Ratio_Resolution_for_%d_eta_bin_PF_data_comparison_With_Sys_Uncert.pdf",etaBin);
  c12 -> SaveAs(pdfFile);

  return 0;
    */
}
示例#6
0
void DeltaPhi(double pt1_cutIN,double pt2_cutIN,double MET_cutIN, double DPHI_cutIN){
  cout<<"#### DeltaPhi(MET,H) #####"<<endl;


 

  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  TLegend* leg = new TLegend(0.13,0.6,0.67,0.87);
  leg->SetNColumns(2);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  TLegend* leg_norm = new TLegend(0.20,0.5,0.74,0.87);
  leg_norm->SetNColumns(2);
  leg_norm->SetBorderSize(0);
leg_norm->SetFillStyle(0);


 TCanvas *c1 = new TCanvas("c1","",500,600);
 TPad *mainPad = new TPad("mainPad","",0,0.3,1,1);
 TPad *smallPad = new TPad("smallPad","",0,0.05,1,0.3);
 mainPad->SetBottomMargin(0.015);

 
 smallPad->SetTopMargin(0.05);
 smallPad->SetBottomMargin(0.25);
 
 c1->cd();
 
 mainPad->Draw();
 mainPad->cd();
 TCut mggmax = "mgg<180";
 TCut mggmin = "mgg>100";
 TCut mggblind = "((mgg<115)||(mgg>135))";
 TCut eveto1 = "eleveto1 == 1";
 TCut eveto2 = "eleveto2 == 1";
 TCut eveto = eveto1 && eveto2;
 TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))";  
  TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))";  
  TCut pt1cut = Form("pt1/mgg>%lf",pt1_cutIN);
  TCut pt2cut = Form("pt2/mgg>%lf",pt2_cutIN);  
  TCut METcutD = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1)>%lf",MET_cutIN);  
  TCut METcut = Form("t1pfmetCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0)>%lf",MET_cutIN);  
  TCut DPHIcut = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>%lf",DPHI_cutIN);  
  TCut DPHIcutD = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>%lf",DPHI_cutIN);  
 
  
 

  TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ");  
  TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ");
  TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ");
  TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ");
  TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ");
  TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ");  
  TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ");  
  TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ");  

 
  TFile *bkg1 =  TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ");  
  TFile *bkg2 =  TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ");  
  TFile *bkg3 =  TFile::Open("./25ns_2246inv_v3/GJets.root","READ");  
  TFile *bkg4 =  TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ");  
  TFile *bkg5 =  TFile::Open("./25ns_2246inv_v3/QCD.root","READ");  
  TFile *bkg6 =  TFile::Open("./25ns_2246inv_v3/VH.root","READ");  
  TFile *bkg7 =  TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ");
  TFile *bkg8 =  TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ");
  TFile *bkg9 =  TFile::Open("./25ns_2246inv_v3/TGJets.root","READ");
  TFile *bkg10 =  TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ");
  TFile *bkg11 =  TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ");
  TFile *bkg12 =  TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ");

  cout<<"check1"<<endl; 

 
  TTree *tree_data = (TTree*) data->Get("DiPhotonTree");
  
  TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree");
  TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree");
  TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree");
  TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree");
  TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree");
  TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree");
  TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree");
  
  
  TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree");
  TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree");
  TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree");
  TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree");
  TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree");
  TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree");
  TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree");
  TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree");
  TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree");
  TTree *tree_bkg10= (TTree*) bkg10->Get("DiPhotonTree");
  TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree");
  TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree");


  cout<<"check2"<<endl; 

  
  
  tree_data->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,1))>>hdata(15,0,3.5)",(mggmax && mggmin && metF && eveto && pt1cut && pt2cut && METcutD&& DPHIcutD));
  TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata");
  hdata->SetMarkerColor(kBlack);
  hdata->SetMarkerStyle(20);
  hdata->SetLineColor(kBlack);
    
 
 
  
  tree_sig1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1");
  tree_sig2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2");
  tree_sig3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3");
  tree_sig4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4");
  tree_sig5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5");
  tree_sig6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6");
  tree_sig7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7");
 
  tree_bkg1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1");
  tree_bkg2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2");
  tree_bkg3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3");
  tree_bkg4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4");
  tree_bkg5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5");
  tree_bkg6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));   //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6");
  tree_bkg7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples   
   TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7");
    tree_bkg8->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8");
   tree_bkg9->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9");
   tree_bkg10->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10");
   tree_bkg11->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11");
   tree_bkg12->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12(15,0,3.5)","weight*(weight>0.)"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12");

 
   cout<<"check3"<<endl; 


  /*  h1->Scale(0.00009338);
  h2->Scale(0.00010348);
  h3->Scale(0.00008394);
  h4->Scale(0.00006352);
  h5->Scale(0.00004712);
  h6->Scale(0.00003020);
  h7->Scale(0.00000972);
  */


  h1->SetLineColor(kRed+3);
  h2->SetLineColor(kRed+1);
  h3->SetLineColor(kRed);
  h4->SetLineColor(kPink+2);
  h5->SetLineColor(kPink+4); //only for 15ns samples
  h6->SetLineColor(kPink+7); //only for 15ns samples
  h7->SetLineColor(kMagenta+2); //only for 15ns samples
  h1->SetLineWidth(2);
  h2->SetLineWidth(2);
  h3->SetLineWidth(2);
  h4->SetLineWidth(2);
  h5->SetLineWidth(2); //only for 15ns samples
  h6->SetLineWidth(2); //only for 15ns samples
  h7->SetLineWidth(2); //only for 15ns samples
  
  





  
  
   THStack *hs=new THStack("hs","");

   hbkg7->SetFillColor(kGreen+2);
   hbkg6->SetFillColor(kGreen);
   hbkg8->SetFillColor(kYellow);
   hbkg4->SetFillColor(kOrange);
   hbkg9->SetFillColor(kOrange+7);
   hbkg10->SetFillColor(kOrange+4);
   hbkg11->SetFillColor(kCyan);
   hbkg12->SetFillColor(kCyan+1);
   hbkg5->SetFillColor(kBlue+2);
   hbkg2->SetFillColor(kBlue);
   hbkg3->SetFillColor(kMagenta-2);
   hbkg1->SetFillColor(kViolet);


 


  hbkg1->SetLineColor(kBlack);
  hbkg2->SetLineColor(kBlack);
  hbkg3->SetLineColor(kBlack);
  hbkg4->SetLineColor(kBlack);
  hbkg5->SetLineColor(kBlack);
  hbkg6->SetLineColor(kBlack);
  hbkg7->SetLineColor(kBlack);
  hbkg8->SetLineColor(kBlack);
  hbkg9->SetLineColor(kBlack);
  hbkg10->SetLineColor(kBlack);
  hbkg11->SetLineColor(kBlack);
  hbkg12->SetLineColor(kBlack);
  

  hs->Add(hbkg7);
  hs->Add(hbkg6);
  hs->Add(hbkg8);
  hs->Add(hbkg4);
  hs->Add(hbkg9);
  hs->Add(hbkg10);
  hs->Add(hbkg11);
  hs->Add(hbkg12);
  hs->Add(hbkg2);
  hs->Add(hbkg5);
  hs->Add(hbkg3);
  hs->Add(hbkg1);


  cout<<"check4"<<endl;  

    TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); 
  hsum->Add(hbkg2);
  hsum->Add(hbkg3);
  hsum->Add(hbkg4);
  hsum->Add(hbkg9);
  hsum->Add(hbkg10);
  hsum->Add(hbkg11);
  hsum->Add(hbkg12);
  hsum->Add(hbkg5);
  hsum->Add(hbkg6);
  hsum->Add(hbkg7);
  hsum->Add(hbkg8);
  hdata->SetMaximum(5000);
  // hs->SetMinimum(0.0001);
  hdata->SetTitle("");
  hdata->Draw("e1"); 

  hsum->SetMarkerStyle(1);
  hsum->SetFillColor(kGray+3);
  hsum->SetFillStyle(3002);
  
  hs->Draw("same hist");
  hsum->Draw("same e2");
  h2->Draw("same hist");
  h3->Draw("same hist"); 
  h4->Draw("same hist");
  h1->Draw("same hist");
  h5->Draw("same hist"); //only for 15ns samples
  h6->Draw("same hist"); //only for 15ns samples
  h7->Draw("same hist"); //only for 15ns samples
  hdata->Draw("same e1");  
  

  hdata->GetXaxis()->SetLabelOffset(999);
  hdata->GetYaxis()->SetTitle("Events/0.4");
 

  hdata->GetYaxis()->SetTitleOffset(1.6);
  hdata->GetYaxis()->SetTitle("Events/0.23 GeV");  
  gPad->Modified();
  
  
  
  /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l");
    leg->AddEntry(h2,"m_{#chi} = 10 GeV","l");
    leg->AddEntry(h3,"m_{#chi} = 100 GeV","l");      
    leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/
 leg->AddEntry(hdata,"Data","elp");
 // leg->AddEntry(h1,"m_{Z'} = 600 GeV","l");
  leg->AddEntry(hbkg1,"#gamma #gamma","f");         
  //  leg->AddEntry(h2,"m_{Z'} = 800 GeV","l");
  leg->AddEntry(hbkg2,"Drell Yann","f");       
  // leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l");      
  leg->AddEntry(hbkg3,"#gamma + Jets","f");      
  // leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l");     
  leg->AddEntry(hbkg5,"QCD","f");    
  // leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 15ns samples    
    leg->AddEntry(hbkg4,"ggH","f");      
    // leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 15ns samples    
  leg->AddEntry(hbkg6,"VH","f");  
  // leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples      
  leg->AddEntry(hbkg7,"ttH","f");  
  leg->AddEntry(hbkg8,"VBF H","f");  
  leg->AddEntry(hbkg9,"t + #gamma + Jets","f");  
  leg->AddEntry(hbkg10,"tt + #gamma +Jets","f");  
  leg->AddEntry(hbkg11,"#gamma+W","f");  
  leg->AddEntry(hbkg12,"#gamma+Z","f");  
  leg->AddEntry(hsum,"Bkg uncertainty","f");
  leg->Draw("same");
  
 cout<<"check5"<<endl; 

  gStyle->SetOptStat(0);  
  
  c1->cd();
  smallPad->Draw();
  smallPad->cd();

  TGraphErrors *gr = new TGraphErrors(0);
  double integralData=hdata->Integral();
  double integralBKG=hsum->Integral();
  double error, ratio;
  for(int w=1; w<15; w++){
    if((hdata->GetBinContent(w)!=0) && (hsum->GetBinContent(w)!=0)){

      gr->SetPoint(w, hdata->GetBinCenter(w),(hdata->GetBinContent(w))/(hsum->GetBinContent(w)));
      ratio= (hdata->GetBinContent(w))/(hsum->GetBinContent(w));
      error= (hdata->GetBinContent(w)*sqrt(hsum->GetBinContent(w))/(hsum->GetBinContent(w)*hsum->GetBinContent(w)) + sqrt(hdata->GetBinContent(w))/hsum->GetBinContent(w));
      std::cout<<"VALUE: "<<ratio<<" ERROR: "<<error<<std::endl;
      gr->SetPointError(w, hdata->GetBinWidth(w)/2,error);
    }else{
      gr->SetPoint(w, hdata->GetBinCenter(w),10);
    }
  }



  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  gr->GetHistogram()->SetMaximum(2);
  gr->GetHistogram()->SetMinimum(0.1);

  gStyle->SetTextSize(14);
  gROOT->ForceStyle();

  gr->GetXaxis()->SetLabelFont(43);
  gr->GetXaxis()->SetLabelSize(15);
  gr->GetYaxis()->SetLabelFont(43);
  gr->GetYaxis()->SetLabelSize(15);

  gr->GetXaxis()->SetLimits(0,3.5);
  gPad->SetGrid();
  gStyle->SetStripDecimals(kTRUE);
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(0.7);


  gr->Draw("AZP");
  gr->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E^{miss}_{T})|");
  gr->GetXaxis()->SetTitleSize(0.1);
  gr->GetYaxis()->SetTitleSize(0.1);
  gr->GetYaxis()->SetNdivisions(505);

  gr->GetXaxis()->SetTitleOffset(1);
  gr->GetYaxis()->SetTitle("Data/MC");
  gr->GetYaxis()->SetTitleOffset(0.4);
  gr->SetTitle("");
  smallPad->Update();
  TF1* line = new TF1("line","1",0,3.5);
  line->SetLineColor(kRed);
  line->SetLineWidth(2);
  line->Draw("L same");
  gr->Draw("ZP SAME");

 

TCanvas *c2 = new TCanvas("c2","",500,500);
    

  tree_sig1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h1_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h1_norm =(TH1F*)gPad->GetPrimitive("h1_norm");
  tree_sig2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h2_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h2_norm =(TH1F*)gPad->GetPrimitive("h2_norm");
  tree_sig3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h3_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h3_norm =(TH1F*)gPad->GetPrimitive("h3_norm");
  tree_sig4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h4_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h4_norm =(TH1F*)gPad->GetPrimitive("h4_norm");
  tree_sig5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h5_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h5_norm =(TH1F*)gPad->GetPrimitive("h5_norm");
  tree_sig6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h6_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h6_norm =(TH1F*)gPad->GetPrimitive("h6_norm");
  tree_sig7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>h7_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h7_norm =(TH1F*)gPad->GetPrimitive("h7_norm");
  




  tree_bkg1->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg1_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg1_norm =(TH1F*)gPad->GetPrimitive("hbkg1_norm");
  tree_bkg2->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg2_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg2_norm =(TH1F*)gPad->GetPrimitive("hbkg2_norm");
  tree_bkg3->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg3_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg3_norm =(TH1F*)gPad->GetPrimitive("hbkg3_norm");
  tree_bkg4->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg4_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg4_norm =(TH1F*)gPad->GetPrimitive("hbkg4_norm");
  tree_bkg5->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg5_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg5_norm =(TH1F*)gPad->GetPrimitive("hbkg5_norm");
  tree_bkg6->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg6_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));   //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg6_norm =(TH1F*)gPad->GetPrimitive("hbkg6_norm");
  tree_bkg7->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg7_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples   
   TH1F *hbkg7_norm =(TH1F*)gPad->GetPrimitive("hbkg7_norm");
    tree_bkg8->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg8_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg8_norm =(TH1F*)gPad->GetPrimitive("hbkg8_norm");
   tree_bkg9->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg9_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg9_norm =(TH1F*)gPad->GetPrimitive("hbkg9_norm");
   tree_bkg10->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg10_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg10_norm =(TH1F*)gPad->GetPrimitive("hbkg10_norm");
   tree_bkg11->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg11_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg11_norm =(TH1F*)gPad->GetPrimitive("hbkg11_norm");
   tree_bkg12->Draw("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhiCorr(t1pfmet,t1pfmetPhi,t1pfmetSumEt,0))>>hbkg12_norm(15,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg12_norm =(TH1F*)gPad->GetPrimitive("hbkg12_norm");


   for(int i = 0; i<26;i++){
     if(hbkg1_norm->GetBinContent(i) < 0.) hbkg1_norm->SetBinContent(i,0.);
     if(hbkg2_norm->GetBinContent(i) < 0.) hbkg2_norm->SetBinContent(i,0.);
     if(hbkg3_norm->GetBinContent(i) < 0.) hbkg3_norm->SetBinContent(i,0.);
     if(hbkg4_norm->GetBinContent(i) < 0.) hbkg4_norm->SetBinContent(i,0.);
     if(hbkg5_norm->GetBinContent(i) < 0.) hbkg5_norm->SetBinContent(i,0.);
     if(hbkg6_norm->GetBinContent(i) < 0.) hbkg6_norm->SetBinContent(i,0.);
     if(hbkg7_norm->GetBinContent(i) < 0.) hbkg7_norm->SetBinContent(i,0.);
     if(hbkg8_norm->GetBinContent(i) < 0.) hbkg8_norm->SetBinContent(i,0.);
     if(hbkg9_norm->GetBinContent(i) < 0.) hbkg9_norm->SetBinContent(i,0.);
     if(hbkg10_norm->GetBinContent(i) < 0.) hbkg10_norm->SetBinContent(i,0.);
     if(hbkg11_norm->GetBinContent(i) < 0.) hbkg11_norm->SetBinContent(i,0.);
     if(hbkg12_norm->GetBinContent(i) < 0.) hbkg12_norm->SetBinContent(i,0.);
   }




  double norm = 1./h1_norm->Integral();
  h1_norm->Scale(norm);
  norm = 1./h2_norm->Integral();
  h2_norm->Scale(norm);
  norm = 1./h3_norm->Integral();
  h3_norm->Scale(norm);
  norm = 1./h4_norm->Integral();
  h4_norm->Scale(norm);  
  norm = 1./h5_norm->Integral(); //only for 50ns samples
  h5_norm->Scale(norm);  //only for 50ns samples
  norm = 1./h6_norm->Integral(); //only for 50ns samples
  h6_norm->Scale(norm);  //only for 50ns samples
  norm = 1./h7_norm->Integral(); //only for 50ns samples
  h7_norm->Scale(norm);  //only for 50ns samples
  


  norm = 1./hbkg1_norm->Integral();
  hbkg1_norm->Scale(norm);  
  norm = 1./hbkg2_norm->Integral();
  hbkg2_norm->Scale(norm);  
  norm = 1./hbkg3_norm->Integral();
  hbkg3_norm->Scale(norm);  
  norm = 1./hbkg4_norm->Integral();
  hbkg4_norm->Scale(norm);  
  norm = 1./hbkg5_norm->Integral();
  hbkg5_norm->Scale(norm);  
  norm = 1./hbkg6_norm->Integral();
  hbkg6_norm->Scale(norm);  
  norm = 1./hbkg7_norm->Integral();
  hbkg7_norm->Scale(norm);  
  norm = 1./hbkg8_norm->Integral();
  hbkg8_norm->Scale(norm);  
  norm = 1./hbkg9_norm->Integral();
  hbkg9_norm->Scale(norm);  
  norm = 1./hbkg10_norm->Integral();
  hbkg10_norm->Scale(norm);  
  norm = 1./hbkg11_norm->Integral();
  hbkg11_norm->Scale(norm);  
  norm = 1./hbkg12_norm->Integral();
  hbkg12_norm->Scale(norm);  
  
  
  h1_norm->SetLineColor(kRed+3);
  h2_norm->SetLineColor(kRed+1);
  h3_norm->SetLineColor(kRed);
  h4_norm->SetLineColor(kPink+2);
  h5_norm->SetLineColor(kPink+4); //only for 25ns samples
  h6_norm->SetLineColor(kPink+7); //only for 25ns samples
  h7_norm->SetLineColor(kMagenta+2); //only for 25ns samples
  h1_norm->SetLineWidth(2);
  h2_norm->SetLineWidth(2);
  h3_norm->SetLineWidth(2);
  h4_norm->SetLineWidth(2);
  h5_norm->SetLineWidth(2); //only for 25ns samples
  h6_norm->SetLineWidth(2); //only for 25ns samples
  h7_norm->SetLineWidth(2); //only for 25ns samples



  hbkg7_norm->SetLineColor(kGreen+2);
  hbkg6_norm->SetLineColor(kGreen);
  hbkg8_norm->SetLineColor(kYellow);
  hbkg4_norm->SetLineColor(kOrange);
  hbkg9_norm->SetLineColor(kOrange+7);
  hbkg10_norm->SetLineColor(kOrange+4);
  hbkg11_norm->SetLineColor(kCyan);
  hbkg12_norm->SetLineColor(kCyan+1);
  hbkg5_norm->SetLineColor(kBlue+3);
  hbkg2_norm->SetLineColor(kBlue);
  hbkg3_norm->SetLineColor(kMagenta-2);
  hbkg1_norm->SetLineColor(kViolet);

 
 
 
  
  
  hbkg1_norm->SetFillStyle(0);
  hbkg2_norm->SetFillStyle(0);
  hbkg3_norm->SetFillStyle(0);
  hbkg4_norm->SetFillStyle(0);
  hbkg5_norm->SetFillStyle(0);
  hbkg6_norm->SetFillStyle(0);
  hbkg7_norm->SetFillStyle(0); 
  hbkg8_norm->SetFillStyle(0);
  hbkg9_norm->SetFillStyle(0);
  hbkg10_norm->SetFillStyle(0);
  hbkg11_norm->SetFillStyle(0);
  hbkg12_norm->SetFillStyle(0);
  
  
   
  h1_norm->SetTitle("");
  
  h1_norm->SetMaximum(1);  
  h1_norm->SetMinimum(0.001);  
  h1_norm->Draw("HIST"); 
  
  hbkg1_norm->Draw("same HIST");  
  hbkg2_norm->Draw("same HIST"); 
  hbkg3_norm->Draw("same HIST"); 
  hbkg5_norm->Draw("same HIST"); 
  hbkg4_norm->Draw("same HIST"); 
  hbkg6_norm->Draw("same HIST"); 
  hbkg7_norm->Draw("same HIST"); 
  hbkg8_norm->Draw("same HIST"); 
  hbkg9_norm->Draw("same HIST"); 
  hbkg10_norm->Draw("same HIST"); 
  hbkg11_norm->Draw("same HIST"); 
  hbkg12_norm->Draw("same HIST"); 
  h1_norm->Draw("same hist"); 
  h2_norm->Draw("same hist");
  h3_norm->Draw("same hist"); 
  h4_norm->Draw("same hist");
  h5_norm->Draw("same hist");
  h6_norm->Draw("same hist");
  h7_norm->Draw("same hist");
  
  h1_norm->GetXaxis()->SetTitle("|#Delta#phi(#gamma#gamma,E_{T}^{miss})|");
  h1_norm->GetYaxis()->SetTitle("Normalized events");  
  h1_norm->GetYaxis()->SetTitleOffset(1.2);  
  gPad->Modified();
  gStyle->SetOptStat(0);
  
  
  //int iPos =0;                                                                                                                 
  //  CMS_lumi(p1,true,iPos,true);                                                                                               
  // CMS_lumi(p2,true,iPos,true);   
  
  leg_norm->AddEntry(h1_norm,"m_{Z'} = 600 GeV","l");
  leg_norm->AddEntry(hbkg1_norm,"#gamma #gamma","l");      
  leg_norm->AddEntry(h2_norm,"m_{Z'} = 800 GeV","l");
  leg_norm->AddEntry(hbkg2_norm,"Drell Yann","l");      
  leg_norm->AddEntry(h3_norm,"m_{Z'} = 1000 GeV","l");      
  leg_norm->AddEntry(hbkg3_norm,"#gamma + Jets","l");      
  leg_norm->AddEntry(h4_norm,"m_{Z'} = 1200 GeV","l");    
  leg_norm->AddEntry(hbkg5_norm,"QCD","l");     
  leg_norm->AddEntry(h5_norm,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples    
  leg_norm->AddEntry(hbkg4_norm,"ggH","l");      
  leg_norm->AddEntry(h6_norm,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples    
  leg_norm->AddEntry(hbkg6_norm,"VH","l");   
  leg_norm->AddEntry(h7_norm,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples      
  leg_norm->AddEntry(hbkg7_norm,"ttH","l");  
  leg_norm->AddEntry(hbkg8_norm,"VBF H","l");   
  leg_norm->AddEntry(hbkg9_norm,"t + #gamma + Jets","l");  
  leg_norm->AddEntry(hbkg10_norm,"tt + #gamma +Jets","l");  
  leg_norm->AddEntry(hbkg11_norm,"#gamma+W","l");  
  leg_norm->AddEntry(hbkg12_norm,"#gamma+Z","l");  
  leg_norm->Draw("same");
  
  if(pt1_cutIN==0. && pt2_cutIN == 0. && MET_cutIN == 0.){
    c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0.png");
    c1->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0.pdf");
 c2->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0_norm.png");
    c2->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhi_H_MET_MET0_norm.pdf");
  }
  
}
示例#7
0
void plotPatDep(Int_t slugNum, TString device, TString asymType){

gROOT->Reset();
gROOT->SetStyle("Plain");

const Double_t nonLin = -0.01; //relative MD:BCM non-linearity

const Bool_t saveFile = kTRUE; //save canvases to a file
const TString plotDir = "subblocks";

Int_t histPos[7] = {1,2,3,6,8,9,12}; //positioning scheme within the canvas
TH1F *histoCharge[7]; //Aq histogram pointer array
TH1F *histoDet[7]; //MD histogram pointer array
TH1F *histoDetCorr[7]; //Aq-corrected MD histogram pointer array

//arrays containing the mean and error for the pattern-history-dependent asymmetries, the ordering is the same as in plotTitles
Double_t aqCorr[7]; Double_t aqErr[7];
Double_t detPatMean[7]; Double_t detPatErr[7];
Double_t detPatCorrMean[7]; Double_t detPatCorrErr[7];

//arrays to be used in graphing the relative sizes of the lowest-level pattern asymmetries
Double_t patType[4] = {1,2,3,4}; // 1=(-++--++-) 2=(-++-+--+) 3=(+--+-++-) 4=(+--++--+)
Double_t patTypeErr[4] = {0,0,0,0};
Double_t patAsymMean[4]; Double_t patAsymErr[4]; //temporary holders

const TString cutList[7]={
"1",
"pat_phase==2",
"pat_phase==2 && actual_previous_pattern_polarity==0",
"pat_phase==2 && actual_previous_pattern_polarity==1",
"pat_phase==1",
"pat_phase==1 && actual_previous_pattern_polarity==0",
"pat_phase==1 && actual_previous_pattern_polarity==1"
}; //cuts to impose pattern history cuts

/*
const TString cutList[7]={
"1",
"actual_pattern_polarity==0",
"actual_pattern_polarity==0 && actual_previous_pattern_polarity==0",
"actual_pattern_polarity==0 && actual_previous_pattern_polarity==1",
"actual_pattern_polarity==1",
"actual_pattern_polarity==1 && actual_previous_pattern_polarity==0",
"actual_pattern_polarity==1 && actual_previous_pattern_polarity==1"
}; //cuts to impose pattern history cuts
*/

const TString plotTitles[7]={
"All Patterns",
"-++-",
"-++- -++-",
"-++- +--+",
"+--+",
"+--+ -++-",
"+--+ +--+"
}; //titles corresponding to above cuts

//open the file
Char_t filename[100];
sprintf(filename,"/w/hallc/qweak/smacewan/scratch/slugrootfiles/QwPass3_slug%i.root",slugNum);
f = new TFile(filename);
if(!f->IsOpen()){
	std::cerr<<"Error opening ROOTFile "<<filename<<".\n"<<std::endl;
	return 0;
}
std::cout<<"Successfully opened ROOTFile "<<filename<<".\n"<<std::endl;

//grab the tree
TTree *slugTree = f->Get("slug");
gStyle->SetOptStat("neMmRr");
gStyle->SetOptFit(1);
gStyle->SetStatW(0.32);


//----------------------------------------------------------------------------------------
//CHARGE ASYMMETRY
TCanvas *cCharge = new TCanvas("cCharge","Pattern History Study: qwk_charge",1400,1100);
cCharge->Divide(3,4);

for (Int_t i=0; i<7; i++){
	histoCharge[i] = new TH1F(Form("%s",plotTitles[i].Data()),"",100,0,0);
	cCharge->cd(histPos[i]);
	histoCharge[i]->SetDirectory(0);

	slugTree->Draw(Form("1e6*asym_qwk_charge>>slug%i_q_%s",slugNum,plotTitles[i].Data()),Form("%s && ErrorFlag==0 && asym_qwk_charge_Device_Error_Code==0",cutList[i].Data()));
	
	TH1F *htemp = (TH1F*)gPad->GetPrimitive(Form("slug%i_q_%s",slugNum,plotTitles[i].Data()));
	aqCorr[i] = htemp->GetMean();
	aqErr[i] = htemp->GetMeanError();
}

cCharge->cd(10);
patAsymMean[0] = aqCorr[2]; patAsymErr[0] = aqErr[2];
patAsymMean[1] = aqCorr[3]; patAsymErr[1] = aqErr[3];
patAsymMean[2] = aqCorr[5]; patAsymErr[2] = aqErr[5];
patAsymMean[3] = aqCorr[6]; patAsymErr[3] = aqErr[6];

TGraphErrors *grp = new TGraphErrors(4,patType,patAsymMean,patTypeErr,patAsymErr);
grp->SetMarkerStyle(21);
grp->Draw("ap");
grp->Fit("pol0");
grp->SetTitle("Asymmetry per pattern: --, -+ +- ++");
grp->GetYaxis()->SetTitle("Asymmetry (ppm)");
grp->GetYaxis()->SetTitleOffset(1.3);
grp->GetXaxis()->SetTitle("Pattern");

cCharge->Update(); cCharge->Modified();

if(saveFile){
	cCharge->SaveAs(Form("%s/%i_charge_%s.png",plotDir.Data(),slugNum,asymType.Data()));
}

//----------------------------------------------------------------------------------------
//DEVICE
TCanvas *cDet = new TCanvas("cDet",Form("Pattern History Study: %s",device.Data()),1400,1100);
cDet->Divide(3,4);

for (Int_t i=0; i<7; i++){
	histoDet[i] = new TH1F(Form("%s",plotTitles[i].Data()),"",100,0,0);
	cDet->cd(histPos[i]);
	histoDet[i]->SetDirectory(0);

	slugTree->Draw(Form("1e6*%s_%s>>slug%i_det_%s",asymType.Data(),device.Data(),slugNum,plotTitles[i].Data()),Form("%s && ErrorFlag==0 && asym_%s_Device_Error_Code==0",cutList[i].Data(),device.Data()));

	TH1F *htemp = (TH1F*)gPad->GetPrimitive(Form("slug%i_det_%s",slugNum,plotTitles[i].Data()));
	detPatMean[i] = htemp->GetMean();
	detPatErr[i] = htemp->GetMeanError();
}

cDet->cd(10);
patAsymMean[0] = detPatMean[2]; patAsymErr[0] = detPatErr[2];
patAsymMean[1] = detPatMean[3]; patAsymErr[1] = detPatErr[3];
patAsymMean[2] = detPatMean[5]; patAsymErr[2] = detPatErr[5];
patAsymMean[3] = detPatMean[6]; patAsymErr[3] = detPatErr[6];

TGraphErrors *grp = new TGraphErrors(4,patType,patAsymMean,patTypeErr,patAsymErr);
grp->SetMarkerStyle(21);
grp->Draw("ap");
grp->Fit("pol0");
grp->SetTitle("Asymmetry per pattern: --, -+ +- ++");
grp->GetYaxis()->SetTitle("Asymmetry (ppm)");
grp->GetYaxis()->SetTitleOffset(1.3);
grp->GetXaxis()->SetTitle("Pattern");

cDet->Update(); cDet->Modified();
if(saveFile){
	cDet->SaveAs(Form("%s/%i_%s_%s.png",plotDir.Data(),slugNum,asymType.Data(),device.Data()));
}



//----------------------------------------------------------------------------------------
//AQ-CORRECTED DEVICE
TCanvas *cDetCorr = new TCanvas("cDetCorr",Form("Pattern History Study: corrected %s",device.Data()),1400,1100);
cDetCorr->Divide(3,4);

for (Int_t i=0; i<7; i++){
//	std::cout<<"i="<<i<<" histPos[i]="<<histPos[i]<<std::endl;
	histoDetCorr[i] = new TH1F(Form("%s",plotTitles[i].Data()),"",100,0,0);
	cDetCorr->cd(histPos[i]);
	histoDetCorr[i]->SetDirectory(0);

	slugTree->Draw(Form("1e6*%s_%s-%f*%f>>slug%i_detcorr_%s",asymType.Data(),device.Data(),nonLin,aqCorr[i],slugNum,plotTitles[i].Data()),Form("%s && ErrorFlag==0 && asym_%s_Device_Error_Code==0",cutList[i].Data(),device.Data()));

	TH1F *htemp = (TH1F*)gPad->GetPrimitive(Form("slug%i_detcorr_%s",slugNum,plotTitles[i].Data()));
	detPatCorrMean[i] = htemp->GetMean();
	detPatCorrErr[i] = htemp->GetMeanError();
}

cDetCorr->cd(10);
patAsymMean[0] = detPatCorrMean[2]; patAsymErr[0] = detPatCorrErr[2];
patAsymMean[1] = detPatCorrMean[3]; patAsymErr[1] = detPatCorrErr[3];
patAsymMean[2] = detPatCorrMean[5]; patAsymErr[2] = detPatCorrErr[5];
patAsymMean[3] = detPatCorrMean[6]; patAsymErr[3] = detPatCorrErr[6];

TGraphErrors *grp = new TGraphErrors(4,patType,patAsymMean,patTypeErr,patAsymErr);
grp->SetMarkerStyle(21);
grp->Draw("ap");
grp->Fit("pol0");
grp->SetTitle("Asymmetry per pattern: --, -+ +- ++");
grp->GetYaxis()->SetTitle("Asymmetry (ppm)");
grp->GetYaxis()->SetTitleOffset(1.3);
grp->GetXaxis()->SetTitle("Pattern");

cDetCorr->Update(); cDetCorr->Modified();

for (Int_t i=0; i<4; i++){
std::cout<<patAsymMean[i]<<" "<<patAsymErr[i]<<std::endl;
}

if(saveFile){
	cDetCorr->SaveAs(Form("%s/%i_%s_%sCorrected.png",plotDir.Data(),slugNum,asymType.Data(),device.Data()));
}
}
示例#8
0
void Significance_auto(){

 //  prepare the weights for 4 background samples

const int N_background_points = 4;
double background_cross_section[N_background_points] = { 139.4 , 42.75 , 5.497 , 2.21 };
//double background_number_of_events[N_background_points] = { 2377497 , 955972 , 1048047 , 987977 };
double background_number_of_events[N_background_points] =   { 2327916 , 955972 , 1038512 , 974623 };
double background_weights[N_background_points];

for(int i=0;i<N_background_points;i++) 
{ background_weights[i] = background_cross_section[i] / background_number_of_events[i];  
}


 // prepare all thing used in below

  const int N_mass_points = 13;
  int Zprime_mass[N_mass_points]={600,800,1000,1200,1400,1600,1800,2000,2500,3000,3500,4000,4500};
  TString path = "/Users/index0192/13_TeV_Task/Zprime_Electron_channel/plot_SubLedaing_ele_pt_optimize/";

  TCanvas *c1[N_mass_points];
  TString c1_name;

  TString leg_name1 = "Significance";
  TString leg_name2 = "Signal efficiency";
  TString leg_name3 = "Background efficiency";


  //



  // now calulate the significance

  // loop in k, which mass point you want to know its Significance

  for(int k=0 ; k<N_mass_points ; k++){
if( k!= 2 && k!= 7 && k!= 9)continue;
if( k!= 7 )continue;
//continue;

	// c1 name	
  	cout<< "Zprime_mass[k]: " << Zprime_mass[k] << endl;
	c1_name  = Form("Significance_and_efficiency_for_Zprme_M_%d", Zprime_mass[k] );
        c1[k] = new TCanvas(c1_name,"Significance in different cut value",200,10,700,500);

	// open the signal ROOT file
  	TString signal_shape_file = Form("signal_shape_in_Zprime_M-%d.root",Zprime_mass[k]);
  	signal_shape_file = path + signal_shape_file ;
  	TFile *f_signal = new TFile (signal_shape_file);

	// open the signal histogram
//  	TString histo_name= "h_ele_pT" ;
        TString histo_name= "h_abs_dEta_ZH" ;
  	TH1D *h_2nd_ele_pT;
  	h_2nd_ele_pT = (TH1D*) f_signal -> Get(histo_name);

        // try to determine the highest cut value
  	int max_non_zero_bin = -1;
  	for( int m=1 ; m<= h_2nd_ele_pT->GetNbinsX() ;m++ ){
       		double bin_content = h_2nd_ele_pT->GetBinContent(m);
       		if( bin_content != 0 ){ max_non_zero_bin = m; }
  	}
	cout<<"max_non_zero_bin: "<< max_non_zero_bin <<endl;

        int min_non_zero_bin = -1;
        for( int m=1 ; m<= h_2nd_ele_pT->GetNbinsX() ;m++ ){
                double bin_content = h_2nd_ele_pT->GetBinContent(m);
                if( bin_content != 0 ){ min_non_zero_bin = m; break; }
        }
        cout<<"min_non_zero_bin: "<< min_non_zero_bin <<endl;

        double bin_width = h_2nd_ele_pT ->GetBinWidth(1);

//	double scan_width = 5; // how many unit you scan your cut points, default I use 5 GeV
        double scan_width = 0.05;
//	scan_width = 100;


	// decide the highest bin that can be divided by the scan-width	
 	int multipier = (max_non_zero_bin - min_non_zero_bin) * bin_width / scan_width;
        cout<<"multipier: "<< multipier <<endl;
  	double highest_cut =  multipier * scan_width;
  	cout<< "highest_cut: " <<  highest_cut <<endl;

        // input the lowest cut value
//  	int lowest_cut = 35;
//        int lowest_cut = 10;
//        int lowest_cut = 115;
        double lowest_cut = 0;

	// save the cut point value for every 5 Gev BTW highest and lowest value 
  	int n_cut_points = (highest_cut - lowest_cut)/scan_width + 1;
  	const int N_cut_points = n_cut_points;
  	cout<< "N_cut_points: " << N_cut_points << endl<<endl;
  	double cut_points[N_cut_points];
 
  	for(int i=0;i<N_cut_points;i++){
  		cut_points[i] = lowest_cut + scan_width*i;
     	}

  	// TGraph for Significance  
  	const int Nbins = N_cut_points ;
  	double vx[Nbins] ;

  	double vy_significance[Nbins] ;
        double vy_significance_errx[Nbins] ;
        double vy_significance_erry[Nbins] ;

  	double vy_sig_eff[Nbins] ;
        double vy_sig_eff_errx[Nbins] ;
        double vy_sig_eff_erry[Nbins] ;

  	double vy_background_eff[Nbins] ;
        double vy_background_eff_errx[Nbins] ;
        double vy_background_eff_erry[Nbins] ;

	for(int i=0;i<Nbins;i++){
		vy_significance_errx[i]=0;    vy_significance_erry[Nbins]=0; 
		vy_sig_eff_errx[i]=0;         vy_sig_eff_erry[i]=0;
		vy_background_eff_errx[i]=0;  vy_background_eff_erry[i]=0;
	}


  	// draw the Tgraph for significance, signal eff. and background eff.
  	TString c1_title = Form("M_{Z'}=%d GeV", Zprime_mass[k] );
  	TLegend *leg=new TLegend(0.4,0.7,0.9,0.9);


  //

  // use Eiko's eff. fn
  bool Eiko_efficiency_function=false;
  Eiko_efficiency_function= true;
  if(Eiko_efficiency_function){


		// signal eff

		        TH1F *h_2nd_ele_pT_ = (TH1F*) h_2nd_ele_pT ->Clone("");
                        h_2nd_ele_pT_->Sumw2();

                        float eff[Nbins], eff_err[Nbins];


		// background eff

		        TH1F *h_background_2nd_ele_pT_combine = (TH1F*) h_2nd_ele_pT_ ->Clone("");
        		h_background_2nd_ele_pT_combine->Reset();
			h_background_2nd_ele_pT_combine->Sumw2();

                        // prepare background sample name
                        TString background_shape_file[N_background_points];
                        for(int l=0 ; l<N_background_points ; l++ ){
                                if(l==0 ){ background_shape_file[l] = Form("background_shape_DYJets_HT100to200_in_Zprime_M-%d.root",Zprime_mass[k]);}
                                if(l==1 ){ background_shape_file[l] = Form("background_shape_DYJets_HT200to400_in_Zprime_M-%d.root",Zprime_mass[k]);}
                                if(l==2 ){ background_shape_file[l] = Form("background_shape_DYJets_HT400to600_in_Zprime_M-%d.root",Zprime_mass[k]);}
                                if(l==3 ){ background_shape_file[l] = Form("background_shape_DYJets_HT600toInf_in_Zprime_M-%d.root",Zprime_mass[k]);}
                        }// loop l background shape file
     
        		// loop background sample, open histogram, weight it, and add together 
        		for(int i=0; i<N_background_points;i++){

                		// open
                		background_shape_file[i] = path + background_shape_file[i];
                		TFile *f_background = new TFile ( background_shape_file[i] );
                		TH1D *h_background_2nd_ele_pT;
                		h_background_2nd_ele_pT = (TH1D*) f_background -> Get(histo_name);

                		// weight
                                h_background_2nd_ele_pT->Sumw2();
          		      	h_background_2nd_ele_pT->Scale( background_weights[i] );

                		// add
                		h_background_2nd_ele_pT_combine ->Add(h_background_2nd_ele_pT);

        		}// loop i background shape file

			// h_background_2nd_ele_pT_combine is ready for background


			//float background_eff[Nbins], background_eff_err[Nbins];

                        TH1F *h_background_2nd_ele_pT_combine_scale1 = (TH1F*) h_background_2nd_ele_pT_combine ->Clone("new");
                        double lumi = 1000;
//                        double lumi = 1;
                        h_background_2nd_ele_pT_combine_scale1->Scale( lumi );

                        float background_eff[Nbins], background_eff_err[Nbins];



                // significance

			cout<<endl;
                        cout<<"significance"<<endl;

                        TH1F *h_background_2nd_ele_pT_combine_scale2 = (TH1F*) h_background_2nd_ele_pT_combine ->Clone("new");
		        lumi = 1000;
			h_background_2nd_ele_pT_combine_scale2->Scale( lumi );

//                        float sig[Nbins], sig_err[Nbins];


//                        float eff[Nbins], eff_err[Nbins];
//                        float background_eff[Nbins], background_eff_err[Nbins];
                        float sig[Nbins], sig_err[Nbins];

                        for(int i=0;i<Nbins; i++)
                        {

                                vx[i] = cut_points[i];

//                              efficiency(eff[i],eff_err[i], h_2nd_ele_pT_, ( i * scan_width ) + lowest_cut + 1 );
//                              double bin_width = h_2nd_ele_pT_ ->GetBinWidth(1);

                                int FirstBinForCut = min_non_zero_bin;
                                int LastBinForCut = (cut_points[i] - lowest_cut)/bin_width + min_non_zero_bin  ;
                                cout<< "LastBinForCut: "<< LastBinForCut <<endl;
                                int mode = 0;
                                int FirstBinForTotal = min_non_zero_bin;
                                int LastBinForTotal = -1;


                                efficiency(eff[i],eff_err[i], h_2nd_ele_pT_, FirstBinForCut , LastBinForCut, mode , FirstBinForTotal , LastBinForTotal );
                                vy_sig_eff[i] = eff[i];
                                vy_sig_eff_erry[i] = eff_err[i];


                                efficiency(background_eff[i] ,background_eff_err[i],h_background_2nd_ele_pT_combine_scale1 , FirstBinForCut , LastBinForCut, mode , FirstBinForTotal , LastBinForTotal );
                                vy_background_eff[i] = background_eff[i]; 
                                vy_background_eff_erry[i] = background_eff_err[i];


                                significance( sig[i] , sig_err[i] , h_2nd_ele_pT_  , h_background_2nd_ele_pT_combine_scale2  ,FirstBinForCut , LastBinForCut, mode , FirstBinForTotal , LastBinForTotal  );
                                vy_significance[i] = sig[i];
                                vy_significance_erry[i] = sig_err[i];




                              cout<<"i:  "<< i  <<endl;
                              cout<<"cut point vx[i]:  "<< vx[i]  <<endl;

                              cout<<"vy_sig_eff[i]:  "<<vy_sig_eff[i]   <<endl;
                              cout<<"vy_sig_eff_erry[i]:  "<<vy_sig_eff_erry[i]   <<endl;

 //                             cout<<"vy_background_eff[i]:  "<<vy_background_eff[i]   <<endl;
 //                             cout<<"vy_background_eff_erry[i]:  "<<vy_background_eff_erry[i]   <<endl;

 //                             cout<<"vy_significance[i]:  "<<vy_significance[i]   <<endl;
 //                             cout<<"vy_significance_erry[i]:  "<<vy_significance_erry[i]   <<endl;



                        }// end loop





                }// end if


  // find the highest significance
  int hightest_bin =-9;
  double highest_sig=-99; 

  for(int i=0;i<Nbins; i++)
  {
  double temp = vy_significance[i] + vy_significance_erry[i]; 
  if(temp > highest_sig){highest_sig = temp; hightest_bin = i;}

  }
  cout<<endl;
  cout<< "Zprime_mass[k]: " << Zprime_mass[k] << endl;
  cout<<"hightest_bin : "<< hightest_bin << endl;  
  cout<<"highest_sig : "<<highest_sig << endl;
  cout<<"vx[hightest_bin] : "<< vx[hightest_bin] <<endl;
  cout<<"sig: "<< vy_significance[hightest_bin] <<" +/- "<< vy_significance_erry[hightest_bin] << endl;
  cout<<endl;

  // draw the TGraphError

  c1[k]->cd();

  TGraphErrors *gr 		  = new TGraphErrors(Nbins , vx , vy_significance, vy_significance_errx, vy_significance_erry );
  TGraphErrors *gr_eff 		  = new TGraphErrors(Nbins , vx , vy_sig_eff, vy_sig_eff_errx, vy_sig_eff_erry );
  TGraphErrors *gr_background_eff = new TGraphErrors(Nbins , vx , vy_background_eff, vy_background_eff_errx, vy_background_eff_erry );


  // draw setting
  gr->GetYaxis()->SetRangeUser(0, 1.1);
  gr->SetTitle(c1_title);
//  gr->GetXaxis()->SetTitle("Minimum p_{T} threshold of leading electron [ GeV]");
  gr->GetXaxis()->SetTitle("| delta eta |");

  gr->SetLineColor(2);
  gr_eff->SetLineColor(kBlue);
  gr_background_eff->SetLineColor(kGreen+2);

  gr->SetLineStyle(1);
  gr_eff->SetLineStyle(1);
  gr_background_eff->SetLineStyle(1);

  gr->SetLineWidth(3);
  gr_eff->SetLineWidth(3);
  gr_background_eff->SetLineWidth(3);

  gr->SetMarkerColor(2);
  gr_eff->SetMarkerColor(kBlue);
  gr_background_eff->SetMarkerColor(kGreen+2);

  gr->SetMarkerStyle(4);
  gr_eff->SetMarkerStyle(5);
  gr_background_eff->SetMarkerStyle(8);

  gr->SetMarkerSize(1);
  gr_eff->SetMarkerSize(1);
  gr_background_eff->SetMarkerSize(1);

  gr->Draw("ALP");
  gr_eff->Draw("same lp");
  gr_background_eff->Draw("same lp");

  leg->AddEntry( gr , leg_name1 ,"pl");
  leg->AddEntry( gr_eff , leg_name2 ,"pl");
  leg->AddEntry( gr_background_eff , leg_name3 ,"pl");
  leg->Draw();

  TString path_name = "/Users/index0192/13_TeV_Task/Zprime_Electron_channel/plot_SubLedaing_ele_pt_optimize/" ;
  c1_name = path_name + c1_name + ".png";
  c1[k]->SaveAs(c1_name);





//  delete h_2nd_ele_pT;
  delete f_signal;
  }// loop k Zprime mass points













  // show the 2nd ele pT distribution of different mass points
  // that is another loop

bool the_2nd_ele_pT_varies_mass = false; 
// the_2nd_ele_pT_varies_mass = true;
if( the_2nd_ele_pT_varies_mass ){

  // define used object
  TString c2_name = "2nd_ele_pT_distribuion_of_signal_varies_mass";
  TString c3_name = "2nd_ele_pT_distribuion_of_background_varies_mass";

  TCanvas *c2 = new TCanvas(c2_name,"2nd_ele_pT_distribuion_signal",200,10,700,500);
  TCanvas *c3 = new TCanvas(c3_name,"2nd_ele_pT_distribuion_background",200,10,700,500);
//  TCanvas *c4 = new TCanvas("2nd_ele_pT_distribuion_background_zoom_in","2nd_ele_pT_distribuion_background_zoom_in",200,10,700,500);
  int  colorN = 1;
  TLegend *leg2 = new TLegend(0.585,0.3,0.9,0.9);
  TLegend *leg3 = new TLegend(0.585,0.3,0.9,0.9);
  TLegend *leg4 = new TLegend(0.585,0.3,0.9,0.9);
  TLegend *leg5[N_mass_points];// for input
//  int rebin_times = 16;
//  int rebin_times = 1;
  int rebin_times = 4;

  TCanvas *c5[N_mass_points];

  for(int k=0;k<13;k++){
if( k!= 2 && k!= 7 && k!= 9)continue;
//if( k!= 2 )continue;
//  for(int k=2;k<3;k++){
//continue;

        leg5[k] = new TLegend(0.50,0.8,0.9,0.9);// for input
        TString c5_name = Form("input_signal_and_background_in_Zprime_M-%d",Zprime_mass[k]);
	c5[k] = new TCanvas(c5_name,"input signal and background",200,10,700,500);
	
// First for signal distribution

	// prepare background sample name
        TString signal_shape_file = Form("signal_shape_in_Zprime_M-%d.root",Zprime_mass[k]);
//        TString signal_shape_file = Form("no_zprime_cut_signal_shape_in_Zprime_M-%d.root",Zprime_mass[k]);

	// open the signal histogram
        signal_shape_file = path + signal_shape_file ;
        TFile *f_signal = new TFile (signal_shape_file);

//        TString histo_name= "h_ele_pT" ;
//        TString histo_name= "h_Zprime_mass" ;
        TString histo_name= "h_abs_dEta_ZH" ;
//        TString histo_name= "h_abs_dPhi_ZH" ;
//        TString histo_name= "h_abs_dR_ZH" ;


        TH1D *h_2nd_ele_pT;
        h_2nd_ele_pT = (TH1D*) f_signal -> Get(histo_name);

        TH1D *h_2nd_ele_pT_clone = (TH1D*) h_2nd_ele_pT ->Clone("");// for later be template for background

// Second for background distribution

	// prepare background sample name
        TString background_shape_file[N_background_points];
        for(int l=0 ; l<N_background_points ; l++ ){
        	if(l==0 ){ background_shape_file[l] = Form("background_shape_DYJets_HT100to200_in_Zprime_M-%d.root",Zprime_mass[k]);}
                if(l==1 ){ background_shape_file[l] = Form("background_shape_DYJets_HT200to400_in_Zprime_M-%d.root",Zprime_mass[k]);}
                if(l==2 ){ background_shape_file[l] = Form("background_shape_DYJets_HT400to600_in_Zprime_M-%d.root",Zprime_mass[k]);}
                if(l==3 ){ background_shape_file[l] = Form("background_shape_DYJets_HT600toInf_in_Zprime_M-%d.root",Zprime_mass[k]);}
	}// loop l background shape file 

	TH1D *h_background_2nd_ele_pT_combine = (TH1D*) h_2nd_ele_pT_clone ->Clone("");
	h_background_2nd_ele_pT_combine->Reset();

	// loop background sample, open histogram, weight it, and add together 
        for(int i=0; i<N_background_points;i++){

		// open
                background_shape_file[i] = path + background_shape_file[i];
                TFile *f_background = new TFile ( background_shape_file[i] );
                TH1D *h_background_2nd_ele_pT;
                h_background_2nd_ele_pT = (TH1D*) f_background -> Get(histo_name);

		// weight
		h_background_2nd_ele_pT->Scale( background_weights[i] );

		// add
		h_background_2nd_ele_pT_combine ->Add(h_background_2nd_ele_pT);

        }// loop i background shape file


// Now
// h_2nd_ele_pT is ready for signal
// h_background_2nd_ele_pT_combine is ready for background






	// input signal and background shape
        // c5[k] is the comparison of signal and background input shape

       	// input signal

        TH1D *input_signal = (TH1D*) h_2nd_ele_pT ->Clone("");

        input_signal->Scale( 1/input_signal->Integral() );
        input_signal->SetTitle("2nd electron pT distribution");
        input_signal->SetStats(0);
        input_signal->Rebin(rebin_times);


        // input background

        TH1D *input_background = (TH1D*) h_background_2nd_ele_pT_combine ->Clone("");

        input_background->Scale( 1/input_background->Integral() );
        input_background->Rebin(rebin_times);

	// decide max-x and max-y
	double MaxX=0,MaxY=0; 

	int signal_max_bin=-9;
	double signal_max_content=-99;
        for( int m=1 ; m<= input_signal->GetNbinsX() ;m++ ){
                double bin_content = input_signal->GetBinContent(m);
		// seek the biggest non-zero bin  
                if( bin_content != 0 ){ signal_max_bin = m; }
		if( bin_content >= signal_max_content ){ signal_max_content = bin_content ; }
        }       

        int background_max_bin=-9;
        double background_max_content=-99;
        for( int m=1 ; m<= input_background->GetNbinsX() ;m++ ){
                double bin_content = input_background->GetBinContent(m);
                if( bin_content != 0 ){ background_max_bin = m; }
                if( bin_content >= background_max_content ){ background_max_content = bin_content ; }
        }
	
	if( signal_max_bin >= background_max_bin ){ MaxX = signal_max_bin; }
	else{ MaxX = background_max_bin;}
	MaxX = MaxX * rebin_times * 1.1  ;
        input_signal->GetXaxis()->SetRangeUser(0, MaxX );

        if( signal_max_content >= background_max_content ){ MaxY = signal_max_content; }
        else{ MaxY = background_max_content;}
        MaxY = MaxY * 1.1  ;
        input_signal->GetYaxis()->SetRangeUser(0, MaxY );

	// other setting
//	input_signal->GetXaxis()->SetTitle("Sub-leading electron p_{T} [ GeV]");
//        input_signal->GetXaxis()->SetTitle("Leading electron p_{T} [ GeV]");
        input_signal->GetXaxis()->SetTitle("| delta eta|");
//        input_signal->GetXaxis()->SetTitle("| delta Phi|");
//        input_signal->GetXaxis()->SetTitle("delta R");
        input_signal->GetYaxis()->SetTitle("Arbitrary Unit");
        input_signal ->SetFillColor(2);
	input_signal->SetFillStyle(1001);
 	input_signal ->SetLineColor(2);
        input_background->SetLineColor(4);
	input_background->SetLineWidth(3); 
 	input_signal->SetTitle("");
	input_background->SetTitle("");

	// draw
        c5[k]->cd();
        input_signal -> Draw();
        input_background -> Draw("same");

        TString leg_input_name =  Form("Signal, M_{Z'}=%d GeV",Zprime_mass[k]);
        leg5[k]->AddEntry( input_signal ,leg_input_name ,"lf");
        leg_input_name = "DY+jets";
        leg5[k]->AddEntry( input_background ,leg_input_name ,"lf");
        leg5[k]->Draw();

	//save
        TString input_save_name =  Form("input_in_Zprime_mass_%d.png",Zprime_mass[k]);
        input_save_name = path + input_save_name ;
        c5[k]->SaveAs(input_save_name);






	// signal shape varies with mass
        // c2 is signal distribution varies with mass
        TH1D *h_signal_varies_mass = (TH1D*) h_2nd_ele_pT ->Clone("");

        h_signal_varies_mass->Scale( 1/h_signal_varies_mass->Integral() );
//        h_signal_varies_mass->SetTitle("2nd electron pT distribution");
        h_signal_varies_mass->SetTitle("");
        h_signal_varies_mass->SetStats(0);

        if( k==0){colorN = kRed;}
        else if( k==3){colorN = kOrange;}
        else if( k==6){colorN = kYellow;}
        else if( k==9){colorN = kCyan;}

        h_signal_varies_mass->SetLineColor(colorN);
        h_signal_varies_mass->GetXaxis()->SetTitle("| delta eta |");
        h_signal_varies_mass->Rebin(rebin_times);

        c2->cd();
        if(k==0){h_signal_varies_mass -> Draw(); h_signal_varies_mass->GetXaxis()->SetRangeUser(0, 1250);}
        else {h_signal_varies_mass -> Draw("same");}

        TString leg_singal_name =  Form("signal in Z' mass= %d",Zprime_mass[k]);
        leg2->AddEntry( h_signal_varies_mass ,leg_singal_name ,"L");
        leg2->Draw();






	// background shape varies with mass
        // c3 is background distribution varies with mass 
        TH1D *h_background_varies_mass = (TH1D*) h_background_2nd_ele_pT_combine ->Clone("");

        h_background_varies_mass->Scale( 1/h_background_varies_mass->Integral() );
        h_background_varies_mass->SetTitle("2nd electron pT distribution");
        h_background_varies_mass->SetTitle("");
        h_background_varies_mass->SetStats(0);

        h_background_varies_mass->SetLineColor(colorN);
        colorN = colorN + 1;// afer used in signal and background color+1

        h_background_varies_mass->Rebin(rebin_times);
        h_background_varies_mass->GetXaxis()->SetTitle("| delta eta |");

        c3->cd();
        if(k==0){
                h_background_varies_mass->GetXaxis()->SetRangeUser(0, 1250);   
                h_background_varies_mass->GetYaxis()->SetRangeUser(0, 1); 
                h_background_varies_mass -> Draw(); 
                }
        else {h_background_varies_mass->GetYaxis()->SetRangeUser(0, 0.3); h_background_varies_mass -> Draw("same");}

        TString leg_background_name =  Form("background in Z' mass= %d",Zprime_mass[k]);
        leg3->AddEntry( h_background_varies_mass ,leg_background_name ,"L");
        leg3->Draw();





  }// loop k Zprime mass point


c2_name = path + c2_name + ".png";
c3_name = path + c3_name + ".png";

c2->cd();
c2->SaveAs(c2_name);

c3->cd();
c3->SaveAs(c3_name);



}// end if




  // combine the 4 background shape to get the Zprime mass distribution 

bool Zprime_mass_combined_background = false;
//Zprime_mass_combined_background = true;
if(Zprime_mass_combined_background)
  {     // Zprime_mass[0] is M = 600 

	// prepare the background sample name
        TString background_shape_file[N_background_points];
        for(int l=0 ; l<N_background_points ; l++ ){
                if(l==0 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT100to200_in_Zprime_M-%d.root",Zprime_mass[0]);}
                if(l==1 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT200to400_in_Zprime_M-%d.root",Zprime_mass[0]);}
                if(l==2 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT400to600_in_Zprime_M-%d.root",Zprime_mass[0]);}
                if(l==3 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT600toInf_in_Zprime_M-%d.root",Zprime_mass[0]);}
        }// loop l background shape file 

	// prepare a template histogram and reset it 
        TString template_name = path + background_shape_file[0] ;
        TFile *f_template = new TFile ( template_name );
        TString histo_name= "h_Zprime_mass" ;
        TH1D *h_template;
        h_template = (TH1D*) f_template -> Get(histo_name);

        TH1D *h_background_2nd_ele_pT_combine = (TH1D*) h_template ->Clone("");
        h_background_2nd_ele_pT_combine->Reset();

	// loop background sample, open, weight, and add
        for(int i=0; i<N_background_points;i++){

		// open
                background_shape_file[i] = path + background_shape_file[i];
                TFile *f_background = new TFile ( background_shape_file[i] );
                TH1D *h_background_2nd_ele_pT;
                h_background_2nd_ele_pT = (TH1D*) f_background -> Get(histo_name);

		// weight
		h_background_2nd_ele_pT->Scale(background_weights[i]  );

		// add
                h_background_2nd_ele_pT_combine ->Add(h_background_2nd_ele_pT);
        }// loop i background shape file

        TCanvas *c6 = new TCanvas("background_Zprime_mass","",200,10,700,500);
	c6->cd();
	h_background_2nd_ele_pT_combine->Rebin(8);
	h_background_2nd_ele_pT_combine->Draw();

  }// end if


}
void dumpWPsAntiElectronDiscr()
{
//--- suppress the output canvas 
  gROOT->SetBatch(true);

  std::string inputFileName = "/nfs/dust/cms/user/fcolombo/HiggsToTauTau/TauPOG/antiElectronDiscrMVATraining/fixTauGSF_scenario3_v2_lessVars_WZJetsSignals/";
  inputFileName.append("computeWPcutsAntiElectronDiscrMVA_mvaAntiElectronDiscr5.root");

  std::string wpTreeName = "wpCutsTree";

  std::vector<int> categories;
  //for ( int iCategory = 0; iCategory < 16; ++iCategory ) {
  //  categories.push_back(iCategory);
  //}
  categories.push_back(0);
  categories.push_back(2);
  categories.push_back(5);
  categories.push_back(7);
  categories.push_back(8);
  categories.push_back(10);
  categories.push_back(13);
  categories.push_back(15);

  std::vector<double> targetSignalEfficiencies;
  targetSignalEfficiencies.push_back(0.95);
  targetSignalEfficiencies.push_back(0.90);
  targetSignalEfficiencies.push_back(0.85);
  targetSignalEfficiencies.push_back(0.80);
  targetSignalEfficiencies.push_back(0.75);
  
  std::vector<workingPointEntryType> workingPoints = readWorkingPoints(inputFileName, wpTreeName, categories);
  
  std::vector<graphWrapperType*> graphWrappers;

  for ( std::vector<workingPointEntryType>::iterator workingPoint = workingPoints.begin();
	workingPoint != workingPoints.end(); ++workingPoint ) {
    bool isInTargetSignalEfficiencies = false;

    for ( std::vector<double>::const_iterator targetSignalEfficiency = targetSignalEfficiencies.begin();
	  targetSignalEfficiency != targetSignalEfficiencies.end(); ++targetSignalEfficiency ) {
      if ( TMath::Abs(workingPoint->targetSignalEfficiency_ - (*targetSignalEfficiency)) < 0.003 ) isInTargetSignalEfficiencies = true;
    }
 
    if ( isInTargetSignalEfficiencies ) {
      std::cout << "targetSignalEfficiency = " << workingPoint->targetSignalEfficiency_ << ":" << std::endl;
      std::cout << " Pt = " << workingPoint->minPt_ << ".." << workingPoint->maxPt_ << std::endl;

      for ( std::vector<int>::const_iterator category = categories.begin();
	    category != categories.end(); ++category ) {
	std::cout << "  category #" << (*category) << ": cut = " << workingPoint->cuts_[*category] << std::endl;
      }
      std::cout << " S = " << workingPoint->S_ << ", B = " << workingPoint->B_ << " --> S/B = " << (workingPoint->S_/workingPoint->B_) << std::endl;
      std::cout << std::endl;

      for ( std::vector<int>::const_iterator category = categories.begin();
	    category != categories.end(); ++category ) {
	graphWrapperType* graphWrapper_matched = 0;
	for ( std::vector<graphWrapperType*>::const_iterator graphWrapper = graphWrappers.begin();
	      graphWrapper != graphWrappers.end(); ++graphWrapper ) {
	  if ( TMath::Abs((*graphWrapper)->targetSignalEfficiency_ - workingPoint->targetSignalEfficiency_) < 1.e-6 && (*graphWrapper)->category_ == (*category) ) {
	    graphWrapper_matched = (*graphWrapper);
	  }
	}
	if ( !graphWrapper_matched ) {
	  graphWrapper_matched = new graphWrapperType();
	  graphWrapper_matched->targetSignalEfficiency_ = workingPoint->targetSignalEfficiency_;
	  graphWrapper_matched->category_ = (*category);
	  graphWrappers.push_back(graphWrapper_matched);	  
	}
//	if ( workingPoint->minPt_ == 0. ) {
//	  // CV: use constant cut on BDT output in low Pt region dominated by SM Drell -> Yan ee background
//	  graphWrapper_matched->x_.push_back(workingPoint->minPt_);
//	  graphWrapper_matched->y_.push_back(workingPoint->cuts_[*category]);
//	  graphWrapper_matched->x_.push_back(workingPoint->maxPt_);
//	  graphWrapper_matched->y_.push_back(workingPoint->cuts_[*category]);
//	} else if ( workingPoint->minPt_ >= 400. ) {
//	  graphWrapper_matched->x_.push_back(400.);
//	  graphWrapper_matched->y_.push_back(workingPoint->cuts_[*category]);
//	} else {
	  double avPt = 0.5*(workingPoint->minPt_ + workingPoint->maxPt_);
          graphWrapper_matched->xLow_.push_back(workingPoint->minPt_);
          graphWrapper_matched->xUp_.push_back(workingPoint->maxPt_);
          graphWrapper_matched->x_.push_back(avPt);
          graphWrapper_matched->y_.push_back(workingPoint->cuts_[*category]);
//	}
      }
    }
  }

  TFile* outputFile = new TFile("dumpWPsAntiElectronDiscr.root", "RECREATE");

  for ( std::vector<graphWrapperType*>::const_iterator graphWrapper = graphWrappers.begin();
	graphWrapper != graphWrappers.end(); ++graphWrapper ) {

    unsigned int numPoints = (*graphWrapper)->x_.size();
    assert((*graphWrapper)->y_.size() == numPoints);
    TGraphErrors* graph = new TGraphErrors(numPoints);
    std::string graphName = Form("eff%1.0fcat%i", (*graphWrapper)->targetSignalEfficiency_*100., (*graphWrapper)->category_);
    std::string graphTitle = Form("Category #%i (target signal efficiency = %1.0f %%)", (*graphWrapper)->category_, (*graphWrapper)->targetSignalEfficiency_*100.);
    graph->SetName(graphName.data());
    graph->SetTitle(graphTitle.data());

    for ( unsigned int iPoint = 0; iPoint < numPoints; ++iPoint ) {
      double xLow = (*graphWrapper)->xLow_[iPoint];
      double xUp = (*graphWrapper)->xUp_[iPoint];
      double x = (*graphWrapper)->x_[iPoint];
      double y = (*graphWrapper)->y_[iPoint];

      if ( xUp >= 1.e+6 ) xUp = 1000.;
      graph->SetPoint(iPoint, 0.5*(xUp + xLow), y);
      graph->SetPointError(iPoint, 0.5*(xUp - xLow), 0.);
    }

    graph->SetMarkerStyle(20);
    graph->SetMarkerColor(1);
    graph->SetLineColor(1);
    graph->SetLineWidth(1);
    graph->GetXaxis()->SetTitle("Pt");
    graph->GetYaxis()->SetTitle("cut value");
    graph->GetYaxis()->SetRangeUser(-1., 1.);
    graph->Write();
  }

  delete outputFile;

  for ( std::vector<graphWrapperType*>::const_iterator it = graphWrappers.begin();
	it != graphWrappers.end(); ++it ) {
    delete (*it);
  }
}
void make1DLimit(TString combine_dir,TString type= "WH",bool blind=true){
  //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiWH_0_175/";

  TGraph obser( (200-125)/25 );
  TGraph graph( (200-125)/25 );
  TGraphAsymmErrors error( (200-125)/25 );

  TGraph obser_r( (200-125)/25 );
  TGraph graph_r( (200-125)/25 );
  TGraphAsymmErrors error_r( (200-125)/25 );
  
  TGraphErrors* theo = 0;
  if(type=="WH") theo = getTheoXSec("xsecs/CharginoNeutralino.txt");
  else theo = getTheoXSec("xsecs/Higgsino_ElectroHiggs.txt");
  //else theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt");

  for(int m=125;m<=200;m+=25) {
    int i=(m-125)/25;
    TFile limit_file(Form("%s/higgsCombineChi%s_0_%d.Asymptotic.mH120.root",combine_dir.Data(),type.Data(),m) );
    TTree *limit_tree = (TTree*)limit_file.Get("limit");
    TTreeFormula limit_form("get_limit","limit",limit_tree);
    
    limit_tree->GetEntry(1);
    float down = limit_form.EvalInstance();
    limit_tree->GetEntry(2);
    float exp = limit_form.EvalInstance();
    limit_tree->GetEntry(3);
    float up = limit_form.EvalInstance();
    limit_tree->GetEntry(5);
    float obs = limit_form.EvalInstance();
    if(i==0) m+=5; //first point is actually at m=130
    graph.SetPoint(i,float(m),exp);
    error.SetPoint(i,float(m),exp);
    error.SetPointError(i,0,0,exp-down,up-exp);
  
    graph_r.SetPoint(i,float(m),exp/theo->Eval(m));
    error_r.SetPoint(i,float(m),exp/theo->Eval(m));
    error_r.SetPointError(i,0,0,(exp-down)/theo->Eval(m),(up-exp)/theo->Eval(m));
  
    obser.SetPoint(i,float(m),obs);
    obser_r.SetPoint(i,float(m),obs/theo->Eval(m));
    if(i==0) m-=5;
  }


    TCanvas cv;
    cv.SetLogy();
    cv.SetGrid(1,1);
    theo->SetMaximum(1e2);
    theo->SetMinimum(1e-2);
    theo->GetYaxis()->SetLabelSize(0.05);
    theo->GetYaxis()->SetTitleSize(0.06);
    theo->GetYaxis()->SetTitleOffset(0.8);
    theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    theo->GetXaxis()->SetTitle("m_{chargino} (GeV)");
    if(type=="HH") theo->GetXaxis()->SetTitle("m_{neutralino} (GeV)");
    theo->SetFillColor(kBlue);
    theo->SetLineStyle(kDotted);
    theo->SetLineWidth(1);
    
    error.SetMaximum(1e2);
    error.SetMinimum(1e-2);
    error.GetYaxis()->SetLabelSize(0.04);
    error.GetYaxis()->SetTitleSize(0.06);
    error.GetYaxis()->SetTitleOffset(0.8);
    error.GetXaxis()->SetLabelSize(0.04);
    error.GetXaxis()->SetTitleSize(0.05);
    error.GetXaxis()->SetTitleOffset(0.9);
    error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    error.GetXaxis()->SetTitle("m_{chargino} (GeV)");
    if(type=="HH") error.GetXaxis()->SetTitle("m_{neutralino} (GeV)");
    error.SetFillColor(kGreen);
    error.SetTitle("");
    error.Draw("A3");

    theo->SetTitle("");
    theo->Draw("3C");

    graph.SetLineStyle(kDashed);
    graph.SetLineWidth(0.09);
    graph.SetTitle("");
    graph.Draw("C");

    obser.SetLineStyle(1);
    obser.SetLineWidth(1.2);
    obser.SetTitle("");
    if(!blind) obser.Draw("C");

    TLegend leg(0.65,0.65,0.89,0.89);
    leg.SetFillColor(0);
    leg.SetBorderSize(0);
    leg.AddEntry(&graph,"expected","l");
    leg.AddEntry(&error,"expected #pm1#sigma","F");
    leg.AddEntry(theo,"theoretical","f");
    if(!blind)     leg.AddEntry(&obser,"observed","l");

    leg.Draw("SAME");

    TLatex latex;
    latex.SetNDC();
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);    
    float extraTextSize = extraOverCmsTextSize*cmsSize;
    latex.SetTextFont(lumifont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);    
    latex.DrawLatex(lumix, lumiy,lumiText);
    
    latex.SetTextFont(cmsTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);
    latex.DrawLatex(cmsx, cmsy, CMSText);
    
    latex.SetTextFont(extraTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(extraTextSize);
    latex.DrawLatex(extrax, extray, extraText);

    TString infix=(blind ? "" : "_OBS");
    cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+".png");
    cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+".pdf");
    cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+".C");

    error_r.SetMaximum(1e2);
    error_r.SetMinimum(1e-2);

    error_r.SetTitle("");
    error_r.GetYaxis()->SetLabelSize(0.04);
    error_r.GetYaxis()->SetTitleSize(0.06);
    error_r.GetYaxis()->SetTitleOffset(0.8);
    error_r.GetXaxis()->SetLabelSize(0.04);
    error_r.GetXaxis()->SetTitleSize(0.05);
    error_r.GetXaxis()->SetTitleOffset(0.9);
    error_r.GetYaxis()->SetTitle("#sigma_{95%}/#sigma_{NLO}");
    if(type=="HH") error_r.GetXaxis()->SetTitle("m_{neutralino} (GeV)");
    else error_r.GetXaxis()->SetTitle("m_{chargino} (GeV)");
    error_r.SetFillColor(kGreen);
    error_r.Draw("A3");

    graph_r.SetLineStyle(kDashed);
    graph_r.SetLineWidth(0.09);
    graph_r.SetTitle("");
    graph_r.Draw("C");

    TLine l(125,1,205,1);
    l.SetLineWidth(2);
    l.SetLineColor(kBlue);
    l.Draw("SAME");

    if(!blind) obser_r.Draw("C");
    leg.Draw("SAME");

    //lbl.SetY(0.20);
    //leg.SetY1NDC(0.28);
    //leg.SetY2NDC(0.43);

    //prelim.Draw();
    //lbl.Draw();
    latex.SetTextFont(lumifont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);    
    latex.DrawLatex(lumix, lumiy,lumiText);
    
    latex.SetTextFont(cmsTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);
    latex.DrawLatex(cmsx, cmsy, CMSText);
    
    latex.SetTextFont(extraTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(extraTextSize);
    latex.DrawLatex(extrax, extray, extraText);
    
    cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+".png");
    cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+".pdf");
    cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+".C");
}
void paraPull_alpha_FT_EFF_extrapolation_2TeV_2Lep_plots_All()
{
//=========Macro generated from canvas: c1/alpha_FT_EFF_extrapolation
//=========  (Sun Nov 22 20:19:02 2015) by ROOT version6.02/12
   TCanvas *c1 = new TCanvas("c1", "alpha_FT_EFF_extrapolation",0,22,1000,600);
   gStyle->SetOptStat(0);
   c1->Range(-4.125,-0.9756589,37.125,1.048929);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetGridx();
   c1->SetGridy();
   c1->SetFrameBorderMode(0);
   c1->SetFrameBorderMode(0);
   
   TH1F *NuisanceParameterFreed23 = new TH1F("NuisanceParameterFreed23","alpha_FT_EFF_extrapolation",33,0,33);
   NuisanceParameterFreed23->SetMinimum(-0.7732002);
   NuisanceParameterFreed23->SetMaximum(0.84647);
   NuisanceParameterFreed23->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   NuisanceParameterFreed23->SetLineColor(ci);
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(1,"XS_ttbar");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(2,"EG_SCALE_ALL");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(3,"FT_EFF_Eigen_C_0");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(4,"Luminosity");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(5,"XS_st");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(6,"FT_EFF_Eigen_B_1");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(7,"XS_Zc");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(8,"MUONS_ID");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(9,"FT_EFF_Eigen_C_1");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(10,"FT_EFF_Eigen_C_3");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(11,"MUON_EFF_TrigSystUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(12,"XS_Zl");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(13,"EL_EFF_ID_TotalCorrUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(14,"FT_EFF_Eigen_B_0");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(15,"FT_EFF_Eigen_B_2");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(16,"EL_EFF_Iso_TotalCorrUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(17,"EL_EFF_Reco_TotalCorrUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(18,"MUONS_SCALE");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(19,"MUON_ISO_STAT");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(20,"MUON_EFF_STAT");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(21,"MUON_EFF_SYS");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(22,"MUON_EFF_TrigStatUncertainty");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(23,"FT_EFF_Eigen_Light_1");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(24,"FT_EFF_Eigen_Light_2");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(25,"EG_RESOLUTION_ALL");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(26,"XS_diboson");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(27,"FT_EFF_Eigen_Light_4");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(28,"FT_EFF_Eigen_Light_3");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(29,"MUON_ISO_SYS");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(30,"XS_Zb");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(31,"MUONS_MS");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(32,"FT_EFF_Eigen_C_2");
   NuisanceParameterFreed23->GetXaxis()->SetBinLabel(33,"FT_EFF_Eigen_Light_0");
   NuisanceParameterFreed23->GetXaxis()->SetLabelFont(42);
   NuisanceParameterFreed23->GetXaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed23->GetXaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed23->GetXaxis()->SetTitleFont(42);
   NuisanceParameterFreed23->GetYaxis()->SetTitle("#theta_{fit} - #theta_{initial}/#Delta#theta");
   NuisanceParameterFreed23->GetYaxis()->SetLabelFont(42);
   NuisanceParameterFreed23->GetYaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed23->GetYaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed23->GetYaxis()->SetTitleFont(42);
   NuisanceParameterFreed23->GetZaxis()->SetLabelFont(42);
   NuisanceParameterFreed23->GetZaxis()->SetLabelSize(0.035);
   NuisanceParameterFreed23->GetZaxis()->SetTitleSize(0.035);
   NuisanceParameterFreed23->GetZaxis()->SetTitleFont(42);
   NuisanceParameterFreed23->Draw("hist");
   
   Double_t _fx1023[35] = {
   1.22802e-312,
   0.5,
   1.5,
   2.5,
   3.5,
   4.5,
   5.5,
   6.5,
   7.5,
   8.5,
   9.5,
   10.5,
   11.5,
   12.5,
   13.5,
   14.5,
   15.5,
   16.5,
   17.5,
   18.5,
   19.5,
   20.5,
   21.5,
   22.5,
   23.5,
   24.5,
   25.5,
   26.5,
   27.5,
   28.5,
   29.5,
   30.5,
   31.5,
   32.5,
   0};
   Double_t _fy1023[35] = {
   1.22802e-312,
   -0.7732002,
   -0.3921591,
   -0.2934756,
   -0.2062307,
   -0.1826562,
   -0.1278773,
   -0.1247963,
   -0.108241,
   -0.06582277,
   -0.05689324,
   -0.05334169,
   -0.04681761,
   -0.03773949,
   -0.03194355,
   -0.03107318,
   -0.02396662,
   -0.01713834,
   -0.001377884,
   0.0001640769,
   0.01059417,
   0.01807268,
   0.01971767,
   0.02015498,
   0.02031121,
   0.0264387,
   0.04025057,
   0.04268968,
   0.0458893,
   0.05072166,
   0.05322667,
   0.05659235,
   0.05743463,
   0.84647,
   0};
   Double_t _fex1023[35] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t _fey1023[35] = {
   0,
   0,
   0.6107108,
   1.073202,
   1.262649,
   0.9362982,
   0.9916356,
   0.9862464,
   0.9262906,
   0.7691235,
   0.9864321,
   0.9937945,
   0.9917446,
   0.9970094,
   0.9817783,
   0.9372476,
   0.9926669,
   0.9931837,
   0.9925578,
   1.005003,
   0.9933467,
   0.9932277,
   0.9929663,
   0.9927589,
   0.9912906,
   0.9909611,
   1.097757,
   0.9869836,
   0.993171,
   0.9930564,
   0.9854803,
   0.753601,
   0.7380864,
   0.9908989,
   0.785308};
   TGraphErrors *gre = new TGraphErrors(35,_fx1023,_fy1023,_fex1023,_fey1023);
   gre->SetName("");
   gre->SetTitle("");
   gre->SetFillColor(1);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(1.2);
   
   TH1F *Graph_Graph1023 = new TH1F("Graph_Graph1023","",100,0,35.75);
   Graph_Graph1023->SetMinimum(-1.799504);
   Graph_Graph1023->SetMaximum(2.167994);
   Graph_Graph1023->SetDirectory(0);
   Graph_Graph1023->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1023->SetLineColor(ci);
   Graph_Graph1023->GetXaxis()->SetLabelFont(42);
   Graph_Graph1023->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1023->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1023->GetXaxis()->SetTitleFont(42);
   Graph_Graph1023->GetYaxis()->SetLabelFont(42);
   Graph_Graph1023->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1023->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1023->GetYaxis()->SetTitleFont(42);
   Graph_Graph1023->GetZaxis()->SetLabelFont(42);
   Graph_Graph1023->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1023->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1023->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1023);
   
   gre->Draw("p");
   
   TLegend *leg = new TLegend(0.1,0.4,0.4,0.95,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(72);
   leg->SetTextSize(0.015);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(0.2917068,0.9341608,0.7082932,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   TText *AText = pt->AddText("alpha_FT_EFF_extrapolation");
   pt->Draw();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
示例#12
0
void apt_all(){
//=========Macro generated from canvas: MyCanvas/My Canvas
//=========  (Thu Dec  3 18:47:52 2009) by ROOT version5.25/04
   
   gROOT->Reset();
   gROOT->ProcessLine(".x rootlogon.C");

   gStyle->SetTitleYOffset(1.5);
   TCanvas *MyCanvas = new TCanvas("MyCanvas", "My Canvas",0,0,550,600);

   MyCanvas->SetLogx();

   double msize = 2;

   TH1D *hDist = new TH1D("hDist","hDist",20,9,10000);
   hDist->GetXaxis()->SetRange(1,20);
   hDist->SetMinimum(0.3);
   //hDist->SetMaximum(0.7);
   hDist->SetMaximum(0.6);  
   hDist->SetLineStyle(0);
   hDist->GetXaxis()->SetTitle("#sqrt{s} [GeV]");
   hDist->GetYaxis()->SetTitle("#LTp_{T}#GT [GeV/c]");
   hDist->GetXaxis()->CenterTitle();
   hDist->GetYaxis()->CenterTitle();
   hDist->GetYaxis()->SetNdivisions(510);
   hDist->Draw("");
   
   // Fit function                                                                                                                                 
   //TF1 *func = new TF1("func","0.426-0.0198*log(x^2)+0.00156*log(x^2)^2",18,100000); 
   //TF1 *func = new TF1("func","0.430-0.0207*log(x^2)+0.00161*log(x^2)^2",18,100000); 
   TF1 *func = new TF1("func","0.425-0.0197*log(x^2)+0.00156*log(x^2)^2",18,100000);
   func->SetLineColor(1);
   func->SetLineWidth(2.0);
   func->Draw("same");


   // ============================= ISR
   // OK, from http://www.slac.stanford.edu/spires/find/hep/www?j=NUPHA,B84,269

   TGraphErrors *gre = new TGraphErrors(4);
   gre->SetName("Graph");
   gre->SetTitle("Graph");

   gre->SetMarkerStyle(28);
   gre->SetMarkerSize(msize);

   gre->SetPoint(0,23.32,0.362);// plab = 289
   gre->SetPointError(0,0,0.004);  // errors are not verified! 
   gre->SetPoint(1,30.59,0.364);// plab = 498
   gre->SetPointError(1,0,0.00497238);
   gre->SetPoint(2,44.61,0.366); // plab = 1060
   gre->SetPointError(2,0,0.00478821);
   gre->SetPoint(3,53.06,0.368); // plab = 1500
   gre->SetPointError(3,0,0.00497238);

   
   TH1F *Graph1 = new TH1F("Graph1","Graph",100,19.03788,56.0634);
   Graph1->SetMinimum(0.3551011);
   Graph1->SetMaximum(0.374549);

   gre->SetHistogram(Graph1);
   gre->Draw("pz");

   TGraph* gre01 = gre->Clone("gre01");
   gre01->SetMarkerStyle(0);
   //   gre01->Draw("pzsame");

   // ============================= UA1  
   // OK, from  http://dx.doi.org/10.1016/0550-3213(90)90493-W

   gre = new TGraphErrors(7);
   gre->SetName("Graph");
   gre->SetTitle("Graph");

   gre->SetMarkerStyle(3);
   gre->SetMarkerSize(msize);
   gre->SetPoint(0,200,0.392);
   gre->SetPointError(0,0,0.003);
   gre->SetPoint(1,260,0.404);
   gre->SetPointError(1,0,0.004);
   gre->SetPoint(2,380,0.408);
   gre->SetPointError(2,0,0.004);
   gre->SetPoint(3,500,0.419);
   gre->SetPointError(3,0,0.004);
   gre->SetPoint(4,620,0.426);
   gre->SetPointError(4,0,0.004);
   gre->SetPoint(5,790,0.435);
   gre->SetPointError(5,0,0.004);
   gre->SetPoint(6,900,0.447);
   gre->SetPointError(6,0,0.003);
   
   TH1F *Graph2 = new TH1F("Graph2","Graph",100,131.4964,972.7974);
   Graph2->SetMinimum(0.3826521);
   Graph2->SetMaximum(0.4560221);

   gre->SetHistogram(Graph2);
   gre->Draw("pz");
   
   TGraph* gre02 = gre->Clone("gre02");
   gre02->SetMarkerStyle(0);
   //   gre02->Draw("pzsame");

   // ============================= E735?
   // OK, from https://twiki.cern.ch/twiki/pub/CMS/DNdEtaBib/e735numbers.pdf
   gre = new TGraphErrors(4);
   gre->SetName("Graph");
   gre->SetTitle("Graph");

   gre->SetMarkerStyle(22);
   gre->SetMarkerSize(msize);
   gre->SetPoint(0,300,0.393);
   gre->SetPointError(0,0,0.01);
   gre->SetPoint(1,540,0.430);
   gre->SetPointError(1,0,0.01);
   gre->SetPoint(2,900,0.448);
   gre->SetPointError(2,0,0.01);
   gre->SetPoint(3,1800,0.468);
   gre->SetPointError(3,0,0.01);

   TH1F *Graph3 = new TH1F("Graph3","Graph",100,148.0787,1967.778);
   Graph3->SetMinimum(0.3734073);
   Graph3->SetMaximum(0.4869985);

   gre->SetHistogram(Graph3);
   gre->Draw("pz");

   TGraph* gre03 = gre->Clone("gre03");
   gre03->SetMarkerStyle(0);
   gre03->Draw("pzsame");
   
   // ============================= CDF
   // OK, from http://www.slac.stanford.edu/spires/find/hep/www?j=PRLTA,61,1819

   gre = new TGraphErrors(2);
   gre->SetName("Graph");
   gre->SetTitle("Graph");

   gre->SetMarkerStyle(21);
   gre->SetMarkerSize(msize);

   gre->SetPoint(0,630,0.432);
   gre->SetPointError(0,0,0.004);
   gre->SetPoint(1,1800,0.495);
   gre->SetPointError(1,0,0.014);
   
   TH1F *Graph4 = new TH1F("Graph4","Graph",100,518.0436,1936.249);
   Graph4->SetMinimum(0.4196686);
   Graph4->SetMaximum(0.5173485);
   gre->SetHistogram(Graph4);
   
   gre->Draw("pz");
   
   TGraph* gre04 = gre->Clone("gre04");
   gre04->SetMarkerStyle(0);
   gre04->Draw("pzsame");

   // ============================= CMS?
   gre = new TGraphErrors(1);
   gre->SetName("Graph");
   gre->SetTitle("Graph");

   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(msize);
   gre->SetMarkerColor(kRed+2);
   gre->SetLineColor(kRed+2);

   /*
   gre->SetPoint(0,900,0.44);
   gre->SetPointError(0,0,0.018);
   */
   
   //Now real measurement
   Float_t cmsSysError = 0.028;
   gre->SetPoint(0,900,0.46);
   //gre->SetPointError(0,0,0.46*cmsSysError);
   // updated to sqrt (0.01*0.01+0.46*0.46*0.028*0.028) , where 0.01 is stat err. 
   gre->SetPointError(0,0,0.0163); 
   gre->SetPoint(1,2360,0.50);
   //gre->SetPointError(1,0,0.50*cmsSysError);
   gre->SetPointError(1,0,0.0172);

   TGraph* greOnT = gre->Clone("greOnT");
   greOnT->SetMarkerStyle(0);
   greOnT->SetLineWidth(2);
   greOnT->Draw("PZsame");

   TGraph* greOnT2 = gre->Clone("cmsnsd05");
   gStyle->SetEndErrorSize(3);
   greOnT2->SetMarkerStyle(0);
   greOnT2->Draw("||");

   
   TH1F *Graph5 = new TH1F("Graph5","Graph",100,899.9,901.1);
   Graph5->SetMinimum(0.4184);
   Graph5->SetMaximum(0.4616);
   gre->SetHistogram(Graph5);
   gre->SetMarkerSize(msize*1.2);
   gre->Draw("pz");
   
   TGraph* gre05 = gre->Clone("gre05");
   gre05->SetMarkerStyle(0);
   //   gre05->Draw("pzsame");
   
   /*
   // Fit function
   //TF1 *func = new TF1("func","0.426-0.0198*log(x^2)+0.00156*log(x^2)^2",18,100000);
   //TF1 *func = new TF1("func","0.430-0.0207*log(x^2)+0.00161*log(x^2)^2",18,100000);  
   TF1 *func = new TF1("func","0.425-0.0197*log(x^2)+0.00156*log(x^2)^2",18,100000);  
   func->SetLineColor(1);
   func->SetLineWidth(1.5);
   func->Draw("same");
   */

   TLegend *leg = new TLegend(0.25,0.90-0.045*5,0.5,0.90,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextFont(62);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(0);
   leg->SetTextSize(0.03);

   TLegendEntry *entry=leg->AddEntry("Graph1","ISR inel.","P");
   entry->SetMarkerStyle(28);
   entry->SetMarkerSize(msize);
   entry=leg->AddEntry("Graph2","UA1 NSD","P");
   entry->SetMarkerStyle(3);   
   entry->SetMarkerSize(msize);   

   entry=leg->AddEntry("Graph3","E735 NSD","P");
   entry->SetMarkerStyle(22);   
   entry->SetMarkerSize(msize); 

   entry=leg->AddEntry("Graph4","CDF NSD","P");
   entry->SetMarkerStyle(21);    
   entry->SetMarkerSize(msize);    

   entry=leg->AddEntry("Graph5","CMS NSD (|#eta|<2.4)","P");
   entry->SetMarkerStyle(20);  
   entry->SetMarkerColor(kRed+2);
   entry->SetMarkerSize(msize*1.0);  
   leg->Draw();  

   TLegend *leg2 = new TLegend(0.35,0.20,0.91,0.26,NULL,"brNDC");
   //TLegend *leg2 = new TLegend(0.411,0.18,0.91,0.33,NULL,"brNDC");     
   leg2->SetBorderSize(0);
   leg2->SetTextFont(62);
   leg2->SetTextSize(0.035);
   leg2->SetLineColor(1);
   leg2->SetLineStyle(1);
   leg2->SetLineWidth(1);
   leg2->SetFillColor(0);
   leg2->SetFillStyle(0);
   leg2->SetMargin(0.15);
   leg2->SetTextSize(0.03);

   //   TLegendEntry *entry=leg2->AddEntry("func","0.40 - 0.015 #times ln(s) + 0.001325 #times ln^{2}(s)","l");
   //TLegendEntry *entry=leg2->AddEntry("func","0.40 - 0.015 ln(s) + 0.001325 ln^{2}(s)","l");
   TLegendEntry *entry=leg2->AddEntry("func","0.425 - 0.0197 ln(s) + 0.00156 ln^{2}(s)","l");
   //TLegendEntry *entry=leg2->AddEntry("func","0.430 - 0.0207 ln(s) + 0.00161 ln^{2}(s)","l");


   entry->SetTextSize(0.03);
   entry->SetMarkerSize(0);
   leg2->Draw();

   printFinalCanvases(MyCanvas,"apt_all");

}
void BSA_InCoherent_xB()
{
//=========Macro generated from canvas: c16/Incoherent channe
//=========  (Tue Aug 21 12:00:25 2018) by ROOT version6.09/01
   TCanvas *c16 = new TCanvas("c16", "Incoherent channe",0,0,1200,400);
   gStyle->SetOptFit(1);
   c16->Range(0,0,1,1);
   c16->SetFillColor(0);
   c16->SetBorderMode(0);
   c16->SetBorderSize(2);
   c16->SetLeftMargin(0.025);
   c16->SetRightMargin(0.02325581);
   c16->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: c16_1
   TPad *c16_1 = new TPad("c16_1", "Incoherent channe_1",0,0,0.262936,0.9);
   c16_1->Draw();
   c16_1->cd();
   c16_1->Range(-29.34641,-0.4888889,350.2581,0.4);
   c16_1->SetFillColor(0);
   c16_1->SetBorderMode(0);
   c16_1->SetBorderSize(2);
   c16_1->SetGridx();
   c16_1->SetGridy();
   c16_1->SetRightMargin(0);
   c16_1->SetTopMargin(0);
   c16_1->SetFrameBorderMode(0);
   c16_1->SetFrameBorderMode(0);
   
   TMultiGraph *multigraph = new TMultiGraph();
   multigraph->SetName("");
   multigraph->SetTitle("0.12<x_{B}<0.21 ");
   
   Double_t Graph_fx1134[9] = {
   24.14331,
   62.70082,
   96.14623,
   141.7289,
   180.8857,
   220.5862,
   258.7856,
   303.3336,
   334.7288};
   Double_t Graph_fy1134[9] = {
   0.1330996,
   -0.03883743,
   0.1388413,
   0.2120595,
   0.03749243,
   -0.09129921,
   -0.1273289,
   -0.1643618,
   0.03103783};
   Double_t Graph_fex1134[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph_fey1134[9] = {
   0.07077824,
   0.06445297,
   0.05939535,
   0.06833722,
   0.08559024,
   0.08401363,
   0.06136237,
   0.05845869,
   0.08718727};
   TGraphErrors *gre = new TGraphErrors(9,Graph_fx1134,Graph_fy1134,Graph_fex1134,Graph_fey1134);
   gre->SetName("Graph");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#00ff00");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(21);
   
   TH1F *Graph_Graph1134 = new TH1F("Graph_Graph1134","Graph",100,0,365.7873);
   Graph_Graph1134->SetMinimum(-0.2731422);
   Graph_Graph1134->SetMaximum(0.3307184);
   Graph_Graph1134->SetDirectory(0);
   Graph_Graph1134->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1134->SetLineColor(ci);
   Graph_Graph1134->GetXaxis()->SetLabelFont(42);
   Graph_Graph1134->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1134->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1134->GetXaxis()->SetTitleFont(42);
   Graph_Graph1134->GetYaxis()->SetLabelFont(42);
   Graph_Graph1134->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1134->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1134->GetYaxis()->SetTitleFont(42);
   Graph_Graph1134->GetZaxis()->SetLabelFont(42);
   Graph_Graph1134->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1134->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1134->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1134);
   
   
   TF1 *myfit1135 = new TF1("myfit","[0]*sin(x*3.1416/180.0)/(1 + [1]*cos(x*3.1416/180.0))",0,365.7873);
   myfit1135->SetFillColor(19);
   myfit1135->SetFillStyle(0);
   myfit1135->SetLineColor(2);
   myfit1135->SetLineWidth(2);
   myfit1135->SetChisquare(10.13595);
   myfit1135->SetNDF(7);
   myfit1135->GetXaxis()->SetLabelFont(42);
   myfit1135->GetXaxis()->SetLabelSize(0.035);
   myfit1135->GetXaxis()->SetTitleSize(0.035);
   myfit1135->GetXaxis()->SetTitleFont(42);
   myfit1135->GetYaxis()->SetLabelFont(42);
   myfit1135->GetYaxis()->SetLabelSize(0.035);
   myfit1135->GetYaxis()->SetTitleSize(0.035);
   myfit1135->GetYaxis()->SetTitleFont(42);
   myfit1135->SetParameter(0,0.1205343);
   myfit1135->SetParError(0,0.03387604);
   myfit1135->SetParLimits(0,0,0);
   myfit1135->SetParameter(1,0.6858633);
   myfit1135->SetParError(1,0.2646153);
   myfit1135->SetParLimits(1,0,0);
   gre->GetListOfFunctions()->Add(myfit1135);
   
   TPaveStats *ptstats = new TPaveStats(0.27,0.74,0.9,0.9,"brNDC");
   ptstats->SetName("stats");
   ptstats->SetBorderSize(1);
   ptstats->SetFillColor(0);
   ptstats->SetTextAlign(12);
   ptstats->SetTextFont(42);
   TText *AText = ptstats->AddText("#chi^{2} / ndf = 10.14 / 7");
   AText = ptstats->AddText("p0       = 0.1205 #pm 0.03388 ");
   AText = ptstats->AddText("p1       = 0.6859 #pm 0.2646 ");
   ptstats->SetOptStat(0);
   ptstats->SetOptFit(111);
   ptstats->Draw();
   gre->GetListOfFunctions()->Add(ptstats);
   ptstats->SetParent(gre->GetListOfFunctions());
   multigraph->Add(gre,"");
   multigraph->Draw("AP");
   multigraph->GetXaxis()->SetTitle("#phi [deg.]");
   multigraph->GetXaxis()->SetLabelFont(42);
   multigraph->GetXaxis()->SetLabelSize(0.035);
   multigraph->GetXaxis()->SetTitleSize(0.035);
   multigraph->GetXaxis()->SetTitleFont(42);
   multigraph->GetYaxis()->SetTitle("A_{LU}");
   multigraph->GetYaxis()->SetLabelFont(42);
   multigraph->GetYaxis()->SetLabelSize(0.035);
   multigraph->GetYaxis()->SetTitleSize(0.035);
   multigraph->GetYaxis()->SetTitleFont(42);
     gPad->Modified();  
   multigraph->GetYaxis()->SetRangeUser(-0.35, 0.35);  




   c16_1->Modified();
   c16->cd();
  
// ------------>Primitives in pad: c16_2
   TPad *c16_2 = new TPad("c16_2", "Incoherent channe_2",0.262936,0,0.5008721,0.9);
   c16_2->Draw();
   c16_2->cd();
   c16_2->Range(5.85529,-0.4888889,352.0975,0.4);
   c16_2->SetFillColor(0);
   c16_2->SetBorderMode(0);
   c16_2->SetBorderSize(2);
   c16_2->SetGridx();
   c16_2->SetGridy();
   c16_2->SetLeftMargin(0);
   c16_2->SetRightMargin(0);
   c16_2->SetTopMargin(0);
   c16_2->SetFrameBorderMode(0);
   c16_2->SetFrameBorderMode(0);
   
   multigraph = new TMultiGraph();
   multigraph->SetName("");
   multigraph->SetTitle("0.21<x_{B}<0.31 ");
   
   Double_t Graph_fx1137[9] = {
   21.59357,
   60.08662,
   95.00395,
   140.4897,
   181.0443,
   224.9978,
   260.1264,
   302.891,
   336.3592};
   Double_t Graph_fy1137[9] = {
   0.0984356,
   0.1891659,
   0.2419886,
   0.08897874,
   0.2077051,
   -0.3071227,
   -0.1933684,
   -0.2875592,
   -0.08265727};
   Double_t Graph_fex1137[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph_fey1137[9] = {
   0.04446748,
   0.058618,
   0.06898028,
   0.1082398,
   0.135301,
   0.1152745,
   0.0716065,
   0.04680018,
   0.05547391};
   gre = new TGraphErrors(9,Graph_fx1137,Graph_fy1137,Graph_fex1137,Graph_fey1137);
   gre->SetName("Graph");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);

   ci = TColor::GetColor("#00ff00");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(21);
   
   TH1F *Graph_Graph1137 = new TH1F("Graph_Graph1137","Graph",100,0,367.8358);
   Graph_Graph1137->SetMinimum(-0.4989376);
   Graph_Graph1137->SetMaximum(0.4195464);
   Graph_Graph1137->SetDirectory(0);
   Graph_Graph1137->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1137->SetLineColor(ci);
   Graph_Graph1137->GetXaxis()->SetLabelFont(42);
   Graph_Graph1137->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1137->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1137->GetXaxis()->SetTitleFont(42);
   Graph_Graph1137->GetYaxis()->SetLabelFont(42);
   Graph_Graph1137->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1137->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1137->GetYaxis()->SetTitleFont(42);
   Graph_Graph1137->GetZaxis()->SetLabelFont(42);
   Graph_Graph1137->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1137->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1137->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1137);
   
   
   TF1 *myfit1138 = new TF1("myfit","[0]*sin(x*3.1416/180.0)/(1 + [1]*cos(x*3.1416/180.0))",0,367.8358);
   myfit1138->SetFillColor(19);
   myfit1138->SetFillStyle(0);
   myfit1138->SetLineColor(2);
   myfit1138->SetLineWidth(2);
   myfit1138->SetChisquare(7.336971);
   myfit1138->SetNDF(7);
   myfit1138->GetXaxis()->SetLabelFont(42);
   myfit1138->GetXaxis()->SetLabelSize(0.035);
   myfit1138->GetXaxis()->SetTitleSize(0.035);
   myfit1138->GetXaxis()->SetTitleFont(42);
   myfit1138->GetYaxis()->SetLabelFont(42);
   myfit1138->GetYaxis()->SetLabelSize(0.035);
   myfit1138->GetYaxis()->SetTitleSize(0.035);
   myfit1138->GetYaxis()->SetTitleFont(42);
   myfit1138->SetParameter(0,0.2508538);
   myfit1138->SetParError(0,0.03583101);
   myfit1138->SetParLimits(0,0,0);
   myfit1138->SetParameter(1,-0.1422748);
   myfit1138->SetParError(1,0.2426713);
   myfit1138->SetParLimits(1,0,0);
   gre->GetListOfFunctions()->Add(myfit1138);
   
   ptstats = new TPaveStats(0.27,0.74,0.9,0.9,"brNDC");
   ptstats->SetName("stats");
   ptstats->SetBorderSize(1);
   ptstats->SetFillColor(0);
   ptstats->SetTextAlign(12);
   ptstats->SetTextFont(42);
   AText = ptstats->AddText("#chi^{2} / ndf = 7.337 / 7");
   AText = ptstats->AddText("p0       = 0.2509 #pm 0.03583 ");
   AText = ptstats->AddText("p1       = -0.1423 #pm 0.2427 ");
   ptstats->SetOptStat(0);
   ptstats->SetOptFit(111);
   ptstats->Draw();
   gre->GetListOfFunctions()->Add(ptstats);
   ptstats->SetParent(gre->GetListOfFunctions());
   multigraph->Add(gre,"");
   multigraph->Draw("AP");
   multigraph->GetXaxis()->SetTitle("#phi [deg.]");
   multigraph->GetXaxis()->SetLabelFont(42);
   multigraph->GetXaxis()->SetLabelSize(0.035);
   multigraph->GetXaxis()->SetTitleSize(0.035);
   multigraph->GetXaxis()->SetTitleFont(42);
   multigraph->GetYaxis()->SetLabelFont(42);
   multigraph->GetYaxis()->SetLabelSize(0.035);
   multigraph->GetYaxis()->SetTitleSize(0.035);
   multigraph->GetYaxis()->SetTitleFont(42);
     gPad->Modified();  
   multigraph->GetYaxis()->SetRangeUser(-0.35, 0.35);  



   c16_2->Modified();
   c16->cd();
  
// ------------>Primitives in pad: c16_3
   TPad *c16_3 = new TPad("c16_3", "Incoherent channe_3",0.5008721,0,0.7388081,0.9);
   c16_3->Draw();
   c16_3->cd();
   c16_3->Range(4.159976,-0.4888889,357.6921,0.4);
   c16_3->SetFillColor(0);
   c16_3->SetBorderMode(0);
   c16_3->SetBorderSize(2);
   c16_3->SetGridx();
   c16_3->SetGridy();
   c16_3->SetLeftMargin(0);
   c16_3->SetRightMargin(0);
   c16_3->SetTopMargin(0);
   c16_3->SetFrameBorderMode(0);
   c16_3->SetFrameBorderMode(0);
   
   multigraph = new TMultiGraph();
   multigraph->SetName("");
   multigraph->SetTitle("0.31<x_{B}<0.39 ");
   
   Double_t Graph_fx1140[9] = {
   20.22962,
   57.37981,
   95.86069,
   135.3486,
   182.9227,
   229.5531,
   263.4275,
   301.2495,
   341.6225};
   Double_t Graph_fy1140[9] = {
   0.09662004,
   0.06965272,
   0.269744,
   -0.170935,
   -0.1509905,
   0.6309487,
   0.06270791,
   -0.2582676,
   -0.152689};
   Double_t Graph_fex1140[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph_fey1140[9] = {
   0.05297617,
   0.09107484,
   0.121636,
   0.2287053,
   0.3066164,
   0.3879093,
   0.1400804,
   0.07623737,
   0.06739512};
   gre = new TGraphErrors(9,Graph_fx1140,Graph_fy1140,Graph_fex1140,Graph_fey1140);
   gre->SetName("Graph");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);

   ci = TColor::GetColor("#00ff00");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(21);
   
   TH1F *Graph_Graph1140 = new TH1F("Graph_Graph1140","Graph",100,0,373.7618);
   Graph_Graph1140->SetMinimum(-0.6052533);
   Graph_Graph1140->SetMaximum(1.166504);
   Graph_Graph1140->SetDirectory(0);
   Graph_Graph1140->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1140->SetLineColor(ci);
   Graph_Graph1140->GetXaxis()->SetLabelFont(42);
   Graph_Graph1140->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1140->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1140->GetXaxis()->SetTitleFont(42);
   Graph_Graph1140->GetYaxis()->SetLabelFont(42);
   Graph_Graph1140->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1140->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1140->GetYaxis()->SetTitleFont(42);
   Graph_Graph1140->GetZaxis()->SetLabelFont(42);
   Graph_Graph1140->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1140->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1140->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1140);
   
   
   TF1 *myfit1141 = new TF1("myfit","[0]*sin(x*3.1416/180.0)/(1 + [1]*cos(x*3.1416/180.0))",0,373.7618);
   myfit1141->SetFillColor(19);
   myfit1141->SetFillStyle(0);
   myfit1141->SetLineColor(2);
   myfit1141->SetLineWidth(2);
   myfit1141->SetChisquare(10.84482);
   myfit1141->SetNDF(7);
   myfit1141->GetXaxis()->SetLabelFont(42);
   myfit1141->GetXaxis()->SetLabelSize(0.035);
   myfit1141->GetXaxis()->SetTitleSize(0.035);
   myfit1141->GetXaxis()->SetTitleFont(42);
   myfit1141->GetYaxis()->SetLabelFont(42);
   myfit1141->GetYaxis()->SetLabelSize(0.035);
   myfit1141->GetYaxis()->SetTitleSize(0.035);
   myfit1141->GetYaxis()->SetTitleFont(42);
   myfit1141->SetParameter(0,0.124049);
   myfit1141->SetParError(0,0.05069177);
   myfit1141->SetParLimits(0,0,0);
   myfit1141->SetParameter(1,-0.6977989);
   myfit1141->SetParError(1,0.2049165);
   myfit1141->SetParLimits(1,0,0);
   gre->GetListOfFunctions()->Add(myfit1141);
   
   ptstats = new TPaveStats(0.27,0.74,0.9,0.9,"brNDC");
   ptstats->SetName("stats");
   ptstats->SetBorderSize(1);
   ptstats->SetFillColor(0);
   ptstats->SetTextAlign(12);
   ptstats->SetTextFont(42);
   AText = ptstats->AddText("#chi^{2} / ndf = 10.84 / 7");
   AText = ptstats->AddText("p0       = 0.124 #pm 0.05069 ");
   AText = ptstats->AddText("p1       = -0.6978 #pm 0.2049 ");
   ptstats->SetOptStat(0);
   ptstats->SetOptFit(111);
   ptstats->Draw();
   gre->GetListOfFunctions()->Add(ptstats);
   ptstats->SetParent(gre->GetListOfFunctions());
   multigraph->Add(gre,"");
   multigraph->Draw("AP");
   multigraph->GetXaxis()->SetTitle("#phi [deg.]");
   multigraph->GetXaxis()->SetLabelFont(42);
   multigraph->GetXaxis()->SetLabelSize(0.035);
   multigraph->GetXaxis()->SetTitleSize(0.035);
   multigraph->GetXaxis()->SetTitleFont(42);
   multigraph->GetYaxis()->SetLabelFont(42);
   multigraph->GetYaxis()->SetLabelSize(0.035);
   multigraph->GetYaxis()->SetTitleSize(0.035);
   multigraph->GetYaxis()->SetTitleFont(42);
     gPad->Modified();  
   multigraph->GetYaxis()->SetRangeUser(-0.35, 0.35);  




   c16_3->Modified();
   c16->cd();
  
// ------------>Primitives in pad: c16_4
   TPad *c16_4 = new TPad("c16_4", "Incoherent channe_4",0.7388081,0,0.9767442,0.9);
   c16_4->Draw();
   c16_4->cd();
   c16_4->Range(-17.15326,-0.4888889,360.2184,0.4);
   c16_4->SetFillColor(0);
   c16_4->SetBorderMode(0);
   c16_4->SetBorderSize(2);
   c16_4->SetGridx();
   c16_4->SetGridy();
   c16_4->SetLeftMargin(0);
   c16_4->SetRightMargin(0);
   c16_4->SetTopMargin(0);
   c16_4->SetFrameBorderMode(0);
   c16_4->SetFrameBorderMode(0);
   
   multigraph = new TMultiGraph();
   multigraph->SetName("");
   multigraph->SetTitle("0.39<x_{B}<0.60 ");
   
   Double_t Graph_fx1143[9] = {
   19.13311,
   55.36321,
   90.36243,
   127.5684,
   0,
   232.109,
   268.7816,
   302.6639,
   343.0651};
   Double_t Graph_fy1143[9] = {
   0.1307559,
   0.1996612,
   0.006608881,
   -2.830736,
   0,
   -2.034047,
   0.1276631,
   -0.2950426,
   -0.003784223};
   Double_t Graph_fex1143[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph_fey1143[9] = {
   0.05218982,
   0.09871893,
   0.1820512,
   4.457049,
   0,
   1.502801,
   0.207584,
   0.0825667,
   0.06276702};
   gre = new TGraphErrors(9,Graph_fx1143,Graph_fy1143,Graph_fex1143,Graph_fey1143);
   gre->SetName("Graph");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);

   ci = TColor::GetColor("#00ff00");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(21);
   
   TH1F *Graph_Graph1143 = new TH1F("Graph_Graph1143","Graph",100,0,377.3716);
   Graph_Graph1143->SetMinimum(-8.179195);
   Graph_Graph1143->SetMaximum(2.517722);
   Graph_Graph1143->SetDirectory(0);
   Graph_Graph1143->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1143->SetLineColor(ci);
   Graph_Graph1143->GetXaxis()->SetLabelFont(42);
   Graph_Graph1143->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1143->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1143->GetXaxis()->SetTitleFont(42);
   Graph_Graph1143->GetYaxis()->SetLabelFont(42);
   Graph_Graph1143->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1143->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1143->GetYaxis()->SetTitleFont(42);
   Graph_Graph1143->GetZaxis()->SetLabelFont(42);
   Graph_Graph1143->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1143->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1143->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1143);
   
   
   TF1 *myfit1144 = new TF1("myfit","[0]*sin(x*3.1416/180.0)/(1 + [1]*cos(x*3.1416/180.0))",0,377.3716);
   myfit1144->SetFillColor(19);
   myfit1144->SetFillStyle(0);
   myfit1144->SetLineColor(2);
   myfit1144->SetLineWidth(2);
   myfit1144->SetChisquare(8.6938);
   myfit1144->SetNDF(7);
   myfit1144->GetXaxis()->SetLabelFont(42);
   myfit1144->GetXaxis()->SetLabelSize(0.035);
   myfit1144->GetXaxis()->SetTitleSize(0.035);
   myfit1144->GetXaxis()->SetTitleFont(42);
   myfit1144->GetYaxis()->SetLabelFont(42);
   myfit1144->GetYaxis()->SetLabelSize(0.035);
   myfit1144->GetYaxis()->SetTitleSize(0.035);
   myfit1144->GetYaxis()->SetTitleFont(42);
   myfit1144->SetParameter(0,0.1663497);
   myfit1144->SetParError(0,0.06722025);
   myfit1144->SetParLimits(0,0,0);
   myfit1144->SetParameter(1,-0.5093054);
   myfit1144->SetParError(1,0.2952021);
   myfit1144->SetParLimits(1,0,0);
   gre->GetListOfFunctions()->Add(myfit1144);
   
   ptstats = new TPaveStats(0.27,0.74,0.9,0.9,"brNDC");
   ptstats->SetName("stats");
   ptstats->SetBorderSize(1);
   ptstats->SetFillColor(0);
   ptstats->SetTextAlign(12);
   ptstats->SetTextFont(42);
   AText = ptstats->AddText("#chi^{2} / ndf = 8.694 / 7");
   AText = ptstats->AddText("p0       = 0.1663 #pm 0.06722 ");
   AText = ptstats->AddText("p1       = -0.5093 #pm 0.2952 ");
   ptstats->SetOptStat(0);
   ptstats->SetOptFit(111);
   ptstats->Draw();
   gre->GetListOfFunctions()->Add(ptstats);
   ptstats->SetParent(gre->GetListOfFunctions());
   multigraph->Add(gre,"");
   multigraph->Draw("AP");
   multigraph->GetXaxis()->SetTitle("#phi [deg.]");
   multigraph->GetXaxis()->SetLabelFont(42);
   multigraph->GetXaxis()->SetLabelSize(0.035);
   multigraph->GetXaxis()->SetTitleSize(0.035);
   multigraph->GetXaxis()->SetTitleFont(42);
   multigraph->GetYaxis()->SetLabelFont(42);
   multigraph->GetYaxis()->SetLabelSize(0.035);
   multigraph->GetYaxis()->SetTitleSize(0.035);
   multigraph->GetYaxis()->SetTitleFont(42);
    gPad->Modified();  
   multigraph->GetYaxis()->SetRangeUser(-0.35, 0.35);  

 


   c16_4->Modified();
   c16->cd();
   c16->Modified();
   c16->cd();
   c16->SetSelected(c16);
}
示例#14
0
void cetaflatHEM3t(int nIterN=1, double Ethr1=4, double Ethr2=150) {

    gStyle->SetOptLogz(0);
    gStyle->SetMarkerSize(0.7);
    gStyle->SetMarkerStyle(20);
    gStyle->SetPadGridX(0);
    gStyle->SetPadGridY(0);
    gStyle->SetTitleOffset(1.7,"Y");
    gStyle->SetTitleOffset(0.9,"X");
    //gStyle->SetPadRightMargin(0.12);
    gStyle->SetPadTopMargin(0.06);
    gStyle->SetPadRightMargin(0.03);
    gStyle->SetPadLeftMargin(0.2);
    //gStyle->SetNdivisions(516);
    gStyle->SetStatH(0.09);
    gStyle->SetStatW(0.3);
    gStyle->SetTitleW(0.4);
    gStyle->SetTitleX(0.3);
    gStyle->SetOptStat(0);
    //gStyle->SetOptStat(1111111);
    gROOT->ForceStyle();

    char ctit[145];

    static const double theHBHEEtaBounds[] = { 0.000, 0.087, 0.087*2, 0.087*3, 0.087*4,
                                               0.087*5, 0.087*6, 0.087*7, 0.087*8, 0.087*9,
                                               0.087*10, 0.087*11, 0.087*12, 0.087*13, 0.087*14,
                                               0.087*15, 0.087*16, 0.087*17, 0.087*18, 0.087*19,
                                               1.74, 1.83, 1.93, 2.043, 2.172,
                                               2.332, 2.5, 2.65, 2.868, 3.000
                                             };

    static const double theHFEtaBounds[] = { 2.853, 2.964, 3.139, 3.314, 3.489, 3.664, 3.839,
                                             4.013, 4.191, 4.363, 4.538, 4.716, 4.889, 5.191
                                           };

    // ---------------- Histos input --------------------------------------

    char ftit[145];
    //sprintf(ftit,"%s","phi43val2012A");
    //sprintf(ftit,"%s","phi2012A_May");
    //sprintf(ftit,"%s","phiSym524_2012AB");
    //sprintf(ftit,"%s","phiSym524newGain_2012AB");
    //sprintf(ftit,"%s","phiSym524newGain_2012ABC");
    sprintf(ftit,"%s","phiSym533Corr45Gain507_2012D");

    sprintf(ctit,"/home/vodib/beam12/intercal/%s.root",ftit);
    TFile *fila = new TFile (ctit);
    cout<<"File= "<<ctit<<endl;

    TH1F *hcounter =   new TH1F(*((TH1F*)fila->Get("phaseHF/hcounter")));
    cout<<"Stat= "<<hcounter->GetBinContent(2)<<endl;
    cout<<"E within: "<<Ethr1<<" - "<<Ethr2<<endl;

    TH2F* hmapP = new TH2F("hmapP","E  HEM;i#eta;i#phi",14,-29.5,-15.5,72,0,72);
    TH2F* hmapP0 = new TH2F("hmapP0","E0  HEM;i#eta;i#phi",14,-29.5,-15.5,72,0,72);
    TH2F* hmapPc = new TH2F("hmapPc","corr  HEM;i#eta;i#phi",14,-29.5,-15.5,72,0,72);
    hmapPc->Sumw2();
    TH1F *hcorr1D = new TH1F("hcorr1D","Corr",150,0.5,2);
    TH1F *ht = new TH1F("ht","ht",20000,0,5e7);
    TH1F *htx = new TH1F("htx","htx",20000,0,5e5);
    TH1F *htr = new TH1F("htr","htr",5000,0,3);

    /*  HE mapping:
    if (ieta==16 && depth<3) continue;
    if (ieta==17 && depth>1) continue;
    if (ieta>17 && ieta<27 && depth==3) continue;
    if (ieta==29 && depth==3) continue;
    if (ieta>20 && iphi%2==0) continue;  */


    TH1F *hdatP[14][72], *hdatPx[14][72];
    for (int ii=0; ii<14; ii++) for (int jj=0; jj<72; jj++) {
            sprintf(ctit,"h%d_%d",ii+16,jj+1);
            hdatP[ii][jj] = new TH1F(ctit,ctit,10000,0,250);
        }

    TCanvas *cx[400];
    TSpline5 *tt;

    Double_t x,y,rPL,rPS,mLE,mSE,ermean,rms;
    Double_t xx[4000],yy[4000];
    Int_t nELP, nESP, nIter=0;
    Double_t mcorrL,scorrL,mcorrS,scorrS,erLP,erSP,rLP,drLP,rSP,corrL,corrS,dcorrL,dcorrS;
    double mLEphi[14];

    TCanvas *ccxx = new TCanvas("ccxx","ccxx",0,400,800,400);
    ccxx->Divide(2,1);
    for (int ii=0; ii<14; ii++) {
        int ieta=-(ii+16);

        mLE=mSE=0;   // ------------------for initial condition
        int nmLE=0, nmSE=0;
        ht->Reset();
        htx->Reset();
        for (int ll=0; ll<72; ll++) {
            int iphi=ll+1;

            if (abs(ieta)!=16 && abs(ieta)!=27 && abs(ieta)!=28) continue;
            if (abs(ieta)>20 && iphi%2==0) continue;

            hmapPc->SetBinContent(14-ii,ll+1,1);
            hmapPc->SetBinError(14-ii,ll+1,1.e-6);
            sprintf(ctit,"phaseHF/eHEspec/E_-%d_%d_3",abs(ieta),iphi);
            hdatPx[ii][ll]  =   new TH1F(*((TH1F*)fila->Get(ctit)));
            hdatPx[ii][ll]->SetAxisRange(Ethr1,Ethr2);
            rLP = hdatPx[ii][ll]->Integral()*hdatPx[ii][ll]->GetMean();
            hmapP0->SetBinContent(14-ii,ll+1,rLP);
            if (skipHEChannel(iphi,ieta)) continue;
            if (rLP>0) {
                ht->Fill(rLP);
                htx->Fill(rLP);
                mLE += rLP;
                nmLE++;
                drLP=rLP*sqrt(pow(1./hdatPx[ii][ll]->Integral(),2)+
                              pow(hdatPx[ii][ll]->GetMeanError()/hdatPx[ii][ll]->GetMean(),2));
                hmapP0->SetBinError(14-ii,ll+1,drLP);
            }
            else hmapP0->SetBinError(14-ii,ll+1,0);
        }
        if (nmLE>0) mLE /= nmLE;
        else mLE=0;
        ccxx->cd(1);
        ht->Draw("hist");
        ccxx->cd(2);
        htx->Draw("hist");
        ccxx->Update();
        if (htx->GetBinContent(20001)>1) histspec(ht,mLE,ermean,rms,4,-5);
        else histspec(htx,mLE,ermean,rms,4,-5);
        //histspec(ht,mLE,ermean,rms);
        mLEphi[ii]=mLE;
        printf("ieta %2d :  <E>= %8.1f \n",ieta,mLE);
        if (ht->GetMean()>0) htr->Fill(ht->GetRMS()/ht->GetMean());

        for (int jj=0; jj<72; jj++) {
            int iphi=jj+1;

            if (abs(ieta)!=16 && abs(ieta)!=27 && abs(ieta)!=28) continue;
            if (abs(ieta)>20 && iphi%2==0) continue;
            if (skipHEChannel(iphi,ieta)) {
                hmapP->SetBinContent(14-ii,jj+1,hmapP0->GetBinContent(14-ii,jj+1,rLP));
                continue;
            }

            for (nIter=1; nIter<nIterN; nIter++) { //cout<<nIter<<" |  ";
                if (hmapP0->GetBinContent(14-ii,jj+1)<=0) continue;
                corrL=hmapPc->GetBinContent(14-ii,jj+1);
                hdatP[ii][jj]->Reset();

                for (int kk=1; kk<=hdatPx[ii][jj]->GetNbinsX(); kk++) {
                    xx[kk-1]=hdatPx[ii][jj]->GetBinCenter(kk);
                    yy[kk-1]=hdatPx[ii][jj]->GetBinContent(kk);
                }
                tt = new TSpline5("tt",xx,yy,1000,"",10,20);

                for (int kk=1; kk<=hdatP[ii][jj]->GetNbinsX(); kk++) {
                    x=hdatP[ii][jj]->GetBinCenter(kk);
                    y=hdatP[ii][jj]->GetBinContent(kk);
                    hdatP[ii][jj]->Fill(x*corrL,tt->Eval(x)/10.0);
                }
                tt->Delete();

                hdatP[ii][jj]->SetAxisRange(Ethr1,Ethr2);
                rLP = hdatP[ii][jj]->Integral()*hdatP[ii][jj]->GetMean();
                dcorrL=(rLP-mLE)/mLE;
                if (fabs(dcorrL)>0.5) dcorrL=0.5*dcorrL/fabs(dcorrL);
                if (rLP>0) drLP=
                        sqrt(pow(hdatP[ii][jj]->GetMeanError()/hdatP[ii][jj]->GetMean(),2)+
                             1.f/hdatP[ii][jj]->Integral()+
                             pow(dcorrL/(1.0+sqrt((float) nIter)),2));
                else drLP=1.e-6;
                if (fabs(dcorrL)>0.001) {
                    //corrL*=1-20*dcorrL/(40+nIter*nIter);
                    //corrL*=1-dcorrL/(2+nIter);
                    corrL*=1-dcorrL/(1.0+sqrt((float) nIter));
                    //printf("%2d : %2d / %2d / 1 %7.3f %7.3f\n",nIter,ieta,iphi,dcorrL,corrL);
                    hmapPc->SetBinContent(14-ii,jj+1,corrL);
                    hmapPc->SetBinError(14-ii,jj+1,corrL*drLP);
                    hmapP->SetBinContent(14-ii,jj+1,rLP);
                }
                else {
                    printf("%2d : %2d / %2d / 3 %7.3f %8.4f %8.4f\n",
                           nIter,ieta,iphi,dcorrL,corrL,corrL*drLP);
                    hmapP->SetBinContent(14-ii,jj+1,rLP);
                    hmapPc->SetBinError(14-ii,jj+1,corrL*drLP);
                    break;
                }
                if (nIter==nIterN-1)
                    printf("%2d : %2d / %2d / 3 %8.4f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrL,corrL,corrL*drLP);
            }
        }
    }

    printf("\nieta      eta  width  dE/dPhidEta\n");
    double xeta[14], weta[14], yield[14];
    int ind=0;
    for (int i=0; i<14; i++) {
        int ieta=-(i+16);
        if (abs(ieta)!=16 && abs(ieta)!=27 && abs(ieta)!=28) continue;
        xeta[ind]=-(theHBHEEtaBounds[i+15]+theHBHEEtaBounds[i+16])/2;
        weta[ind]=(theHBHEEtaBounds[i+16]-theHBHEEtaBounds[i+15]);
        yield[ind]=mLEphi[i];
        if (abs(ieta)<21) yield[ind]*=72/weta[ind];
        else yield[ind]*=36/weta[ind];
        printf("%3d   3 %7.3f%7.3f   %g\n",ieta,xeta[ind],weta[ind],yield[ind]);
        ind++;
    }
    TCanvas *cgL = new TCanvas("cgL","cgL",300,300,600,600);
    TGraphErrors *grL = new TGraphErrors(ind,xeta,yield,0,0);
    grL->SetTitle("HEM ;#eta;E / #Delta#eta ,  GeV");
    grL->Draw("1+PAl");
    cgL->Print("pictHEplot/phiProfHEM3.gif");
    //cgL->Print("HEmc/phiProfM3.gif");


    //TFile *histf = new TFile("HEM3mc.root","RECREATE");

    FILE *ft1;
    sprintf(ctit,"corrHEM3_%s_%d_%d.txt",ftit,((int) Ethr1),((int) Ethr2));
    //sprintf(ctit,"corrHEM3_MC_%d_%d.txt",((int) Ethr1),((int) Ethr2));
    if ((ft1 = fopen(ctit,"w"))==NULL) {              // Open new file
        printf("\nNo file %s open => EXIT\n\n",file);
        return;
    }
    printf("\n\n File '%s' open \n\n",ctit);

    TH1D *hprL[14],*hprL0[14],*hprcL[16];
    TCanvas *cpr[14],*ccc[16];
    TLine *lin1 = new TLine(0,1,71,1);
    lin1->SetLineWidth(1);

    int noff=0;
    for (int ii=0; ii<14; ii++) {

        int ieta=-(ii+16);
        if (abs(ieta)!=16 && abs(ieta)!=27 && abs(ieta)!=28) continue;

        sprintf(ctit,"HEMcorr_%d_3",ieta);  // draw corrections
        hprcL[ii] = hmapPc->ProjectionY(ctit,14-ii,14-ii);
        hprcL[ii]->SetTitle(ctit);
        ccc[ii] = new TCanvas(ctit,ctit,800,100,500,500);
        hprcL[ii]->SetMinimum(0.41);
        hprcL[ii]->SetMaximum(hprcL[ii]->GetMaximum()*1.1);
        hprcL[ii]->SetTitleOffset(0.9,"X");
        hprcL[ii]->Draw("e");
        lin1->Draw();
        sprintf(ctit,"pictHEplot/HEM3corr_%d.gif",ieta);
        //sprintf(ctit,"HEmc/HEM3c_4_100G_%d.gif",ieta);
        ccc[ii]->Print(ctit);
        //hprcL[ii]->Write();

        sprintf(ctit,"HEM_E_%d_3;i#phi;GeV",ieta);
        hprL0[ii] = hmapP0->ProjectionY(ctit,14-ii,14-ii);
        hprL0[ii]->SetTitle(ctit);
        sprintf(ctit,"HEM__%d",ieta);
        hprL[ii] = hmapP->ProjectionY(ctit,14-ii,14-ii);
        if (abs(ieta)>20) {
            hprL[ii]->Rebin();
            hprL0[ii]->Rebin();
        }
        cpr[ii] = new TCanvas(ctit,ctit,800,100,500,500);
        hprL0[ii]->SetFillColor(3);
        hprL0[ii]->SetLineColor(3);
        hprL0[ii]->SetLineWidth(1);
        hprL0[ii]->SetTitleOffset(0.9,"X");
        hprL0[ii]->SetMinimum(0);
        hprL0[ii]->Draw("hist");
        hprL[ii]->Draw("samehist");
        sprintf(ctit,"pictHEplot/HEM_E_%d_3.gif",ieta);
        //sprintf(ctit,"HEmc/HEM_E_%d_3.gif",ieta);
        cpr[ii]->Print(ctit);
        //hprL0[ii]->Write();

        for (int jj=0; jj<72; jj++) {
            int ieta=-(ii+16);
            int iphi=jj+1;

            if (abs(ieta)>20 && iphi%2==0) continue;

            corrL=hmapPc->GetBinContent(14-ii,jj+1);
            dcorrL=hmapPc->GetBinError(14-ii,jj+1);
            hcorr1D->Fill(corrL);
            noff++;
            //printf("%2d : %2d / %2d / 3 %8.4f %8.4f\n",noff,ieta,iphi,corrL,dcorrL);
            fprintf(ft1,"%2d   %2d   3 %8.4f %8.4f\n",ieta,iphi,corrL,dcorrL);
        }
    }
    fclose(ft1);

    TCanvas *c1corr =new TCanvas("c1corr","c1corr",30,30,600,600);
    hcorr1D->Draw("hist");
    histStat(hcorr1D,1);
    c1corr->Print("pictHEplot/corrHEM3.gif");
    //c1corr->Print("HEmc/corrHEM3.gif");

    TCanvas *ctr = new TCanvas("ctr","ctr",0,0,650,600);
    htr->Draw("hist");
    ctr->Update();

    TCanvas *chmapP = new TCanvas("chmapP","chmapP",0,0,650,600);
    chmapP->cd();
    chmapP->SetRightMargin(0.12);
    chmapP->SetLogz();
    hmapP->SetAxisRange(hmapP->GetBinContent(14,1)/2,-1111,"Z");
    hmapP->Draw("colz");
    chmapP->Print("pictHEplot/hmapHEM3.gif");
    chmapP->Update();

    TCanvas *chmapP0 = new TCanvas("chmapP0","chmapP0",0,0,650,600);
    chmapP0->cd();
    chmapP0->SetRightMargin(0.12);
    chmapP0->SetLogz();
    hmapP0->SetAxisRange(hmapP0->GetBinContent(14,1)/2,-1111,"Z");
    hmapP0->Draw("colz");
    chmapP0->Print("pictHEplot/hmap0HEM3.gif");
    chmapP0->Update();

    TCanvas *chmapPc = new TCanvas("chmapPc","chmapPc",0,0,650,600);
    chmapPc->cd();
    chmapPc->SetRightMargin(0.12);
    hmapPc->SetAxisRange(0.6,2,"Z");
    hmapPc->Draw("colz");
    chmapPc->Print("pictHEplot/hmapcHEM3.gif");
    chmapPc->Update();

    sprintf(ctit,"HEM3o_%s_%d_%d.root",ftit,((int) Ethr1),((int) Ethr2));
    TFile *histf = new TFile(ctit,"RECREATE");
    hmapP->Write();
    hmapP0->Write();
    hmapPc->Write();
    histf->Close();

}
示例#15
0
void DrawNCLUSTER()
{
  //=========Macro generated from canvas: r1/Energy
  //=========  (Fri Apr  6 17:14:48 2012) by ROOT version5.28/00g
  TCanvas *r1 = new TCanvas("r1", "Ncluster",12,24,550,741);
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  gStyle->SetFrameLineWidth(1);
  r1->Range(0,0,1,1);
  r1->SetFillColor(0);
  r1->SetBorderMode(0);
  r1->SetBorderSize(0);
  r1->SetTickx(1);
  r1->SetTicky(1);
  r1->SetLeftMargin(0.16);
  r1->SetRightMargin(0.01);
  r1->SetTopMargin(0.0256917);
  r1->SetBottomMargin(0.07692308);
  r1->SetFrameBorderMode();
  
  // ------------>Primitives in pad: r1_1
  TPad *r1_1 = new TPad("r1_1", "Energy_1",0.02,0.37,0.95,0.99);
  r1_1->Draw();
  r1_1->cd();
  r1_1->Range(-19,0.01,95,95);
  r1_1->SetFillColor(0);
  r1_1->SetBorderMode(0);
  r1_1->SetBorderSize(2);
  r1_1->SetTickx(1);
  r1_1->SetTicky(1);
  r1_1->SetLeftMargin(0.16);
  r1_1->SetRightMargin(0.01);
  r1_1->SetTopMargin(0.02);
  r1_1->SetBottomMargin(0);
  r1_1->SetFrameBorderMode(0);
  r1_1->SetFrameBorderMode(0);
   
  TH1D *he = new TH1D("he"," ",55,0,55);
  he->SetMinimum(0.01);
  he->SetMaximum(70);
  he->SetStats(0);
  he->GetXaxis()->SetTitle("E_{beam} [GeV]");
  he->GetXaxis()->SetLabelFont(43);
  he->GetXaxis()->SetLabelSize(0);
  he->GetXaxis()->SetTitleFont(43);
  he->GetXaxis()->SetTitleSize(0); 
  he->GetYaxis()->SetTitle("<N_{cluster}>");
  he->GetYaxis()->SetLabelFont(43);
  he->GetYaxis()->SetTitleSize(30);
  he->GetYaxis()->SetLabelSize(20);
  he->GetYaxis()->SetTitleFont(43);
  he->GetYaxis()->SetTitleOffset(1.7);
  he->GetZaxis()->SetLabelFont(42);
  he->GetZaxis()->SetTitleSize(0.05);
  he->GetZaxis()->SetTitleFont(42);
  he->Draw("");
   
  std::vector<result> resultData=readTXT(std::string("ncluster_augsep2012_electron.txt"));
  TGraphErrors *gre = new TGraphErrors(resultData.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  gre->SetLineColor(1);
  gre->SetFillStyle(1);
  gre->SetFillColor(1);
  gre->SetLineWidth(2);
  gre->SetMarkerColor(1);
  gre->SetMarkerStyle(34);
  gre->SetMarkerSize(1.2);
  for(unsigned int i=0; i<resultData.size(); i++){
    gre->SetPoint(i,resultData.at(i).ebeam,resultData.at(i).ncluster);
    gre->SetPointError(i,0,resultData.at(i).nclusterError);
  }

  TH1F *Graph_Graph3 = new TH1F("Graph_Graph3","Graph",100,0,87.5);
  Graph_Graph3->SetMinimum(0);
  Graph_Graph3->SetMaximum(1193.483);
  Graph_Graph3->SetDirectory(0);
  Graph_Graph3->SetStats(0);
  Graph_Graph3->GetXaxis()->SetLabelFont(42);
  Graph_Graph3->GetXaxis()->SetTitleSize(0.05);
  Graph_Graph3->GetXaxis()->SetTitleFont(42);
  Graph_Graph3->GetYaxis()->SetLabelFont(42);
  Graph_Graph3->GetYaxis()->SetTitleSize(0.05);
  Graph_Graph3->GetYaxis()->SetTitleFont(42);
  Graph_Graph3->GetZaxis()->SetLabelFont(42);
  Graph_Graph3->GetZaxis()->SetTitleSize(0.05);
  Graph_Graph3->GetZaxis()->SetTitleFont(42);
  gre->SetHistogram(Graph_Graph3);
   
  gre->Draw("p");
   
  std::vector<result> resultFTFP=readTXT(std::string("ncluster_ftfp_bert_hp_electron.txt"));
  gre = new TGraphErrors(resultFTFP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  gre->SetFillColor(kRed-3);
  gre->SetMarkerColor(kRed-3);
  gre->SetLineWidth(2);
  gre->SetMarkerStyle(20);
  for(unsigned int i=0; i<resultFTFP.size(); i++){
    gre->SetPoint(i,resultFTFP.at(i).ebeam,resultFTFP.at(i).ncluster);
    gre->SetPointError(i,0,resultFTFP.at(i).nclusterError);
  }
   
  TH1F *Graph1 = new TH1F("Graph1","Graph",100,0,87.17072);
  Graph1->SetMinimum(2.655724);
  Graph1->SetMaximum(88.56778);
  Graph1->SetDirectory(0);
  Graph1->SetStats(0);
  Graph1->GetXaxis()->SetLabelFont(42);
  Graph1->GetXaxis()->SetTitleSize(0.05);
  Graph1->GetXaxis()->SetTitleFont(42);
  Graph1->GetYaxis()->SetLabelFont(42);
  Graph1->GetYaxis()->SetTitleSize(0.05);
  Graph1->GetYaxis()->SetTitleFont(42);
  Graph1->GetZaxis()->SetLabelFont(42);
  Graph1->GetZaxis()->SetTitleSize(0.05);
  Graph1->GetZaxis()->SetTitleFont(42);
  gre->SetHistogram(Graph1);
   
  gre->Draw("p");

  std::vector<result> resultQGSP=readTXT(std::string("ncluster_qgsp_bert_hp_electron.txt"));
  gre = new TGraphErrors(resultQGSP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  gre->SetFillColor(kBlue-6);
  gre->SetMarkerColor(kBlue-6);
  gre->SetLineWidth(2);
  gre->SetMarkerStyle(25);
  for(unsigned int i=0; i<resultQGSP.size(); i++){
    gre->SetPoint(i,resultQGSP.at(i).ebeam,resultQGSP.at(i).ncluster);
    gre->SetPointError(i,0,resultQGSP.at(i).nclusterError);
  }

  TH1F *Graph_Graph2 = new TH1F("Graph_Graph2","Graph",100,0,87.5);
  Graph_Graph2->SetMinimum(0);
  Graph_Graph2->SetMaximum(1193.483);
  Graph_Graph2->SetDirectory(0);
  Graph_Graph2->SetStats(0);
  Graph_Graph2->GetXaxis()->SetLabelFont(42);
  Graph_Graph2->GetXaxis()->SetTitleSize(0.05);
  Graph_Graph2->GetXaxis()->SetTitleFont(42);
  Graph_Graph2->GetYaxis()->SetLabelFont(42);
  Graph_Graph2->GetYaxis()->SetTitleSize(0.05);
  Graph_Graph2->GetYaxis()->SetTitleFont(42);
  Graph_Graph2->GetZaxis()->SetLabelFont(42);
  Graph_Graph2->GetZaxis()->SetTitleSize(0.05);
  Graph_Graph2->GetZaxis()->SetTitleFont(42);
  gre->SetHistogram(Graph_Graph2);
   
  gre->Draw("p");

  TLegend *leg = new TLegend(0.15,0.7,0.75,0.9,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextFont(62);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(0);
   
  TLegendEntry *entry=leg->AddEntry("Graph_Graph3","SDHCAL DATA (H6 Cern SPS)","p");
  entry->SetLineColor(1);
  entry->SetLineStyle(1);
  entry->SetLineWidth(1);
  entry->SetMarkerColor(1);
  entry->SetMarkerStyle(34);
  entry->SetMarkerSize(1.2);

  entry=leg->AddEntry("Graph1","FTFP_BERT_HP","p");
  entry->SetLineColor(kRed-3);
  entry->SetLineStyle(kRed-3);
  entry->SetLineWidth(kRed-3);
  entry->SetMarkerColor(kRed-3);
  entry->SetMarkerStyle(20);
  entry->SetMarkerSize(1.0);

  entry=leg->AddEntry("Graph_Graph2","QGSP_BERT_HP","p");
  entry->SetLineColor(kBlue-6);
  entry->SetLineStyle(kBlue-6);
  entry->SetLineWidth(kBlue-6);
  entry->SetMarkerColor(kBlue-6);
  entry->SetMarkerStyle(25);
  entry->SetMarkerSize(0.9);

  leg->Draw();

  TText *tex=new TText();
  tex->SetTextSize(0.05);
  tex->SetTextColor(kGray+2);
  //tex->DrawTextNDC(0.5,0.05,"SDHCAL Preliminary");
  tex->DrawTextNDC(0.3,0.05,"CALICE Fe-SDHCAL Preliminary");
  r1_1->Modified();
  r1->cd();
  
  // ------------>Primitives in pad: r1_2
  TPad *r1_2 = new TPad("r1_2", "Energy_2",0.02,0.0,0.95,0.38);
  r1_2->Draw();
  r1_2->cd();
  r1_2->Range(-19,-0.06545455,95,0.048);
  r1_2->SetFillColor(0);
  r1_2->SetBorderMode(0);
  r1_2->SetBorderSize(2);
  r1_2->SetTickx(1);
  r1_2->SetTicky(1);
  r1_2->SetLeftMargin(0.16);
  r1_2->SetRightMargin(0.01);
  r1_2->SetTopMargin(0.0);
  r1_2->SetBottomMargin(0.23);
  r1_2->SetFrameBorderMode(0);
  r1_2->SetFrameBorderMode(0);
   
  TH1D *hd = new TH1D("hd"," ",55,0,55);
  hd->SetMinimum(-0.20);
  hd->SetMaximum(0.20);
  hd->SetStats(0);
  hd->GetXaxis()->SetTitle("E_{beam} [GeV]");
  hd->GetXaxis()->SetLabelFont(43);
  hd->GetXaxis()->SetLabelSize(20);
  hd->GetXaxis()->SetTitleFont(43);
  hd->GetXaxis()->SetTitleSize(30);
  hd->GetXaxis()->SetTitleOffset(2.);
  hd->GetYaxis()->SetTitle("(#DeltaN_{cluster})/N_{data}");
  hd->GetYaxis()->SetLabelFont(43);
  hd->GetYaxis()->SetLabelSize(20);
  hd->GetYaxis()->SetTitleSize(30);
  hd->GetYaxis()->SetTitleOffset(1.7);
  hd->GetYaxis()->SetTitleFont(43);
  hd->GetYaxis()->SetNdivisions(505);
  hd->GetZaxis()->SetLabelFont(42);
  hd->GetZaxis()->SetTitleSize(0.05);
  hd->GetZaxis()->SetTitleFont(42);
  hd->Draw("");
   
  float deltaError;
  float delta;
  gre = new TGraphErrors(resultQGSP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  for(unsigned int i=0; i<resultQGSP.size(); i++){
    delta=(resultQGSP.at(i).ncluster-resultData.at(i).ncluster)/resultData.at(i).ncluster;
    deltaError=1/resultData.at(i).ncluster*
      sqrt(pow(resultQGSP.at(i).nclusterError,2) +
	   pow(resultQGSP.at(i).ncluster/resultData.at(i).ncluster*resultData.at(i).nclusterError,2));
    gre->SetPoint(i,resultQGSP.at(i).ebeam,delta);
    gre->SetPointError(i,0,deltaError);
  }
  gre->SetLineWidth(2);
  gre->SetLineColor(kBlue-6);
  gre->SetMarkerColor(kBlue-6);
  gre->SetMarkerSize(1.0);
  gre->SetMarkerStyle(25);
   
  gre->Draw("p");
   
  gre = new TGraphErrors(resultFTFP.size());
  gre->SetName("Graph");
  gre->SetTitle("Graph");
  for(unsigned int i=0; i<resultFTFP.size(); i++){
    delta=(resultFTFP.at(i).ncluster-resultData.at(i).ncluster)/resultData.at(i).ncluster;
    deltaError=1/resultData.at(i).ncluster*
      sqrt(pow(resultFTFP.at(i).nclusterError,2) +
	   pow(resultFTFP.at(i).ncluster/resultData.at(i).ncluster*resultData.at(i).nclusterError,2));
    gre->SetPoint(i,resultFTFP.at(i).ebeam,delta);
    gre->SetPointError(i,0,deltaError);
  }
  gre->SetLineWidth(2);
  gre->SetLineColor(kRed-3);
  gre->SetMarkerColor(kRed-3);
  gre->SetMarkerSize(1.0);
  gre->SetMarkerStyle(20);
   
  gre->Draw("p");
   
   
  TF1 *lin1 = new TF1("lin1","0",-0.01,95);
  lin1->SetFillColor(19);
  lin1->SetFillStyle(0);
  lin1->SetLineWidth(1);
  lin1->SetLineStyle(1);
  lin1->SetLineColor(1);
  lin1->GetXaxis()->SetLabelFont(42);
  lin1->GetXaxis()->SetTitleSize(0.05);
  lin1->GetXaxis()->SetTitleFont(42);
  lin1->GetYaxis()->SetLabelFont(42);
  lin1->GetYaxis()->SetTitleSize(0.05);
  lin1->GetYaxis()->SetTitleFont(42);
  lin1->Draw("same");
   
  lin1 = new TF1("lin1","0.1",0.01,95);
  lin1->SetFillColor(1);
  lin1->SetFillStyle(0);
  lin1->SetLineWidth(1);
  lin1->SetLineStyle(2);
  lin1->SetLineColor(17);
  lin1->GetXaxis()->SetLabelFont(42);
  lin1->GetXaxis()->SetTitleSize(0.05);
  lin1->GetXaxis()->SetTitleFont(42);
  lin1->GetYaxis()->SetLabelFont(42);
  lin1->GetYaxis()->SetTitleSize(0.05);
  lin1->GetYaxis()->SetTitleFont(42);
  lin1->Draw("same");
   
  lin1 = new TF1("lin1","-0.1",0.01,95);
  lin1->SetFillColor(1);
  lin1->SetFillStyle(0);
  lin1->SetLineWidth(1);
  lin1->SetLineStyle(2);
  lin1->SetLineColor(17);
  lin1->GetXaxis()->SetLabelFont(42);
  lin1->GetXaxis()->SetTitleSize(0.05);
  lin1->GetXaxis()->SetTitleFont(42);
  lin1->GetYaxis()->SetLabelFont(42);
  lin1->GetYaxis()->SetTitleSize(0.05);
  lin1->GetYaxis()->SetTitleFont(42);
  lin1->Draw("same");

  r1_2->Modified();
  r1->cd();
  r1->Modified();
  r1->cd();
  r1->SetSelected(r1);
  r1->SaveAs("../plots/NCLUSTERELECTRON.pdf");
}
void srcPositionStudy(Int_t binWidth, TString source, TString geometry) {

  int numFiles = 200; 

  TString simLocation;
  TChain *chain = new TChain("anaTree");

  if (geometry==TString("2011-2012")) simLocation = TString(getenv("SIM_2011_2012"));
  else if (geometry==TString("2012-2013")) simLocation = TString(getenv("SIM_2012_2013"));
  else if (geometry==TString("2012-2013_ISOBUTANE")) simLocation = TString(getenv("SIM_2012_2013_ISOBUTANE"));
  else { std::cout << "BAD GEOMETRY\n"; exit(0); }

  for (int i=0; i<numFiles; i++) {
    chain->AddFile(TString::Format("%s/%s/analyzed_%i.root",simLocation.Data(),source.Data(),i));
  }
  

  Double_t maxEn = 1500.;
  Double_t minEn = 0.;
  Double_t fidMax = 55.;
  Int_t nHists = (int)(fidMax/binWidth);
  
  
  
  std::vector <TH1D*> histsE(nHists, 0);
  std::vector <TH1D*> histsW(nHists, 0);
  std::vector <Double_t> rmin(nHists,0);
  std::vector <Double_t> rmax(nHists,0);
  std::vector <Double_t> rmid(nHists,0);

  //final means and errors
  std::vector < Double_t > EastMeans(nHists,0.);
  std::vector < Double_t > WestMeans(nHists,0.);
  
  std::vector < Double_t > EastMeanErrors(nHists,0.);
  std::vector < Double_t > WestMeanErrors(nHists,0.);

  for (Int_t i=0; i<nHists; i++) {

    rmin[i] = i*binWidth;
    rmax[i] = (i+1)*binWidth;
    rmid[i] = (double)rmin[i] + (double)binWidth/2.;

    histsE[i] = new TH1D(TString::Format("his%iE",i), 
			 TString::Format("%s %i mm radius bins East", source.Data(),binWidth),
			550, 0., 1100.);
    histsW[i] = new TH1D(TString::Format("his%iW",i), 
			 TString::Format("%s %i mm radius bins West", source.Data(),binWidth),
			550, 0., 1100.);

    histsE[i]->SetLineColor(i+1);
    histsW[i]->SetLineColor(i+1);
  }

  Double_t primPos[4];

  // Set the addresses of the information read in from the simulation file
  chain->SetBranchAddress("MWPCEnergy",&mwpcE);
  chain->SetBranchAddress("time",&Time);
  chain->SetBranchAddress("Edep",&edep);
  chain->SetBranchAddress("EdepQ",&edepQ);
  chain->SetBranchAddress("MWPCPos",&mwpc_pos);
  chain->SetBranchAddress("ScintPos",&scint_pos);
  chain->SetBranchAddress("primKE",&primKE);
  chain->SetBranchAddress("primTheta",&primTheta);
  chain->SetBranchAddress("primPos",&primPos);


  //Get total number of events in TChain
  UInt_t nevents = chain->GetEntries();
  cout << "events = " << nevents << endl;

  for (Int_t i=0; i<nevents; i++) {
    
    chain->GetEvent(i);

    Int_t nBin = primPos[3]*1000./binWidth;

    if (edepQ.EdepQE>0. && primKE<maxEn && primKE>minEn && mwpcE.MWPCEnergyE>0.1 && primTheta>TMath::Pi()/2.) histsE[nBin]->Fill(edepQ.EdepQE);
    if (edepQ.EdepQW>0. && primKE<maxEn && primKE>minEn && mwpcE.MWPCEnergyW>0.1 && primTheta<TMath::Pi()/2.) histsW[nBin]->Fill(edepQ.EdepQW);

    if (i%100000==0) std::cout << "*";
  }
  
  std::cout << std::endl;

  TCanvas *c1 = new TCanvas("c1","c1",1600,1200);
  c1->Divide(2,2);
  //TCanvas *c2 = new TCanvas("c2");
  
  //histsE[1]->Draw("SAME");
  
  Double_t refMeanE = 0., refMeanW = 0.; //This will hold the mean of the center pixel

  std::cout << nHists << endl;  
  for (Int_t i=0; i<nHists; i++) {
    c1->cd(1);
    histsE[i]->Draw("SAME");
    
    EastMeans[i] = histsE[i]->GetMean();
    EastMeanErrors[i] = EastMeans[i]>0. ? EastMeans[i]/sqrt(histsE[i]->GetEntries()) : 0.;
    //cout << EastMeans[i][0] << " " << EastMeans[i][1] << endl;

    c1->cd(2);
    histsW[i]->Draw("SAME");
    
    WestMeans[i] = histsW[i]->GetMean();
    WestMeanErrors[i] = WestMeans[i]>0. ? WestMeans[i]/sqrt(histsW[i]->GetEntries()) : 0.;

    if (i==0) { refMeanE = EastMeans[i], refMeanW = WestMeans[i]; }
  }

  

  //TCanvas *c3 = new TCanvas("c3");
  c1->cd(3);

  std::vector <Double_t> xerr(nHists,0.);
  
  TGraphErrors *gEast = new TGraphErrors(11, &rmax[0],&EastMeans[0],&xerr[0],&EastMeanErrors[0]);
  gEast->SetMarkerStyle(21);
  gEast->SetTitle(TString::Format("East %s Mean EQ vs. position",source.Data()));
  gEast->GetXaxis()->SetTitle("Position Bin Edge (mm)");
  gEast->GetYaxis()->SetTitle("Energy (keV)");
  gEast->Draw("AP");

  TLine *eastLine = new TLine(gEast->GetXaxis()->GetXmin(),refMeanE,gEast->GetXaxis()->GetXmax(),refMeanE);
  eastLine->SetLineStyle(2);
  eastLine->Draw();
 

  //TCanvas *c4 = new TCanvas("c4");
  c1->cd(4);

  TGraphErrors *gWest = new TGraphErrors(11, &rmax[0],&WestMeans[0],&xerr[0],&WestMeanErrors[0]);
  gWest->SetMarkerStyle(21);
  gWest->SetTitle(TString::Format("West %s Mean EQ vs. position",source.Data()));
  gWest->GetXaxis()->SetTitle("Position Bin Edge (mm)");
  gWest->GetYaxis()->SetTitle("Energy (keV)");
  gWest->Draw("AP");

  TLine *westLine = new TLine(gWest->GetXaxis()->GetXmin(),refMeanW,gWest->GetXaxis()->GetXmax(),refMeanW);
  westLine->SetLineStyle(2);
  westLine->Draw();

  
    


}
void para_12TeV_2Lep_plots_All()
{
//=========Macro generated from canvas: c1/Parameter1
//=========  (Sun Nov 22 20:05:00 2015) by ROOT version6.02/12
    TCanvas *c1 = new TCanvas("c1", "Parameter1",0,22,1000,600);
    gStyle->SetOptStat(0);
    c1->Range(-4.375,-0.2745458,39.375,2.490986);
    c1->SetFillColor(0);
    c1->SetBorderMode(0);
    c1->SetBorderSize(2);
    c1->SetGridx();
    c1->SetGridy();
    c1->SetFrameBorderMode(0);
    c1->SetFrameBorderMode(0);

    TH1F *NuisanceParameterFreed2 = new TH1F("NuisanceParameterFreed2","Mu",35,0,35);
    NuisanceParameterFreed2->SetMinimum(0.00200744);
    NuisanceParameterFreed2->SetMaximum(2.214433);
    NuisanceParameterFreed2->SetStats(0);

    Int_t ci;      // for color index setting
    TColor *color; // for color definition with alpha
    ci = TColor::GetColor("#000099");
    NuisanceParameterFreed2->SetLineColor(ci);
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(1,"MUONS_MS");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(2,"Luminosity");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(3,"XS_Zb");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(4,"FT_EFF_Eigen_C_2");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(5,"MUON_EFF_TrigStatUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(6,"FT_EFF_Eigen_C_3");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(7,"FT_EFF_Eigen_B_0");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(8,"MUON_EFF_SYS");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(9,"MUON_EFF_STAT");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(10,"FT_EFF_Eigen_Light_3");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(11,"FT_EFF_Eigen_Light_4");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(12,"global");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(13,"MUONS_SCALE");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(14,"MUON_ISO_STAT");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(15,"FT_EFF_Eigen_C_0");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(16,"EL_EFF_Iso_TotalCorrUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(17,"FT_EFF_Eigen_B_1");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(18,"XS_diboson");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(19,"XS_st");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(20,"MUON_EFF_TrigSystUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(21,"EG_RESOLUTION_ALL");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(22,"FT_EFF_Eigen_B_2");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(23,"MUONS_ID");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(24,"EL_EFF_Reco_TotalCorrUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(25,"EG_SCALE_ALL");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(26,"FT_EFF_extrapolation");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(27,"FT_EFF_Eigen_Light_1");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(28,"FT_EFF_Eigen_Light_2");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(29,"FT_EFF_Eigen_C_1");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(30,"MUON_ISO_SYS");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(31,"FT_EFF_Eigen_Light_0");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(32,"EL_EFF_ID_TotalCorrUncertainty");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(33,"XS_Zl");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(34,"XS_Zc");
    NuisanceParameterFreed2->GetXaxis()->SetBinLabel(35,"XS_ttbar");
    NuisanceParameterFreed2->GetXaxis()->SetLabelFont(42);
    NuisanceParameterFreed2->GetXaxis()->SetLabelSize(0.035);
    NuisanceParameterFreed2->GetXaxis()->SetTitleSize(0.035);
    NuisanceParameterFreed2->GetXaxis()->SetTitleFont(42);
    NuisanceParameterFreed2->GetYaxis()->SetTitle("#mu_{best}");
    NuisanceParameterFreed2->GetYaxis()->SetLabelFont(42);
    NuisanceParameterFreed2->GetYaxis()->SetLabelSize(0.035);
    NuisanceParameterFreed2->GetYaxis()->SetTitleSize(0.035);
    NuisanceParameterFreed2->GetYaxis()->SetTitleFont(42);
    NuisanceParameterFreed2->GetZaxis()->SetLabelFont(42);
    NuisanceParameterFreed2->GetZaxis()->SetLabelSize(0.035);
    NuisanceParameterFreed2->GetZaxis()->SetTitleSize(0.035);
    NuisanceParameterFreed2->GetZaxis()->SetTitleFont(42);
    NuisanceParameterFreed2->Draw("hist");

    Double_t _fx1002[37] = {
        0,
        0.5,
        1.5,
        2.5,
        3.5,
        4.5,
        5.5,
        6.5,
        7.5,
        8.5,
        9.5,
        10.5,
        11.5,
        12.5,
        13.5,
        14.5,
        15.5,
        16.5,
        17.5,
        18.5,
        19.5,
        20.5,
        21.5,
        22.5,
        23.5,
        24.5,
        25.5,
        26.5,
        27.5,
        28.5,
        29.5,
        30.5,
        31.5,
        32.5,
        33.5,
        34.5,
        0
    };
    Double_t _fy1002[37] = {
        0,
        0.00200744,
        2.065197,
        2.090439,
        2.097085,
        2.102307,
        2.102459,
        2.103994,
        2.109032,
        2.110826,
        2.110827,
        2.110944,
        2.111107,
        2.111297,
        2.111303,
        2.111389,
        2.11147,
        2.1115,
        2.112008,
        2.112152,
        2.112174,
        2.112884,
        2.113456,
        2.113847,
        2.114265,
        2.114548,
        2.11588,
        2.116422,
        2.117402,
        2.123061,
        2.129504,
        2.131184,
        2.133743,
        2.13776,
        2.138737,
        2.214433,
        0
    };
    Double_t _fex1002[37] = {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0
    };
    Double_t _fey1002[37] = {
        0,
        0,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10,
        10
    };
    TGraphErrors *gre = new TGraphErrors(37,_fx1002,_fy1002,_fex1002,_fey1002);
    gre->SetName("");
    gre->SetTitle("");
    gre->SetFillColor(1);
    gre->SetMarkerStyle(20);
    gre->SetMarkerSize(1.2);

    TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","",100,0,37.95);
    Graph_Graph1002->SetMinimum(-12.22144);
    Graph_Graph1002->SetMaximum(14.43588);
    Graph_Graph1002->SetDirectory(0);
    Graph_Graph1002->SetStats(0);

    ci = TColor::GetColor("#000099");
    Graph_Graph1002->SetLineColor(ci);
    Graph_Graph1002->GetXaxis()->SetLabelFont(42);
    Graph_Graph1002->GetXaxis()->SetLabelSize(0.035);
    Graph_Graph1002->GetXaxis()->SetTitleSize(0.035);
    Graph_Graph1002->GetXaxis()->SetTitleFont(42);
    Graph_Graph1002->GetYaxis()->SetLabelFont(42);
    Graph_Graph1002->GetYaxis()->SetLabelSize(0.035);
    Graph_Graph1002->GetYaxis()->SetTitleSize(0.035);
    Graph_Graph1002->GetYaxis()->SetTitleFont(42);
    Graph_Graph1002->GetZaxis()->SetLabelFont(42);
    Graph_Graph1002->GetZaxis()->SetLabelSize(0.035);
    Graph_Graph1002->GetZaxis()->SetTitleSize(0.035);
    Graph_Graph1002->GetZaxis()->SetTitleFont(42);
    gre->SetHistogram(Graph_Graph1002);

    gre->Draw("p");

    TLegend *leg = new TLegend(0.1,0.4,0.4,0.95,NULL,"brNDC");
    leg->SetBorderSize(0);
    leg->SetTextFont(72);
    leg->SetTextSize(0.015);
    leg->SetLineColor(1);
    leg->SetLineStyle(1);
    leg->SetLineWidth(1);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    TLegendEntry *entry=leg->AddEntry("","global","P");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(1);
    entry->SetMarkerColor(1);
    entry->SetMarkerStyle(20);
    entry->SetMarkerSize(1.2);
    entry->SetTextFont(72);
    leg->Draw();

    TPaveText *pt = new TPaveText(0.4694177,0.94,0.5305823,0.995,"blNDC");
    pt->SetName("title");
    pt->SetBorderSize(0);
    pt->SetFillColor(0);
    pt->SetFillStyle(0);
    pt->SetTextFont(42);
    TText *AText = pt->AddText("Mu");
    pt->Draw();
    c1->Modified();
    c1->cd();
    c1->SetSelected(c1);
}
void RenameGraph( TGraphErrors & graph , TString name )
{
    graph.SetName( name.Data() );
    graph.SetTitle( name.Data() );
}
void vnpt_5panels_ratio()
{
  gROOT->Reset();
  gROOT->SetStyle("MyStyle");
//  gROOT->LoadMacro("v2pt_12cen_MyDef.C");
  // gROOT->LoadMacro("MyDef.C");
  gStyle->SetTextFont(43);
  gStyle->SetLabelFont(43,"x");
  gStyle->SetLabelFont(43,"y");
  gStyle->SetLabelFont(43,"z");
  gStyle->SetTitleFont(43,"x");
  gStyle->SetTitleFont(43,"y");
  gStyle->SetTitleFont(43,"z");
  gStyle->SetEndErrorSize(0);

  double textsize = 19;

//int   mcol[8]={kRed,kMagenta,kBlue,kCyan,kGreen,kYellow,kOrange,kGray};
int   mcol[8]={kRed,kOrange+1,kBlue,kGreen+1,kCyan,kYellow,kOrange,kGray};
int   mcol2[4]={6,2,4,8};

//int   msty[8][2]={{20,20},{25,24},{22,22},{28,26},{29,30},{33,27},{34,28},{20,24}};
int   msty[8][2]={{20,20},{21,24},{22,29},{23,30},{24,30},{25,27},{28,28},{30,24}};


//float msiz[8]={1.11,0.9,1.2,1.24,1.5,1,1,1};
float msiz[8]={1.11,1.0,1.5,1.2,1.2,1.2,1.2,1.6};
float msiz2[4]={1.5,1.5,1.5,1.5};
//
// arrays
//
const int Mfiles=50;
int   ndp[Mfiles];
char *cfn[Mfiles];
char *cft[Mfiles];
const int Mpoints=40;
double xa[Mfiles][Mpoints],xe[Mfiles][Mpoints],xesys[Mfiles][Mpoints];
double ya[Mfiles][Mpoints],ye[Mfiles][Mpoints],yesys[Mfiles][Mpoints];  

double nAxa[Mfiles][Mpoints],nAxe[Mfiles][Mpoints];
double nAya[Mfiles][Mpoints],nAye[Mfiles][Mpoints];
double nBxa[Mfiles][Mpoints],nBxe[Mfiles][Mpoints];
double nBya[Mfiles][Mpoints],nBye[Mfiles][Mpoints];
double nARxa[Mfiles][Mpoints],nARxe[Mfiles][Mpoints];
double nARya[Mfiles][Mpoints],nARye[Mfiles][Mpoints];
double nBRxa[Mfiles][Mpoints],nBRxe[Mfiles][Mpoints];
double nBRya[Mfiles][Mpoints],nBRye[Mfiles][Mpoints];

double xa60[Mfiles][Mpoints],xe60[Mfiles][Mpoints],xesys60[Mfiles][Mpoints];
double ya60[Mfiles][Mpoints],ye60[Mfiles][Mpoints],yesys60[Mfiles][Mpoints];
double nAxa60[Mfiles][Mpoints],nAxe60[Mfiles][Mpoints];
double nAya60[Mfiles][Mpoints],nAye60[Mfiles][Mpoints];
double nBxa60[Mfiles][Mpoints],nBxe60[Mfiles][Mpoints];
double nBya60[Mfiles][Mpoints],nBye60[Mfiles][Mpoints];
double nARxa60[Mfiles][Mpoints],nARxe60[Mfiles][Mpoints];
double nARya60[Mfiles][Mpoints],nARye60[Mfiles][Mpoints];
double nBRxa60[Mfiles][Mpoints],nBRxe60[Mfiles][Mpoints];
double nBRya60[Mfiles][Mpoints],nBRye60[Mfiles][Mpoints];

const int Mpads=14;


char  *htit[Mpads];
char  *htitc2[Mpads];
char  *atit[Mpads][3];
double ptit[Mpads][2];
double hxmin[Mpads],hxmax[Mpads];
double hymin[Mpads],hymax[Mpads];
double lxmin[Mpads],lxmax[Mpads];
double lymin[Mpads],lymax[Mpads];


 
  //
  // Data input
  //
  char *cjob="v2pt_12cen_4x3";
  int i=-1;


  // histogram parameter
  htit[0]="(a) v_{4}{#Psi_{22}}";
  htit[1]="(b) v_{5}{#Psi_{23}}";
  htit[2]="(c) v_{6}{#Psi_{222}}";
  htit[3]="(d) v_{6}{#Psi_{33}}";
  htit[4]="(e) v_{7}{#Psi_{223}}";
  htit[5]="25-30%";
  htit[6]="30-35%";
  htit[7]="35-40%";
  htit[8]="40-50%";
  htit[9]="50-60%";
  htit[10]="60-70%";
  htit[11]="70-80%";
  htitc2[0]="(f) v_{4}{#Psi_{22}}";
  htitc2[1]="(g) v_{5}{#Psi_{23}}";
  htitc2[2]="(h) v_{6}{#Psi_{222}}";
  htitc2[3]="(i) v_{6}{#Psi_{33}}";
  htitc2[4]="(j) v_{7}{#Psi_{223}}";
  for (int ip=0;ip<Mpads;ip++)
  {
    //  hxmin[ip]=0.0; hxmax[ip]=11.9;
    hxmin[ip]=0.0001; hxmax[ip]=4.1;
    hymin[ip]=-0.003; hymax[ip]=0.0655;
    lxmin[ip]=0.24; lxmax[ip]=0.88;
    lymin[ip]=0.65; lymax[ip]=0.94;
    ptit[ip][0]=0.45; ptit[ip][1]=0.036;// position legends 
    atit[ip][0]="p_{T} (GeV/c)"; atit[ip][1]="v_{n}";
  }
  //
  // Read data and create vector files
  //

  double sysXYZ[5]={6,7,8,8,9};
  //double sysXYZ[5]={8,9,12,12,15};
  //double sysXYZ[5]={8,9,20,20,20};
  double sysEach[5]={0.0002, 0.0002, 0.0002, 0.0003, 0.0002};
  double tmp;
  const int nw=5;
  const int npt=20;
  ifstream inEP;
  inEP.open("./data_vnptcent020_5020gev.txt");
  for(int i=0; i<nw; i++){
    for(int j=0; j<npt; j++){
      inEP>>tmp; inEP>>tmp; inEP>>xa[i][j]; inEP>>tmp; inEP>>ya[i][j]; inEP>>ye[i][j];
      if(ye[i][j]<0) ye[i][j]=-ye[i][j];
      xe[i][j]=0.0;
    }
  }
  inEP.close();
  ifstream inEP;
  inEP.open("./data_vnptcent020_5020gev_vzA.txt");
  for(int i=0; i<nw; i++){
    for(int j=0; j<npt; j++){
      inEP>>tmp; inEP>>tmp; inEP>>nAxa[i][j]; inEP>>tmp; inEP>>nAya[i][j]; inEP>>nAye[i][j];
      if(nAye[i][j]<0) nAye[i][j]=-nAye[i][j];
      nAxe[i][j]=0.0; 

      nARxa[i][j]=nAxa[i][j];
      nARxe[i][j]=nAxe[i][j];
      nARye[i][j]=nAya[i][j]/ya[i][j]*sqrt(ye[i][j]*ye[i][j]/ya[i][j]/ya[i][j] + nAye[i][j]*nAye[i][j]/nAya[i][j]/nAya[i][j] - 2.5*ye[i][j]*ye[i][j]/ya[i][j]/nAya[i][j] );
      nARya[i][j]=nAya[i][j]/ya[i][j];
    }
  }
  inEP.close();
  ifstream inEP;
  inEP.open("./data_vnptcent020_5020gev_vzB.txt");
  for(int i=0; i<nw; i++){
    for(int j=0; j<npt; j++){
      inEP>>tmp; inEP>>tmp; inEP>>nBxa[i][j]; inEP>>tmp; inEP>>nBya[i][j]; inEP>>nBye[i][j];
      if(nBye[i][j]<0) nBye[i][j]=-nBye[i][j];
      nBxe[i][j]=0.0; 

      nBRxa[i][j]=nBxa[i][j];
      nBRxe[i][j]=nBxe[i][j];
      nBRye[i][j]=nBya[i][j]/ya[i][j]*sqrt(ye[i][j]*ye[i][j]/ya[i][j]/ya[i][j] + nBye[i][j]*nBye[i][j]/nBya[i][j]/nBya[i][j] - 2.5*ye[i][j]*ye[i][j]/ya[i][j]/nBya[i][j] );
      nBRya[i][j]=nBya[i][j]/ya[i][j];
    }
  }
  inEP.close();

//20-60%
  ifstream inEP;
  inEP.open("./data_vnptcent2060_5020gev.txt");
  for(int i=0; i<nw; i++){
    for(int j=0; j<npt; j++){
      inEP>>tmp; inEP>>tmp; inEP>>xa60[i][j]; inEP>>tmp; inEP>>ya60[i][j]; inEP>>ye60[i][j];
      if(ye60[i][j]<0) ye60[i][j]=-ye60[i][j];
      xe60[i][j]=0.0;
    }
  }
  inEP.close();
  ifstream inEP;
  inEP.open("./data_vnptcent2060_5020gev_vzA.txt");
  for(int i=0; i<nw; i++){
    for(int j=0; j<npt; j++){
      inEP>>tmp; inEP>>tmp; inEP>>nAxa60[i][j]; inEP>>tmp; inEP>>nAya60[i][j]; inEP>>nAye60[i][j];
      if(nAye60[i][j]<0) nAye60[i][j]=-nAye60[i][j];
      nAxe60[i][j]=0.0; 

      nARxa60[i][j]=nAxa60[i][j];
      nARxe60[i][j]=nAxe60[i][j];
      nARye60[i][j]=nAya60[i][j]/ya60[i][j]*sqrt(ye60[i][j]*ye60[i][j]/ya60[i][j]/ya60[i][j] + nAye60[i][j]*nAye60[i][j]/nAya60[i][j]/nAya60[i][j] - 2.5*ye60[i][j]*ye60[i][j]/ya60[i][j]/nAya60[i][j] );
      nARya60[i][j]=nAya60[i][j]/ya60[i][j];
    }
  }
  inEP.close();
  ifstream inEP;
  inEP.open("./data_vnptcent2060_5020gev_vzB.txt");
  for(int i=0; i<nw; i++){
    for(int j=0; j<npt; j++){
      inEP>>tmp; inEP>>tmp; inEP>>nBxa60[i][j]; inEP>>tmp; inEP>>nBya60[i][j]; inEP>>nBye60[i][j];
      if(nBye60[i][j]<0) nBye60[i][j]=-nBye60[i][j];
      nBxe60[i][j]=0.0; 

      nBRxa60[i][j]=nBxa60[i][j];
      nBRxe60[i][j]=nBxe60[i][j];
      nBRye60[i][j]=nBya60[i][j]/ya60[i][j]*sqrt(ye60[i][j]*ye60[i][j]/ya60[i][j]/ya60[i][j] + nBye60[i][j]*nBye60[i][j]/nBya60[i][j]/nBya60[i][j] - 2.5*ye60[i][j]*ye60[i][j]/ya60[i][j]/nBya60[i][j] );
      nBRya60[i][j]=nBya60[i][j]/ya60[i][j];
    }
  }
  inEP.close();
nBRya60[1][2]=1.06;

  TCanvas *can=new TCanvas("can","can",10,10,1050*0.8*1.3,800*0.3*1.3*1.8);

  can->Divide(5,2,0,0); //sticks the pads with no space inbetween 
  
  TH1D *h1[nw];
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);
    if(iw==4) gPad->SetRightMargin(0.02);
    //gPad->SetLogy();
    char ch1[8];
    sprintf(ch1,"h1_%d",iw);
    h1[iw] = new TH1D(ch1,"",500,hxmin[iw],hxmax[iw]);
    h1[iw]->SetMinimum(0.5); h1[iw]->SetMaximum(1.5);
    h1[iw]->SetXTitle(atit[iw][0]); h1[iw]->SetYTitle("v_{n} ratio");
    h1[iw]->GetXaxis()->CenterTitle(1);
    h1[iw]->GetYaxis()->CenterTitle(1);

    // futz with the axes
    h1[iw]->GetYaxis()->SetNdivisions(606);
    h1[iw]->GetXaxis()->SetNdivisions(606);

      h1[iw]->GetYaxis()->SetTitleSize(textsize*1.4);
      h1[iw]->GetYaxis()->SetTitleOffset(2.3);
      h1[iw]->GetYaxis()->SetLabelSize(textsize);
      h1[iw]->GetXaxis()->SetTitleSize(textsize*1.4);
      h1[iw]->GetXaxis()->SetTitleOffset(1.3);
      h1[iw]->GetXaxis()->SetLabelSize(textsize);
     // h1[iw]->GetXaxis()->SetLabelOffset(1.2);

    h1[iw]->Draw();
  }
  TH1D *h2[nw];
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1+5);

    if(iw==4) gPad->SetRightMargin(0.02);
    //gPad->SetLogy();
    char ch2[8];
    sprintf(ch2,"h2_%d",iw);
    h2[iw] = new TH1D(ch2,"",500,hxmin[iw],hxmax[iw]);
    h2[iw]->SetMinimum(0.5); h2[iw]->SetMaximum(1.5);
    h2[iw]->SetXTitle(atit[iw][0]); h2[iw]->SetYTitle("v_{n} ratio");
    h2[iw]->GetXaxis()->CenterTitle(1);
    h2[iw]->GetYaxis()->CenterTitle(1);

    // futz with the axes
    h2[iw]->GetYaxis()->SetNdivisions(606);
    h2[iw]->GetXaxis()->SetNdivisions(606);

      h2[iw]->GetYaxis()->SetTitleSize(textsize*1.4);
      h2[iw]->GetYaxis()->SetTitleOffset(2.3);
      h2[iw]->GetYaxis()->SetLabelSize(textsize*1.2);
      h2[iw]->GetXaxis()->SetTitleSize(textsize*1.4);
      h2[iw]->GetXaxis()->SetTitleOffset(1.9);
      h2[iw]->GetXaxis()->SetLabelSize(textsize*1.2);
     // h2[iw]->GetXaxis()->SetLabelOffset(1.2);

    h2[iw]->Draw();
  }

  //
  // Draw! 
  //

  const int nPlotBin = 40;
  double ptPlot[nPlotBin];
  double vnPlot[nPlotBin];
  double errPlot[nPlotBin];

  cout << "Now Draw!" << endl;
  TGraphErrors *ge, *ge2, *ge3, *ge4;
  for (int iw=0;iw<nw;iw++)
  {
    can->cd(iw+1);

    //
    if (iw==0)
    {
      tex=new TLatex(0.6,0.0235*0.88*1.275*1.47*1.6,"CMS");
      tex->SetTextSize(textsize*1.0);
      //tex->Draw();
      tex=new TLatex(2.8,0.0235*0.88*1.275*1.47*1.6,"Preliminary");
      tex->SetTextSize(textsize*1.0);
      //tex->Draw();
    }
    if (iw==0)
    {
      tex=new TLatex(1.5,1.18,"0-20%");
      tex->SetTextSize(textsize*1.0);
      tex->Draw();
      tex=new TLatex(2.,0.021,"|#eta|<0.8");
      tex->SetTextSize(textsize*1.0);
      //tex->Draw();
      tex=new TLatex(0.5,0.02,"0.3<p_{T}<3.0 GeV/c");
      tex->SetTextSize(textsize*1.0);
      //tex->Draw();
    }
    //if (iw < 4) tex=new TLatex(ptit[iw][0]+2,0.27,htit[iw]);
    tex=new TLatex(2.1,1.4,htit[iw]);
    if ( iw == 0)   tex->SetTextSize(textsize);
    else if (iw == 8) tex->SetTextSize(textsize);
    else  tex->SetTextSize(textsize);
    tex->Draw();
    //
    // Legend
    //
    TLegend *leg = new TLegend(lxmin[iw]*1.2,lymin[iw]*1.*0.75*0.1,lxmax[iw]*0.8,lymax[iw]*1.02*0.4*0.92);
    leg->SetFillColor(0);
    leg->SetTextSize(textsize);
    TLegend *leg2 = new TLegend(lxmin[iw]*1.2,lymin[iw]*1.*0.75*0.52,lxmax[iw]*0.8,lymax[iw]*1.02*0.56*0.92);
    leg2->SetFillColor(0);
    leg2->SetTextSize(textsize);
    //
    // Read data
    //

    for (int im=0;im<1;im++)
    {
      int j=im*5+iw;
      int col=2;
      //if (ndp[j]==0) continue;

      ge=new TGraphErrors(19,&nARxa[j][0],&nARya[j][0],&nARxe[j][0],&nARye[j][0]);
      ge->SetTitle("");
      ge->SetMarkerStyle(24);
      //      ge->SetMarkerStyle(msty[im]);
      ge->SetMarkerSize(msiz[im]);
      ge->SetMarkerColor(col);
      ge->SetLineWidth(1.2);
      ge->SetLineColor(col);
      //ge->Draw("pe");
      leg->AddEntry(ge,"HF(3,4)/HF(3,5)","pl");
    }
    for (int im=0;im<1;im++)
    {
      int j=im*5+iw;
      int col=4;
      //if (ndp[j]==0) continue;
      ge2=new TGraphErrors(19,&nBRxa[j][0],&nBRya[j][0],&nBRxe[j][0],&nBRye[j][0]);
      ge2->SetTitle("");
      ge2->SetMarkerStyle(25);
      //      ge2->SetMarkerStyle(msty[im]);
      ge2->SetMarkerSize(msiz[im]);
      ge2->SetMarkerColor(col);
      ge2->SetLineWidth(1.2);
      ge2->SetLineColor(col);
      //ge2->Draw("pe");
      leg->AddEntry(ge2,"HF(4,5)/HF(3,5)","pl");
      //drawSysBox(ge2,16,0.2, sysXYZ[j]);
    }
    ge2->Draw("pe");
    ge->Draw("pe");
    if (iw==0) leg->Draw();
    TLine *lines = new TLine(0,1,4.0,1);
    lines->SetLineStyle(2);
    lines->SetLineWidth(1);
    lines->Draw();

if(iw==0||iw<6){
    TF1 *fitFun = new TF1("fitFun","pol1", 0, 4);
    fitFun->SetLineColor(2);
    ge->Fit("fitFun","R+");
    fitFun->Draw("same");
cout<<fitFun->Eval(0.4)<<",  "<<fitFun->Eval(0.9)<<",  "<<fitFun->Eval(1.9)<<",  "<<fitFun->Eval(3.5)<<endl;
    double p0 = fitFun->GetParameter(0);
    double p0Err = fitFun->GetParError(0);
    double p1 = fitFun->GetParameter(1);
    double p1Err = fitFun->GetParError(1);
    //double p2 = fitFun->GetParameter(2);
    //double p2Err = fitFun->GetParError(2);

  //TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x+[2]*x*x", 0, 4);
  TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x", 0, 4);
  //fitFunE->SetParameters(p0+p0Err, p1+p1Err, p2+p2Err);
  fitFunE->SetParameters(p0+p0Err, p1);
  for(int ipt=0; ipt<nPlotBin; ipt++){
    ptPlot[ipt] = ipt*0.1+0.05;
    vnPlot[ipt] = fitFun->Eval(ptPlot[ipt]);
    errPlot[ipt] = fitFunE->Eval(ptPlot[ipt]) - fitFun->Eval(ptPlot[ipt]);
  }

  TGraphErrors *graph = new TGraphErrors(nPlotBin,ptPlot,vnPlot,0,errPlot);
  graph->SetTitle("");
  graph->SetMarkerStyle(20);
  graph->SetMarkerSize(1.0);
  graph->SetMarkerColor(1);
  graph->SetLineWidth(2);
  graph->SetLineColor(2);
MyStyle->SetFillColor(kRed+1);
  graph->SetFillColor(kRed+1);
graph->SetFillStyle(3002);
  graph->Draw("e3same");

}
else {
    TF1 *fitFun = new TF1("fitFun","pol1", 0, 4);
    fitFun->SetLineColor(4);
    ge->Fit("fitFun","R+");
    fitFun->Draw("same");
cout<<fitFun->Eval(0.4)<<",  "<<fitFun->Eval(0.9)<<",  "<<fitFun->Eval(1.9)<<",  "<<fitFun->Eval(3.5)<<endl;

}

    double chi2 = fitFun->GetChisquare();
    double ndf = fitFun->GetNDF();
   TLatex *tex = new TLatex(0.6,0.53,Form("#chi^{2}/ndf = %2.1f", chi2/ndf));
   tex->SetTextColor(2);
   tex->SetTextSize(16);
   tex->Draw("same");


    can->cd(iw+1+5);
    tex=new TLatex(2.1,1.4,htitc2[iw]);
    if ( iw == 0)   tex->SetTextSize(textsize);
    else if (iw == 8) tex->SetTextSize(textsize);
    else  tex->SetTextSize(textsize);
    tex->Draw();

    for (int im=0;im<1;im++)
    {
      int j=im*5+iw;
      int col=2;
      //if (ndp[j]==0) continue;

      ge3=new TGraphErrors(19,&nARxa60[j][0],&nARya60[j][0],&nARxe60[j][0],&nARye60[j][0]);
      ge3->SetTitle("");
      ge3->SetMarkerStyle(24);
      //      ge3->SetMarkerStyle(msty[im]);
      ge3->SetMarkerSize(msiz[im]);
      ge3->SetMarkerColor(col);
      ge3->SetLineWidth(1.2);
      ge3->SetLineColor(col);
      //ge3->Draw("pe");
      leg2->AddEntry(ge3,"HF(3,4)/HF(3,5)","pl");
    }
    for (int im=0;im<1;im++)
    {
      int j=im*5+iw;
      int col=4;
      //if (ndp[j]==0) continue;
      ge4=new TGraphErrors(19,&nBRxa60[j][0],&nBRya60[j][0],&nBRxe60[j][0],&nBRye60[j][0]);
      ge4->SetTitle("");
      ge4->SetMarkerStyle(25);
      //      ge4->SetMarkerStyle(msty[im]);
      ge4->SetMarkerSize(msiz[im]);
      ge4->SetMarkerColor(col);
      ge4->SetLineWidth(1.2);
      ge4->SetLineColor(col);
      //ge4->Draw("pe");
      leg2->AddEntry(ge4,"HF(4,5)/HF(3,5)","pl");
    }
    ge4->Draw("pe");
    ge3->Draw("pe");
    TLine *lines = new TLine(0,1,4.0,1);
    lines->SetLineStyle(2);
    lines->SetLineWidth(1);
    lines->Draw();
    if(iw==0) leg2->Draw();

if(iw==0||iw<6){
    TF1 *fitFun = new TF1("fitFun","pol1", 0, 4);
    fitFun->SetLineColor(2);
    ge3->Fit("fitFun","R+");
    fitFun->Draw("same");
cout<<fitFun->Eval(2.5)<<",  "<<fitFun->Eval(7.5)<<",  "<<fitFun->Eval(45)<<",  "<<fitFun->Eval(55)<<endl;
    double p0 = fitFun->GetParameter(0);
    double p0Err = fitFun->GetParError(0);
    double p1 = fitFun->GetParameter(1);
    double p1Err = fitFun->GetParError(1);
    //double p2 = fitFun->GetParameter(2);
    //double p2Err = fitFun->GetParError(2);

  //TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x+[2]*x*x", 0, 4);
  TF1 *fitFunE = new TF1("fitFunE","[0]+[1]*x", 0, 4);
  //fitFunE->SetParameters(p0+p0Err, p1+p1Err, p2+p2Err);
  fitFunE->SetParameters(p0+p0Err, p1);
  for(int ipt=0; ipt<nPlotBin; ipt++){
    ptPlot[ipt] = ipt*0.1+0.05;
    vnPlot[ipt] = fitFun->Eval(ptPlot[ipt]);
    errPlot[ipt] = fitFunE->Eval(ptPlot[ipt]) - fitFun->Eval(ptPlot[ipt]);
  }

  TGraphErrors *graph = new TGraphErrors(nPlotBin,ptPlot,vnPlot,0,errPlot);
  graph->SetTitle("");
  graph->SetMarkerStyle(20);
  graph->SetMarkerSize(1.0);
  graph->SetMarkerColor(1);
  graph->SetLineWidth(2);
  graph->SetLineColor(2);
MyStyle->SetFillColor(kRed+1);
  graph->SetFillColor(kRed+1);
graph->SetFillStyle(3002);
  graph->Draw("e3same");
}
else {
    TF1 *fitFun = new TF1("fitFun","pol1", 0, 4);
    fitFun->SetLineColor(4);
    ge3->Fit("fitFun","R+");
    fitFun->Draw("same");
cout<<fitFun->Eval(2.5)<<",  "<<fitFun->Eval(7.5)<<",  "<<fitFun->Eval(45)<<",  "<<fitFun->Eval(55)<<endl;
}

    double chi2 = fitFun->GetChisquare();
    double ndf = fitFun->GetNDF();
   TLatex *tex = new TLatex(0.6,0.53,Form("#chi^{2}/ndf = %2.1f", chi2/ndf));
   tex->SetTextColor(2);
   tex->SetTextSize(16);
   tex->Draw("same");

     
      if(iw==0){
      can->cd(iw+5+1);
      TLatex *tex=new TLatex(1.5,1.18,"20-60%");
      tex->SetTextSize(textsize*1.0);
      tex->Draw();
      }

  }


   can->cd();
   TLatex *   tex = new TLatex(0.06,0.96,"CMS");
   tex->SetNDC();
   tex->SetTextFont(62);
   tex->SetTextSize(0.038);
   tex->SetLineWidth(2);
   tex->Draw();
   TLatex *   tex = new TLatex(0.108,0.96,"Preliminary");
   tex->SetNDC();
   tex->SetTextFont(52);
   tex->SetTextSize(0.038);
   tex->SetLineWidth(2);
   //tex->Draw();
   TLatex *   tex = new TLatex(0.24,0.963,"|#eta|<0.8");
   tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.038);
   tex->SetLineWidth(2);
   tex->Draw();

  cout << "end of process" << endl;
  can->cd();
  can->Print("./figures/plot_vnpt_5panels_hfSys_ratio.png");
  can->Print("./figures/plot_vnpt_5panels_hfSys_ratio.pdf");
  //can->Print("./figures/plot_vnpt_5panels.gif");
}
示例#20
0
void RatioPlot()
{
//=========Macro generated from canvas: c/c
//=========  (Mon Feb  8 04:04:50 2016) by ROOT version6.02/05
   TCanvas *c = new TCanvas("c", "c",0,22,700,500);
   gStyle->SetOptStat(0);
   c->Range(-2.75,-0.125,22.75,1.125);
   c->SetFillColor(0);
   c->SetBorderMode(0);
   c->SetBorderSize(2);
   c->SetFrameBorderMode(0);
   c->SetFrameBorderMode(0);
   
   TH2F *dummy31 = new TH2F("dummy31","",400,-0.2,20.2,100,0,1);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   dummy31->SetLineColor(ci);
   dummy31->GetXaxis()->SetTitle("c#tau [mm]");
   dummy31->GetXaxis()->SetLabelFont(42);
   dummy31->GetXaxis()->SetLabelSize(0.035);
   dummy31->GetXaxis()->SetTitleSize(0.035);
   dummy31->GetXaxis()->SetTitleFont(42);
   dummy31->GetYaxis()->SetTitle("#epsilon_{full}/#alpha_{gen}");
   dummy31->GetYaxis()->SetLabelFont(42);
   dummy31->GetYaxis()->SetLabelSize(0.035);
   dummy31->GetYaxis()->SetTitleSize(0.035);
   dummy31->GetYaxis()->SetTitleFont(42);
   dummy31->GetZaxis()->SetLabelFont(42);
   dummy31->GetZaxis()->SetLabelSize(0.035);
   dummy31->GetZaxis()->SetTitleSize(0.035);
   dummy31->GetZaxis()->SetTitleFont(42);
   dummy31->Draw("");
   
   Double_t Graph0_fx1001[11] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5,
   10,
   20};
   Double_t Graph0_fy1001[11] = {
   0.6263773,
   0.6093359,
   0.6089716,
   0.6266389,
   0.6476112,
   0.687127,
   0.6566757,
   0.7160494,
   0.6727273,
   0.5,
   0.6363636};
   Double_t Graph0_fex1001[11] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph0_fey1001[11] = {
   0.003617954,
   0.003452905,
   0.003812233,
   0.004599549,
   0.007938784,
   0.01353797,
   0.02478533,
   0.03542708,
   0.06326931,
   0.07537784,
   0.1450407};
   TGraphErrors *gre = new TGraphErrors(11,Graph0_fx1001,Graph0_fy1001,Graph0_fex1001,Graph0_fey1001);
   gre->SetName("Graph0");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1001 = new TH1F("Graph_Graph1001","Graph",100,0,22);
   Graph_Graph1001->SetMinimum(0.3889439);
   Graph_Graph1001->SetMaximum(0.8170826);
   Graph_Graph1001->SetDirectory(0);
   Graph_Graph1001->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1001->SetLineColor(ci);
   Graph_Graph1001->GetXaxis()->SetLabelFont(42);
   Graph_Graph1001->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetXaxis()->SetTitleFont(42);
   Graph_Graph1001->GetYaxis()->SetLabelFont(42);
   Graph_Graph1001->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetYaxis()->SetTitleFont(42);
   Graph_Graph1001->GetZaxis()->SetLabelFont(42);
   Graph_Graph1001->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1001);
   
   gre->Draw(" pl");
   
   Double_t Graph1_fx1002[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph1_fy1002[9] = {
   0.6514658,
   0.6416856,
   0.6326761,
   0.6479022,
   0.6696315,
   0.7406897,
   0.7671233,
   0.8043478,
   0.8064516};
   Double_t Graph1_fex1002[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fey1002[9] = {
   0.004300009,
   0.004478815,
   0.003819988,
   0.004685294,
   0.009679864,
   0.01627643,
   0.02473456,
   0.0584905,
   0.07095828};
   gre = new TGraphErrors(9,Graph1_fx1002,Graph1_fy1002,Graph1_fex1002,Graph1_fey1002);
   gre->SetName("Graph1");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(2);
   gre->SetMarkerColor(2);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","Graph",100,0,5.5);
   Graph_Graph1002->SetMinimum(0.6040008);
   Graph_Graph1002->SetMaximum(0.9022653);
   Graph_Graph1002->SetDirectory(0);
   Graph_Graph1002->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1002->SetLineColor(ci);
   Graph_Graph1002->GetXaxis()->SetLabelFont(42);
   Graph_Graph1002->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetXaxis()->SetTitleFont(42);
   Graph_Graph1002->GetYaxis()->SetLabelFont(42);
   Graph_Graph1002->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetYaxis()->SetTitleFont(42);
   Graph_Graph1002->GetZaxis()->SetLabelFont(42);
   Graph_Graph1002->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1002);
   
   gre->Draw(" pl");
   
   Double_t Graph2_fx1003[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph2_fy1003[9] = {
   0.6723047,
   0.6589839,
   0.6429941,
   0.6576543,
   0.6838966,
   0.7941176,
   0.7376093,
   0.7065217,
   1};
   Double_t Graph2_fex1003[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph2_fey1003[9] = {
   0.004903155,
   0.006039476,
   0.004282267,
   0.005308662,
   0.007835682,
   0.06934458,
   0.0237542,
   0.03356926,
   0};
   gre = new TGraphErrors(9,Graph2_fx1003,Graph2_fy1003,Graph2_fex1003,Graph2_fey1003);
   gre->SetName("Graph2");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(3);
   gre->SetMarkerColor(3);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1003 = new TH1F("Graph_Graph1003","Graph",100,0,5.5);
   Graph_Graph1003->SetMinimum(0.602583);
   Graph_Graph1003->SetMaximum(1.036129);
   Graph_Graph1003->SetDirectory(0);
   Graph_Graph1003->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1003->SetLineColor(ci);
   Graph_Graph1003->GetXaxis()->SetLabelFont(42);
   Graph_Graph1003->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetXaxis()->SetTitleFont(42);
   Graph_Graph1003->GetYaxis()->SetLabelFont(42);
   Graph_Graph1003->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetYaxis()->SetTitleFont(42);
   Graph_Graph1003->GetZaxis()->SetLabelFont(42);
   Graph_Graph1003->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1003);
   
   gre->Draw(" pl");
   
   Double_t Graph3_fx1004[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph3_fy1004[9] = {
   0.6748178,
   0.6517303,
   0.6591389,
   0.653531,
   0.6774732,
   0.7201717,
   0.7198697,
   0.7260274,
   0.6923077};
   Double_t Graph3_fex1004[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph3_fey1004[9] = {
   0.003921157,
   0.004304159,
   0.006041756,
   0.009399202,
   0.007217104,
   0.01315228,
   0.02562936,
   0.03691082,
   0.05225894};
   gre = new TGraphErrors(9,Graph3_fx1004,Graph3_fy1004,Graph3_fex1004,Graph3_fey1004);
   gre->SetName("Graph3");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(7);
   gre->SetMarkerColor(7);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1004 = new TH1F("Graph_Graph1004","Graph",100,0,5.5);
   Graph_Graph1004->SetMinimum(0.6277598);
   Graph_Graph1004->SetMaximum(0.7752272);
   Graph_Graph1004->SetDirectory(0);
   Graph_Graph1004->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1004->SetLineColor(ci);
   Graph_Graph1004->GetXaxis()->SetLabelFont(42);
   Graph_Graph1004->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1004->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1004->GetXaxis()->SetTitleFont(42);
   Graph_Graph1004->GetYaxis()->SetLabelFont(42);
   Graph_Graph1004->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1004->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1004->GetYaxis()->SetTitleFont(42);
   Graph_Graph1004->GetZaxis()->SetLabelFont(42);
   Graph_Graph1004->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1004->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1004->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1004);
   
   gre->Draw(" pl");
   
   Double_t Graph4_fx1005[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph4_fy1005[9] = {
   0.6867879,
   0.6728068,
   0.6743687,
   0.6736553,
   0.6777217,
   0.7043302,
   0.7062147,
   0.738204,
   0.7375};
   Double_t Graph4_fex1005[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1005[9] = {
   0.004028779,
   0.003941647,
   0.004032707,
   0.004410025,
   0.005612004,
   0.0118701,
   0.01531129,
   0.0171509,
   0.0491927};
   gre = new TGraphErrors(9,Graph4_fx1005,Graph4_fy1005,Graph4_fex1005,Graph4_fey1005);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(8);
   gre->SetMarkerColor(8);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1005 = new TH1F("Graph_Graph1005","Graph",100,0,5.5);
   Graph_Graph1005->SetMinimum(0.6570824);
   Graph_Graph1005->SetMaximum(0.7984755);
   Graph_Graph1005->SetDirectory(0);
   Graph_Graph1005->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1005->SetLineColor(ci);
   Graph_Graph1005->GetXaxis()->SetLabelFont(42);
   Graph_Graph1005->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1005->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1005->GetXaxis()->SetTitleFont(42);
   Graph_Graph1005->GetYaxis()->SetLabelFont(42);
   Graph_Graph1005->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1005->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1005->GetYaxis()->SetTitleFont(42);
   Graph_Graph1005->GetZaxis()->SetLabelFont(42);
   Graph_Graph1005->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1005->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1005->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1005);
   
   gre->Draw(" pl");
   
   Double_t Graph5_fx1006[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph5_fy1006[9] = {
   0.6756335,
   0.6781523,
   0.6774474,
   0.6698265,
   0.6754523,
   0.6925329,
   0.7143727,
   0.7442177,
   0.7108753};
   Double_t Graph5_fex1006[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph5_fey1006[9] = {
   0.004360858,
   0.004526824,
   0.003976201,
   0.004215048,
   0.004947981,
   0.0066736,
   0.01114745,
   0.01609317,
   0.02334902};
   gre = new TGraphErrors(9,Graph5_fx1006,Graph5_fy1006,Graph5_fex1006,Graph5_fey1006);
   gre->SetName("Graph5");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(9);
   gre->SetMarkerColor(9);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1006 = new TH1F("Graph_Graph1006","Graph",100,0,5.5);
   Graph_Graph1006->SetMinimum(0.6561415);
   Graph_Graph1006->SetMaximum(0.7697808);
   Graph_Graph1006->SetDirectory(0);
   Graph_Graph1006->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1006->SetLineColor(ci);
   Graph_Graph1006->GetXaxis()->SetLabelFont(42);
   Graph_Graph1006->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1006->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1006->GetXaxis()->SetTitleFont(42);
   Graph_Graph1006->GetYaxis()->SetLabelFont(42);
   Graph_Graph1006->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1006->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1006->GetYaxis()->SetTitleFont(42);
   Graph_Graph1006->GetZaxis()->SetLabelFont(42);
   Graph_Graph1006->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1006->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1006->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1006);
   
   gre->Draw(" pl");
   
   Double_t Graph6_fx1007[8] = {
   0,
   0.05,
   0.1,
   0.2,
   1,
   2,
   3,
   5};
   Double_t Graph6_fy1007[8] = {
   0.6812023,
   0.6763509,
   0.6851705,
   0.6878941,
   0.6878173,
   0.7069583,
   0.7088734,
   0.7517162};
   Double_t Graph6_fex1007[8] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph6_fey1007[8] = {
   0.004112248,
   0.004220682,
   0.01307915,
   0.004749901,
   0.006474723,
   0.009075961,
   0.01014285,
   0.0146132};
   gre = new TGraphErrors(8,Graph6_fx1007,Graph6_fy1007,Graph6_fex1007,Graph6_fey1007);
   gre->SetName("Graph6");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);

   ci = TColor::GetColor("#ffcc00");
   gre->SetLineColor(ci);

   ci = TColor::GetColor("#ffcc00");
   gre->SetMarkerColor(ci);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1007 = new TH1F("Graph_Graph1007","Graph",100,0,5.5);
   Graph_Graph1007->SetMinimum(0.6626675);
   Graph_Graph1007->SetMaximum(0.7757533);
   Graph_Graph1007->SetDirectory(0);
   Graph_Graph1007->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1007->SetLineColor(ci);
   Graph_Graph1007->GetXaxis()->SetLabelFont(42);
   Graph_Graph1007->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1007->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1007->GetXaxis()->SetTitleFont(42);
   Graph_Graph1007->GetYaxis()->SetLabelFont(42);
   Graph_Graph1007->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1007->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1007->GetYaxis()->SetTitleFont(42);
   Graph_Graph1007->GetZaxis()->SetLabelFont(42);
   Graph_Graph1007->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1007->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1007->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1007);
   
   gre->Draw(" pl");
   
   Double_t Graph7_fx1008[11] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5,
   10,
   20};
   Double_t Graph7_fy1008[11] = {
   0.683087,
   0.693799,
   0.6853017,
   0.6814364,
   0.6712711,
   0.6809284,
   0.6746204,
   0.7442773,
   0.7352151,
   0.7230584,
   0.7238979};
   Double_t Graph7_fex1008[11] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph7_fey1008[11] = {
   0.005684641,
   0.005503086,
   0.00555297,
   0.005606572,
   0.005852263,
   0.006621753,
   0.008908382,
   0.01115702,
   0.01617586,
   0.01097984,
   0.0215345};
   gre = new TGraphErrors(11,Graph7_fx1008,Graph7_fy1008,Graph7_fex1008,Graph7_fey1008);
   gre->SetName("Graph7");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(4);
   gre->SetMarkerColor(4);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1008 = new TH1F("Graph_Graph1008","Graph",100,0,22);
   Graph_Graph1008->SetMinimum(0.6564173);
   Graph_Graph1008->SetMaximum(0.7644359);
   Graph_Graph1008->SetDirectory(0);
   Graph_Graph1008->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1008->SetLineColor(ci);
   Graph_Graph1008->GetXaxis()->SetLabelFont(42);
   Graph_Graph1008->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1008->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1008->GetXaxis()->SetTitleFont(42);
   Graph_Graph1008->GetYaxis()->SetLabelFont(42);
   Graph_Graph1008->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1008->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1008->GetYaxis()->SetTitleFont(42);
   Graph_Graph1008->GetZaxis()->SetLabelFont(42);
   Graph_Graph1008->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1008->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1008->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1008);
   
   gre->Draw(" pl");
   
   Double_t Graph8_fx1009[9] = {
   0,
   0.05,
   0.1,
   0.2,
   0.5,
   1,
   2,
   3,
   5};
   Double_t Graph8_fy1009[9] = {
   0.6763273,
   0.6728698,
   0.6706598,
   0.6686953,
   0.6702438,
   0.6629484,
   0.6587852,
   0.6699412,
   0.6794829};
   Double_t Graph8_fex1009[9] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph8_fey1009[9] = {
   0.003746493,
   0.00374542,
   0.003741634,
   0.003709151,
   0.003702686,
   0.003763241,
   0.003947963,
   0.004403951,
   0.004905311};
   gre = new TGraphErrors(9,Graph8_fx1009,Graph8_fy1009,Graph8_fex1009,Graph8_fey1009);
   gre->SetName("Graph8");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineColor(6);
   gre->SetMarkerColor(6);
   gre->SetMarkerStyle(7);
   gre->SetMarkerSize(5);
   
   TH1F *Graph_Graph1009 = new TH1F("Graph_Graph1009","Graph",100,0,5.5);
   Graph_Graph1009->SetMinimum(0.6518821);
   Graph_Graph1009->SetMaximum(0.6873433);
   Graph_Graph1009->SetDirectory(0);
   Graph_Graph1009->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1009->SetLineColor(ci);
   Graph_Graph1009->GetXaxis()->SetLabelFont(42);
   Graph_Graph1009->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1009->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1009->GetXaxis()->SetTitleFont(42);
   Graph_Graph1009->GetYaxis()->SetLabelFont(42);
   Graph_Graph1009->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1009->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1009->GetYaxis()->SetTitleFont(42);
   Graph_Graph1009->GetZaxis()->SetLabelFont(42);
   Graph_Graph1009->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1009->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1009->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1009);
   
   gre->Draw(" pl");
   
   TLegend *leg = new TLegend(0.5,0.3,0.85,0.6,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.045);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph0","m_{#gamma D}=0.250 GeV","PL");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph1","m_{#gamma D}=0.275 GeV","PL");
   entry->SetLineColor(2);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(2);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","m_{#gamma D}=0.300 GeV","PL");
   entry->SetLineColor(3);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(3);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph3","m_{#gamma D}=0.400 GeV","PL");
   entry->SetLineColor(7);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(7);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph4","m_{#gamma D}=0.700 GeV","PL");
   entry->SetLineColor(8);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(8);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph5","m_{#gamma D}=1.000 GeV","PL");
   entry->SetLineColor(9);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(9);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph6","m_{#gamma D}=1.500 GeV","PL");

   ci = TColor::GetColor("#ffcc00");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);

   ci = TColor::GetColor("#ffcc00");
   entry->SetMarkerColor(ci);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph7","m_{#gamma D}=2.000 GeV","PL");
   entry->SetLineColor(4);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(4);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph8","m_{#gamma D}=8.500 GeV","PL");
   entry->SetLineColor(6);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(6);
   entry->SetMarkerStyle(7);
   entry->SetMarkerSize(5);
   entry->SetTextFont(42);
   leg->Draw();
   c->Modified();
   c->cd();
   c->SetSelected(c);
}
void Pythia8_Dijet30_result_JER_akPu4PF_((abs(refeta)<2)&&(hiBin>60))&&(refpt>30)_refeta()
{
//=========Macro generated from canvas: Can_result_3/
//=========  (Mon Apr 18 04:08:04 2016) by ROOT version6.02/13
   TCanvas *Can_result_3 = new TCanvas("Can_result_3", "",18,40,700,500);
   gStyle->SetOptFit(1);
   Can_result_3->Range(-2.75,0.1715425,2.75,0.2926317);
   Can_result_3->SetFillColor(0);
   Can_result_3->SetBorderMode(0);
   Can_result_3->SetBorderSize(2);
   Can_result_3->SetFrameBorderMode(0);
   Can_result_3->SetFrameBorderMode(0);
   
   TMultiGraph *multigraph = new TMultiGraph();
   multigraph->SetName("name");
   multigraph->SetTitle("JER_akPu4PF");
   
   Double_t Graph_fx1007[9] = {
   -1.8,
   -1.4,
   -1,
   -0.6,
   -0.2,
   0.2,
   0.6,
   1,
   1.6};
   Double_t Graph_fy1007[9] = {
   0.2213775,
   0.2313726,
   0.212349,
   0.1992318,
   0.2015521,
   0.2047929,
   0.2065286,
   0.2141753,
   0.2298097};
   Double_t Graph_fex1007[9] = {
   0.2,
   0.2,
   0.2,
   0.2,
   0.2,
   0.2,
   0.2,
   0.2,
   0.4};
   Double_t Graph_fey1007[9] = {
   0.001529502,
   0.001378741,
   0.001274153,
   0.001286487,
   0.00132694,
   0.001354738,
   0.001397823,
   0.001305814,
   0.001034891};
   TGraphErrors *gre = new TGraphErrors(9,Graph_fx1007,Graph_fy1007,Graph_fex1007,Graph_fey1007);
   gre->SetName("Graph");
   gre->SetTitle("some title_0");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   
   TH1F *Graph_Graph1007 = new TH1F("Graph_Graph1007","some title_0",100,-2.4,2.4);
   Graph_Graph1007->SetMinimum(0.1944648);
   Graph_Graph1007->SetMaximum(0.236232);
   Graph_Graph1007->SetDirectory(0);
   Graph_Graph1007->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   Graph_Graph1007->SetLineColor(ci);
   Graph_Graph1007->GetXaxis()->SetLabelFont(42);
   Graph_Graph1007->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1007->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1007->GetXaxis()->SetTitleFont(42);
   Graph_Graph1007->GetYaxis()->SetLabelFont(42);
   Graph_Graph1007->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1007->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1007->GetYaxis()->SetTitleFont(42);
   Graph_Graph1007->GetZaxis()->SetLabelFont(42);
   Graph_Graph1007->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1007->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1007->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1007);
   
   multigraph->Add(gre,"");
   
   Double_t Graph_fx1008[20] = {
   -1.9,
   -1.7,
   -1.5,
   -1.2,
   -0.9,
   -0.7,
   -0.5,
   -0.3,
   -0.1,
   0.1,
   0.3,
   0.5,
   0.7,
   0.9,
   1.1,
   1.3,
   1.5,
   1.7,
   1.9,
   1};
   Double_t Graph_fy1008[20] = {
   0.2311591,
   0.2477474,
   0.2655955,
   0.2576075,
   0.2220231,
   0.206768,
   0.2064983,
   0.2020811,
   0.19917,
   0.2115871,
   0.1952014,
   0.1965805,
   0.2158946,
   0.2003286,
   0.213619,
   0.213695,
   0.2466632,
   0.2597152,
   0.2553281,
   0.2344014};
   Double_t Graph_fex1008[20] = {
   0.1,
   0.1,
   0.1,
   0.2,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   0.1,
   -1};
   Double_t Graph_fey1008[20] = {
   0.009894431,
   0.01000488,
   0.01052403,
   0.009913006,
   0.008527985,
   0.007570562,
   0.007309829,
   0.007320613,
   0.00699798,
   0.00776784,
   0.007146697,
   0.00713059,
   0.007530691,
   0.007364154,
   0.007896077,
   0.007855752,
   0.009496669,
   0.01034782,
   0.01046585,
   0.009252961};
   gre = new TGraphErrors(20,Graph_fx1008,Graph_fy1008,Graph_fex1008,Graph_fey1008);
   gre->SetName("Graph");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineColor(2);
   gre->SetMarkerColor(2);
   
   TH1F *Graph_Graph1008 = new TH1F("Graph_Graph1008","Graph",100,-2.4,2.4);
   Graph_Graph1008->SetMinimum(0.1792482);
   Graph_Graph1008->SetMaximum(0.284926);
   Graph_Graph1008->SetDirectory(0);
   Graph_Graph1008->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1008->SetLineColor(ci);
   Graph_Graph1008->GetXaxis()->SetLabelFont(42);
   Graph_Graph1008->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1008->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1008->GetXaxis()->SetTitleFont(42);
   Graph_Graph1008->GetYaxis()->SetLabelFont(42);
   Graph_Graph1008->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1008->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1008->GetYaxis()->SetTitleFont(42);
   Graph_Graph1008->GetZaxis()->SetLabelFont(42);
   Graph_Graph1008->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1008->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1008->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1008);
   
   multigraph->Add(gre,"");
   multigraph->Draw("AP");
   multigraph->GetXaxis()->SetTitle("refeta");
   multigraph->GetXaxis()->SetLabelFont(42);
   multigraph->GetXaxis()->SetLabelSize(0.035);
   multigraph->GetXaxis()->SetTitleSize(0.035);
   multigraph->GetXaxis()->SetTitleFont(42);
   multigraph->GetYaxis()->SetTitle("#sigma_{Reco./Gen.}");
   multigraph->GetYaxis()->SetLabelFont(42);
   multigraph->GetYaxis()->SetLabelSize(0.035);
   multigraph->GetYaxis()->SetTitleSize(0.035);
   multigraph->GetYaxis()->SetTitleFont(42);
   
   TLegend *leg = new TLegend(0.68,0.7,0.88,0.85,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph","allJets","l");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph","from chris","l");
   entry->SetLineColor(2);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   TLatex *   tex = new TLatex(0.35,0.8,"#bf{#color[2]{|#eta_{jet}|<2.0 & refpt>30}}");
tex->SetNDC();
   tex->SetTextFont(43);
   tex->SetTextSize(24);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.17,0.17,"Centrality:30-100%");
tex->SetNDC();
   tex->SetTextFont(43);
   tex->SetTextSize(24);
   tex->SetLineWidth(2);
   tex->Draw();
   
   TPaveText *pt = new TPaveText(0.3743391,0.9365254,0.6256609,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   AText = pt->AddText("JER_akPu4PF");
   pt->Draw();
   Can_result_3->Modified();
   Can_result_3->cd();
   Can_result_3->SetSelected(Can_result_3);
}
void MakeAmplitudeVsBiasVoltageGraph() {

  //With the 600V point
  // const int nPoints = 5;
  // float x[nPoints] = { 200, 300, 400, 500, 600 };
  // float xerr[nPoints] = { 0.01*200, 0.01*300, 0.01*400, 0.01*500, 0.01*600 };
  // float y_charge[nPoints] = {  58.4, 68.0, 73.8, 77.1, 78.6 }; 
  // float yerr_charge[nPoints] = { 1.0, 1.4, 1.3, 0.5, 1.4 };
  // float y_MIP[nPoints] = {  0.0, 0.0, 0.0, 0.0, 0.0 }; 
  // float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0, 0.0 };

  //Without the 600V point
  const int nPoints = 5;
  float x[nPoints] = { 200, 300, 400, 500 };
  float xerr[nPoints] = { 0.01*200, 0.01*300, 0.01*400, 0.01*500 };
  float y_charge[nPoints] = {  58.4, 68.0, 73.8, 77.1 }; 
  float yerr_charge[nPoints] = { 1.0, 1.4, 1.3, 0.5 };
  float y_MIP[nPoints] = {  0.0, 0.0, 0.0, 0.0 }; 
  float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0 };


  double chargePerMIP = 1.3;
  for (int i=0; i<nPoints; ++i) {
    y_MIP[i] = y_charge[i] / chargePerMIP;
    yerr_MIP[i] =  yerr_charge[i] / chargePerMIP;
  }

  TGraphErrors *graphChargeVsBiasVoltage = new TGraphErrors(nPoints,x,y_charge,xerr,yerr_charge);
  graphChargeVsBiasVoltage->SetLineWidth(3);
  TGraphErrors *graphMIPVsBiasVoltage = new TGraphErrors(nPoints,x,y_MIP,xerr,yerr_MIP);
  graphMIPVsBiasVoltage->SetLineWidth(3);

  TCanvas *c = 0;
  TVirtualFitter *fitter = 0;

  c = new TCanvas("c","c",800,600);
  graphChargeVsBiasVoltage->Draw("AP");
  graphChargeVsBiasVoltage->SetTitle("");
  graphChargeVsBiasVoltage->GetXaxis()->SetTitle("Bias Voltage [V]");
  graphChargeVsBiasVoltage->GetXaxis()->SetTitleSize(0.045);
  graphChargeVsBiasVoltage->GetXaxis()->SetLabelSize(0.045);
  graphChargeVsBiasVoltage->GetXaxis()->SetTitleOffset(1.0);
  graphChargeVsBiasVoltage->GetYaxis()->SetTitle("Integrated Charge [pC]");
  graphChargeVsBiasVoltage->GetYaxis()->SetTitleOffset(1.02);
  graphChargeVsBiasVoltage->GetYaxis()->SetTitleSize(0.045);
  graphChargeVsBiasVoltage->GetYaxis()->SetLabelSize(0.045);
  graphChargeVsBiasVoltage->GetXaxis()->SetRangeUser(0.0,700);
  graphChargeVsBiasVoltage->GetYaxis()->SetRangeUser(0,90);

  // graphChargeVsBiasVoltage->Fit("pol2","","");
  // fitter = TVirtualFitter::GetFitter();
  
  c->SaveAs( "ChargeVsBiasVoltageAt6X0_16GeV.gif" );
  c->SaveAs( "ChargeVsBiasVoltageAt6X0_16GeV.pdf" );


  c = new TCanvas("c","c",800,600);
  c->SetLeftMargin(0.11);
  graphMIPVsBiasVoltage->Draw("AP");
  graphMIPVsBiasVoltage->SetTitle("");
  graphMIPVsBiasVoltage->GetXaxis()->SetTitle("Bias Voltage [V]");
  graphMIPVsBiasVoltage->GetXaxis()->SetTitleSize(0.045);
  graphMIPVsBiasVoltage->GetXaxis()->SetLabelSize(0.045);
  graphMIPVsBiasVoltage->GetXaxis()->SetTitleOffset(1.0);
  graphMIPVsBiasVoltage->GetYaxis()->SetTitle("Integrated Charge [ Q_{MIP} ]");
  graphMIPVsBiasVoltage->GetYaxis()->SetTitleOffset(1.02);
  graphMIPVsBiasVoltage->GetYaxis()->SetTitleSize(0.045);
  graphMIPVsBiasVoltage->GetYaxis()->SetLabelSize(0.045);
  graphMIPVsBiasVoltage->GetXaxis()->SetRangeUser(0.0, 700);
  graphMIPVsBiasVoltage->GetYaxis()->SetRangeUser(0, 70);

  // graphMIPVsBiasVoltage->Fit("pol1","","");
  // fitter = TVirtualFitter::GetFitter();
  
  c->SaveAs( "MIPVsBiasVoltageAt6X0_16GeV.gif" );
  c->SaveAs( "MIPVsBiasVoltageAt6X0_16GeV.pdf" );


}
示例#23
0
void IsoMultipole(Char_t* Mlp, Char_t* Iso, Bool_t SAVE=false, Double_t Lo=0.0, Double_t Hi=0.0)
{
  if(SAVE) TCanvas* Canvas = new TCanvas();
  //if(SAVE) SetBit(TH1::kNoTitle);

  FILE* InPlots;
  FILE* InModel_0;
  FILE* InModel_p;
  Char_t Buffer[256];
  Char_t M, p;
  Int_t l;
  Double_t PlRe[N_MAX];
  Double_t PlIm[N_MAX];
  Double_t PlDRe[N_MAX];
  Double_t PlDIm[N_MAX];
  Double_t PlW[N_MAX];
  Double_t MoRe_0[N_MAX];
  Double_t MoRe_p[N_MAX];
  Double_t MoIm_0[N_MAX];
  Double_t MoIm_p[N_MAX];
  Double_t MoW_0[N_MAX];
  Double_t MoW_p[N_MAX];
  Double_t MoRe[N_MAX];
  Double_t MoIm[N_MAX];
  Int_t PlPts;
  Int_t MoPts_0, MoPts_p;
  Double_t W, Re, DRe, Im, DIm;
  Double_t Min = 0.0;
  Double_t Max = 0.0;
  TGraphErrors* PlotsRe;
  TGraphErrors* PlotsIm;
  TGraph* ModelRe;
  TGraph* ModelIm;

  //Decompose multipole name
  sscanf(Mlp, "%c%d%c", &M, &l, &p);

  //Open text file with fit results for given multipole
  sprintf(Buffer, "isospin/%s_%s.txt", Mlp, Iso);
  InPlots = fopen(Buffer, "r");

  //Skip two lines with table header
  fgets(Buffer, sizeof(Buffer), InPlots);
  fgets(Buffer, sizeof(Buffer), InPlots);
  //Read multipole fit values from file
  PlPts = 0;
  while(!feof(InPlots))
  {
    if(fscanf(InPlots, "%lf %lf %lf %lf %lf", &W, &Re, &DRe, &Im, &DIm)==5)
    {
      //Look for maximum & minimum of values to adjust plotting range
      if(Re+DRe > Max) Max = Re+DRe;
      if(Im+DIm > Max) Max = Im+DIm;
      if(Re-DRe < Min) Min = Re-DRe;
      if(Im-DIm < Min) Min = Im-DIm;
      //Add real and imaginary parts of multipole (w/ errors) to graph
      PlW[PlPts] = W;
      PlRe[PlPts] = Re;
      PlIm[PlPts] = Im;
      PlDRe[PlPts] = DRe;
      PlDIm[PlPts] = DIm;
      PlPts++;
    }
  }
  //Close file with fit values
  fclose(InPlots);

  //Create graphs for real and imaginary parts of fitted multipole
  PlotsRe = new TGraphErrors(PlPts, PlW, PlRe, NULL, PlDRe);
  PlotsIm = new TGraphErrors(PlPts, PlW, PlIm, NULL, PlDIm);

  //Color, line size, marker style adjustments
  PlotsRe->SetLineColor(kRed+2);
  PlotsIm->SetLineColor(kBlue+2);
  PlotsRe->SetMarkerColor(kRed+2);
  PlotsIm->SetMarkerColor(kBlue+2);
  PlotsRe->SetMarkerStyle(21);
  PlotsIm->SetMarkerStyle(21);
  PlotsRe->SetMarkerSize(0.7);
  PlotsIm->SetMarkerSize(0.7);

  //Set plot titles and object names
  sprintf(Buffer, "%s_%s", Mlp, Iso);
  PlotsRe->SetTitle(Buffer);
  PlotsIm->SetTitle(Buffer);
  sprintf(Buffer, "Fit_Re%s_%s", Mlp, Iso);
  PlotsRe->SetName(Buffer);
  sprintf(Buffer, "Fit_Im%s_%s", Mlp, Iso);
  PlotsIm->SetName(Buffer);

  PlotsRe->Draw("APZ"); //Plot with x,y axis, points and small error bars
  PlotsIm->Draw("PZ"); //Plot with points and small error bars, into existing frame

  //x-axis labeling
  PlotsRe->GetXaxis()->SetTitle("W / MeV");
  //y-axis labeling
  sprintf(Buffer, "%c_{%1d%c}", M, l, p);
  for(Int_t n=0; n<strlen(Buffer); n++)
  {
    if(Buffer[n]=='p') Buffer[n] = '+';
    if(Buffer[n]=='m') Buffer[n] = '-';
  }
  if(!strcmp(Iso, "32"))  sprintf(Buffer, "%s^{3/2}",  Buffer, Iso);
  if(!strcmp(Iso, "p12")) sprintf(Buffer, "%s^{p1/2}", Buffer, Iso);
  PlotsRe->GetYaxis()->SetTitle(Buffer);

  //Open text file with model values for given p pi0 multipole
  sprintf(Buffer, "model/ppi0/%s.txt", Mlp);
  InModel_0 = fopen(Buffer, "r");
  //Skip two lines with table header
  fgets(Buffer, sizeof(Buffer), InModel_0);
  fgets(Buffer, sizeof(Buffer), InModel_0);
  //Read multipole model values from file
  MoPts_0 = 0;
  while(!feof(InModel_0))
  {
    if(fscanf(InModel_0, "%lf %lf %lf", &W, &Re, &Im)==3)
    {
      MoW_0[MoPts_0]  = W;
      MoRe_0[MoPts_0] = Re;
      MoIm_0[MoPts_0] = Im;
      MoPts_0++;
    }
  }
  //Close file with model values
  fclose(InModel_0);

  //Open text file with model values for given n pi+ multipole
  sprintf(Buffer, "model/npip/%s.txt", Mlp);
  InModel_p = fopen(Buffer, "r");
  //Skip two lines with table header
  fgets(Buffer, sizeof(Buffer), InModel_p);
  fgets(Buffer, sizeof(Buffer), InModel_p);
  //Read multipole model values from file
  MoPts_p = 0;
  while(!feof(InModel_p))
  {
    if(fscanf(InModel_p, "%lf %lf %lf", &W, &Re, &Im)==3)
    {
      MoW_p[MoPts_p]  = W;
      MoRe_p[MoPts_p] = Re;
      MoIm_p[MoPts_p] = Im;
      MoPts_p++;
    }
  }
  //Close file with model values
  fclose(InModel_p);

  //Create selected isospin multipole from p pi0 and n pi+ multipoles
  for(Int_t wp=0; wp<MoPts_p; wp++)
  {
    //Find corresponding energy bin between n pi+ and p pi0 multipoles
    Int_t w0;
    for(Int_t w0=0; w0<MoPts_0; w0++)
      if(MoW_p[wp]==MoW_0[w0]) break;
    //Create isospin multipoles
    if(!strcmp(Iso, "32"))  { MoRe[wp] = A_32(MoRe_0[w0], MoRe_p[wp]); MoIm[wp] = A_32(MoIm_0[w0], MoIm_p[wp]); }
    if(!strcmp(Iso, "p12")) { MoRe[wp] = A_12(MoRe_0[w0], MoRe_p[wp]); MoIm[wp] = A_12(MoIm_0[w0], MoIm_p[wp]); }
  }

  //Create graphs for real and imaginary parts of model multipole
  ModelRe = new TGraph(MoPts_p, MoW_p, MoRe);
  ModelIm = new TGraph(MoPts_p, MoW_p, MoIm);

  //Color, line size adjustments
  ModelRe->SetLineColor(kRed);
  ModelIm->SetLineColor(kBlue);
  ModelRe->SetLineWidth(2);
  ModelIm->SetLineWidth(2);

  //Set plot titles and object names
  sprintf(Buffer, "%s_%s", Mlp, Iso);
  ModelRe->SetTitle(Buffer);
  ModelIm->SetTitle(Buffer);
  sprintf(Buffer, "Model_Re%s_%s", Mlp, Iso);
  ModelRe->SetName(Buffer);
  sprintf(Buffer, "Model_Im%s_%s", Mlp, Iso);
  ModelIm->SetName(Buffer);

  //Plot graphs
  ModelRe->Draw("L"); //Plot as line, into same frame
  ModelIm->Draw("L"); //Plot as line, into same frame

  //Adjust drawing ranges for y-axis
  if((Lo==0.0) && (Hi==0.0))
  {
    PlotsRe->SetMinimum(Min*1.05);
    PlotsRe->SetMaximum(Max*1.05);
  }
  else
  {
    PlotsRe->SetMinimum(Lo);
    PlotsRe->SetMaximum(Hi);
  }

  if(SAVE) PlotsRe->SetTitle("");
  if(SAVE) sprintf(Buffer, "isospin/%s_%s.eps", Mlp, Iso);
  if(SAVE) Canvas->SaveAs(Buffer);
}
void MakeAmplitudeVsBeamEnergyGraph() {

  //use beam energy for xaxis
  const int nPoints = 4;
  float x[nPoints] = { 4.0, 8.0, 16.0, 32.0 };
  float xerr[nPoints] = { 0.027*4.0, 0.023*8.0, 0.045*16.0, 0.05*32.0 };
  float y_charge[nPoints] = {  54.8, 106, 217, 350 }; 
  float yerr_charge[nPoints] = { 19, 46, 46, 92 };
  float y_MIP[nPoints] = {  0.0, 0.0, 0.0, 0.0 }; 
  float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0 };

  double chargePerMIP = 6.5;
  for (int i=0; i<nPoints; ++i) {
    y_MIP[i] = y_charge[i] / chargePerMIP;
    yerr_MIP[i] =  yerr_charge[i] / chargePerMIP;
  }

  TGraphErrors *graphChargeVsEnergy = new TGraphErrors(nPoints,x,y_charge,xerr,yerr_charge);
  graphChargeVsEnergy->SetLineWidth(3);
  TGraphErrors *graphMIPVsEnergy = new TGraphErrors(nPoints,x,y_MIP,xerr,yerr_MIP);
  graphMIPVsEnergy->SetLineWidth(3);

  TCanvas *c = 0;
  TVirtualFitter *fitter = 0;

  c = new TCanvas("c","c",800,600);
  graphChargeVsEnergy->Draw("AP");
  graphChargeVsEnergy->SetTitle("");
  graphChargeVsEnergy->GetXaxis()->SetTitle("Electron Beam Energy [GeV/c^{2}]");
  graphChargeVsEnergy->GetXaxis()->SetTitleSize(0.045);
  graphChargeVsEnergy->GetXaxis()->SetLabelSize(0.045);
  graphChargeVsEnergy->GetXaxis()->SetTitleOffset(1.0);
  graphChargeVsEnergy->GetYaxis()->SetTitle("Integrated Charge [pC]");
  graphChargeVsEnergy->GetYaxis()->SetTitleOffset(1.0);
  graphChargeVsEnergy->GetYaxis()->SetTitleSize(0.05);
  graphChargeVsEnergy->GetYaxis()->SetLabelSize(0.045);
  graphChargeVsEnergy->GetXaxis()->SetRangeUser(0,40);
  graphChargeVsEnergy->GetYaxis()->SetRangeUser(0,500);

  graphChargeVsEnergy->Fit("pol1","","");
  fitter = TVirtualFitter::GetFitter();
  
  c->SaveAs( "ChargeVsEnergyAt6X0.gif" );
  c->SaveAs( "ChargeVsEnergyAt6X0.pdf" );


  c = new TCanvas("c","c",800,600);
  c->SetLeftMargin(0.11);
  graphMIPVsEnergy->Draw("AP");
  graphMIPVsEnergy->SetTitle("");
  graphMIPVsEnergy->GetXaxis()->SetTitle("Electron Beam Energy [GeV/c^{2}]");
  graphMIPVsEnergy->GetXaxis()->SetTitleSize(0.045);
  graphMIPVsEnergy->GetXaxis()->SetLabelSize(0.045);
  graphMIPVsEnergy->GetXaxis()->SetTitleOffset(1.0);
  graphMIPVsEnergy->GetYaxis()->SetTitle("Integrated Charge [ Q_{MIP} ]");
  graphMIPVsEnergy->GetYaxis()->SetTitleOffset(0.9);
  graphMIPVsEnergy->GetYaxis()->SetTitleSize(0.05);
  graphMIPVsEnergy->GetYaxis()->SetLabelSize(0.045);
  graphMIPVsEnergy->GetXaxis()->SetRangeUser(0,40);
  graphMIPVsEnergy->GetYaxis()->SetRangeUser(0,80);

  graphMIPVsEnergy->Fit("pol1","","");
  fitter = TVirtualFitter::GetFitter();
  
  c->SaveAs( "MIPVsEnergyAt6X0.gif" );
  c->SaveAs( "MIPVsEnergyAt6X0.pdf" );


}
void fit_fy_vs_y_from_all_angles(TString tgt_pos){

  // histo parameters
  gStyle->SetTitleYOffset(1.2);
  gStyle->SetTitleXOffset(1.0);
  gStyle->SetLabelSize(0.06,"x");
  gStyle->SetLabelSize(0.06,"y");
  gStyle->SetTitleSize(0.06,"x");
  gStyle->SetTitleSize(0.06,"y");
  gStyle->SetTitleX(0.4);
  gStyle->SetTitleW(0.6);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleFillColor(0);
  gStyle->SetTitleFontSize(0.09);
  gStyle->SetStripDecimals(0);

 
  // Fit and stat parameters
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  gStyle->SetStatFont(132);
  gStyle->SetStatY(0.99);
  gStyle->SetStatX(0.99);
  gStyle->SetStatW(0.20);
  gStyle->SetStatH(0.20);

  //Pad parameters
  gStyle->SetPadColor(0); 
  gStyle->SetPadBorderMode(0);
  gStyle->SetFrameBorderMode(0);
  gStyle->SetPadBorderSize(0);
  gStyle->SetPadTopMargin(0.18);
  gStyle->SetPadBottomMargin(0.16);
  gStyle->SetPadRightMargin(0.05);
  gStyle->SetPadLeftMargin(0.15);
  
  //set target flag
  if(tgt_pos.Contains("us")) 
    upstream = true;
  else
    upstream = false;

  // Open a file to output the fy values
  fp = fopen(Form("%s_al_fy_for_all_angles.txt",tgt_pos.Data()), "w+");
  // fprintf(fp, This is testing for fprintf...\n");
  // fputs("This is testing for fputs...\n", fp);
  
  //Delete all the objects stored in the current directory memmory
  gDirectory->Delete("*");
  
  std::vector<std::string> files;
  Double_t angles[6] = {18,22,26,32,40,50};

  // vectors to store the fy and y from individual angles and their errors
  TVectorD *fyv = new TVectorD();
  TVectorD *yv= new TVectorD();
  TVectorD *yev= new TVectorD();
  TVectorD *fyev= new TVectorD();
  
  // vectors to store the fy_data/fy_model ratio and its error
  TVectorD *ratio = new TVectorD();
  TVectorD *eratio = new TVectorD();

  // vectors to store all the data together
  TVectorD *tfyv = new TVectorD();
  TVectorD *tyv= new TVectorD();
  TVectorD *tyev= new TVectorD();
  TVectorD *tfyev= new TVectorD();
  

 // Open canvas to draw the comparision between Fy vs Y using sig_exp and sig_exp corrected for sig_di// s
  TCanvas * c = new TCanvas("c", "",0,0,1000,1000);  
  c->Draw();
  c->Divide(1,2);
  
  Int_t pp = 0;

  // select files for a target with the given angle and get fy and y
  for(int i=0;i<6;i++){

    std::cout<<"reading angle = "<<angles[i]<<std::endl;
    files =  get_files(angles[i], tgt_pos);
    if(nodata){
      //skip. Do nothing
      nodata = false;
    }
    else{

      // get the fy and y from data with their errors
      get_fy_y(files, fyv, yv, yev, fyev);
      for(int k =0;k<fyv->GetNoElements();k++){


	// Fill the full arrays
	(*tfyv).ResizeTo(pp+1);
	(*tfyev).ResizeTo(pp+1);
	(*tyv).ResizeTo(pp+1);
	(*tyev).ResizeTo(pp+1);

	(*tfyv).operator()(pp) = (*fyv)[k];
	(*tfyev).operator()(pp) = (*fyev)[k];
	(*tyv).operator()(pp) = (*yv)[k];
	(*tyev).operator()(pp) = (*yev)[k];

	// Fill the full ratio arrays
	(*ratio).ResizeTo(pp+1);
	(*eratio).ResizeTo(pp+1);

	(*ratio).operator()(pp)=((*fyv)[k]/al_fy_from_pass0((*yv)[k]));
	//std::cout<<ratio(k)<<std::endl;
	(*eratio).operator()(pp)=((*fyev)[k]/al_fy_from_pass0((*yv)[k]));
	std::cout<<" @ y = "<<(*yv)[k]<<" (ratio, eratio) = "<<"("<<(*ratio)[pp]<<","<<(*eratio)[pp]<<")"<<std::endl;


	pp++;

      }
    }
  }  
  


  TLegend * leg= new TLegend(0.2,0.6,0.4,0.8);

  myfunc();

  TGraphErrors *gp = new TGraphErrors(*tyv,*tfyv,*tyev,*tfyev);
  c->cd(1);
  gPad->SetGridy();
  gPad->SetGridx();
  gp->Draw("AEP");
  gp->SetMarkerStyle(4);
  gp->SetMarkerColor(kBlue);
  gp->SetLineStyle(1);
  gp->SetLineColor(kBlue);
  gp->Fit("myfunc","EBMR");
  TF1 *tfit = gp->GetFunction("myfunc");
  tfit->SetLineColor(kRed);


  gp->GetYaxis()->SetRangeUser(0,4);
  gp->GetXaxis()->SetRangeUser(-1.0,0.2);
  gp->GetXaxis()->SetTitle("y(GeV/c)");
  gp->GetYaxis()->SetTitle("F(y)(GeV/c)^{-1}");
  gp->SetTitle("");
  leg->AddEntry(gp,"data","p");
  leg->AddEntry(tfit,"F(y) from pass1","l");

  
  // From model:
  myfunc();
  TF1 *ft = new TF1("ft"," al_fy_from_pass0(x)",-1.0,0.1); 
  ft->SetLineColor(kBlack);
  ft->SetLineStyle(1);
 
  // draw the model
  ft->Draw("same");
  leg->AddEntry(ft,"F(y) model","l");
  leg->Draw();

  // Draw in log scale
  c->cd(2);
  gPad->SetGridy();
  gPad->SetGridx();
  gp->Draw("AEP");
  ft->Draw("same");
  gPad->Modified();
  gPad->Update();
  gPad->SetLogy();
  gp->GetYaxis()->SetRangeUser(1e-6,10);
  gp->GetXaxis()->SetRangeUser(-1.0,0.2);
  gp->SetTitle(Form("%s Al, Y scaling with DIS subtraction;y(GeV/c);F(y,q)(GeV/c)^{-1}",tgt_pos.Data()));
  leg->Draw();

 
  TCanvas * c1 = new TCanvas("c1", "",0,0,700,500);  
  c1->Draw();
  gPad->SetGridy();
  gPad->SetGridx();
  // Fill the ratio graphs
  TGraphErrors * grr = new TGraphErrors(*tyv,*ratio,*tyev,*eratio); 
  grr->SetMarkerStyle(2);
  grr->SetMarkerColor(2);
  grr->SetLineStyle(1);
  grr->SetLineColor(2);
  grr->Draw("AEP");
  //grr->GetYaxis()->SetRangeUser(-100);
  grr->GetXaxis()->SetRangeUser(-1.0,0.2);
  grr->GetXaxis()->SetTitle("y(GeV/c)");
  grr->GetYaxis()->SetTitle("data_{F(y)}/model_{F(y)}");


 //close the text file
  fclose(fp);

  // // // c->Print(Form("xsec_rad_exp_mod_ratio_x_geq_%2.1f_and_x_leq_%2.1f_%s_dummy_%s_%s.png",xlow,xup,tgt_pos.Data(),angle.Data(),fit.Data()));
 
}
void MakeAmplitudeVsAbsorberThicknessGraph() {

  //use beam energy for xaxis
  const int nPoints = 5;
  float x[nPoints] = { 0.0, 1.0, 2.0, 4.0, 6.0 };
  float xerr[nPoints] = { 0.1, 0.25, 0.25, 0.25, 0.25 };
  float y_charge[nPoints] = {  6.5, 33, 57.0, 109, 106 }; 
  float yerr_charge[nPoints] = { 1.4, 24, 22, 60, 46 };
  float y_MIP[nPoints] = {  0.0, 0.0, 0.0, 0.0, 0.0 }; 
  float yerr_MIP[nPoints] = { 0.0, 0.0, 0.0, 0.0, 0.0 };

  double chargePerMIP = 6.5;
  for (int i=0; i<nPoints; ++i) {
    y_MIP[i] = y_charge[i] / chargePerMIP;
    yerr_MIP[i] =  yerr_charge[i] / chargePerMIP;
  }

  TGraphErrors *graphChargeVsAbsorber = new TGraphErrors(nPoints,x,y_charge,xerr,yerr_charge);
  graphChargeVsAbsorber->SetLineWidth(3);
  TGraphErrors *graphMIPVsAbsorber = new TGraphErrors(nPoints,x,y_MIP,xerr,yerr_MIP);
  graphMIPVsAbsorber->SetLineWidth(3);

  TCanvas *c = 0;
  TVirtualFitter *fitter = 0;

  c = new TCanvas("c","c",800,600);
  c->SetBottomMargin(0.12);
  graphChargeVsAbsorber->Draw("AP");
  graphChargeVsAbsorber->SetTitle("");
  graphChargeVsAbsorber->GetXaxis()->SetTitle("Tungsten Absorber Thickness [X_{0}]");
  graphChargeVsAbsorber->GetXaxis()->SetTitleSize(0.045);
  graphChargeVsAbsorber->GetXaxis()->SetLabelSize(0.045);
  graphChargeVsAbsorber->GetXaxis()->SetTitleOffset(1.2);
  graphChargeVsAbsorber->GetYaxis()->SetTitle("Integrated Charge [pC]");
  graphChargeVsAbsorber->GetYaxis()->SetTitleOffset(1.0);
  graphChargeVsAbsorber->GetYaxis()->SetTitleSize(0.05);
  graphChargeVsAbsorber->GetYaxis()->SetLabelSize(0.045);
  graphChargeVsAbsorber->GetXaxis()->SetRangeUser(0.0,8.0);
  graphChargeVsAbsorber->GetYaxis()->SetRangeUser(0,200);

  // graphChargeVsAbsorber->Fit("pol2","","");
  // fitter = TVirtualFitter::GetFitter();
  
  c->SaveAs( "ChargeVsAbsorberAt8GeV.gif" );
  c->SaveAs( "ChargeVsAbsorberAt8GeV.pdf" );


  c = new TCanvas("c","c",800,600);
  c->SetBottomMargin(0.12);
  c->SetLeftMargin(0.11);

  graphMIPVsAbsorber->Draw("AP");
  graphMIPVsAbsorber->SetTitle("");
  graphMIPVsAbsorber->GetXaxis()->SetTitle("Tungsten Absorber Thickness [X_{0}]");
  graphMIPVsAbsorber->GetXaxis()->SetTitleSize(0.045);
  graphMIPVsAbsorber->GetXaxis()->SetLabelSize(0.045);
  graphMIPVsAbsorber->GetXaxis()->SetTitleOffset(1.2);
  graphMIPVsAbsorber->GetYaxis()->SetTitle("Integrated Charge [ Q_{MIP} ]");
  graphMIPVsAbsorber->GetYaxis()->SetTitleOffset(0.9);
  graphMIPVsAbsorber->GetYaxis()->SetTitleSize(0.05);
  graphMIPVsAbsorber->GetYaxis()->SetLabelSize(0.045);
  graphMIPVsAbsorber->GetXaxis()->SetRangeUser(0.0, 8.0);
  graphMIPVsAbsorber->GetYaxis()->SetRangeUser(0, 30);

  // graphMIPVsAbsorber->Fit("pol1","","");
  // fitter = TVirtualFitter::GetFitter();
  
  c->SaveAs( "MIPVsAbsorberAt8GeV.gif" );
  c->SaveAs( "MIPVsAbsorberAt8GeV.pdf" );


}
void Overlay_NeutralEnergyDifferenceMean()
{
   std::string canvasName = "canvas";
   std::string canvasTitle = "Neutral energy mean";
   int canvasX1 = 200;
   int canvasY1 = 52;
   int canvasX2 = 700;
   int canvasY2 = 650;
   int nPoints = 6;
   int nGraphs = 5;
   int neutralEnergy = 10;

   double zero [] = {0, 0, 0, 0, 0, 0, 0, 0};
   double energies[] = {10, 20, 30, 40, 50};
   double distances[] = {5, 10, 15, 20, 25, 30};

   std::string graphXTitle = "Distance between showers [cm]";
   std::string graphYTitle = "<E_{n,rec} - E_{n,meas}>";
   double rangeUserXMin = 0;
   double rangeUserXMax = 35;
   double rangeUserYMin = -10;
   double rangeUserYMax = 10;

   TCanvas *pCanvas = new TCanvas(canvasName.c_str(), canvasTitle.c_str(), canvasX1, canvasY1, canvasX2, canvasY2);
   pCanvas->SetFillColor(0);
   pCanvas->SetBorderMode(0);
   pCanvas->SetBorderSize(2);
   pCanvas->SetTickx(1);
   pCanvas->SetTicky(1);
   pCanvas->SetLeftMargin(0.15);
   pCanvas->SetRightMargin(0.03);
   pCanvas->SetTopMargin(0.05);
   pCanvas->SetBottomMargin(0.14);
   pCanvas->SetFrameBorderMode(0);
   pCanvas->SetFrameBorderMode(0);

   TH1F *pH = new TH1F("pouette", "", rangeUserXMax-rangeUserXMin, rangeUserXMin, rangeUserXMax);
   pH->SetMinimum(rangeUserYMin);
   pH->SetMaximum(rangeUserYMax);
   pH->Draw();
   gStyle->SetOptStat(0);
   pH->GetYaxis()->SetTitle(graphYTitle.c_str());
   pH->GetXaxis()->SetTitle(graphXTitle.c_str());
   pH->GetYaxis()->SetLabelFont(42);
   pH->GetYaxis()->SetTitleSize(0.05);
   pH->GetYaxis()->SetTitleOffset(1);
   pH->GetYaxis()->SetTitleFont(42);
   pH->GetYaxis()->SetLabelSize(0.045);

   TLegend *leg = new TLegend(0.3,0.55,0.8,0.8,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(0);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetTextSize(0.03);

   int currentColor = 1;

   for(unsigned int e=0 ; e<nGraphs ; e++)
   {
     int energy = energies[e];
  
     double *data = new double[nPoints];
     double *dataError = zero;//new double[nPoints];

     std::stringstream fileName;
     fileName << "data_neutralERecDifference_ArborPFA_Test\ Beam_" << energy << "Gev.txt";
     readData(fileName.str(), data, nPoints);
     
     // fileName.str("");
     // fileName << "fichier_data_error_energy_" << energy << "GeV.txt";
     // readData(fileName.str(), dataError, nPoints);
   
     TGraphErrors *gre = 0;
     std::stringstream graphName;
     graphName << "Charged particle energy = " << energy << " GeV";
     gre = new TGraphErrors(nPoints, distances, data, zero, dataError);
     gre->SetName(graphName.str().c_str());
     gre->SetTitle(graphName.str().c_str());
     gre->SetLineColor(currentColor);
     gre->SetMarkerColor(currentColor);
     gre->SetMarkerStyle(23);
     gre->SetMarkerSize(1.2);
     gre->Draw("lp same");
   
     TLegendEntry *entry = 0;
     entry=leg->AddEntry(gre, graphName.str().c_str(), "lp");
     entry->SetFillStyle(1001);
     entry->SetMarkerColor(currentColor);
     entry->SetMarkerStyle(23);
     entry->SetMarkerSize(1);

     currentColor++;
   }

   TPaveText *pt = new TPaveText(0.55, 0.2, 0.93, 0.3, "tbNDC");
   pt->SetTextSize(0.05);
   pt->SetTextColor(kGray+2);
   pt->SetFillColor(0);
   pt->SetLineWidth(0);
   pt->SetBorderSize(0);
   pt->AddText("CALICE Preliminary");
   pt->SetTextFont(62);
   pt->Draw();
   
   leg->Draw();

   pCanvas->Modified();
   pCanvas->cd();
   pCanvas->SetSelected(pCanvas);
}
示例#28
0
文件: fitwitherr2.C 项目: XuQiao/HI
void fitwitherr2() {

  fetchpc3dphidz();

  float pt[50];
  float errx[50];

  for (int ipt=0; ipt<50; ipt++) {
    pt[ipt] = ipt*0.1 + 0.05;
    errx[ipt] = 0.0;
  }

  gStyle->SetOptStat(kFALSE);
  //gStyle->SetOptFit(1101);

  ofstream fout("run16dAupc3matchingsmooth.h");
  ofstream fout2("run16dAupc3matchingsmooth2.h");


  for (int iarm=0; iarm<2; iarm++) {
    for (int ich=0; ich<2; ich++) {
    for(int ivz=0; ivz<10; ivz++){
      string arm;
      string ch;
      if (iarm == 0) arm = "east";
      else if (iarm == 1) arm = "west";
      else arm = "err";

      if (ich == 0) ch = "pos";
      else if (ich == 1) ch = "neg";
      else ch = "err";
        string bbcz;
	if (ivz==0) bbcz = "-10 to -8";
        else if (ivz==1) bbcz = "-8 to -6";
	else if (ivz==2) bbcz = "-6 to -4";
	else if (ivz==3) bbcz = "-4 to -2";
	else if (ivz==4) bbcz = "-2 to 0";
	else if (ivz==5) bbcz = "0 to 2";
	else if (ivz==6) bbcz = "2 to 4";
	else if (ivz==7) bbcz = "4 to 6";
	else if (ivz==8) bbcz = "6 to 8";
	else if (ivz==9) bbcz = "8 to 10";
	else bbcz = "err";

      TCanvas *c1 = new TCanvas("c1","c1",500,500);
      c1->SetGridx();
      TGraphErrors* dphisigma = new TGraphErrors(50,pt,pc3dphisigma[iarm][ich][ivz],errx,pc3dphisigmaerr[iarm][ich][ivz]);
      dphisigma->SetTitle(Form("dphisigma_%s_%s_%s",arm,ch,bbcz));
      dphisigma->SetLineColor(1);
      dphisigma->SetMarkerStyle(20);
      dphisigma->SetMarkerSize(0.8);
      dphisigma->GetXaxis()->SetRangeUser(0.2,5.0);
      dphisigma->GetHistogram()->SetMaximum(0.01);
      dphisigma->GetHistogram()->SetMinimum(-0.01);
      dphisigma->GetXaxis()->SetTitle("p_{T}");
      dphisigma->GetYaxis()->SetTitle("dphi sigma");
      dphisigma->Draw("AP");

      TPaveText *p1 = new TPaveText(0.2,0.8,0.9,0.9,"NDC");
      p1->AddText("Fit function: a+bx+cx^{2}+dx^{3}+ex^{4}+fx^{5}+#frac{g}{#sqrt{x}}+#frac{h}{x^{2}}");
      p1->Draw("same");

      TF1 *fdphisigma = new TF1("fdphisigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.3,5.0);
      //TF1 *fdphisigma2 = new TF1("fdphisigma2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.2,5.0);
      dphisigma->Fit("fdphisigma","Q0","",0.4,4.0);
      //double sigma_par[8];
      //fdphisigma->GetParameters(sigma_par);
      //fdphisigma->SetParameters(sigma_par);
      //dphisigma->Fit("fdphisigma2","Q0","",0.3,5.0);
      fdphisigma->Draw("same");
      fout << "fdphisigma->SetParameters(" << fdphisigma->GetParameter(0) << "," << fdphisigma->GetParameter(1) << "," << fdphisigma->GetParameter(2) << "," << fdphisigma->GetParameter(3) << "," << fdphisigma->GetParameter(4) << "," << fdphisigma->GetParameter(5) << "," << fdphisigma->GetParameter(6) << "," << fdphisigma->GetParameter(7) << ");" << endl;
      for(int ipar=0;ipar<8;ipar++){
      fout2 << "PC3_dphisigma[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdphisigma->GetParameter(ipar) << ";" << endl;
      }
      c1->Print(Form("smooth/dphisigma_%d_%d_%d.png",iarm,ich,ivz));
      delete c1;


      TCanvas *c3 = new TCanvas("c3","c3",500,500);
      c3->SetGridx();
      TGraphErrors* dphimean = new TGraphErrors(50,pt,pc3dphimean[iarm][ich][ivz],errx,pc3dphimeanerr[iarm][ich][ivz]);
      dphimean->SetTitle(Form("dphimean_%s_%s_%s",arm,ch,bbcz));
      dphimean->SetLineColor(1);
      dphimean->SetMarkerStyle(20);
      dphimean->SetMarkerSize(0.8);
      dphimean->GetXaxis()->SetRangeUser(0.2,5.0);
      dphimean->GetHistogram()->SetMaximum(0.01);
      dphimean->GetHistogram()->SetMinimum(-0.01);
      dphimean->GetXaxis()->SetTitle("p_{T}");
      dphimean->GetYaxis()->SetTitle("dphi mean");
      dphimean->Draw("AP");

      TPaveText *p3 = new TPaveText(0.2,0.8,0.9,0.9,"NDC");
      p3->AddText("Fit function: a+bx+#frac{c}{x}+#frac{d}{#sqrt{x}}+#frac{e}{x^{2}}+#frac{f}{x^{3}}+#frac{g}{x^{4}}");
      p3->Draw("same");
      TF1 *fdphimean = new TF1("fdphimean","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.3,5.0);
      //TF1 *fdphimean2 = new TF1("fdphimean2","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.2,5.0);
      dphimean->Fit("fdphimean","Q0","",0.4,4.0);
      double mean_par[7];
      //fdphimean->GetParameters(mean_par);
      //fdphimean2->SetParameters(mean_par);
      //dphimean->Fit("fdphimean2","Q0","",0.3,5.0);
      fdphimean->Draw("same");
      fout << "fdphimean->SetParameters(" << fdphimean->GetParameter(0) << "," << fdphimean->GetParameter(1) << "," << fdphimean->GetParameter(2) << "," << fdphimean->GetParameter(3) << "," << fdphimean->GetParameter(4) << "," << fdphimean->GetParameter(5) << "," << fdphimean->GetParameter(6) << ");" << endl;
      for(int ipar=0;ipar<7;ipar++){
      fout2 << "PC3_dphimean[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdphimean->GetParameter(ipar) << ";" << endl;
      }
      c3->Print(Form("smooth/dphimean_%d_%d_%d.png",iarm,ich,ivz));
      delete c3;

      TCanvas *c2 = new TCanvas("c2","c2",500,500);
      c2->SetGridx();
      TGraphErrors* dzsigma = new TGraphErrors(50,pt,pc3dzsigma[iarm][ich][ivz],errx,pc3dzsigmaerr[iarm][ich][ivz]);
      dzsigma->SetTitle(Form("dzsigma_%s_%s_%s",arm,ch,bbcz));
      dzsigma->SetLineColor(1);
      dzsigma->SetMarkerStyle(20);
      dzsigma->SetMarkerSize(0.8);
      dzsigma->GetXaxis()->SetRangeUser(0.2,5.0);
      dzsigma->GetHistogram()->SetMaximum(5);
      dzsigma->GetHistogram()->SetMinimum(0);
      dzsigma->GetXaxis()->SetTitle("p_{T}");
      dzsigma->GetYaxis()->SetTitle("dz sigma");
      dzsigma->Draw("AP");

      TPaveText *p2 = new TPaveText(0.2,0.8,0.9,0.9,"NDC");
      p2->AddText("Fit function: a+bx+cx^{2}+dx^{3}+ex^{4}+fx^{5}+#frac{g}{#sqrt{x}}+#frac{h}{x^{2}}");
      p2->Draw("same");

      //TF1 *fdzsigma = new TF1("fdzsigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]/TMath::Sqrt(x)+[6]/x/x",0.3,5.0);
      TF1 *fdzsigma = new TF1("fdzsigma","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]*x*x*x*x*x+[6]/TMath::Sqrt(x)+[7]/x/x",0.3,5.0);
      //TF1 *fdzsigma2 = new TF1("fdzsigma2","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x+[5]/TMath::Sqrt(x)+[6]/x/x",0.2,5.0);
      dzsigma->Fit("fdzsigma","Q0","",0.4,4.0);
      //fdzsigma->GetParameters(sigma_par);
      //fdzsigma2->SetParameters(sigma_par);
      //dzsigma->Fit("fdzsigma2","Q0","",0.3,5.0);
      fdzsigma->Draw("same");
      fout << "fdzsigma->SetParameters(" << fdzsigma->GetParameter(0) << "," << fdzsigma->GetParameter(1) << "," << fdzsigma->GetParameter(2) << "," << fdzsigma->GetParameter(3) << "," << fdzsigma->GetParameter(4) << "," << fdzsigma->GetParameter(5) << "," << fdzsigma->GetParameter(6) << ");" << endl;
      for(int ipar=0;ipar<8;ipar++){
      fout2 << "PC3_dzsigma[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdzsigma->GetParameter(ipar) <<  ";" << endl;
      }
      c2->Print(Form("smooth/dzsigma_%d_%d_%d.png",iarm,ich,ivz));
      delete c2;





      TCanvas *c4 = new TCanvas("c4","c4",500,500);
      c4->SetGridx();
      TGraphErrors* dzmean = new TGraphErrors(50,pt,pc3dzmean[iarm][ich][ivz],errx,pc3dzmeanerr[iarm][ich][ivz]);
      dzmean->SetTitle(Form("dzmean_%s_%s_%s",arm,ch,bbcz));
      dzmean->SetLineColor(1);
      dzmean->SetMarkerStyle(20);
      dzmean->SetMarkerSize(0.8);
      dzmean->GetXaxis()->SetRangeUser(0.2,5.0);
      dzmean->GetHistogram()->SetMaximum(3);
      dzmean->GetHistogram()->SetMinimum(-2);
      dzmean->GetXaxis()->SetTitle("p_{T}");
      dzmean->GetYaxis()->SetTitle("dz mean");
      dzmean->Draw("AP");

      TPaveText *p4 = new TPaveText(0.2,0.8,0.9,0.9,"NDC");
      p4->AddText("Fit function: a+bx+#frac{c}{x}+#frac{d}{#sqrt{x}}+#frac{e}{x^{2}}+#frac{f}{x^{3}}+#frac{g}{x^{4}}");
      p4->Draw("same");

      TF1 *fdzmean = new TF1("fdzmean","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.3,5.0);
      //TF1 *fdzmean2 = new TF1("fdzmean2","[0]+[1]*x+[2]/x+[3]/TMath::Sqrt(x)+[4]/x/x+[5]/x/x/x+[6]/x/x/x/x",0.2,5.0);
      dzmean->Fit("fdzmean","Q0","",0.4,4.0);
      //fdzmean->GetParameters(mean_par);
      //fdzmean2->SetParameters(mean_par);
      //dzmean->Fit("fdzmean2","Q0","",0.3,5.0);
      fdzmean->Draw("same");
      fout << "fdzmean->SetParameters(" << fdzmean->GetParameter(0) << "," << fdzmean->GetParameter(1) << "," << fdzmean->GetParameter(2) << "," << fdzmean->GetParameter(3) << "," << fdzmean->GetParameter(4) << "," << fdzmean->GetParameter(5) << "," << fdzmean->GetParameter(6) << ");" << endl;
      for(int ipar=0;ipar<7;ipar++){
      fout2 << "PC3_dzmean[" << iarm <<"][" << ich << "][" << ivz <<"][" << ipar << "] = " << fdzmean->GetParameter(ipar) <<  ";" << endl;
      }
      c4->Print(Form("smooth/dzmean_%d_%d_%d.png",iarm,ich,ivz));
      delete c4;
      }
    }
  }
  

}
示例#29
0
void cetaflatHFM12(int nIterN=1, double Ethr1=10, double Ethr2=150) { // for HFM, L and S separately
  // nIterN - number of iterations
  // Ethr1 and Ethr2 - E thresholds within which E is estimated
  
  gStyle->SetOptLogz(0);
  gStyle->SetMarkerSize(0.7);
  gStyle->SetMarkerStyle(20);
  gStyle->SetPadGridX(0);
  gStyle->SetPadGridY(0);
  gStyle->SetTitleOffset(1.7,"Y");
  gStyle->SetTitleOffset(0.9,"X");
  //gStyle->SetPadRightMargin(0.12);
  gStyle->SetPadRightMargin(0.03);
  gStyle->SetPadLeftMargin(0.18);
  //gStyle->SetNdivisions(516);
  gStyle->SetStatH(0.025);
  gStyle->SetStatW(0.3);
  gStyle->SetTitleW(0.4);
  gStyle->SetTitleX(0.28);
  gStyle->SetOptStat(0);
  gROOT->ForceStyle();

  char ctit[245],ftit[245];
  float etaBounds[14] = {2.853,2.964,3.139,3.314,3.489,3.664,3.839,4.013,4.191,4.363,4.538,4.716,4.889,5.205};

  // ------Histos input: spectra of all channels-----------------------------------

  //sprintf(ftit,"%s","phi43val2012A");
  //sprintf(ftit,"%s","phi2012A_May");
  //sprintf(ftit,"%s","phiSym524_2012AB");
  //sprintf(ftit,"%s","phiSym524newGain_2012AB");
  //sprintf(ftit,"%s","phiSym524newGain_2012ABC");
  //sprintf(ftit,"%s","phisymNewCond2012Cval");
  //sprintf(ftit,"%s","phisymOldCond2012Cval");
  //sprintf(ftit,"%s","phiSym533Gain507_2012D");
  //  sprintf(ftit,"%s","phiSym533Corr45Gain507_2012D");  //  histo root file processed

  //sprintf(ctit,"/home/vodib/beam12/intercal/%s.root",ftit);
  sprintf(ctit,"hcal.root",ftit);    
TFile *fila = new TFile (ctit);
  cout<<"File= "<<ctit<<endl;

  TH1F *hcounter =   new TH1F(*((TH1F*)fila->Get("phaseHF/hcounter")));
  cout<<"Stat= "<<hcounter->GetBinContent(2)<<endl;
  cout<<"E within: "<<Ethr1<<" - "<<Ethr2<<endl;

  TH2F* hLmapP = new TH2F("hLmapP","E L HFM;i#eta;i#phi",13,-41.5,-28.5,36,0,72);
  TH2F* hSmapP = new TH2F("hSmapP","E S HFM;i#eta;i#phi",13,-41.5,-28.5,36,0,72);
  TH2F* hLmapM0 = new TH2F("hLmapM0","E0 L HFM;i#eta;i#phi",13,-41.5,-28.5,36,0,72);
  TH2F* hSmapM0 = new TH2F("hSmapM0","E0 S HFM;i#eta;i#phi",13,-41.5,-28.5,36,0,72);
  TH2F* hLmapPc = new TH2F("hLmapPc","corr L HFM;i#eta;i#phi",13,-41.5,-28.5,36,0,72);
  TH2F* hSmapPc = new TH2F("hSmapPc","corr S HFM;i#eta;i#phi",13,-41.5,-28.5,36,0,72);
  hLmapPc->Sumw2(); hSmapPc->Sumw2();
  //TH1F *hLcorr1D = new TH1F("hLcorr1D","Corr L",300,0.5,2);
  //TH1F *hScorr1D = new TH1F("hScorr1D","Corr S",300,0.5,2);
  TH1F *hLcorr1D = new TH1F("hLcorr1D","Corr L",180,0.7,1.5);
  TH1F *hScorr1D = new TH1F("hScorr1D","Corr S",180,0.7,1.5);
  TH1F *hLdatP[13][36], *hSdatP[13][36], *hLdatPx[13][36], *hSdatPx[13][36];
  for (int ii=0;ii<13;ii++) for (int jj=0;jj<36;jj++) {
    sprintf(ctit,"hL%d_%d",-29-ii,2*jj+1);
    hLdatP[ii][jj] = new TH1F(ctit,ctit,8000,0,250);
    sprintf(ctit,"hS%d_%d",-29-ii,2*jj+1);
    hSdatP[ii][jj] = new TH1F(ctit,ctit,8000,0,250);
  }
  TH1F *htL = new TH1F("htL","htL",20000,0,7e8/3.);
  TH1F *htS = new TH1F("htS","htS",20000,0,5e8/3.);
  //TH1F *htL = new TH1F("htL","htL",20000,0,4e8/40);
  //TH1F *htS = new TH1F("htS","htS",20000,0,2e8/40);
  TH1F *hLdatPx[13][36], *hSdatPx[13][36];

  TCanvas *cLx[200],*cSx[200];
  TSpline5 *ttL,*ttS;

  Double_t x,y,rPL,rPS,drPL,drPS,mLE,mSE,ermean,rms;
  Double_t xxL[1000],yyL[1000];
  Double_t xxS[1000],yyS[1000];
  Int_t nELP, nESP, nIter=0;
  Double_t mcorrL,scorrL,mcorrS,scorrS,erLP,erSP,rLP,drLP,rSP,drSP,corrL,corrS,dcorrL,dcorrS;
  double mLEphi[13],mSEphi[13],dmLEphi[13],dmSEphi[13];

  TCanvas *ccxx = new TCanvas("ccxx","ccxx",100,300,900,500);
  ccxx->Divide(2,1);

  // loop over channels, 
  for (int ii=0;ii<13;ii++) {  // loop over HFM ieta (rings)
  //for (int ii=1;ii<2;ii++) {
    int ieta=-ii-29;

    mLE=mSE=0;   // ------------------for initial condition
    int nmLE=0, nmSE=0;
    htL->Reset(); htS->Reset();
    for (int ll=1;ll<=72;ll+=2) { // loop over channels within HFM ieta (ring) to get data
      int iphi=ll;
      if (abs(ieta)>39 && (iphi-1)%4==0) continue;
      //if (ieta==29 && iphi==67) continue;
      hSmapPc->SetBinContent(13-ii,ll/2+1,1);  //  initial correction set to 1
      hLmapPc->SetBinContent(13-ii,ll/2+1,1);
      hSmapPc->SetBinError(13-ii,ll/2+1,1.e-6);  //  non-zero err required
      hLmapPc->SetBinError(13-ii,ll/2+1,1.e-6);
      sprintf(ctit,"phaseHF/espec/E_%d_%d_1",ieta,iphi);
      hLdatPx[ii][ll/2]  =   new TH1F(*((TH1F*)fila->Get(ctit)));  // read spectrum from root file
      hLdatPx[ii][ll/2]->SetAxisRange(Ethr1,Ethr2);
      rLP = hLdatPx[ii][ll/2]->Integral()*hLdatPx[ii][ll/2]->GetMean();  // channel's total E between thresholds
      if (rLP>0) {
	htL->Fill(rLP);
	mLE += rLP;  // ring's total E between thresholds
	nmLE++;
      }
      sprintf(ctit,"phaseHF/espec/E_%d_%d_2",ieta,iphi);
      hSdatPx[ii][ll/2]  =   new TH1F(*((TH1F*)fila->Get(ctit)));
      hSdatPx[ii][ll/2]->SetAxisRange(Ethr1,Ethr2);
      rSP = hSdatPx[ii][ll/2]->Integral()*hSdatPx[ii][ll/2]->GetMean();
      if (rSP>0) {
	htS->Fill(rSP);
	mSE += rSP;
	nmSE++;
      }
      hLmapM0->SetBinContent(13-ii,ll/2+1,rLP);
      hSmapM0->SetBinContent(13-ii,ll/2+1,rSP);
      hSdatP[ii][ll/2]->SetAxisRange(Ethr1,Ethr2);
    }
    if (nmLE>0) mLE /= nmLE; // ring's <E> 
    else continue;
    if (nmSE>0) mSE /= nmSE; 
    else continue;
    ccxx->cd(1); htL->Draw("hist");
    ccxx->cd(2); htS->Draw("hist");
    ccxx->Update();
    //histspec(htL,mLE,ermean,rms,4,3);
    //histspec(htS,mSE,ermean,rms,4,3);
    mLEphi[ii]=mLE;
    mSEphi[ii]=mSE;
    dmLEphi[ii]=htL->GetRMS();
    dmSEphi[ii]=htS->GetRMS();
    printf("ieta %2d :  <E>L= %8.1f (%6.1f) x %d    <E>S= %8.1f (%6.1f) x %d \n",
	   ieta,mLE,dmLEphi[ii],nmLE,mSE,dmSEphi[ii],nmSE);
    
    for (int jj=1;jj<=72;jj+=2) { // loop over channels within HFM ieta (ring) to get correction
      int iphi=jj;
      if (abs(ieta)>39 && (iphi-1)%4==0) continue;

      for (nIter=1;nIter<nIterN;nIter++) { // loop over iterations, L channels
	corrL=hLmapPc->GetBinContent(13-ii,jj/2+1);  // correction factor
	hLdatP[ii][jj/2]->Reset();

	for (int kk=1;kk<=hLdatPx[ii][jj/2]->GetNbinsX();kk++) {
	  xxL[kk-1]=hLdatPx[ii][jj/2]->GetBinCenter(kk);
	  yyL[kk-1]=hLdatPx[ii][jj/2]->GetBinContent(kk);
	}
	ttL = new TSpline5("tt",xxL,yyL,1000,"",10,20);  // spline function over spectrum to get
	// smoother image of spectrum to improve convergence 

	for (int kk=1;kk<=hLdatP[ii][jj/2]->GetNbinsX();kk++) {
	  x=hLdatP[ii][jj/2]->GetBinCenter(kk);
	  y=hLdatP[ii][jj/2]->GetBinContent(kk);
	  hLdatP[ii][jj/2]->Fill(x*corrL,ttL->Eval(x)/8.0);  // smoother image of spectrum,
	  // with E shifted (corrected) by correction factor;
	  // factor 8 due to difference in bin size of spectrum and smoother image of spectrum.
	}
	ttL->Delete();

	hLdatP[ii][jj/2]->SetAxisRange(Ethr1,Ethr2);
	rLP = hLdatP[ii][jj/2]->Integral()*hLdatP[ii][jj/2]->GetMean(); // E of corrected spectrum 
	dcorrL=(rLP-mLE)/mLE;  // estimator of difference between <E> and E of corrected spectrum
	if (rLP>0) drLP=
	      sqrt(pow(hLdatP[ii][jj/2]->GetMeanError()/hLdatP[ii][jj/2]->GetMean(),2)+
		   1.f/hLdatP[ii][jj/2]->Integral()+
		   pow(dcorrL/(1.0+sqrt((float) nIter)),2));
	else drLP=1.e-6;
	if (fabs(dcorrL)>0.001) { 
	  corrL*=1-dcorrL/(1.0+sqrt((float) nIter));  // new correction factor
	  //printf("%2d : %2d / %2d / 1 %7.3f %7.3f\n",nIter,ieta,iphi,dcorrL,corrL);
	  hLmapPc->SetBinContent(13-ii,jj/2+1,corrL);
	  hLmapPc->SetBinError(13-ii,jj/2+1,corrL*drLP);
	  hLmapP->SetBinContent(13-ii,jj/2+1,rLP);
	}
	else {
	  printf("%2d : %2d / %2d / 1 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrL,corrL,corrL*drLP);
	  hLmapP->SetBinContent(13-ii,jj/2+1,rLP);
	  hLmapPc->SetBinError(13-ii,jj/2+1,corrL*drLP);
	  break;
	}
	if (nIter==nIterN-1) {
	  printf("%2d : %2d / %2d / 1 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrL,corrL,corrL*drLP);
	}
      }

      for (nIter=1;nIter<nIterN;nIter++) { 
	corrS=hSmapPc->GetBinContent(13-ii,jj/2+1);
	hSdatP[ii][jj/2]->Reset();

	for (int kk=1;kk<=hSdatPx[ii][jj/2]->GetNbinsX();kk++) {
	  xxS[kk-1]=hSdatPx[ii][jj/2]->GetBinCenter(kk);
	  yyS[kk-1]=hSdatPx[ii][jj/2]->GetBinContent(kk);
	}
	ttS = new TSpline5("tt",xxS,yyS,1000,"",10,20);

	for (int kk=1;kk<=hSdatP[ii][jj/2]->GetNbinsX();kk++) {
	  x=hSdatP[ii][jj/2]->GetBinCenter(kk);
	  y=hSdatP[ii][jj/2]->GetBinContent(kk);
	  hSdatP[ii][jj/2]->Fill(x*corrS,ttS->Eval(x)/8.0);
	}
	ttS->Delete();

	hSdatP[ii][jj/2]->SetAxisRange(Ethr1,Ethr2);
	rSP = hSdatP[ii][jj/2]->Integral()*hSdatP[ii][jj/2]->GetMean();
	dcorrS=(rSP-mSE)/mSE;
	if (rSP>0) drSP=sqrt(pow(hSdatP[ii][jj/2]->GetMeanError()/hSdatP[ii][jj/2]->GetMean(),2)+
			     1.f/hSdatP[ii][jj/2]->Integral()+
			     pow(dcorrS/(1.0+sqrt((float) nIter)),2));
	else drSP=1.e-6;
	if (fabs(dcorrS)>0.001) { 
	  corrS*=1-dcorrS/(1.0+sqrt((float) nIter));
	  //printf("%2d : %2d / %2d / 1 %7.3f %7.3f\n",nIter,ieta,iphi,dcorrS,corrS);
	  hSmapPc->SetBinContent(13-ii,jj/2+1,corrS);
	  hSmapPc->SetBinError(13-ii,jj/2+1,corrS*drSP);
	  hSmapP->SetBinContent(13-ii,jj/2+1,rSP);
	}
	else {
	  printf("%2d : %2d / %2d / 2 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrS,corrS,corrS*drSP);
	  hSmapP->SetBinContent(13-ii,jj/2+1,rSP);
	  hSmapPc->SetBinError(13-ii,jj/2+1,corrS*drSP);
	  break;
	}
	if (nIter==nIterN-1) {
	  printf("%2d : %2d / %2d / 2 %7.3f %8.4f %8.4f\n",nIter,ieta,iphi,dcorrS,corrS,corrS*drSP);
	}
      }
    }
  }
  //fila->Close();

  cout<<endl<<"Rings :  "<<endl;
  cout<<"       E L        "<<"E S        "<<"eta     "<<"delta eta"<<endl;
  double xeta[13], weta[13], reta[13];
  for (int i=0;i<13;i++) {
    xeta[i]=-(etaBounds[i+1]+etaBounds[i])/2;
    weta[i]=(etaBounds[i+1]-etaBounds[i]);
    mLEphi[i]=mLEphi[i]*36/weta[i];
    mSEphi[i]=mSEphi[i]*36/weta[i];
    dmLEphi[i]=dmLEphi[i]*36/weta[i];
    dmSEphi[i]=dmSEphi[i]*36/weta[i];
    if (i>10) {  mLEphi[i]/=2; mSEphi[i]/=2; dmLEphi[i]/=2; dmSEphi[i]/=2; }
    reta[i] = mSEphi[i]/mLEphi[i];
    cout<<i<<" :  "<<mLEphi[i]<<"    "<<mSEphi[i]<<"    "<<xeta[i]<<"   "<<weta[i]<<endl;
  }
  TCanvas *cgL = new TCanvas("cgL","cgL",300,300,600,600);
  TGraphErrors *grL = new TGraphErrors(13,xeta,mLEphi,0,dmLEphi);
  grL->SetName("grL");
  grL->SetTitle("HFM L;#eta;E_{Ring} / #Delta#eta_{Ring} ,  GeV");
  grL->SetMinimum(0);
  grL->SetMarkerStyle(20);
  grL->Draw("1+PAl");
  cgL->Print("pictHFplot/etaProfHFML.gif");
  //cgL->Print("pictHFmc/etaProfHFML.gif");
  mSEphi[12]/=2; mSEphi[11]/=2;
  TCanvas *cgS = new TCanvas("cgS","cgS",300,300,600,600);
  TGraphErrors *grS = new TGraphErrors(13,xeta,mSEphi,0,dmSEphi);
  grS->SetName("grS");
  grS->SetTitle("HFM S;#eta;E_{Ring} / #Delta#eta_{Ring} ,  GeV");
  grS->SetMinimum(0);
  grS->SetMarkerStyle(20);
  grS->Draw("1+PAl");
  cgS->Print("pictHFplot/etaProfHFMS.gif");
  //cgS->Print("pictHFmc/etaProfHFMS.gif");
  TCanvas *crg = new TCanvas("crg","crg",300,300,600,600);
  TGraphErrors *rg = new TGraphErrors(13,xeta,reta,0,0);
  rg->SetTitle("HFM;#eta;E(S) / E(L)");
  rg->SetMinimum(0);
  rg->Draw("1+PAl");
  crg->Print("pictHFplot/SoverLetaHFM.gif");
  //crg->Print("pictHFmc/SoverLetaHFM.gif");

  TCanvas *cL0 = new TCanvas("cL0","cL0",0,0,650,600);
  hLmapM0->Draw("colz");
  cL0->Update();
  TCanvas *cS = new TCanvas("cS0","cS0",1000,0,650,600);
  hSmapM0->Draw("colz");
  cS0->Update();

  //TFile *histf = new TFile("HFMmc.root","RECREATE");

  FILE *ft1;
  //sprintf(ctit,"corrHFMmc_%d_%d.txt",((int) Ethr1),((int) Ethr2));
  sprintf(ctit,"corrHFM_%s_%d_%d.txt",ftit,((int) Ethr1),((int) Ethr2));
  if ((ft1 = fopen(ctit,"w"))==NULL){               // Open new file
    printf("\nNo file %s open => EXIT\n\n",file);
    return;
  }
  printf("\n\n File '%s' open \n\n",ctit);

  TH1D *hprL[13],*hprS[13],*hprL0[13],*hprS0[13];
  TH1D *hprcL[13],*hprcS[13];
  TCanvas *cpr[13],*ccc[13];
  TLine *lin1 = new TLine(0,1,71,1); lin1->SetLineWidth(1);

  int noff=0;
  for (int ii=0;ii<13;ii++) {
    int ieta=-ii-29;

    sprintf(ctit,"HFMcorr_%d_L",-ii-29);  // draw corrections
    hprcL[ii] = hLmapPc->ProjectionY(ctit,13-ii,13-ii);
    hprcL[ii]->SetTitle(ctit);
    sprintf(ctit,"HFMcorr_%d_S",-ii-29);
    hprcS[ii] = hSmapPc->ProjectionY(ctit,13-ii,13-ii);
    hprcS[ii]->SetTitle(ctit);
    ccc[ii] = new TCanvas(ctit,ctit,800,100,500,900);
    ccc[ii]->Divide(1,2);
    ccc[ii]->cd(1);
    if (abs(ieta)>39) {
      hprcL[ii]->Rebin(2);
      hprcS[ii]->Rebin(2);
    }
    hprcL[ii]->SetMinimum(0);
    hprcL[ii]->SetTitleOffset(0.9,"X");
    hprcL[ii]->Draw("e");
    lin1->Draw();
    ccc[ii]->cd(2);
    hprcS[ii]->SetMinimum(0);
    hprcS[ii]->SetTitleOffset(0.9,"X");
    hprcS[ii]->Draw("e");
    lin1->Draw();
    sprintf(ctit,"pictHFplot/HFMcorr_%d.gif",ii+29);
    //sprintf(ctit,"pictHFmc/HFMcorr_%d.gif",ii+29);
    ccc[ii]->Update();
    ccc[ii]->Print(ctit);
    //hprcL[ii]->Write();
    //hprcS[ii]->Write();

    sprintf(ctit,"HFM_%d_L",-29-ii);  //  draw E depositions
    hprL0[ii] = hLmapM0->ProjectionY(ctit,13-ii,13-ii);
    sprintf(ctit,"HFM_%d_L;i#phi;GeV;",-29-ii);  //  draw E depositions
    hprL0[ii]->SetTitle(ctit);
    sprintf(ctit,"HFM_L_%d",-29-ii);
    hprL[ii] = hLmapP->ProjectionY(ctit,13-ii,13-ii);
    sprintf(ctit,"HFM_%d_S",-29-ii);
    hprS0[ii] = hSmapM0->ProjectionY(ctit,13-ii,13-ii);
    sprintf(ctit,"HFM_%d_S;i#phi;GeV;",-29-ii);  //  draw E depositions
    hprS0[ii]->SetTitle(ctit);
    sprintf(ctit,"HFM_S_%d",-29-ii);
    hprS[ii] = hSmapP->ProjectionY(ctit,13-ii,13-ii);

    cpr[ii] = new TCanvas(ctit,ctit,800,100,500,900);
    cpr[ii]->Divide(1,2);
    cpr[ii]->cd(1);
    if (abs(ieta)>39) {
      hprL0[ii]->Rebin(2);
      hprL[ii]->Rebin(2);
      hprS0[ii]->Rebin(2);
      hprS[ii]->Rebin(2);
    }
    hprL0[ii]->SetFillColor(3);hprL0[ii]->SetLineColor(3);hprL0[ii]->SetLineWidth(3);
    hprL0[ii]->SetMinimum(0);
    hprL0[ii]->SetTitleOffset(0.9,"X");
    hprL0[ii]->Draw("hist");
    hprL[ii]->Draw("samehist");
    cpr[ii]->cd(2);
    hprS0[ii]->SetMinimum(0);
    hprS0[ii]->SetTitleOffset(0.9,"X");
    hprS0[ii]->SetFillColor(3);hprS0[ii]->SetLineColor(3);hprS0[ii]->SetLineWidth(3);
    hprS0[ii]->Draw("hist");
    hprS[ii]->Draw("samehist");
    sprintf(ctit,"pictHFplot/HFM_%d.gif",ii+29);
    //sprintf(ctit,"pictHFmc/HFM_10_100G_%d.gif",ii+29);
    cpr[ii]->Update();
    cpr[ii]->Print(ctit);
    //hprS0[ii]->Write();
    //hprL0[ii]->Write();

    cout<<"Results : "<<endl;
    for (int jj=1;jj<=72;jj+=2) {
      int ieta=-ii-29;
      int iphi=jj;
      if (abs(ieta)>39 && (iphi-1)%4==0) continue;
      //if (ieta==29 && iphi==67) continue;
      corrL=hLmapPc->GetBinContent(13-ii,jj/2+1);
      corrS=hSmapPc->GetBinContent(13-ii,jj/2+1);
      dcorrL=hLmapPc->GetBinError(13-ii,jj/2+1);
      dcorrS=hSmapPc->GetBinError(13-ii,jj/2+1);
      // -------------------------------------------------------------- !!!
      //if (abs(ieta)>29 && abs(ieta)<41) 
      hLcorr1D->Fill(corrL); 
      hScorr1D->Fill(corrS);
      noff++;
      //printf("%2d : %2d / %2d / 1 %9.4f %9.4f\n",noff,ieta,iphi,corrL,dcorrL);
      fprintf(ft1,"%2d   %2d   1 %9.4f %9.4f\n",ieta,iphi,corrL,dcorrL);
      noff++;
      //printf("%2d : %2d / %2d / 2 %9.4f %9.4f\n",noff,ieta,iphi,corrS,dcorrS);
      fprintf(ft1,"%2d   %2d   2 %9.4f %9.4f\n",ieta,iphi,corrS,dcorrS);
    }
  }
  fclose(ft1);

  for (int ii=0;ii<13;ii++) for (int jj=1;jj<=72;jj+=2) {
      int ieta=-ii-29;
      int iphi=jj;
      if (abs(ieta)>39 && (iphi-1)%4==0) continue;
      //if (ieta==29 && iphi==67) continue;
      corrL=hLmapPc->GetBinContent(13-ii,jj/2+1);
      if (fabs(corrL-1)>0.16) printf("%2d / %2d / 1 %9.4f %9.4f\n",ieta,iphi,corrL,dcorrL);
      corrS=hSmapPc->GetBinContent(13-ii,jj/2+1);
      if (fabs(corrS-1)>0.16) printf("%2d / %2d / 2 %9.4f %9.4f\n",ieta,iphi,corrS,dcorrS);
  }

  TCanvas *cLcorr =new TCanvas("cLcorr","cLcorr",30,30,600,600);
  cLcorr->SetRightMargin(0.12);
  hLmapPc->SetAxisRange(0.6,1.6,"Z");
  hLmapPc->Draw("colz");
  TCanvas *cScorr =new TCanvas("cScorr","cScorr",30,300,600,600);
  cScorr->SetRightMargin(0.12);
  hSmapPc->SetAxisRange(0.6,1.6,"Z");
  hSmapPc->Draw("colz");

  TCanvas *cL = new TCanvas("cL","cL",0,0,650,600);
  hLmapP->Draw("colz");
  cL->Update();
  TCanvas *cS = new TCanvas("cS","cS",1000,0,650,600);
  hSmapP->Draw("colz");
  cS->Update();
  
  TCanvas *c1corr =new TCanvas("c1corr","c1corr",30,30,900,500);
  c1corr->Divide(2,1);
  c1corr->cd(1);  hLcorr1D->Draw("hist");  histStat(hLcorr1D,1);
  c1corr->cd(2);  hScorr1D->Draw("hist");  histStat(hScorr1D,1);
  c1corr->Print("pictHFplot/corrHFM.gif");
  //c1corr->Print("pictHFmc/corrM.gif");
  c1corr->Update();
  
  //fila->Close();
  //histf->Close();

  sprintf(ctit,"HFMo_%s_%d_%d.root",ftit,((int) Ethr1),((int) Ethr2));
  TFile *histf = new TFile(ctit,"RECREATE");
  hLcorr1D->Write(); 
  hScorr1D->Write();  
  hLmapP->Write(); 
  hLmapM0->Write(); 
  hLmapPc->Write(); 
  hSmapP->Write(); 
  hSmapM0->Write(); 
  hSmapPc->Write(); 
  grL->Write();
  grS->Write();
  histf->Close();
}
void AnalyzeWaveforms(char *WaveformsFile = "Waveforms.root", const int nAddedChannels = 5) {
	
	//try to access waveforms file and in case of failure return
	if(gSystem->AccessPathName(WaveformsFile,kFileExists)) {
		cout << "Error: file " << WaveformsFile << " does not exsist. Run .x WaveformsFileMaker.C to create it" << endl;
		return;
	}
	//	gStyle->SetOptFit(111);
	//	gStyle->SetStatFormat("1.3E");
	//	gStyle->SetFitFormat("1.3E");
	
	// fetch the list of trees contained in the waveforms file
	// for every tree generate a waveform graph

	TFile *f = TFile::Open(WaveformsFile);
	TList *listOfKeys = f->GetListOfKeys();
	Int_t numberOfKeys = listOfKeys->GetEntries();
	TList *listOfGraphs = new TList();
	
	// if the waveform file name begins with the string "comparator" it goes in this list
	TList *listOfCompWaves = new TList();
	// if the waveform file name begins with the string "sum output" it goes in this list
	TList *listOfAdderWaves = new TList();

	for(Int_t i = 0; i < numberOfKeys; i++) {
		TString *keyName = new TString(listOfKeys->At(i)->GetName());
		TTree *tree = (TTree*)f->Get(keyName->Data());
		Float_t x = 0;
		Float_t y = 0;
		tree->SetBranchAddress("x",&x);
		tree->SetBranchAddress("y",&y);
		Int_t nentries = tree->GetEntries();

		TString *gName = new TString(keyName->Data());
		gName->Append(" graph");
		TGraphErrors *gWave = new TGraphErrors(nentries);
		gWave->SetName(gName->Data());
		gWave->SetTitle(gName->Data());
		gWave->GetXaxis()->SetTitle("Time");
		gWave->GetYaxis()->SetTitle("Voltage");
	//	gWave->SetBit(TH1::kCanRebin);

		for (Int_t j = 0; j < nentries; j++) {
			tree->GetEntry(j);
			gWave->SetPoint(j,x,y);
		}

		listOfGraphs->Add(gWave);

		if(keyName->BeginsWith("comparator"))
			listOfCompWaves->Add(gWave);

		if(keyName->BeginsWith("sum output"))
			listOfAdderWaves->Add(gWave);

	/*	TString *cName = new TString(keyName->Data());
		cName->Append(" canvas");
		TCanvas *cy = new TCanvas(cName->Data(),cName->Data(),800,600);
		gWave->Draw("AL"); */
	}
	
	cout << listOfAdderWaves->GetEntries() << endl;

	// analysis for waves with no delay

	// global variables

	Double_t xMin,xMax,yStart,yEnd;
	Int_t graphPoints;
	Double_t step;

	// comparator outputs waves sum

	TGraphErrors *gFirstCompWave = (TGraphErrors *)listOfCompWaves->First();

	graphPoints = gFirstCompWave->GetN();
	gFirstCompWave->GetPoint(0,xMin,yStart);
	gFirstCompWave->GetPoint(graphPoints - 1,xMax,yEnd); 

	step = (xMax - xMin)/graphPoints;
	cout << gFirstCompWave->GetName() << endl;
	cout << "xMin = " << xMin << "  xMax = " << xMax << "  graphPoints = " << graphPoints << endl;

	TGraphErrors *gCompSum = new TGraphErrors(graphPoints);
	gCompSum->SetLineColor(kBlue);
	gCompSum->SetLineWidth(2);
	gCompSum->SetName("Comparator Outputs Sum");
	gCompSum->SetTitle("Comparator Outputs Sum");
	Int_t nCompWaves = listOfCompWaves->GetEntries();
	Float_t gx,gy = 0;
	
	// Alpha coefficiens are now written "hard coded" here
	Float_t alphaArray[3] = {0.199,0.201,0.197};
	
	// Deleays coming from the multiplexer are written "hard coded" here
	Float_t muxDelayArray[3] = {0,77.14E-12,192.01E-12};

	for(Int_t i = 0; i < graphPoints; i++) {
		for(Int_t j = 0; j < nCompWaves; j++) {
			TGraphErrors *gCompWave = (TGraphErrors *)listOfCompWaves->At(j);
			gy += (gCompWave->Eval(xMin + i*step + muxDelayArray[j]))*alphaArray[j];
		}
		gCompSum->SetPoint(i,xMin + i*step,gy);
		gy = 0;
	}
	
	// note that there is a manual correction on the x axis for the comparator waves sum to compare them better in the multigraph
	
	Double_t *xArray = gCompSum->GetX();
	for(Int_t i = 0; i < graphPoints; i++) {
		xArray[i] += 5.6E-9;
	}

//	TCanvas *cCompSum = new TCanvas("cCompSum","Comparator Outputs Sum",800,600);
//	gCompSum->Draw("AL");

	// adder outputs waves sum
	
	// THE ANALYSIS FOR THE ADDER OUTPUT WITH NOT DELAY AND 3 CHANNELS ADDED IS DEPRECATED.
	// THERE WAS A MISTAKE IN THE DATA TAKING
	// I'LL KEEP THE CODE HERE FOR FURTHER REFERENCE

/*
	TGraphErrors *gFirstAdderWave = (TGraphErrors *)listOfAdderWaves->First();

	graphPoints = gFirstAdderWave->GetN();
	gFirstAdderWave->GetPoint(0,xMin,yStart);
	gFirstAdderWave->GetPoint(graphPoints - 1,xMax,yEnd);

	step = (xMax - xMin)/graphPoints;
	cout << gFirstAdderWave->GetName() << endl;
	cout << "xMin : " << xMin << "  xMax : " << xMax << endl;

	TGraphErrors *gAdderSum = new TGraphErrors(graphPoints);
	gAdderSum->SetLineWidth(2);
//	gAdderSum->SetLineColor(kGreen);
	gAdderSum->SetLineStyle(9);
	gAdderSum->SetName("Sum of the adder outputs with no delay");
	gAdderSum->SetTitle("Sum of the adder outputs with no delay");
	Int_t nAdderWaves = listOfAdderWaves->GetEntries();
	gy = 0;

	for(Int_t i = 0; i < graphPoints; i++) {
		for(Int_t j = 0; j < nAdderWaves; j++) {
			TGraphErrors *gAdderWave = (TGraphErrors *)listOfAdderWaves->At(j);
			gy += gAdderWave->Eval(xMin + i*step);
		} 
		gAdderSum->SetPoint(i,xMin + i*step,gy);
		gy = 0;
	}

//	TCanvas *cAdderSum = new TCanvas("cAdderSum","Sum of the adder outputs",800,600);
//	gAdderSum->Draw("AL"); 
	
	TGraphErrors *g3ChannelsSumNoDelay = listOfGraphs->FindObject("sum_output_3_channels_(3) graph");
	g3ChannelsSumNoDelay->SetLineColor(kRed);
	g3ChannelsSumNoDelay->SetLineWidth(2);
	
	// note that there is a manual correction on the x axis for the adder output to compare it better in the multigraph
	
	Double_t *xArray = g3ChannelsSumNoDelay->GetX();
	graphPoints = g3ChannelsSumNoDelay->GetN();
	
	for(Int_t i = 0; i < graphPoints; i++) {
		xArray[i] -= 600E-12;
	}
	
	// comparison among the computed adder output ,the real one and the sum of the comparator outputs with alpha coefficients correction
	
	TMultiGraph *mgSumNoDelay = new TMultiGraph();
	mgSumNoDelay->Add(g3ChannelsSumNoDelay);
	mgSumNoDelay->Add(gAdderSum);
	mgSumNoDelay->Add(gCompSum);
	mgSumNoDelay->SetTitle("Collection of graphs for 3 channels sum with no delay");
	
	TCanvas *cmgSumNoDelay = new TCanvas("cmgSumNoDelay", "Collection of graphs for 3 channels sum with no delay", 1200,800);
	cmgSumNoDelay->Update();
	mgSumNoDelay->Draw("AL");
	
	legend = new TLegend(0.6,0.78,0.99,0.99);
	legend->AddEntry(g3ChannelsSumNoDelay, "Actual sum done by the adder", "lp");
	legend->AddEntry(gAdderSum, "Sum of the adder outputs", "lp");
	legend->AddEntry(gCompSum, "Sum of the comparator outputs","lp");
	legend->Draw();
	
	mgSumNoDelay->GetXaxis()->SetTitle("Seconds");
	mgSumNoDelay->GetYaxis()->SetTitle("Volts");
	TPaveText *title = (TPaveText*)cmgSumNoDelay->GetPrimitive("title");
	title->SetX1NDC(0.009);
	title->SetY1NDC(0.94);
	title->SetX2NDC(0.56);
	title->SetY2NDC(0.99);
	cmgSumNoDelay->Modified();
*/
	
	
	// analysis for delayed adder outputs
	
	Int_t nAdderWaves = listOfAdderWaves->GetEntries();

	TGraphErrors *g3ChannelsSumDelay = listOfGraphs->FindObject("sum_output_3_channels_(1-1-1) graph");
	g3ChannelsSumDelay->SetLineColor(kRed);
	g3ChannelsSumDelay->SetLineWidth(2);

	// Delay coming from cables are written "hard coded" here
	Float_t cablesDelayArray[3] = {0,1.45E-9,3.21E-9};
	
	graphPoints = g3ChannelsSumDelay->GetN();
	//g3ChannelsSumDelay->GetPoint(0,xMin,yStart);
	//g3ChannelsSumDelay->GetPoint(graphPoints - 1,xMax,yEnd);
	xMin = 6E-9;
	xMax = 16E-9;
	step = (xMax - xMin)/graphPoints;
	cout << "Sum of the adder outputs with delay" << endl;
	cout << "xMin : " << xMin << "  xMax : " << xMax << endl;

	TGraphErrors *gAdderSumDelay = new TGraphErrors(graphPoints);
	gAdderSumDelay->SetLineColor(kBlue);
	gAdderSumDelay->SetLineWidth(2);
	gAdderSumDelay->SetName("Sum of the adder outputs with delay");
	gAdderSumDelay->SetTitle("Sum of the adder outputs with delay");

	gy = 0;
	
	// note that there is a manual correction on the delay of 500E-12 to compare the adder output better in the multigraph

	for(Int_t i = 0; i < graphPoints; i++) {
		for(Int_t j = 0; j < nAdderWaves; j++) {
			TGraphErrors *gAdderWave = (TGraphErrors *)listOfAdderWaves->At(j);
			gy += gAdderWave->Eval(xMin + i*step + cablesDelayArray[j] - 500E-12);
		} 
		gAdderSumDelay->SetPoint(i,xMin + i*step,gy);
		gy = 0;
	}

	//	TCanvas *cSumSumDelay = new TCanvas("cSumSumDelay","Sum of the sum outputs with delay",800,600);
	//	gAdderSumDelay->Draw("APEL");

	TMultiGraph *mg3ChannelsSumDelay = new TMultiGraph();
	mg3ChannelsSumDelay->Add(gAdderSumDelay);
	mg3ChannelsSumDelay->Add(g3ChannelsSumDelay);
	mg3ChannelsSumDelay->SetTitle("Collection of graphs for 3 channels sum with delay");

	TCanvas *cmg3ChannelsSumDelay = new TCanvas("cmg3ChannelsSumDelay", "Collection of graphs for 3 channels sum with delay", 1200, 800);
	cmg3ChannelsSumDelay->Update();
	
	legend = new TLegend(0.6,0.78,0.99,0.99);
	legend->AddEntry(g3ChannelsSumDelay, "Actual sum done by the adder", "lp");
	legend->AddEntry(gAdderSumDelay, "Sum of the delayed adder outputs", "lp");
	mg3ChannelsSumDelay->Draw("AL");
	legend->Draw();
	
	mg3ChannelsSumDelay->GetXaxis()->SetTitle("Seconds");
	mg3ChannelsSumDelay->GetYaxis()->SetTitle("Volts");
	
	TPaveText *title = (TPaveText*)cmg3ChannelsSumDelay->GetPrimitive("title");
	title->SetX1NDC(0.009);
	title->SetY1NDC(0.94);
	title->SetX2NDC(0.56);
	title->SetY2NDC(0.99);
	
	cmg3ChannelsSumDelay->Modified();

/*
	// delay test just to try a different method

	TMultiGraph *mgDelayTest = new TMultiGraph();
	Double_t gxTest,gyTest;

	TGraphErrors *gDelayTest0 = new TGraphErrors(((TGraphErrors *)listOfAdderWaves->At(0))->GetN());
	for(Int_t j = 0; j < gDelayTest0->GetN(); j++) {
		((TGraphErrors *)listOfAdderWaves->At(0))->GetPoint(j,gxTest,gyTest);
		gDelayTest0->SetPoint(j,gxTest - cablesDelayArray[0],gyTest);
	}
	mgDelayTest->Add(gDelayTest0);

	TGraphErrors *gDelayTest1 = new TGraphErrors(((TGraphErrors *)listOfAdderWaves->At(1))->GetN());
	for(Int_t j = 0; j < gDelayTest1->GetN(); j++) {
		((TGraphErrors *)listOfAdderWaves->At(1))->GetPoint(j,gxTest,gyTest);
		gDelayTest1->SetPoint(j,gxTest - cablesDelayArray[1],gyTest);
	}
	mgDelayTest->Add(gDelayTest1);

	TGraphErrors *gDelayTest2 = new TGraphErrors(((TGraphErrors *)listOfAdderWaves->At(2))->GetN());
	for(Int_t j = 0; j < gDelayTest2->GetN(); j++) {
		((TGraphErrors *)listOfAdderWaves->At(2))->GetPoint(j,gxTest,gyTest);
		gDelayTest2->SetPoint(j,gxTest - cablesDelayArray[2],gyTest);
	}
	mgDelayTest->Add(gDelayTest2);

//	TCanvas *cmgDelayTest = new TCanvas("cmgDelayTest", "cmgDelayTest", 800,600);
//	mgDelayTest->Draw("APEL");

	graphPoints = 12000;
	xMin = 2E-9;
	xMax = 22E-9;
	step = (xMax - xMin)/graphPoints;
	cout << "xMin : " << xMin << "  xMax : " << xMax << endl;

	Double_t delayTest0xMin,delayTest0xMax,delayTest1xMin,delayTest1xMax,delayTest2xMin,delayTest2xMax;
	gDelayTest0->GetPoint(0,delayTest0xMin,gyTest);
	gDelayTest0->GetPoint(gDelayTest0->GetN() - 1,delayTest0xMax,gyTest);
	gDelayTest1->GetPoint(0,delayTest1xMin,gyTest);
	gDelayTest1->GetPoint(gDelayTest1->GetN() - 1,delayTest1xMax,gyTest);
	gDelayTest2->GetPoint(0,delayTest2xMin,gyTest);
	gDelayTest2->GetPoint(gDelayTest2->GetN() - 1,delayTest2xMax,gyTest);

	cout << delayTest0xMin << endl;

	TGraphErrors *gAdderSumDelayV2 = new TGraphErrors(graphPoints);
	for(Int_t i = 0; i < graphPoints; i++) {
		gyTest = gDelayTest0->Eval(xMin + i*step);
		gyTest += gDelayTest1->Eval(xMin + i*step);
		gyTest += gDelayTest2->Eval(xMin + i*step);
		gAdderSumDelayV2->SetPoint(i,xMin + i*step+ 500E-12,gyTest);
	} 
	
	gAdderSumDelayV2->SetLineColor(kGreen);
	gAdderSumDelayV2->SetLineWidth(2);
	mg3ChannelsSumDelay->Add(gAdderSumDelayV2);
	c3ChannelsSumDelay->Modified();

	TCanvas *cAdderSumDelayV2 = new TCanvas("cAdderSumDelayV2","cAdderSumDelayV2",800,600);
	gAdderSumDelayV2->Draw("APL");
*/

	// List of waves representing the adder output with 5,4,3,2,1 channels in input

	TGraphErrors *gAdder5Channels = listOfGraphs->FindObject("adder output 5 channels v2 graph");
	TGraphErrors *gAdder4Channels = listOfGraphs->FindObject("adder output 4 channels v2 graph");
	TGraphErrors *gAdder3Channels = listOfGraphs->FindObject("adder output 3 channels v2 graph");
	TGraphErrors *gAdder2Channels = listOfGraphs->FindObject("adder output 2 channels v2 graph");
	TGraphErrors *gAdder1Channel = listOfGraphs->FindObject("adder output 1 channel v2 graph");
	
	TGraphErrors *gAdderSingleCh0 = listOfGraphs->FindObject("single sum output ch 0 input 500 mV DT 100 mV graph");
	TGraphErrors *gAdderSingleCh1 = listOfGraphs->FindObject("single sum output ch 1 input 500 mV DT 100 mV graph");
	TGraphErrors *gAdderSingleCh4 = listOfGraphs->FindObject("single sum output ch 4 input 500 mV DT 100 mV graph");
	TGraphErrors *gAdderSingleCh5 = listOfGraphs->FindObject("single sum output ch 5 input 500 mV DT 100 mV graph");
	TGraphErrors *gAdderSingleCh7 = listOfGraphs->FindObject("single sum output ch 7 input 500 mV DT 100 mV graph");
	
	TMultiGraph *mgAdder54321Channels = new TMultiGraph();
	mgAdder54321Channels->SetTitle("Collection of graphs for different numbers of added channels");
	mgAdder54321Channels->Add(gAdder5Channels);
	mgAdder54321Channels->Add(gAdder4Channels);
	mgAdder54321Channels->Add(gAdder3Channels);
	mgAdder54321Channels->Add(gAdder2Channels);
	mgAdder54321Channels->Add(gAdder1Channel);
	
	TCanvas *cmgAdder54321Channels = new TCanvas("cmgAdder54321Channels", "Collection of graphs for different numbers of added channels",1200,800);
	mgAdder54321Channels->Draw("AL");
	cmgAdder54321Channels->Update();
	mgAdder54321Channels->GetXaxis()->SetTitle("seconds");
	mgAdder54321Channels->GetYaxis()->SetTitle("Volts");	
	cmgAdder54321Channels->Modified();
	
	// analysis of the linearity of the adder
	
	Double_t addedVMax[nAddedChannels];
	addedVMax[0] = TMath::MaxElement(gAdder1Channel->GetN(), gAdder1Channel->GetY());
	addedVMax[1] = TMath::MaxElement(gAdder2Channels->GetN(), gAdder2Channels->GetY());
	addedVMax[2] = TMath::MaxElement(gAdder3Channels->GetN(), gAdder3Channels->GetY());
	addedVMax[3] = TMath::MaxElement(gAdder4Channels->GetN(), gAdder4Channels->GetY());
	addedVMax[4] = TMath::MaxElement(gAdder5Channels->GetN(), gAdder5Channels->GetY());
	
	Double_t singleVMax[nAddedChannels];
	singleVMax[0] = TMath::MaxElement(gAdderSingleCh0->GetN(), gAdderSingleCh0->GetY());
	singleVMax[1] = TMath::MaxElement(gAdderSingleCh1->GetN(), gAdderSingleCh1->GetY());
	singleVMax[2] = TMath::MaxElement(gAdderSingleCh4->GetN(), gAdderSingleCh4->GetY());
	singleVMax[3] = TMath::MaxElement(gAdderSingleCh5->GetN(), gAdderSingleCh5->GetY());
	singleVMax[4] = TMath::MaxElement(gAdderSingleCh7->GetN(), gAdderSingleCh7->GetY());
	
	vector<double> expectedVMax(nAddedChannels);
	Double_t previousVmax = 0;
	for(Int_t i = 0; i < expectedVMax.size(); i++) {
		expectedVMax[i] = singleVMax[i] + previousVmax;
		previousVmax = expectedVMax[i];
		cout << "singleVMax[" <<i <<"] = " << singleVMax[i] <<  endl;
		cout << "addedVMax[" <<i <<"] = " << addedVMax[i] <<  endl;
		cout << "expectedVMax[" <<i <<"] = " << expectedVMax[i] <<  endl;
	}
	
	TGraph *gAdderLinearity = new TGraph(expectedVMax.size(),&expectedVMax[0],addedVMax);
	gAdderLinearity->SetTitle("Linearity of the adder");
	gAdderLinearity->GetXaxis()->SetTitle("Expected amplitude value (V)");
	gAdderLinearity->GetYaxis()->SetTitle("Actual amplitude value (V)");
	gAdderLinearity->GetYaxis()->SetTitleOffset(1.3);
	
	TCanvas *cgAdderLinearity = new TCanvas("cgAdderLinearity","Linearity of the adder",800,600);
	cgAdderLinearity->SetGrid();
	cgAdderLinearity->Update();
	gAdderLinearity->SetMarkerStyle(20);
	gAdderLinearity->SetMarkerSize(0.8);
	//gAdderLinearity->Fit("pol1","Q+","",expectedVMax[0],expectedVMax[2]);
	TF1 *line = new TF1("line","x",expectedVMax.back(),expectedVMax.front());
	gAdderLinearity->Draw("APEL");
	line->Draw("SAME");
	//gAdderLinearity->GetFunction("pol1")->SetRange(expectedVMax.back(),expectedVMax.front());;
	cgAdderLinearity->SetLeftMargin(0.13);
	cgAdderLinearity->Modified();
	
	f->Close();


}