void makePrettyTurnOn()
{
  const char *type = "hydjet_276_jets_gen";
  TFile *inFile = TFile::Open(Form("hist_%s.root",type));

  const Int_t THRESHOLDS = 4;
  //const Double_t L1_THRESHOLD[THRESHOLDS] = {2, 5, 12, 20};
  const Double_t L1_THRESHOLD[THRESHOLDS] = {16, 36, 52, 80};
  const Int_t COLORS[THRESHOLDS] = {kBlack, kRed, kBlue, kGreen+3};//, kMagenta+3};
  //const char* LABELS[2] = {"central", "periph"};
  TGraphAsymmErrors *asymm[THRESHOLDS];//[2];

  for(int i = 0; i < THRESHOLDS; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      asymm[i] = (TGraphAsymmErrors*)inFile->Get(Form("asymm_pt_%d_0",(int)L1_THRESHOLD[i]));
      asymm[i]->SetMarkerColor(COLORS[i]);
      asymm[i]->SetLineColor(COLORS[i]);
    }
    //asymm[i][1]->SetMarkerStyle(25);
  }

  const int nBins = 75;
  const double maxPt = 300;

  TH1D *hEmpty = new TH1D("hEmpty",Form(";Gen Jet p_{T} (GeV);Efficiency"),nBins,0,maxPt);

  TCanvas *c1 = new TCanvas();
  hEmpty->SetMinimum(0);
  hEmpty->SetMaximum(1.2);
  hEmpty->Draw();
  //c1->SetLogy();

  TLine *line = new TLine(0,1,maxPt,1);
  line->Draw();

  for(int i = 0; i < THRESHOLDS; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      asymm[i]->Draw("p");
    }
  }

  TLegend *leg = new TLegend(0.55,0.2,0.9,0.5);
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSizePixels(18);

  for(int i = 0; i < THRESHOLDS; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      leg->AddEntry(asymm[i], Form("L1_SingleJet%d", (int)L1_THRESHOLD[i]), "lp");
    }
  }

  leg->Draw();

  c1->SaveAs(Form("%s_turnon.pdf",type));

}
Exemple #2
0
void ptPlots(){
    TFile *file1 = new TFile("20170527_Kstar0bar_recon_masswidth_pf100_wide_scaled.root");
    TH1D* single1 = file1->Get("ptbin21particle5");
    single1->SetLineColor(1);
    single1->SetMarkerStyle(21);
    single1->SetMarkerSize(0.3);
    single1->SetLineWidth(3);
    TH1D* othersingle1 = file1->Get("ptbin05particle5");
    othersingle1->SetLineColor(1);
    othersingle1->SetMarkerStyle(21);
    othersingle1->SetMarkerSize(0.3);
    othersingle1->SetLineWidth(3);
    TF1* fit1 = single1->GetFunction("fitPTbin2100particle5");
    TF1* otherfit1 = othersingle1->GetFunction("fitPTbin500particle5");
    fit1->SetBit(TF1::kNotDraw);
    fit1->SetLineColor(kGray+3);
    fit1->SetLineWidth(4);
    otherfit1->SetBit(TF1::kNotDraw);
    otherfit1->SetLineColor(kGray+3);
    otherfit1->SetLineWidth(4);

    TFile *file2 = new TFile("20170527_Kstar0bar_recon_masswidth_pf100_wide_scaled_error05.root");
    TH1D* single2 = file2->Get("ptbin21particle5");
    single2->SetLineColor(17);
    single2->SetFillColor(17);
    single2->SetLineWidth(3);
    TH1D* othersingle2 = file2->Get("ptbin05particle5");
    othersingle2->SetLineColor(17);
    othersingle2->SetFillColor(17);
    othersingle2->SetLineWidth(3);
    TF1* fit2 = single2->GetFunction("fitPTbin2100particle5");
    TF1* otherfit2 = othersingle2->GetFunction("fitPTbin500particle5");
    fit2->SetLineColor(kGreen-2);
    fit2->SetLineStyle(5);
    fit2->SetLineWidth(6);
    otherfit2->SetLineColor(kGreen-2);
    otherfit2->SetLineWidth(6);
    otherfit2->SetLineStyle(5);

    TFile *file3 = new TFile("20170527_Kstar0bar_recon_simplewidth_pf100_wide_scaled_error05.root");
    TF1* fit3 = file3->Get("fitPTbin2100particle5");
    fit3->SetLineColor(4);
    fit3->SetLineStyle(7);
    fit3->SetLineWidth(6);
    TF1* otherfit3 = file3->Get("fitPTbin500particle5");
    otherfit3->SetLineColor(4);
    otherfit3->SetLineStyle(7);
    otherfit3->SetLineWidth(6);

    TFile *file5 = new TFile("20170527_Kstar0bar_recon_fixedwidth_pf100_wide_scaled_error05.root");
    TF1* fit5 = file5->Get("fitPTbin2100particle5");
    fit5->SetLineColor(2);
    fit5->SetLineStyle(3);
    fit5->SetLineWidth(6);
    TF1* otherfit5 = file5->Get("fitPTbin500particle5");
    otherfit5->SetLineColor(2);
    otherfit5->SetLineStyle(3);
    otherfit5->SetLineWidth(6);

    //KStar0 AT DECAY //
    TFile *decayfile1 = new TFile("20170527_Kstar0bar_masswidth_pf160_scaled.root");
    TH1D* decaysingle1 = decayfile1->Get("ptbin21particle5");
    decaysingle1->SetLineColor(1);
    decaysingle1->SetMarkerStyle(21);
    decaysingle1->SetMarkerSize(0.3);
    decaysingle1->SetLineWidth(3);
    TH1D* otherdecaysingle1 = decayfile1->Get("ptbin05particle5");
    otherdecaysingle1->SetLineColor(1);
    otherdecaysingle1->SetMarkerStyle(21);
    otherdecaysingle1->SetMarkerSize(0.3);
    otherdecaysingle1->SetLineWidth(3);
    TF1* decayfit1 = decaysingle1->GetFunction("fitPTbin2100particle5");
    TF1* otherdecayfit1 = otherdecaysingle1->GetFunction("fitPTbin500particle5");
    decayfit1->SetBit(TF1::kNotDraw);
    decayfit1->SetLineColor(kGray+3);
    decayfit1->SetLineWidth(4);
    otherdecayfit1->SetBit(TF1::kNotDraw);
    otherdecayfit1->SetLineColor(kGray+3);
    otherdecayfit1->SetLineWidth(4);

    TFile *decayfile2 = new TFile("20170527_Kstar0bar_masswidth_pf160_scaled_error05.root");
    TH1D* decaysingle2 = decayfile2->Get("ptbin21particle5");
    decaysingle2->SetLineColor(17);
    decaysingle2->SetFillColor(17);
    decaysingle2->SetLineWidth(3);
    TH1D* otherdecaysingle2 = decayfile2->Get("ptbin05particle5");
    otherdecaysingle2->SetLineColor(17);
    otherdecaysingle2->SetFillColor(17);
    otherdecaysingle2->SetLineWidth(3);
    TF1* decayfit2 = decaysingle2->GetFunction("fitPTbin2100particle5");
    TF1* otherdecayfit2 = otherdecaysingle2->GetFunction("fitPTbin500particle5");
    decayfit2->SetLineColor(kGreen-2);
    decayfit2->SetLineStyle(5);
    decayfit2->SetLineWidth(6);
    otherdecayfit2->SetLineColor(kGreen-2);
    otherdecayfit2->SetLineWidth(4);
    otherdecayfit2->SetLineStyle(6);

    TFile *decayfile3 = new TFile("20170527_Kstar0bar_simplewidth_pf160_scaled_error05.root");
    TF1* decayfit3 = decayfile3->Get("fitPTbin2100particle5");
    decayfit3->SetLineColor(4);
    decayfit3->SetLineStyle(7);
    decayfit3->SetLineWidth(6);
    TF1* otherdecayfit3 = decayfile3->Get("fitPTbin500particle5");
    otherdecayfit3->SetLineColor(4);
    otherdecayfit3->SetLineStyle(7);
    otherdecayfit3->SetLineWidth(6);

    TFile *decayfile5 = new TFile("20170527_Kstar0bar_fixedwidth_pf160_scaled_error05.root");
    TF1* decayfit5 = decayfile5->Get("fitPTbin2100particle5");
    decayfit5->SetLineColor(2);
    decayfit5->SetLineStyle(3);
    decayfit5->SetLineWidth(6);
    TF1* otherdecayfit5 = decayfile5->Get("fitPTbin500particle5");
    otherdecayfit5->SetLineColor(2);
    otherdecayfit5->SetLineStyle(3);
    otherdecayfit5->SetLineWidth(6);


    //Do plots for decay and recon side by side, for high PT////////////////////////////////////////////////
    TExec *exec1 = new TExec("exec1", "gStyle->SetErrorX(0)");
    TExec *exec2 = new TExec("exec2", "gStyle->SetErrorX(0.5)");

    TCanvas *cSingle = new TCanvas("single", "single", 70, 70, 1000, 600);
    cSingle->SetMargin(0.0, 0.0, 0.0, 0.0);
    cSingle->Divide(2,1,0.0);
    cSingle->cd(2)->SetMargin(0.0, 0.1867, 0.1326, 0.0977);
    cSingle->cd(2)->SetTicks(0,1);

    single1->SetStats(kFALSE);
    single1->SetTitle("");
    single1->GetYaxis()->SetTitleOffset(1.50);
    single1->GetYaxis()->SetLabelSize(0.05);
    single1->GetYaxis()->SetTitleSize(0.06);
    single1->GetYaxis()->SetTitleFont(42);
    single1->GetYaxis()->SetLabelFont(42);
    single1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
    single1->GetXaxis()->SetRangeUser(0.61, 1.09);
    single1->GetXaxis()->SetLabelSize(0.05);
    single1->GetXaxis()->SetTitleSize(0.06);
    single1->GetXaxis()->SetLabelFont(42);
    single1->GetXaxis()->SetTitleFont(42);
    single1->GetXaxis()->SetTitle("K^{-}#pi^{+} invariant mass (GeV/c^{2})");
    single1->Draw("E Y+");
    single2->SetStats(kFALSE);
    single2->GetXaxis()->SetRangeUser(0.61, 1.09);
    single2->Draw("SAME E2");
    fit1->Draw("SAME");
    fit2->Draw("SAME");
    fit3->Draw("SAME");
    fit5->Draw("SAME");
    exec1->Draw();
    single1->Draw("E SAME");
    exec2->Draw();
    //fit7->Draw("SAME");

    TPaveText *text = new TPaveText(0.3715, 0.7592, 0.6586, 0.8901, "NDC");
    text->AddText("Reconstructed #bar{K}*^{0}");
    text->AddText("2.0 < p_{T} < 2.2 GeV/c");
    text->SetBorderSize(0);
    text->SetFillStyle(0);
    text->GetLine(1)->SetTextSizePixels(28);
    text->GetLine(0)->SetTextSizePixels(32);
  
    text->Draw();

    //Do DECAY part
    cSingle->cd(1)->SetMargin(0.1727, 0.0, 0.1326, 0.0977);
    cSingle->cd(1)->SetTicks(0,1);
    TLegend *singleLegend = new TLegend(0.2048, 0.4223, 0.5884, 0.7400);
    singleLegend->AddEntry(fit1, "Mass Dep. Width", "l");
    singleLegend->AddEntry(fit2, "#splitline{Mass Dep. Width}{+5% Error}", "l");
    singleLegend->AddEntry(fit3, "#splitline{Simple Width}{+5% Error}", "l");
    singleLegend->AddEntry(fit5, "#splitline{Fixed #Gamma = 50 MeV/c^{2}}{+5% Error}", "l");
    singleLegend->SetTextSizePixels(20);

    TLegend *singleLegend2 = new TLegend(0.2430, 0.3351, 0.4940, 0.3892);
    singleLegend2->AddEntry(single2, "#splitline{Added Error}{(5% of peak bin)}", "f");
    singleLegend2->SetFillStyle(0);
    singleLegend2->SetBorderSize(0);
    singleLegend2->SetTextSizePixels(20); 

    decaysingle1->SetStats(kFALSE);
    decaysingle1->SetTitle("");
    decaysingle1->GetYaxis()->SetTitleOffset(1.50);
    decaysingle1->GetYaxis()->SetLabelSize(0.05);
    decaysingle1->GetYaxis()->SetTitleSize(0.06);
    decaysingle1->GetYaxis()->SetTitleFont(42);
    decaysingle1->GetYaxis()->SetLabelFont(42);
    decaysingle1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
    decaysingle1->GetXaxis()->SetRangeUser(0.61, 1.09);
    decaysingle1->GetXaxis()->SetLabelSize(0.05);
    decaysingle1->GetXaxis()->SetTitleSize(0.06);
    decaysingle1->GetXaxis()->SetTitleFont(42);
    decaysingle1->GetXaxis()->SetLabelFont(42);
    decaysingle1->GetXaxis()->SetTitle("K^{-}#pi^{+} invariant mass (GeV/c^{2})");
    decaysingle1->Draw("E");
    decaysingle2->SetStats(kFALSE);
    decaysingle2->GetXaxis()->SetRangeUser(0.61, 1.09);
    decaysingle2->Draw("SAME E2");
    decayfit1->Draw("SAME");
    decayfit2->Draw("SAME");
    decayfit3->Draw("SAME");
    decayfit5->Draw("SAME");
    exec1->Draw();
    decaysingle1->Draw("E SAME");
    exec2->Draw();
    //fit7->Draw("SAME");

    TPaveText *text = new TPaveText(0.5964, 0.7539, 0.8835, 0.8848, "NDC");
    text->AddText("#bar{K}*^{0} at Decay Point");
    text->AddText("2.0 < p_{T} < 2.2 GeV/c");
    text->SetBorderSize(0);
    text->SetFillStyle(0);
    text->GetLine(1)->SetTextSizePixels(28);
    text->GetLine(0)->SetTextSizePixels(32);
  
    singleLegend->Draw();
    singleLegend2->Draw();
    text->Draw();


    //DO LOW MOMENTUM/////////////////////////////////////////////////////////////

    TCanvas *cotherSingle = new TCanvas("othersingle", "othersingle", 70, 70, 1000, 600);
    cotherSingle->SetMargin(0.0, 0.0, 0.0, 0.0);
    cotherSingle->Divide(2,1,0.0);
    cotherSingle->cd(2)->SetMargin(0.0, 0.1867, 0.1326, 0.0977);
    cotherSingle->cd(2)->SetTicks(0,1);

    othersingle1->SetStats(kFALSE);
    othersingle1->SetTitle("");
    othersingle1->GetYaxis()->SetTitleOffset(1.50);
    othersingle1->GetYaxis()->SetLabelSize(0.05);
    othersingle1->GetYaxis()->SetTitleSize(0.06);
    othersingle1->GetYaxis()->SetTitleFont(42);
    othersingle1->GetYaxis()->SetLabelFont(42);
    othersingle1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
    othersingle1->GetXaxis()->SetRangeUser(0.61, 1.09);
    othersingle1->GetXaxis()->SetLabelSize(0.05);
    othersingle1->GetXaxis()->SetTitleSize(0.06);
    othersingle1->GetXaxis()->SetLabelFont(42);
    othersingle1->GetXaxis()->SetTitleFont(42);
    othersingle1->GetXaxis()->SetTitle("K^{-}#pi^{+} invariant mass (GeV/c^{2})");
    othersingle1->Draw("E Y+");
    othersingle2->SetStats(kFALSE);
    othersingle2->GetXaxis()->SetRangeUser(0.61, 1.09);
    othersingle2->Draw("SAME E2");
    otherfit1->Draw("SAME");
    otherfit2->Draw("SAME");
    otherfit3->Draw("SAME");
    otherfit5->Draw("SAME");
    exec1->Draw();
    othersingle1->Draw("E SAME");
    exec2->Draw();
    //fit7->Draw("SAME");

    TPaveText *othertext = new TPaveText(0.3715, 0.7592, 0.6586, 0.8901, "NDC");
    othertext->AddText("Reconstructed #bar{K}*^{0}");
    othertext->AddText("0.4 < p_{T} < 0.6 GeV/c");
    othertext->SetBorderSize(0);
    othertext->SetFillStyle(0);
    othertext->GetLine(1)->SetTextSizePixels(28);
    othertext->GetLine(0)->SetTextSizePixels(32);
  
    othertext->Draw();

    //Do DECAY part
    cotherSingle->cd(1)->SetMargin(0.1727, 0.0, 0.1326, 0.0977);
    cotherSingle->cd(1)->SetTicks(0,1);
    TLegend *othersingleLegend = new TLegend(0.2048, 0.4223, 0.5884, 0.7400);
    othersingleLegend->AddEntry(fit1, "Mass Dep. Width", "l");
    othersingleLegend->AddEntry(fit2, "#splitline{Mass Dep. Width}{+5% Error}", "l");
    othersingleLegend->AddEntry(fit3, "#splitline{Simple Width}{+5% Error}", "l");
    othersingleLegend->AddEntry(fit5, "#splitline{Fixed #Gamma = 50 MeV/c^{2}}{+5% Error}", "l");
    othersingleLegend->SetTextSizePixels(20);

    TLegend *othersingleLegend2 = new TLegend(0.2430, 0.3351, 0.4940, 0.3892);
    othersingleLegend2->AddEntry(othersingle2, "#splitline{Added Error}{(5% of peak bin)}", "f");
    othersingleLegend2->SetFillStyle(0);
    othersingleLegend2->SetBorderSize(0);
    othersingleLegend2->SetTextSizePixels(20); 

    otherdecaysingle1->SetStats(kFALSE);
    otherdecaysingle1->SetTitle("");
    otherdecaysingle1->GetYaxis()->SetTitleOffset(1.50);
    otherdecaysingle1->GetYaxis()->SetLabelSize(0.05);
    otherdecaysingle1->GetYaxis()->SetTitleSize(0.06);
    otherdecaysingle1->GetYaxis()->SetTitleFont(42);
    otherdecaysingle1->GetYaxis()->SetLabelFont(42);
    otherdecaysingle1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
    otherdecaysingle1->GetXaxis()->SetRangeUser(0.61, 1.09);
    otherdecaysingle1->GetXaxis()->SetLabelSize(0.05);
    otherdecaysingle1->GetXaxis()->SetTitleSize(0.06);
    otherdecaysingle1->GetXaxis()->SetTitleFont(42);
    otherdecaysingle1->GetXaxis()->SetLabelFont(42);
    otherdecaysingle1->GetXaxis()->SetTitle("K^{-}#pi^{+} invariant mass (GeV/c^{2})");
    otherdecaysingle1->Draw("E");
    otherdecaysingle2->SetStats(kFALSE);
    otherdecaysingle2->GetXaxis()->SetRangeUser(0.61, 1.09);
    otherdecaysingle2->Draw("SAME E2");
    otherdecayfit1->Draw("SAME");
    otherdecayfit2->Draw("SAME");
    otherdecayfit3->Draw("SAME");
    otherdecayfit5->Draw("SAME");
    exec1->Draw();
    otherdecaysingle1->Draw("E SAME");
    exec2->Draw();
    //fit7->Draw("SAME");

    TPaveText *othertext = new TPaveText(0.5964, 0.7539, 0.8835, 0.8848, "NDC");
    othertext->AddText("#bar{K}*^{0} at Decay Point");
    othertext->AddText("0.4 < p_{T} < 0.6 GeV/c");
    othertext->SetBorderSize(0);
    othertext->SetFillStyle(0);
    othertext->GetLine(1)->SetTextSizePixels(24);
    othertext->GetLine(0)->SetTextSizePixels(28);
  
    othersingleLegend->Draw();
    othersingleLegend2->Draw();
    othertext->Draw();

}
Exemple #3
0
void alicePlots(){
    
    TFile* alice = new TFile("~/Downloads/HEPData-ins1288320-v1-root.root");
    alice->cd("Table 16");
    TGraph* aliceData = Graph1D_y1;
    TH1F* hist = Hist1D_y1;
    TH1F* stat = Hist1D_y1_e1;
    TH1F* syst = Hist1D_y1_e2;
    TGraphAsymmErrors* graph2 = (TGraphAsymmErrors*)aliceData->Clone("graph2");

    Int_t numPts = aliceData->GetN();
    Double_t x, y;
    for(int i = 0; i<numPts; i++){
        aliceData->GetPoint(i, x, y);
        aliceData->SetPoint(i, x, (y - 0.89581));
        graph2->SetPoint(i, x, (y- 0.89581));
        hist->SetBinContent(i+1, hist->GetBinContent(i+1) - 0.89581);
        hist->SetBinError(i+1, stat->GetBinContent(i+1));
        graph2->SetPointEXhigh(i, 0.1);
        graph2->SetPointEXlow(i, 0.1);
    }

    graph2->SetLineColor(kBlue-10);
    graph2->SetLineWidth(2);
    graph2->SetMarkerColor(kBlue-10);
    graph2->SetFillColor(kBlue-10);
    hist->SetLineColor(kBlue-2);
    hist->SetLineWidth(2);

    aliceData->SetTitle("");
    aliceData->GetYaxis()->SetTitle("Mass - Vacuum Mass (GeV/c^{2})");
    aliceData->GetYaxis()->SetTitleSize(0.06);
    aliceData->GetYaxis()->SetLabelSize(0.04);
    aliceData->GetYaxis()->SetTitleOffset(1.65);
    aliceData->GetYaxis()->SetTitleFont(42);
    aliceData->GetYaxis()->SetLabelFont(42);
    aliceData->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    aliceData->GetXaxis()->SetTitleSize(0.06);
    aliceData->GetXaxis()->SetLabelSize(0.05);
    aliceData->GetXaxis()->SetTitleFont(42);
    aliceData->GetXaxis()->SetLabelFont(42);
    aliceData->SetMarkerStyle(29);
    aliceData->SetMarkerSize(2.5);
    aliceData->SetMarkerColor(kBlue-2);
    aliceData->SetLineColor(kBlue-2);

    aliceData->GetYaxis()->SetRangeUser(-0.02, 0.015);
    aliceData->GetXaxis()->SetRangeUser(0, 5);

    TFile* phsd = new TFile("~/utaustin/resonancefits/finalplotting/20170721_KKbarAdded2_fixedwidth42_recon_pf100_scaled_error05.root");
    TH1D* mass = phsd->Get("kstar0mass");
    mass->SetName("mass");
    mass->SetMarkerStyle(26);
    mass->SetMarkerSize(2.5);
    mass->SetMarkerColor(2);
    mass->SetLineColor(2);

    TF1* line = new TF1("line", "[0]", 0.0, 5.0);
    line->SetParameter(0, 0.0);
    line->SetLineColor(1);
    line->SetLineStyle(7);
    line->SetLineWidth(3);

    for(int j = 0; j<mass->GetNbinsX(); j++){
        mass->SetBinContent(j+1, (mass->GetBinContent(j+1) - 0.892));
    }


    TFile* phsd2 = new TFile("~/utaustin/resonancefits/finalplotting/20170616_KKbarAdded2_fixedwidth_recon_pf100_scaled_error05.root");
    TH1D* mass2 = phsd2->Get("kstar0mass");
    mass2->SetName("mass2");
    mass2->SetMarkerStyle(22);
    mass2->SetMarkerSize(2.5);
    mass2->SetMarkerColor(2);
    mass2->SetLineColor(2);
    for(int j = 0; j<mass2->GetNbinsX(); j++){
        mass2->SetBinContent(j+1, (mass2->GetBinContent(j+1) - 0.892));
    }



    TExec *exec1 = new TExec("exec1", "gStyle->SetErrorX(0.1)");
    TExec *exec2 = new TExec("exec2", "gStyle->SetErrorX(0.5)");
    
    TCanvas *c = new TCanvas ("c", "c", 50, 50, 650, 600);
    c->cd()->SetMargin(0.1997, 0.0369, 0.1396, 0.0681);
    aliceData->Draw("APX");
    //exec1->Draw();
    graph2->Draw("SAME P2");
    //exec2->Draw();
    hist->Draw("SAME E1");
    line->Draw("SAME");
    mass2->Draw("SAME P E1");
    mass->Draw("SAME P E1");
    aliceData->Draw("SAME PX");
    

    TLegend* legend = new TLegend(0.5836, 0.1815, 0.9489, 0.3438);
    legend->SetMargin(0.2);
    legend->SetTextSizePixels(20);
    legend->AddEntry(aliceData, "ALICE data, 0-20%", "p");
    legend->AddEntry(mass2, "Fit IV to PHSD: w in-med", "p");
    legend->AddEntry(mass, "Fit IV to PHSD: w/o in-med", "p");
    legend->Draw("SAME"); 
  
    TPaveText* text = new TPaveText(0.2554, 0.7243, 0.6006, 0.9162, "NDC");
    text->AddText("(K*^{0} + #bar{K}*^{0})");
    text->AddText("Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
    text->GetLine(0)->SetTextSizePixels(36);
    text->GetLine(1)->SetTextSizePixels(24);
    text->SetTextFont(42);
    text->SetBorderSize(0);
    text->SetFillStyle(0);
    text->Draw();
}
void makePrettyTurnOn_tracks()
{
  TFile *inFile = TFile::Open("hist_out_tracks.root");
  TGraphAsymmErrors *asymm_pt_0_cen = (TGraphAsymmErrors*)inFile->Get("asymm_pt_0_cen");
  TGraphAsymmErrors *asymm_pt_15_cen = (TGraphAsymmErrors*)inFile->Get("asymm_pt_15_cen");
  TGraphAsymmErrors *asymm_pt_30_cen = (TGraphAsymmErrors*)inFile->Get("asymm_pt_30_cen");
  TGraphAsymmErrors *asymm_pt_60_cen = (TGraphAsymmErrors*)inFile->Get("asymm_pt_60_cen");
  TGraphAsymmErrors *asymm_pt_0_periph = (TGraphAsymmErrors*)inFile->Get("asymm_pt_0_periph");
  TGraphAsymmErrors *asymm_pt_15_periph = (TGraphAsymmErrors*)inFile->Get("asymm_pt_15_periph");
  TGraphAsymmErrors *asymm_pt_30_periph = (TGraphAsymmErrors*)inFile->Get("asymm_pt_30_periph");
  TGraphAsymmErrors *asymm_pt_60_periph = (TGraphAsymmErrors*)inFile->Get("asymm_pt_60_periph");


  asymm_pt_0_cen->SetMarkerColor(1);
  asymm_pt_0_cen->SetLineColor(1);
  asymm_pt_15_cen->SetMarkerColor(kBlue);
  asymm_pt_15_cen->SetLineColor(kBlue);
  asymm_pt_30_cen->SetMarkerColor(kRed);
  asymm_pt_30_cen->SetLineColor(kRed);
  asymm_pt_60_cen->SetMarkerColor(kOrange);
  asymm_pt_60_cen->SetLineColor(kOrange);

  asymm_pt_0_periph->SetMarkerColor(1);
  asymm_pt_0_periph->SetLineColor(1);
  asymm_pt_15_periph->SetMarkerColor(kBlue);
  asymm_pt_15_periph->SetLineColor(kBlue);
  asymm_pt_30_periph->SetMarkerColor(kRed);
  asymm_pt_30_periph->SetLineColor(kRed);
  asymm_pt_60_periph->SetMarkerColor(kOrange);
  asymm_pt_60_periph->SetLineColor(kOrange);

  asymm_pt_0_periph->SetMarkerStyle(24);
  asymm_pt_15_periph->SetMarkerStyle(24);
  asymm_pt_30_periph->SetMarkerStyle(24);
  asymm_pt_60_periph->SetMarkerStyle(24);


  const int nBins = 100;
  const double maxPt = 120;

  TH1D *hEmpty = new TH1D("hEmpty",";Offline max track p_{T} (GeV);Efficiency",nBins,10,maxPt);

  TCanvas *c1 = new TCanvas();
  hEmpty->SetMinimum(0);
  hEmpty->SetMaximum(1.2);
  hEmpty->Draw();
  //c1->SetLogy();

  asymm_pt_0_cen->Draw("p");
  asymm_pt_15_cen->Draw("p");
  asymm_pt_30_cen->Draw("p");
  asymm_pt_60_cen->Draw("p");
  asymm_pt_0_periph->Draw("p");
  asymm_pt_15_periph->Draw("p");
  asymm_pt_30_periph->Draw("p");
  asymm_pt_60_periph->Draw("p");

  TLegend *leg = new TLegend(0.6,0.2,0.9,0.5,"L1 Threshold (GeV)");
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSizePixels(20);

  leg->AddEntry(asymm_pt_0_cen,"0 cen","lp");
  leg->AddEntry(asymm_pt_15_cen,"15 cen","lp");
  leg->AddEntry(asymm_pt_30_cen,"30 cen","lp");
  leg->AddEntry(asymm_pt_60_cen,"60 cen","lp");

  leg->AddEntry(asymm_pt_0_periph,"0 periph","lp");
  leg->AddEntry(asymm_pt_15_periph,"15 periph","lp");
  leg->AddEntry(asymm_pt_30_periph,"30 periph","lp");
  leg->AddEntry(asymm_pt_60_periph,"60 periph","lp");

  leg->Draw();

  c1->SaveAs("minbiasHI_trkturnon_hisub.pdf");

}
void plotCentrality(TString l1_input, bool isdata=false)
{

	TFile *lFile = TFile::Open(Form("%s_CentralityCalibration.root",l1_input.Data()));
	TH2D *hcorrOfflineEtsumVsL1Etsum = (TH2D*)lFile->Get("hcorrOfflineEtsumVsL1Etsum");
	TH1D *hl1Etsum = (TH1D*)lFile->Get("hl1Etsum");
	TProfile *profileofflineCentralityVsl1Etsum = (TProfile*)lFile->Get("profileofflineCentralityVsl1Etsum");
	TProfile *profilel1EtsumVsofflineCentrality = (TProfile*)lFile->Get("profilel1EtsumVsofflineCentrality");
	TProfile *profilel1CentralityVsofflineCentrality = (TProfile*)lFile->Get("profilel1CentralityVsofflineCentrality");
	TH2D *hcorrL1CentralityVsfflineCentrality= (TH2D*)lFile->Get("hcorrL1CentralityVsfflineCentrality");
	TF1* fprofileofflinel1EtsumVsCentrality_Calibration=(TF1*)lFile->Get("fprofileofflinel1EtsumVsCentrality_Calibration");
	fprofileofflinel1EtsumVsCentrality_Calibration->SetName("fprofileofflinel1EtsumVsCentrality_Calibration");
	TH1D *hofflineCentrality= (TH1D*)lFile->Get("hofflineCentrality");

	TH1D *hcorrl1EtsumPlusVscorrl1EtsumMinus= (TH1D*)lFile->Get("hcorrl1EtsumPlusVscorrl1EtsumMinus");
	TH1D *hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel= (TH1D*)lFile->Get("hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel");

	TH1D *hOffline[NBINSCentrality];

	for(int i = 0; i < NBINSCentrality; ++i){
		hOffline[i]=(TH1D*)lFile->Get(Form("hOffline_Bin%d",i)); 
	}  

	TF1 *f1 = new TF1("f1","pol9",0,6500);
	TF1 *f2 = new TF1("f2","pol9",0,200.);
	TF1 *f3 = new TF1("f3","pol1",0,200.);
	f3->SetLineColor(2);
	f1->SetLineColor(1);
	f2->SetLineColor(1);


	TCanvas *canvascorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel=new TCanvas("canvascorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel","canvas",600,600);
	canvascorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->cd();
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->SetMinimum(0.);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetYaxis()->SetTitleOffset(1.3);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetYaxis()->SetLabelSize(0.03);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetXaxis()->SetTitle("L1 ETsum Plus");
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetYaxis()->SetTitle("L1 ETsum Minus");
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetXaxis()->SetTitleOffset(1.1);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetYaxis()->SetTitleOffset(1.1);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetXaxis()->SetTitleSize(0.04);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetYaxis()->SetTitleSize(0.04);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetXaxis()->SetRangeUser(0,2500.);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->GetYaxis()->SetRangeUser(0,2500.);
	hcorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->Draw();

	TCanvas *canvascorrl1EtsumPlusVscorrl1EtsumMinus=new TCanvas("canvascorrl1EtsumPlusVscorrl1EtsumMinus","canvas",600,600);
	canvascorrl1EtsumPlusVscorrl1EtsumMinus->cd();
	hcorrl1EtsumPlusVscorrl1EtsumMinus->SetMinimum(0.);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetYaxis()->SetTitleOffset(1.3);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetYaxis()->SetLabelSize(0.03);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetXaxis()->SetTitle("L1 ETsum Plus");
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetYaxis()->SetTitle("L1 ETsum Minus");
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetXaxis()->SetTitleOffset(1.1);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetYaxis()->SetTitleOffset(1.1);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetXaxis()->SetTitleSize(0.04);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetYaxis()->SetTitleSize(0.04);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetXaxis()->SetRangeUser(0,2500.);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->GetYaxis()->SetRangeUser(0,2500.);
	hcorrl1EtsumPlusVscorrl1EtsumMinus->Draw();

	hcorrl1EtsumPlusVscorrl1EtsumMinus->Draw();

	TCanvas *canvasOfflineCentrality=new TCanvas("canvasOfflineCentrality","canvas",1200,800);
	canvasOfflineCentrality->cd();
	hofflineCentrality->SetMinimum(0.);
	hofflineCentrality->GetYaxis()->SetTitleOffset(1.3);
	hofflineCentrality->GetYaxis()->SetLabelSize(0.03);
	hofflineCentrality->GetXaxis()->SetTitle("Offline Centrality");
	hofflineCentrality->GetYaxis()->SetTitle("Entries");
	hofflineCentrality->GetXaxis()->SetTitleOffset(1.1);
	hofflineCentrality->GetYaxis()->SetTitleOffset(1.1);
	hofflineCentrality->GetXaxis()->SetTitleSize(0.04);
	hofflineCentrality->GetYaxis()->SetTitleSize(0.04);
	hofflineCentrality->Draw();

	TCanvas *canvasOfflineEtsumVsL1Etsum=new TCanvas("canvasOfflineEtsumVsL1Etsum","canvas",1200,800);
	canvasOfflineEtsumVsL1Etsum->cd();
	hcorrOfflineEtsumVsL1Etsum->SetMinimum(0.);
	hcorrOfflineEtsumVsL1Etsum->GetYaxis()->SetTitleOffset(1.3);
	hcorrOfflineEtsumVsL1Etsum->GetYaxis()->SetLabelSize(0.03);
	hcorrOfflineEtsumVsL1Etsum->GetXaxis()->SetTitle("Offline HF E_{T} sum");
	hcorrOfflineEtsumVsL1Etsum->GetYaxis()->SetTitle("Emulator HF E_{T} sum");
	hcorrOfflineEtsumVsL1Etsum->GetXaxis()->SetTitleOffset(1.1);
	hcorrOfflineEtsumVsL1Etsum->GetYaxis()->SetTitleOffset(1.1);
	hcorrOfflineEtsumVsL1Etsum->GetXaxis()->SetTitleSize(0.04);
	hcorrOfflineEtsumVsL1Etsum->GetYaxis()->SetTitleSize(0.04);
	hcorrOfflineEtsumVsL1Etsum->Draw();


	TCanvas *canvasL1Etsum=new TCanvas("canvasL1Etsum","canvas",600,500);
	canvasL1Etsum->cd();
	hl1Etsum->SetMinimum(0.);
	hl1Etsum->GetYaxis()->SetTitleOffset(1.3);
	hl1Etsum->GetYaxis()->SetLabelSize(0.03);
	hl1Etsum->GetYaxis()->SetTitle("Entries");
	hl1Etsum->GetXaxis()->SetTitle("L1 E_{T} sum");
	hl1Etsum->GetXaxis()->SetTitleOffset(1.1);
	hl1Etsum->GetYaxis()->SetTitleOffset(1.1);
	hl1Etsum->GetXaxis()->SetTitleSize(0.04);
	hl1Etsum->GetYaxis()->SetTitleSize(0.04);
	hl1Etsum->Draw();


	TCanvas *canvasofflineCentralityVsl1Etsum=new TCanvas("canvasofflineCentralityVsl1Etsum","canvas",600,500);
	canvasofflineCentralityVsl1Etsum->cd();
	profileofflineCentralityVsl1Etsum->GetXaxis()->SetRangeUser(0,6500.);
	profileofflineCentralityVsl1Etsum->GetYaxis()->SetRangeUser(0,250.);
	profileofflineCentralityVsl1Etsum->GetYaxis()->SetTitle("Offline Centrality (bins of 0.5%)");
	profileofflineCentralityVsl1Etsum->GetXaxis()->SetTitle("Emulator HF E_{T} sum");
	profileofflineCentralityVsl1Etsum->SetMarkerStyle(21);
	profileofflineCentralityVsl1Etsum->SetMarkerSize(0.6);
	profileofflineCentralityVsl1Etsum->GetXaxis()->SetTitleOffset(1.2);
	profileofflineCentralityVsl1Etsum->GetYaxis()->SetTitleOffset(1.2);
	profileofflineCentralityVsl1Etsum->Draw();
	profileofflineCentralityVsl1Etsum->Fit("f1");


	TCanvas *canvasl1EtsumVsofflineCentrality=new TCanvas("canvasl1EtsumVsofflineCentrality","canvas",600,500);
	canvasl1EtsumVsofflineCentrality->cd();
	profilel1EtsumVsofflineCentrality->GetYaxis()->SetRangeUser(0,6500.);
	profilel1EtsumVsofflineCentrality->GetXaxis()->SetRangeUser(0,250.);
	profilel1EtsumVsofflineCentrality->GetXaxis()->SetTitle("Offline Centrality (bins of 0.5%)");
	profilel1EtsumVsofflineCentrality->GetYaxis()->SetTitle("Emulator HF E_{T} sum");
	profilel1EtsumVsofflineCentrality->SetMarkerStyle(21);
	profilel1EtsumVsofflineCentrality->SetMarkerSize(0.6);
	profilel1EtsumVsofflineCentrality->GetXaxis()->SetTitleOffset(1.2);
	profilel1EtsumVsofflineCentrality->GetYaxis()->SetTitleOffset(1.2);
	profilel1EtsumVsofflineCentrality->Draw();
	profilel1EtsumVsofflineCentrality->Fit("f2");

	TCanvas *canvasL1CentralityVsfflineCentrality=new TCanvas("canvasL1CentralityVsfflineCentrality","canvas",600,500);
	canvasL1CentralityVsfflineCentrality->cd();
	hcorrL1CentralityVsfflineCentrality->SetMinimum(0.);
	hcorrL1CentralityVsfflineCentrality->GetYaxis()->SetTitleOffset(1.3);
	hcorrL1CentralityVsfflineCentrality->GetYaxis()->SetLabelSize(0.03);
	hcorrL1CentralityVsfflineCentrality->GetXaxis()->SetTitle("Offline centrality");
	hcorrL1CentralityVsfflineCentrality->GetYaxis()->SetTitle("L1 centrality");
	hcorrL1CentralityVsfflineCentrality->GetXaxis()->SetTitleOffset(1.1);
	hcorrL1CentralityVsfflineCentrality->GetYaxis()->SetTitleOffset(1.1);
	hcorrL1CentralityVsfflineCentrality->GetXaxis()->SetTitleSize(0.04);
	hcorrL1CentralityVsfflineCentrality->GetYaxis()->SetTitleSize(0.04);
	hcorrL1CentralityVsfflineCentrality->Draw();


	TCanvas *canvasl1CentralityVsofflineCentrality=new TCanvas("canvasl1CentralityVsofflineCentrality","canvas",600,500);
	canvasl1CentralityVsofflineCentrality->cd();
	profilel1CentralityVsofflineCentrality->GetYaxis()->SetRangeUser(0,250.);
	profilel1CentralityVsofflineCentrality->GetXaxis()->SetRangeUser(0,250.);
	profilel1CentralityVsofflineCentrality->GetXaxis()->SetTitle("Offline Centrality (bins of 0.5%)");
	profilel1CentralityVsofflineCentrality->GetYaxis()->SetTitle("L1 Centrality (bins of 0.5%)");
	profilel1CentralityVsofflineCentrality->SetMarkerStyle(21);
	profilel1CentralityVsofflineCentrality->SetMarkerSize(0.6);
	profilel1CentralityVsofflineCentrality->GetXaxis()->SetTitleOffset(1.2);
	profilel1CentralityVsofflineCentrality->GetYaxis()->SetTitleOffset(1.2);
	profilel1CentralityVsofflineCentrality->Draw();
	profilel1CentralityVsofflineCentrality->Fit("f3");

	const Int_t COLORS[NBINSCentrality] = {kViolet+1,kRed+1,kBlue+1,kGreen+1,1,30};

	TCanvas *canvasranges=new TCanvas("canvasranges","canvasranges",600,500);
	canvasranges->cd();

	hOffline[0]->SetMaximum(300);
	hOffline[0]->GetXaxis()->SetRangeUser(-10,210.);
	hOffline[0]->GetYaxis()->SetTitleOffset(1.5);

	for(int j=0;j<NBINSCentrality;j++){

		hOffline[j]->Sumw2();
		hOffline[j]->SetMarkerStyle(0);
		hOffline[j]->SetLineColor(COLORS[j]);
		hOffline[j]->SetFillStyle(3325);
		hOffline[j]->SetFillColor(COLORS[j]);
	}
	for(int j=0;j<NBINSCentrality;j++){
		hOffline[j]->Draw("same hist e");

	}

	TLegend *leg = new TLegend(0.340604,0.5940803,0.8741611,0.8816068,"L1 centrality threshold");
	leg->SetFillColor(0);
	leg->SetTextFont(42);
	leg->SetTextSizePixels(20);


	leg->AddEntry(hOffline[0],Form("0  < L1cen < %d",limit[0]),"lp");
	leg->AddEntry(hOffline[1],Form("%d < L1cen < %d",limit[0],limit[1]),"lp");
	leg->AddEntry(hOffline[2],Form("%d < L1cen < %d",limit[1],limit[2]),"lp");
	leg->AddEntry(hOffline[3],Form("%d < L1cen < %d",limit[2],limit[3]),"lp");
	leg->AddEntry(hOffline[4],Form("%d< L1cen < %d", limit[3],limit[4]),"lp");
	leg->AddEntry(hOffline[5],Form("%d< L1cen < 200",limit[4]),"lp");
	leg->Draw();  

	double Etsum[NBINSCentrality];

	for (int m=0;m<NBINSCentrality-1;m++){

		Etsum[m]=fprofileofflinel1EtsumVsCentrality_Calibration->Eval(limit[m]);
	}

	cout<<"***************************"<<endl;
	cout<<"LUT for centrality ranges"<<endl;
	cout<<"Centrality 0-5% = E_{T} sum > "<<Etsum[0]<<endl;
	cout<<"Centrality 5-10% ="<<Etsum[1]<<"<E_{T} sum <"<<Etsum[0]<<endl;
	cout<<"Centrality 10-30% ="<<Etsum[2]<<"<E_{T} sum <"<<Etsum[1]<<endl;
	cout<<"Centrality 30-50% ="<<Etsum[3]<<"<E_{T} sum <"<<Etsum[2]<<endl;
	cout<<"Centrality 50-90% ="<<Etsum[4]<<"<E_{T} sum <"<<Etsum[3]<<endl;
	cout<<"Centrality "<<(int)(limit[4]/2)<<"-100% =  E_{T} sum <"<<Etsum[4]<<endl;


	if(!isdata){

		TH1D *hNcoll[NBINSCentrality];

		for(int i = 0; i < NBINSCentrality; ++i){
			hNcoll[i]=(TH1D*)lFile->Get(Form("hNcoll_Bin%d",i)); 
			hNcoll[i]->Rebin(5);
		}  

		TCanvas *canvasrangesNcoll=new TCanvas("canvasrangesNcoll","canvasrangesNcoll",600,500);
		canvasrangesNcoll->cd();

		hNcoll[0]->SetMaximum(300);
		hNcoll[0]->GetXaxis()->SetRangeUser(-0.5,1999.5);
		hNcoll[0]->GetYaxis()->SetTitleOffset(1.5);

		for(int j=0;j<NBINSCentrality;j++){

			hNcoll[j]->Sumw2();
			hNcoll[j]->SetMarkerStyle(0);
			hNcoll[j]->SetLineColor(COLORS[j]);
			hNcoll[j]->SetFillStyle(3325);
			hNcoll[j]->SetFillColor(COLORS[j]);
		}
		for(int j=0;j<NBINSCentrality;j++){
			hNcoll[j]->Draw("same hist e");

		}

		TLegend *leg = new TLegend(0.340604,0.5940803,0.8741611,0.8816068,"L1 centrality threshold");
		leg->SetFillColor(0);
		leg->SetTextFont(42);
		leg->SetTextSizePixels(20);

		leg->AddEntry(hNcoll[0],Form("0  < L1cen < %d",limit[0]),"lp");
		leg->AddEntry(hNcoll[1],Form("%d < L1cen < %d",limit[0],limit[1]),"lp");
		leg->AddEntry(hNcoll[2],Form("%d < L1cen < %d",limit[1],limit[2]),"lp");
		leg->AddEntry(hNcoll[3],Form("%d < L1cen < %d",limit[2],limit[3]),"lp");
		leg->AddEntry(hNcoll[4],Form("%d< L1cen < %d", limit[3],limit[4]),"lp");
		leg->AddEntry(hNcoll[5],Form("%d< L1cen < 200",limit[4]),"lp");
		leg->Draw();

		canvasranges->SaveAs(Form("Plots/canvasranges_%s.eps",l1_input.Data()));
		canvasl1CentralityVsofflineCentrality->SaveAs(Form("Plots/canvasl1CentralityVsofflineCentrality_%s.pdf",l1_input.Data()));
		canvasL1CentralityVsfflineCentrality->SaveAs(Form("Plots/canvasL1CentralityVsfflineCentrality_%s.pdf",l1_input.Data()));
		canvasl1EtsumVsofflineCentrality->SaveAs(Form("Plots/canvasl1EtsumVsofflineCentrality_%s.pdf",l1_input.Data()));
		canvasofflineCentralityVsl1Etsum->SaveAs(Form("Plots/canvasofflineCentralityVsl1Etsum_%s.pdf",l1_input.Data()));
		canvasL1Etsum->SaveAs(Form("Plots/canvasL1Etsum_%s.pdf",l1_input.Data()));
		canvasOfflineEtsumVsL1Etsum->SaveAs(Form("Plots/canvasOfflineEtsumVsL1Etsum_%s.pdf",l1_input.Data()));
		canvasOfflineCentrality->SaveAs(Form("Plots/canvasOfflineCentrality_%s.pdf",l1_input.Data()));
		canvascorrl1EtsumPlusVscorrl1EtsumMinus->SaveAs(Form("Plots/canvascorrl1EtsumPlusVscorrl1EtsumMinus_%s.pdf",l1_input.Data()));
		canvascorrl1EtsumPlusVscorrl1EtsumMinus->SaveAs(Form("Plots/canvascorrl1EtsumPlusVscorrl1EtsumMinusNo_%s.pdf",l1_input.Data()));
		canvascorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel->SaveAs(Form("Plots/canvascorrl1EtsumPlusVscorrl1EtsumMinusNoEvSel_%s.pdf",l1_input.Data()));
		canvasrangesNcoll->SaveAs(Form("Plots/canvasrangesNcoll_%s.pdf",l1_input.Data()));

	}
}
void plotTurnOn(TString inFileName, TString outFileTag)
{
  TFile *inFile = TFile::Open(inFileName);

  const Int_t THRESHOLDS = 4;
  const Double_t L1_THRESHOLD[THRESHOLDS] = {4, 12, 20, 29};
  const Int_t COLORS[THRESHOLDS] = {kBlack, kRed, kBlue, kGreen+3};//, kMagenta+3};
  TGraphAsymmErrors *asymm[THRESHOLDS];//[2];

  for(int i = 0; i < THRESHOLDS; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      asymm[i] = (TGraphAsymmErrors*)inFile->Get(Form("asymm_pt_%d_0",(int)L1_THRESHOLD[i]));
      asymm[i]->SetMarkerColor(COLORS[i]);
      asymm[i]->SetLineColor(COLORS[i]);
    }
    //asymm[i][1]->SetMarkerStyle(25);
  }

  // these values MUST MATCH those used in makeTurnOn.C
  const int nBins = 200;
  const double maxPt = 200;

  TH1D *hEmpty = new TH1D("hEmpty",Form(";Photon p_{T} (GeV);Efficiency"),nBins,0,maxPt);

  TCanvas *c1 = new TCanvas();
  hEmpty->SetMinimum(0);
  hEmpty->SetMaximum(1.2);
  hEmpty->Draw();
  //c1->SetLogy();

  TLine *line = new TLine(0,1,maxPt,1);
  line->Draw();

  for(int i = 0; i < THRESHOLDS; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      asymm[i]->Draw("p");
    }
  }

  TLegend *leg = new TLegend(0.55,0.2,0.9,0.5,"|#eta| < 2");
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSizePixels(18);

  for(int i = 0; i < THRESHOLDS; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      leg->AddEntry(asymm[i], Form("L1_BarrelRegion%d", (int)L1_THRESHOLD[i]), "lp");
    }
  }

  leg->Draw();

  c1->SaveAs(Form("%s_turnon.pdf",outFileTag.Data()));

}
void energyHistoCompare(string dataset){

    /*setting up some global style variables */

    gStyle->SetLabelSize(0.05, "xyz");
    gStyle->SetLabelOffset(0.015, "xyz");
    gStyle->SetTitleSize(0.05, "xyz");
    gStyle->SetTitleSize(0.055, "h");
    gStyle->SetTitleOffset(1.1, "x");
    gStyle->SetTitleOffset(1.2, "y");
    gStyle->SetPadTopMargin(0.08);
    gStyle->SetPadBottomMargin(0.12);
    gStyle->SetPadLeftMargin(0.14);
    gStyle->SetPadRightMargin(0.1);
    gStyle->SetOptStat(0);
    gROOT->ForceStyle();


    //Initialize OADB container
    AliOADBContainer *container = new AliOADBContainer("");
    container->InitFromFile("$ALICE_PHYSICS/OADB/EMCAL/EMCALTimeCalib.root", "AliEMCALTimeCalib");
    if(!container){
        fprintf(stderr, "No OADB container!");
        return;
    }
    
    //Find container in OADB
    TObject *calibration = (TObject*) container->GetObject(0, "TimeCalib13");
    if(!calibration){
        fprintf(stderr, "No calibration container found in OADB!");
        return;
    }

    //Get Array for pass1 (13g) and pass4 (13b and 13c) and set up histograms
    TObject *calibPass1 = (TObject*) calibration->FindObject("pass1");
    if(!calibPass1){
        fprintf(stderr, "No pass1!");
        return;
    }
    TH1F *pass1[4];

    TObject* calibPass4 = (TObject*) calibration->FindObject("pass4");
    if(!calibPass4){
        fprintf(stderr, "No pass4!");
        return;
    }
    TH1F *pass4[4];

    //Set up the file to check against OADB
    TFile *checkFile[6];
    checkFile[0] = new TFile(Form("Calibration_%s_1000_400.root", dataset.c_str()));
    checkFile[1] = new TFile(Form("Calibration_%s_1000_200.root", dataset.c_str()));
    checkFile[2] = new TFile(Form("Calibration_%s_800_400.root", dataset.c_str()));
    checkFile[3] = new TFile(Form("Calibration_%s_800_200.root", dataset.c_str()));
    checkFile[4] = new TFile(Form("Calibration_%s_400_400.root", dataset.c_str()));
    checkFile[5] = new TFile(Form("Calibration_%s_400_200.root", dataset.c_str()));

    for(int i=0; i<6; i++){
        if(!checkFile[i]){
            fprintf(stderr, "Check file %i wasn't loaded!", i);
            return;
        }
    }
//  printf("dataset: %s, strcomp(\"13g\", %s) = %i\n", dataset.c_str(), dataset.c_str(), strcmp("13g", dataset.c_str()));
    TH1F **check[6];
    TH1F **errors[6];
    TH1F **errorsRebin[6];
    TH1F **compare[6];
    TH1F **compareRebin[6];
    TH1F **compare1000[6];
    TH1F **compare1000Rebin[6];
    for(int nfile = 0; nfile<6; nfile++){
        check[nfile] = new TH1F*[4];
        compare[nfile] = new TH1F*[4];
        compareRebin[nfile] = new TH1F*[4];
        errors[nfile] = new TH1F*[4];
        errorsRebin[nfile] = new TH1F*[4];
        compare1000[nfile] = new TH1F*[4];
        compare1000Rebin[nfile] = new TH1F*[4];
    }
    TH1F *compareSingle[4];
    TH1F *errors1000400upper[4];
    TH1F *errors1000400lower[4];

    //Get histograms from files (not LG for dataset 13g)
    for(int ibc =0; ibc<4; ibc++){
       for(int nfile = 0; nfile<6; nfile++){ 
            if(strcmp("13g", dataset.c_str())==0){
                check[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeAvBC%d", ibc));
                errors[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeRMSBC%d", ibc));
            }else{
                check[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeAvLGBC%d", ibc));
                errors[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeRMSLGBC%d", ibc));
            }
            switch(nfile){
                case 0 : check[nfile][ibc]->SetName(Form("1000mev400mevBC%d", ibc));
                    break;
                case 1 : check[nfile][ibc]->SetName(Form("1000mev200mevBC%d", ibc));
                        break;
                case 2 : check[nfile][ibc]->SetName(Form("800mev400mevBC%d", ibc));
                       break;
                case 3 : check[nfile][ibc]->SetName(Form("800mev200mevBC%d", ibc));
                         break;
                case 4 : check[nfile][ibc]->SetName(Form("400mev400mevBC%d", ibc));
                         break;
                case 5 : check[nfile][ibc]->SetName(Form("400mev200mevBC%d", ibc));
                         break;
                default: break;
            }
            compare[nfile][ibc] = check[nfile][ibc]->Clone(Form("compare%s", check[nfile][ibc]->GetName()));
            compare1000[nfile][ibc] = check[0][ibc]->Clone(Form("compare1000_%s", check[nfile][ibc]->GetName()));
      }
        pass1[ibc] = (TH1F*)calibPass1->FindObject(Form("hAllTimeAvBC%d", ibc));
        pass4[ibc] = (TH1F*)calibPass4->FindObject(Form("hAllTimeAvBC%d", ibc));
    }
   
    //Generate the comparison histograms
    for(int nfile=0; nfile<6; nfile++){
        for(int jbc=0; jbc<4; jbc++){
            for(int bin=0; bin < compare[nfile][jbc]->GetNbinsX(); bin++){
                if(strcmp("13g", dataset.c_str())==0){
                    compare[nfile][jbc]->SetBinContent(bin, compare[nfile][jbc]->GetBinContent(bin) - pass1[jbc]->GetBinContent(bin));
                    if(compare[nfile][jbc]->GetBinContent(bin)<-200){
                        compare[nfile][jbc]->SetBinContent(bin, 0.);
                    } 
                }else{
                    compare[nfile][jbc]->SetBinContent(bin, compare[nfile][jbc]->GetBinContent(bin) - pass4[jbc]->GetBinContent(bin));
                    if(compare[nfile][jbc]->GetBinContent(bin)<-200){
                        compare[nfile][jbc]->SetBinContent(bin, 0.);
                    }
                }
                compare1000[nfile][jbc]->SetBinContent(bin, check[nfile][jbc]->GetBinContent(bin) - compare1000[nfile][jbc]->GetBinContent(bin));
            }
            if(nfile==0){
                compareSingle[jbc] = (TH1F*)compare[nfile][jbc]->Clone("singlecomp");
            }
            compareRebin[nfile][jbc] = compare[nfile][jbc]->Rebin(100, Form("compareR%s", check[nfile][jbc]->GetName()));
            compareRebin[nfile][jbc]->Scale(0.01);
            compare1000Rebin[nfile][jbc]= compare1000[nfile][jbc]->Rebin(100, Form("compare1000R%s", check[nfile][jbc]->GetName()));
            compare1000Rebin[nfile][jbc]->Scale(0.01);
        }
    }

    Double_t variance = 0.0;
    //Generate the Errors histograms using standard deviation squared
    for(int nfile = 0; nfile<6; nfile++){
        for(int jbc=0; jbc<4; jbc++){
            for(int bin=0; bin < check[nfile][jbc]->GetNbinsX(); bin++){
                variance = TMath::Power(errors[nfile][jbc]->GetBinContent(bin), 2) - TMath::Power(check[nfile][jbc]->GetBinContent(bin), 2);
                if(variance >= 0){
                    errors[nfile][jbc]->SetBinContent(bin, (TMath::Sqrt(variance)));
                }else{
                    errors[nfile][jbc]->SetBinContent(bin, 0.0);
                }
            }
            //rebin
            errorsRebin[nfile][jbc] = errors[nfile][jbc]->Rebin(100, Form("%sR", errors[nfile][jbc]->GetName()));
            errorsRebin[nfile][jbc]->Scale(0.01);
            if(nfile==0){
                errors1000400upper[jbc] = (TH1F*)errors[nfile][jbc]->Clone("errorUpper");
                errors1000400lower[jbc] = (TH1F*)errors[nfile][jbc]->Clone("errorLower");
                errors1000400lower[jbc]->Scale(-1.0);
            }
        }
    }

   errors[0][0]->Print("base"); 
    /*    
//Setup Output file
    TFile *output = new TFile("comparison.root", "RECREATE");
    output->cd();
    check_1000_200[0]->Write();
    output->Close();
*/

    //draw all calibration on same plot
    TCanvas* c0 = new TCanvas("Calibration Offsets BC0", "calibrationoffsetsbc0", 1000,600);
    c0->cd();

    TLegend *legend = new TLegend(0.1,0.7,0.3,0.9);
    legend->SetHeader("Calibration for Cluster/Cell energy cuts");
   
    // bc number to plot 
    int bcNum = 0;

    if(strcmp("13g",dataset.c_str())==0){
        pass1[bcNum]->SetMarkerStyle(20);
        pass1[bcNum]->SetMarkerColor(1);
        pass1[bcNum]->SetMarkerSize(1);
        pass1[bcNum]->SetTitle(Form("Calibration for Different Cluster/Cell Energy Cuts for LHC%s BC%d", dataset.c_str(), bcNum));
        pass1[bcNum]->GetXaxis()->SetTitle("Cell AbsID");
        pass1[bcNum]->GetXaxis()->SetRangeUser(0,11650);
        pass1[bcNum]->GetYaxis()->SetTitle("Calibrated Offset (ns)");
        pass1[bcNum]->GetYaxis()->SetRangeUser(550,650);
        pass1[bcNum]->SetStats(kFALSE);
        pass1[bcNum]->Draw("P SAME");
        legend->AddEntry(pass1[bcNum], "Current OADB Calibration", "p");
    }else{
        pass4[bcNum]->SetMarkerStyle(20);
        pass4[bcNum]->SetMarkerColor(1);
        pass4[bcNum]->SetMarkerSize(1);
        pass4[bcNum]->SetTitle(Form("Calibration for Different Cluster/Cell Energy Cuts for LHC%s BC%d", dataset.c_str(), bcNum));
        pass4[bcNum]->GetXaxis()->SetTitle("Cell AbsID");
        pass4[bcNum]->GetXaxis()->SetRangeUser(0,11650);
        pass4[bcNum]->GetYaxis()->SetTitle("Calibrated Offset (ns)");
        pass4[bcNum]->GetYaxis()->SetRangeUser(550,650);
        pass4[bcNum]->SetStats(kFALSE);
        pass4[bcNum]->Draw("P SAME");
        legend->AddEntry(pass4[bcNum], "Current OADB Calibration", "p");
    }

    for(int nfile=0; nfile<6; nfile++){
        check[nfile][bcNum]->SetMarkerStyle(3);
        check[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        check[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);

        switch(nfile){
            case 0 : legend->AddEntry((TH1F*)check[nfile][bcNum], "1000MeV / 400MeV", "p");
                     break;
            case 1 : legend->AddEntry((TH1F*)check[nfile][bcNum], "1000MeV / 200MeV", "p");
                     break;
            case 2 : legend->AddEntry((TH1F*)check[nfile][bcNum], "800MeV / 400MeV", "p");
                     break;
            case 3 : legend->AddEntry((TH1F*)check[nfile][bcNum], "800MeV / 200MeV", "p");
                     break;
            case 4 : legend->AddEntry((TH1F*)check[nfile][bcNum], "400MeV / 400MeV", "p");
                     break;
            case 5 : legend->AddEntry((TH1F*)check[nfile][bcNum], "400MeV / 200MeV", "p");
                     break;
            default: break;
        }
        check[nfile][bcNum]->SetTitle(Form("Calibration for Different Cluster/Cell Energy Cuts for LHC%s BC%d", dataset.c_str(), bcNum));
        check[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID");
        check[nfile][bcNum]->GetXaxis()->SetRangeUser(0,11650);
        check[nfile][bcNum]->GetYaxis()->SetTitle("Calibrated Offset (ns)");
        check[nfile][bcNum]->GetYaxis()->SetRangeUser(550,650);
        check[nfile][bcNum]->SetStats(kFALSE);
        check[nfile][bcNum]->Draw("P SAME");
    }
    legend->SetTextSizePixels(10);
    legend->Draw();

    //draw just OADB 1000/400 MeV cut on same plot

    TCanvas* c400 = new TCanvas("Calibration Offsets 1000MeV/400MeV BC0", "calibrationoffsets400bc0", 1000,600);
    c400->cd();

    TLegend *legend400 = new TLegend(0.1,0.7,0.3,0.9);
    legend400->SetHeader("Calibration for Cluster/Cell energy cuts");



    nfile=0;    
    int color = nfile+2;
    if(strcmp("13g", dataset.c_str())==0){
        pass1[bcNum]->SetTitle(Form("Time Calibration for LHC%s BC%d", dataset.c_str(), bcNum));
        pass1[bcNum]->Draw("P SAME");
        legend400->AddEntry((TH1F*)pass1[bcNum], "OADB Calibration", "p");
    }else{
        pass4[bcNum]->SetTitle(Form("Time Calibration for LHC%s BC%d", dataset.c_str(), bcNum));
        pass4[bcNum]->Draw("P SAME");
        legend400->AddEntry((TH1F*)pass4[bcNum], "OADB Calibration", "p");
    }

    legend400->AddEntry((TH1F*)check[nfile][bcNum], "1000MeV / 400MeV", "p");
    check[nfile][bcNum]->SetTitle(Form("Time Calibration for LHC%s BC%d", dataset.c_str(), bcNum));
    check[nfile][bcNum]->GetYaxis()->SetRangeUser(550,650);
    check[nfile][bcNum]->GetXaxis()->SetRangeUser(0,11650);
    check[nfile][bcNum]->Draw("P SAME");

    legend400->SetTextSizePixels(12);
    legend400->Draw();


    //draw all standard deviation on same plot
    TCanvas* cError = new TCanvas("Calibration Errors BC0", "calibrationerrorsbc0", 1000,600);
    cError->cd();

    TLegend *legendError = new TLegend(0.1,0.7,0.4,0.9);
    legendError->SetHeader("Calibration for Cluster/Cell Energy cuts");

    for(int nfile=0; nfile<6; nfile++){
        errors[nfile][bcNum]->SetMarkerStyle(3);
        errors[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        errors[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        errors[nfile][bcNum]->SetLineWidth(2);
        errors[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : legendError->AddEntry((TH1F*)errors[nfile][bcNum], "1000MeV / 400MeV", "l");
                     break;
            case 1 : legendError->AddEntry((TH1F*)errors[nfile][bcNum], "1000MeV / 200MeV", "l");
                     break;
            case 2 : legendError->AddEntry((TH1F*)errors[nfile][bcNum], "800MeV / 400MeV", "l");
                     break;
            case 3 : legendError->AddEntry((TH1F*)errors[nfile][bcNum], "800MeV / 200MeV", "l");
                     break;
            case 4 : legendError->AddEntry((TH1F*)errors[nfile][bcNum], "400MeV / 400MeV", "l");
                     break;
            case 5 : legendError->AddEntry((TH1F*)errors[nfile][bcNum], "400MeV / 200MeV", "l");
                     break;
            default: break;
        }
        errors[nfile][bcNum]->SetTitle(Form("Standard Deviation of Calibration for LHC%s BC%d", dataset.c_str(), bcNum));
        errors[nfile][bcNum]->GetXaxis()->SetRangeUser(0, 11650);
        errors[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID");
        errors[nfile][bcNum]->GetYaxis()->SetRangeUser(-2,8);
        errors[nfile][bcNum]->GetYaxis()->SetTitle("Standard Deviation of Calibration (ns)");
        errors[nfile][bcNum]->SetStats(kFALSE);
        errors[nfile][bcNum]->Draw("L SAME");
    }
    legendError->SetTextSizePixels(10);
//    legendError->Draw();
 
//Draw comparison with OADB plot (all cuts)
    TCanvas* c1 = new TCanvas("(OADB - Calibration)", "comparisonbc0", 1000,600);
    c1->cd();

    TLegend *compLegend = new TLegend(0.1,0.7,0.4,0.9);
    compLegend->SetHeader("Difference between OADB and Calibration for Cluster/Cell energy cuts");

    for(int nfile=0; nfile<6; nfile++){
        compare[nfile][bcNum]->SetMarkerStyle(3);
        compare[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        compare[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compare[nfile][bcNum]->SetLineWidth(2);
        compare[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : compLegend->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 1000MeV/400MeV)", "l");
                     break;
            case 1 : compLegend->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 1000MeV/200MeV)", "l");
                     break;
            case 2 : compLegend->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 800MeV/400MeV)", "l");
                     break;
            case 3 : compLegend->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 800MeV/200MeV)", "l");
                     break;
            case 4 : compLegend->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 400MeV/400MeV)", "l");
                     break;
            case 5 : compLegend->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 400MeV/200MeV)", "l");
                     break;
            default: break;
        }
        compare[nfile][bcNum]->SetTitle(Form("(OADB - Calibration) for LHC%s BC%d", dataset.c_str(), bcNum));
        compare[nfile][bcNum]->GetXaxis()->SetRangeUser(0,11650);
        compare[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID");
        compare[nfile][bcNum]->GetYaxis()->SetRangeUser(-3,10);
        compare[nfile][bcNum]->GetYaxis()->SetTitle("Difference in Calibration (ns)"); 
        compare[nfile][bcNum]->SetStats(kFALSE);
        compare[nfile][bcNum]->Draw("L SAME");
    }
    compLegend->SetTextSizePixels(10);
//    compLegend->Draw();

//Draw comparison with OADB (400 cell cut, all cluster cuts)
    TCanvas* c2 = new TCanvas("(OADB - Calibration_400)", "comparison_400_bc0", 1000,600);
    c2->cd();

    TLegend *compLegend2 = new TLegend(0.1,0.7,0.4,0.9);
    compLegend2->SetHeader("Difference between OADB and Calibration for Cluster/Cell energy cuts");

    for(int nfile=0; nfile<6; nfile+=2){
        compare[nfile][bcNum]->SetMarkerStyle(3);
        compare[nfile][bcNum]->SetMarkerSize(0.8);
        int color = nfile+2;
        compare[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compare[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : compLegend2->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 1000MeV/400MeV)", "l");
                     break;
            case 1 : compLegend2->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 1000MeV/200MeV)", "l");
                     break;
            case 2 : compLegend2->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 800MeV/400MeV)", "l");
                     break;
            case 3 : compLegend2->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 800MeV/200MeV)", "l");
                     break;
            case 4 : compLegend2->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 400MeV/400MeV)", "l");
                     break;
            case 5 : compLegend2->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 400MeV/200MeV)", "l");
                     break;
            default: break;
        }
        compare[nfile][bcNum]->Draw("L SAME");
    }
    compLegend2->SetTextSizePixels(10);
//    compLegend2->Draw();

    //Draw comparison with OADB (200 cell cut, cluster cuts)
    TCanvas* c3 = new TCanvas("(OADB - Calibration_200)", "comparison_200_bc0", 1000,600);
    c3->cd();

    TLegend *compLegend3 = new TLegend(0.1,0.7,0.4,0.9);
    compLegend3->SetHeader("Difference between OADB and Calibration for Cluster/Cell energy cuts");

    for(int nfile=1; nfile<6; nfile+=2){
        compare[nfile][bcNum]->SetMarkerStyle(3);
        compare[nfile][bcNum]->SetMarkerSize(0.8);
        int color = nfile+2;
        compare[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compare[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : compLegend3->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 1000MeV/400MeV)", "l");
                     break;
            case 1 : compLegend3->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 1000MeV/200MeV)", "l");
                     break;
            case 2 : compLegend3->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 800MeV/400MeV)", "l");
                     break;
            case 3 : compLegend3->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 800MeV/200MeV)", "l");
                     break;
            case 4 : compLegend3->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 400MeV/400MeV)", "l");
                     break;
            case 5 : compLegend3->AddEntry((TH1F*)compare[nfile][bcNum], "(OADB - 400MeV/200MeV)", "l");
                     break;
            default: break;
        }
        compare[nfile][bcNum]->Draw("L SAME");
    }
    compLegend3->SetTextSizePixels(10);
//    compLegend3->Draw();

//Draw comparison with OADB and 1000/400 cut
    TCanvas* c400comp = new TCanvas("(OADB - Calibration_1000/400)", "comparison_1000400_bc0", 1000,600);
    c400comp->cd();

    nfile=0;
    compareSingle[bcNum]->SetMarkerStyle(3);
    compareSingle[bcNum]->SetMarkerSize(0.8);
    int color = nfile+2;
    compareSingle[bcNum]->SetMarkerColorAlpha(color, 0.3);
    compareSingle[bcNum]->SetLineColor(color);
    compareSingle[bcNum]->SetTitle(Form("(OADB - Calibration) for LHC%s BC%d", dataset.c_str(), bcNum));
    compareSingle[bcNum]->GetXaxis()->SetRangeUser(0,11650);
    compareSingle[bcNum]->GetXaxis()->SetTitle("Cell AbsID");
    compareSingle[bcNum]->GetYaxis()->SetRangeUser(-3,10);
    compareSingle[bcNum]->GetYaxis()->SetTitle("Difference in Calibration (ns)"); 
    compareSingle[bcNum]->SetStats(kFALSE); 
    compareSingle[bcNum]->Draw("L SAME");

//Draw comparison with 1000_400 plot (all cuts)
    TCanvas* c1000 = new TCanvas("(Calibration - 1000MeV/400MeV)", "comparison1000bc0", 1000,600);
    c1000->cd();

    TLegend *comp1000Legend = new TLegend(0.1,0.7,0.4,0.9);
    comp1000Legend->SetHeader("Difference between 1000MeV/400MeV cut and other Cluster/Cell energy cuts");

    for(int nfile=0; nfile<6; nfile++){
        compare1000[nfile][bcNum]->SetMarkerStyle(3);
        compare1000[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        compare1000[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compare1000[nfile][bcNum]->SetLineWidth(2);
        compare1000[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : comp1000Legend->AddEntry((TH1F*)compare1000[nfile][bcNum], "(1000MeV/400MeV - 1000MeV/400MeV)", "l");
                     break;
            case 1 : comp1000Legend->AddEntry((TH1F*)compare1000[nfile][bcNum], "(1000MeV/200MeV - 1000MeV/400MeV)", "l");
                     break;
            case 2 : comp1000Legend->AddEntry((TH1F*)compare1000[nfile][bcNum], "(800MeV/400MeV - 1000MeV/400MeV)", "l");
                     break;
            case 3 : comp1000Legend->AddEntry((TH1F*)compare1000[nfile][bcNum], "(800MeV/200MeV - 1000MeV/400MeV)", "l");
                     break;
            case 4 : comp1000Legend->AddEntry((TH1F*)compare1000[nfile][bcNum], "(400MeV/400MeV - 1000MeV/400MeV)", "l");
                     break;
            case 5 : comp1000Legend->AddEntry((TH1F*)compare1000[nfile][bcNum], "(400MeV/200MeV - 1000MeV/400MeV)", "l");
                     break;
            default: break;
        }
        compare1000[nfile][bcNum]->SetStats(kFALSE);
        compare1000[nfile][bcNum]->GetXaxis()->SetRangeUser(0,11650);
        compare1000[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID");
        compare1000[nfile][bcNum]->GetYaxis()->SetRangeUser(-5, 15);
        compare1000[nfile][bcNum]->GetYaxis()->SetTitle("Difference in Calibration (ns)");
        compare1000[nfile][bcNum]->SetTitle(Form("(Calibration - 1000MeV/400MeV) for LHC%s BC%d", dataset.c_str(), bcNum));
        compare1000[nfile][bcNum]->SetStats(kFALSE);
        compare1000[nfile][bcNum]->Draw("L SAME");
    }
    comp1000Legend->SetTextSizePixels(10);
//    comp1000Legend->Draw();



//**REBIN draw all standard deviation on same plot
    TCanvas* cErrorR = new TCanvas("Calibration Errors BC0 Rebin", "calibrationerrorsbc0R", 1000,600);
    cErrorR->cd();

    TLegend *legendErrorR = new TLegend(0.1,0.7,0.4,0.9);
    legendError->SetHeader("Calibration for Cluster/Cell Energy cuts");

    for(int nfile=0; nfile<6; nfile++){
        errorsRebin[nfile][bcNum]->SetMarkerStyle(3);
        errorsRebin[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        errorsRebin[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        errorsRebin[nfile][bcNum]->SetLineWidth(2);
        errorsRebin[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : legendError->AddEntry((TH1F*)errorsRebin[nfile][bcNum], "1000MeV / 400MeV", "l");
                     break;
            case 1 : legendError->AddEntry((TH1F*)errorsRebin[nfile][bcNum], "1000MeV / 200MeV", "l");
                     break;
            case 2 : legendError->AddEntry((TH1F*)errorsRebin[nfile][bcNum], "800MeV / 400MeV", "l");
                     break;
            case 3 : legendError->AddEntry((TH1F*)errorsRebin[nfile][bcNum], "800MeV / 200MeV", "l");
                     break;
            case 4 : legendError->AddEntry((TH1F*)errorsRebin[nfile][bcNum], "400MeV / 400MeV", "l");
                     break;
            case 5 : legendError->AddEntry((TH1F*)errorsRebin[nfile][bcNum], "400MeV / 200MeV", "l");
                     break;
            default: break;
        }
        errorsRebin[nfile][bcNum]->SetTitle(Form("Standard Deviation of Calibration for LHC%s BC%d", dataset.c_str(), bcNum));
        errorsRebin[nfile][bcNum]->GetXaxis()->SetRangeUser(0, 11650);
        errorsRebin[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID (Rebinned by 100)");
        errorsRebin[nfile][bcNum]->GetYaxis()->SetRangeUser(-2,8);
        errorsRebin[nfile][bcNum]->GetYaxis()->SetTitle("Standard Deviation of Calibration (ns)");
        errorsRebin[nfile][bcNum]->SetStats(kFALSE);
        errorsRebin[nfile][bcNum]->Draw("L SAME");
    }
    legendError->SetTextSizePixels(10);
//    legendError->Draw();
 

//**REBIN Draw comparison with OADB plot (all cuts)
    TCanvas* c1R = new TCanvas("(OADB - Calibration) Rebin", "comparisonbc0R", 1000,600);
    c1R->cd();

    TLegend *compLegendR = new TLegend(0.1,0.7,0.4,0.9);
    compLegend->SetHeader("Difference between OADB and Calibration for Cluster/Cell energy cuts");

    for(int nfile=0; nfile<6; nfile++){
        compareRebin[nfile][bcNum]->SetMarkerStyle(3);
        compareRebin[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        compareRebin[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compareRebin[nfile][bcNum]->SetLineWidth(2);
        compareRebin[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : compLegend->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 1000MeV/400MeV)", "l");
                     break;
            case 1 : compLegend->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 1000MeV/200MeV)", "l");
                     break;
            case 2 : compLegend->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 800MeV/400MeV)", "l");
                     break;
            case 3 : compLegend->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 800MeV/200MeV)", "l");
                     break;
            case 4 : compLegend->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 400MeV/400MeV)", "l");
                     break;
            case 5 : compLegend->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 400MeV/200MeV)", "l");
                     break;
            default: break;
        }
        compareRebin[nfile][bcNum]->SetTitle(Form("(OADB - Calibration) for LHC%s BC%d", dataset.c_str(), bcNum));
        compareRebin[nfile][bcNum]->GetXaxis()->SetRangeUser(0,11650);
        compareRebin[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID (Rebinned by 100)");
        compareRebin[nfile][bcNum]->GetYaxis()->SetRangeUser(-3,10);
        compareRebin[nfile][bcNum]->GetYaxis()->SetTitle("Difference in Calibration (ns)"); 
        compareRebin[nfile][bcNum]->SetStats(kFALSE);
        compareRebin[nfile][bcNum]->Draw("L SAME");
    }
    compLegend->SetTextSizePixels(10);
//    compLegend->Draw();


//**REBIN Draw comparison with OADB (400 cell cut, all cluster cuts)
    TCanvas* c2R = new TCanvas("(OADB - Calibration_400) Rebin", "comparison_400_bc0R", 1000,600);
    c2R->cd();

    TLegend *compLegend2R = new TLegend(0.1,0.7,0.4,0.9);
    compLegend2->SetHeader("Difference between OADB and Calibration for Cluster/Cell energy cuts");

    for(int nfile=0; nfile<6; nfile+=2){
        compareRebin[nfile][bcNum]->SetMarkerStyle(3);
        compareRebin[nfile][bcNum]->SetMarkerSize(0.8);
        int color = nfile+2;
        compareRebin[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compareRebin[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : compLegend2->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 1000MeV/400MeV)", "l");
                     break;
            case 1 : compLegend2->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 1000MeV/200MeV)", "l");
                     break;
            case 2 : compLegend2->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 800MeV/400MeV)", "l");
                     break;
            case 3 : compLegend2->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 800MeV/200MeV)", "l");
                     break;
            case 4 : compLegend2->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 400MeV/400MeV)", "l");
                     break;
            case 5 : compLegend2->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 400MeV/200MeV)", "l");
                     break;
            default: break;
        }
        compareRebin[nfile][bcNum]->Draw("L SAME");
    }
    compLegend2->SetTextSizePixels(10);
//    compLegend2->Draw();

//**REBIN Draw comparison with OADB (200 cell cut, cluster cuts)
    TCanvas* c3R = new TCanvas("(OADB - Calibration_200) Rebin", "comparison_200_bc0R", 1000,600);
    c3R->cd();

    TLegend *compLegend3R = new TLegend(0.1,0.7,0.4,0.9);
    compLegend3->SetHeader("Difference between OADB and Calibration for Cluster/Cell energy cuts");

    for(int nfile=1; nfile<6; nfile+=2){
        compareRebin[nfile][bcNum]->SetMarkerStyle(3);
        compareRebin[nfile][bcNum]->SetMarkerSize(0.8);
        int color = nfile+2;
        compareRebin[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compareRebin[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : compLegend3->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 1000MeV/400MeV)", "l");
                     break;
            case 1 : compLegend3->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 1000MeV/200MeV)", "l");
                     break;
            case 2 : compLegend3->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 800MeV/400MeV)", "l");
                     break;
            case 3 : compLegend3->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 800MeV/200MeV)", "l");
                     break;
            case 4 : compLegend3->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 400MeV/400MeV)", "l");
                     break;
            case 5 : compLegend3->AddEntry((TH1F*)compareRebin[nfile][bcNum], "(OADB - 400MeV/200MeV)", "l");
                     break;
            default: break;
        }
        compareRebin[nfile][bcNum]->Draw("L SAME");
    }
    compLegend3->SetTextSizePixels(10);
//    compLegend3->Draw();


//**REBIN Draw comparison with 1000_400 plot (all cuts)
    TCanvas* c1000R = new TCanvas("(Calibration - 1000MeV/400MeV) Rebin", "comparison1000bc0R", 1000,600);
    c1000R->cd();

    TLegend *comp1000LegendR = new TLegend(0.1,0.7,0.4,0.9);
    comp1000LegendR->SetHeader("Difference between 1000MeV/400MeV cut and other Cluster/Cell energy cuts");

    for(int nfile=0; nfile<6; nfile++){
        compare1000Rebin[nfile][bcNum]->SetMarkerStyle(3);
        compare1000Rebin[nfile][bcNum]->SetMarkerSize(0.6);
        int color = nfile+2;
        compare1000Rebin[nfile][bcNum]->SetMarkerColorAlpha(color, 0.3);
        compare1000Rebin[nfile][bcNum]->SetLineWidth(2);
        compare1000Rebin[nfile][bcNum]->SetLineColor(color);
        switch(nfile){
            case 0 : comp1000Legend->AddEntry((TH1F*)compare1000Rebin[nfile][bcNum], "(1000MeV/400MeV - 1000MeV/400MeV)", "l");
                     break;
            case 1 : comp1000Legend->AddEntry((TH1F*)compare1000Rebin[nfile][bcNum], "(1000MeV/200MeV - 1000MeV/400MeV)", "l");
                     break;
            case 2 : comp1000Legend->AddEntry((TH1F*)compare1000Rebin[nfile][bcNum], "(800MeV/400MeV - 1000MeV/400MeV)", "l");
                     break;
            case 3 : comp1000Legend->AddEntry((TH1F*)compare1000Rebin[nfile][bcNum], "(800MeV/200MeV - 1000MeV/400MeV)", "l");
                     break;
            case 4 : comp1000Legend->AddEntry((TH1F*)compare1000Rebin[nfile][bcNum], "(400MeV/400MeV - 1000MeV/400MeV)", "l");
                     break;
            case 5 : comp1000Legend->AddEntry((TH1F*)compare1000Rebin[nfile][bcNum], "(400MeV/200MeV - 1000MeV/400MeV)", "l");
                     break;
            default: break;
        }
        compare1000Rebin[nfile][bcNum]->SetStats(kFALSE);
        compare1000Rebin[nfile][bcNum]->GetXaxis()->SetRangeUser(0,11650);
        compare1000Rebin[nfile][bcNum]->GetXaxis()->SetTitle("Cell AbsID (Rebinned by 100)");
        compare1000Rebin[nfile][bcNum]->GetYaxis()->SetRangeUser(-5, 15);
        compare1000Rebin[nfile][bcNum]->GetYaxis()->SetTitle("Difference in Calibration (ns)");
        compare1000Rebin[nfile][bcNum]->SetTitle(Form("(Calibration - 1000MeV/400MeV) for LHC%s BC%d", dataset.c_str(), bcNum));
        compare1000Rebin[nfile][bcNum]->SetStats(kFALSE);
        compare1000Rebin[nfile][bcNum]->Draw("L SAME");
    }
    comp1000Legend->SetTextSizePixels(10);
//    comp1000Legend->Draw();


}
void plotTurnOn()
{
  const Int_t INPUTFILES = 4;


  // TString outFileTag = "MBData_200Hz";
  // TString inFileName[INPUTFILES] = {"hist_MBData_zeroWalls.root",
  // 				    "hist_MBData_sigmaSubtraction.root",
  // 				    "hist_MBData_oneByOneAndzeroWalls.root",
  // 				    "hist_MBData_twoByTwoANDzeroWalls.root"
  // };
  // TString labels[INPUTFILES] = {"zeroWalls, L1_40, 206Hz",
  // 				"sigma subtracted, L1_24, 187Hz",
  // 				"1x1 jets +ZW, L1_16, 191Hz",
  // 				"2x2 jets +ZW, L1_52, 228Hz"};
  // const Double_t L1_THRESHOLD[INPUTFILES] = {40, 24, 16, 32};
  // // TString labels[INPUTFILES] = {"zeroWalls, L1_44, 550Hz",
  // // 				"sigma subtracted, L1_20, 505Hz",
  // // 				"1x1 jets +ZW, L1_20, 441Hz",
  // // 				"2x2 jets +ZW, L1_36, 444Hz"};
  // // const Double_t L1_THRESHOLD[INPUTFILES] = {44, 20, 20, 36};

  // TString outFileTag = "Hydjet276_270Hz";
  // TString inFileName[INPUTFILES] = {"hist_Hydjet276_zeroWalls.root",
  // 				    "hist_Hydjet276_sigmaSubtraction.root",
  // 				    "hist_Hydjet276_oneByOneAndzeroWalls.root",
  // 				    "hist_Hydjet276_twoByTwoANDzeroWalls.root"};
  // // const TString labels[INPUTFILES] = {"zeroWalls, L1_60, 104Hz",
  // // 				      "sigma subtracted, L1_28, 102Hz",
  // // 				      "1x1 jets, L1_28, 112Hz",
  // // 				      "2x2 jets, L1_48, 107Hz"};
  // // const Double_t L1_THRESHOLD[INPUTFILES] = {60, 28, 28, 48};
  // const TString labels[INPUTFILES] = {"zeroWalls, L1_40, 276Hz",
  // 				      "sigma subtracted, L1_24, 280Hz",
  // 				      "1x1 jets +ZW, L1_20, 270Hz",
  // 				      "2x2 jets +ZW, L1_32, 272Hz"};
  // const Double_t L1_THRESHOLD[INPUTFILES] = {40, 24, 20, 32};


  // TString outFileTag = "Hydjet502_200Hz";
  // TString inFileName[INPUTFILES] = {"hist_Hydjet502_zeroWalls.root",
  // 				    "hist_Hydjet502_sigmaSubtraction.root",
  // 				    "hist_Hydjet502_oneByOneAndzeroWalls.root",
  // 				    "hist_Hydjet502_twoByTwoANDzeroWalls.root"
  // };
  // // TString labels[INPUTFILES] = {"zeroWalls, L1_80, 150Hz",
  // // 				"sigma subtracted, L1_36, 163Hz",
  // // 				"1x1 jets, L1_36, 167Hz",
  // // 				"2x2 jets, L1_88, 155Hz"};
  // // const Double_t L1_THRESHOLD[INPUTFILES] = {80, 36, 36, 64};

  // TString outFileTag = "Photon502_60GeV";
  // TString inFileName[INPUTFILES] = {"hist_Photon502_isophoton_regions.root",
  // 				    "hist_Photon502_isophotons_eta1.44_2x2jets.root",
  // 				    "hist_Photon502_isophotons_eta1.44_3x3jets.root",
  // 				    "hist_Photon502_isophotons_noHoEorFG_emcands.root"};
  // TString labels[INPUTFILES] = {"Single Regions 50GeV, |#eta| < 1.74",
  // 				"2x2 Jets 48GeV, |#eta| < 1.74",
  // 				"3x3 Jets 48GeV, |#eta| < 1.74",
  // 				"EG cands 50GeV"};
  // const Double_t L1_THRESHOLD[INPUTFILES] = {50, 48, 48,50};

  TString outFileTag = "Photon502_40GeV";
  TString inFileName[INPUTFILES] = {"hist_Photon502_isophoton_regions.root",
  				    "hist_Photon502_isophotons_eta1.44_2x2jets.root",
  				    "hist_Photon502_isophotons_eta1.44_3x3jets.root",
				    "hist_Photon502_isophotons_noHoEorFG_emcands.root"};
  TString labels[INPUTFILES] = {"Single Regions 20GeV, |#eta| < 1.74",
  				"2x2 Jets 24GeV, |#eta| < 1.74",
  				"3x3 Jets 28GeV, |#eta| < 1.74",
  				"EG cands 32GeV"};
  const Double_t L1_THRESHOLD[INPUTFILES] = {20, 24, 28,32};

  TFile *inFile[INPUTFILES];
  const Int_t COLORS[INPUTFILES] = {kBlack, kRed, kBlue, kGreen+3};//, kMagenta+3};
  TGraphAsymmErrors *asymm[INPUTFILES];//[2];

  for(int i = 0; i < INPUTFILES; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      inFile[i] = TFile::Open(inFileName[i]);
      asymm[i] = (TGraphAsymmErrors*)inFile[i]->Get(Form("asymm_pt_%d_0",(int)L1_THRESHOLD[i]));
      asymm[i]->SetMarkerColor(COLORS[i]);
      asymm[i]->SetLineColor(COLORS[i]);
    }
    //asymm[i][1]->SetMarkerStyle(25);
  }

  // these values MUST MATCH those used in makeTurnOn.C
  const int nBins = 75;
  const double maxPt = 200;

  TH1D *hEmpty = new TH1D("hEmpty",Form(";Isolated Photon p_{T} (GeV);Efficiency"),nBins,0,maxPt);

  TCanvas *c1 = new TCanvas();
  hEmpty->SetMinimum(0);
  hEmpty->SetMaximum(1.2);
  hEmpty->Draw();
  //c1->SetLogy();

  TLine *line = new TLine(0,1,maxPt,1);
  line->Draw();

  for(int i = 0; i < INPUTFILES; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      asymm[i]->Draw("p");
    }
  }

  TLegend *leg = new TLegend(0.55,0.2,0.9,0.5,"|#eta| < 1.44");
  leg->SetFillColor(0);
  leg->SetTextFont(42);
  leg->SetTextSizePixels(18);

  for(int i = 0; i < INPUTFILES; i++)
  {
    //for(int j = 0; j < 2; j++)
    {
      leg->AddEntry(asymm[i], Form("%s", labels[i].Data()), "lp");
    }
  }

  leg->Draw();

  c1->SaveAs(Form("%s_turnon.pdf",outFileTag.Data()));

}
Exemple #9
0
void massPlotsbar(){

    TFile *file1 = new TFile("20170721_Kstar0bar_masswidth_pf160_scaled.root");
    TH1D* mass1 = file1->Get("kstar0mass");
    mass1->SetName("mwScaled");
    mass1->SetTitle("Fit Mass Peak for K*^{0}");
    mass1->SetMarkerStyle(20);
    mass1->SetMarkerSize(1.5);
    mass1->SetMarkerColor(1);
    TH1D* width1 = file1->Get("kstar0width");
    width1->SetName("mwWidthScaled");
    width1->SetTitle("Fit Width for K*^{0}");
    width1->SetMarkerStyle(20);
    width1->SetMarkerSize(1.5);
    width1->SetMarkerColor(1);
    TH1D* single1 = file1->Get("ptbin21particle5");
    single1->SetLineColor(1);
    single1->SetMarkerStyle(21);
    single1->SetMarkerSize(0.3);
    single1->SetLineWidth(3);
    TH1D* othersingle1 = file1->Get("ptbin05particle5");
    othersingle1->SetLineColor(1);
    othersingle1->SetMarkerStyle(21);
    othersingle1->SetMarkerSize(0.3);
    othersingle1->SetLineWidth(3);
    TF1* fit1 = single1->GetFunction("fitPTbin2100particle5");
    TF1* otherfit1 = othersingle1->GetFunction("fitPTbin500particle5");
    fit1->SetBit(TF1::kNotDraw);
    fit1->SetLineColor(kGray+3);
    fit1->SetLineWidth(4);
    otherfit1->SetBit(TF1::kNotDraw);
    otherfit1->SetLineColor(kGray+3);
    otherfit1->SetLineWidth(4);

    TFile *file2 = new TFile("20170721_Kstar0bar_masswidth_pf160_scaled_error05.root");
    TH1D* mass2 = file2->Get("kstar0mass");
    mass2->SetName("mwError05");
    mass2->SetTitle("Fit Mass Peak for K*^{-}");
    mass2->SetMarkerStyle(33);
    mass2->SetMarkerSize(1.5);
    mass2->SetLineColor(kGreen-2);
    mass2->SetMarkerColor(kGreen-2);
    TH1D* width2 = file2->Get("kstar0width");
    width2->SetName("mwWidth05");
    width2->SetTitle("Fit Width for K*^{0}");
    width2->SetMarkerStyle(33);
    width2->SetMarkerSize(1.5);
    width2->SetMarkerColor(kGreen-2);
    width2->SetLineColor(kGreen-2);
    TH1D* single2 = file2->Get("ptbin21particle5");
    single2->SetLineColor(17);
    single2->SetFillColor(17);
    single2->SetLineWidth(3);
    TH1D* othersingle2 = file2->Get("ptbin05particle5");
    othersingle2->SetLineColor(17);
    othersingle2->SetFillColor(17);
    othersingle2->SetLineWidth(3);
    TF1* fit2 = single2->GetFunction("fitPTbin2100particle5");
    TF1* otherfit2 = othersingle2->GetFunction("fitPTbin500particle5");
    fit2->SetLineColor(kGreen-2);
    fit2->SetLineStyle(5);
    fit2->SetLineWidth(4);
    otherfit2->SetLineColor(kGreen-2);
    otherfit2->SetLineWidth(4);
    otherfit2->SetLineStyle(5);



    TFile *file3 = new TFile("20170721_Kstar0bar_simplewidth_pf160_scaled_error05.root");
    TH1D* mass3 = file3->Get("kstar0mass");
    mass3->SetName("swError05");
    mass3->SetTitle("simple width, error: 5%");
    mass3->SetMarkerStyle(21);
    mass3->SetMarkerSize(1.5);
    mass3->SetMarkerColor(4);
    mass3->SetLineColor(4);
    TH1D* width3 = file3->Get("kstar0collWidth");
    width3->SetName("swWidth05");
    width3->SetTitle("Fit Width for (K*^{0} + K*^{0})");
    width3->SetMarkerStyle(21);
    width3->SetMarkerSize(1.5);
    width3->SetMarkerColor(4);
    width3->SetLineColor(4);
    TF1* fit3 = file3->Get("fitPTbin2100particle5");
    fit3->SetLineColor(4);
    fit3->SetLineStyle(7);
    fit3->SetLineWidth(4);
    TF1* otherfit3 = file3->Get("fitPTbin500particle5");
    otherfit3->SetLineColor(4);
    otherfit3->SetLineStyle(7);
    otherfit3->SetLineWidth(4);

/*
    TFile *file4 = new TFile("20170522_Kstar0_reconsimplewidth_pf160_error01.root");
    TH1D* mass4 = file4->Get("kstar0mass");
    mass4->SetName("swError10");
    mass4->SetTitle("simple width, error: 10%");
    mass4->SetMarkerStyle(25);
    mass4->SetMarkerSize(1.5);
    mass4->SetMarkerColor(3);
*/
    TFile *file5 = new TFile("20170721_Kstar0bar_fixedwidth42_pf160_scaled_error05.root");
    TH1D* mass5 = file5->Get("kstar0mass");
    mass5->SetName("fwError05");
    mass5->SetTitle("fixed width, error: 5%");
    mass5->SetMarkerStyle(22);
    mass5->SetMarkerSize(1.5);
    mass5->SetMarkerColor(2);
    mass5->SetLineColor(2);
    TH1D* width5 = file5->Get("kstar0collWidth");
    width5->SetName("fwWidth05");
    width5->SetTitle("Fit Width for K*^0");
    width5->SetMarkerStyle(22);
    width5->SetMarkerSize(1.5);
    width5->SetMarkerColor(2);
    width5->SetLineColor(2);
    TF1* fit5 = file5->Get("fitPTbin2100particle5");
    fit5->SetLineColor(2);
    fit5->SetLineStyle(3);
    fit5->SetLineWidth(4);
    TF1* otherfit5 = file5->Get("fitPTbin500particle5");
    otherfit5->SetLineColor(2);
    otherfit5->SetLineStyle(3);
    otherfit5->SetLineWidth(4);
    /*
    TFile *file6 = new TFile("20170522_Kstar0_reconfixedwidth_pf160_error10.root");
    TH1D* mass6 = file6->Get("kstar0mass");
    mass6->SetName("fwError05");
    mass6->SetTitle("fixed width, error: 10%");
    mass6->SetMarkerStyle(26);
    mass6->SetMarkerSize(1.5);
    mass6->SetMarkerColor(3);

    TFile *file7 = new TFile("20170522_Kstar0_reconfixedwidth70_pf160_scaled.root");
    TH1D* mass7 = file7->Get("kstar0mass");
    mass7->SetName("fw70Error05");
    mass7->SetMarkerStyle(22);
    mass7->SetMarkerSize(1.5);
    mass7->SetMarkerColor(kRed+3);
    TH1D* width7 = file7->Get("kstar0collWidth");
    width7->SetName("fw70Width05");
    width7->SetTitle("Fit Width for K*^{0}");
    width7->SetMarkerStyle(22);
    width7->SetMarkerSize(1.5);
    width7->SetMarkerColor(kRed+3);
    width7->SetLineColor(2);
    TF1* fit7 = file7->Get("fitPTbin2100particle5");
    fit7->SetLineColor(kRed+3);
    fit7->SetLineStyle(3);
    fit7->SetLineWidth(3);
*/
   


    TCanvas *cMass = new TCanvas("cMass", "cMass", 50, 50, 600, 600);

    TF1 *pdg = new TF1("pdg", "[0]", 0.0, 4.0);
    pdg->SetParameter(0, 0.892);
    pdg->SetLineStyle(7);
    pdg->SetLineColor(1);
    pdg->SetLineWidth(4);

    TPaveText *pdgtext = new TPaveText(0.5520, 0.5637, 0.8322, 0.6946, "NDC");
    pdgtext->AddText("PHSD vacuum mass");
    pdgtext->SetTextSizePixels(32);
    pdgtext->SetBorderSize(0);
    pdgtext->SetTextFont(42);
    pdgtext->SetFillStyle(0);

    cMass->cd();
    TLegend* legend = new TLegend(0.1611,0.6370,0.4832,0.8935);
    legend->AddEntry(mass1, "Mass Dep. Width", "lpe");
    legend->AddEntry(mass2, "Mass Dep. Width (+5% Error)", "lpe");
    legend->AddEntry(mass3, "Simple Width (+5% Error)", "lpe");
    legend->AddEntry(mass5, "Fixed Vacuum Width (+5% Error)", "lpe");
    legend->SetMargin(0.1);
    legend->SetTextSizePixels(28);
    //legend->AddEntry(mass7, "Fixed Width (70 MeV/c^{2}), 5% Error", "lpe");

    mass1->GetYaxis()->SetRangeUser(0.87, 0.91);
    mass1->GetYaxis()->SetLabelSize(0.06);
    mass1->GetYaxis()->SetTitleOffset(1.3);
    mass1->GetYaxis()->SetTitleSize(0.07);
    mass1->GetYaxis()->SetTitleFont(42);
    mass1->GetYaxis()->SetLabelFont(42);
    mass1->GetXaxis()->SetLabelSize(0.06);
    mass1->GetXaxis()->SetTitleSize(0.07);
    mass1->GetXaxis()->SetLabelFont(42);
    mass1->GetXaxis()->SetTitleFont(42);
    mass1->SetTitle("");
    mass1->Draw("P E1");
    mass3->Draw("SAME P E1");
    //mass4->Draw("SAME");
    mass5->Draw("SAME P E1");
    mass2->Draw("SAME P E1");
    pdg->Draw("SAME");
    pdgtext->Draw("SAME");
    //mass6->Draw("SAME");
    //mass7->Draw("SAME P E1");
    TPaveText *masstext = new TPaveText(0.5520, 0.7208, 0.8389, 0.8517, "NDC");
    masstext->AddText("#bar{K}*^{0} Mass");
    masstext->AddText("At Decay Point");
    //masstext->AddText("Reconstructed");
    masstext->SetBorderSize(0);
    masstext->SetFillStyle(0);
    masstext->SetTextSizePixels(36);
    masstext->SetTextFont(42);
    masstext->Draw();

    legend->Draw();

    TLegend *widthLegend = new TLegend(0.1913,0.6108,0.5134,0.8656);
    widthLegend->AddEntry(width1, "Mass Dep. Width", "lpe");
    widthLegend->AddEntry(width2, "Mass Dep. Width (+5% Error)", "lpe");
    widthLegend->AddEntry(width3, "Simple Width (+5% Error)", "lpe");
    widthLegend->AddEntry(width5, "Fixed Vacuum Width (+5% Error)", "lpe");
    widthLegend->SetTextSizePixels(20);
    //widthLegend->AddEntry(width7, "Fixed Width (70 MeV/c^{2}), 5% Error", "lpw");
    
    TCanvas *cWidth = new TCanvas("cWidth", "cWidth", 60, 60, 600, 600);
    cWidth->cd();
    width1->GetYaxis()->SetLabelSize(0.06);
    width1->GetYaxis()->SetTitleOffset(1.4);
    width1->GetYaxis()->SetRangeUser(0.02, 0.12);
    width1->GetYaxis()->SetTitleSize(0.07);
    width1->GetYaxis()->SetTitleFont(42);
    width1->GetYaxis()->SetLabelFont(42);
    width1->GetXaxis()->SetTitleSize(0.07);
    width1->GetXaxis()->SetLabelSize(0.06);
    width1->GetXaxis()->SetTitleFont(42);
    width1->GetXaxis()->SetLabelFont(42);
    width1->GetYaxis()->SetTitle("Width (GeV/c^{2})");
    width1->SetTitle("");
    width1->Draw("P E1");
    width3->Draw("SAME P E1");
    width1->Draw("SAME P E1");
    width5->Draw("SAME P E1");
    width2->Draw("SAME P E1");
   //width7->Draw("SAME P E1");
    widthLegend->Draw();

    TPaveText *widthtext = new TPaveText(0.5822, 0.7024, 0.8675, 0.8333, "NDC");
    widthtext->AddText("#bar{K}*^{0} Width");
    widthtext->AddText("At Decay Point");
    //widthtext->AddText("Reconstructed");
    widthtext->SetBorderSize(0);
    widthtext->SetFillStyle(0);
    widthtext->SetTextSizePixels(36);
    widthtext->SetTextFont(42);
    widthtext->Draw();

    TExec *exec1 = new TExec("exec1", "gStyle->SetErrorX(0)");
    TExec *exec2 = new TExec("exec2", "gStyle->SetErrorX(0.5)");

    TLegend *singleLegend = new TLegend(0.1376, 0.5585, 0.5201, 0.8778);
    singleLegend->AddEntry(fit1, "Mass Dep. Width", "l");
    singleLegend->AddEntry(fit2, "#splitline{Mass Dep. Width}{+5% Error}", "l");
    singleLegend->AddEntry(fit3, "#splitline{Simple Width}{+5% Error}", "l");
    singleLegend->AddEntry(fit5, "#splitline{Fixed #Gamma = 50 MeV/c^{2}}{+5% Error}", "l");
    singleLegend->SetTextSizePixels(20);
    //singleLegend->AddEntry(fit7, "Fixed Width (70 MeV/c^{2})", "l");
    TCanvas *cSingle = new TCanvas("single", "single", 70, 70, 600, 600);
    cSingle->cd();
    single1->SetStats(kFALSE);
    single1->SetTitle("");
    single1->GetYaxis()->SetTitleOffset(1.50);
    single1->GetYaxis()->SetLabelSize(0.03);
    single1->GetYaxis()->SetTitleSize(0.04);
    single1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
    single1->GetXaxis()->SetRangeUser(0.61, 1.09);
    single1->GetXaxis()->SetLabelSize(0.03);
    single1->GetXaxis()->SetTitleSize(0.04);
    single1->GetXaxis()->SetTitle("K^{+}#pi^{-} invariant mass (GeV/c^{2})");
    single1->Draw("E");
    single2->SetStats(kFALSE);
    single2->GetXaxis()->SetRangeUser(0.61, 1.09);
    single2->Draw("SAME E2");
    fit1->Draw("SAME");
    fit2->Draw("SAME");
    fit3->Draw("SAME");
    fit5->Draw("SAME");
    exec1->Draw();
    single1->Draw("E SAME");
    exec2->Draw();
    //fit7->Draw("SAME");
    TLegend *singleLegend2 = new TLegend(0.1695, 0.4738, 0.4211, 0.5279);
    singleLegend2->AddEntry(single2, "#splitline{Added Error}{(5% of peak bin)}", "f");
    singleLegend2->SetFillStyle(0);
    singleLegend2->SetBorderSize(0);
    singleLegend2->SetTextSizePixels(20);
 
    TPaveText *text = new TPaveText(0.5822, 0.7024, 0.8675, 0.8333, "NDC");
    text->AddText("Reconstructed #bar{K}*^{0}");
    text->AddText("2.0 < p_{T} < 2.2 GeV/c");
    text->SetBorderSize(0);
    text->SetFillStyle(0);
    text->GetLine(1)->SetTextSizePixels(20);
    text->GetLine(0)->SetTextSizePixels(22);
  
    singleLegend->Draw();
    singleLegend2->Draw();
    text->Draw();

    TLegend *othersingleLegend = new TLegend(0.1376, 0.5585, 0.5201, 0.8778);
    othersingleLegend->AddEntry(otherfit1, "Mass Dep. Width", "l");
    othersingleLegend->AddEntry(otherfit2, "#splitline{Mass Dep. Width}{+5% Error}", "l");
    othersingleLegend->AddEntry(otherfit3, "#splitline{Simple Width}{+5% Error}", "l");
    othersingleLegend->AddEntry(otherfit5, "#splitline{Fixed #Gamma = 50 MeV/c^{2}}{+5% Error}", "l");
    //othersingleLegend->SetBorderSize(0);
    //othersingleLegend->SetFillStyle(0);
    othersingleLegend->SetTextSizePixels(20);
    TCanvas *cotherSingle = new TCanvas("othersingle", "othersingle", 70, 70, 600, 600);
    cotherSingle->cd();
    othersingle1->SetStats(kFALSE);
    othersingle1->SetTitle("");
    othersingle1->GetYaxis()->SetTitleOffset(1.50);
    othersingle1->GetYaxis()->SetTitleSize(0.06);
    othersingle1->GetYaxis()->SetLabelSize(0.07);
    othersingle1->GetYaxis()->SetTitleFont(42);
    othersingle1->GetYaxis()->SetLabelFont(42);
    othersingle1->GetYaxis()->SetTitle("Counts / 8 MeV/c^{2}");
    othersingle1->GetXaxis()->SetRangeUser(0.61, 1.09);
    othersingle1->GetXaxis()->SetLabelSize(0.06);
    othersingle1->GetXaxis()->SetTitleSize(0.07);
    othersingle1->GetXaxis()->SetLabelFont(42);
    othersingle1->GetXaxis()->SetTitleFont(42);
    othersingle1->GetXaxis()->SetTitle("K^{+}#pi^{-} invariant mass (GeV/c^{2})");
    othersingle1->Draw("E");
    othersingle2->SetStats(kFALSE);
    othersingle2->GetXaxis()->SetRangeUser(0.61, 1.09);
    othersingle2->Draw("SAME E2");
    otherfit1->Draw("SAME");
    otherfit2->Draw("SAME");
    otherfit3->Draw("SAME");
    otherfit5->Draw("SAME");
    exec1->Draw();
    othersingle1->Draw("E SAME");
    exec2->Draw();
    othersingle1->GetXaxis()->Draw();
    //fit7->Draw("SAME");
    TLegend *othersingleLegend2 = new TLegend(0.1695, 0.4738, 0.4211, 0.5279);
   //othersingleLegend2->AddEntry(othersingle1, "Invariant Mass at Decay Point", "l");
    othersingleLegend2->AddEntry(othersingle2, "#splitline{Added Error}{(5% of peak bin)}", "f");
    othersingleLegend2->SetTextSizePixels(20);
    othersingleLegend2->SetBorderSize(0);
    othersingleLegend2->SetFillStyle(0);
   
    TPaveText *othertext = new TPaveText(0.5882, 0.7024, 0.8675, 0.8333, "NDC");
    othertext->AddText("Reconstructed K*^{0}");
    othertext->AddText("0.4 < p_{T} < 0.6 GeV/c");
    othertext->GetLine(0)->SetTextSizePixels(22);
    othertext->GetLine(1)->SetTextSizePixels(20);
    othertext->SetBorderSize(0);
    othertext->SetFillStyle(0);

    othersingleLegend->Draw();
    othersingleLegend2->Draw();
    othertext->Draw();  

    //testing drawing mass and width on same plot
    TCanvas* cMassWidth = new TCanvas("cmasswidth", "cmasswidth", 50, 50, 1000, 500);
    cMassWidth->SetMargin(0.0, 0.0, 0.0, 0.0);

    cMassWidth->Divide(2, 1, 0.0);
    
    cMassWidth->cd(1)->SetMargin(0.1827, 0.0, 0.1543, 0.0994);
    cMassWidth->cd(1)->SetTicks(0,1);
   
    mass1->Draw("P E1");
    mass3->Draw("SAME P E1");
    //mass4->Draw("SAME");
    mass5->Draw("SAME P E1");
    mass2->Draw("SAME P E1");
    pdg->Draw("SAME");
    pdgtext->Draw("SAME");
    masstext->Draw();
    legend->Draw();

    cMassWidth->cd(2)->SetMargin(0.0, 0.1968, 0.1543, 0.0994);
    cMassWidth->cd(2)->SetTicks(0,1);

    width1->Draw("P E1 Y+");
    width3->Draw("SAME P E1");
    width1->Draw("SAME P E1");
    width5->Draw("SAME P E1");
    width2->Draw("SAME P E1");
    //widthLegend->Draw("SAME");
    widthtext->Draw();


}
Exemple #10
0
void generatePlots(Files *inputs, const string &path)
{
    Files::const_iterator first_source = inputs->begin();
    TDirectory *folder = dynamic_cast<TDirectory *>(first_source->second->Get(path.c_str()));
    if (!folder)
    {
        cerr << "Failed to extract folder: " << path << endl;

        return;
    }
    //
    //gain time, do not add the objects in the list in memory
    //
    Bool_t status = TH1::AddDirectoryStatus();
    TH1::AddDirectory(kFALSE);

    // loop over all keys in this directory
    TIter nextkey(folder->GetListOfKeys() );

    for(TKey *key, *oldkey=0; key = (TKey*) nextkey(); )
    {
        //keep only the highest cycle number for each key
        if (oldkey
            && !strcmp(oldkey->GetName(), key->GetName()))

            continue;

        // read object from first source file
        //
        TObject *obj = key->ReadObj();

        if ( obj->IsA()->InheritsFrom(TH1::Class()))
        {
            cout << obj->GetName() << endl;

            TCanvas *canvas = new TCanvas();

            canvas->SetWindowSize(640, 480);

            THStack *stack = new THStack();
            TLegend  *legend = new TLegend(.6, .98, .98, .58);
            legend->SetBorderSize(1);
            legend->SetLineStyle(1);
            legend->SetTextFont(43);
            legend->SetTextSizePixels(12);
            legend->SetFillColor(0);

            TH1 *h1 = dynamic_cast<TH1*>(obj);
            legend->AddEntry(h1, style(h1, first_source->first).c_str(), "pl");
            h1->Scale(1.0 / h1->Integral());

            stack->Add(h1);

            // loop over all source files and add the content of the
            // correspondant histogram to the one pointed to by "h1"
            for(Files::const_iterator input = ++inputs->begin();
                    inputs->end() != input;
                    ++input)
            {
                TH1 *h2 = dynamic_cast<TH1*>(input->second->Get((path + "/" + obj->GetName()).c_str()));
                if (!h2)
                {
                    cerr << "Failed to extract plot from input: " << endl;

                    continue;
                }

                h2->Scale(1. / h2->Integral());
                legend->AddEntry(h2, style(h2, input->first).c_str(), "pl");
                stack->Add(h2);
            }

            stack->Draw("h nostack");
            legend->Draw();
            stack->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());

            canvas->Update();
        } else {
            // object is of no type that we know or can handle
            //
            cout << "Unknown object type, name: "
                << obj->GetName() << " title: " << obj->GetTitle() << endl;
        }
    }

    // save modifications to target file
    TH1::AddDirectory(status);
}