void showEfficiency(const TString& title, double canvasSizeX, double canvasSizeY, const TH1* histogram1_numerator, const TH1* histogram1_denominator, const std::string& legendEntry1, const TH1* histogram2_numerator, const TH1* histogram2_denominator, const std::string& legendEntry2, const TH1* histogram3_numerator, const TH1* histogram3_denominator, const std::string& legendEntry3, const TH1* histogram4_numerator, const TH1* histogram4_denominator, const std::string& legendEntry4, const TH1* histogram5_numerator, const TH1* histogram5_denominator, const std::string& legendEntry5, const TH1* histogram6_numerator, const TH1* histogram6_denominator, const std::string& legendEntry6, const std::string& xAxisTitle, double xAxisOffset, bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, double legendX0, double legendY0, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); canvas->SetLogy(useLogScale); canvas->SetGridx(); canvas->SetGridy(); TH1* dummyHistogram = new TH1D("dummyHistogram_top", "dummyHistogram_top", 10, histogram1_numerator->GetXaxis()->GetXmin(), histogram1_numerator->GetXaxis()->GetXmax()); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMaximum(yMax); dummyHistogram->SetMinimum(yMin); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw(); int colors[6] = { 1, 2, 3, 4, 6, 7 }; int markerStyles[6] = { 22, 32, 20, 24, 21, 25 }; int numGraphs = 1; if ( histogram2_numerator && histogram2_denominator ) ++numGraphs; if ( histogram3_numerator && histogram3_denominator ) ++numGraphs; if ( histogram4_numerator && histogram4_denominator ) ++numGraphs; if ( histogram5_numerator && histogram5_denominator ) ++numGraphs; if ( histogram6_numerator && histogram6_denominator ) ++numGraphs; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.18, legendY0 + 0.05*numGraphs, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); TGraphAsymmErrors* graph1 = getEfficiency(histogram1_numerator, histogram1_denominator); graph1->SetLineColor(colors[0]); graph1->SetMarkerColor(colors[0]); graph1->SetMarkerStyle(markerStyles[0]); graph1->Draw("p"); legend->AddEntry(graph1, legendEntry1.data(), "p"); TGraphAsymmErrors* graph2 = 0; if ( histogram2_numerator && histogram2_denominator ) { graph2 = getEfficiency(histogram2_numerator, histogram2_denominator); graph2->SetLineColor(colors[1]); graph2->SetMarkerColor(colors[1]); graph2->SetMarkerStyle(markerStyles[1]); graph2->Draw("p"); legend->AddEntry(graph2, legendEntry2.data(), "p"); } TGraphAsymmErrors* graph3 = 0; if ( histogram3_numerator && histogram3_denominator ) { graph3 = getEfficiency(histogram3_numerator, histogram3_denominator); graph3->SetLineColor(colors[2]); graph3->SetMarkerColor(colors[2]); graph3->SetMarkerStyle(markerStyles[2]); graph3->Draw("p"); legend->AddEntry(graph3, legendEntry3.data(), "p"); } TGraphAsymmErrors* graph4 = 0; if ( histogram4_numerator && histogram4_denominator ) { graph4 = getEfficiency(histogram4_numerator, histogram4_denominator); graph4->SetLineColor(colors[3]); graph4->SetMarkerColor(colors[3]); graph4->SetMarkerStyle(markerStyles[3]); graph4->Draw("p"); legend->AddEntry(graph4, legendEntry4.data(), "p"); } TGraphAsymmErrors* graph5 = 0; if ( histogram5_numerator && histogram5_denominator ) { graph5 = getEfficiency(histogram5_numerator, histogram5_denominator); graph5->SetLineColor(colors[4]); graph5->SetMarkerColor(colors[4]); graph5->SetMarkerStyle(markerStyles[4]); graph5->Draw("p"); legend->AddEntry(graph5, legendEntry5.data(), "p"); } TGraphAsymmErrors* graph6 = 0; if ( histogram6_numerator && histogram6_denominator ) { graph6 = getEfficiency(histogram6_numerator, histogram6_denominator); graph6->SetLineColor(colors[5]); graph6->SetMarkerColor(colors[5]); graph6->SetMarkerStyle(markerStyles[5]); graph6->Draw("p"); legend->AddEntry(graph6, legendEntry6.data(), "p"); } legend->Draw(); TPaveText* label = 0; if ( title.Length() > 0 ) { label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC"); label->AddText(title.Data()); label->SetTextAlign(13); label->SetTextSize(0.045); label->SetFillStyle(0); label->SetBorderSize(0); label->Draw(); } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data()); canvas->Print(std::string(outputFileName_plot).append(".png").data()); canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); delete legend; delete label; delete dummyHistogram; delete canvas; }
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(); }
void HTT_ET_X(bool scaled=true, bool log=true, float min=0.1, float max=-1., string inputfile="root/$HISTFILE", const char* directory="eleTau_$CATEGORY") { // defining the common canvas, axes pad styles SetStyle(); gStyle->SetLineStyleString(11,"20 10"); // determine category tag const char* category = ""; const char* category_extra = ""; const char* category_extra2 = ""; if(std::string(directory) == std::string("eleTau_0jet_low" )){ category = "e#tau_{h}, 0 jet"; } if(std::string(directory) == std::string("eleTau_0jet_low" )){ category_extra = "p_{T}(#tau) low"; } if(std::string(directory) == std::string("eleTau_0jet_medium" )){ category = "e#tau_{h}, 0 jet"; } if(std::string(directory) == std::string("eleTau_0jet_medium" )){ category_extra = "p_{T}(#tau) medium"; } if(std::string(directory) == std::string("eleTau_0jet_high" )){ category = "e#tau_{h}, 0 jet"; } if(std::string(directory) == std::string("eleTau_0jet_high" )){ category_extra = "p_{T}(#tau) high"; } if(std::string(directory) == std::string("eleTau_1jet_medium" )){ category = "e#tau_{h}, 1 jet"; } if(std::string(directory) == std::string("eleTau_1jet_medium" )){ category_extra = "p_{T}(#tau) medium"; } if(std::string(directory) == std::string("eleTau_1jet_high_lowhiggs" )){ category = "e#tau_{h}, 1 jet"; } if(std::string(directory) == std::string("eleTau_1jet_high_lowhiggs" )){ category_extra= "p_{T}(#tau) high"; } if(std::string(directory) == std::string("eleTau_1jet_high_lowhiggs" )){ category_extra2= "p_{T}(H) low"; } if(std::string(directory) == std::string("eleTau_1jet_high_mediumhiggs")){ category = "e#tau_{h}, 1 jet"; } if(std::string(directory) == std::string("eleTau_1jet_high_mediumhiggs")){ category_extra= "p_{T}(#tau) high"; } if(std::string(directory) == std::string("eleTau_1jet_high_mediumhiggs")){ category_extra2= "p_{T}(H) med."; } if(std::string(directory) == std::string("eleTau_vbf_loose" )){ category = "e#tau_{h}, 2 jet"; } if(std::string(directory) == std::string("eleTau_vbf_loose" )){ category_extra = "VBF, loose"; } if(std::string(directory) == std::string("eleTau_vbf_tight" )){ category = "e#tau_{h}, 2 jet"; } if(std::string(directory) == std::string("eleTau_vbf_tight" )){ category_extra = "VBF, tight"; } if(std::string(directory) == std::string("eleTau_nobtag" )){ category = "e#tau_{h}"; } if(std::string(directory) == std::string("eleTau_nobtag" )){ category_extra = "No B-Tag"; } if(std::string(directory) == std::string("eleTau_btag" )){ category = "e#tau_{h}"; } if(std::string(directory) == std::string("eleTau_btag" )){ category_extra = "B-Tag"; } const char* dataset; if(std::string(inputfile).find("7TeV")!=std::string::npos){dataset = "CMS Preliminary, H#rightarrow#tau#tau, 4.9 fb^{-1} at 7 TeV";} if(std::string(inputfile).find("8TeV")!=std::string::npos){dataset = "CMS Preliminary, H#rightarrow#tau#tau, 19.7 fb^{-1} at 8 TeV";} TFile* input = new TFile(inputfile.c_str()); #ifdef MSSM TFile* input2 = new TFile((inputfile+"_$MA_$TANB").c_str()); #endif TH1F* Fakes = refill((TH1F*)input->Get(TString::Format("%s/QCD" , directory)), "QCD"); InitHist(Fakes, "", "", kMagenta-10, 1001); TH1F* EWK0 = refill((TH1F*)input->Get(TString::Format("%s/VV" , directory)), "VV" ); InitHist(EWK0 , "", "", kRed + 2, 1001); TH1F* EWK1 = refill((TH1F*)input->Get(TString::Format("%s/W" , directory)), "W" ); InitHist(EWK1 , "", "", kRed + 2, 1001); #ifdef EXTRA_SAMPLES TH1F* EWK2 = refill((TH1F*)input->Get(TString::Format("%s/ZJ" , directory)), "ZJ" ); InitHist(EWK2 , "", "", kAzure + 2, 1001); TH1F* EWK = refill((TH1F*)input->Get(TString::Format("%s/ZL" , directory)), "ZL" ); InitHist(EWK , "", "", kAzure + 2, 1001); #else TH1F* EWK = refill((TH1F*)input->Get(TString::Format("%s/ZLL" , directory)), "ZLL"); InitHist(EWK , "", "", kAzure + 2, 1001); #endif TH1F* ttbar = refill((TH1F*)input->Get(TString::Format("%s/TT" , directory)), "TT" ); InitHist(ttbar, "", "", kBlue - 8, 1001); TH1F* Ztt = refill((TH1F*)input->Get(TString::Format("%s/ZTT" , directory)), "ZTT"); InitHist(Ztt , "", "", kOrange - 4, 1001); #ifdef MSSM TH1F* ggH = refill((TH1F*)input2->Get(TString::Format("%s/ggH$MA" , directory)), "ggH"); InitSignal(ggH); ggH->Scale($TANB); TH1F* bbH = refill((TH1F*)input2->Get(TString::Format("%s/bbH$MA" , directory)), "bbH"); InitSignal(bbH); bbH->Scale($TANB); #else #ifndef DROP_SIGNAL TH1F* ggH = refill((TH1F*)input->Get(TString::Format("%s/ggH125" , directory)), "ggH"); InitSignal(ggH); ggH->Scale(SIGNAL_SCALE); TH1F* qqH = refill((TH1F*)input->Get(TString::Format("%s/qqH125" , directory)), "qqH"); InitSignal(qqH); qqH->Scale(SIGNAL_SCALE); TH1F* VH = refill((TH1F*)input->Get(TString::Format("%s/VH125" , directory)), "VH" ); InitSignal(VH ); VH ->Scale(SIGNAL_SCALE); #endif #endif #ifdef ASIMOV TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs_asimov", directory)), "data", true); #else TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs", directory)), "data", true); #endif InitHist(data, "#bf{m_{#tau#tau} [GeV]}", "#bf{dN/dm_{#tau#tau} [1/GeV]}"); InitData(data); TH1F* ref=(TH1F*)Fakes->Clone("ref"); ref->Add(EWK0 ); ref->Add(EWK1 ); #ifdef EXTRA_SAMPLES ref->Add(EWK2 ); #endif ref->Add(EWK ); ref->Add(ttbar); ref->Add(Ztt ); double unscaled[7]; unscaled[0] = Fakes->Integral(); unscaled[1] = EWK ->Integral(); unscaled[1]+= EWK0 ->Integral(); unscaled[1]+= EWK1 ->Integral(); #ifdef EXTRA_SAMPLES unscaled[1]+= EWK2 ->Integral(); #endif unscaled[2] = ttbar->Integral(); unscaled[3] = Ztt ->Integral(); #ifdef MSSM unscaled[4] = ggH ->Integral(); unscaled[5] = bbH ->Integral(); unscaled[6] = 0; #else #ifndef DROP_SIGNAL unscaled[4] = ggH ->Integral(); unscaled[5] = qqH ->Integral(); unscaled[6] = VH ->Integral(); #endif #endif if(scaled){ rescale(Fakes, 7); rescale(EWK0 , 6); rescale(EWK1 , 3); #ifdef EXTRA_SAMPLES rescale(EWK2 , 4); rescale(EWK , 5); #else rescale(EWK , 4); #endif rescale(ttbar, 2); rescale(Ztt , 1); #ifdef MSSM rescale(ggH , 8); rescale(bbH , 9); #else #ifndef DROP_SIGNAL rescale(ggH , 8); rescale(qqH , 9); rescale(VH ,10); #endif #endif } TH1F* scales[7]; scales[0] = new TH1F("scales-Fakes", "", 7, 0, 7); scales[0]->SetBinContent(1, unscaled[0]>0 ? (Fakes->Integral()/unscaled[0]-1.) : 0.); scales[1] = new TH1F("scales-EWK" , "", 7, 0, 7); scales[1]->SetBinContent(2, unscaled[1]>0 ? ((EWK ->Integral() +EWK0 ->Integral() +EWK1 ->Integral() #ifdef EXTRA_SAMPLES +EWK2 ->Integral() #endif )/unscaled[1]-1.) : 0.); scales[2] = new TH1F("scales-ttbar", "", 7, 0, 7); scales[2]->SetBinContent(3, unscaled[2]>0 ? (ttbar->Integral()/unscaled[2]-1.) : 0.); scales[3] = new TH1F("scales-Ztt" , "", 7, 0, 7); scales[3]->SetBinContent(4, unscaled[3]>0 ? (Ztt ->Integral()/unscaled[3]-1.) : 0.); #ifdef MSSM scales[4] = new TH1F("scales-ggH" , "", 7, 0, 7); scales[4]->SetBinContent(5, unscaled[4]>0 ? (ggH ->Integral()/unscaled[4]-1.) : 0.); scales[5] = new TH1F("scales-bbH" , "", 7, 0, 7); scales[5]->SetBinContent(6, unscaled[5]>0 ? (bbH ->Integral()/unscaled[5]-1.) : 0.); scales[6] = new TH1F("scales-NONE" , "", 7, 0, 7); scales[6]->SetBinContent(7, 0.); #else #ifndef DROP_SIGNAL scales[4] = new TH1F("scales-ggH" , "", 7, 0, 7); scales[4]->SetBinContent(5, unscaled[4]>0 ? (ggH ->Integral()/unscaled[4]-1.) : 0.); scales[5] = new TH1F("scales-qqH" , "", 7, 0, 7); scales[5]->SetBinContent(6, unscaled[5]>0 ? (qqH ->Integral()/unscaled[5]-1.) : 0.); scales[6] = new TH1F("scales-VH" , "", 7, 0, 7); scales[6]->SetBinContent(7, unscaled[6]>0 ? (VH ->Integral()/unscaled[6]-1.) : 0.); #endif #endif EWK0 ->Add(Fakes); EWK1 ->Add(EWK0 ); #ifdef EXTRA_SAMPLES EWK2 ->Add(EWK1 ); EWK ->Add(EWK2 ); #else EWK ->Add(EWK1 ); #endif ttbar->Add(EWK ); Ztt ->Add(ttbar); if(log){ #ifdef MSSM ggH ->Add(bbH); #else #ifndef DROP_SIGNAL qqH ->Add(VH ); ggH ->Add(qqH); #endif #endif } else{ #ifdef MSSM bbH ->Add(Ztt); ggH ->Add(bbH); #else #ifndef DROP_SIGNAL VH ->Add(Ztt); qqH ->Add(VH ); ggH ->Add(qqH); #endif #endif } /* Mass plot before and after fit */ TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600); canv->cd(); if(log){ canv->SetLogy(1); } #if defined MSSM if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(345)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(UPPER_EDGE)); }; #else data->GetXaxis()->SetRange(0, data->FindBin(345)); #endif data->SetNdivisions(505); data->SetMinimum(min); #ifndef DROP_SIGNAL data->SetMaximum(max>0 ? max : std::max(std::max(maximum(data, log), maximum(Ztt, log)), maximum(ggH, log))); #else data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(Ztt, log))); #endif data->Draw("e"); TH1F* errorBand = (TH1F*)Ztt ->Clone("errorBand"); errorBand ->SetMarkerSize(0); errorBand ->SetFillColor(1); errorBand ->SetFillStyle(3013); errorBand ->SetLineWidth(1); for(int idx=0; idx<errorBand->GetNbinsX(); ++idx){ if(errorBand->GetBinContent(idx)>0){ std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl; break; } } if(log){ Ztt ->Draw("histsame"); ttbar->Draw("histsame"); EWK ->Draw("histsame"); EWK1 ->Draw("histsame"); Fakes->Draw("histsame"); $DRAW_ERROR #ifndef DROP_SIGNAL ggH ->Draw("histsame"); #endif } else{ #ifndef DROP_SIGNAL ggH ->Draw("histsame"); #endif Ztt ->Draw("histsame"); ttbar->Draw("histsame"); EWK ->Draw("histsame"); EWK1 ->Draw("histsame"); Fakes->Draw("histsame"); $DRAW_ERROR } data->Draw("esame"); canv->RedrawAxis(); //CMSPrelim(dataset, "#tau_{e}#tau_{h}", 0.17, 0.835); CMSPrelim(dataset, "", 0.16, 0.835); TPaveText* chan = new TPaveText(0.20, (category_extra2 && category_extra2[0]=='\0') ? 0.65+0.061 : 0.65+0.061, 0.32, 0.75+0.161, "tlbrNDC"); chan->SetBorderSize( 0 ); chan->SetFillStyle( 0 ); chan->SetTextAlign( 12 ); chan->SetTextSize ( 0.05 ); chan->SetTextColor( 1 ); chan->SetTextFont ( 62 ); chan->AddText(category); chan->AddText(category_extra); chan->AddText(category_extra2); chan->Draw(); /* TPaveText* cat = new TPaveText(0.20, 0.71+0.061, 0.32, 0.71+0.161, "NDC"); cat->SetBorderSize( 0 ); cat->SetFillStyle( 0 ); cat->SetTextAlign( 12 ); cat->SetTextSize ( 0.05 ); cat->SetTextColor( 1 ); cat->SetTextFont ( 62 ); cat->AddText(category_extra); cat->Draw(); TPaveText* cat2 = new TPaveText(0.20, 0.66+0.061, 0.32, 0.66+0.161, "NDC"); cat2->SetBorderSize( 0 ); cat2->SetFillStyle( 0 ); cat2->SetTextAlign( 12 ); cat2->SetTextSize ( 0.05 ); cat2->SetTextColor( 1 ); cat2->SetTextFont ( 62 ); cat2->AddText(category_extra2); cat2->Draw(); */ #ifdef MSSM TPaveText* massA = new TPaveText(0.53, 0.50+0.061, 0.95, 0.50+0.161, "NDC"); massA->SetBorderSize( 0 ); massA->SetFillStyle( 0 ); massA->SetTextAlign( 12 ); massA->SetTextSize ( 0.03 ); massA->SetTextColor( 1 ); massA->SetTextFont ( 62 ); massA->AddText("m^{h}_{max} (m_{A}=$MA GeV, tan#beta=$TANB)"); massA->Draw(); #endif #ifdef MSSM TLegend* leg = new TLegend(0.53, 0.65, 0.95, 0.90); SetLegendStyle(leg); leg->AddEntry(ggH , "#phi#rightarrow#tau#tau" , "L" ); #else TLegend* leg = new TLegend(0.50, 0.65, 0.95, 0.90); SetLegendStyle(leg); #ifndef DROP_SIGNAL if(SIGNAL_SCALE!=1){ leg->AddEntry(ggH , TString::Format("%.0f#timesH(125 GeV)#rightarrow#tau#tau", SIGNAL_SCALE) , "L" ); } else{ leg->AddEntry(ggH , "H(125 GeV)#rightarrow#tau#tau" , "L" ); } #endif #endif #ifdef ASIMOV leg->AddEntry(data , "sum(bkg) + H(125)" , "LP"); #else leg->AddEntry(data , "observed" , "LP"); #endif leg->AddEntry(Ztt , "Z#rightarrow#tau#tau" , "F" ); leg->AddEntry(EWK , "Z#rightarrow ee" , "F" ); leg->AddEntry(EWK1 , "W+jets" , "F" ); leg->AddEntry(ttbar, "t#bar{t}" , "F" ); leg->AddEntry(Fakes, "QCD" , "F" ); $ERROR_LEGEND leg->Draw(); /* Ratio Data over MC */ TCanvas *canv0 = MakeCanvas("canv0", "histograms", 600, 400); canv0->SetGridx(); canv0->SetGridy(); canv0->cd(); TH1F* model = (TH1F*)Ztt ->Clone("model"); TH1F* test1 = (TH1F*)data->Clone("test1"); for(int ibin=0; ibin<test1->GetNbinsX(); ++ibin){ //the small value in case of 0 entries in the model is added to prevent the chis2 test from failing model->SetBinContent(ibin+1, model->GetBinContent(ibin+1)>0 ? model->GetBinContent(ibin+1)*model->GetBinWidth(ibin+1) : 0.01); model->SetBinError (ibin+1, CONVERVATIVE_CHI2 ? 0. : model->GetBinError (ibin+1)*model->GetBinWidth(ibin+1)); test1->SetBinContent(ibin+1, test1->GetBinContent(ibin+1)*test1->GetBinWidth(ibin+1)); test1->SetBinError (ibin+1, test1->GetBinError (ibin+1)*test1->GetBinWidth(ibin+1)); } double chi2prob = test1->Chi2Test (model,"PUW"); std::cout << "chi2prob:" << chi2prob << std::endl; double chi2ndof = test1->Chi2Test (model,"CHI2/NDFUW"); std::cout << "chi2ndf :" << chi2ndof << std::endl; double ksprob = test1->KolmogorovTest(model); std::cout << "ksprob :" << ksprob << std::endl; double ksprobpe = test1->KolmogorovTest(model,"DX"); std::cout << "ksprobpe:" << ksprobpe << std::endl; std::vector<double> edges; TH1F* zero = (TH1F*)ref->Clone("zero"); zero->Clear(); TH1F* rat1 = (TH1F*)data->Clone("rat1"); for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin){ rat1->SetBinContent(ibin+1, Ztt->GetBinContent(ibin+1)>0 ? data->GetBinContent(ibin+1)/Ztt->GetBinContent(ibin+1) : 0); rat1->SetBinError (ibin+1, Ztt->GetBinContent(ibin+1)>0 ? data->GetBinError (ibin+1)/Ztt->GetBinContent(ibin+1) : 0); zero->SetBinContent(ibin+1, 0.); zero->SetBinError (ibin+1, Ztt->GetBinContent(ibin+1)>0 ? Ztt ->GetBinError (ibin+1)/Ztt->GetBinContent(ibin+1) : 0); } for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin){ if(rat1->GetBinContent(ibin+1)>0){ edges.push_back(TMath::Abs(rat1->GetBinContent(ibin+1)-1.)+TMath::Abs(rat1->GetBinError(ibin+1))); // catch cases of 0 bins, which would lead to 0-alpha*0-1 rat1->SetBinContent(ibin+1, rat1->GetBinContent(ibin+1)-1.); } } float range = 0.1; std::sort(edges.begin(), edges.end()); if (edges[edges.size()-2]>0.1) { range = 0.2; } if (edges[edges.size()-2]>0.2) { range = 0.5; } if (edges[edges.size()-2]>0.5) { range = 1.0; } if (edges[edges.size()-2]>1.0) { range = 1.5; } if (edges[edges.size()-2]>1.5) { range = 2.0; } rat1->SetLineColor(kBlack); rat1->SetFillColor(kGray ); rat1->SetMaximum(+range); rat1->SetMinimum(-range); rat1->GetYaxis()->CenterTitle(); rat1->GetYaxis()->SetTitle("#bf{Data/MC-1}"); rat1->GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]}"); rat1->Draw(); zero->SetFillStyle( 3013); zero->SetFillColor(kBlack); zero->SetLineColor(kBlack); zero->SetMarkerSize(0.1); zero->Draw("e2histsame"); canv0->RedrawAxis(); TPaveText* stat1 = new TPaveText(0.20, 0.76+0.061, 0.32, 0.76+0.161, "NDC"); stat1->SetBorderSize( 0 ); stat1->SetFillStyle( 0 ); stat1->SetTextAlign( 12 ); stat1->SetTextSize ( 0.05 ); stat1->SetTextColor( 1 ); stat1->SetTextFont ( 62 ); stat1->AddText(TString::Format("#chi^{2}/ndf=%.3f, P(#chi^{2})=%.3f", chi2ndof, chi2prob)); //stat1->AddText(TString::Format("#chi^{2}/ndf=%.3f, P(#chi^{2})=%.3f, P(KS)=%.3f", chi2ndof, chi2prob, ksprob)); stat1->Draw(); /* Ratio After fit over Prefit */ TCanvas *canv1 = MakeCanvas("canv1", "histograms", 600, 400); canv1->SetGridx(); canv1->SetGridy(); canv1->cd(); edges.clear(); TH1F* rat2 = (TH1F*) Ztt->Clone("rat2"); for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin){ rat2->SetBinContent(ibin+1, ref->GetBinContent(ibin+1)>0 ? Ztt->GetBinContent(ibin+1)/ref->GetBinContent(ibin+1) : 0); rat2->SetBinError (ibin+1, ref->GetBinContent(ibin+1)>0 ? Ztt->GetBinError (ibin+1)/ref->GetBinContent(ibin+1) : 0); } for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin){ if(rat2->GetBinContent(ibin+1)>0){ edges.push_back(TMath::Abs(rat2->GetBinContent(ibin+1)-1.)+TMath::Abs(rat2->GetBinError(ibin+1))); // catch cases of 0 bins, which would lead to 0-alpha*0-1 rat2 ->SetBinContent(ibin+1, rat2->GetBinContent(ibin+1)-1.); } } range = 0.1; std::sort(edges.begin(), edges.end()); if (edges[edges.size()-2]>0.1) { range = 0.2; } if (edges[edges.size()-2]>0.2) { range = 0.5; } if (edges[edges.size()-2]>0.5) { range = 1.0; } if (edges[edges.size()-2]>1.0) { range = 1.5; } if (edges[edges.size()-2]>1.5) { range = 2.0; } #if defined MSSM if(!log){ rat2->GetXaxis()->SetRange(0, rat2->FindBin(345)); } else{ rat2->GetXaxis()->SetRange(0, rat2->FindBin(UPPER_EDGE)); }; #else rat2->GetXaxis()->SetRange(0, rat2->FindBin(345)); #endif rat2->SetNdivisions(505); rat2->SetLineColor(kRed+ 3); rat2->SetMarkerColor(kRed+3); rat2->SetMarkerSize(1.1); rat2->SetMaximum(+range); rat2->SetMinimum(-range); rat2->GetYaxis()->SetTitle("#bf{Postfit/Prefit-1}"); rat2->GetYaxis()->CenterTitle(); rat2->GetXaxis()->SetTitle("#bf{m_{#tau#tau} [GeV]}"); rat2->Draw(); zero->SetFillStyle( 3013); zero->SetFillColor(kBlack); zero->SetLineColor(kBlack); zero->Draw("e2histsame"); canv1->RedrawAxis(); /* Relative shift per sample */ TCanvas *canv2 = MakeCanvas("canv2", "histograms", 600, 400); canv2->SetGridx(); canv2->SetGridy(); canv2->cd(); InitHist (scales[0], "", "", kMagenta-10, 1001); InitHist (scales[1], "", "", kRed + 2, 1001); InitHist (scales[2], "", "", kBlue - 8, 1001); InitHist (scales[3], "", "", kOrange - 4, 1001); #ifndef DROP_SIGNAL InitSignal(scales[4]); InitSignal(scales[5]); InitSignal(scales[6]); #endif scales[0]->Draw(); scales[0]->GetXaxis()->SetBinLabel(1, "#bf{Fakes}"); scales[0]->GetXaxis()->SetBinLabel(2, "#bf{EWK}" ); scales[0]->GetXaxis()->SetBinLabel(3, "#bf{ttbar}"); scales[0]->GetXaxis()->SetBinLabel(4, "#bf{Ztt}" ); #ifdef MSSM scales[0]->GetXaxis()->SetBinLabel(5, "#bf{ggH}" ); scales[0]->GetXaxis()->SetBinLabel(6, "#bf{bbH}" ); scales[0]->GetXaxis()->SetBinLabel(7, "NONE" ); #else scales[0]->GetXaxis()->SetBinLabel(5, "#bf{ggH}" ); scales[0]->GetXaxis()->SetBinLabel(6, "#bf{qqH}" ); scales[0]->GetXaxis()->SetBinLabel(7, "#bf{VH}" ); #endif scales[0]->SetMaximum(+0.5); scales[0]->SetMinimum(-0.5); scales[0]->GetYaxis()->CenterTitle(); scales[0]->GetYaxis()->SetTitle("#bf{Postfit/Prefit-1}"); scales[1]->Draw("same"); scales[2]->Draw("same"); scales[3]->Draw("same"); #ifndef DROP_SIGNAL scales[4]->Draw("same"); scales[5]->Draw("same"); scales[6]->Draw("same"); #endif TH1F* zero_samples = (TH1F*)scales[0]->Clone("zero_samples"); zero_samples->Clear(); zero_samples->SetBinContent(1,0.); zero_samples->Draw("same"); canv2->RedrawAxis(); /* prepare output */ bool isSevenTeV = std::string(inputfile).find("7TeV")!=std::string::npos; canv ->Print(TString::Format("%s_%sfit_%s_%s.png" , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv ->Print(TString::Format("%s_%sfit_%s_%s.pdf" , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv ->Print(TString::Format("%s_%sfit_%s_%s.eps" , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); if(!log || FULLPLOTS) { canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); } if((!log && scaled) || FULLPLOTS) { canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); } TFile* output = new TFile(TString::Format("%s_%sfit_%s_%s.root", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"), "update"); output->cd(); data ->Write("data_obs"); Fakes->Write("Fakes" ); EWK ->Write("EWK" ); EWK1 ->Write("EWK1" ); ttbar->Write("ttbar" ); Ztt ->Write("Ztt" ); #ifdef MSSM ggH ->Write("ggH" ); bbH ->Write("bbH" ); #else #ifndef DROP_SIGNAL ggH ->Write("ggH" ); qqH ->Write("qqH" ); VH ->Write("VH" ); #endif #endif if(errorBand){ errorBand->Write("errorBand"); } output->Close(); delete errorBand; delete model; delete test1; delete zero; delete rat1; delete rat2; delete zero_samples; delete ref; }
int extractSignificanceStats( bool unblind=true, TString legALT="2^{+}_{m}(gg)", TString nameALT="2pmgg", TString input="qmu_*.root", int rebin=500, float xlow=-10., float xhigh=10. ){ float labelCLs=0; gStyle->SetPalette(1); gStyle->SetOptStat(0); setTDRStyle(); TChain* t = new TChain("q"); t->Add(input); float q,m,w; int type; t->SetBranchAddress("q",&q); t->SetBranchAddress("mh",&m); t->SetBranchAddress("weight",&w); t->SetBranchAddress("type",&type); unsigned long ntoysALT = t->Draw("","type>0","goff"); unsigned long ntoysSM = t->Draw("","type<0","goff"); TH1F *hSM=new TH1F("hSM;S = -2 #times ln(L_{ALT}/L_{SM});Number of Toys","",32000,xlow,xhigh); TH1F *hALT=new TH1F("hALT;S = -2 #times ln(L_{ALT}/L_{SM});Number of Toys","",32000,xlow,xhigh); TH1F *hObs=new TH1F("hObserved","",32000,xlow,xhigh); std::vector<float> vSM, vALT,vObs; int counterData=0; for(int i=0;i<t->GetEntries();i++){ t->GetEntry(i); if(i==0) cout<<"MASS in the TREE = "<<m<<endl<<endl; q *= -2.0; if(type<0){ //SM hypothesis hSM->Fill(q); vSM.push_back(q); } else if(type>0){//ALT hypothesis hALT->Fill(q); vALT.push_back(q); } else{ counterData++; hObs->Fill(q); //cout<<"DATA -q ="<<q<<endl; vObs.push_back(q); } }//end loop on tree entries //cout<<"Finished to loop, sorting vectors "<<vSM.size()<<" "<<vALT.size()<<" "<<vObs.size()<<endl; sort(vSM.begin(),vSM.end());//sort in ascending order sort(vALT.begin(),vALT.end()); sort(vObs.begin(),vObs.end()); if(vALT.at(0)>vSM.at(ntoysSM-1)){ cout<<"Swapped distributions !!! The alternative model should stay on the negative side of the significance."<<endl; cout<<"Please edit the code and change the sign of q when filling histos and vectors in the loop on tree entries"<<endl; return 1; } if((vSM.size()!= ntoysSM)||(vALT.size()!= ntoysALT)){ cout<<"Mismatch in size of vectors and #entries of histograms ! vSM.size()="<< vSM.size() <<" ntoysSM="<<ntoysSM<<endl; cout<<"Mismatch in size of vectors and #entries of histograms ! vALT.size()="<< vALT.size() <<" ntoysALT="<<ntoysALT<<endl; return 1; } float medianSM=vSM.at(int(ntoysSM/2)); float medianALT=vALT.at(int(ntoysALT/2)); cout<<"Toys generated SM: "<<ntoysSM<<"\t"<<ntoysALT<<endl; cout<<"Mean of SM/ALT hypothesis: "<<hSM->GetMean()<<"\t"<<hALT->GetMean()<<endl; cout<<"RMS of SM/ALT hypothesis: "<<hSM->GetRMS()<<"\t"<<hALT->GetRMS()<<endl; cout<<"Median of SM/ALT hypothesis: "<<medianSM<<"\t"<<medianALT<<endl; const float step=0.05; float coverage=0.0; float diff=10.0; float cut=vALT.at(0)-step; float crosspoint=-99.0; int startSM=ntoysSM-1, startALT=0; //cout<<"Starting to loop with cut at "<<cut<<endl; while(cut<=vSM.at(ntoysSM-1)+step){ float cutSM=-1.0,cutALT=-1.0; for(long iSM=startSM;iSM>=0;iSM--){ if(vSM.at(iSM)<cut){//gotcha cutSM=ntoysSM-iSM; break; } } for(unsigned long iALT=startALT;iALT<ntoysALT;iALT++){ if(vALT.at(iALT)>cut){//gotcha cutALT=iALT; break; } } if(cutSM>=0 && cutALT>=0){ float fracSM=(ntoysSM-cutSM)/ntoysSM; float fracALT=(ntoysALT-cutALT)/ntoysALT; if(fabs(fracSM-fracALT)<diff){ diff=fabs(fracSM-fracALT); coverage=fabs(fracSM+fracALT)/2.0; crosspoint=cut; } } cut+=step; }//end while loop //cout<<"Finished loop on vector elements, min diff is "<<diff<<", looped until cut_fin="<<cut<<endl; cout<<"q value where SM and ALT distributions have same area on opposite sides: "<<crosspoint<<" Coverage="<<coverage<< " Separation="<<1.0-coverage <<endl; float separation=2*ROOT::Math::normal_quantile_c(1.0 - coverage, 1.0); cout<<"Separation from tail prob: "<<separation<<endl<<endl<<endl; float integralSM=hSM->Integral(); float integralALT=hALT->Integral(); float tailSM=hSM->Integral(1,hSM->FindBin(medianALT))/integralSM; float tailALT=hALT->Integral(hALT->FindBin(medianSM),hALT->GetNbinsX())/integralALT; cout<<"Median point prob SM : "<<tailSM <<" ("<<ROOT::Math::normal_quantile_c(tailSM, 1.0) <<" sigma)"<<endl; cout<<"Median point prob ALT: "<<tailALT<<" ("<<ROOT::Math::normal_quantile_c(tailALT,1.0) <<" sigma)"<<"\t Exp 1-CLS: "<< 1.0-tailALT/0.5 << endl; labelCLs=tailALT/0.5; diff=10.0; coverage=0.0; for(int i=1;i<hSM->GetNbinsX();i++){ float fracSM=hSM->Integral(1,i) / integralSM; float fracALT=hALT->Integral(i,hALT->GetNbinsX()) / integralALT; if(fabs(fracSM-fracALT)<diff){ diff=fabs(fracSM-fracALT); coverage=(fracSM+fracALT)/2.0; } } float sepH= 2*ROOT::Math::normal_quantile_c(1.0 - coverage, 1.0); cout<<"Separation from histograms = "<<sepH<<" with coverage "<<coverage<<endl; double observedQ=vObs.at(0); if(unblind){ if ( (*(vObs.end()-1) / *vObs.begin() - 1.0) > 0.1/100 ){ cout<<"Ooops ! The size of the vector with the observed separation is "<<vObs.size()<<" !"<<endl; cout << "Found more than 0.1% difference between the first and the last: " << *vObs.begin() << " -- " << *(vObs.end()-1) << endl; return -1; } else{ float obsTailSM = hSM->Integral(1,hSM->FindBin(observedQ))/integralSM; float obsTailALT=hALT->Integral(hALT->FindBin(observedQ),hALT->GetNbinsX())/integralALT; cout<<"P(SM < Obs) : "<<obsTailSM <<" ("<<ROOT::Math::normal_quantile_c(obsTailSM,1.0) <<" sigma)"<<endl; cout<<"P(ALT > Obs): "<<obsTailALT<<" ("<<ROOT::Math::normal_quantile_c(obsTailALT,1.0) <<" sigma)"<<endl; float obsCLsRatio = obsTailALT / (1.0 - obsTailSM); cout<<"CLs criterion P(ALT > Obs) / P(SM > Obs) : "<<obsCLsRatio<<" ("<<ROOT::Math::normal_quantile_c(obsCLsRatio,1.0) <<" sigma)"<< "\t Obs 1-CLS="<<1.0-obsCLsRatio <<endl; labelCLs=obsCLsRatio; } cout << "\n\nOBSERVED SIGNIFICANCE" << endl; cout << "observation: " << vObs[0] << endl; cout << "bin: " << hObs->GetMaximumBin() << endl; cout << " --------------- " << endl; double obsPvalSM = 1-hSM->Integral(0,hObs->GetMaximumBin())/integralSM; cout << "pvalue SM : " << obsPvalSM << endl; cout << "signif SM : " << ROOT::Math::normal_quantile_c(obsPvalSM,1.0) << endl; double obsPvalALT = hALT->Integral(0,hObs->GetMaximumBin())/integralALT; cout << "pvalue ALT: " << obsPvalALT << endl; cout << "signif ALT: " << ROOT::Math::normal_quantile_c(obsPvalALT,1.0) << endl<<endl<<endl; }//end if unblinding //Plotting gStyle->SetOptStat(0); TCanvas *c1=new TCanvas("c","c",500,500); c1->cd(); //hSM->Rebin(20e7/ntoysSM); //hALT->Rebin(20e7/ntoysALT); hSM->Rebin(rebin); hALT->Rebin(rebin); TString xtitle=" -2 #times ln(L_{"+legALT+"} / L_{0^{+}})"; hSM->SetXTitle(xtitle); hSM->SetYTitle("Probability density"); hALT->SetXTitle(xtitle); hALT->SetYTitle("Probability density"); hSM->SetLineColor(kRed+2); hSM->SetLineStyle(2); hSM->SetFillColor(798); hSM->SetLineWidth(2); hALT->SetFillColor(kAzure+7); hALT->SetLineColor(kBlue); hALT->SetLineWidth(1); hALT->SetFillStyle(3001); hObs->SetLineColor(kRed); hObs->SetLineWidth(2); hSM->GetXaxis()->SetRangeUser(-30.0,30.0); hSM->GetXaxis()->SetLabelFont(42); hSM->GetXaxis()->SetLabelOffset(0.007); hSM->GetXaxis()->SetLabelSize(0.045); hSM->GetXaxis()->SetTitleSize(0.05); hSM->GetXaxis()->SetTitleOffset(1.15); hSM->GetXaxis()->SetTitleFont(42); hSM->GetYaxis()->SetLabelFont(42); hSM->GetYaxis()->SetLabelOffset(0.007); hSM->GetYaxis()->SetLabelSize(0.045); hSM->GetYaxis()->SetTitleSize(0.05); hSM->GetYaxis()->SetTitleOffset(1.8); hSM->GetYaxis()->SetTitleFont(42); //TGaxis::SetMaxDigits(2); hSM->Scale(1./hSM->Integral("width")); hALT->Scale(1./hALT->Integral("width")); float maxhSM=hSM->GetBinContent(hSM->GetMaximumBin()); float maxhALT=hALT->GetBinContent(hALT->GetMaximumBin()); if(maxhALT>maxhSM){ hSM->SetMaximum(maxhALT*1.3); hALT->SetMaximum(maxhALT*1.3); } else{ hSM->SetMaximum(maxhSM*1.3); hALT->SetMaximum(maxhSM*1.3); } TH1F* hSM2= (TH1F*)(hSM->Clone("hSM2")); hSM2->SetFillStyle(0); hSM2->SetFillColor(0); hSM2->SetLineColor(kRed+2); hSM2->SetLineStyle(2); hSM2->SetLineWidth(2); hSM->Draw("HIST"); hALT->Draw("HISTsames"); hSM2->Draw("HISTsames"); TArrow *obsArrow=0; if(unblind){ obsArrow=new TArrow(observedQ,hSM->GetMaximum()/5.0,observedQ,0.0,0.05,"|->"); obsArrow->SetLineColor(kRed); obsArrow->SetLineWidth(2.0); obsArrow->Draw(); } TLegend *leg = new TLegend(0.63,0.73,0.88,0.93); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->AddEntry(hSM, "0^{+}","f"); leg->AddEntry(hALT, legALT,"f"); if(unblind){ leg->AddEntry(hObs,"CMS data","L"); leg->AddEntry((TObject*)0,Form("(CL_{s}^{obs.} = %2.1f%%)",labelCLs*100),""); }else{ leg->AddEntry((TObject*)0,"",""); leg->AddEntry((TObject*)0,Form("(CL_{s}^{exp.} = %2.1f%%)",labelCLs*100),""); } c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.18); c1->SetRightMargin(0.05); c1->SetTopMargin(0.05); c1->SetBottomMargin(0.15); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); TPaveText *pt = new TPaveText(0.1577181,0.9562937,0.9580537,0.9947552,"brNDC"); pt->SetBorderSize(0); pt->SetTextAlign(12); pt->SetFillStyle(0); pt->SetTextFont(42); pt->SetTextSize(0.03); pt->AddText(0.01,0.5,"CMS preliminary"); pt->AddText(0.3,0.6,"#sqrt{s} = 7 TeV, L = 5.1 fb^{-1} #sqrt{s} = 8 TeV, L = 19.6 fb^{-1}"); //pt->AddText(0.6,0.6,"#sqrt{s} = 8 TeV, L = 19.6 fb^{-1}"); pt->Draw(); leg->Draw(); c1->SaveAs(nameALT+".png"); c1->SaveAs(nameALT+".pdf"); c1->SaveAs(nameALT+".eps"); c1->SaveAs(nameALT+".root"); return 0; }//end main
void plot3(TString infile = "fp-d", TString pltmd = "cos") { // CHECK FOR RIGHT INPUT //////////////////////////////////////////////// string strpltmd = pltmd, filename = infile, strfile = infile; if( (strpltmd.compare("cos") != 0 ) && (strpltmd.compare("sin") != 0 ) && (strpltmd.compare("tan") != 0 ) && (strpltmd.compare("mmp") != 0 ) ) {error(4);}; // GLOBAL VARIABLES //////////////////////////////////////////////////// Int_t file, point, color, style; Float_t fits2b, fittph, tphold, fitsph, fitcph, fitx, fitxmin, fitxmax = -1.0; Float_t xVal, yVal; Float_t xMin = 100000, xMax = -1.0, yMin = 100000, yMax = -1.0; Float_t MZ, MW, Mmin = 100000; Float_t Cz1, Cz2, Cz3, Cw1, Cw2, Cw3, Cw4, C1, C2; Float_t phiMin, phiMax, cphmin, cphmax, sphmin, sphmax; // CUSTOMIZE PLOT /////////////////////////////////////////////////////// gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetTitleBorderSize(0); gStyle->SetPalette(1); TCanvas *MyC = new TCanvas("MyC","Plot of the GAPP fit results",200,10,700,500); Float_t mmlegxmin, mmlegxmax, mmlegymin, mmlegymax; Float_t s2blegxmin, s2blegymin, s2blegxmax, s2blegymax; Float_t lblxmin, lblxmax, lblymin, lblymax; string plottitle = "Model: " + infile + " | Plot: "; string xtitle, ytitle, NPleg, SMleg, display; NPleg = "#font[52]{M_{H}^{(NP)}, #bar{m}_{t}^{(NP)}}"; SMleg = "#font[52]{M_{H}^{(SM)}, #bar{m}_{t}^{(SM)}}"; if (strpltmd.compare("tan") == 0) { plottitle += "#font[42]{tan^{2}(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{tan^{2}(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.15; s2blegxmax = 0.40; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.88; lblxmax = 0.88; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("cos") == 0) { plottitle += "#font[42]{cos(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{cos(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.70; mmlegxmax = 0.85; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.15; s2blegxmax = 0.40; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.65; lblxmax = 0.80; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("sin") == 0) { plottitle += "#font[42]{sin(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}"; xtitle = "#font[52]{#tilde{x}}"; ytitle = "#font[42]{sin(#tilde{#phi})}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.60; s2blegxmax = 0.85; s2blegymin = 0.30; s2blegymax = 0.50; lblxmin = 0.65; lblxmax = 0.80; lblymin = 0.60; lblymax = 0.65; } else if (strpltmd.compare("mmp") == 0) { plottitle += "#font[42]{Masses of the new heavy gauge bosons.}"; xtitle = "#font[52]{M_{Z'}}#font[42]{ (TeV)}"; ytitle = "#font[52]{M_{W'}}#font[42]{ (TeV)}"; display = "C"; mmlegxmin = 0.15; mmlegxmax = 0.30; mmlegymin = 0.75; mmlegymax = 0.85; s2blegxmin = 0.60; s2blegxmax = 0.85; s2blegymin = 0.45; s2blegymax = 0.65; lblxmin = 0.35; lblxmax = 0.50; lblymin = 0.45; lblymax = 0.50; }; // PREPARE BOSON MASSES AND PHI BOUNDS ////////////////////////////////// string mdl(filename,0,2); if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { phiMin = 5.600; phiMax = 84.400; string Higgs(filename,3,1); if (Higgs.compare("d") == 0) { Cz1 = 11.95349795785275; Cz2 = 30.63269990028513; Cz3 = 42.58619785813789; Cw1 = 21.29309892906894; Cw2 = 9.339600971216193; Cw3 = 30.63269990028513; Cw4 = 42.58619785813789; } else if (Higgs.compare("t") == 0) { Cz1 = 5.976748978926375; Cz2 = 30.63269990028513; Cz3 = 85.17239571627579; Cw1 = 15.05649464522066; Cw2 = 3.302047590161717; Cw3 = 21.66058982554409; Cw4 = 60.22597858088265; } } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { phiMin = 10.179, phiMax = 79.821; C1 = 94.0397928463607; C2 = 77.1253849720165; } else {error(6);} cphmin = cos(TMath::Pi()*phiMin/180.0)*cos(TMath::Pi()*phiMin/180.0); cphmax = cos(TMath::Pi()*phiMax/180.0)*cos(TMath::Pi()*phiMax/180.0); sphmin = sin(TMath::Pi()*phiMin/180.0)*sin(TMath::Pi()*phiMin/180.0); sphmax = sin(TMath::Pi()*phiMax/180.0)*sin(TMath::Pi()*phiMax/180.0); // LOOP OVER ROOT FILES //////////////////////////////////////////////// for(file=0; file<=1; file++) { if(file==0) string epsfile = filename + "_" + strpltmd + ".eps"; if(file==1) string filename = filename + "_sm"; string rootname = filename + ".root"; TFile *rootfile = TFile::Open(rootname.c_str()); if(rootfile == NULL) error(1); TTree *tree = (TTree*)rootfile->Get(filename.c_str()); if(tree == NULL) error(2); TBranch *fits2bbranch = (TBranch*)tree->GetBranch("fits2b"); TBranch *fittphbranch = (TBranch*)tree->GetBranch("fittph"); TBranch *fitxbranch = (TBranch*)tree->GetBranch("fitx"); if( (fits2bbranch == NULL) || (fittphbranch == NULL) || (fitxbranch == NULL) ) error(3); tree->SetBranchAddress("fits2b",&fits2b); tree->SetBranchAddress("fittph",&fittph); tree->SetBranchAddress("fitx", &fitx); // GET ARRAYS /////////////////////////////////////////////////////////// Int_t Npoints = (Int_t)tree->GetEntries(); Int_t tphStep = 0; Float_t tphMax = -1.0; for(point=0; point<Npoints; point++) { tree->GetEntry(point); if( fittph > tphMax ) {tphStep++; tphMax = fittph;} }; const int tphSteps = tphStep; Float_t xArray[tphSteps], yArray[tphSteps], zArray[tphSteps]; tphStep = -1, tphold = -1.0, fitxmin = 100000; for(point=0; point<Npoints; point++) { tree->GetEntry(point); if(fittph > tphold) {tphStep++; fitxmin = 100000;} fitsph = fittph / (1.0 + fittph); fitcph = 1.0 - fitsph; if (strpltmd.compare("tan") == 0) { xVal = fitx; yVal = fittph; } else if (strpltmd.compare("cos") == 0) { xVal = fitx; yVal = sqrt(fitcph); } else if (strpltmd.compare("sin") == 0) { xVal = fitx; yVal = sqrt(fitsph); } else if (strpltmd.compare("mmp") == 0) { if (fitsph != 0.0) { if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,fitsph,fitcph,fits2b,xVal,yVal); } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { MMII(C1,C2,fitx,fitsph,fitcph,xVal,yVal); } } } if( (strpltmd.compare("mmp") == 0) && (tphStep==1) ) { xArray[0] = xArray[1]; yArray[0] = yArray[1]; zArray[0] = zArray[1]; } if(fitx>fitxmax) fitxmax = fitx; if(fitx<fitxmin) { xArray[tphStep] = xVal; yArray[tphStep] = yVal; zArray[tphStep] = fits2b; fitxmin = fitx; } tphold = fittph; } if(file==0) TGraph *NPplot = new TGraph(tphSteps,xArray,yArray); if(file==1) TGraph *SMplot = new TGraph(tphSteps,xArray,yArray); TMarker *NPmrk[tphSteps], *SMmrk[tphSteps]; for(tphStep=0; tphStep<tphSteps; tphStep++){ marker(zArray[tphStep],color,style); if(file==0) { NPmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style); NPmrk[tphStep]->SetMarkerSize(0.8); NPmrk[tphStep]->SetMarkerColor(color);} if(file==1) { SMmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style); SMmrk[tphStep]->SetMarkerSize(0.8); SMmrk[tphStep]->SetMarkerColor(color);} if( (strpltmd.compare("mmp") != 0) || (tphStep !=0 )) { if (xArray[tphStep] < xMin) xMin = xArray[tphStep]; if (xArray[tphStep] > xMax) xMax = xArray[tphStep]; if (yArray[tphStep] < yMin) yMin = yArray[tphStep]; if (yArray[tphStep] > yMax) yMax = yArray[tphStep]; } if( ((strfile.compare("uu-d") == 0) || (strfile.compare("nu-d") == 0)) && (strpltmd.compare("sin") == 0) ) { fitx = xArray[tphStep]; fitsph = yArray[tphStep]*yArray[tphStep]; fitcph = 1.0 - fitsph; if( (sphmin < fitsph) && (fitsph<sphmax) ) { MMII(C1,C2,fitx,fitsph,fitcph,MZ,MW); if(MZ < Mmin) { Mmin = MZ; cout << MZ << "\t" << sqrt(fitsph) << endl;} } } } } // CREATE PLOTS ///////////////////////////////////////////////////////// NPplot->SetLineStyle(2); NPplot->SetMarkerStyle(20); NPplot->SetMarkerSize(0.4); SMplot->SetMarkerStyle(20); SMplot->SetMarkerSize(0.4); if(strpltmd.compare("cos") == 0) {yMin = 0.0; yMax = 1.0;} if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;} if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.0; yMin = 0.0; yMax = 5;} TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax); frame->SetTitle(plottitle.c_str()); TAxis *xaxis = frame->GetXaxis(); TAxis *yaxis = frame->GetYaxis(); xaxis->SetTitle(xtitle.c_str()); xaxis->CenterTitle(); xaxis->SetTitleOffset(1.); xaxis->SetDecimals(); xaxis->SetLabelSize(0.03); xaxis->SetLabelOffset(0.01); yaxis->SetTitle(ytitle.c_str()); yaxis->CenterTitle(); yaxis->SetTitleOffset(1.2); yaxis->SetDecimals(); yaxis->SetLabelSize(0.03); yaxis->SetLabelOffset(0.01); TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax); mmleg->AddEntry(NPplot,NPleg.c_str(),"l"); mmleg->AddEntry(SMplot,SMleg.c_str(),"l"); mmleg->SetTextSize(0.025); mmleg->SetFillStyle(0); if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) { for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();} } Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0}; TGraph *circle = new TGraph(1,xdummy,ydummy); circle->SetMarkerStyle(24); circle->SetMarkerColor(kGreen+1); circle->SetMarkerSize(0.8); TGraph *square = new TGraph(1,xdummy,ydummy); square->SetMarkerStyle(25); square->SetMarkerColor(kCyan+1); square->SetMarkerSize(0.8); TGraph *triangle = new TGraph(1,xdummy,ydummy); triangle->SetMarkerStyle(26); triangle->SetMarkerColor(kBlue+1); triangle->SetMarkerSize(0.8); TGraph *diamond = new TGraph(1,xdummy,ydummy); diamond->SetMarkerStyle(27); diamond->SetMarkerColor(kMagenta+1); diamond->SetMarkerSize(0.8); TLegend *s2bleg = new TLegend(s2blegxmin,s2blegymin,s2blegxmax,s2blegymax); s2bleg->AddEntry(circle,"#font[42]{0.00 < sin^{2}(2#tilde{#beta}) #leq 0.25}","p"); s2bleg->AddEntry(square,"#font[42]{0.25 < sin^{2}(2#tilde{#beta}) #leq 0.50}","p"); s2bleg->AddEntry(triangle,"#font[42]{0.50 < sin^{2}(2#tilde{#beta}) #leq 0.75}","p"); s2bleg->AddEntry(diamond,"#font[42]{0.75 < sin^{2}(2#tilde{#beta}) #leq 1.00}","p"); s2bleg->SetTextSize(0.025); s2bleg->SetFillStyle(0); NPplot->Draw(display.c_str()); SMplot->Draw(display.c_str()); mmleg->Draw(); if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) s2bleg->Draw(); // BOUNDS ON PHI ////////////////////////////////////////////////////// Int_t i; const int iSteps = 100; fitxmin = 1.0, fitxmax *= 1.5; Float_t deltax = (fitxmax-fitxmin)/iSteps; Float_t phixmin0[iSteps], phixmax0[iSteps], phixmin1[iSteps], phixmax1[iSteps]; Float_t phiymin0[iSteps], phiymax0[iSteps], phiymin1[iSteps], phiymax1[iSteps]; if ( (strpltmd.compare("tan") == 0) || (strpltmd.compare("cos") == 0) || (strpltmd.compare("sin") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; phixmin0[i] = fitx; if (strpltmd.compare("tan") == 0) { phiymin0[i] = sphmin / cphmin; phiymax0[i] = sphmax / cphmax; } if (strpltmd.compare("cos") == 0) { phiymin0[i] = sqrt(cphmin); phiymax0[i] = sqrt(cphmax); } if (strpltmd.compare("sin") == 0) { phiymin0[i] = sqrt(sphmin); phiymax0[i] = sqrt(sphmax); } } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMax0 = new TGraph(iSteps,phixmin0,phiymax0); } else if (strpltmd.compare("mmp") == 0) { if ( (mdl.compare("lr") == 0) || (mdl.compare("lp") == 0) || (mdl.compare("hp") == 0) || (mdl.compare("fp") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,0.0,phixmin0[i],phiymin0[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,1.0,phixmin1[i],phiymin1[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,0.0,phixmax0[i],phiymax0[i]); MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,1.0,phixmax1[i],phiymax1[i]); } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMin1 = new TGraph(iSteps,phixmin1,phiymin1); TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0); TGraph *phiMax1 = new TGraph(iSteps,phixmax1,phiymax1); phiMin1->SetLineStyle(7); phiMin1->SetMarkerStyle(22); phiMin1->SetMarkerSize(1.0); phiMax1->SetLineStyle(7); phiMax1->SetMarkerStyle(22); phiMax1->SetMarkerSize(1.0); phiMin1->Draw("C"); phiMax1->Draw("C"); } else if ( (mdl.compare("uu") == 0) || (mdl.compare("nu") == 0) ) { for(i=0; i<100; i++) { fitx = fitxmin + i*deltax; MMII(C1,C2,fitx,sphmin,cphmin,phixmin0[i],phiymin0[i]); MMII(C1,C2,fitx,sphmax,cphmax,phixmax0[i],phiymax0[i]); } TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0); TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0); } } phiMin0->SetLineStyle(3); phiMin0->SetMarkerStyle(20); phiMin0->SetMarkerSize(0.4); phiMax0->SetLineStyle(3); phiMax0->SetMarkerStyle(20); phiMax0->SetMarkerSize(0.4); phiMin0->Draw("C"); phiMax0->Draw("C"); // LABEL ALLOWED REGION /////////////////////////////////////////////// TPaveText *allowed = new TPaveText(lblxmin,lblymin,lblxmax,lblymax,"NDC"); TText *text = allowed->AddText("#font[42]{allowed (95% CL)}"); allowed->SetTextSize(0.04); if (strpltmd.compare("tan") == 0) text->SetTextAngle(270); allowed->SetFillStyle(0); allowed->SetLineColor(0); allowed->SetBorderSize(1); allowed->Draw(); // SAVE GRAPHIC /////////////////////////////////////////////////////// MyC->Print(epsfile.c_str()); }
void draw2DLimitBFstyle(map<string,TList *>& m_contours, const TString& par1, const TString& par2, const TString& plotprefix, TLegend *legend) { //from here we build the two-dimensional aTGC limit TCanvas *finalPlot = new TCanvas("final","limits",500,500); finalPlot->cd(); cout << "Drawing +2s" << endl; TList *contLevel = m_contours["+2s"]; TGraph *curv; assert(contLevel); curv = (TGraph*)(contLevel->First()); //curv->GetYaxis()->SetRangeUser(-1.25*curv->GetYaxis()->GetXmax(), //+2.0*curv->GetYaxis()->GetXmax()); //curv->GetYaxis()->SetRangeUser(-0.1,0.15); curv->GetYaxis()->SetRangeUser(parmin(par2),parmax(par2)); curv->SetTitle(); curv->GetXaxis()->SetTitle(par2latex(par1)); curv->GetXaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitle(par2latex(par2)); curv->GetYaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitleOffset(1.20); for (int i=0; i<contLevel->GetSize(); i++) { assert(curv); curv->SetLineColor(kYellow); curv->SetFillColor(kYellow); curv->GetXaxis()->SetLimits(parmin(par1),parmax(par1)); if (!i) { curv->Draw("ACF"); legend->AddEntry(curv,"#pm 2#sigma","F"); } else curv->Draw("SAME CF"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing +1s" << endl; contLevel = m_contours["+1s"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kGreen); curv->SetFillColor(kGreen); curv->Draw("SAME CF"); if (!i) legend->AddEntry(curv,"#pm 1#sigma","F"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing -1s" << endl; contLevel = m_contours["-1s"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kYellow); curv->SetFillColor(kYellow); curv->Draw("SAME CF"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing -2s" << endl; contLevel = m_contours["-2s"]; if (!contLevel) // this can happen more often for this contour if there is insufficient // sensitivity close to the SM cerr << "No contour level for +2s, have to fill in the central region" << endl; else { curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetFillColor(kWhite); curv->SetLineColor(kYellow); curv->Draw("SAME CF"); curv=(TGraph *)(contLevel->After(curv)); } } cout << "Drawing median" << endl; curv = (TGraph*)(m_contours["median"]->First()); curv->SetLineColor(kBlack); curv->SetLineWidth(2); curv->SetLineStyle(2); curv->Draw("SAME C"); legend->AddEntry(curv,"Expected","L"); cout << "Drawing obs" << endl; contLevel = m_contours["obs"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kBlack); curv->SetLineWidth(2); curv->Draw("SAME C"); if (!i) legend->AddEntry(curv,"Observed","L"); curv=(TGraph *)(contLevel->After(curv)); } TGraph *SMpoint = new TGraph(1); SMpoint->SetPoint(1,0,0); SMpoint->Draw("SAME Po"); // smLabel = TPaveText(0, // m_contours["-2s"]->GetYaxis()->GetXmax()/8, // m_contours["-2s"]->GetXaxis()->GetXmax()/3->5, // -m_contours["-2s"]->GetYaxis()->GetXmax()/8); // smLabel->SetFillStyle(0); // smLabel->SetBorderSize(0); // smLabel->AddText(" SM"); // smLabel->Draw(); legend->Draw(); TPaveText *text = new TPaveText(0.566,0.87,0.965,1.101,"NDC"); text->SetFillStyle(0); text->SetBorderSize(0); text->AddText(Form("95%% CL Limit on %s and %s",par2latex(par1).Data(),par2latex(par2).Data())); text->AddText(0,0.35,Form("#intL dt= %.1f fb^{-1}, #sqrt{s} = %d TeV",intlumifbinv,beamcometev)); text->Draw(); // text2 = TPaveText(0.155,0.199,0.974,0.244,"NDC"); // text2->SetFillStyle(0); // text2->SetBorderSize(0); // text2->AddText("Values outside contour excluded"); // text2->Draw(); //text3 = TPaveText(0.506,0.699,0.905,0.758,"NDC"); //text3->SetFillStyle(0); //text3->SetBorderSize(0); //text3->AddText(options.flavorText); //text3->Draw(); finalPlot->RedrawAxis(); finalPlot->ResetAttPad(); finalPlot->Update(); finalPlot->Draw(); finalPlot->Update(); finalPlot->Modified(); finalPlot->Update(); finalPlot->Print(Form("%s.pdf",plotprefix.Data())); finalPlot->Print(Form("%s.eps",plotprefix.Data())); finalPlot->Print(Form("%s.png",plotprefix.Data())); } // draw2DlimitBFstyle
void draw1DLimit(map<string,TGraph2D *> m_graphs, const TString& parname, const TString& plotprefix, int npts, double boundScale, // used to exclude region closest to SM from plotting double exclusionlimit, bool isX, TLegend *legend) { TCanvas *c1 = new TCanvas(Form("%slimit",parname.Data()), Form("%slimit",parname.Data()), 500,500); map<string,TGraphAsymmErrors *> m_limits1d; m_limits1d["2s"] = new TGraphAsymmErrors(); m_limits1d["1s"] = new TGraphAsymmErrors(); m_limits1d["-median"] = new TGraphAsymmErrors(); m_limits1d["-obs"] = new TGraphAsymmErrors(); m_limits1d["+median"] = new TGraphAsymmErrors(); m_limits1d["+obs"] = new TGraphAsymmErrors(); double parSize = parmax(parname) - parmin(parname); double lowerLimit=0.0, upperLimit=0.0; bool lowerLimitFound=false, upperLimitFound=false; double parcutoff = parmin(parname)*boundScale; double bound = 0.0; // bound = the max y value for the minus side if (isX) bound = m_graphs["-2s"]->Interpolate(parcutoff,0.0); else bound = m_graphs["-2s"]->Interpolate(0.0,parcutoff); printf ("par=%s, min=%f, max=%f, boundScale=%lf, bound=%lf, parcutoff=%lf\n", parname.Data(),parmin(parname), parmax(parname), boundScale, bound, parcutoff); int nnegpts=0,npospts=0; for (int i=0; i<npts; i++) { double obs, median, p1s, m1s, p2s, m2s; double parval = parmin(parname) + i*parSize/npts; if (isX) { obs = m_graphs["obs"]->Interpolate(parval,0.0); median = m_graphs["median"]->Interpolate(parval,0.0); p1s = m_graphs["+1s"]->Interpolate(parval,0.0); m1s = m_graphs["-1s"]->Interpolate(parval,0.0); p2s = m_graphs["+2s"]->Interpolate(parval,0.0); m2s = m_graphs["-2s"]->Interpolate(parval,0.0); } else { obs = m_graphs["obs"]->Interpolate(0.0,parval); median = m_graphs["median"]->Interpolate(0.0,parval); p1s = m_graphs["+1s"]->Interpolate(0.0,parval); m1s = m_graphs["-1s"]->Interpolate(0.0,parval); p2s = m_graphs["+2s"]->Interpolate(0.0,parval); m2s = m_graphs["-2s"]->Interpolate(0.0,parval); } //print m2s, m1s, median, p1s, p2s if (obs > exclusionlimit && !lowerLimitFound && (parval < 0)) { lowerLimit = parval; lowerLimitFound = true; } else if (obs < exclusionlimit && !upperLimitFound && (parval > 0)) { upperLimit = parval; upperLimitFound = true; } if ( // (m2s < bound) && (fabs(parval) > fabs(parcutoff)) ) { //par1 observed limit //obs and median if (parval < 0) { m_limits1d["-median"]->SetPoint(nnegpts,parval,median); m_limits1d["-obs"]->SetPoint(nnegpts++,parval,obs); } else { m_limits1d["+median"]->SetPoint(npospts,parval,median); m_limits1d["+obs"]->SetPoint(npospts++,parval,obs); } // one sigma expected m_limits1d["1s"]->SetPoint(i,parval,median); m_limits1d["1s"]->SetPointError(i,0,0,median-m1s,p1s-median); //two sigma expected m_limits1d["2s"]->SetPoint(i,parval,median); m_limits1d["2s"]->SetPointError(i,0,0,median-m2s,p2s-median); } else { m_limits1d["1s"]->SetPoint(i,parval,bound+0.1); m_limits1d["1s"]->SetPointError(i,0,0,0,0); m_limits1d["2s"]->SetPoint(i,parval,bound+0.1); m_limits1d["2s"]->SetPointError(i,0,0,0,0); } } // npts loop //print "95% CL on"+" %s = [%.3g,%.3g]"%(par,lowerLimit,upperLimit) c1->cd(); c1->SetLogy(); m_limits1d["2s"]->SetFillColor(kYellow); m_limits1d["2s"]->Draw("A E3"); m_limits1d["1s"]->SetFillColor(kGreen); m_limits1d["1s"]->Draw("SAME E3"); m_limits1d["-median"]->SetLineStyle(2); m_limits1d["-median"]->SetLineWidth(2); m_limits1d["-median"]->Draw("SAME C"); m_limits1d["+median"]->SetLineStyle(2); m_limits1d["+median"]->SetLineWidth(2); m_limits1d["+median"]->Draw("SAME C"); m_limits1d["-obs"]->SetLineWidth(2); m_limits1d["-obs"]->Draw("SAME C"); m_limits1d["+obs"]->SetLineWidth(2); m_limits1d["+obs"]->Draw("SAME C"); //titles if (exclusionlimit==1) m_limits1d["2s"]->GetYaxis()->SetTitle("95% CL limit on #sigma/#sigma_{aTGC}"); else m_limits1d["2s"]->GetYaxis()->SetTitle(Form("p_{S+B}(%s)",par2latex(parname).Data())); m_limits1d["2s"]->GetYaxis()->SetTitleFont(42); m_limits1d["2s"]->GetXaxis()->SetTitle(par2latex(parname)); m_limits1d["2s"]->GetXaxis()->SetTitleFont(42); m_limits1d["2s"]->GetYaxis()->SetRangeUser(m_limits1d["2s"]->GetYaxis()->GetXmin()*0.75,10); //,bound); m_limits1d["2s"]->GetXaxis()->SetRangeUser(parmin(parname)*0.985,parmax(parname)*0.96); #if 0 legend->SetX1NDC(0.43); legend->SetY1NDC(0.43); legend->SetX2NDC(0.75); legend->SetY2NDC(0.65); #endif legend->Draw(); TPaveText *text1d = new TPaveText(0.566,0.87,0.965,1.101,"NDC"); //TPaveText *text1d = new TPaveText(0.359,0.24,0.758,0.44,"NDC"); text1d->SetFillStyle(0); text1d->SetBorderSize(0); text1d->AddText(Form("95%% CL Limit on #bf{%s}",par2latex(parname).Data())); text1d->AddText(0,0.35,Form("#intL dt= %.1f fb^{-1}, #sqrt{s} = %d TeV", intlumifbinv,beamcometev)); text1d->Draw(); // text3.SetX1NDC(0.357); // text3.SetY1NDC(0.246); // text3.SetX2NDC(0.756); // text3.SetY2NDC(0.305); // text3.Draw(); TPaveText *obslimtext = new TPaveText(0.357,0.197,0.754,0.246,"NDC"); obslimtext->SetFillStyle(0); obslimtext->SetBorderSize(0); obslimtext->AddText(Form("%.3f < %s < %.3f", lowerLimit,par2latex(parname).Data(),upperLimit)); obslimtext->Draw(); //lowLimitLine = TLine(lowerLimit,m_limits1d["2s"]->GetYaxis()->GetXmin()*0.75, // lowerLimit,1) //lowLimitLine->SetLineColor(14) //lowLimitLine->SetLineWidth(2) //lowLimitLine->Draw() //upLimitLine = TLine(upperLimit,m_limits1d["2s"]->GetYaxis()->GetXmin()*0.75, // upperLimit,1) //upLimitLine->SetLineColor(14) //upLimitLine->SetLineWidth(2) //upLimitLine->Draw() TLine *oneLine = new TLine(parmin(parname)*0.985,exclusionlimit, parmax(parname)*0.960,exclusionlimit); oneLine->SetLineStyle(9); oneLine->SetLineColor(14); oneLine->Draw(); c1->Draw(); c1->Update(); c1->Modified(); c1->Update(); c1->Print(Form("%s.pdf",plotprefix.Data())); c1->Print(Form("%s.eps",plotprefix.Data())); c1->Print(Form("%s.png",plotprefix.Data())); } // draw1Dlimit
std::pair<double, double> fit_mass(RooDataSet* ds, string oFile, string cut, string massvar = "Z_M"){ RooRealVar m( massvar.c_str(), massvar.c_str(), 60., 120. ); RooPlot* plot = m.frame(); // Breit Wigner - Z Lineshape RooRealVar m0( "m0", "m0", 0 ); RooRealVar width( "width", "width", 1.5, 0, 5 ); RooBreitWigner bw( "gauss", "gauss", m, m0, width ); // Crystal-Ball - Detector response + FSR RooRealVar mean( "mean", "mean", 90.3, 70, 110 ); RooRealVar sigma( "sigma", "sigma", 0.5, 0, 5); RooRealVar alpha( "alpha", "alpha", 2.2, 0.01, 5 ); RooRealVar n( "n", "n", 1, 0.01, 80 ); RooCBShape cb( "cb", "cb", m, mean, sigma, alpha, n ); //exponential - DY component + background RooRealVar lambda("lambda", "slope", -2e-2, -30., 0.); RooExponential expo("expo", "exponential PDF", m, lambda); //Set cache for FFT convolution m.setBins(10000, "cache"); m.setMin("cache", 50.5); m.setMax("cache", 129.5); //convolve PDFs RooFFTConvPdf pdf( "pdf", "pdf", m, cb, bw ); //Background fraction RooRealVar b("b", "background", 0.7, 0, 1); RooAddPdf sum("sum", "crystal ball + gaussian + expo", RooArgList(pdf, expo), RooArgList(b)); //sum.fitTo(*ds, RooFit::Extended()); sum.fitTo(*ds); //Make mass plot TCanvas* canv = new TCanvas( "canv", "canv", 800.0, 600.0 ); plot -> GetXaxis() -> SetTitle( "M_{#mu#mu} [GeV]" ); plot -> GetYaxis() -> SetTitleOffset( 1.5 ); ds->plotOn( plot ); sum.plotOn(plot); //print chi2 on plot and add tpavetext ostringstream sstream; sstream<<"#chi^{2}/nDoF = "<<plot->chiSquare(); TPaveText* p = new TPaveText(0.15, 0.7, 0.5, 0.9, "NDC"); p->SetFillStyle(0); p->SetBorderSize(0.0); plot->addObject(p); p->AddText(cut.c_str()); p->AddText(sstream.str().c_str()); plot->Draw(); p->Draw(); canv->SaveAs( ("BWxCB_"+oFile+".pdf").c_str() ); // return as pair with value and error of mean std::pair<double, double> a(mean.getVal(), mean.getError()); return a; }
void makeGenLevel_pTRatios(int erg_tev){ char TREE_NAME[]="candTree"; TString OUTPUT_NAME = Form("compareProductionModes_pT_%iTeV.root", erg_tev); char csuffix[] = "_pToverMZZ"; char cxtitle[] = "p_{T} / m_{4l}"; TFile* foutput = new TFile(OUTPUT_NAME, "recreate"); TH1F* h_pt[nProdModes]; TH1F* hratio_pt[nProdModes-1]; TProfile* hpr_pt[nProdModes-1]; TGraphAsymmErrors* tgratio_pt[nProdModes-1]; TF1* fratio_pt[nProdModes]; double xmin = 0; double xmax = 6; const int nbins = 23; double xbins[nbins+1]; for (int bin=0; bin<=nbins; bin++){ if (bin==0) xbins[bin] = xmin; else if (xbins[bin-1]<1.2) xbins[bin] = xbins[bin-1] + 0.1; // 12 else if (xbins[bin-1]<2.4) xbins[bin] = xbins[bin-1] + 0.2; // 6 else if (xbins[bin-1]<4) xbins[bin] = xbins[bin-1] + 0.4; // 4 else if (xbins[bin-1]<xmax) xbins[bin] = xbins[bin-1] + 2.0; // 1 } TString cytitle = "Rate / bin"; for (int p = 0; p < nProdModes; p++){ TString hname = Form("%s%s", prodName[p], csuffix); // TString htitle = Form("%s %i TeV", prodName[p], erg_tev); h_pt[p] = new TH1F(hname, "", nbins, xbins); h_pt[p]->Sumw2(); h_pt[p]->GetXaxis()->SetTitle(cxtitle); h_pt[p]->GetYaxis()->SetTitle(cytitle); if (p>0){ hname = Form("%s%s_profile", prodName[p], csuffix); hpr_pt[p-1] = new TProfile(hname, "", nbins, xbins); hpr_pt[p-1]->Sumw2(); } } int genFinalState = -1; float GenHMass = 0; float GenHPt = 0; TString cinput_common = location_primaryTrees; if (erg_tev==7) cinput_common.Append("141217/"); else if (erg_tev==8) cinput_common.Append("141021/"); for (int p = 0; p < nProdModes; p++){ TString cinput = cinput_common; // cinput.Append(Form("%s/ZZ4lAnalysis_%s%s", sampleName[p], sampleName[p], ".root")); cinput.Append(Form("ZZ4lAnalysis_%s%s", sampleName[p], ".root")); TFile* finput = new TFile(cinput, "read"); cout << "Production " << prodName[p] << endl; TTree* tin[3] ={ (TTree*)finput->Get(Form("ZZ4muTree/%s", TREE_NAME)), (TTree*)finput->Get(Form("ZZ4eTree/%s", TREE_NAME)), (TTree*)finput->Get(Form("ZZ2e2muTree/%s", TREE_NAME)) }; for (int f = 0; f < 3; f++){ cout << "Channel " << f << endl; cout << "Nentries: " << tin[f]->GetEntries() << endl; tin[f]->SetBranchAddress("genFinalState", &genFinalState); tin[f]->SetBranchAddress("GenHMass", &GenHMass); tin[f]->SetBranchAddress("GenHPt", &GenHPt); for (int ev = 0; ev < tin[f]->GetEntries(); ev++){ // for (int ev = 0; ev < 1000; ev++){ genFinalState = -1; GenHMass = 0; GenHPt = 0; tin[f]->GetEntry(ev); if (f != genFinalState) continue; double kd = GenHPt / GenHMass; h_pt[p]->Fill(kd); if (p==0){ for (int pp=0; pp<nProdModes-1; pp++) hpr_pt[pp]->Fill(kd, kd); } else hpr_pt[p-1]->Fill(kd, kd); } } finput->Close(); cout << "File closed" << endl; } foutput->cd(); /* double zhxsec, whxsec; if (erg_tev == 7){ whxsec = 0.5688; zhxsec = 0.3299; } else if (erg_tev == 8){ whxsec = 0.6931; zhxsec = 0.4091; } h_pt[nProdModes]->Add(h_pt[nProdModes-1], whxsec); h_pt[nProdModes]->Add(h_pt[nProdModes-2], zhxsec); */ double max_plot = 0; for (int p = 0; p < nProdModes; p++){ h_pt[p]->Scale(1. / h_pt[p]->Integral(0, h_pt[p]->GetNbinsX() + 1)); h_pt[p]->GetYaxis()->SetRangeUser(0, 1); h_pt[p]->SetLineWidth(2); h_pt[p]->SetLineStyle(1); if (p==0) h_pt[p]->SetLineColor(kBlack); else if (p==3) h_pt[p]->SetLineColor(kRed); else if (p==4) h_pt[p]->SetLineColor(kGreen+2); else if (p==2) h_pt[p]->SetLineColor(kBlue); else if (p==1) h_pt[p]->SetLineColor(kViolet); if (p==0) h_pt[p]->SetMarkerColor(kBlack); else if (p==3) h_pt[p]->SetMarkerColor(kRed); else if (p==4) h_pt[p]->SetMarkerColor(kGreen+2); else if (p==2) h_pt[p]->SetMarkerColor(kBlue); else if (p==1) h_pt[p]->SetMarkerColor(kViolet); cout << "Writing hpt at " << p << endl; foutput->WriteTObject(h_pt[p]); if (p > 0){ cout << "Creating ratio at " << p << endl; hratio_pt[p - 1] = (TH1F*)h_pt[p]->Clone(Form("%s_ratio", h_pt[p]->GetName())); hratio_pt[p - 1]->Divide(h_pt[0]); hratio_pt[p - 1]->GetYaxis()->SetTitle("Ratio to ggH"); hratio_pt[p - 1]->SetTitle(Form("%s / %s", prodName[p], h_pt[0]->GetTitle())); double xx[nbins]; double yy[nbins]; double xx_up[nbins]; double yy_up[nbins]; double xx_dn[nbins]; double yy_dn[nbins]; int nAcc=0; for (int bin=1; bin<=nbins; bin++){ double bincontent = hratio_pt[p - 1]->GetBinContent(bin); double binerror = hratio_pt[p - 1]->GetBinError(bin); if (bincontent == 0) continue; else{ xx[nAcc] = hpr_pt[p-1]->GetBinContent(bin); xx_up[nAcc] = hpr_pt[p-1]->GetBinError(bin); xx_dn[nAcc] = hpr_pt[p-1]->GetBinError(bin); yy[nAcc] = bincontent; yy_up[nAcc] = binerror; yy_dn[nAcc] = binerror; nAcc++; max_plot = max(max_plot, (bincontent+binerror)); } } tgratio_pt[p-1] = new TGraphAsymmErrors(nAcc, xx, yy, xx_dn, xx_up, yy_dn, yy_up); tgratio_pt[p-1]->SetName(Form("tg_%s_ratio", h_pt[p]->GetName())); tgratio_pt[p-1]->GetYaxis()->SetTitle("Ratio to ggH"); tgratio_pt[p-1]->GetXaxis()->SetTitle(cxtitle); tgratio_pt[p-1]->GetYaxis()->SetRangeUser(0, 30); tgratio_pt[p-1]->SetLineWidth(2); tgratio_pt[p-1]->SetLineStyle(1); if (p==3) tgratio_pt[p-1]->SetMarkerColor(kRed); else if (p==4) tgratio_pt[p-1]->SetMarkerColor(kGreen+2); else if (p==2) tgratio_pt[p-1]->SetMarkerColor(kBlue); else if (p==1) tgratio_pt[p-1]->SetMarkerColor(kViolet); if (p==3) tgratio_pt[p-1]->SetLineColor(kRed); else if (p==4) tgratio_pt[p-1]->SetLineColor(kGreen+2); else if (p==2) tgratio_pt[p-1]->SetLineColor(kBlue); else if (p==1) tgratio_pt[p-1]->SetLineColor(kViolet); TF1* fitratio; if (p != 4){ fitratio = new TF1(Form("%s_fit", hratio_pt[p - 1]->GetName()), "([0]-[1]*exp(-pow(x/[2],2)))*exp(-x/[3])", hratio_pt[p - 1]->GetXaxis()->GetXmin(), hratio_pt[p - 1]->GetXaxis()->GetXmax()); if (p==1) fitratio->SetParameters(8.76, 8.69, 0.98, 4.3); else fitratio->SetParameters(8.76, 8.69, 0.98, -24); } else{ fitratio = new TF1(Form("%s_fit", hratio_pt[p - 1]->GetName()), "([0]-[1]*exp(-pow(x/[2],2)))", hratio_pt[p - 1]->GetXaxis()->GetXmin(), hratio_pt[p - 1]->GetXaxis()->GetXmax()); fitratio->SetParameters(4.2, 4.0, 0.7); } fitratio->SetParameters(6, 5.77, 1, 5); fitratio->SetTitle(""); fitratio->SetLineColor(hratio_pt[p - 1]->GetLineColor()); fitratio->SetLineStyle(7); fitratio->SetLineWidth(3); hratio_pt[p - 1]->GetYaxis()->SetRangeUser(1e-3, 1000); tgratio_pt[p - 1]->Fit(fitratio, "N"); cout << "Writing ratio fit at " << p << endl; foutput->WriteTObject(fitratio); cout << "Writing ratio at " << p << endl; foutput->WriteTObject(hratio_pt[p - 1]); foutput->WriteTObject(tgratio_pt[p - 1]); fratio_pt[p - 1] = fitratio; } } foutput->cd(); gStyle->SetTitleFont(62, "t"); gROOT->SetStyle(gStyle->GetName()); gROOT->ForceStyle(); TPaveText* pt = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(12); pt->SetTextFont(42); pt->SetTextSize(0.045); TText* text = pt->AddText(0.025, 0.45, "#font[61]{CMS}"); text->SetTextSize(0.044); text = pt->AddText(0.165, 0.42, "#font[52]{Simulation}"); text->SetTextSize(0.0315); if (erg_tev==8) text = pt->AddText(0.837, 0.45, "#font[42]{ 8 TeV}"); else if (erg_tev==7) text = pt->AddText(0.837, 0.45, "#font[42]{ 7 TeV}"); // if (erg_tev==7) text = pt->AddText(0.837, 0.45, "#font[42]{5.1 fb^{-1} (7 TeV)}"); text->SetTextSize(0.0315); TString canvasname_2D = Form("cCompare_SignalProductionMC_AllChannels_%iTeV", erg_tev); canvasname_2D.Append(Form("_%s_ratio", csuffix)); TCanvas* c2D = new TCanvas(canvasname_2D, "", 8, 30, 800, 800); c2D->cd(); gStyle->SetOptStat(0); c2D->SetFillColor(0); c2D->SetBorderMode(0); c2D->SetBorderSize(2); c2D->SetTickx(1); c2D->SetTicky(1); // c2D->SetLogy(); c2D->SetLeftMargin(0.17); c2D->SetRightMargin(0.05); c2D->SetTopMargin(0.07); c2D->SetBottomMargin(0.13); c2D->SetFrameFillStyle(0); c2D->SetFrameBorderMode(0); c2D->SetFrameFillStyle(0); c2D->SetFrameBorderMode(0); TLegend *l2D = new TLegend(0.20, 0.67, 0.58, 0.90); l2D->SetBorderSize(0); l2D->SetTextFont(42); l2D->SetTextSize(0.03); l2D->SetLineColor(1); l2D->SetLineStyle(1); l2D->SetLineWidth(1); l2D->SetFillColor(0); l2D->SetFillStyle(0); /* for (int p = 0; p < nProdModes-1; p++){ hratio_pt[p]->SetTitle(""); hratio_pt[p]->GetXaxis()->SetNdivisions(505); hratio_pt[p]->GetXaxis()->SetLabelFont(42); hratio_pt[p]->GetXaxis()->SetLabelOffset(0.007); hratio_pt[p]->GetXaxis()->SetLabelSize(0.04); hratio_pt[p]->GetXaxis()->SetTitleSize(0.06); hratio_pt[p]->GetXaxis()->SetTitleOffset(0.9); hratio_pt[p]->GetXaxis()->SetTitleFont(42); hratio_pt[p]->GetYaxis()->SetNdivisions(505); hratio_pt[p]->GetYaxis()->SetLabelFont(42); hratio_pt[p]->GetYaxis()->SetLabelOffset(0.007); hratio_pt[p]->GetYaxis()->SetLabelSize(0.04); hratio_pt[p]->GetYaxis()->SetTitleSize(0.06); hratio_pt[p]->GetYaxis()->SetTitleOffset(1.1); hratio_pt[p]->GetYaxis()->SetTitleFont(42); hratio_pt[p]->GetYaxis()->SetRangeUser(0, 30); hratio_pt[p]->GetXaxis()->SetRangeUser(0, 5); l2D->AddEntry(hratio_pt[p], prodTitle[p], "l"); if (p == 0) hratio_pt[p]->Draw("e1p"); else hratio_pt[p]->Draw("e1psame"); fratio_pt[p]->Draw("csame"); } */ for (int p = 0; p < nProdModes-1; p++){ tgratio_pt[p]->SetTitle(""); tgratio_pt[p]->GetXaxis()->SetNdivisions(505); tgratio_pt[p]->GetXaxis()->SetLabelFont(42); tgratio_pt[p]->GetXaxis()->SetLabelOffset(0.007); tgratio_pt[p]->GetXaxis()->SetLabelSize(0.04); tgratio_pt[p]->GetXaxis()->SetTitleSize(0.06); tgratio_pt[p]->GetXaxis()->SetTitleOffset(0.9); tgratio_pt[p]->GetXaxis()->SetTitleFont(42); tgratio_pt[p]->GetYaxis()->SetNdivisions(505); tgratio_pt[p]->GetYaxis()->SetLabelFont(42); tgratio_pt[p]->GetYaxis()->SetLabelOffset(0.007); tgratio_pt[p]->GetYaxis()->SetLabelSize(0.04); tgratio_pt[p]->GetYaxis()->SetTitleSize(0.06); tgratio_pt[p]->GetYaxis()->SetTitleOffset(1.1); tgratio_pt[p]->GetYaxis()->SetTitleFont(42); tgratio_pt[p]->GetYaxis()->SetRangeUser(0, max_plot*1.25); tgratio_pt[p]->GetXaxis()->SetRangeUser(0, 6); l2D->AddEntry(tgratio_pt[p], prodTitle[p+1], "l"); if (p == 0) tgratio_pt[p]->Draw("ae1p"); else tgratio_pt[p]->Draw("e1psame"); fratio_pt[p]->Draw("csame"); } l2D->Draw("same"); pt->Draw(); c2D->RedrawAxis(); c2D->Modified(); c2D->Update(); foutput->WriteTObject(c2D); c2D->Close(); foutput->cd(); for (int p = 0; p < nProdModes; p++){ delete h_pt[p]; if (p>0){ delete tgratio_pt[p-1]; delete hpr_pt[p-1]; delete hratio_pt[p-1]; } } foutput->Close(); }
void plot_BSM_MCFM(int SignalOnly=0){ gROOT->ProcessLine(".x tdrstyle.cc"); double mPOLE = 125.6; TString OUTPUT_NAME; OUTPUT_NAME = "HtoZZ4l_MCFM_125p6_BSMPlots"; if (SignalOnly==0) OUTPUT_NAME.Append(".root"); else OUTPUT_NAME.Append("_SignalOnly.root"); TString coutput_common = user_TemplateswithTrees_dir + "../BSMReweight_GenLevel/Plots/"; gSystem->Exec("mkdir -p " + coutput_common); TString coutput = coutput_common + OUTPUT_NAME; TFile* foutput = new TFile(coutput, "recreate"); foutput->cd(); float ZZMass = 0; float p0plus_VAJHU; float p0hplus_VAJHU; float p0minus_VAJHU; float p0_g1prime2_VAJHU; float p0_g1prime4_VAJHU; float pg1g2_VAJHU; float pg1g4_VAJHU; float pg1g1prime2_VAJHU; float pg1g1prime4_VAJHU; TChain* tc[2][3][4]; TH1F* hfill[4][9]; int nbinsx = 73; double xlimits[2]={ 160, 1620 }; if (SignalOnly==1){ xlimits[0]=100; nbinsx = 76; } for (int t=0; t<4; t++){ for (int ac=0; ac<9; ac++){ hfill[t][ac]= new TH1F(Form("hSum_BSI%i_Hypo%i", t, ac), "", nbinsx, xlimits[0], xlimits[1]); hfill[t][ac]->SetXTitle("m_{4l} (GeV)"); hfill[t][ac]->SetYTitle(Form("Events / %.0f GeV", (xlimits[1]-xlimits[0])/nbinsx)); } } double nCounted[2][3][9]={ { { 0 } } }; double nCountedScaled[2][3][9]={ { { 0 } } }; for (int erg_tev=7; erg_tev<9; erg_tev++){ for (int folder=0; folder<3; folder++){ TString comstring; comstring.Form("%iTeV", erg_tev); TString erg_dir; erg_dir.Form("LHC_%iTeV/", erg_tev); int EnergyIndex = 1; if (erg_tev == 7) EnergyIndex = 0; TString cinput_common = user_TemplateswithTrees_dir + "../BSMReweight_GenLevel/"; cinput_common.Append(+erg_dir); cinput_common += user_folder[folder] + "/"; cout << cinput_common << endl; for (int t=0; t<4; t++){ TString INPUT_NAME; INPUT_NAME = "HtoZZ4l_MCFM_125p6_BSMTrees_"; INPUT_NAME += sample_suffix[t] + ".root"; INPUT_NAME.Prepend(cinput_common); tc[EnergyIndex][folder][t] = new TChain("GenTree"); if (t!=3) tc[EnergyIndex][folder][t]->Add(INPUT_NAME); tc[EnergyIndex][folder][t]->SetBranchAddress("ZZMass", &ZZMass); tc[EnergyIndex][folder][t]->SetBranchAddress("p0plus_VAJHU", &p0plus_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0hplus_VAJHU", &p0hplus_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0minus_VAJHU", &p0minus_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0_g1prime2_VAJHU", &p0_g1prime2_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("p0_g1prime4_VAJHU", &p0_g1prime4_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g2_VAJHU", &pg1g2_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g4_VAJHU", &pg1g4_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g1prime2_VAJHU", &pg1g1prime2_VAJHU); tc[EnergyIndex][folder][t]->SetBranchAddress("pg1g1prime4_VAJHU", &pg1g1prime4_VAJHU); } double nsig_counted[9] ={ 0 }; for (int ev=0; ev<tc[EnergyIndex][folder][0]->GetEntries(); ev++){ tc[EnergyIndex][folder][0]->GetEntry(ev); if (fabs(ZZMass-mPOLE)<0.1){ nsig_counted[0] += p0plus_VAJHU; nsig_counted[1] += p0hplus_VAJHU; nsig_counted[2] += p0minus_VAJHU; nsig_counted[3] += p0_g1prime2_VAJHU; nsig_counted[4] += p0_g1prime4_VAJHU; nsig_counted[5] += (2.*(p0plus_VAJHU+p0hplus_VAJHU)-pg1g2_VAJHU); nsig_counted[6] += pg1g4_VAJHU; nsig_counted[7] += pg1g1prime2_VAJHU; nsig_counted[8] += pg1g1prime4_VAJHU; } } for (int ac=0; ac<9; ac++) nCounted[EnergyIndex][folder][ac] = nsig_counted[ac]; } } for (int erg_tev=7; erg_tev<9; erg_tev++){ for (int folder=0; folder<3; folder++){ int EnergyIndex = 1; if (erg_tev == 7) EnergyIndex = 0; double nsig_SM = nSM_ScaledPeak[EnergyIndex][folder]; double SMscale = nsig_SM/nCounted[EnergyIndex][folder][0]; double scale=1; for (int t=0; t<4; t++){ for (int ev=0; ev<tc[EnergyIndex][folder][t]->GetEntries(); ev++){ tc[EnergyIndex][folder][t]->GetEntry(ev); if (ZZMass<xlimits[0]) continue; if (ZZMass>=xlimits[1]) ZZMass=xlimits[1]*0.999; scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][0] = nCounted[EnergyIndex][folder][0]*scale; hfill[t][0]->Fill(ZZMass, p0plus_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][1] = nCounted[EnergyIndex][folder][1]*scale; hfill[t][1]->Fill(ZZMass, p0hplus_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][2] = nCounted[EnergyIndex][folder][2]*scale; hfill[t][2]->Fill(ZZMass, p0minus_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][3] = nCounted[EnergyIndex][folder][3]*scale; hfill[t][3]->Fill(ZZMass, p0_g1prime2_VAJHU*scale); scale = SMscale; if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][4] = nCounted[EnergyIndex][folder][4]*scale; hfill[t][4]->Fill(ZZMass, p0_g1prime4_VAJHU*scale); scale = SMscale; if (t>0){ hfill[t][5]->Fill(ZZMass, pg1g2_VAJHU*scale); } else{ scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][5]+nCounted[1][2][5]); hfill[t][5]->Fill(ZZMass, (2.*(p0plus_VAJHU+p0hplus_VAJHU)-pg1g2_VAJHU)*scale); } if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][5] = nCounted[EnergyIndex][folder][5]*scale; scale = SMscale; if (t==0) scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][6]+nCounted[1][2][6]); if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][6] = nCounted[EnergyIndex][folder][6]*scale; hfill[t][6]->Fill(ZZMass, pg1g4_VAJHU*scale); scale = SMscale; if (t==0) scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][7]+nCounted[1][2][7]); if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][7] = nCounted[EnergyIndex][folder][7]*scale; hfill[t][7]->Fill(ZZMass, pg1g1prime2_VAJHU*scale); scale = SMscale; // if (t==0) scale *= (nCounted[0][2][0]+nCounted[1][2][0])/(nCounted[0][2][8]+nCounted[1][2][8]); if (t==0 && ev==0) nCountedScaled[EnergyIndex][folder][8] = nCounted[EnergyIndex][folder][8]*scale; hfill[t][8]->Fill(ZZMass, pg1g1prime4_VAJHU*scale); } delete tc[EnergyIndex][folder][t]; } } } for (int ac=1; ac<9; ac++){ double nTotal[2]={ 0 }; for (int erg_tev=7; erg_tev<9; erg_tev++){ for (int folder=0; folder<3; folder++){ int EnergyIndex = 1; if (erg_tev == 7) EnergyIndex = 0; nTotal[0] += nCountedScaled[EnergyIndex][folder][0]; nTotal[1] += nCountedScaled[EnergyIndex][folder][ac]; } } if (ac!=8) hfill[0][ac]->Scale(nTotal[0]/nTotal[1]); else hfill[0][ac]->Scale(0.5); } double maxplot=0; for (int t=0; t<4; t++){ for (int ac=0; ac<9; ac++){ if (SignalOnly==0 && ac<5) maxplot = max(maxplot, hfill[t][ac]->GetMaximum()); else if (SignalOnly==1 && !(ac<5 && ac>0) && t==0) maxplot = max(maxplot, hfill[t][ac]->GetMaximum()); hfill[t][ac]->SetLineWidth(2); if (t==0 && ac>=5){ hfill[t][ac]->SetLineStyle(7); // hfill[t][ac]->Add(hfill[1][ac]); } if (t==1) hfill[t][ac]->SetLineStyle(3); if (t==3) hfill[t][ac]->SetLineStyle(9); hfill[t][ac]->GetXaxis()->SetLabelFont(42); hfill[t][ac]->GetXaxis()->SetLabelOffset(0.007); hfill[t][ac]->GetXaxis()->SetLabelSize(0.04); hfill[t][ac]->GetXaxis()->SetTitleSize(0.06); hfill[t][ac]->GetXaxis()->SetTitleOffset(0.9); hfill[t][ac]->GetXaxis()->SetTitleFont(42); hfill[t][ac]->GetYaxis()->SetNdivisions(505); hfill[t][ac]->GetYaxis()->SetLabelFont(42); hfill[t][ac]->GetYaxis()->SetLabelOffset(0.007); hfill[t][ac]->GetYaxis()->SetLabelSize(0.04); hfill[t][ac]->GetYaxis()->SetTitleSize(0.06); hfill[t][ac]->GetYaxis()->SetTitleOffset(1.1); hfill[t][ac]->GetYaxis()->SetTitleFont(42); } } TPaveText* pt = new TPaveText(0.15, 0.93, 0.85, 1, "brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(12); pt->SetTextFont(42); pt->SetTextSize(0.045); TText* text = pt->AddText(0.025, 0.45, "#font[61]{CMS}"); text->SetTextSize(0.044); text = pt->AddText(0.165, 0.42, "#font[52]{Simulation}"); text->SetTextSize(0.0315); TString cErgTev = "#font[42]{19.7 fb^{-1} (8 TeV) + 5.1 fb^{-1} (7 TeV)}"; text = pt->AddText(0.537, 0.45, cErgTev); text->SetTextSize(0.0315); float lxmin = 0.22; float lxwidth = 0.38; float lymax = 0.9; float lywidth = 0.3; float lxmax = lxmin + lxwidth; float lymin = lymax; if (SignalOnly==0) lymin -= lywidth*4./5.; else lymin -= lywidth; float lxmin2 = 0.22+0.39; float lymax2 = lymax; float lxmax2 = lxmin2 + lxwidth; float lymin2 = lymax2; if (SignalOnly==0) lymin2 -= lywidth*2./5.; else lymin2 -= lywidth*4./5.; if (SignalOnly==1){ float lxmin3 = lxmin2; float lymax3 = lymax2; float lxmax3 = lxmax2; float lymin3 = lymin2; lxmin2 = lxmin; lxmax2 = lxmax; lymin2 = lymin; lymax2 = lymax; lxmin = lxmin3; lxmax = lxmax3; lymin = lymin3; lymax = lymax3; } float pxmin = 0.756; float pymin = 0.76; float pxmax = 0.85; if (SignalOnly==1){ pymin -= 0.12; } float pymax = pymin+0.05; TPaveText* ptx = new TPaveText(pxmin, pymin, pxmax, pymax, "brNDC"); ptx->SetBorderSize(0); ptx->SetTextFont(42); ptx->SetTextSize(0.04); ptx->SetLineColor(1); ptx->SetLineStyle(1); ptx->SetLineWidth(1); ptx->SetFillColor(0); ptx->SetFillStyle(0); text = ptx->AddText(0.01, 0.01, "gg#rightarrow4l"); text->SetTextSize(0.04); TString canvasname = "cCanvas_MCFMBSM_GenLevel"; if (SignalOnly==1) canvasname.Append("_SignalOnly"); TCanvas* cc = new TCanvas(canvasname, "", 8, 30, 800, 800); cc->cd(); gStyle->SetOptStat(0); cc->SetFillColor(0); cc->SetBorderMode(0); cc->SetBorderSize(2); cc->SetTickx(1); cc->SetTicky(1); cc->SetLeftMargin(0.17); cc->SetRightMargin(0.05); cc->SetTopMargin(0.07); cc->SetBottomMargin(0.13); cc->SetFrameFillStyle(0); cc->SetFrameBorderMode(0); cc->SetFrameFillStyle(0); cc->SetFrameBorderMode(0); cc->SetLogy(); TLegend* ll; TLegend* ll2; ll = new TLegend(lxmin2, lymin2, lxmax2, lymax2); ll2 = new TLegend(lxmin, lymin, lxmax, lymax); ll->SetBorderSize(0); ll->SetTextFont(42); ll->SetTextSize(0.04); ll->SetLineColor(1); ll->SetLineStyle(1); ll->SetLineWidth(1); ll->SetFillColor(0); ll->SetFillStyle(0); ll2->SetBorderSize(0); ll2->SetTextFont(42); ll2->SetTextSize(0.04); ll2->SetLineColor(1); ll2->SetLineStyle(1); ll2->SetLineWidth(1); ll2->SetFillColor(0); ll2->SetFillStyle(0); TString strACtitle[9]={ "", "f_{a2}=1", "f_{a3}=1", "f_{#Lambda1}=1", "f_{#LambdaQ}=1", "f_{a2}=0.5, #phi_{#lower[-0.2]{a2}}=#pi", "f_{a3}=0.5", "f_{#Lambda1}=0.5", "f_{#LambdaQ}=0.5" }; int iDraw = 2 - 2*SignalOnly; if (SignalOnly==0) hfill[iDraw][0]->GetYaxis()->SetRangeUser(7e-3, maxplot*15.); else{ double histmin = 7e-3; if (hfill[iDraw][0]->GetMinimum()>0) histmin = hfill[iDraw][0]->GetMinimum(); hfill[iDraw][0]->GetYaxis()->SetRangeUser(histmin, maxplot*2000.); } hfill[iDraw][0]->GetXaxis()->SetRangeUser(xlimits[0], 800.); hfill[iDraw][0]->SetLineColor(kBlack); if (SignalOnly==0){ hfill[iDraw][0]->SetFillColor(kAzure-2); hfill[iDraw][0]->SetFillStyle(1001); } hfill[iDraw][0]->Draw("hist"); hfill[iDraw][1]->SetLineColor(kBlue); hfill[iDraw][1]->Draw("histsame"); hfill[iDraw][2]->SetLineColor(kRed); hfill[iDraw][2]->Draw("histsame"); hfill[iDraw][3]->SetLineColor(kViolet); hfill[iDraw][3]->Draw("histsame"); hfill[iDraw][4]->SetLineColor(kGreen+2); hfill[iDraw][4]->Draw("histsame"); if (SignalOnly==1){ hfill[iDraw][5]->SetLineColor(kBlue); hfill[iDraw][5]->Draw("histsame"); hfill[iDraw][6]->SetLineColor(kRed); hfill[iDraw][6]->Draw("histsame"); hfill[iDraw][7]->SetLineColor(kViolet); hfill[iDraw][7]->Draw("histsame"); hfill[iDraw][8]->SetLineColor(kGreen+2); hfill[iDraw][8]->Draw("histsame"); } if (SignalOnly==0){ hfill[1][0]->SetLineColor(kBlack); hfill[1][0]->SetLineStyle(3); hfill[1][0]->Draw("histsame"); } hfill[iDraw][0]->Draw("histsame"); TLegendEntry* legendtext; if (SignalOnly==0){ legendtext = ll->AddEntry(hfill[iDraw][0], "SM total", "f"); legendtext = ll->AddEntry(hfill[1][0], "SM bkg.", "f"); legendtext->SetFillStyle(1001); legendtext->SetFillColor(hfill[1][0]->GetFillColor()); } else{ legendtext = ll->AddEntry(hfill[iDraw][0], "SM signal", "f"); legendtext->SetFillStyle(3001); } if (SignalOnly==0){ legendtext = ll2->AddEntry(hfill[iDraw][4], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[4].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][4]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][2], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[2].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][2]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][1], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[1].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][1]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][3], Form("#Gamma_{H}=#Gamma^{SM}_{H}, %s", strACtitle[3].Data()), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][3]->GetFillColor()); } else{ legendtext = ll->AddEntry(hfill[iDraw][4], strACtitle[4].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][4]->GetFillColor()); legendtext = ll->AddEntry(hfill[iDraw][2], strACtitle[2].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][2]->GetFillColor()); legendtext = ll->AddEntry(hfill[iDraw][1], strACtitle[1].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][1]->GetFillColor()); legendtext = ll->AddEntry(hfill[iDraw][3], strACtitle[3].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][3]->GetFillColor()); } if (SignalOnly==1){ legendtext = ll2->AddEntry(hfill[iDraw][8], strACtitle[8].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][8]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][5], strACtitle[5].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][5]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][7], strACtitle[7].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][7]->GetFillColor()); legendtext = ll2->AddEntry(hfill[iDraw][6], strACtitle[6].Data(), "f"); legendtext->SetFillStyle(3001); legendtext->SetFillColor(hfill[iDraw][6]->GetFillColor()); } ll->Draw("same"); ll2->Draw("same"); ptx->Draw(); pt->Draw(); cc->RedrawAxis(); cc->Update(); canvasname.Prepend(coutput_common); TString canvasname_pdf = canvasname; TString canvasname_eps = canvasname; TString canvasname_png = canvasname; TString canvasname_root = canvasname; TString canvasname_c = canvasname; canvasname_pdf.Append(".pdf"); canvasname_eps.Append(".eps"); canvasname_png.Append(".png"); canvasname_root.Append(".root"); canvasname_c.Append(".C"); cc->SaveAs(canvasname_pdf); cc->SaveAs(canvasname_eps); cc->SaveAs(canvasname_png); cc->SaveAs(canvasname_root); cc->SaveAs(canvasname_c); foutput->WriteTObject(cc); delete ll2; delete ll; cc->Close(); delete ptx; delete pt; for (int t=0; t<4; t++){ for (int ac=0; ac<5; ac++){ foutput->WriteTObject(hfill[t][ac]); delete hfill[t][ac]; } } foutput->Close(); }
void picture2() { //=========Macro generated from canvas: c/ //========= (Wed Jul 15 12:53:51 2015) by ROOT version6.04/00 TCanvas *c = new TCanvas("c", "",0,45,600,500); c->SetHighLightColor(2); c->Range(-150,-150,1350,150); c->SetFillColor(0); c->SetBorderMode(0); c->SetBorderSize(2); c->SetFrameBorderMode(0); c->SetFrameBorderMode(0); Double_t _fx11[1] = { 792.688}; Double_t _fy11[1] = { 20.02759}; TGraph *graph = new TGraph(1,_fx11,_fy11); graph->SetName(""); graph->SetTitle("Event 2"); graph->SetFillColor(1); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#0000ff"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); TH1F *Graph_Graph11 = new TH1F("Graph_Graph11","Event 2",100,0,1200); Graph_Graph11->SetMinimum(-120); Graph_Graph11->SetMaximum(120); Graph_Graph11->SetDirectory(0); Graph_Graph11->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph11->SetLineColor(ci); Graph_Graph11->GetXaxis()->SetTitle("Z [cm]"); Graph_Graph11->GetXaxis()->SetLabelFont(42); Graph_Graph11->GetXaxis()->SetLabelSize(0.035); Graph_Graph11->GetXaxis()->SetTitleSize(0.035); Graph_Graph11->GetXaxis()->SetTitleFont(42); Graph_Graph11->GetYaxis()->SetTitle("Y [cm]"); Graph_Graph11->GetYaxis()->SetLabelFont(42); Graph_Graph11->GetYaxis()->SetLabelSize(0.035); Graph_Graph11->GetYaxis()->SetTitleSize(0.035); Graph_Graph11->GetYaxis()->SetTitleFont(42); Graph_Graph11->GetZaxis()->SetLabelFont(42); Graph_Graph11->GetZaxis()->SetLabelSize(0.035); Graph_Graph11->GetZaxis()->SetTitleSize(0.035); Graph_Graph11->GetZaxis()->SetTitleFont(42); graph->SetHistogram(Graph_Graph11); graph->Draw("ap"); Double_t _fx12[1] = { 792.688}; Double_t _fy12[1] = { 20.02759}; graph = new TGraph(1,_fx12,_fy12); graph->SetName(""); graph->SetTitle("Event 2"); graph->SetFillColor(1); ci = TColor::GetColor("#0000ff"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); TH1F *Graph_Graph_Graph1112 = new TH1F("Graph_Graph_Graph1112","Event 2",100,0,1200); Graph_Graph_Graph1112->SetMinimum(-120); Graph_Graph_Graph1112->SetMaximum(120); Graph_Graph_Graph1112->SetDirectory(0); Graph_Graph_Graph1112->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph_Graph1112->SetLineColor(ci); Graph_Graph_Graph1112->GetXaxis()->SetTitle("Z [cm]"); Graph_Graph_Graph1112->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph1112->GetXaxis()->SetLabelSize(0.035); Graph_Graph_Graph1112->GetXaxis()->SetTitleSize(0.035); Graph_Graph_Graph1112->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph1112->GetYaxis()->SetTitle("Y [cm]"); Graph_Graph_Graph1112->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph1112->GetYaxis()->SetLabelSize(0.035); Graph_Graph_Graph1112->GetYaxis()->SetTitleSize(0.035); Graph_Graph_Graph1112->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph1112->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph1112->GetZaxis()->SetLabelSize(0.035); Graph_Graph_Graph1112->GetZaxis()->SetTitleSize(0.035); Graph_Graph_Graph1112->GetZaxis()->SetTitleFont(42); graph->SetHistogram(Graph_Graph_Graph1112); graph->Draw("p"); Double_t _fx13[1] = { 801.6865}; Double_t _fy13[1] = { 111.6076}; graph = new TGraph(1,_fx13,_fy13); graph->SetName(""); graph->SetTitle(""); graph->SetFillColor(1); ci = TColor::GetColor("#00ff00"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); TH1F *Graph_Graph13 = new TH1F("Graph_Graph13","",100,801.5865,802.7865); Graph_Graph13->SetMinimum(-120); Graph_Graph13->SetMaximum(120); Graph_Graph13->SetDirectory(0); Graph_Graph13->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph13->SetLineColor(ci); Graph_Graph13->GetXaxis()->SetRange(0,101); Graph_Graph13->GetXaxis()->SetLabelFont(42); Graph_Graph13->GetXaxis()->SetLabelSize(0.035); Graph_Graph13->GetXaxis()->SetTitleSize(0.035); Graph_Graph13->GetXaxis()->SetTitleFont(42); Graph_Graph13->GetYaxis()->SetLabelFont(42); Graph_Graph13->GetYaxis()->SetLabelSize(0.035); Graph_Graph13->GetYaxis()->SetTitleSize(0.035); Graph_Graph13->GetYaxis()->SetTitleFont(42); Graph_Graph13->GetZaxis()->SetLabelFont(42); Graph_Graph13->GetZaxis()->SetLabelSize(0.035); Graph_Graph13->GetZaxis()->SetTitleSize(0.035); Graph_Graph13->GetZaxis()->SetTitleFont(42); graph->SetHistogram(Graph_Graph13); graph->Draw("p"); Double_t _fx14[1] = { 801.6865}; Double_t _fy14[1] = { 111.6076}; graph = new TGraph(1,_fx14,_fy14); graph->SetName(""); graph->SetTitle(""); graph->SetFillColor(1); ci = TColor::GetColor("#00ff00"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); TH1F *Graph_Graph_Graph1314 = new TH1F("Graph_Graph_Graph1314","",100,801.5865,802.7865); Graph_Graph_Graph1314->SetMinimum(-120); Graph_Graph_Graph1314->SetMaximum(120); Graph_Graph_Graph1314->SetDirectory(0); Graph_Graph_Graph1314->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph_Graph1314->SetLineColor(ci); Graph_Graph_Graph1314->GetXaxis()->SetRange(0,101); Graph_Graph_Graph1314->GetXaxis()->SetLabelFont(42); Graph_Graph_Graph1314->GetXaxis()->SetLabelSize(0.035); Graph_Graph_Graph1314->GetXaxis()->SetTitleSize(0.035); Graph_Graph_Graph1314->GetXaxis()->SetTitleFont(42); Graph_Graph_Graph1314->GetYaxis()->SetLabelFont(42); Graph_Graph_Graph1314->GetYaxis()->SetLabelSize(0.035); Graph_Graph_Graph1314->GetYaxis()->SetTitleSize(0.035); Graph_Graph_Graph1314->GetYaxis()->SetTitleFont(42); Graph_Graph_Graph1314->GetZaxis()->SetLabelFont(42); Graph_Graph_Graph1314->GetZaxis()->SetLabelSize(0.035); Graph_Graph_Graph1314->GetZaxis()->SetTitleSize(0.035); Graph_Graph_Graph1314->GetZaxis()->SetTitleFont(42); graph->SetHistogram(Graph_Graph_Graph1314); graph->Draw("p"); Double_t _fx15[1] = { 823.7501}; Double_t _fy15[1] = { 86.87169}; graph = new TGraph(1,_fx15,_fy15); graph->SetName(""); graph->SetTitle(""); graph->SetFillColor(1); ci = TColor::GetColor("#ff0000"); graph->SetMarkerColor(ci); graph->SetMarkerStyle(20); TH1F *Graph_Graph15 = new TH1F("Graph_Graph15","",100,823.6501,824.8501); Graph_Graph15->SetMinimum(-120); Graph_Graph15->SetMaximum(120); Graph_Graph15->SetDirectory(0); Graph_Graph15->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph15->SetLineColor(ci); Graph_Graph15->GetXaxis()->SetLabelFont(42); Graph_Graph15->GetXaxis()->SetLabelSize(0.035); Graph_Graph15->GetXaxis()->SetTitleSize(0.035); Graph_Graph15->GetXaxis()->SetTitleFont(42); Graph_Graph15->GetYaxis()->SetLabelFont(42); Graph_Graph15->GetYaxis()->SetLabelSize(0.035); Graph_Graph15->GetYaxis()->SetTitleSize(0.035); Graph_Graph15->GetYaxis()->SetTitleFont(42); Graph_Graph15->GetZaxis()->SetLabelFont(42); Graph_Graph15->GetZaxis()->SetLabelSize(0.035); Graph_Graph15->GetZaxis()->SetTitleSize(0.035); Graph_Graph15->GetZaxis()->SetTitleFont(42); graph->SetHistogram(Graph_Graph15); graph->Draw("p"); TPaveText *pt = new TPaveText(0.4189298,0.94,0.5810702,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("Event 2"); pt->Draw(); c->Modified(); c->cd(); c->SetSelected(c); }
TCanvas* getExtrapolFak(TString plotName, TString label, int verbose, TString outputFileFull, TString outputFileParton, TString outputFileHadron){ // ============================ // Set Root Style // ============================ TStyle myStyle("HHStyle","HHStyle"); setHHStyle(myStyle); TGaxis::SetMaxDigits(2); myStyle.cd(); gROOT->SetStyle("HHStyle"); // open files TFile* fileFull = TFile::Open(outputFileFull , "READ"); TFile* fileParton = TFile::Open(outputFileParton, "READ"); TFile* fileHadron = TFile::Open(outputFileHadron, "READ"); // dont associate new objects with file to be able to close it in the end gROOT->cd(); // get canvas^3 for chosen cross section TCanvas* canvasFull = (TCanvas*)(fileFull ->Get("xSec/sysNo/"+plotName+"Norm")->Clone()); TCanvas* canvasParton = (TCanvas*)(fileParton->Get("xSec/sysNo/"+plotName+"Norm")->Clone()); TCanvas* canvasHadron = (TCanvas*)(fileHadron->Get("xSec/sysNo/"+plotName+"Norm")->Clone()); // get data histos TH1F* dataFull = killEmptyBins((TH1F*)((canvasFull ->GetPrimitive(plotName+"kData"))->Clone())); TH1F* dataRawParton = killEmptyBins((TH1F*)((canvasParton->GetPrimitive(plotName+"kData"))->Clone())); TH1F* dataRawHadron = killEmptyBins((TH1F*)((canvasHadron->GetPrimitive(plotName+"kData"))->Clone())); // use always the correct PS definition: // hadron level for b-quarks and lepton // parton level for all others TH1F* dataPS = ( (plotName.Contains("bq")||plotName.Contains("lep")) ? (TH1F*)dataRawHadron->Clone() : (TH1F*)dataRawParton->Clone() ); // adjust style and labels TString PSlabel = ( (plotName.Contains("bq")||plotName.Contains("lep")) ? "hadron" : "parton" ); int color = kBlue; if(PSlabel=="hadron") color-=4; dataPS->SetLineColor(color); dataPS->SetMarkerColor(color); histogramStyle(*dataFull, kData); dataFull->SetLineWidth(3); dataPS->SetLineWidth(3); if (plotName=="lepPt") dataFull->GetXaxis()->SetRangeUser(0.,199.); else if(plotName=="bqPt" ) dataFull->GetXaxis()->SetRangeUser(0.,399.); else setXAxisRange(dataFull, plotName); double max=dataFull->GetMaximum(); if(max<dataPS->GetMaximum()) max=dataPS->GetMaximum(); dataFull->SetMaximum(1.3*max); dataFull->GetXaxis()->SetTitle(xSecLabelName(plotName)); TString label2=label; TString label3=""; if(label.Contains("/[GeV]")){ label2.ReplaceAll("/[GeV]",""); label3=" / [GeV]"; } label2.ReplaceAll("/ ",""); dataFull->GetYaxis()->SetTitle("#frac{1}{#sigma} #frac{d#sigma}{d"+label2+"}"+label3); dataFull->GetYaxis()->SetNoExponent(false); dataFull->GetXaxis()->SetNoExponent(true); dataFull->SetTitle(""); // create legend TLegend *leg0 = new TLegend(0.65, 0.762, 0.95, 0.89); leg0->SetFillStyle(0); leg0->SetBorderSize(0); leg0->SetHeader("phase spaces"); leg0->AddEntry(dataFull, "extrapol. parton lv","L"); leg0->AddEntry(dataPS , "restricted "+PSlabel+" lv","L"); // create label TPaveText *headerlabel = new TPaveText(); headerlabel -> SetX1NDC(gStyle->GetPadLeftMargin()); headerlabel -> SetY1NDC(1.0-gStyle->GetPadTopMargin()); headerlabel -> SetX2NDC(1.0-gStyle->GetPadRightMargin()); headerlabel -> SetY2NDC(1.0); headerlabel -> SetTextFont(42); headerlabel -> AddText("comparing 2011 data results"); headerlabel->SetFillStyle(0); headerlabel->SetBorderSize(0); headerlabel->SetTextSize(0.04); headerlabel->SetTextAlign(32); // create extrapolation factor / ratio canvas std::vector<TCanvas*> plotCanvas_; addCanvas(plotCanvas_); plotCanvas_[0]->cd(); plotCanvas_[0]->Draw(); dataFull->Draw("hist"); dataPS->Draw("hist same"); leg0->Draw("same"); headerlabel->Draw("same"); DrawDecayChLabel("e/#mu + Jets Combined"); drawRatio(dataPS, dataFull, 0., 2.4, myStyle, verbose, std::vector<double>(0), PSlabel+" PS", "extrapolated", "hist", kBlack); // close files fileFull ->Close(); fileParton->Close(); fileHadron->Close(); // return return plotCanvas_[0]; }
void showGraphs(const TString& title, double canvasSizeX, double canvasSizeY, TGraph* graph1, const std::string& legendEntry1, TGraph* graph2, const std::string& legendEntry2, TGraph* graph3, const std::string& legendEntry3, TGraph* graph4, const std::string& legendEntry4, TGraph* graph5, const std::string& legendEntry5, TGraph* graph6, const std::string& legendEntry6, double xMin, double xMax, unsigned numBinsX, const std::string& xAxisTitle, double xAxisOffset, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, double legendX0, double legendY0, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); int colors[6] = { 1, 2, 3, 4, 6, 7 }; int markerStyles[6] = { 22, 32, 20, 24, 21, 25 }; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.20, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", numBinsX, xMin, xMax); dummyHistogram->SetTitle(""); dummyHistogram->SetStats(false); dummyHistogram->SetMinimum(yMin); dummyHistogram->SetMaximum(yMax); TAxis* xAxis = dummyHistogram->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = dummyHistogram->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); dummyHistogram->Draw("axis"); graph1->SetLineColor(colors[0]); graph1->SetLineWidth(2); graph1->Draw("L"); legend->AddEntry(graph1, legendEntry1.data(), "l"); if ( graph2 ) { graph2->SetLineColor(colors[1]); graph2->SetLineWidth(2); graph2->Draw("L"); legend->AddEntry(graph2, legendEntry2.data(), "l"); } if ( graph3 ) { graph3->SetLineColor(colors[2]); graph3->SetLineWidth(2); graph3->Draw("L"); legend->AddEntry(graph3, legendEntry3.data(), "l"); } if ( graph4 ) { graph4->SetLineColor(colors[3]); graph4->SetLineWidth(2); graph4->Draw("L"); legend->AddEntry(graph4, legendEntry4.data(), "l"); } if ( graph5 ) { graph5->SetLineColor(colors[4]); graph5->SetLineWidth(2); graph5->Draw("L"); legend->AddEntry(graph5, legendEntry5.data(), "l"); } if ( graph6 ) { graph6->SetLineColor(colors[5]); graph6->SetLineWidth(2); graph6->Draw("L"); legend->AddEntry(graph6, legendEntry6.data(), "l"); } legend->Draw(); TPaveText* label = 0; if ( title.Length() > 0 ) { label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC"); label->AddText(title.Data()); label->SetTextAlign(13); label->SetTextSize(0.045); label->SetFillStyle(0); label->SetBorderSize(0); label->Draw(); } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data()); canvas->Print(std::string(outputFileName_plot).append(".png").data()); canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); delete legend; delete label; delete dummyHistogram; delete canvas; }
//------------------------------------------------------------------------------- void showDistribution(const TString& title, double canvasSizeX, double canvasSizeY, TH1* histogram1, const std::string& legendEntry1, TH1* histogram2, const std::string& legendEntry2, TH1* histogram3, const std::string& legendEntry3, TH1* histogram4, const std::string& legendEntry4, const std::string& xAxisTitle, double xAxisOffset, bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset, double legendX0, double legendY0, const std::string& outputFileName) { TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY); canvas->SetFillColor(10); canvas->SetBorderSize(2); canvas->SetLeftMargin(0.12); canvas->SetBottomMargin(0.12); canvas->SetLogy(useLogScale); int colors[6] = { 1, 2, 3, 4, 6, 7 }; int markerStyles[6] = { 22, 32, 20, 24, 21, 25 }; int numHistograms = 1; if ( histogram2 ) ++numHistograms; if ( histogram3 ) ++numHistograms; if ( histogram4 ) ++numHistograms; TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.05*numHistograms, "", "brNDC"); legend->SetBorderSize(0); legend->SetFillColor(0); histogram1->SetTitle(""); histogram1->SetStats(false); histogram1->SetMinimum(yMin); histogram1->SetMaximum(yMax); histogram1->SetLineColor(colors[0]); histogram1->SetLineWidth(2); histogram1->SetMarkerColor(colors[0]); histogram1->SetMarkerStyle(markerStyles[0]); histogram1->Draw("e1p"); legend->AddEntry(histogram1, legendEntry1.data(), "p"); TAxis* xAxis = histogram1->GetXaxis(); xAxis->SetTitle(xAxisTitle.data()); xAxis->SetTitleOffset(xAxisOffset); TAxis* yAxis = histogram1->GetYaxis(); yAxis->SetTitle(yAxisTitle.data()); yAxis->SetTitleOffset(yAxisOffset); if ( histogram2 ) { histogram2->SetLineColor(colors[1]); histogram2->SetLineWidth(2); histogram2->SetMarkerColor(colors[1]); histogram2->SetMarkerStyle(markerStyles[1]); histogram2->Draw("e1psame"); legend->AddEntry(histogram2, legendEntry2.data(), "p"); } if ( histogram3 ) { histogram3->SetLineColor(colors[2]); histogram3->SetLineWidth(2); histogram3->SetMarkerColor(colors[2]); histogram3->SetMarkerStyle(markerStyles[2]); histogram3->Draw("e1psame"); legend->AddEntry(histogram3, legendEntry3.data(), "p"); } if ( histogram4 ) { histogram4->SetLineColor(colors[3]); histogram4->SetLineWidth(2); histogram4->SetMarkerColor(colors[3]); histogram4->SetMarkerStyle(markerStyles[3]); histogram4->Draw("e1psame"); legend->AddEntry(histogram4, legendEntry4.data(), "p"); } legend->Draw(); TPaveText* label = 0; if ( title.Length() > 0 ) { label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC"); label->AddText(title.Data()); label->SetTextAlign(13); label->SetTextSize(0.045); label->SetFillStyle(0); label->SetBorderSize(0); label->Draw(); } canvas->Update(); size_t idx = outputFileName.find_last_of('.'); std::string outputFileName_plot = std::string(outputFileName, 0, idx); if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data()); canvas->Print(std::string(outputFileName_plot).append(".png").data()); canvas->Print(std::string(outputFileName_plot).append(".pdf").data()); delete legend; delete label; delete canvas; }
int compare(){ gROOT->SetStyle("Plain"); // For the canvas: gStyle->SetCanvasColor(0); // For the Pad: gStyle->SetPadColor(0); gStyle->SetPadTickX(1); gStyle->SetPadTickY(1); gStyle->SetPadBorderSize(2); // For the frame: gStyle->SetFrameBorderMode(0); // For the statistics box: gStyle->SetOptStat(0); // Margins: gStyle->SetPadBottomMargin(0.25); gStyle->SetPadTopMargin(0.15); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadRightMargin(0.1); // For the Global title: gStyle->SetOptTitle(0); gStyle->SetTitleColor(1); gStyle->SetTitleFillColor(10); gStyle->SetTitleTextColor(1); gStyle->SetTitleFont(42); gStyle->SetTitleFontSize(0.05); gStyle->SetTitleBorderSize(0); // For the axis gStyle->SetNdivisions(510, "X"); gStyle->SetNdivisions(510, "Y"); gStyle->SetTickLength(0.03); // For the axis titles: gStyle->SetTitleOffset(1.4, "X"); gStyle->SetTitleOffset(1.2, "Y"); gStyle->SetTitleOffset(0.5, "Z"); gStyle->SetTitleSize(0.061, "XYZ"); gStyle->SetTitleFont(42, "XYZ"); // For the axis labels: gStyle->SetLabelSize(0.04, "XYZ"); gStyle->SetLabelOffset(0.01, "XYZ"); gStyle->SetLabelFont(42, "XYZ"); // For the legend gStyle->SetLegendBorderSize(0); gROOT->ForceStyle(); //////////////////////////////////////// TFile *f1 = new TFile("output_GetPrediction/prediction_histos_MyTest_data_METsoftSmeared_noAngSmear_N20_CR_v3.root", "READ", "", 0); TFile *f2 = new TFile("output_GetPrediction/bkg.root", "READ", "", 0); selection = (TH1F*) f1->FindObjectAny("VBF_MET_presel_4JV_dPhiSide_selection"); prediction = (TH1F*) f1->FindObjectAny("VBF_MET_presel_4JV_dPhiSide_prediction_px"); background2 = (TH1F*) f2->FindObjectAny("met_check_inVR_rebin"); TH1F* background = new TH1F(*prediction); background->Reset(); for (int i = 1; i <= background->GetXaxis()->GetNbins(); ++i) { float x = background->GetXaxis()->GetBinCenter(i); int j = background2->GetXaxis()->FindBin(x); float value = background2->GetBinContent(j); float error = background2->GetBinError(j); background->SetBinContent(i,value); background->SetBinError(i,error); } //double MinX = selection->GetXaxis()->GetBinLowEdge(1); //double MaxX = selection->GetXaxis()->GetBinUpEdge(selection->GetXaxis()->GetNbins()); double MinX = 150; double MaxX = 500; double BinWidth = selection->GetXaxis()->GetBinWidth(selection->GetXaxis()->GetNbins()); double MaxY = prediction->GetBinContent(prediction->GetMaximumBin()); double MaxYsel = selection->GetBinContent(selection->GetMaximumBin()); if (MaxY < MaxYsel) MaxY = MaxYsel; double YRangeMax = 2.*pow(10., int(log10(MaxY))+2); double MinY = prediction->GetBinContent(prediction->GetMinimumBin()); double MinYsel = selection->GetBinContent(selection->GetMinimumBin()); if (MinY > MinYsel) MinY = MinYsel; if (MinY < 0.001) MinY = 0.001; double YRangeMin = 0.5*pow(10., int(log10(MinY))-2); TString titlePrediction; TString titleSelection; TString titleBackground; TString RatioTitle; TString LumiTitle; TString Title; TString xTitle; TString yTitle; LumiTitle = "ATLAS internal, L = 36.1 fb^{ -1}, #sqrt{s} = 13 TeV"; Title = "3 jets, 1.8<#Delta#phi(jj)<2.7, MET>150 GeV, M(jj)>0.6 TeV, p_{T}^{3rd}<50 GeV"; xTitle = "#slash{E}_{T} (GeV)"; yTitle = "Events"; titlePrediction = "Data-driven Pred."; titleSelection = "Data"; titleBackground = "non-QCD background"; RatioTitle = "(Pred-Data)/Data"; static Int_t c_LightBrown = TColor::GetColor( "#D9D9CC" ); static Int_t c_LightGray = TColor::GetColor( "#DDDDDD" ); selection->SetAxisRange(MinX, MaxX, "X"); selection->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax); selection->SetMarkerStyle(20); selection->SetMarkerSize(0.9); selection->SetMarkerColor(kBlack); selection->SetXTitle(xTitle); selection->SetYTitle(yTitle); prediction->SetAxisRange(MinX, MaxX, "X"); prediction->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax); prediction->SetFillColor(c_LightGray); prediction->SetTitle(""); prediction->SetXTitle(xTitle); prediction->SetYTitle(yTitle); background->SetAxisRange(MinX, MaxX, "X"); background->GetYaxis()->SetRangeUser(YRangeMin, YRangeMax); background->SetTitle(""); background->SetLineColor(kRed); background->SetLineWidth(2); background->SetXTitle(xTitle); background->SetYTitle(yTitle); TCanvas *c = new TCanvas("ca", "Comparison and ratio of two histos", 700, 700); TPad *pad1 = new TPad("pad1a", "pad1a", 0, 0.35, 1, 1); pad1->SetLogy(); pad1->SetBottomMargin(0); pad1->Draw(); pad1->cd(); prediction->DrawCopy("hist"); selection->Draw("same"); prediction->SetFillColor(kAzure-3); prediction->SetFillStyle(3354); prediction->DrawCopy("e2same"); background->Scale(36.1/32.6); background->Draw("same"); prediction->SetFillStyle(1001); //prediction->SetFillColor(c_LightBrown); prediction->SetFillColor(c_LightGray); //TLegend* leg1 = new TLegend(0.48, 0.63, 0.95, 0.83); TLegend* leg1 = new TLegend(0.44, 0.63, 0.91, 0.83); leg1->SetFillStyle(0); leg1->SetLineStyle(1); leg1->SetTextFont(42); //leg1->SetTextSize(0.04); leg1->SetTextSize(0.045); leg1->AddEntry(prediction, titlePrediction, "lf"); leg1->AddEntry(selection, titleSelection, "lep"); leg1->AddEntry(background, titleBackground, "l"); leg1->Draw("same"); TPaveText* pt = new TPaveText(0.11, 0.98, 0.95, 0.86, "NDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(12); pt->SetTextSize(0.045); pt->AddText(Title); pt->AddText(LumiTitle); pt->Draw(); c->cd(); TPad *pad2 = new TPad("pad2a", "pad2a", 0, 0, 1, 0.35); pad2->SetTopMargin(0); pad2->Draw(); pad2->cd(); TH1F* r = new TH1F(*prediction); r->SetTitle(""); r->SetLabelSize(0.08, "XYZ"); r->SetLabelOffset(0.01, "XYZ"); // r->SetTitleSize(0.09, "XYZ"); r->SetTitleSize(0.125, "XYZ"); r->SetTitleOffset(0.95, "X"); r->SetTitleOffset(0.53, "Y"); // r->SetTitleOffset(0.65, "Y"); r->SetTickLength(0.05); r->SetYTitle(RatioTitle); r->SetStats(0); r->SetMarkerStyle(20); r->SetMarkerSize(0.9); r->SetMarkerColor(kBlack); r->Reset(); r->Add(prediction, 1); r->Add(background, 1); r->Add(selection, -1); r->Divide(selection); r->SetMaximum(2.2); r->SetMinimum(-2.2); r->Draw("ep"); TLine l; l.DrawLine(MinX, 0., MaxX+BinWidth, 0.); c->cd(); c->SaveAs("compare.pdf"); return 0; }
//RooRealVar fitSvtxmTag = bfractionFit(fixCL,"svtxm",0,6,centBin[n],centBin[n+1],ptlo,pthi,etalo,etahi,tagger,workingPoint,6,"b-tagged sample (ssvHighEff at 2)",9e3); RooRealVar bfractionFit(bool fixCL=1, char *var="discr_prob", double minXvar=0, double maxXvar=3, int centlo, int centhi, float ptMin, float ptMax, float etalo, float etahi, // by default, no b-tagging : char *discr="discr_prob", double minXdiscr=-999, double maxXdiscr=999, char *comment="inclusive sample", double maxYaxis=1e3) { gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetLabelFont(43,"xyz"); gStyle->SetLabelSize(20,"xyz"); gStyle->SetTitleFont(43,"xyz"); gStyle->SetTitleSize(26,"xyz"); gStyle->SetTitleOffset(1.0,"x"); gROOT->ForceStyle(1); int cbinlo = (int)centlo/2.5; int cbinhi = (int)centhi/2.5; // discr_prob : from (0) 0 to 3, operating point : 0.6 (1%), 0.7 // discr_ssvHighEff : from (-1) 1 to 6, operating point : 2 ? // discr_ssvHighPur : from (-1) 1 to 6, operating point : 2 ? // discr_csvSimple : from (-10,-1) 0 to 1, operating point : 0.9 // svtxm : from (0) 0 to 7 // muptrel : from (0) 0 to 5 //* TFile *fQCDMC = new TFile("histos/PbPbQCDMC.root"); TFile *fBMC = new TFile("histos/PbPbBMC.root"); TFile *fCMC = new TFile("histos/PbPbCMC.root"); TFile *fdata = new TFile("histos/PbPbdata.root"); //*/ /* TFile *fQCDMC = new TFile("histos/ppMC_hiReco_jetTrig.root"); TFile *fBMC = new TFile("histos/ppMC_hiReco_jetTrig.root"); TFile *fCMC = new TFile("histos/ppMC_hiReco_jetTrig.root"); TFile *fdata = new TFile("histos/ppdata_hiReco_jetTrig.root"); */ TTree *tQCDMC = (TTree*) fQCDMC->Get("nt"); TTree *tBMC = (TTree*) fBMC->Get("nt"); TTree *tCMC = (TTree*) fCMC->Get("nt"); TTree *tdata = (TTree*) fdata->Get("nt"); int nhistBins=30; if(var=="svtxm") nhistBins=24; TH1D *hB = new TH1D("hB","",nhistBins,minXvar,maxXvar); hB->Sumw2(); tBMC->Draw(Form("%s>>hB",var),Form("weight*(abs(refparton_flavorForB)==5&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)); fixEmpty(hB); TH1D *hC = new TH1D("hC","",nhistBins,minXvar,maxXvar); hC->Sumw2(); tCMC->Draw(Form("%s>>hC",var),Form("weight*(abs(refparton_flavorForB)==4&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)); fixEmpty(hC); TH1D *hL = new TH1D("hL","",nhistBins,minXvar,maxXvar); hL->Sumw2(); tQCDMC->Draw(Form("%s>>hL",var),Form("weight*(abs(refparton_flavorForB)!=5&&abs(refparton_flavorForB)!=4&&abs(refparton_flavorForB)<99&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)); fixEmpty(hL); /* TH1D *hCaux = new TH1D("hCaux","",nhistBins,minXvar,maxXvar); hCaux->Sumw2(); tQCDMC->Draw(Form("%s>>hCaux",var),Form("weight*(abs(refparton_flavorForB)==4&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)); fixEmpty(hCaux); */ /* TH1D *hCL = new TH1D("hCL","",nhistBins,minXvar,maxXvar); hCL->Sumw2(); tQCDMC->Draw(Form("%s>>hCL",var),Form("weight*(abs(refparton_flavorForB)!=5&&abs(refparton_flavorForB)<99&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)); fixEmpty(hCL); //*/ //* TH1D *hCL = hL->Clone(); //Double_t cCoef = hCaux->Integral()/hC->Integral(); hCL->Add(hC); //*/ // --- Observable --- RooRealVar s(var,var,0,minXvar,maxXvar); RooRealVar jtpt("jtpt","jtpt",0,ptMin,ptMax); RooRealVar discriminator(discr,discr,0,minXdiscr,maxXdiscr); RooRealVar bin("bin","bin",0,0,40); RooRealVar jteta("jteta","jteta",0,-2,2); // --- Build Histogram PDF --- RooDataHist xB("xB","xB",s,hB); RooHistPdf bottom("bottom","bottom PDF",s,xB); RooDataHist xC("xC","xC",s,hC); RooHistPdf charm("charm","charm PDF",s,xC); RooDataHist xL("xL","xL",s,hL); RooHistPdf light("light","light PDF",s,xL); RooDataHist xCL("xCL","xCL",s,hCL); RooHistPdf charmlight("charmlight","charmlight PDF",s,xCL); /* cout<<"hB "<<hB->Integral()<<endl; cout<<"hC "<<hC->Integral()<<endl; cout<<"hL "<<hL->Integral()<<endl; cout<<"hCL "<<hCL->Integral()<<endl; //*/ // --- Construct signal+background PDF --- //Double_t bInitFrac = hB->Integral()/(hB->Integral()+hCL->Integral()); //Double_t cInitFrac = hC->Integral()/(hB->Integral()+hCL->Integral()); RooRealVar Bfraction("Bfraction","#light events",0.3,0.,1); RooRealVar Cfraction("Cfraction","#background events",0.3,0.,1); if(fixCL) RooAddPdf model("model","",bottom,charmlight,Bfraction); else RooAddPdf model("model","",RooArgList(bottom,charm,light),RooArgList(Bfraction,Cfraction)); // --- Data sample --- //RooDataSet *data = new RooDataSet("data","data",tdata,RooArgSet(s,jtpt,discriminator),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr)); //RooDataSet *data = new RooDataSet("data","data",tdata,RooArgSet(s,jtpt,discriminator),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&fabs(jteta)>%f&&fabs(jteta)<%f",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)); RooDataSet *data = new RooDataSet("data","data",tdata,RooArgSet(s,jtpt,jteta,bin,discriminator),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&abs(jteta)>%f&&abs(jteta)<%f&&bin>=%d&&bin<%d",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,etalo,etahi,cbinlo,cbinhi)); TPaveText *header = new TPaveText(0.05,0.9,0.95,0.99); header->AddText(Form("%s - ROOFIT ML unbinned fit of %s",var,fixCL?"2 components : bottom and (charm + light)":"3 components : bottom, charm and light")); header->AddText(Form("Pb-Pb data - %s",comment)); header->AddText(Form("%s%.0f <= jet pT < %.0f",(var=="muptrel")?"deltaR < 0.5 ; muon pT > 5 ; ":"",ptMin,ptMax)); header->SetTextSize(0.027); header->SetTextAlign(12); header->SetBorderSize(0); header->SetFillStyle(0); //header->Draw(); //RooPlot* sframe = s.frame(); TH2D *htemp = new TH2D(Form("%s%.0f%.0f",var,ptMin,ptMax),Form("%s%.0f%.0f",var,ptMin,ptMax),100,minXvar,maxXvar,100,0.5,maxYaxis) ; //htemp->SetXTitle(Form("%s %.0f < p_{T} < %.0f GeV/c",var,ptMin,ptMax)); if(var=="svtxm")htemp->SetXTitle("SV mass (GeV/c^{2})"); else htemp->SetXTitle("JP Disc."); htemp->SetYTitle("Entries"); /* htemp->Draw(); data->plotOn(sframe,Binning(25)); if(fixCL) { model.plotOn(sframe,Components(charmlight),LineStyle(kDashed),LineColor(30),LineWidth(2)); } else { model.plotOn(sframe,Components(light),LineStyle(kDashed),LineColor(kBlue),LineWidth(2)); model.plotOn(sframe,Components(charm),LineStyle(kDashed),LineColor(kGreen),LineWidth(2)); model.plotOn(sframe,Components(RooArgSet(charm,light)),LineStyle(kDashed),LineColor(30),LineWidth(2)); } model.plotOn(sframe,Components(bottom),LineStyle(kDashed),LineColor(kRed),LineWidth(2),FillColor(kRed),FillStyle(1)); model.plotOn(sframe,LineWidth(2),LineColor(13)); data->plotOn(sframe,Binning(25)); model.paramOn(sframe,Layout(0.4,0.9,0.9),Format("NEU",FixedPrecision(3))); sframe->Draw("same"); */ // --- Perform extended ML fit of composite PDF to data --- //RooFitResult *fitresult = model.fitTo(*data,Save(),PrintLevel(-1)); RooFitResult *fitresult = model.fitTo(*data,Save()); RooPlot* sframe = s.frame(); // sframe = s.frame(); htemp->Draw(); if(var=="svtxm")data->plotOn(sframe,Binning(24)); else data->plotOn(sframe,Binning(30)); if(fixCL) { model.plotOn(sframe,Components(charmlight),LineStyle(kDashed),LineColor(30),LineWidth(2)); } else { model.plotOn(sframe,Components(light),LineStyle(kDashed),LineColor(kBlue),LineWidth(2)); model.plotOn(sframe,Components(charm),LineStyle(kDashed),LineColor(kGreen),LineWidth(2)); model.plotOn(sframe,Components(RooArgSet(charm,light)),LineStyle(kDashed),LineColor(30),LineWidth(2)); } model.plotOn(sframe,Components(bottom),LineStyle(kDashed),LineColor(kRed),LineWidth(2),FillColor(kRed),FillStyle(1)); model.plotOn(sframe,LineWidth(2),VisualizeError(*fitresult),FillColor(17)); model.plotOn(sframe,LineWidth(2),LineColor(13)); if(var=="svtxm")data->plotOn(sframe,Binning(24)); else data->plotOn(sframe,Binning(30)); model.paramOn(sframe,Layout(0.4,0.9,0.9),Format("NEU",FixedPrecision(3))); sframe->Draw("same"); TLegend *leg = new TLegend(0.61,fixCL?0.60:0.50,0.98,fixCL?0.78:0.75); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->AddEntry("h_data","PbPb data","p"); leg->AddEntry(Form("model_Norm[%s]_Comp[bottom]",var),"b","l"); if(fixCL) { leg->AddEntry(Form("model_Norm[%s]_Comp[charmlight]",var),"c + udsg","l"); } else { leg->AddEntry(Form("model_Norm[%s]_Comp[charm]",var),"c","l"); leg->AddEntry(Form("model_Norm[%s]_Comp[light]",var),"udsg","l"); leg->AddEntry(Form("model_Norm[%s]_Comp[charm,light]",var),"c + udsg","l"); } leg->AddEntry(Form("model_Norm[%s]",var),"b + c + udsg","l"); leg->Draw("same"); cout<<Form("weight*(abs(refparton_flavorForB)==5&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi)<<"\n\n"<<endl; ////////////////////////////////////////////////////////// //Plot Stacked histos ////////////////////////////////////////////////////////// int nXbins = 12; bool doLog = true; hMCB[counter] = new TH1D(Form("hMCB_%d",counter),Form("hMCB_%d",counter),nXbins,minXvar,maxXvar); hMCC[counter] = new TH1D(Form("hMCC_%d",counter),Form("hMCC_%d",counter),nXbins,minXvar,maxXvar); hMCL[counter] = new TH1D(Form("hMCL_%d",counter),Form("hMCL_%d",counter),nXbins,minXvar,maxXvar); hMCLC[counter] = new TH1D(Form("hMCLC_%d",counter),Form("hMCLC_%d",counter),nXbins,minXvar,maxXvar); hData[counter] = new TH1D(Form("hData_%d",counter),Form("hData_%d",counter),nXbins,minXvar,maxXvar); hData[counter]->Sumw2(); hMCL[counter]->Sumw2(); hMCB[counter]->Sumw2(); hMCC[counter]->Sumw2(); hMCLC[counter]->Sumw2(); tBMC->Draw(Form("%s>>hMCB_%d",var,counter),Form("weight*(abs(refparton_flavorForB)==5&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi),"goff"); tCMC->Draw(Form("%s>>hMCC_%d",var,counter),Form("weight*(abs(refparton_flavorForB)==4&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi),"goff"); tQCDMC->Draw(Form("%s>>hMCL_%d",var,counter),Form("weight*(abs(refparton_flavorForB)!=5&&abs(refparton_flavorForB)!=4&&abs(refparton_flavorForB)<99&&jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&bin>=%d&&bin<%d&&abs(jteta)>%f&&abs(jteta)<%f)",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,cbinlo,cbinhi,etalo,etahi),"goff"); tdata->Draw(Form("%s>>hData_%d",var,counter),Form("jtpt>=%f&&jtpt<%f&&%s>=%f&&%s<%f&&abs(jteta)>%f&&abs(jteta)<%f&&bin>=%d&&bin<%d",ptMin,ptMax,discr,minXdiscr,discr,maxXdiscr,etalo,etahi,cbinlo,cbinhi),"goff"); hMCLC[counter]->Add( hMCL[counter]); hMCLC[counter]->Add( hMCC[counter]); fixEmpty(hMCB[counter]); fixEmpty(hMCC[counter]); fixEmpty(hMCL[counter]); fixEmpty(hMCLC[counter]); fixEmpty(hData[counter]); can1[counter] = new TCanvas(Form("can1_%d",counter),Form("can1_%d",counter),700,600); hs[counter] = new THStack(Form("hs_%d",counter),"le stack of MC histos"); fakehs[counter] = new THStack(Form("fakehs_%d",counter),"le fake stack of MC histos"); can1[counter]->cd(); if (doLog) can1[counter]->cd()->SetLogy(); if (doLog){ hData[counter]->SetMaximum(hData[counter]->GetMaximum()*100); hData[counter]->SetMinimum(0.5); } if (!doLog){ hData[counter]->SetMaximum(hData[counter]->GetMaximum()*1.5); hData[counter]->SetMinimum(0.0); } const char* yTitle; const char* xTitle; if (var=="svtxm") xTitle = Form("Secondary Vertex Mass [GeV/c^{2}]"); if (var=="discr_prob") xTitle = Form("Jet Probability"); //if (var=="svtxm") yTitle = (Form("Number of Jets / %3.2f GeV",(maxXvar-minXvar)/nXbins)); //if (var=="discr_prob") yTitle = (Form("Numbers of Jets / %3.2f",(maxXvar-minXvar)/nXbins)); if (var=="svtxm") yTitle = ("Number of Jets"); if (var=="discr_prob") yTitle = ("Number of Jets"); hData[counter]->GetXaxis()->CenterTitle(); hData[counter]->GetYaxis()->CenterTitle(); hData[counter]->GetYaxis()->SetTitle(yTitle); hData[counter]->GetXaxis()->SetTitle(xTitle); hData[counter]->Draw(); double Bnorm, Cnorm, Lnorm, LCnorm; Double_t Bfrac =Bfraction.getVal(); Double_t Cfrac =Cfraction.getVal(); //Normalize Histograms if(!fixCL) Lnorm = (hData[counter]->Integral(1,nXbins)/hMCL[counter]->Integral(1,nXbins))*(1.-Cfrac-Bfrac); if(!fixCL) Cnorm = (hData[counter]->Integral(1,nXbins)/hMCC[counter]->Integral(1,nXbins))*(Cfrac); if(!fixCL) Bnorm = (hData[counter]->Integral(1,nXbins)/hMCB[counter]->Integral(1,nXbins))*(Bfrac); if(fixCL) LCnorm = (hData[counter]->Integral(1,nXbins)/hMCLC[counter]->Integral(1,nXbins))*(1.-Bfrac); if(fixCL) Bnorm = (hData[counter]->Integral(1,nXbins)/hMCB[counter]->Integral(1,nXbins))*(Bfrac); hMCB[counter]->SetFillColor(kRed+2); //hMCB[counter]->SetLineWidth(4); hMCL[counter]->SetFillColor(kBlue+1); hMCC[counter]->SetFillColor(kGreen+2); hMCLC[counter]->SetFillColor(kBlue+2); hMCB[counter]->SetMarkerSize(0); hMCC[counter]->SetMarkerSize(0); hMCL[counter]->SetMarkerSize(0); hMCLC[counter]->SetMarkerSize(0); hMCB[counter]->Scale(Bnorm); hMCC[counter]->Scale(Cnorm); hMCL[counter]->Scale(Lnorm); hMCLC[counter]->Scale(LCnorm); if (!fixCL){ hs[counter]->Add(hMCB[counter]); hs[counter]->Add(hMCC[counter]); hs[counter]->Add(hMCL[counter]); } if (fixCL){ hs[counter]->Add(hMCB[counter]); hs[counter]->Add(hMCLC[counter]); } //hs[counter]->Draw("same hE2"); hs[counter]->Draw("same h e"); hData[counter]->Draw("same"); can1[counter]->GetFrame()->SetLineWidth(4); can1[counter]->RedrawAxis(); //checkBins(hMCB[counter]); checkBins(hMCC[counter]); checkBins(hMCL[counter]); checkBins(hData[counter]); //To obtain the ovaerll sum histogram of the MC counts MCTotal[counter] = new TH1D(Form("MCTotal_%d",counter),Form("MCTotal_%d",counter),nXbins,minXvar,maxXvar); MCTotal[counter]->Sumw2(); if (!fixCL){ MCTotal[counter]->Add(hMCB[counter]); MCTotal[counter]->Add(hMCC[counter]); MCTotal[counter]->Add(hMCL[counter]); } if (fixCL){ MCTotal[counter]->Add(hMCB[counter]); MCTotal[counter]->Add(hMCLC[counter]); } MCTotal[counter]->SetLineWidth(3.0); MCTotal[counter]->SetMarkerSize(0); MCTotal[counter]->SetMarkerColor(kGray+2); //MCTotal[counter]->SetLineColor(kAzure-3); MCTotal[counter]->SetLineColor(kBlue-9); //MCTotal[counter]->SetLineColor(kGray+2); MCTotal[counter]->Draw("same e"); hData[counter]->Draw("same"); //http://root.cern.ch/root/htmldoc/TH1.html#TH1:Chi2Test Double_t chi2 = hData[counter]->Chi2Test(MCTotal[counter],"UW CHI2 P"); Double_t chi2NDF = hData[counter]->Chi2Test(MCTotal[counter],"UW CHI2/NDF P"); //This is a fake THstack to also plot the constribution from the charm, //even though it is supposed to be merged with the Light constribution if(fixCL){ //fakehs[counter]->Add(hMCB[counter]); //hMCC[counter]->Scale(); } //Redraw some partial histograms to show error bars in between if(fixCL){ //hMCB[counter]->SetLineColor(kBlack); //hMCB[counter]->SetLineColor(kRed); hMCB[counter]->SetMarkerSize(0); hMCB[counter]->Draw("same e"); } /* // Jorge, I don't know what you're doing here, but there's a bug. The error bars are drawn in the wrong place if(!fixCL){ hMCB[counter]->SetLineColor(kBlack); hMCB[counter]->SetMarkerSize(0); hMCB[counter]->Draw("same e"); hMCB[counter]->Add(hMCC[counter]); //hMCB[counter]->SetLineColor(kRed); //hMCB[counter]->SetLineColor(kBlack); hMCB[counter]->SetMarkerSize(0); hMCB[counter]->Draw("same e"); } */ TLegend *hleg = new TLegend(0.5,fixCL?0.70:0.67,0.90,fixCL?0.92:0.92); hleg->SetBorderSize(0); hleg->SetFillStyle(0); hleg->AddEntry(hData[counter],"PbPb data","lp"); hleg->AddEntry(hMCB[counter],"b","f"); if(!fixCL){ hleg->AddEntry(hMCC[counter],"c","f"); hleg->AddEntry(hMCL[counter],"udsg","f"); } if(fixCL){ hleg->AddEntry(hMCLC[counter],"c + usdg","f"); } // int cbinlo = (double)centlo/2.5; // int cbinhi = (double)centhi/2.5 // double lowcent = (cbinlo)*2.5; // double hicent = (cbinhi)*2.5; hleg->Draw("same"); if(!fixCL)drawText(Form("%d - %d %%",centlo,centhi),0.52,0.62); if(fixCL) drawText(Form("%d - %d %%",centlo,centhi),0.52,0.66); drawText(Form("#chi^{2}/NDF = %3.1f / %d",chi2,(int)(chi2/chi2NDF)),0.51,0.55); drawText("CMS Preliminary",0.15,0.965); drawText("#sqrt{s_{NN}} = 2.76 TeV",0.60,0.965); drawText("|#eta| < 2.0",0.18,0.88); if(comment!="b-tagged sample (SSVHE > 2)") drawText(comment,0.18,0.80); if(comment=="b-tagged sample (SSVHE > 2)"){ drawText("b-tagged sample",0.18,0.80); drawText("(SSVHE > 2)",0.18,0.75); } bool printEach=false; // --- Print results --- //cout <<"b jet fraction in MC = "<<bInitFrac<<endl; cout<<"ZZZZZ TEXTcounter: "<<counter<<" Comment: "<<comment<<endl; if(!fixCL) cout<<"ZZZZZ Scale factors: B= "<<Bnorm<<" C= "<<Cnorm<<" Light= "<<Lnorm<<endl; if(fixCL) cout<<"ZZZZZ Scale factors: B= "<<Bnorm<<" LC= "<<LCnorm<<endl; cout<<"ZZZZZ Chi2: "<<chi2<<" Chi2/NDF: "<<chi2NDF<<endl; cout<<"ZZZZZ var: "<<var<<" discr: "<<discr<<" min(discr): "<<minXvar<<" max(discr): "<<maxXvar<<endl; cout<<"ZZZZZ in cent [ "<<centlo<<" - "<<centhi<<" ] %"<<endl; cout<<"ZZZZZ b jet fraction in data = "<<Bfraction.getVal()<<endl; if(!fixCL) cout <<"ZZZZZ c jet fraction = "<<Cfraction.getVal()<<endl; if(!fixCL){ if (!printEach){ if (counter<11) can1[counter]->Print("bTagStackedHistosInCentBin_nofixCL.pdf(","pdf"); if (counter==11) can1[counter]->Print("bTagStackedHistosInCentBin_nofixCL.pdf)","pdf"); } if (printEach) can1[counter]->Print(Form("PDFS/bStack_%sCent%d_%d_nofixCL.pdf",var,cbinlo,cbinhi),"pdf"); } if(fixCL){ if (!printEach){ if (counter<11) can1[counter]->Print("bTagStackedHistosInCentBin_fixCL.pdf(","pdf"); if (counter==11) can1[counter]->Print("bTagStackedHistosInCentBin_fixCL.pdf)","pdf"); } if (printEach) can1[counter]->Print(Form("PDFS/bStack_%sCent%d_%d_fixCL.pdf",var,cbinlo,cbinhi),"pdf"); } counter++; // --- Print results --- //cout <<"b jet fraction in MC = "<<bInitFrac<<endl; cout <<"b jet fraction in data = "<<Bfraction.getVal()<<endl; if(!fixCL) cout <<"c jet fraction = "<<Cfraction.getVal()<<endl; // --- Save canvas --- TString path = Form("gifs/%s_jtpt%.0fto%.0f_%s%.2fto%.2f_%s.gif",var,ptMin,ptMax,discr,minXdiscr,maxXdiscr,fixCL?"CLfixed":"CLfree"); //cROOFIT->SaveAs(path); return Bfraction; }
void finalizeMassToys() { // data fits (uppere) // float dm1h=0.572; gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gStyle->SetOptFit(1111); TFile *fit1D = TFile::Open("histos1D.root"); TH1F *pull1D = (TH1F*)fit1D->Get("pullh"); TH1F *errh1D = (TH1F*)fit1D->Get("errh"); TFile *fit2D = TFile::Open("histos2D.root"); TH1F *pull2D = (TH1F*)fit2D->Get("pullh"); TH1F *errh2D = (TH1F*)fit2D->Get("errh"); TFile *fit3D = TFile::Open("histos3D.root"); TH1F *pull3D = (TH1F*)fit3D->Get("pullh"); TH1F *errh3D = (TH1F*)fit3D->Get("errh"); float m1=errh1D->GetMean(); float m2=errh2D->GetMean(); float m3=errh3D->GetMean(); float me1=errh1D->GetMeanError(); float me2=errh2D->GetMeanError(); float me3=errh3D->GetMeanError(); stringstream m1s,m2s,m3s; m1s.precision(2); m2s.precision(2); m3s.precision(2); m1s << std::fixed << "m_{4l}. Mean = " << m1 << " #pm " << me1; m2s << std::fixed << "m_{4l}, #sigma_{m}. Mean = " << m2 << " #pm " << me2; m3s << std::fixed << "m_{4l}, #sigma_{m}, KD. Mean = " << m3 << " #pm " << me3; std::vector<TH1F*> pulls,errs; pulls.push_back(pull1D); pulls.push_back(pull2D); pulls.push_back(pull3D); errs.push_back(errh1D); errs.push_back(errh2D); errs.push_back(errh3D); TPaveText *text = new TPaveText(0.50,0.50,0.85,0.60,"brNDC"); text->AddText(m1s.str().c_str()); text->AddText(m2s.str().c_str()); text->AddText(m3s.str().c_str()); text->SetBorderSize(0); text->SetFillStyle(0); text->SetTextAlign(12); text->SetTextFont(42); text->SetTextSize(0.03); // draw the legend TLegend *legend = new TLegend(0.50,0.65,0.85,0.85,NULL,"brNDC"); legend->SetBorderSize( 0); legend->SetFillColor ( 0); legend->SetTextAlign ( 12); legend->SetTextFont ( 42); legend->SetTextSize (0.05); legend->AddEntry(errh1D, "m_{4l}","l"); legend->AddEntry(errh2D, "m_{4l},#sigma_{m}","l"); legend->AddEntry(errh3D, "m_{4l},#sigma_{m},KD","l"); TCanvas *c1 = new TCanvas("c1","",750,750); errs[0]->SetMaximum(3000); for(int i=0;i<3;++i) { errs[i]->SetLineColor(i+1); if(i==0) errs[i]->Draw(); else { errs[i]->Scale(errs[0]->Integral()/errs[i]->Integral()); errs[i]->Draw("same"); } } legend->Draw(); text->Draw(); c1->SaveAs("errors.png"); for(int i=0;i<3;++i) { pulls[i]->Draw(); pulls[i]->Fit("gaus"); stringstream pullc; pullc << "pull_" << i+1 << "D.png"; c1->SaveAs(pullc.str().c_str()); } }
void //HTT_TT_X(bool scaled=true, bool log=true, float min=0.1, float max=-1., string inputfile="root/$HISTFILE", const char* directory="tauTau_$CATEGORY") HHH_TT_X(bool scaled=true, bool log=true, float min=0.1, float max=-1., string inputfile="root/$HISTFILE", const char* directory="tauTau_$CATEGORY") { // defining the common canvas, axes pad styles SetStyle(); gStyle->SetLineStyleString(11,"20 10"); // determine category tag const char* category = ""; const char* category_extra = ""; const char* category_extra2 = ""; if(std::string(directory) == std::string("tauTau_2jet0tag")){ category = "#tau_{h}#tau_{h}"; } if(std::string(directory) == std::string("tauTau_2jet0tag")){ category_extra= "2-jet 0 b-tag"; } if(std::string(directory) == std::string("tauTau_2jet1tag" )){ category = "#tau_{h}#tau_{h}"; } if(std::string(directory) == std::string("tauTau_2jet1tag" )){ category_extra= "2-jet 1 b-tag"; } if(std::string(directory) == std::string("tauTau_2jet2tag" )){ category = "#tau_{h}#tau_{h}"; } if(std::string(directory) == std::string("tauTau_2jet2tag" )){ category_extra = "2-jet 2 b-tag"; } const char* dataset; #ifdef MSSM if(std::string(inputfile).find("7TeV")!=std::string::npos){dataset = "#scale[1.5]{CMS} h,H,A#rightarrow#tau#tau 4.9 fb^{-1} (7 TeV)";} if(std::string(inputfile).find("8TeV")!=std::string::npos){ if(std::string(directory).find("btag")!=std::string::npos){ dataset = "#scale[1.5]{CMS} h,H,A#rightarrow#tau#tau 18.3 fb^{-1} (8 TeV)"; } else{ dataset = "#scale[1.5]{CMS} h,H,A#rightarrow#tau#tau 19.7 fb^{-1} (8 TeV)"; } } #else if(std::string(inputfile).find("8TeV")!=std::string::npos){dataset = "CMS, 19.7 fb^{-1} at 8 TeV";} #endif // open example histogram file TFile* input = new TFile(inputfile.c_str()); #ifdef MSSM TFile* input2 = new TFile((inputfile+"_$MA_$TANB").c_str()); #endif TH1F* Fakes = refill((TH1F*)input->Get(TString::Format("%s/QCD" , directory)), "QCD"); InitHist(Fakes, "", "", TColor::GetColor(250,202,255), 1001); TH1F* EWK1 = refill((TH1F*)input->Get(TString::Format("%s/W" , directory)), "W" ); InitHist(EWK1 , "", "", TColor::GetColor(222,90,106), 1001); TH1F* EWK2 = refill((TH1F*)input->Get(TString::Format("%s/ZJ" , directory)), "ZJ" ); InitHist(EWK2 , "", "", TColor::GetColor(222,90,106), 1001); //TH1F* EWK3 = refill((TH1F*)input->Get(TString::Format("%s/ZL" , directory)), "ZL" ); InitHist(EWK3 , "", "", TColor::GetColor(222,90,106), 1001); TH1F* EWK = refill((TH1F*)input->Get(TString::Format("%s/VV" , directory)), "VV" ); InitHist(EWK , "", "", TColor::GetColor(222,90,106), 1001); TH1F* ttbar = refill((TH1F*)input->Get(TString::Format("%s/TT" , directory)), "TT" ); InitHist(ttbar, "", "", TColor::GetColor(155,152,204), 1001); TH1F* Ztt = refill((TH1F*)input->Get(TString::Format("%s/ZTT" , directory)), "ZTT"); InitHist(Ztt , "", "", TColor::GetColor(248,206,104), 1001); #ifdef MSSM TH1F* ggHTohhTo2Tau2B = refill((TH1F*)input2->Get(TString::Format("%s/ggHTohhTo2Tau2B$MA" , directory)), "ggHTohhTo2Tau2B"); InitSignal(ggHTohhTo2Tau2B); ggHTohhTo2Tau2B->Scale(SIGNAL_SCALE); TH1F* ggAToZhToLLTauTau = refill((TH1F*)input2->Get(TString::Format("%s/ggAToZhToLLTauTau$MA",directory)),"ggAToZhToLLTauTau"); InitSignal(ggAToZhToLLTauTau); TH1F* ggAToZhToLLBB = refill((TH1F*)input2->Get(TString::Format("%s/ggAToZhToLLBB$MA",directory)),"ggAToZhToLLBB"); InitSignal(ggAToZhToLLBB); TH1F* bbH = refill((TH1F*)input2->Get(TString::Format("%s/bbH$MA" , directory)), "bbH"); InitSignal(bbH); #endif #ifdef ASIMOV TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs_asimov", directory)), "data", true); #else TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs", directory)), "data",true); #endif InitHist(data, "#bf{m_{H} [GeV]}", "#bf{dN/dm_{H} [1/GeV]}"); InitData(data); TH1F* ref=(TH1F*)Fakes->Clone("ref"); ref->Add(EWK1 ); ref->Add(EWK2 ); //ref->Add(EWK3 ); ref->Add(EWK ); ref->Add(ttbar); ref->Add(Ztt ); double unscaled[8]; unscaled[0] = Fakes->Integral(); unscaled[1] = EWK ->Integral(); unscaled[1]+= EWK1 ->Integral(); unscaled[1]+= EWK2 ->Integral(); //unscaled[1]+= EWK3 ->Integral(); unscaled[2] = ttbar->Integral(); unscaled[3] = Ztt ->Integral(); #ifdef MSSM unscaled[4] = ggHTohhTo2Tau2B ->Integral(); unscaled[5] = ggAToZhToLLTauTau->Integral(); unscaled[6] = ggAToZhToLLBB->Integral(); unscaled[7] = bbH ->Integral(); #endif if(scaled){ /* Fakes = refill(shape_histos(Fakes, datacard, "QCD"), "QCD"); EWK1 = refill(shape_histos(EWK1, datacard, "W"), "W"); EWK2 = refill(shape_histos(EWK2, datacard, "ZJ"), "ZJ"); EWK = refill(shape_histos(EWK, datacard, "VV"), "VV"); ttbar = refill(shape_histos(ttbar, datacard, "TT"), "TT"); Ztt = refill(shape_histos(Ztt, datacard, "ZTT"), "ZTT"); #ifdef MSSM ggH = refill(shape_histos(ggH, datacard, "ggH$MA"), "ggH$MA"); bbH = refill(shape_histos(bbH, datacard, "bbH$MA"), "bbH$MA"); #else ggH = refill(shape_histos(ggH, datacard, "ggH"), "ggH"); qqH = refill(shape_histos(qqH, datacard, "qqH"), "qqH"); VH = refill(shape_histos(VH, datacard, "VH"), "VH"); #endif */ rescale(Fakes, 7); rescale(EWK1 , 3); rescale(EWK2 , 4); //rescale(EWK3 , 5); rescale(EWK , 6); rescale(ttbar, 2); rescale(Ztt , 1); #ifdef MSSM rescale(ggHTohhTo2Tau2B , 8); rescale(ggAToZhToLLTauTau,9); rescale(ggAToZhToLLBB,10); rescale(bbH , 11); #endif } TH1F* scales[8]; scales[0] = new TH1F("scales-Fakes", "", 8, 0, 8); scales[0]->SetBinContent(1, unscaled[0]>0 ? (Fakes->Integral()/unscaled[0]-1.) : 0.); scales[1] = new TH1F("scales-EWK" , "", 8, 0, 8); scales[1]->SetBinContent(2, unscaled[1]>0 ? ((EWK ->Integral() +EWK1 ->Integral() +EWK2 ->Integral() //+EWK3 ->Integral() )/unscaled[1]-1.) : 0.); scales[2] = new TH1F("scales-ttbar", "", 8, 0, 8); scales[2]->SetBinContent(3, unscaled[2]>0 ? (ttbar->Integral()/unscaled[2]-1.) : 0.); scales[3] = new TH1F("scales-Ztt" , "", 8, 0, 8); scales[3]->SetBinContent(4, unscaled[3]>0 ? (Ztt ->Integral()/unscaled[3]-1.) : 0.); #ifdef MSSM scales[4] = new TH1F("scales-ggHTohhTo2Tau2B" , "", 8, 0, 8); scales[4]->SetBinContent(5, unscaled[4]>0 ? (ggHTohhTo2Tau2B ->Integral()/unscaled[4]-1.) : 0.); scales[5] = new TH1F("scales-ggAToZhToLLTauTau" , "", 8, 0, 8); scales[5]->SetBinContent(6, unscaled[5]>0 ? (ggAToZhToLLTauTau ->Integral()/unscaled[5]-1.) : 0.); scales[6] = new TH1F("scales-ggAToZhToLLBB" , "", 8, 0, 8); scales[6]->SetBinContent(7, unscaled[6]>0 ? (ggAToZhToLLBB ->Integral()/unscaled[6]-1.) : 0.); scales[7] = new TH1F("scales-bbH" , "", 8, 0, 8); scales[7]->SetBinContent(8, unscaled[7]>0 ? (bbH ->Integral()/unscaled[7]-1.) : 0.); #endif //#ifdef MSSM // qqH_SM125->Add(ggH_SM125); // VH_SM125->Add(qqH_SM125); // Fakes->Add(VH_SM125); //#endif Fakes->Add(ttbar); EWK1 ->Add(Fakes); EWK2 ->Add(EWK1 ); //EWK3 ->Add(EWK2 ); //EWK ->Add(EWK3 ); EWK ->Add(EWK2 ); // ttbar->Add(EWK ); Ztt ->Add(EWK); //if(log){ //#ifdef MSSM // ggH->Add(bbH); //#else // qqH->Add(VH ); // ggH->Add(qqH); //#endif // } //else{ //#ifdef MSSM // bbH->Add(Ztt); // ggH->Add(bbH); //#else // VH ->Add(Ztt); // qqH->Add(VH ); // ggH->Add(qqH); //#endif // } /* Mass plot before and after fit */ TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600); canv->cd(); if(log){ canv->SetLogy(1); } #if defined MSSM if(!log){ data->GetXaxis()->SetRange(200, data->FindBin(UPPER_EDGE)); } else{ data->GetXaxis()->SetRange(200, data->FindBin(UPPER_EDGE)); }; #else data->GetXaxis()->SetRange(200, data->FindBin(UPPER_EDGE)); #endif data->SetNdivisions(505); data->SetMinimum(min); data->SetMaximum(max>0 ? max : std::max(std::max(maximum(data, log), maximum(Ztt, log)), maximum(ggHTohhTo2Tau2B, log))); data->Draw("e"); TH1F* errorBand = (TH1F*)Ztt ->Clone(); errorBand ->SetMarkerSize(0); errorBand ->SetFillColor(13); errorBand ->SetFillStyle(3013); errorBand ->SetLineWidth(1); for(int idx=0; idx<errorBand->GetNbinsX(); ++idx){ if(errorBand->GetBinContent(idx)>0){ std::cout << "Uncertainties on summed background samples: " << errorBand->GetBinError(idx)/errorBand->GetBinContent(idx) << std::endl; break; } } if(log){ Ztt ->Draw("histsame"); // ttbar->Draw("histsame"); EWK ->Draw("histsame"); Fakes->Draw("histsame"); ttbar->Draw("histsame"); //#ifdef MSSM // VH_SM125->Draw("histsame"); //#endif $DRAW_ERROR ggHTohhTo2Tau2B ->Draw("histsame"); } else{ ggHTohhTo2Tau2B ->Draw("histsame"); Ztt ->Draw("histsame"); // ttbar->Draw("histsame"); EWK ->Draw("histsame"); Fakes->Draw("histsame"); ttbar->Draw("histsame"); #ifdef MSSM //VH_SM125->Draw("histsame"); #endif $DRAW_ERROR } data->Draw("esame"); canv->RedrawAxis(); //CMSPrelim(dataset, "#tau_{h}#tau_{h}", 0.17, 0.835); CMSPrelim(dataset, "", 0.16, 0.835); #if defined MSSM TPaveText* chan = new TPaveText(0.20, 0.74+0.061, 0.32, 0.74+0.161, "tlbrNDC"); if (strcmp(category_extra2,"")!=0) chan = new TPaveText(0.20, 0.69+0.061, 0.32, 0.74+0.161, "tlbrNDC"); #else TPaveText* chan = new TPaveText(0.52, 0.35, 0.91, 0.55, "tlbrNDC"); #endif chan->SetBorderSize( 0 ); chan->SetFillStyle( 0 ); chan->SetTextAlign( 12 ); chan->SetTextSize ( 0.05 ); chan->SetTextColor( 1 ); chan->SetTextFont ( 62 ); chan->AddText(category); chan->AddText(category_extra); #if defined MSSM if (strcmp(category_extra2,"")!=0) chan->AddText(category_extra2); #else chan->AddText(category_extra2); #endif chan->Draw(); /* TPaveText* cat = new TPaveText(0.20, 0.71+0.061, 0.32, 0.71+0.161, "NDC"); cat->SetBorderSize( 0 ); cat->SetFillStyle( 0 ); cat->SetTextAlign( 12 ); cat->SetTextSize ( 0.05 ); cat->SetTextColor( 1 ); cat->SetTextFont ( 62 ); cat->AddText(category_extra); cat->Draw(); TPaveText* cat2 = new TPaveText(0.20, 0.66+0.061, 0.32, 0.66+0.161, "NDC"); cat2->SetBorderSize( 0 ); cat2->SetFillStyle( 0 ); cat2->SetTextAlign( 12 ); cat2->SetTextSize ( 0.05 ); cat2->SetTextColor( 1 ); cat2->SetTextFont ( 62 ); cat2->AddText(category_extra2); cat2->Draw(); */ #ifdef MSSM TPaveText* massA = new TPaveText(0.53, 0.44+0.061, 0.95, 0.44+0.151, "NDC"); massA->SetBorderSize( 0 ); massA->SetFillStyle( 0 ); massA->SetTextAlign( 12 ); massA->SetTextSize ( 0.03 ); massA->SetTextColor( 1 ); massA->SetTextFont ( 62 ); massA->AddText("MSSM m^{h}_{mod+} scenario"); massA->AddText("m_{A}=$MA GeV, tan#beta=$TANB"); massA->Draw(); #endif #ifdef MSSM TLegend* leg = new TLegend(0.53, 0.60, 0.95, 0.90); SetLegendStyle(leg); leg->AddEntry(ggHTohhTo2Tau2B , TString::Format("%0.f #times H#rightarrowhh#rightarrow#tau#taubb", SIGNAL_SCALE) , "L" ); #endif #ifdef ASIMOV leg->AddEntry(data , "sum(bkg) + H(125)" , "LP"); #else leg->AddEntry(data , "Observed" , "LP"); #endif leg->AddEntry(Ztt , "Z#rightarrow#tau#tau" , "F" ); leg->AddEntry(EWK , "Electroweak" , "F" ); leg->AddEntry(Fakes, "QCD" , "F" ); leg->AddEntry(ttbar, "t#bar{t}" , "F" ); /*#ifdef MSSM leg->AddEntry(VH_SM125, "SM H(125 GeV) #rightarrow #tau#tau", "F" ); #endif */ $ERROR_LEGEND leg->Draw(); /* Ratio Data over MC */ TCanvas *canv0 = MakeCanvas("canv0", "histograms", 600, 400); canv0->SetGridx(); canv0->SetGridy(); canv0->cd(); TH1F* model = (TH1F*)Ztt ->Clone("model"); TH1F* test1 = (TH1F*)data->Clone("test1"); for(int ibin=0; ibin<test1->GetNbinsX(); ++ibin){ //the small value in case of 0 entries in the model is added to prevent the chis2 test from failing model->SetBinContent(ibin+1, model->GetBinContent(ibin+1)>0 ? model->GetBinContent(ibin+1)*model->GetBinWidth(ibin+1) : 0.01); model->SetBinError (ibin+1, CONSERVATIVE_CHI2 ? 0. : model->GetBinError (ibin+1)*model->GetBinWidth(ibin+1)); test1->SetBinContent(ibin+1, test1->GetBinContent(ibin+1)*test1->GetBinWidth(ibin+1)); test1->SetBinError (ibin+1, test1->GetBinError (ibin+1)*test1->GetBinWidth(ibin+1)); } double chi2prob = test1->Chi2Test (model,"PUW"); std::cout << "chi2prob:" << chi2prob << std::endl; double chi2ndof = test1->Chi2Test (model,"CHI2/NDFUW"); std::cout << "chi2ndf :" << chi2ndof << std::endl; double ksprob = test1->KolmogorovTest(model); std::cout << "ksprob :" << ksprob << std::endl; double ksprobpe = test1->KolmogorovTest(model,"DX"); std::cout << "ksprobpe:" << ksprobpe << std::endl; std::vector<double> edges; TH1F* zero = (TH1F*)ref->Clone("zero"); zero->Clear(); TH1F* rat1 = (TH1F*)data->Clone("rat1"); for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin){ rat1->SetBinContent(ibin+1, Ztt->GetBinContent(ibin+1)>0 ? data->GetBinContent(ibin+1)/Ztt->GetBinContent(ibin+1) : 0); rat1->SetBinError (ibin+1, Ztt->GetBinContent(ibin+1)>0 ? data->GetBinError (ibin+1)/Ztt->GetBinContent(ibin+1) : 0); zero->SetBinContent(ibin+1, 0.); zero->SetBinError (ibin+1, Ztt->GetBinContent(ibin+1)>0 ? Ztt ->GetBinError (ibin+1)/Ztt->GetBinContent(ibin+1) : 0); } for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin){ if(rat1->GetBinContent(ibin+1)>0){ edges.push_back(TMath::Abs(rat1->GetBinContent(ibin+1)-1.)+TMath::Abs(rat1->GetBinError(ibin+1))); // catch cases of 0 bins, which would lead to 0-alpha*0-1 rat1->SetBinContent(ibin+1, rat1->GetBinContent(ibin+1)-1.); } } float range = 0.1; std::sort(edges.begin(), edges.end()); if (edges[edges.size()-2]>0.1) { range = 0.2; } if (edges[edges.size()-2]>0.2) { range = 0.5; } if (edges[edges.size()-2]>0.5) { range = 1.0; } if (edges[edges.size()-2]>1.0) { range = 1.5; } if (edges[edges.size()-2]>1.5) { range = 2.0; } rat1->SetLineColor(kBlack); rat1->SetFillColor(kGray ); rat1->SetMaximum(+range); rat1->SetMinimum(-range); rat1->GetYaxis()->CenterTitle(); rat1->GetYaxis()->SetTitle("#bf{Data/MC-1}"); rat1->GetXaxis()->SetTitle("#bf{m_{H} [GeV]}"); rat1->Draw(); zero->SetFillStyle( 3013); zero->SetFillColor(kBlack); zero->SetLineColor(kBlack); zero->SetMarkerSize(0.1); zero->Draw("e2histsame"); canv0->RedrawAxis(); TPaveText* stat1 = new TPaveText(0.20, 0.76+0.061, 0.32, 0.76+0.161, "NDC"); stat1->SetBorderSize( 0 ); stat1->SetFillStyle( 0 ); stat1->SetTextAlign( 12 ); stat1->SetTextSize ( 0.05 ); stat1->SetTextColor( 1 ); stat1->SetTextFont ( 62 ); stat1->AddText(TString::Format("#chi^{2}/ndf=%.3f, P(#chi^{2})=%.3f", chi2ndof, chi2prob)); //stat1->AddText(TString::Format("#chi^{2}/ndf=%.3f, P(#chi^{2})=%.3f, P(KS)=%.3f", chi2ndof, chi2prob, ksprob)); stat1->Draw(); /* Ratio After fit over Prefit */ TCanvas *canv1 = MakeCanvas("canv1", "histograms", 600, 400); canv1->SetGridx(); canv1->SetGridy(); canv1->cd(); edges.clear(); TH1F* rat2 = (TH1F*) Ztt->Clone("rat2"); for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin){ rat2->SetBinContent(ibin+1, ref->GetBinContent(ibin+1)>0 ? Ztt->GetBinContent(ibin+1)/ref->GetBinContent(ibin+1) : 0); rat2->SetBinError (ibin+1, ref->GetBinContent(ibin+1)>0 ? Ztt->GetBinError (ibin+1)/ref->GetBinContent(ibin+1) : 0); } for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin){ if(rat2->GetBinContent(ibin+1)>0){ edges.push_back(TMath::Abs(rat2->GetBinContent(ibin+1)-1.)+TMath::Abs(rat2->GetBinError(ibin+1))); // catch cases of 0 bins, which would lead to 0-alpha*0-1 rat2 ->SetBinContent(ibin+1, rat2->GetBinContent(ibin+1)-1.); } } range = 0.1; std::sort(edges.begin(), edges.end()); if (edges[edges.size()-2]>0.1) { range = 0.2; } if (edges[edges.size()-2]>0.2) { range = 0.5; } if (edges[edges.size()-2]>0.5) { range = 1.0; } if (edges[edges.size()-2]>1.0) { range = 1.5; } if (edges[edges.size()-2]>1.5) { range = 2.0; } #if defined MSSM if(!log){ rat2->GetXaxis()->SetRange(200, rat2->FindBin(UPPER_EDGE)); } else{ rat2->GetXaxis()->SetRange(200, rat2->FindBin(UPPER_EDGE)); }; #else rat2->GetXaxis()->SetRange(200, rat2->FindBin(UPPER_EDGE)); #endif rat2->SetNdivisions(505); rat2->SetLineColor(kRed+ 3); rat2->SetMarkerColor(kRed+3); rat2->SetMarkerSize(1.1); rat2->SetMaximum(+range); rat2->SetMinimum(-range); rat2->GetYaxis()->SetTitle("#bf{Postfit/Prefit-1}"); rat2->GetYaxis()->CenterTitle(); rat2->GetXaxis()->SetTitle("#bf{m_{H} [GeV]}"); rat2->Draw(); zero->SetFillStyle( 3013); zero->SetFillColor(kBlack); zero->SetLineColor(kBlack); zero->Draw("e2histsame"); canv1->RedrawAxis(); /* Relative shift per sample */ TCanvas *canv2 = MakeCanvas("canv2", "histograms", 600, 400); canv2->SetGridx(); canv2->SetGridy(); canv2->cd(); InitHist (scales[0], "", "", TColor::GetColor(250,202,255), 1001); InitHist (scales[1], "", "", TColor::GetColor(222,90,106), 1001); InitHist (scales[2], "", "", TColor::GetColor(155,152,204), 1001); InitHist (scales[3], "", "", TColor::GetColor(248,206,104), 1001); InitHist(scales[4],"","",kGreen+2,1001); InitHist(scales[5],"","",kGreen+2,1001); InitHist(scales[6],"","",kGreen+2,1001); InitHist(scales[7],"","",kGreen+2,1001); scales[0]->Draw(); scales[0]->GetXaxis()->SetBinLabel(1, "#bf{Fakes}"); scales[0]->GetXaxis()->SetBinLabel(2, "#bf{EWK}" ); scales[0]->GetXaxis()->SetBinLabel(3, "#bf{ttbar}"); scales[0]->GetXaxis()->SetBinLabel(4, "#bf{Ztt}" ); #ifdef MSSM scales[0]->GetXaxis()->SetBinLabel(5, "#bf{ggHTohhTo2tau2B}" ); scales[0]->GetXaxis()->SetBinLabel(6, "#bf{ggAToZhToLLTauTau}"); scales[0]->GetXaxis()->SetBinLabel(7, "#bf{ggAToZhToLLBB}"); scales[0]->GetXaxis()->SetBinLabel(8, "#bf{bbH}" ); #endif scales[0]->SetMaximum(+0.5); scales[0]->SetMinimum(-0.5); scales[0]->GetYaxis()->CenterTitle(); scales[0]->GetYaxis()->SetTitle("#bf{Postfit/Prefit-1}"); scales[1]->Draw("same"); scales[2]->Draw("same"); scales[3]->Draw("same"); scales[4]->Draw("same"); scales[5]->Draw("same"); scales[6]->Draw("same"); TH1F* zero_samples = (TH1F*)scales[0]->Clone("zero_samples"); zero_samples->Clear(); zero_samples->SetBinContent(1,0.); zero_samples->Draw("same"); canv2->RedrawAxis(); /* prepare output */ bool isSevenTeV = std::string(inputfile).find("7TeV")!=std::string::npos; canv ->Print(TString::Format("%s_%sfit_%s_%s.png" , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv ->Print(TString::Format("%s_%sfit_%s_%s.pdf" , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv ->Print(TString::Format("%s_%sfit_%s_%s.eps" , directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); if(!log || FULLPLOTS) { canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv0->Print(TString::Format("%s_datamc_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); } if((!log && scaled) || FULLPLOTS) { canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv1->Print(TString::Format("%s_prefit_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.png", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.pdf", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); canv2->Print(TString::Format("%s_sample_%sfit_%s_%s.eps", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN")); } TFile* output = new TFile(TString::Format("%s_%sfit_%s_%s.root", directory, scaled ? "post" : "pre", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "LIN"), "update"); output->cd(); data ->Write("data_obs"); Fakes->Write("Fakes" ); EWK ->Write("EWK" ); ttbar->Write("ttbar" ); Ztt ->Write("Ztt" ); #ifdef MSSM ggHTohhTo2Tau2B ->Write("ggHTohhTo2Tau2B" ); ggAToZhToLLTauTau->Write("ggAToZhToLLTauTau"); ggAToZhToLLBB->Write("ggAToZhToLLBB"); bbH ->Write("bbH" ); #endif output->Close(); delete errorBand; delete model; delete test1; delete zero; delete rat1; delete rat2; delete zero_samples; delete ref; }
void draw2DLimitContours(map<string,TList *>& m_contours, const TString& par1, const TString& par2, const TString& plotprefix, TLegend *legend) { //from here we build the two-dimensional aTGC limit TCanvas *finalPlot = new TCanvas("final","limits",500,500); finalPlot->cd(); cout << "Drawing expected 68%" << endl; TList *contLevel = m_contours["exp68"]; TGraph *curv; std::cout << "m_contours.size() = " << m_contours.size() << std::endl; for (map<string,TList *>::const_iterator iter = m_contours.begin(); iter != m_contours.end(); iter++ ){ std::cout << "iter->first = " << iter->first << std::endl; std::cout << "iter->second = " << iter->second << std::endl; } std::cout << "contLevel = " << contLevel << std::endl; assert(contLevel); curv = (TGraph*)(contLevel->First()); curv->GetXaxis()->SetLimits(parmin(par1),parmax(par1)); curv->GetYaxis()->SetRangeUser(parmin(par2),parmax(par2)); curv->SetTitle(); curv->GetXaxis()->SetTitle(par2latex(par1)); curv->GetXaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitle(par2latex(par2)); curv->GetYaxis()->SetTitleFont(42); curv->GetYaxis()->SetTitleOffset(1.20); for (int i=0; i<contLevel->GetSize(); i++) { assert(curv); curv->SetLineColor(kBlue); curv->SetLineWidth(2); curv->SetLineStyle(9); if (!i) { curv->Draw("AC"); legend->AddEntry(curv,"Expected 68% C.L.","L"); } else curv->Draw("SAME C"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing expected 95%" << endl; contLevel = m_contours["exp95"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kGreen); curv->SetLineWidth(2); curv->SetLineStyle(9); curv->Draw("SAME C"); if (!i) legend->AddEntry(curv,"Expected 95% C.L.","L"); curv=(TGraph *)(contLevel->After(curv)); } cout << "Drawing expected 99%" << endl; contLevel = m_contours["exp99"]; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->SetLineColor(kRed); curv->SetLineWidth(2); curv->SetLineStyle(9); curv->Draw("SAME C"); if (!i) legend->AddEntry(curv,"Expected 99% C.L.","L"); curv=(TGraph *)(contLevel->After(curv)); } contLevel = m_contours["obs95"]; if (contLevel) { cout << "Drawing obs95" << endl; curv = (TGraph*)(contLevel->First()); for (int i=0; i<contLevel->GetSize(); i++) { curv->Draw("SAME C"); curv->SetLineWidth(2); if (!i) legend->AddEntry(curv,"Observed 95% C.L.","L"); curv=(TGraph *)(contLevel->After(curv)); } } TGraph *SMpoint = new TGraph(1); SMpoint->SetPoint(1,0,0); //SMpoint->Draw("SAME Po"); //smLabel = TPaveText(0, // m_contours["-2s"]->GetYaxis()->GetXmax()/8, // m_contours["-2s"]->GetXaxis()->GetXmax()/3->5, // -m_contours["-2s"]->GetYaxis()->GetXmax()/8); //smLabel->SetFillStyle(0); //smLabel->SetBorderSize(0); //smLabel->AddText(" SM"); //smLabel->Draw(); legend->Draw(); TPaveText *text = new TPaveText(0.566,0.87,0.965,1.101,"NDC"); text->SetFillStyle(0); text->SetBorderSize(0); //text->AddText(Form("95%% CL Limit on %s and %s",par2latex(par1).Data(),par2latex(par2).Data())); text->AddText(0,0.35,Form("#intL dt= %.1f fb^{-1}, #sqrt{s} = %d TeV",intlumifbinv,beamcometev)); text->Draw(); // text2 = TPaveText(0.155,0.199,0.974,0.244,"NDC"); // text2->SetFillStyle(0); // text2->SetBorderSize(0); // text2->AddText("Values outside contour excluded"); // text2->Draw(); //text3 = TPaveText(0.506,0.699,0.905,0.758,"NDC"); //text3->SetFillStyle(0); //text3->SetBorderSize(0); //text3->AddText(options.flavorText); //text3->Draw(); gPad->SetGrid(1,1); finalPlot->RedrawAxis(); finalPlot->ResetAttPad(); finalPlot->Update(); finalPlot->Draw(); finalPlot->Update(); finalPlot->Modified(); finalPlot->Update(); finalPlot->Print(Form("%s.pdf",plotprefix.Data())); finalPlot->Print(Form("%s.eps",plotprefix.Data())); //finalPlot->Print(Form("%s.png",plotprefix.Data())); } // draw2DlimitContours
void compareLimits(const char* filename, const char* channelstr, bool expected, bool observed, const char* type, double minimum=0., double maximum=20., bool log=false, const char* label="#scale[1.5]{CMS} h,H,A#rightarrow#tau#tau 19.7 fb^{-1} (8 TeV) + 4.9 fb^{-1} (7 TeV)", bool legendOnRight=true, bool legendOnTop=true, bool ggH=true) { SetStyle(); std::map<std::string, unsigned int> colors; colors["0jet" ] = kBlue; colors["1jet" ] = kRed; colors["2jet" ] = kMagenta; colors["vbf" ] = kMagenta; colors["boost" ] = kGreen; colors["btag" ] = kRed; colors["nobtag" ] = kBlue; colors["em" ] = kBlue; colors["et" ] = kRed; colors["mt" ] = kGreen; colors["mm" ] = kMagenta; colors["ee" ] = kCyan; colors["tt" ] = kMagenta+3; colors["vhtt" ] = kCyan-6; colors["cmb" ] = kBlack; colors["htt" ] = kBlack; colors["ggH" ] = kRed; colors["bbH" ] = kBlue; colors["HIG-11-020" ] = kBlue+2; colors["HIG-11-029" ] = kRed+2; colors["HIG-12-018" ] = kBlue; colors["HIG-12-032" ] = kRed+2; colors["HIG-12-043" ] = kRed; colors["HIG-12-050" ] = kRed; std::cout << " *******************************************************************************************************\n" << " * Usage : root -l \n" << " * .x MitLimits/Higgs2Tau/macros/compareLimits.C+(file, chn, exp, obs, type, min, max, log) \n" << " * \n" << " * Arguments : + file const char* full path to the input file \n" << " * + chn const char* list of channels; choose between: 'cmb', 'htt', 'emu', \n" << " * 'etau', 'mutau', 'mumu', 'vhtt', 'hgg', 'hww', 'ggH', \n" << " * 'bbH', 'nomix[-200, +200]', 'mhmax[-400, -200, +200]' \n" << " * 'mhmax[+400, +600, +800]', 'test-0...5', 'saeff', 'gluph' \n" << " * The list should be comma separated and may contain \n" << " * whitespaces \n" << " * + exp bool compare expected limits \n" << " * + obs bool compare observed limits \n" << " * + type const char* type of plot; choose between 'sm-xsec', 'mssm-xsec' and \n" << " * 'mssm-tanb' \n" << " * + max double maximum of the plot (default is 20.) \n" << " * \n" << " * + min double minimum of the plot (default is 0.) \n" << " * \n" << " * + log bool set log scale yes or no (default is false) \n" << " * \n" << " *******************************************************************************************************\n"; /// open input file TFile* inputFile = new TFile(filename); if(inputFile->IsZombie()){ std::cout << "ERROR:: file: " << filename << " does not exist.\n"; } /// prepare input parameters std::vector<std::string> channels; string2Vector(cleanupWhitespaces(channelstr), channels); /// prepare histograms std::vector<TGraph*> hobs, hexp; for(unsigned i=0; i<channels.size(); ++i){ if(observed) hobs.push_back(get<TGraph>(inputFile, std::string(channels[i]).append("/observed").c_str())); if(expected) hexp.push_back(get<TGraph>(inputFile, std::string(channels[i]).append("/expected").c_str())); } /// do the drawing TCanvas* canv1 = new TCanvas("canv1", "Limit Comparison", 600, 600); canv1->cd(); canv1->SetGridx(1); canv1->SetGridy(1); if((std::string(type) == std::string("mssm-xsec") || std::string(type) == std::string("mssm-tanb")) && log) canv1->SetLogx(1); bool firstPlot=true; for(unsigned int i=0; i<hexp.size(); ++i){ if(firstPlot){ if(log){ canv1->SetLogy(1); } hexp[i]->SetMaximum(maximum); hexp[i]->SetMinimum(minimum); // format x-axis std::string x_title; if(std::string(type) == std::string("mssm-tanb")){ x_title = std::string("m_{A} [GeV]"); } else if(std::string(type) == std::string("mssm-xsec")){ x_title = std::string("m_{#phi} [GeV]"); } else{ x_title = std::string("m_{H} [GeV]"); } hexp[i]->GetXaxis()->SetTitle(x_title.c_str()); hexp[i]->GetXaxis()->SetLabelFont(62); hexp[i]->GetXaxis()->SetTitleFont(62); hexp[i]->GetXaxis()->SetTitleColor(1); hexp[i]->GetXaxis()->SetTitleOffset(1.05); if((std::string(type) == std::string("mssm-xsec") || std::string(type) == std::string("mssm-tanb")) && log){ hexp[i]->GetXaxis()->SetNdivisions(50005, "X"); hexp[i]->GetXaxis()->SetMoreLogLabels(); hexp[i]->GetXaxis()->SetNoExponent(); hexp[i]->GetXaxis()->SetLabelSize(0.040); } hexp[i]->GetXaxis()->SetLimits(hexp[i]->GetX()[0]-.1, hexp[i]->GetX()[hexp[i]->GetN()-1]+.1); if(std::string(type) == std::string("mssm-xsec") || std::string(type) == std::string("mssm-tanb")){ if(log){ hexp[i]->GetXaxis()->SetLimits(hexp[i]->GetX()[0], hexp[i]->GetX()[hexp[i]->GetN()-1]+.1); } else{ hexp[i]->GetXaxis()->SetLimits(hexp[i]->GetX()[0]-.1, hexp[i]->GetX()[hexp[i]->GetN()-1]+.1); } } // format y-axis std::string y_title; if( std::string(type) == std::string("mssm-xsec") ){ if(ggH) y_title = std::string("95% CL limit on #sigma(gg#rightarrow#phi)#timesBR [pb]"); else y_title = std::string("95% CL limit on #sigma(gg#rightarrowbb#phi)#timesBR [pb]"); } else if( std::string(type) == std::string("mssm-tanb") ){ y_title = std::string("#bf{tan#beta}"); } else{ y_title = std::string("95% CL limit on #sigma/#sigma_{SM}"); } hexp[i]->GetYaxis()->SetTitle(y_title.c_str()); hexp[i]->GetYaxis()->SetLabelFont(62); hexp[i]->GetYaxis()->SetTitleFont(62); hexp[i]->GetYaxis()->SetTitleOffset(1.05); hexp[i]->GetYaxis()->SetLabelSize(0.03); } hexp[i]->SetLineStyle(11.); hexp[i]->SetLineWidth( 3.); hexp[i]->SetLineColor(colors.find(channels[i])->second); hexp[i]->SetMarkerStyle(20); hexp[i]->SetMarkerSize(MARKER_SIZE); hexp[i]->SetMarkerColor(colors.find(channels[i])->second); hexp[i]->Draw(firstPlot ? "APL" : "PLsame"); //hexp[i]->Draw(firstPlot ? "AL" : "Lsame"); firstPlot=false; } for(unsigned int i=0; i<hobs.size(); ++i){ if(firstPlot){ if(log){ canv1->SetLogy(1); } hobs[i]->SetMaximum(maximum); hobs[i]->SetMinimum(minimum); // format x-axis std::string x_title; if(std::string(type) == std::string("mssm-tanb")){ x_title = std::string("m_{A} [GeV]"); } else if(std::string(type) == std::string("mssm-xsec")){ x_title = std::string("m_{#phi} [GeV]"); } else{ x_title = std::string("m_{H} [GeV]"); } hobs[i]->GetXaxis()->SetTitle(x_title.c_str()); hobs[i]->GetXaxis()->SetLabelFont(62); hobs[i]->GetXaxis()->SetTitleFont(62); hobs[i]->GetXaxis()->SetTitleColor(1); hobs[i]->GetXaxis()->SetTitleOffset(1.05); if((std::string(type) == std::string("mssm-xsec") || std::string(type) == std::string("mssm-tanb")) && log){ hobs[i]->GetXaxis()->SetNdivisions(50005, "X"); hobs[i]->GetXaxis()->SetMoreLogLabels(); hobs[i]->GetXaxis()->SetNoExponent(); hobs[i]->GetXaxis()->SetLabelSize(0.040); } hobs[i]->GetXaxis()->SetLimits(hobs[i]->GetX()[0]-.1, hobs[i]->GetX()[hobs[i]->GetN()-1]+.1); if(std::string(type) == std::string("mssm-xsec") || std::string(type) == std::string("mssm-tanb")){ if(log){ hobs[i]->GetXaxis()->SetLimits(hobs[i]->GetX()[0], hobs[i]->GetX()[hobs[i]->GetN()-1]+.1); } else{ hobs[i]->GetXaxis()->SetLimits(hobs[i]->GetX()[0]-.1, hobs[i]->GetX()[hobs[i]->GetN()-1]+.1); } } // format y-axis std::string y_title; if( std::string(type) == std::string("mssm-xsec") ){ if(ggH) y_title = std::string("95% CL limit on #sigma#font[42]{(gg#phi)}#upoint#font[52]{B}#font[42]{(#phi#rightarrow#tau#tau)} [pb]"); else y_title = std::string("95% CL limit on #sigma#font[42]{(bb#phi)}#upoint#font[52]{B}#font[42]{(#phi#rightarrow#tau#tau)} [pb]"); } else if( std::string(type) == std::string("mssm-tanb") ){ y_title = std::string("#bf{tan#beta}"); } else{ y_title = std::string("95% CL limit on #sigma/#sigma_{SM}"); } hobs[i]->GetYaxis()->SetTitle(y_title.c_str()); hobs[i]->GetYaxis()->SetLabelFont(62); hobs[i]->GetYaxis()->SetTitleOffset(1.05); hobs[i]->GetYaxis()->SetLabelSize(0.03); } hobs[i]->SetLineStyle(11.); hobs[i]->SetLineWidth( 3.); hobs[i]->SetLineColor(colors.find(channels[i])->second); hobs[i]->SetMarkerStyle(20); hobs[i]->SetMarkerSize(MARKER_SIZE); hobs[i]->SetMarkerColor(colors.find(channels[i])->second); hobs[i]->Draw(firstPlot ? "APL" : "PLsame"); //hobs[i]->Draw(firstPlot ? "AL" : "Lsame"); firstPlot=false; } canv1->RedrawAxis(); TPaveText* extra; if( std::string(type) == std::string("mssm-xsec") ){ extra = new TPaveText(legendOnRight ? 0.6 : 0.18, 0.50, legendOnRight ? 0.95 : 0.605, 0.60, "NDC"); extra->SetBorderSize( 0 ); extra->SetFillStyle ( 0 ); extra->SetTextAlign ( 12 ); extra->SetTextSize (0.04 ); extra->SetTextColor ( 1 ); extra->SetTextFont ( 62 ); if(ggH) extra->AddText("gg#phi"); else extra->AddText("bb#phi"); extra->Draw(); } bool firstLeg=true; if(observed){ TLegend* leg1; if(expected && observed){ /// setup the CMS Preliminary if(std::string(type) == std::string("mssm-tanb")){ if (firstLeg) CMSPrelim(label, "", 0.15, 0.835); leg1 = new TLegend(firstLeg ? 0.60 : 0.20, hobs.size()<5 ? 0.20-0.06*hobs.size() : 0.4, firstLeg ? 0.93 : 0.60, 0.20); } else{ if (firstLeg) CMSPrelim(label, "", 0.135, 0.835); leg1 = new TLegend(firstLeg ? 0.20 : 0.20, hobs.size()<5 ? 0.90-0.08*hobs.size() : 0.6, firstLeg ? 0.63 : 0.60, 0.90); } } else{ /// setup the CMS Preliminary if(std::string(type) == std::string("mssm-tanb")){ CMSPrelim(label, "", 0.15, 0.835); leg1 = new TLegend(legendOnRight?0.60:0.20, hobs.size()<5 ? (legendOnTop?0.90:0.40)-0.04*hobs.size() : (legendOnTop?0.6:0.2), legendOnRight?0.94:0.45, (legendOnTop?0.90:0.40)); } else{ CMSPrelim(label, "", 0.135, 0.835); leg1 = new TLegend(legendOnRight ? 0.50 : 0.20, hobs.size()<5 ? 0.90-0.08*hobs.size() : 0.6, legendOnRight ? 0.94 : 0.64, 0.90); } } if(std::string(type) == std::string("mssm-tanb")) {leg1->SetTextSize(0.03);} //leg1->SetTextSize(0.02); leg1->SetBorderSize( 0 ); leg1->SetFillStyle ( 1001 ); //leg1->SetFillColor ( 0 ); leg1->SetFillColor (kWhite); leg1->SetHeader( "#bf{observed}" ); for(unsigned int i=0; i<hobs.size(); ++i){ leg1->AddEntry( hobs[i] , channel(channels[i]) ? legendEntry(channels[i]).c_str() : legendEntry(channels[i]).append("-Channel").c_str(), "PL" ); } leg1->Draw("same"); firstLeg=false; } if(expected){ TLegend* leg0; if(expected && observed){ /// setup the CMS Preliminary if(std::string(type) == std::string("mssm-tanb")){ CMSPrelim(label, "", 0.15, 0.835); leg0 = new TLegend(legendOnRight ? 0.60 : 0.20, hexp.size()<5 ? 0.20-0.06*hexp.size() : 0.4, legendOnRight ? 0.94 : 0.63, 0.20); } else{ CMSPrelim(label, "", 0.135, 0.835); leg0 = new TLegend(legendOnRight ? 0.20 : 0.20, hexp.size()<5 ? 0.75-0.08*hexp.size() : 0.6, legendOnRight ? 0.94 : 0.63, 0.75); } } else{ /// setup the CMS Preliminary if(std::string(type) == std::string("mssm-tanb")){ CMSPrelim(label, "", 0.15, 0.835); leg0 = new TLegend(legendOnRight?0.60:0.20, hexp.size()<5 ? (legendOnTop?0.90:0.40)-0.04*hexp.size() : (legendOnTop?0.6:0.2), legendOnRight?0.94:0.45, (legendOnTop?0.90:0.40)); } else{ CMSPrelim(label, "", 0.135, 0.835); leg0 = new TLegend(legendOnRight ? 0.50 : 0.20, hexp.size()<5 ? 0.90-0.06*hexp.size() : 0.6, legendOnRight ? 0.74 : 0.63, 0.90); //leg0 = new TLegend(legendOnRight ? 0.50 : 0.20, hexp.size()<5 ? 0.90-0.08*hexp.size() : 0.6, legendOnRight ? 0.94 : 0.80, 0.90); } } if(std::string(type) == std::string("mssm-tanb")) {leg0->SetTextSize(0.03);} leg0->SetBorderSize( 0 ); leg0->SetFillStyle ( 1001 ); leg0->SetFillColor (kWhite); leg0->SetHeader( "#bf{expected}" ); for(unsigned int i=0; i<hexp.size(); ++i){ leg0->AddEntry( hexp[i] , channel(channels[i]) ? legendEntry(channels[i]).c_str() : legendEntry(channels[i]).append("-Channel").c_str(), "PL" ); } leg0->Draw("same"); firstLeg=false; } canv1->Print(std::string("singleLimits").append(expected ? "_expected" : "").append(observed ? "_observed" : "").append(std::string(type).find("mssm")!=std::string::npos ? "_mssm.png" : "_sm.png").c_str()); canv1->Print(std::string("singleLimits").append(expected ? "_expected" : "").append(observed ? "_observed" : "").append(std::string(type).find("mssm")!=std::string::npos ? "_mssm.pdf" : "_sm.pdf").c_str()); canv1->Print(std::string("singleLimits").append(expected ? "_expected" : "").append(observed ? "_observed" : "").append(std::string(type).find("mssm")!=std::string::npos ? "_mssm.pdf" : "_sm.eps").c_str()); return; }
void METptb2() { //=========Macro generated from canvas: b2/METptb2/b2/METptb2 //========= (Tue Nov 24 14:26:31 2015) by ROOT version6.02/05 TCanvas *b2/METptb2 = new TCanvas("b2/METptb2", "b2/METptb2",200,222,700,700); b2/METptb2->Range(37.49999,-7.364757,1662.5,0.7273038); b2/METptb2->SetFillColor(0); b2/METptb2->SetBorderMode(0); b2/METptb2->SetBorderSize(2); b2/METptb2->SetLogy(); b2/METptb2->SetFrameBorderMode(0); b2/METptb2->SetFrameBorderMode(0); THStack *b2/METptb2 = new THStack(); b2/METptb2->SetName("b2/METptb2"); b2/METptb2->SetTitle("b2/METptb2"); TH1F *b2/METptb2_stack_11 = new TH1F("b2/METptb2_stack_11","b2/METptb2",26,200,1500); b2/METptb2_stack_11->SetMinimum(2.782592e-07); b2/METptb2_stack_11->SetMaximum(0.8281284); b2/METptb2_stack_11->SetDirectory(0); b2/METptb2_stack_11->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); b2/METptb2_stack_11->SetLineColor(ci); b2/METptb2_stack_11->GetXaxis()->SetTitle("b2/METptb2"); b2/METptb2_stack_11->GetXaxis()->SetLabelFont(42); b2/METptb2_stack_11->GetXaxis()->SetLabelSize(0.035); b2/METptb2_stack_11->GetXaxis()->SetTitleSize(0.035); b2/METptb2_stack_11->GetXaxis()->SetTitleFont(42); b2/METptb2_stack_11->GetYaxis()->SetTitle("Events/pb"); b2/METptb2_stack_11->GetYaxis()->SetLabelFont(42); b2/METptb2_stack_11->GetYaxis()->SetLabelSize(0.035); b2/METptb2_stack_11->GetYaxis()->SetTitleSize(0.035); b2/METptb2_stack_11->GetYaxis()->SetTitleFont(42); b2/METptb2_stack_11->GetZaxis()->SetLabelFont(42); b2/METptb2_stack_11->GetZaxis()->SetLabelSize(0.035); b2/METptb2_stack_11->GetZaxis()->SetTitleSize(0.035); b2/METptb2_stack_11->GetZaxis()->SetTitleFont(42); b2/METptb2->SetHistogram(b2/METptb2_stack_11); TH1D *METptb251 = new TH1D("METptb251","MET_{p_{T}}",26,200,1500); METptb251->SetBinContent(1,0.1044396); METptb251->SetBinContent(2,0.0193603); METptb251->SetBinContent(3,0.00544552); METptb251->SetBinContent(4,0.00204207); METptb251->SetBinContent(8,0.00068069); METptb251->SetBinError(1,0.02774932); METptb251->SetBinError(2,0.01184302); METptb251->SetBinError(3,0.001925282); METptb251->SetBinError(4,0.00117899); METptb251->SetBinError(8,0.00068069); METptb251->SetEntries(48); ci = TColor::GetColor("#00cc00"); METptb251->SetFillColor(ci); ci = TColor::GetColor("#00cc00"); METptb251->SetLineColor(ci); ci = TColor::GetColor("#00cc00"); METptb251->SetMarkerColor(ci); METptb251->SetMarkerStyle(22); METptb251->GetXaxis()->SetTitle("METptb2"); METptb251->GetXaxis()->SetLabelFont(42); METptb251->GetXaxis()->SetLabelSize(0.035); METptb251->GetXaxis()->SetTitleSize(0.035); METptb251->GetXaxis()->SetTitleFont(42); METptb251->GetYaxis()->SetTitle("Events/pb"); METptb251->GetYaxis()->SetLabelFont(42); METptb251->GetYaxis()->SetLabelSize(0.035); METptb251->GetYaxis()->SetTitleSize(0.035); METptb251->GetYaxis()->SetTitleFont(42); METptb251->GetZaxis()->SetLabelFont(42); METptb251->GetZaxis()->SetLabelSize(0.035); METptb251->GetZaxis()->SetTitleSize(0.035); METptb251->GetZaxis()->SetTitleFont(42); b2/METptb2->Add(METptb2,""); TH1D *METptb252 = new TH1D("METptb252","MET_{p_{T}}",26,200,1500); METptb252->SetBinContent(1,0.3917192); METptb252->SetBinContent(2,0.1187636); METptb252->SetBinContent(3,0.04893815); METptb252->SetBinContent(4,0.01957569); METptb252->SetBinContent(5,0.00999049); METptb252->SetBinContent(6,0.005074523); METptb252->SetBinContent(7,0.002797197); METptb252->SetBinContent(8,0.001509849); METptb252->SetBinContent(9,0.0007554042); METptb252->SetBinContent(10,0.0005153702); METptb252->SetBinContent(11,0.0003203653); METptb252->SetBinContent(12,0.0001671471); METptb252->SetBinContent(13,9.750248e-05); METptb252->SetBinContent(14,8.357355e-05); METptb252->SetBinContent(15,2.785785e-05); METptb252->SetBinContent(16,1.392893e-05); METptb252->SetBinContent(17,5.57157e-05); METptb252->SetBinContent(18,1.392893e-05); METptb252->SetBinContent(19,1.392893e-05); METptb252->SetBinContent(21,1.392893e-05); METptb252->SetBinContent(23,1.392893e-05); METptb252->SetBinError(1,0.009015143); METptb252->SetBinError(2,0.003467256); METptb252->SetBinError(3,0.00198213); METptb252->SetBinError(4,0.0009025235); METptb252->SetBinError(5,0.0004185742); METptb252->SetBinError(6,0.0002713332); METptb252->SetBinError(7,0.0002003913); METptb252->SetBinError(8,0.0001460045); METptb252->SetBinError(9,0.0001028093); METptb252->SetBinError(10,8.472634e-05); METptb252->SetBinError(11,6.680078e-05); METptb252->SetBinError(12,4.825121e-05); METptb252->SetBinError(13,3.685247e-05); METptb252->SetBinError(14,3.411876e-05); METptb252->SetBinError(15,1.969847e-05); METptb252->SetBinError(16,1.392893e-05); METptb252->SetBinError(17,2.785785e-05); METptb252->SetBinError(18,1.392893e-05); METptb252->SetBinError(19,1.392893e-05); METptb252->SetBinError(21,1.392893e-05); METptb252->SetBinError(23,1.392893e-05); METptb252->SetEntries(12325); ci = TColor::GetColor("#00ffff"); METptb252->SetFillColor(ci); ci = TColor::GetColor("#00ffff"); METptb252->SetLineColor(ci); ci = TColor::GetColor("#00ffff"); METptb252->SetMarkerColor(ci); METptb252->SetMarkerStyle(20); METptb252->GetXaxis()->SetTitle("METptb2"); METptb252->GetXaxis()->SetLabelFont(42); METptb252->GetXaxis()->SetLabelSize(0.035); METptb252->GetXaxis()->SetTitleSize(0.035); METptb252->GetXaxis()->SetTitleFont(42); METptb252->GetYaxis()->SetTitle("Events/pb"); METptb252->GetYaxis()->SetLabelFont(42); METptb252->GetYaxis()->SetLabelSize(0.035); METptb252->GetYaxis()->SetTitleSize(0.035); METptb252->GetYaxis()->SetTitleFont(42); METptb252->GetZaxis()->SetLabelFont(42); METptb252->GetZaxis()->SetLabelSize(0.035); METptb252->GetZaxis()->SetTitleSize(0.035); METptb252->GetZaxis()->SetTitleFont(42); b2/METptb2->Add(METptb2,""); TH1D *METptb253 = new TH1D("METptb253","MET_{p_{T}}",26,200,1500); METptb253->SetBinContent(1,0.08670416); METptb253->SetBinContent(2,0.03119945); METptb253->SetBinContent(3,0.01373989); METptb253->SetBinContent(4,0.006818856); METptb253->SetBinContent(5,0.003406878); METptb253->SetBinContent(6,0.001827934); METptb253->SetBinContent(7,0.001084198); METptb253->SetBinContent(8,0.0005744535); METptb253->SetBinContent(9,0.0004089983); METptb253->SetBinContent(10,0.0002469337); METptb253->SetBinContent(11,0.000147458); METptb253->SetBinContent(12,8.426173e-05); METptb253->SetBinContent(13,7.372901e-05); METptb253->SetBinContent(14,4.564177e-05); METptb253->SetBinContent(15,3.159815e-05); METptb253->SetBinContent(16,2.340604e-05); METptb253->SetBinContent(17,1.638422e-05); METptb253->SetBinContent(18,1.053272e-05); METptb253->SetBinContent(19,8.192112e-06); METptb253->SetBinContent(20,8.192112e-06); METptb253->SetBinContent(21,4.681207e-06); METptb253->SetBinContent(22,2.340604e-06); METptb253->SetBinContent(24,1.170302e-06); METptb253->SetBinContent(26,2.340604e-06); METptb253->SetBinContent(27,4.681207e-06); METptb253->SetBinError(1,0.00161953); METptb253->SetBinError(2,0.0008248426); METptb253->SetBinError(3,0.0004810386); METptb253->SetBinError(4,0.0002668444); METptb253->SetBinError(5,0.0001146987); METptb253->SetBinError(6,7.088941e-05); METptb253->SetBinError(7,5.03671e-05); METptb253->SetBinError(8,3.047945e-05); METptb253->SetBinError(9,2.325693e-05); METptb253->SetBinError(10,1.699961e-05); METptb253->SetBinError(11,1.31366e-05); METptb253->SetBinError(12,9.93034e-06); METptb253->SetBinError(13,9.288982e-06); METptb253->SetBinError(14,7.308532e-06); METptb253->SetBinError(15,6.081066e-06); METptb253->SetBinError(16,5.233749e-06); METptb253->SetBinError(17,4.378868e-06); METptb253->SetBinError(18,3.510905e-06); METptb253->SetBinError(19,3.096327e-06); METptb253->SetBinError(20,3.096327e-06); METptb253->SetBinError(21,2.340604e-06); METptb253->SetBinError(22,1.655057e-06); METptb253->SetBinError(24,1.170302e-06); METptb253->SetBinError(26,1.655057e-06); METptb253->SetBinError(27,2.340604e-06); METptb253->SetEntries(19290); ci = TColor::GetColor("#ffcc00"); METptb253->SetFillColor(ci); ci = TColor::GetColor("#ffcc00"); METptb253->SetLineColor(ci); ci = TColor::GetColor("#ffcc00"); METptb253->SetMarkerColor(ci); METptb253->SetMarkerStyle(21); METptb253->GetXaxis()->SetTitle("METptb2"); METptb253->GetXaxis()->SetLabelFont(42); METptb253->GetXaxis()->SetLabelSize(0.035); METptb253->GetXaxis()->SetTitleSize(0.035); METptb253->GetXaxis()->SetTitleFont(42); METptb253->GetYaxis()->SetTitle("Events/pb"); METptb253->GetYaxis()->SetLabelFont(42); METptb253->GetYaxis()->SetLabelSize(0.035); METptb253->GetYaxis()->SetTitleSize(0.035); METptb253->GetYaxis()->SetTitleFont(42); METptb253->GetZaxis()->SetLabelFont(42); METptb253->GetZaxis()->SetLabelSize(0.035); METptb253->GetZaxis()->SetTitleSize(0.035); METptb253->GetZaxis()->SetTitleFont(42); b2/METptb2->Add(METptb2,""); TH1D *METptb254 = new TH1D("METptb254","MET_{p_{T}}",26,200,1500); METptb254->SetBinContent(1,0.006046434); METptb254->SetBinContent(2,0.003609351); METptb254->SetBinContent(3,0.002082318); METptb254->SetBinContent(4,0.001604156); METptb254->SetBinContent(5,0.0008175025); METptb254->SetBinContent(6,0.0006941059); METptb254->SetBinContent(7,0.0003084915); METptb254->SetBinContent(8,0.0002930669); METptb254->SetBinContent(9,0.0001388212); METptb254->SetBinContent(10,0.000107972); METptb254->SetBinContent(11,7.712288e-05); METptb254->SetBinContent(12,4.627373e-05); METptb254->SetBinContent(13,4.627373e-05); METptb254->SetBinContent(14,1.542458e-05); METptb254->SetBinContent(15,1.542458e-05); METptb254->SetBinContent(18,1.542458e-05); METptb254->SetBinContent(21,1.542458e-05); METptb254->SetBinError(1,0.000305391); METptb254->SetBinError(2,0.0002359506); METptb254->SetBinError(3,0.0001792174); METptb254->SetBinError(4,0.0001573004); METptb254->SetBinError(5,0.0001122926); METptb254->SetBinError(6,0.0001034712); METptb254->SetBinError(7,6.89808e-05); METptb254->SetBinError(8,6.723417e-05); METptb254->SetBinError(9,4.627373e-05); METptb254->SetBinError(10,4.080959e-05); METptb254->SetBinError(11,3.44904e-05); METptb254->SetBinError(12,2.671615e-05); METptb254->SetBinError(13,2.671615e-05); METptb254->SetBinError(14,1.542458e-05); METptb254->SetBinError(15,1.542458e-05); METptb254->SetBinError(18,1.542458e-05); METptb254->SetBinError(21,1.542458e-05); METptb254->SetEntries(1033); ci = TColor::GetColor("#ff0000"); METptb254->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); METptb254->SetLineColor(ci); ci = TColor::GetColor("#ff0000"); METptb254->SetMarkerColor(ci); METptb254->SetMarkerStyle(20); METptb254->GetXaxis()->SetTitle("METptb2"); METptb254->GetXaxis()->SetLabelFont(42); METptb254->GetXaxis()->SetLabelSize(0.035); METptb254->GetXaxis()->SetTitleSize(0.035); METptb254->GetXaxis()->SetTitleFont(42); METptb254->GetYaxis()->SetTitle("Events/pb"); METptb254->GetYaxis()->SetLabelFont(42); METptb254->GetYaxis()->SetLabelSize(0.035); METptb254->GetYaxis()->SetTitleSize(0.035); METptb254->GetYaxis()->SetTitleFont(42); METptb254->GetZaxis()->SetLabelFont(42); METptb254->GetZaxis()->SetLabelSize(0.035); METptb254->GetZaxis()->SetTitleSize(0.035); METptb254->GetZaxis()->SetTitleFont(42); b2/METptb2->Add(METptb2,""); TH1D *METptb255 = new TH1D("METptb255","MET_{p_{T}}",26,200,1500); METptb255->SetBinContent(1,1.677165e-05); METptb255->SetBinError(1,1.677165e-05); METptb255->SetEntries(1); ci = TColor::GetColor("#0000ff"); METptb255->SetFillColor(ci); ci = TColor::GetColor("#0000ff"); METptb255->SetLineColor(ci); ci = TColor::GetColor("#0000ff"); METptb255->SetMarkerColor(ci); METptb255->SetMarkerStyle(21); METptb255->GetXaxis()->SetTitle("METptb2"); METptb255->GetXaxis()->SetLabelFont(42); METptb255->GetXaxis()->SetLabelSize(0.035); METptb255->GetXaxis()->SetTitleSize(0.035); METptb255->GetXaxis()->SetTitleFont(42); METptb255->GetYaxis()->SetTitle("Events/pb"); METptb255->GetYaxis()->SetLabelFont(42); METptb255->GetYaxis()->SetLabelSize(0.035); METptb255->GetYaxis()->SetTitleSize(0.035); METptb255->GetYaxis()->SetTitleFont(42); METptb255->GetZaxis()->SetLabelFont(42); METptb255->GetZaxis()->SetLabelSize(0.035); METptb255->GetZaxis()->SetTitleSize(0.035); METptb255->GetZaxis()->SetTitleFont(42); b2/METptb2->Add(METptb2,""); b2/METptb2->Draw("nostack"); TPaveText *pt = new TPaveText(0.348477,0.9342857,0.651523,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("b2/METptb2"); pt->Draw(); TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetTextSize(0.034965); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("METptb2","b2/METptb2_QCD_b2/","lp"); ci = TColor::GetColor("#00cc00"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#00cc00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(22); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METptb2","b2/METptb2_WJetsToLNu_b2/","lp"); ci = TColor::GetColor("#00ffff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#00ffff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METptb2","b2/METptb2_ZJetsToNuNu_b2/","lp"); ci = TColor::GetColor("#ffcc00"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#ffcc00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METptb2","b2/METptb2_signal_b2/","lp"); ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#ff0000"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METptb2","b2/METptb2_ttbar_b2/","lp"); ci = TColor::GetColor("#0000ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); b2/METptb2->Modified(); b2/METptb2->cd(); b2/METptb2->SetSelected(b2/METptb2); }
int theoryStudy_separate(const TString BaseName) { TString tmpTStr; char tmpName[30],tmpName_org[30]; int Numb; TFile *f_theory; TFile *f_Data; double fScale[14]={0}; double fScale_WtoMu[14]={0}; double fScale_WtoEle[14]={0}; double fScale_WptoMu[14] = {0, 64.48, 1.105, 8.274, 9.716, 7.226, 8.534, 5.76, 6.4783, 4.5879, 1.3952, 0.52169, 0.2662, 0.09476}; double fScale_WmtoMu[14] = {0, 45.388, 1.601, 4.628, 6.315, 4.866, 5.935, 4.1334, 4.6873, 3.4607, 1.0583, 0.36488, 0.18399, 0.063812}; double fScale_WptoEle[14] = {0, 74.18, 2.079, 8.808, 10.496, 7.646, 8.934, 5.998, 6.6528, 4.7955, 1.4991, 0.4733, 0.28867, 0.09178}; double fScale_WmtoEle[14] = {0, 48.427, 1.315, 5.692, 6.855, 5.33, 6.332, 4.3037, 4.9102, 3.7312, 1.1115, 0.38448, 0.19356, 0.062427}; for(int i(0);i<14;i++) { fScale_WtoMu[i] = sqrt((fScale_WptoMu[i]*fScale_WptoMu[i])+(fScale_WmtoMu[i]*fScale_WmtoMu[i])); fScale_WtoEle[i] = sqrt((fScale_WptoEle[i]*fScale_WptoEle[i])+(fScale_WmtoEle[i]*fScale_WmtoEle[i])); } if(BaseName=="WInclToMuNu") { for(int i(0);i<14;i++) { fScale[i] = fScale_WtoMu[i]; cout << "fScale : " << fScale[i] << "\t fScale_WtoMu : " << fScale_WtoMu[i] << endl; } f_theory = new TFile("Theory_Muon.root"); f_Data = new TFile("Result_WinclMu.root"); } if(BaseName=="WInclToEleNu") { for(int i(0);i<14;i++) { fScale[i] = fScale_WtoEle[i]; cout << "fScale : " << fScale[i] << "\t fScale_WtoEle : " << fScale_WtoEle[i] << endl; } f_theory = new TFile("Theory_Ele.root"); f_Data = new TFile("Result_WinclEle.root"); } TH1D *hResbosLog30 = new TH1D("hResbosLog30","hResbosLog30",13,WptLogBins);hResbosLog30->Sumw2(); TH1D *hResbosLog31 = new TH1D("hResbosLog31","hResbosLog31",13,WptLogBins);hResbosLog31->Sumw2(); TH1D *hResbosLog34 = new TH1D("hResbosLog34","hResbosLog34",13,WptLogBins);hResbosLog34->Sumw2(); TH1D *hFewzLog = new TH1D("hFewzLog","hFewzLog",13,WptLogBins);hFewzLog->Sumw2(); TH1D *hPowhegLog = new TH1D("hPowhegLog","hPowhegLog",13,WptLogBins);hPowhegLog->Sumw2(); TH1D *hDataLog = new TH1D("hDataLog","hDataLog",13,WptLogBins);hDataLog->Sumw2(); TH1D *hDataNoLog = new TH1D("hDataNoLog","hDataNoLog",13,WptBins);hDataNoLog->Sumw2(); TH1D *hDataErrBand = new TH1D("hDataErrBand","hDataErrBand",13,WptLogBins);hDataErrBand->Sumw2(); TH1D *hPowhegErrBand = new TH1D("hPowhegErrBand","hPowhegErrBand",13,WptLogBins);hPowhegErrBand->Sumw2(); TH1D *hPowhegErrBandPDF = new TH1D("hPowhegErrBandPDF","hPowhegErrBandPDF",13,WptLogBins);hPowhegErrBandPDF->Sumw2(); TH1D *hFewzErrBand = new TH1D("hFewzErrBand","hFewzErrBand",13,WptLogBins);hFewzErrBand->Sumw2(); TH1D *hFewzTheoryErrBand = new TH1D("hFewzTheoryErrBand","hFewzTheoryErrBand",13,WptLogBins);hFewzTheoryErrBand->Sumw2(); //FEWZ Scale Syst TH1D *hFewzScale = new TH1D("hFewzScale","hFewzScale",13,WptLogBins);hFewzScale->Sumw2(); TH1D *hFewzScaleErrBand = new TH1D("hFewzScaleErrBand","hFewzScaleErrBand",13,WptLogBins);hFewzScaleErrBand->Sumw2(); TH1D *hStatErr = new TH1D("hStatErr","hStatErr",13,WptLogBins);hStatErr->Sumw2(); TH1D* lResbos[7]; TH1D* lResbos30; TH1D* lResbos31; TH1D* lResbos34; TH1D* lFEWZ; TH1D* lPowheg; TH1D* lData; TH1D* hRD; for( int i(0);i<7;i++) { Numb = 29+i; sprintf(tmpName_org,"hResbos%d",Numb); sprintf(tmpName,"lResbos_%d",i); lResbos[i] = (TH1D*)f_theory->Get(tmpName_org)->Clone(tmpName); } lResbos30 = (TH1D*)f_theory->Get("hResbos30")->Clone(); lResbos31 = (TH1D*)f_theory->Get("hResbos31")->Clone(); lResbos34 = (TH1D*)f_theory->Get("hResbos34")->Clone(); lFEWZ = (TH1D*)f_theory->Get("hxsec")->Clone(); lPowheg = (TH1D*)f_Data->Get("SVD_BornGen")->Clone(); orgPowheg = (TH1D*)f_Data->Get("SVD_BornGen")->Clone(); lData = (TH1D*)f_Data->Get("BornEffCorr")->Clone(); hRD = (TH1D*)f_Data->Get("data_Rec")->Clone(); for( int ipt(1);ipt<nBins;ipt++) { double tmp = sqrt(hRD->GetBinContent(ipt)); hRD->SetBinError(ipt,tmp); cout<<ipt<<"\t"<<hRD->GetBinContent(ipt)<<"\t"<<hRD->GetBinError(ipt)<<endl; } lPowheg->Scale(1./18.429); lData->Scale(1./18.429); hRD->Scale(1./18.429); for( int ipt(1);ipt<nBins;ipt++) { cout<<ipt<<"\t"<<hRD->GetBinError(ipt)<<"\t"<<lData->GetBinError(ipt)<<endl; } cout << "Resbos Total Xsec: " << lResbos30->Integral() << endl; cout << "Data Total Xsec: " << lData->Integral() << endl; Double_t resb30[nBins-1]; Double_t errMax[nBins-1]; Double_t errMin[nBins-1]; double tmpVal,tmpDiff; for( int ipt(0);ipt<nBins-1;ipt++) { resb30[ipt] = lResbos30->GetBinContent(ipt+1)/hDataNoLog->GetXaxis()->GetBinWidth(ipt+1); double norVal = lResbos[1]->GetBinContent(ipt+1); errMax[ipt] = -99999; errMin[ipt] = 990009; for (int i(0);i<7;i++) { tmpVal = lResbos[i]->GetBinContent(ipt+1); tmpDiff = tmpVal - norVal; if( tmpDiff > errMax[ipt] ) errMax[ipt] = tmpDiff; if( tmpDiff < errMin[ipt] ) errMin[ipt] = tmpDiff; } if (errMax[ipt] < 0) errMax[ipt] = 0.; if (errMin[ipt] > 0) errMin[ipt] = 0.; if (errMin[ipt] < 0) errMin[ipt] = -errMin[ipt]; errMax[ipt] = errMax[ipt]/hDataNoLog->GetXaxis()->GetBinWidth(ipt+1); errMin[ipt] = errMin[ipt]/hDataNoLog->GetXaxis()->GetBinWidth(ipt+1); } Double_t errFewz[nBins-1]; Double_t vPowheg[nBins-1]; Double_t vFewz[nBins-1]; Double_t resbVal[nBins-1],errResbosDataLo[nBins-1],errResbosDataHi[nBins-1]; for( int ipt(1);ipt<=nBins-1;ipt++) { hResbosLog30->SetBinContent(ipt,lResbos30->GetBinContent(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt) ); hResbosLog31->SetBinContent(ipt,lResbos31->GetBinContent(ipt)); hResbosLog34->SetBinContent(ipt,lResbos34->GetBinContent(ipt)); hFewzLog->SetBinContent(ipt,lFEWZ->GetBinContent(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); //hFewzLog->SetBinError(ipt,lFEWZ->GetBinError(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hFewzLog->SetBinError(ipt,sqrt((lFEWZ->GetBinError(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt))*(lFEWZ->GetBinError(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt))+(fScale[ipt]/hDataNoLog->GetXaxis()->GetBinWidth(ipt))*(fScale[ipt]/hDataNoLog->GetXaxis()->GetBinWidth(ipt)))); hPowhegLog->SetBinContent(ipt,lPowheg->GetBinContent(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hPowhegLog->SetBinError(ipt,sqrt(lPowheg->GetBinContent(ipt))/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hDataLog->SetBinContent(ipt,lData->GetBinContent(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hDataLog->SetBinError(ipt,lData->GetBinError(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hDataErrBand->SetBinContent(ipt,1.); hDataErrBand->SetBinError(ipt,lData->GetBinError(ipt)/lData->GetBinContent(ipt)); hStatErr->SetBinContent(ipt,1.); hStatErr->SetBinError(ipt,hRD->GetBinError(ipt)/lData->GetBinContent(ipt)); hPowhegErrBand->SetBinContent(ipt,hPowhegLog->GetBinContent(ipt)/hDataLog->GetBinContent(ipt)); hPowhegErrBand->SetBinError(ipt,sqrt(orgPowheg->GetBinContent(ipt))/orgPowheg->GetBinContent(ipt)); hPowhegErrBandPDF->SetBinContent(ipt,hPowhegLog->GetBinContent(ipt)/hDataLog->GetBinContent(ipt)); //hPowhegErrBandPDF->SetBinError(ipt,lPowheg->GetBinError(ipt)/hDataLog->GetBinContent(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hPowhegErrBandPDF->SetBinError(ipt,sqrt(orgPowheg->GetBinContent(ipt))/orgPowheg->GetBinContent(ipt)+lPowheg->GetBinError(ipt)/hDataLog->GetBinContent(ipt)/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hFewzErrBand->SetBinContent(ipt,hFewzLog->GetBinContent(ipt)/hDataLog->GetBinContent(ipt)); hFewzErrBand->SetBinError(ipt,0.01); hFewzScale->SetBinContent(ipt,hFewzLog->GetBinContent(ipt)/hDataLog->GetBinContent(ipt)); hFewzScale->SetBinError(ipt,fScale[ipt]/hDataNoLog->GetXaxis()->GetBinWidth(ipt)); hFewzTheoryErrBand->SetBinContent(ipt,hFewzLog->GetBinContent(ipt)/hDataLog->GetBinContent(ipt)); //hFewzTheoryErrBand->SetBinError(ipt,hFewzLog->GetBinError(ipt)/hDataLog->GetBinContent(ipt)); //hFewzTheoryErrBand->SetBinError(ipt,0.01+hFewzLog->GetBinError(ipt)/hDataLog->GetBinContent(ipt)); hFewzTheoryErrBand->SetBinError(ipt,0.01+(hFewzLog->GetBinError(ipt)+hFewzScale->GetBinError(ipt))/hDataLog->GetBinContent(ipt)); hFewzScaleErrBand->SetBinContent(ipt,hFewzLog->GetBinContent(ipt)/hDataLog->GetBinContent(ipt)); hFewzScaleErrBand->SetBinError(ipt,0.01+hFewzScale->GetBinError(ipt)/hDataLog->GetBinContent(ipt)); resbVal[ipt-1]=hResbosLog30->GetBinContent(ipt)/hDataLog->GetBinContent(ipt); errResbosDataLo[ipt-1]=errMin[ipt-1]/hDataLog->GetBinContent(ipt); errResbosDataHi[ipt-1]=errMax[ipt-1]/hDataLog->GetBinContent(ipt); cout<<ipt<<"\t"<<errMin[ipt-1]<<"\t"<<errMax[ipt-1]<<"\t"<<hDataLog->GetBinContent(ipt)<<"\t"<<errResbosDataLo[ipt-1]<<"\t"<<errResbosDataHi[ipt-1]<<endl; //cout<<ipt<<"\t"<<hResbosLog30->GetBinContent(ipt)<<"\t"<<hDataLog->GetBinContent(ipt)<<"\t"<<hPowhegLog->GetBinError(ipt)<<endl; } hDataLog->SetMarkerStyle(kFullCircle); hDataLog->SetMarkerColor(kBlack); hDataLog->SetMarkerSize(1); hStatErr->SetMarkerStyle(kFullCircle); hStatErr->SetMarkerColor(kBlack); hStatErr->SetMarkerSize(0.6); TGraphErrors *hData = new TGraphErrors(hDataLog); TGraphErrors *hPowheg = new TGraphErrors(hPowhegLog); TGraphErrors *hFewz = new TGraphErrors(hFewzLog); TGraphAsymmErrors* hResbos = new TGraphAsymmErrors(nBins-1, ax, resb30, aex, aex, errMin, errMax); TGraphAsymmErrors* ResbosErrBand = new TGraphAsymmErrors(nBins-1, ax, resbVal, aex, aex, errResbosDataLo, errResbosDataHi); TGraphErrors* pRatio = new TGraphErrors(hPowhegErrBand); TGraphErrors* pRatioPDF = new TGraphErrors(hPowhegErrBandPDF); TGraphErrors* fRatio = new TGraphErrors(hFewzErrBand); TGraphErrors* fTheoryRatio = new TGraphErrors(hFewzTheoryErrBand); TGraphErrors* fScaleRatio = new TGraphErrors(hFewzScaleErrBand); TGraphErrors* dataErrBand = new TGraphErrors(hDataErrBand); dataErrBand->SetFillColor(kBlack); dataErrBand->SetFillStyle(3354); ResbosErrBand->SetFillColor(kBlue-7); ResbosErrBand->SetFillStyle(3001); //pRatio->SetFillColor(kRed-7); pRatio->SetFillColor(kRed-10); pRatio->SetFillStyle(3001); pRatioPDF->SetFillColor(kRed+2); pRatioPDF->SetFillStyle(3001); fRatio->SetFillColor(kGreen); fRatio->SetFillStyle(3001); //fTheoryRatio->SetFillColor(kGreen-9); fTheoryRatio->SetFillColor(kGreen+3); fTheoryRatio->SetFillStyle(3001); fScaleRatio->SetFillColor(kGreen+7); fScaleRatio->SetFillStyle(3001); hFewz->SetFillColor(kGreen); hFewz->SetFillStyle(3305); hPowheg->SetFillColor(kRed); hPowheg->SetFillStyle(3345); hResbos->SetFillColor(kBlue); hResbos->SetFillStyle(3354); TLegend *lL =new TLegend(0.2,0.2,0.52,0.38); lL->SetFillColor(0); lL->SetBorderSize(0); lL->AddEntry(hData,"Unfolded","PL"); lL->AddEntry(hPowheg,"Powheg CT10 NLO","f"); lL->AddEntry(hFewz,"FEWZ CT10 NNLO","f"); lL->AddEntry(hResbos,"ResBos CT10 NNLO","f"); TPaveText *tb = new TPaveText(0.2,0.39,0.52,0.5,"NDC"); tb->SetBorderSize(0); tb->SetFillStyle(0); tb->AddText("18.43 pb^{-1} at #sqrt{s} = 8 TeV"); if (BaseName=="WpToMuNu") tb->AddText("W^{+} #rightarrow #mu^{+} #nu"); if (BaseName=="WmToMuNu") tb->AddText("W^{-} #rightarrow #mu^{-} #bar{#nu}"); if (BaseName=="WInclToMuNu") tb->AddText("W #rightarrow #mu #nu"); if (BaseName=="WpToEleNu") tb->AddText("W^{+} #rightarrow e^{+} #nu"); if (BaseName=="WmToEleNu") tb->AddText("W^{-} #rightarrow e^{-} #bar{#nu}"); if (BaseName=="WInclToEleNu") tb->AddText("W #rightarrow e #nu"); TCanvas *lC1 = new TCanvas("Can","Can",800,840); lC1->cd(); lC1->SetLogy(); lC1->cd(1)->SetPad(0,0.05,0.95,1.0); lC1->cd(1)->SetTopMargin(0.05); lC1->cd(1)->SetBottomMargin(0.1); lC1->cd(1)->SetLeftMargin(0.15); lC1->cd(1)->SetRightMargin(0.07); lC1->cd(1)->SetTickx(1); lC1->cd(1)->SetTicky(1); gStyle->SetLineWidth(2.); gStyle->SetOptStat(0); gStyle->SetHatchesSpacing(0.75); gStyle->SetHatchesLineWidth(2); gPad->SetLogx(1); gPad->SetLogy(1); hPowheg->GetYaxis()->SetRangeUser(1e-4,5*resb30[0]); hPowheg->SetTitle(""); hPowheg->GetYaxis()->SetTitle("Cross-section [pb (GeV/c)^{-1}]"); hPowheg->GetXaxis()->SetTitle("W p_{T}"); hPowheg->GetXaxis()->SetTitleOffset(1.); hPowheg->GetYaxis()->SetTitleOffset(1.5); hPowheg->GetYaxis()->SetTitleSize(0.03); hPowheg->GetYaxis()->SetLabelSize(0.03); hPowheg->GetXaxis()->SetTitleSize(0.03); hPowheg->GetXaxis()->SetLabelSize(0.03); hPowheg->Draw("A2"); hFewz->Draw("2"); hResbos->Draw("2"); hData->Draw("p"); lL->Draw(); tb->Draw(); if(BaseName=="WInclToMuNu") sprintf(tmpName,"winclmnCrossSec.png"); if (BaseName=="WInclToEleNu") sprintf(tmpName,"winclenCrossSec.png"); lC1->SaveAs(tmpName); TCanvas *lC2 = new TCanvas("Can","Can",800,800); lC2->cd(); lC2->SetLogy(); lC2->Divide(1,3,0,0); lC2->cd(1)->SetPad(0,0.67,0.95,0.95); lC2->cd(1)->SetTopMargin(0.05); lC2->cd(1)->SetBottomMargin(0.01); lC2->cd(1)->SetLeftMargin(0.15); lC2->cd(1)->SetRightMargin(0.07); lC2->cd(1)->SetTickx(1); lC2->cd(1)->SetTicky(1); lC2->cd(1)->SetLogx(1); TPaveText *tb1 = new TPaveText(0.15,0.82,0.35,0.92,"NDC"); tb1->SetBorderSize(0); tb1->SetFillStyle(0); tb1->SetTextSize(0.12); tb1->AddText("ResBos"); TLegend *rL1 =new TLegend(0.2,0.05,0.86,0.15); rL1->SetFillColor(0); rL1->SetBorderSize(0); rL1-> SetNColumns(3); rL1->AddEntry(ResbosErrBand,"Theory unc. (gen)","F"); rL1->AddEntry(hStatErr,"Statistic error (data)","PLE1"); rL1->AddEntry(dataErrBand,"Stat. + Syst. (data)","F"); rL1->SetTextSize(0.07); drawDifference(hResbosLog30,hDataLog,hDataErrBand,pRatio,1,pRatio,ResbosErrBand,hStatErr,fScaleRatio); rL1->Draw(); tb1->Draw(); lC2->cd(2)->SetPad(0,0.37,0.95,0.65); lC2->cd(2)->SetTopMargin(0.01); lC2->cd(2)->SetBottomMargin(0.01); lC2->cd(2)->SetLeftMargin(0.15); lC2->cd(2)->SetRightMargin(0.07); lC2->cd(2)->SetTickx(1); lC2->cd(2)->SetTicky(1); lC2->cd(2)->SetLogx(1); TPaveText *tb2 = new TPaveText(0.15,0.82,0.35,0.92,"NDC"); tb2->SetBorderSize(0); tb2->SetFillStyle(0); tb2->SetTextSize(0.12); tb2->AddText("Powheg"); TLegend *rL2 =new TLegend(0.2,0.05,0.68,0.30); rL2->SetFillColor(0); rL2->SetBorderSize(0); rL2-> SetNColumns(2); rL2->AddEntry(pRatioPDF,"PDF unc. (gen)","F"); rL2->AddEntry(hStatErr,"Statistic error (data)","PLE1"); rL2->AddEntry(pRatio,"Statistical unc. (gen)","F"); rL2->AddEntry(dataErrBand,"Stat. + Syst. (data)","F"); rL2->SetTextSize(0.07); drawDifference(hPowhegLog,hDataLog,hDataErrBand,pRatio,2,pRatioPDF,ResbosErrBand,hStatErr,fScaleRatio); rL2->Draw(); tb2->Draw(); lC2->cd(3)->SetPad(0,0.07,0.95,0.35); lC2->cd(3)->SetTopMargin(0.01); lC2->cd(3)->SetBottomMargin(0.05); lC2->cd(3)->SetLeftMargin(0.15); lC2->cd(3)->SetRightMargin(0.07); lC2->cd(3)->SetTickx(1); lC2->cd(3)->SetTicky(1); lC2->cd(3)->SetLogx(1); TPaveText *tb3 = new TPaveText(0.15,0.82,0.35,0.92,"NDC"); tb3->SetBorderSize(0); tb3->SetFillStyle(0); tb3->SetTextSize(0.12); tb3->AddText("Fewz"); TLegend *rL3 =new TLegend(0.2,0.1,0.68,0.30); rL3->SetFillColor(0); rL3->SetBorderSize(0); rL3-> SetNColumns(2); rL3->AddEntry(fTheoryRatio,"PDF unc. (gen)","F"); rL3->AddEntry(fScaleRatio,"Scale unc. (gen)","F"); rL3->AddEntry(hStatErr,"Statistic error (data)","PLE1"); rL3->AddEntry(fRatio,"Statistical unc. (gen)","F"); rL3->AddEntry(dataErrBand,"Stat. + Syst. (data)","F"); rL3->SetTextSize(0.07); drawDifference(hFewzLog,hDataLog,hDataErrBand,fRatio,3,fTheoryRatio,ResbosErrBand,hStatErr,fScaleRatio); rL3->Draw(); tb3->Draw(); if(BaseName=="WInclToMuNu") sprintf(tmpName,"winclmnRatioTheoData.png"); if (BaseName=="WInclToEleNu") sprintf(tmpName,"winclenRatioTheoData.png"); lC2->SaveAs(tmpName); return 0; }
int extractSignificanceStats(bool average=false, TString legALT="0^{-}", TString nameALT="0m", TString inputA="qmu_*.root", TString inputB="/afs/cern.ch/user/s/sbologne/workspace/superME_alessioCode/UFLresults/mu_float/sepExample_ggSpin0M_qmu.root"){ bool unblind = true; gStyle->SetPalette(1); gStyle->SetOptStat(0); setTDRStyle(); const float lumi7TeV=5.051; const float lumi8TeV=12.21; TChain* t = new TChain("q"); t->Add(inputA); t->Add(inputB); float q,m,w; int type; t->SetBranchAddress("q",&q); t->SetBranchAddress("mh",&m); t->SetBranchAddress("weight",&w); t->SetBranchAddress("type",&type); TH1F *hSM=new TH1F("hSM;S = -2 #times ln(L_{PS}/L_{SM});Number of Toys","",8000,-40,40); TH1F *hPS=new TH1F("hPS;S = -2 #times ln(L_{PS}/L_{SM});Number of Toys","",8000,-40,40); TH1F *hObs=new TH1F("hObserved","",8000,-40,40); std::vector<float> v_SM, v_PS,v_Obs; int counterData=0; for(int i=0;i<t->GetEntries();i++){ t->GetEntry(i); if(i==0)cout<<"MASS in the TREE = "<<m<<endl<<endl; q*=2.0; if(type<0){ //SM hypothesis hSM->Fill(-q); v_SM.push_back(-q); } else if(type>0){//ALT hypothesis hPS->Fill(-q); v_PS.push_back(-q); } else{ counterData++; hObs->Fill(-q); //cout<<"DATA -q ="<<(-q)<<endl; v_Obs.push_back(-q); } }//end loop on tree entries //cout<<"Finished to loop, sorting vectors "<<v_SM.size()<<" "<<v_PS.size()<<" "<<v_Obs.size()<<endl; sort(v_SM.begin(),v_SM.end());//sort in ascending order sort(v_PS.begin(),v_PS.end()); sort(v_Obs.begin(),v_Obs.end()); int ntoysSM= hSM->GetEntries(); int ntoysPS= hPS->GetEntries(); if(v_PS.at(0)>v_SM.at(ntoysSM-1)){ cout<<"Swapped distributions !!! The alternative model shouldstay on the negative side of the significance."<<endl; cout<<"Please edit the code and change the sign of q when filling histos and vectors in the loop on tree entries"<<endl; return 1; } if((int(v_SM.size())!= ntoysSM)||(int(v_PS.size())!= ntoysPS)){ cout<<"Mismatch in size of vectors and #entries of historgams ! v_SM.size()="<< v_SM.size() <<" ntoysSM="<<ntoysSM<<endl; return 1; } float medianSM=v_SM.at(int(ntoysSM/2)); float medianPS=v_PS.at(int(ntoysPS/2)); cout<<"Toys generated "<<ntoysSM<<"\t"<<ntoysPS<<endl; //cout<<"Mean of SM/PS hypothesis: "<<hSM->GetMean()<<"\t"<<hPS->GetMean()<<endl; //cout<<"RMS of SM/PS hypothesis: "<<hSM->GetRMS()<<"\t"<<hPS->GetRMS()<<endl; //cout<<"Median of SM/PS hypothesis: "<<medianSM<<"\t"<<medianPS<<endl; const float step=0.05; float coverage=0.0; float diff=10.0; float cut=v_PS.at(0)-step; float crosspoint=-99.0; int startSM=ntoysSM-1, startPS=0; //cout<<"Starting to loop with cut at "<<cut<<endl; while(cut<=v_SM.at(ntoysSM-1)+step){ float cutSM=-1.0,cutPS=-1.0; for(int iSM=startSM;iSM>=0;iSM--){ if(v_SM.at(iSM)<cut){//gotcha cutSM=ntoysSM-iSM; break; } } for(int iPS=startPS;iPS<ntoysPS;iPS++){ if(v_PS.at(iPS)>cut){//gotcha cutPS=iPS; break; } } if(cutSM>=0&&cutPS>=0){ float fracSM=(ntoysSM-cutSM)/ntoysSM; float fracPS=(ntoysPS-cutPS)/ntoysPS; if(fabs(fracSM-fracPS)<diff){ diff=fabs(fracSM-fracPS); coverage=fabs(fracSM+fracPS)/2.0; crosspoint=cut; } } cut+=step; }//end while loop //cout<<"Finished loop on vector elements, min diff is "<<diff<<", looped until cut_fin="<<cut<<endl; //cout<<"q value where SM and ALT distributions have same area on opposite sides: "<<crosspoint<<" Coverage="<<coverage<<endl; float separation=2*ROOT::Math::normal_quantile_c(1.0 - coverage, 1.0); //cout<<"Separation from tail prob: "<<separation<<endl<<endl<<endl; float integralSM=hSM->Integral(); float integralPS=hPS->Integral(); float tailSM=hSM->Integral(1,hSM->FindBin(medianPS))/integralSM; float tailPS=hPS->Integral(hPS->FindBin(medianSM),hPS->GetNbinsX())/integralPS; //cout<<"Median point prob SM: "<<tailSM<<" ("<<ROOT::Math::normal_quantile_c(tailSM,1.0) <<" sigma)"<<endl; //cout<<"Median point prob PS: "<<tailPS<<" ("<<ROOT::Math::normal_quantile_c(tailPS,1.0) <<" sigma)"<<endl; diff=10.0; coverage=0.0; for(int i=1;i<hSM->GetNbinsX();i++){ float fracSM=hSM->Integral(1,i) / integralSM; float fracPS=hPS->Integral(i,hPS->GetNbinsX()) / integralPS; if(fabs(fracSM-fracPS)<diff){ diff=fabs(fracSM-fracPS); coverage=(fracSM+fracPS)/2.0; } } float sepH= 2*ROOT::Math::normal_quantile_c(1.0 - coverage, 1.0); cout<<"Separation from histograms = "<<sepH<<" with coverage "<<coverage<<endl; double observedQ=-99; if(average) observedQ=(v_Obs.at(0)+v_Obs.at(counterData-1))/2.; else observedQ=TMath::Min(v_Obs.at(0),v_Obs.at(counterData-1)); cout<<"q value in DATA: framework A "<<v_Obs.at(0)<<" framework B "<<v_Obs.at(counterData-1)<<" Combined most conservative "<<observedQ<<endl; if(unblind){ if(v_Obs.size()<1){ cout<<"Ooops ! The size of the vector with the observed separation is not 1 but "<<v_Obs.size()<<" ! I am not going to plot the observed results."<<endl; unblind=false; } else{ float obsTailSM=hSM->Integral(1,hSM->FindBin(observedQ))/integralSM; float obsTailPS=hPS->Integral(hPS->FindBin(observedQ),hPS->GetNbinsX())/integralPS; cout<<"P(SM < Obs): "<<obsTailSM<<" ("<<ROOT::Math::normal_quantile_c(obsTailSM,1.0) <<" sigma)"<<endl; cout<<"P(PS > Obs): "<<obsTailPS<<" ("<<ROOT::Math::normal_quantile_c(obsTailPS,1.0) <<" sigma)"<<endl; float obsCLsRatio = obsTailPS / (1.0 - obsTailSM); cout<<"CLs criterion P(PS > Obs) / P(SM > Obs) : "<<obsCLsRatio<<endl;//" ("<<ROOT::Math::normal_quantile_c(obsCLsRatio,1.0) <<" sigma)"<<endl; } }//end if unblinding //Plotting gStyle->SetOptStat(0); TCanvas *c1=new TCanvas("c","c",500,500); c1->cd(); hSM->Rebin(50); hPS->Rebin(50); TString xtitle=" -2 #times ln(L_{"+legALT+"} / L_{0^{+}})"; hSM->SetXTitle(xtitle); hSM->SetYTitle("Pseudoexperiments"); hPS->SetXTitle(xtitle); hPS->SetYTitle("Pseudoexperiments"); hSM->SetLineColor(kRed+2); hSM->SetLineStyle(2); hSM->SetFillColor(798); hSM->SetLineWidth(2); hPS->SetFillColor(kAzure+7); hPS->SetLineColor(kBlue); hPS->SetLineWidth(1); hPS->SetFillStyle(3001); hObs->SetLineColor(kRed); hObs->SetLineWidth(2); TGraph *grObs=new TGraph();//dummy, just for the legend grObs->SetLineColor(kRed); grObs->SetLineWidth(1); hSM->GetXaxis()->SetRangeUser(-30.0,30.0); hSM->GetXaxis()->SetLabelFont(42); hSM->GetXaxis()->SetLabelOffset(0.007); hSM->GetXaxis()->SetLabelSize(0.045); hSM->GetXaxis()->SetTitleSize(0.05); hSM->GetXaxis()->SetTitleOffset(1.15); hSM->GetXaxis()->SetTitleFont(42); hSM->GetYaxis()->SetLabelFont(42); hSM->GetYaxis()->SetLabelOffset(0.007); hSM->GetYaxis()->SetLabelSize(0.045); hSM->GetYaxis()->SetTitleSize(0.05); hSM->GetYaxis()->SetTitleOffset(1.8); hSM->GetYaxis()->SetTitleFont(42); //TGaxis::SetMaxDigits(2); hSM->Scale(1./hSM->Integral("width")); hPS->Scale(1./hPS->Integral("width")); float maxhSM=hSM->GetBinContent(hSM->GetMaximumBin()); float maxhPS=hPS->GetBinContent(hPS->GetMaximumBin()); if(maxhPS>maxhSM){ hSM->SetMaximum(maxhPS*1.3); hPS->SetMaximum(maxhPS*1.3); } else{ hSM->SetMaximum(maxhSM*1.3); hPS->SetMaximum(maxhSM*1.3); } TH1F* hSM2= (TH1F*)(hSM->Clone("hSM2")); hSM2->SetFillStyle(0); hSM2->SetFillColor(0); hSM2->SetLineColor(kRed+2); hSM2->SetLineStyle(2); hSM2->SetLineWidth(2); hSM->Draw(); hPS->Draw("sames"); hSM2->Draw("sames"); TArrow *obsArrow=0; if(unblind)obsArrow=new TArrow(observedQ,hSM->GetMaximum()/5.0,observedQ,0.0,0.05,"|->"); else obsArrow=new TArrow(0.0,hSM->GetMaximum()/5.0,0.0,0.0,0.05,"|->"); obsArrow->SetLineColor(kRed); obsArrow->SetLineWidth(2.0); if(unblind) obsArrow->Draw(); TLegend *leg = new TLegend(0.63,0.73,0.88,0.93); leg->SetFillColor(0); leg->SetLineColor(0); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->AddEntry(hSM, "0^{+}","f"); leg->AddEntry(hPS, legALT,"f"); if(unblind) leg->AddEntry(hObs,"CMS data","L"); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.18); c1->SetRightMargin(0.05); c1->SetTopMargin(0.05); c1->SetBottomMargin(0.15); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); TPaveText *pt = new TPaveText(0.1577181,0.9562937,0.9580537,0.9947552,"brNDC"); pt->SetBorderSize(0); pt->SetTextAlign(12); pt->SetFillStyle(0); pt->SetTextFont(42); pt->SetTextSize(0.03); TText *text = pt->AddText(0.01,0.5,"CMS preliminary"); text = pt->AddText(0.3,0.6,"#sqrt{s} = 7 TeV, L = 5.1 fb^{-1} #sqrt{s} = 8 TeV, L = 19.6 fb^{-1}"); pt->Draw(); leg->Draw(); c1->SaveAs("sigsep_combine_"+nameALT+".eps"); c1->SaveAs("sigsep_combine_"+nameALT+".png"); c1->SaveAs("sigsep_combine_"+nameALT+".root"); c1->SaveAs("sigsep_combine_"+nameALT+".C"); return 0; }//end main
void HBB_LEP_X(bool scaled=true, bool log=true, float min=0.1, float max=-1., const char* inputfile="root/$HISTFILE", const char* directory="bb_$CATEGORY") { // define common canvas, axes pad styles SetStyle(); gStyle->SetLineStyleString(11,"20 10"); // determine category tag const char* category_extra = ""; if(std::string(directory) == std::string("bb_had0" )){ category_extra = "all-had_{0}"; } if(std::string(directory) == std::string("bb_had1" )){ category_extra = "all-had_{1}"; } if(std::string(directory) == std::string("bb_had2" )){ category_extra = "all-had_{2}"; } if(std::string(directory) == std::string("bb_had3" )){ category_extra = "all-had_{3}"; } if(std::string(directory) == std::string("bb_had4" )){ category_extra = "all-had_{4}"; } if(std::string(directory) == std::string("bb_had5" )){ category_extra = "all-had_{5}"; } if(std::string(directory) == std::string("bb_lep" )){ category_extra = "semi-lep"; } const char* dataset; if(std::string(inputfile).find("7TeV")!=std::string::npos){dataset = "Preliminary, #sqrt{s} = 7 TeV, L = 4.8 fb^{-1}";} if(std::string(inputfile).find("8TeV")!=std::string::npos){dataset = "Preliminary, #sqrt{s} = 8 TeV, L = 19.4 fb^{-1}";} TFile* input = new TFile(inputfile); TH1F* bkgBBB = refill((TH1F*)input->Get(TString::Format("%s/bkgBBB" , directory)), "bkgBBB"); InitHist(bkgBBB, "", "", kMagenta-10, 1001);; #ifdef MSSM float bbHScale = 1.; // scenario for MSSM, mhmax, mA=160, tanb=20, A+H for the time being if(std::string(inputfile).find("7TeV")!=std::string::npos){ bbHScale = (23314.3*0.879 + 21999.3*0.877)/1000.; } if(std::string(inputfile).find("8TeV")!=std::string::npos){ bbHScale = (31087.9*0.879 + 29317.8*0.877)/1000.; } // float bbHScale = 1.; // scenario for MSSM, mhmax, mA=160, tanb=10, A+H for the time being // if(std::string(inputfile).find("7TeV")!=std::string::npos){ bbHScale = (6211.6*0.89 + 5145.0*0.85)/1000.; } // if(std::string(inputfile).find("8TeV")!=std::string::npos){ bbHScale = (8282.7*0.89 + 6867.8*0.85)/1000.; } TH1F* bbH = refill((TH1F*)input->Get(TString::Format("%s/bbH160" , directory)), "bbH" ); InitSignal(bbH); bbH->Scale(bbHScale); #endif TH1F* data = refill((TH1F*)input->Get(TString::Format("%s/data_obs", directory)), "data", true); InitHist(data, "#bf{m_{b#bar{b}} [GeV]}", "#bf{dN/dm_{b#bar{b}} [1/GeV]}"); InitData(data); TH1F* ref=(TH1F*)bkgBBB->Clone("ref"); double unscaled[7]; unscaled[0] = bkgBBB ->Integral(); #ifdef MSSM unscaled[1] = bbH ->Integral(); unscaled[2] = 0; #endif if(scaled){ rescale(bkgBBB, 1); #ifdef MSSM rescale(bbH, 2); #endif } TH1F* scales[7]; scales[0] = new TH1F("scales-bkgBBB", "", 3, 0, 3); scales[0]->SetBinContent(1, unscaled[0]>0 ? (bkgBBB ->Integral()/unscaled[0]-1.) : 0.); #ifdef MSSM scales[1] = new TH1F("scales-bbH" , "", 3, 0, 3); scales[1]->SetBinContent(2, unscaled[1]>0 ? (bbH ->Integral()/unscaled[1]-1.) : 0.); scales[2] = new TH1F("scales-NONE" , "", 3, 0, 3); scales[2]->SetBinContent(3, 0.); #endif if(!log){ #ifdef MSSM bbH ->Add(bkgBBB); #endif } /* mass plot before and after fit */ TCanvas* canv = MakeCanvas("canv", "histograms", 600, 600); canv->cd(); if(log){ canv->SetLogy(1); } #if defined MSSM if(!log){ data->GetXaxis()->SetRange(0, data->FindBin(350)); } else{ data->GetXaxis()->SetRange(0, data->FindBin(1000)); }; #endif data->SetNdivisions(505); data->SetMinimum(min); data->SetMaximum(max>0 ? max : std::max(maximum(data, log), maximum(bkgBBB, log))); data->Draw("e"); TH1F* errorBand = (TH1F*)bkgBBB ->Clone(); errorBand ->SetMarkerSize(0); errorBand ->SetFillColor(1); errorBand ->SetFillStyle(3013); errorBand ->SetLineWidth(1); if(log){ bkgBBB ->Draw("histsame"); $DRAW_ERROR #ifndef DROP_SIGNAL bbH ->Draw("histsame"); #endif } else{ #ifndef DROP_SIGNAL bbH ->Draw("histsame"); #endif bkgBBB ->Draw("histsame"); $DRAW_ERROR } data->Draw("esame"); canv->RedrawAxis(); //CMSPrelim(dataset, "b#bar{b}", 0.17, 0.835); CMSPrelim(dataset, "", 0.17, 0.835); TPaveText* chan = new TPaveText(0.20, 0.74+0.061, 0.32, 0.74+0.161, "NDC"); chan->SetBorderSize( 0 ); chan->SetFillStyle( 0 ); chan->SetTextAlign( 12 ); chan->SetTextSize ( 0.05 ); chan->SetTextColor( 1 ); chan->SetTextFont ( 62 ); chan->AddText("b#bar{b}"); chan->Draw(); TPaveText* cat = new TPaveText(0.20, 0.68+0.061, 0.32, 0.68+0.161, "NDC"); cat->SetBorderSize( 0 ); cat->SetFillStyle( 0 ); cat->SetTextAlign( 12 ); cat->SetTextSize ( 0.05 ); cat->SetTextColor( 1 ); cat->SetTextFont ( 62 ); cat->AddText(category_extra); cat->Draw(); #ifdef MSSM TPaveText* massA = new TPaveText(0.75, 0.48+0.061, 0.85, 0.48+0.161, "NDC"); massA->SetBorderSize( 0 ); massA->SetFillStyle( 0 ); massA->SetTextAlign( 12 ); massA->SetTextSize ( 0.03 ); massA->SetTextColor( 1 ); massA->SetTextFont ( 62 ); massA->AddText("m_{A}=160GeV"); massA->Draw(); TPaveText* tanb = new TPaveText(0.75, 0.44+0.061, 0.85, 0.44+0.161, "NDC"); tanb->SetBorderSize( 0 ); tanb->SetFillStyle( 0 ); tanb->SetTextAlign( 12 ); tanb->SetTextSize ( 0.03 ); tanb->SetTextColor( 1 ); tanb->SetTextFont ( 62 ); tanb->AddText("tan#beta=20"); tanb->Draw(); TPaveText* scen = new TPaveText(0.75, 0.40+0.061, 0.85, 0.40+0.161, "NDC"); scen->SetBorderSize( 0 ); scen->SetFillStyle( 0 ); scen->SetTextAlign( 12 ); scen->SetTextSize ( 0.03 ); scen->SetTextColor( 1 ); scen->SetTextFont ( 62 ); scen->AddText("mhmax"); scen->Draw(); #endif #ifdef MSSM TLegend* leg = new TLegend(0.55, 0.65, 0.94, 0.90); SetLegendStyle(leg); leg->AddEntry(bbH , "#phi#rightarrowb#bar{b}" , "L" ); #endif leg->AddEntry(data, "observed" , "LP"); leg->AddEntry(bkgBBB, "bkgBBB" , "F" ); $ERROR_LEGEND leg->Draw(); //#ifdef MSSM // TPaveText* mssm = new TPaveText(0.69, 0.85, 0.90, 0.90, "NDC"); // mssm->SetBorderSize( 0 ); // mssm->SetFillStyle( 0 ); // mssm->SetTextAlign( 12 ); // mssm->SetTextSize ( 0.03 ); // mssm->SetTextColor( 1 ); // mssm->SetTextFont ( 62 ); // mssm->AddText("(m_{A}=250, tan#beta=5)"); // mssm->Draw(); //#else // TPaveText* mssm = new TPaveText(0.83, 0.85, 0.95, 0.90, "NDC"); // mssm->SetBorderSize( 0 ); // mssm->SetFillStyle( 0 ); // mssm->SetTextAlign( 12 ); // mssm->SetTextSize ( 0.03 ); // mssm->SetTextColor( 1 ); // mssm->SetTextFont ( 62 ); // mssm->AddText("m_{H}=125"); // mssm->Draw(); //#endif /* Ratio Data over MC */ TCanvas *canv0 = MakeCanvas("canv0", "histograms", 600, 400); canv0->SetGridx(); canv0->SetGridy(); canv0->cd(); TH1F* zero = (TH1F*)ref ->Clone("zero"); zero->Clear(); TH1F* rat1 = (TH1F*)data->Clone("rat"); rat1->Divide(bkgBBB); for(int ibin=0; ibin<rat1->GetNbinsX(); ++ibin){ if(rat1->GetBinContent(ibin+1)>0){ // catch cases of 0 bins, which would lead to 0-alpha*0-1 rat1->SetBinContent(ibin+1, rat1->GetBinContent(ibin+1)-1.); } zero->SetBinContent(ibin+1, 0.); } rat1->SetLineColor(kBlack); rat1->SetFillColor(kGray ); rat1->SetMaximum(+1.5); rat1->SetMinimum(-1.5); rat1->GetYaxis()->CenterTitle(); rat1->GetYaxis()->SetTitle("#bf{Data/MC-1}"); rat1->GetXaxis()->SetTitle("#bf{m_{b#bar{b}} [GeV]}"); rat1->Draw(); zero->SetLineColor(kBlack); zero->Draw("same"); canv0->RedrawAxis(); /* Ratio After fit over Prefit */ TCanvas *canv1 = MakeCanvas("canv1", "histograms", 600, 400); canv1->SetGridx(); canv1->SetGridy(); canv1->cd(); TH1F* rat2 = (TH1F*) bkgBBB->Clone("rat2"); rat2->Divide(ref); for(int ibin=0; ibin<rat2->GetNbinsX(); ++ibin){ if(rat2->GetBinContent(ibin+1)>0){ // catch cases of 0 bins, which would lead to 0-alpha*0-1 rat2 ->SetBinContent(ibin+1, rat2->GetBinContent(ibin+1)-1.); } } rat2->SetLineColor(kRed+ 3); rat2->SetFillColor(kRed-10); rat2->SetMaximum(+0.3); rat2->SetMinimum(-0.3); rat2->GetYaxis()->SetTitle("#bf{Fit/Prefit-1}"); rat2->GetYaxis()->CenterTitle(); rat2->GetXaxis()->SetTitle("#bf{m_{b#bar{b}} [GeV]}"); rat2->GetXaxis()->SetRange(0, 28); rat2->Draw(); zero->SetLineColor(kBlack); zero->Draw("same"); canv1->RedrawAxis(); /* Relative shift per sample */ TCanvas *canv2 = MakeCanvas("canv2", "histograms", 600, 400); canv2->SetGridx(); canv2->SetGridy(); canv2->cd(); InitHist (scales[0], "", "", kMagenta-10, 1001); scales[0]->Draw(); scales[0]->GetXaxis()->SetBinLabel(1, "#bf{bkgBBB}"); #ifdef MSSM scales[0]->GetXaxis()->SetBinLabel(2, "#bf{bbH}" ); scales[0]->GetXaxis()->SetBinLabel(3, "#bf{NONE}" ); #endif scales[0]->SetMaximum(+1.0); scales[0]->SetMinimum(-1.0); scales[0]->GetYaxis()->CenterTitle(); scales[0]->GetYaxis()->SetTitle("#bf{Fit/Prefit-1}"); zero->Draw("same"); canv2->RedrawAxis(); /* prepare output */ bool isSevenTeV = std::string(inputfile).find("7TeV")!=std::string::npos; canv ->Print(TString::Format("%s_%sscaled_%s_%s.png" , directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv ->Print(TString::Format("%s_%sscaled_%s_%s.pdf" , directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv ->Print(TString::Format("%s_%sscaled_%s_%s.eps" , directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv0->Print(TString::Format("%s_datamc_%sscaled_%s_%s.png", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv0->Print(TString::Format("%s_datamc_%sscaled_%s_%s.pdf", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv0->Print(TString::Format("%s_datamc_%sscaled_%s_%s.eps", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv1->Print(TString::Format("%s_prefit_%sscaled_%s_%s.png", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv1->Print(TString::Format("%s_prefit_%sscaled_%s_%s.pdf", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv1->Print(TString::Format("%s_prefit_%sscaled_%s_%s.eps", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv2->Print(TString::Format("%s_sample_%sscaled_%s_%s.png", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv2->Print(TString::Format("%s_sample_%sscaled_%s_%s.pdf", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); canv2->Print(TString::Format("%s_sample_%sscaled_%s_%s.eps", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : "")); TFile* output = new TFile(TString::Format("%s_%sscaled_%s_%s.root", directory, scaled ? "re" : "un", isSevenTeV ? "7TeV" : "8TeV", log ? "LOG" : ""), "update"); output->cd(); data ->Write("data_obs"); bkgBBB ->Write("bkgBBB" ); #ifdef MSSM bbH ->Write("bbH" ); #endif if(errorBand){ errorBand->Write("errorBand"); } output->Close(); }
// examples macro void etauAfterFit_Pt2(bool scaled = true, bool log = true) { // defining the common canvas, axes pad styles SetStyle(); // open example histogram file TFile* exampleFile = new TFile("more/eleTauPT2.root"); //load example histograms TH1F* data = (TH1F*)exampleFile->Get("eleTau_X/data_obs"); if(data) {InitHist(data, "#bf{#tau p_{T} [GeV]}", "#bf{Events}"); InitData(data);} else{std::cout << "can't find hitogram " << "eleTau_SM0/data_obs" << std::endl;} TH1F* Fakes = refill((TH1F*)exampleFile->Get("eleTau_X/QCD")) ; InitHist(Fakes, "", "", kMagenta-10, 1001); TH1F* EWK1 = refill((TH1F*)exampleFile->Get("eleTau_X/W" )) ; InitHist(EWK1 , "", "", kRed + 2, 1001); TH1F* EWK2 = refill((TH1F*)exampleFile->Get("eleTau_X/ZJ" )) ; InitHist(EWK2 , "", "", kRed + 2, 1001); TH1F* EWK3 = refill((TH1F*)exampleFile->Get("eleTau_X/ZL" )) ; InitHist(EWK3 , "", "", kRed + 2, 1001); TH1F* EWK = refill((TH1F*)exampleFile->Get("eleTau_X/VV" )) ; InitHist(EWK , "", "", kRed + 2, 1001); TH1F* ttbar = refill((TH1F*)exampleFile->Get("eleTau_X/TT" )) ; InitHist(ttbar, "", "", kBlue - 8, 1001); TH1F* Ztt = refill((TH1F*)exampleFile->Get("eleTau_X/ZTT")) ; InitHist(Ztt , "", "", kOrange - 4, 1001); TH1F* ggH = refill((TH1F*)exampleFile->Get("eleTau_X/SM120" )) ; InitSignal(ggH); ggH ->Scale(10*16.63*0.071*16.083/ggH ->Integral()); TH1F* qqH = refill((TH1F*)exampleFile->Get("eleTau_X/VBF120")) ; InitSignal(qqH); qqH ->Scale(10*1.269*0.071* 1.105/qqH ->Integral()); if(scaled){ rescale(Fakes, 2); rescale(EWK1 , 3); rescale(EWK2 , 4); rescale(EWK3 , 5); rescale(EWK , 7); rescale(ttbar, 6); rescale(Ztt , 1); rescale(ggH , 8); rescale(qqH , 9); } if(log){ qqH ->Add(ggH ); Fakes->Add(qqH ); EWK1 ->Add(Fakes); EWK2 ->Add(EWK1 ); EWK3 ->Add(EWK2 ); EWK ->Add(EWK3 ); ttbar->Add(EWK ); Ztt ->Add(ttbar); } else{ EWK1 ->Add(Fakes); EWK2 ->Add(EWK1 ); EWK3 ->Add(EWK2 ); EWK ->Add(EWK3 ); ttbar->Add(EWK ); Ztt ->Add(ttbar); ggH ->Add(Ztt ); qqH ->Add(ggH ); } // define canvas TCanvas *canv = MakeCanvas("canv", "histograms", 600, 600); canv->cd(); if(log){ canv->SetLogy(1); data->SetMinimum(1.0); data->SetMaximum(100000.); } else{ data->SetMaximum(4000.); } data->SetNdivisions(505); data->Draw("e"); if(log){ Ztt->Draw("same"); ttbar->Draw("same"); EWK->Draw("same"); Fakes->Draw("same"); qqH->Draw("same"); } else{ qqH->Draw("same"); Ztt->Draw("same"); ttbar->Draw("same"); EWK->Draw("same"); Fakes->Draw("same"); } data->Draw("esame"); canv->RedrawAxis(); CMSPrelim("#tau_{e}#tau_{h}", 0.45, 0.75); TLegend* leg = new TLegend(0.45, 0.45, 0.9, 0.75); SetLegendStyle(leg); leg->AddEntry(qqH , "(10x) H#rightarrow#tau#tau" , "L" ); leg->AddEntry(data , "Observed" , "LP"); leg->AddEntry(Ztt , "Z#rightarrow#tau#tau" , "F" ); leg->AddEntry(ttbar, "t#bar{t}" , "F" ); leg->AddEntry(EWK , "Electroweak" , "F" ); leg->AddEntry(Fakes, "QCD" , "F" ); leg->Draw(); TPaveText* mssm = new TPaveText(0.78, 0.70, 0.90, 0.74, "NDC"); mssm->SetBorderSize( 0 ); mssm->SetFillStyle( 0 ); mssm->SetTextAlign( 12 ); mssm->SetTextSize ( 0.04 ); mssm->SetTextColor( 1 ); mssm->SetTextFont ( 62 ); mssm->AddText("m_{H}=120"); mssm->Draw(); if(log){ if(scaled) canv->Print("etau_Pt2_LOG.pdf"); else canv->Print("etau_Pt2_LOG.pdf"); if(scaled) canv->Print("etau_Pt2_LOG.png"); else canv->Print("etau_Pt2_LOG.png"); } }
void makeMuonTimingPlot (std::string fname) { TFile file(fname.c_str()); TDirectoryFile *dir = (TDirectoryFile*)file.Get("Muons"); TList *hlist = dir->GetListOfKeys(); TH1F *h1; bool foundHist = false; for (auto hist : *hlist) { TString name = hist->GetName(); if (!name.Contains("hMuTimeP")) continue; TH1F *h0 = (TH1F*)dir->Get(name.Data()); if (!foundHist) { h1 = (TH1F*)h0->Clone(); h1->Sumw2(); foundHist = true; } else { h1->Add(h0); } } TH1F *h2 = new TH1F("h2", "h2", 200, -100, 100); h2->GetXaxis()->SetTitle("muon time (ns)"); h2->GetYaxis()->SetTitle("Fraction of Muons/ns"); h2->GetYaxis()->SetTitleOffset(1.1); h2->GetXaxis()->SetTitleOffset(0.8); h2->SetTitle("CSC Muon Time"); h2->SetTitleFont(42); h2->SetTitleSize(0.052); h2->Sumw2(); h2->SetLineColor(kCyan+3); h2->SetFillColor(kCyan+3); for (int ibin = 1; ibin <= 200; ibin++) { h2->SetBinContent(ibin, h1->GetBinContent(ibin)); h2->SetBinError(ibin, h1->GetBinError(ibin)); if (ibin == 200) h2->SetEntries(h1->GetEntries()); } TCanvas c1("c1", "c1", 600, 400); gStyle->SetOptStat(""); double rms = h2->GetRMS(); double avg = h2->GetMean(); TLatex cms(0.17, 0.83, "CMS"); cms.SetNDC(); cms.SetTextFont(61); cms.SetTextSize(0.06); TLatex prelim(0.17, 0.81, "Preliminary"); prelim.SetNDC(); prelim.SetTextAlign(13); prelim.SetTextFont(52); prelim.SetTextSize(0.0456); TLatex data(0.17, 0.76, "Data 2016"); data.SetNDC(); data.SetTextAlign(13); data.SetTextFont(52); data.SetTextSize(0.0456); TLatex lumi(0.9, 0.93, "4.0 fb^{-1} (13 TeV)"); lumi.SetNDC(); lumi.SetTextAlign(31); lumi.SetTextFont(42); lumi.SetTextSize(0.052); TLatex mean(0.7, 0.81, Form("Mean %2.1f", avg)); mean.SetNDC(); mean.SetTextAlign(11); mean.SetTextFont(61); mean.SetTextSize(0.06); TLatex stdev(0.7, 0.76, Form("RMS %2.1f", rms)); stdev.SetNDC(); stdev.SetTextAlign(11); stdev.SetTextFont(61); stdev.SetTextSize(0.06); h2->GetXaxis()->SetRangeUser(-6*rms,6*rms); TH1F* h2norm = (TH1F*)h2->DrawNormalized("hist"); gPad->Update(); cms.Draw(); prelim.Draw(); data.Draw(); lumi.Draw(); mean.Draw(); stdev.Draw(); TPaveText *title = (TPaveText*)gPad->GetPrimitive("title"); title->SetBorderSize(0); title->SetFillColor(0); title->SetFillStyle(0); title->SetX1NDC(0.13); title->SetY1NDC(0.88); title->SetX2NDC(0.9); title->SetY2NDC(0.98); title->SetTextFont(42); title->SetTextSize(0.052); title->SetTextAlign(11); c1.Print("plots/muon_time_all.pdf"); c1.Print("plots/muon_time_all.png"); c1.Print("plots/muon_time_all.root"); }
Float_t doCoinc(const char *fileIn="coincCERN_0102n.root",TCanvas *cout=NULL,Float_t &rate,Float_t &rateErr){ // Print settings printf("SETTINGS\nAnalyze output from new Analyzer\n"); printf("Input file = %s\n",fileIn); printf("School distance = %f m, angle = %f deg\n",distance,angle); printf("School orientation: tel1=%f deg, tel2=%f deg\n",phi1Corr,phi2Corr); printf("Max Chi2 = %f\n",maxchisquare); printf("Theta Rel Range = %f - %f deg\n",minthetarel,maxthetarel); printf("Range for N sattellite in each run = (tel1) %f - %f, (tel2) %f - %f \n",minAvSat[0],maxAvSat[0],minAvSat[1],maxAvSat[1]); printf("Min N satellite in a single event = %i\n",satEventThr); Int_t adayMin = (yearRange[0]-2014) * 1000 + monthRange[0]*50 + dayRange[0]; Int_t adayMax = (yearRange[1]-2014) * 1000 + monthRange[1]*50 + dayRange[1]; Float_t nsigPeak=0; Float_t nbackPeak=0; angle *= TMath::DegToRad(); // define some histos TH1F *hDeltaTheta = new TH1F("hDeltaTheta","#Delta#theta below the peak (500 ns);#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhi = new TH1F("hDeltaPhi","#Delta#phi below the peak (500 ns);#Delta#phi (#circ)",200,-360,360); TH1F *hDeltaThetaBack = new TH1F("hDeltaThetaBack","#Delta#theta out of the peak (> 1000 ns) - normalized;#Delta#theta (#circ)",100,-60,60); TH1F *hDeltaPhiBack = new TH1F("hDeltaPhiBack","#Delta#phi out of the peak (> 1000 ns) - normalized;#Delta#phi (#circ)",200,-360,360); TH1F *hThetaRel = new TH1F("hThetaRel","#theta_{rel} below the peak (500 ns);#theta_{rel} (#circ)",100,0,120); TH1F *hThetaRelBack = new TH1F("hThetaRelBack","#theta_{rel} out of the peak (> 1000 ns) - normalized;#theta_{rel} (#circ)",100,0,120); TH2F *hAngle = new TH2F("hAngle",";#Delta#theta (#circ);#Delta#phi (#circ}",20,-60,60,20,-360,360); TH2F *hAngleBack = new TH2F("hAngleBack",";#Delta#theta (#circ);#Delta#phi (#circ}",20,-60,60,20,-360,360); TProfile *hModulation = new TProfile("hModulation","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulation2 = new TProfile("hModulation2","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulationAv = new TProfile("hModulationAv","#theta^{rel} < 10#circ;#phi - #alpha;dist (m)",50,0,360); TProfile *hModulationAvCorr = new TProfile("hModulationAvCorr","#theta^{rel} < 10#circ;#phi - #alpha;diff (ns)",50,0,360); TH1F *hnsigpeak = new TH1F("hnsigpeak","",50,0,360); TH1F *hnbackpeak = new TH1F("hnbackpeak","",50,0,360); TProfile *hSinTheta = new TProfile("hSinTheta",";#phi - #alpha;sin(#theta)",50,0,360); TProfile *hSinTheta2 = new TProfile("hSinTheta2",";#phi - #alpha;sin(#theta)",50,0,360); TH1F *hRunCut[2]; hRunCut[0] = new TH1F("hRunCut1","Reason for Run Rejection Tel-1;Reason;runs rejected",11,0,11); hRunCut[1] = new TH1F("hRunCut2","Reason for Run Rejection Tel-2;Reason;runs rejected",11,0,11); for(Int_t i=0;i<2;i++){ hRunCut[i]->Fill("DateRange",0); hRunCut[i]->Fill("LowFractionGT",0); hRunCut[i]->Fill("TimeDuration",0); hRunCut[i]->Fill("rateGT",0); hRunCut[i]->Fill("RunNumber",0); hRunCut[i]->Fill("MissingHitFrac",0); hRunCut[i]->Fill("DeadStripBot",0); hRunCut[i]->Fill("DeadStripMid",0); hRunCut[i]->Fill("DeadStripTop",0); hRunCut[i]->Fill("NSatellites",0); hRunCut[i]->Fill("NoGoodWeather",0); } TFile *f = new TFile(fileIn); TTree *t = (TTree *) f->Get("tree"); TTree *tel[2]; tel[0] = (TTree *) f->Get("treeTel1"); tel[1] = (TTree *) f->Get("treeTel2"); TTree *telC = (TTree *) f->Get("treeTimeCommon"); // quality info of runs const Int_t nyearmax = 5; Bool_t runstatus[2][nyearmax][12][31][500]; //#telescope, year-2014, month, day, run Float_t effTel[2][nyearmax][12][31][500]; Int_t nStripDeadBot[2][nyearmax][12][31][500]; Int_t nStripDeadMid[2][nyearmax][12][31][500]; Int_t nStripDeadTop[2][nyearmax][12][31][500]; Float_t nstripDeadB[2]={0,0},nstripDeadM[2]={0,0},nstripDeadT[2]={0,0}; // sat info Float_t NsatAv[2][nyearmax][12][31][500]; // weather info Float_t pressureTel[2][nyearmax][12][31][500]; Float_t TempInTel[2][nyearmax][12][31][500]; Float_t TempOutTel[2][nyearmax][12][31][500]; Float_t timeWeath[2][nyearmax][12][31][500]; Float_t rateGT; Float_t phirelative; Float_t phirelative2; Float_t phirelativeAv; printf("Check Run quality\n"); if(tel[0] && tel[1]){ for(Int_t i=0;i < 2;i++){ // loop on telescopes printf("Tel-%i\n",i+1); for(Int_t j=0;j < tel[i]->GetEntries();j++){ // loop on runs tel[i]->GetEvent(j); rateGT = tel[i]->GetLeaf("FractionGoodTrack")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue(); Int_t aday = (tel[i]->GetLeaf("year")->GetValue()-2014) * 1000 + tel[i]->GetLeaf("month")->GetValue()*50 + tel[i]->GetLeaf("day")->GetValue(); if(i==1) printf("%f %f\n",rateGT , rateMin[i]); if(aday < adayMin || aday > adayMax){ hRunCut[i]->Fill("DateRange",1); continue;} if(tel[i]->GetLeaf("FractionGoodTrack")->GetValue() < fracGT[i]){ hRunCut[i]->Fill("LowFractionGT",1); continue;} // cut on fraction of good track if(tel[i]->GetLeaf("timeduration")->GetValue()*tel[i]->GetLeaf("rateHitPerRun")->GetValue() < hitevents[i]){ hRunCut[i]->Fill("TimeDuration",1); continue;} // cut on the number of event if(rateGT < rateMin[i] || rateGT > rateMax[i]){ hRunCut[i]->Fill("rateGT",1); continue;} // cut on the rate if(tel[i]->GetLeaf("run")->GetValue() > 499){ hRunCut[i]->Fill("RunNumber",1); continue;} // run < 500 if(i==1) printf("GR\n"); Float_t missinghitfrac = (tel[i]->GetLeaf("ratePerRun")->GetValue()-tel[i]->GetLeaf("rateHitPerRun")->GetValue()-2)/(tel[i]->GetLeaf("ratePerRun")->GetValue()-2); if(missinghitfrac < minmissingHitFrac[i] || missinghitfrac > maxmissingHitFrac[i]){ hRunCut[i]->Fill("MissingHitFrac",1); continue;} // active strip maps if(tel[i]->GetLeaf("maskB")) nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskB")->GetValue())); if(tel[i]->GetLeaf("maskM")) nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskM")->GetValue())); if(tel[i]->GetLeaf("maskT")) nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = countBits(Int_t(tel[i]->GetLeaf("maskT")->GetValue())); if(nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadBotMax[i] || nStripDeadBot[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadBotMin[i]) { hRunCut[i]->Fill("DeadStripBot",1); continue;} if(nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadMidMax[i] || nStripDeadMid[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadMidMin[i]){ hRunCut[i]->Fill("DeadStripMid",1); continue;} if(nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > ndeadTopMax[i] || nStripDeadTop[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < ndeadTopMin[i]){ hRunCut[i]->Fill("DeadStripTop",1); continue;} // nsat averaged per run if(tel[i]->GetLeaf("nSat")) NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("nSat")->GetValue(); if(NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < minAvSat[i] || NsatAv[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > maxAvSat[i]){ hRunCut[i]->Fill("NSatellites",1); continue;} // weather info if(tel[i]->GetLeaf("Pressure")) pressureTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("Pressure")->GetValue(); if(tel[i]->GetLeaf("IndoorTemperature")) TempInTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("IndoorTemperature")->GetValue(); if(tel[i]->GetLeaf("OutdoorTemperature")) TempOutTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("OutdoorTemperature")->GetValue(); if(tel[i]->GetLeaf("TimeWeatherUpdate")) timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = tel[i]->GetLeaf("TimeWeatherUpdate")->GetValue(); if(timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] < minWeathTimeDelay[i] || timeWeath[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] > maxWeathTimeDelay[i]){ hRunCut[i]->Fill("NoGoodWeather",1); continue; } // Set good runs runstatus[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = kTRUE; effTel[i][Int_t(tel[i]->GetLeaf("year")->GetValue())-2014][Int_t(tel[i]->GetLeaf("month")->GetValue())][Int_t(tel[i]->GetLeaf("day")->GetValue())][Int_t(tel[i]->GetLeaf("run")->GetValue())] = 1;//rateGT/refRate[i]; } } } else{ telC = NULL; } printf("Start to process correlations\n"); Int_t n = t->GetEntries(); // counter for seconds Int_t nsec = 0; Int_t nsecGR = 0; // for good runs Int_t isec = -1; // used only in case the tree with time info is not available Float_t neventsGR = 0; Float_t neventsGRandSat = 0; if(telC){ for(Int_t i=0; i < telC->GetEntries();i++){ telC->GetEvent(i); nsec += telC->GetLeaf("timeduration")->GetValue(); if(telC->GetLeaf("run")->GetValue() > 499 || telC->GetLeaf("run2")->GetValue() > 499) continue; if(!runstatus[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())]) continue; if(!runstatus[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run2")->GetValue())]) continue; nsecGR += telC->GetLeaf("timeduration")->GetValue(); nstripDeadB[0] += countBits(nStripDeadBot[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadM[0] += countBits(nStripDeadMid[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadT[0] += countBits(nStripDeadTop[0][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadB[1] += countBits(nStripDeadBot[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadM[1] += countBits(nStripDeadMid[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); nstripDeadT[1] += countBits(nStripDeadTop[1][Int_t(telC->GetLeaf("year")->GetValue())-2014][Int_t(telC->GetLeaf("month")->GetValue())][Int_t(telC->GetLeaf("day")->GetValue())][Int_t(telC->GetLeaf("run")->GetValue())])*telC->GetLeaf("timeduration")->GetValue(); } nstripDeadB[0] /= nsecGR; nstripDeadM[0] /= nsecGR; nstripDeadT[0] /= nsecGR; nstripDeadB[1] /= nsecGR; nstripDeadM[1] /= nsecGR; nstripDeadT[1] /= nsecGR; printf("Dead channel tel1 = %f - %f - %f\n",nstripDeadB[0],nstripDeadM[0],nstripDeadT[0]); printf("Dead channel tel2 = %f - %f - %f\n",nstripDeadB[1],nstripDeadM[1],nstripDeadT[1]); } char title[300]; TH1F *h; sprintf(title,"correction assuming #Delta#phi = %4.2f, #DeltaL = %.1f m;#Deltat (ns);entries",angle,distance); h = new TH1F("hCoinc",title,nbint,tmin,tmax); Float_t DeltaT; Float_t phiAv,thetaAv,corr; Float_t Theta1,Theta2; Float_t Phi1,Phi2; Int_t nsatel1cur,nsatel2cur,ntrack1,ntrack2; Float_t v1[3],v2[3],vSP; // variable to recompute ThetaRel on the fly Float_t eff = 1; for(Int_t i=0;i<n;i++){ t->GetEvent(i); if(t->GetLeaf("RunNumber1") && (t->GetLeaf("RunNumber1")->GetValue() > 499 || t->GetLeaf("RunNumber2")->GetValue() > 499)) continue; if(tel[0] && !runstatus[0][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]) continue; if(tel[1] && !runstatus[1][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]) continue; eff = effTel[0][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber1")->GetValue())]; eff *= effTel[1][Int_t(t->GetLeaf("year")->GetValue())-2014][Int_t(t->GetLeaf("month")->GetValue())][Int_t(t->GetLeaf("day")->GetValue())][Int_t(t->GetLeaf("RunNumber2")->GetValue())]; Int_t timec = t->GetLeaf("ctime1")->GetValue(); if(! telC){ if(isec == -1) isec = timec; if(timec != isec){ if(timec - isec < 20){ // printf("diff = %i\n",timec-isec); nsec +=(timec - isec); nsecGR +=(timec - isec); } isec = timec; } } Float_t thetarel = t->GetLeaf("ThetaRel")->GetValue(); Theta1 = (t->GetLeaf("Theta1")->GetValue())*TMath::DegToRad(); Theta2 = t->GetLeaf("Theta2")->GetValue()*TMath::DegToRad(); Phi1 = t->GetLeaf("Phi1")->GetValue()*TMath::DegToRad(); Phi2 = t->GetLeaf("Phi2")->GetValue()*TMath::DegToRad(); nsatel1cur = t->GetLeaf("Nsatellite1")->GetValue(); nsatel2cur = t->GetLeaf("Nsatellite2")->GetValue(); ntrack1 = t->GetLeaf("Ntracks1")->GetValue(); ntrack2 = t->GetLeaf("Ntracks2")->GetValue(); if(recomputeThetaRel){ // recompute ThetaRel applying corrections Phi1 += phi1Corr*TMath::DegToRad(); Phi2 += phi2Corr*TMath::DegToRad(); if(Phi1 > 2*TMath::Pi()) Phi1 -= 2*TMath::Pi(); if(Phi1 < 0) Phi1 += 2*TMath::Pi(); if(Phi2 > 2*TMath::Pi()) Phi2 -= 2*TMath::Pi(); if(Phi2 < 0) Phi2 += 2*TMath::Pi(); v1[0] = TMath::Sin(Theta1)*TMath::Cos(Phi1); v1[1] = TMath::Sin(Theta1)*TMath::Sin(Phi1); v1[2] = TMath::Cos(Theta1); v2[0] = TMath::Sin(Theta2)*TMath::Cos(Phi2); v2[1] = TMath::Sin(Theta2)*TMath::Sin(Phi2); v2[2] = TMath::Cos(Theta2); v1[0] *= v2[0]; v1[1] *= v2[1]; v1[2] *= v2[2]; vSP = v1[0] + v1[1] + v1[2]; thetarel = TMath::ACos(vSP)*TMath::RadToDeg(); } // cuts if(thetarel < minthetarel) continue; if(thetarel > maxthetarel) continue; if(t->GetLeaf("ChiSquare1")->GetValue() > maxchisquare) continue; if(t->GetLeaf("ChiSquare2")->GetValue() > maxchisquare) continue; neventsGR++; // reject events with not enough satellites if(nsatel1cur < satEventThr || nsatel1cur < satEventThr) continue; neventsGRandSat++; DeltaT = t->GetLeaf("DiffTime")->GetValue(); // get primary direction if(TMath::Abs(Phi1-Phi2) < TMath::Pi()) phiAv = (Phi1+Phi2)*0.5; else phiAv = (Phi1+Phi2)*0.5 + TMath::Pi(); thetaAv = (Theta1+Theta2)*0.5; // extra cuts if needed // if(TMath::Cos(Phi1-Phi2) < 0.) continue; Float_t resFactor = 1; if(thetarel > 10 ) resFactor *= 0.5; if(thetarel > 20 ) resFactor *= 0.5; if(thetarel > 30 ) resFactor *= 0.5; corr = distance * TMath::Sin(thetaAv)*TMath::Cos(phiAv-angle)/2.99792458000000039e-01 + deltatCorr; phirelative = (Phi1-angle)*TMath::RadToDeg(); if(phirelative < 0) phirelative += 360; if(phirelative < 0) phirelative += 360; if(phirelative > 360) phirelative -= 360; if(phirelative > 360) phirelative -= 360; phirelative2 = (Phi2-angle)*TMath::RadToDeg(); if(phirelative2 < 0) phirelative2 += 360; if(phirelative2 < 0) phirelative2 += 360; if(phirelative2 > 360) phirelative2 -= 360; if(phirelative2 > 360) phirelative2 -= 360; phirelativeAv = (phiAv-angle)*TMath::RadToDeg(); if(phirelativeAv < 0) phirelativeAv += 360; if(phirelativeAv < 0) phirelativeAv += 360; if(phirelativeAv > 360) phirelativeAv -= 360; if(phirelativeAv > 360) phirelativeAv -= 360; // if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment){ // } if(thetarel < 10){//cos(thetarel*TMath::DegToRad())>0.98 && sin(thetaAv)>0.1){ if(TMath::Abs(DeltaT- corr) < windowAlignment) hModulationAvCorr->Fill(phirelativeAv,DeltaT-corr); if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment){ hModulation->Fill(phirelative,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hModulation2->Fill(phirelative2,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hModulationAv->Fill(phirelativeAv,(DeltaT-deltatCorr)/sin(thetaAv)*2.99792458000000039e-01); hSinTheta->Fill(phirelative,sin(thetaAv)); hSinTheta2->Fill(phirelative2,sin(thetaAv)); nsigPeak++; hnsigpeak->Fill(phirelativeAv); } else if(TMath::Abs(DeltaT- deltatCorr) < windowAlignment*10){ nbackPeak++; hnbackpeak->Fill(phirelativeAv); } } h->Fill(DeltaT-corr,1./eff); if(TMath::Abs(DeltaT-corr) < windowAlignment){ hDeltaTheta->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhi->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRel->Fill(thetarel); hAngle->Fill((Theta1-Theta2)*TMath::RadToDeg(),(Phi1-Phi2)*TMath::RadToDeg()); } else if(TMath::Abs(DeltaT-corr) > windowAlignment*2 && TMath::Abs(DeltaT-corr) < windowAlignment*12){ hDeltaThetaBack->Fill((Theta1-Theta2)*TMath::RadToDeg()); hDeltaPhiBack->Fill((Phi1-Phi2)*TMath::RadToDeg()); hThetaRelBack->Fill(thetarel); hAngleBack->Fill((Theta1-Theta2)*TMath::RadToDeg(),(Phi1-Phi2)*TMath::RadToDeg()); } } // compute (S+B)/S for(Int_t i=1;i<=50;i++){ Float_t corrfactorPeak = 1; if(nsigPeak-nbackPeak*0.1 > 0) corrfactorPeak = hnsigpeak->GetBinContent(i)/(hnsigpeak->GetBinContent(i)-hnbackpeak->GetBinContent(i)*0.1); else printf("bin %i) not enough statistics\n",i); hnsigpeak->SetBinContent(i,corrfactorPeak); } TF1 *fpol0 = new TF1("fpol0","pol0"); hnsigpeak->Fit(fpol0); hModulation->Scale(fpol0->GetParameter(0)); hModulation2->Scale(fpol0->GetParameter(0)); hModulationAv->Scale(fpol0->GetParameter(0)); hModulationAvCorr->Scale(fpol0->GetParameter(0)); TF1 *fmod = new TF1("fmod","[0] + [1]*cos((x-[2])*TMath::DegToRad())"); hModulationAv->Fit(fmod); printf("Estimates from time delay: Distance = %f +/- %f m -- Angle = %f +/- %f deg\n",fmod->GetParameter(1),fmod->GetParError(1),fmod->GetParameter(2),fmod->GetParError(2)); h->SetStats(0); hDeltaThetaBack->Sumw2(); hDeltaPhiBack->Sumw2(); hThetaRelBack->Sumw2(); hDeltaThetaBack->Scale(0.1); hDeltaPhiBack->Scale(0.1); hThetaRelBack->Scale(0.1); hAngleBack->Scale(0.1); hAngle->Add(hAngleBack,-1); printf("bin counting: SIGNAL = %f +/- %f\n",hDeltaPhi->Integral()-hDeltaPhiBack->Integral(),sqrt(hDeltaPhi->Integral())); rate = (hDeltaPhi->Integral()-hDeltaPhiBack->Integral())/nsecGR*86400; rateErr = sqrt(hDeltaPhi->Integral())/nsecGR*86400; Float_t val,eval; TCanvas *c1=new TCanvas(); TF1 *ff = new TF1("ff","[0]*[4]/[2]/sqrt(2*TMath::Pi())*TMath::Exp(-(x-[1])*(x-[1])*0.5/[2]/[2]) + [3]*[4]/6/[2]"); ff->SetParName(0,"signal"); ff->SetParName(1,"mean"); ff->SetParName(2,"sigma"); ff->SetParName(3,"background"); ff->SetParName(4,"bin width"); ff->SetParameter(0,42369); ff->SetParameter(1,0); ff->SetParLimits(2,10,maxwidth); ff->SetParameter(2,350); // fix witdh if needed ff->SetParameter(3,319); ff->FixParameter(4,(tmax-tmin)/nbint); // bin width ff->SetNpx(1000); if(cout) cout->cd(); h->Fit(ff,"EI","",-10000,10000); val = ff->GetParameter(2); eval = ff->GetParError(2); printf("significance = %f\n",ff->GetParameter(0)/sqrt(ff->GetParameter(0) + ff->GetParameter(3))); h->Draw(); new TCanvas; TF1 *func1 = (TF1 *) h->GetListOfFunctions()->At(0); func1->SetLineColor(2); h->SetLineColor(4); TPaveText *text = new TPaveText(1500,(h->GetMinimum()+(h->GetMaximum()-h->GetMinimum())*0.6),9500,h->GetMaximum()); text->SetFillColor(0); sprintf(title,"width = %5.1f #pm %5.1f",func1->GetParameter(2),func1->GetParError(2)); text->AddText(title); sprintf(title,"signal (S) = %5.1f #pm %5.1f",func1->GetParameter(0),func1->GetParError(0)); text->AddText(title); sprintf(title,"background (B) (3#sigma) = %5.1f #pm %5.1f",func1->GetParameter(3),func1->GetParError(3)); text->AddText(title); sprintf(title,"significance (S/#sqrt{S+B}) = %5.1f",func1->GetParameter(0)/sqrt(func1->GetParameter(0)+func1->GetParameter(3))); text->AddText(title); text->SetFillStyle(0); text->SetBorderSize(0); text->Draw("SAME"); // correct nsecGR for the event rejected because of the number of satellites (event by event cut) nsecGR *= neventsGRandSat/neventsGR; printf("n_day = %f\nn_dayGR = %f\n",nsec*1./86400,nsecGR*1./86400); text->AddText(Form("rate = %f #pm %f per day",func1->GetParameter(0)*86400/nsecGR,func1->GetParError(0)*86400/nsecGR)); TFile *fo = new TFile("outputCERN-01-02.root","RECREATE"); h->Write(); hDeltaTheta->Write(); hDeltaPhi->Write(); hThetaRel->Write(); hDeltaThetaBack->Write(); hDeltaPhiBack->Write(); hThetaRelBack->Write(); hAngle->Write(); hModulation->Write(); hModulation2->Write(); hModulationAv->Write(); hModulationAvCorr->Write(); hSinTheta->Write(); hSinTheta2->Write(); hnsigpeak->Write(); hRunCut[0]->Write(); hRunCut[1]->Write(); fo->Close(); return nsecGR*1./86400; }
void METoptb1() { //=========Macro generated from canvas: b1/METoptb1/b1/METoptb1 //========= (Tue Nov 24 14:28:21 2015) by ROOT version6.02/05 TCanvas *b1/METoptb1 = new TCanvas("b1/METoptb1", "b1/METoptb1",0,22,700,700); b1/METoptb1->Range(-0.375,-6.019488,3.375,0.3851344); b1/METoptb1->SetFillColor(0); b1/METoptb1->SetBorderMode(0); b1/METoptb1->SetBorderSize(2); b1/METoptb1->SetLogy(); b1/METoptb1->SetFrameBorderMode(0); b1/METoptb1->SetFrameBorderMode(0); THStack *b1/METoptb1 = new THStack(); b1/METoptb1->SetName("b1/METoptb1"); b1/METoptb1->SetTitle("b1/METoptb1"); TH1F *b1/METoptb1_stack_1 = new TH1F("b1/METoptb1_stack_1","b1/METoptb1",15,0,3); b1/METoptb1_stack_1->SetMinimum(4.178057e-06); b1/METoptb1_stack_1->SetMaximum(0.5554848); b1/METoptb1_stack_1->SetDirectory(0); b1/METoptb1_stack_1->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); b1/METoptb1_stack_1->SetLineColor(ci); b1/METoptb1_stack_1->GetXaxis()->SetTitle("b1/METoptb1"); b1/METoptb1_stack_1->GetXaxis()->SetLabelFont(42); b1/METoptb1_stack_1->GetXaxis()->SetLabelSize(0.035); b1/METoptb1_stack_1->GetXaxis()->SetTitleSize(0.035); b1/METoptb1_stack_1->GetXaxis()->SetTitleFont(42); b1/METoptb1_stack_1->GetYaxis()->SetTitle("Events/pb"); b1/METoptb1_stack_1->GetYaxis()->SetLabelFont(42); b1/METoptb1_stack_1->GetYaxis()->SetLabelSize(0.035); b1/METoptb1_stack_1->GetYaxis()->SetTitleSize(0.035); b1/METoptb1_stack_1->GetYaxis()->SetTitleFont(42); b1/METoptb1_stack_1->GetZaxis()->SetLabelFont(42); b1/METoptb1_stack_1->GetZaxis()->SetLabelSize(0.035); b1/METoptb1_stack_1->GetZaxis()->SetTitleSize(0.035); b1/METoptb1_stack_1->GetZaxis()->SetTitleFont(42); b1/METoptb1->SetHistogram(b1/METoptb1_stack_1); TH1D *METoptb11 = new TH1D("METoptb11","MET/p_{T}^{lead jet}",15,0,3); METoptb11->SetBinContent(4,0.00831877); METoptb11->SetBinContent(6,0.00831877); METoptb11->SetBinError(4,0.00831877); METoptb11->SetBinError(6,0.00831877); METoptb11->SetEntries(2); ci = TColor::GetColor("#00cc00"); METoptb11->SetFillColor(ci); ci = TColor::GetColor("#00cc00"); METoptb11->SetLineColor(ci); ci = TColor::GetColor("#00cc00"); METoptb11->SetMarkerColor(ci); METoptb11->SetMarkerStyle(22); METoptb11->GetXaxis()->SetTitle("METoptb1"); METoptb11->GetXaxis()->SetLabelFont(42); METoptb11->GetXaxis()->SetLabelSize(0.035); METoptb11->GetXaxis()->SetTitleSize(0.035); METoptb11->GetXaxis()->SetTitleFont(42); METoptb11->GetYaxis()->SetTitle("Events/pb"); METoptb11->GetYaxis()->SetLabelFont(42); METoptb11->GetYaxis()->SetLabelSize(0.035); METoptb11->GetYaxis()->SetTitleSize(0.035); METoptb11->GetYaxis()->SetTitleFont(42); METoptb11->GetZaxis()->SetLabelFont(42); METoptb11->GetZaxis()->SetLabelSize(0.035); METoptb11->GetZaxis()->SetTitleSize(0.035); METoptb11->GetZaxis()->SetTitleFont(42); b1/METoptb1->Add(METoptb1,""); TH1D *METoptb12 = new TH1D("METoptb12","MET/p_{T}^{lead jet}",15,0,3); METoptb12->SetBinContent(3,0.0005979839); METoptb12->SetBinContent(4,0.009463439); METoptb12->SetBinContent(5,0.1735299); METoptb12->SetBinContent(6,0.2970475); METoptb12->SetBinContent(7,0.1010679); METoptb12->SetBinContent(8,0.0282671); METoptb12->SetBinContent(9,0.01741373); METoptb12->SetBinContent(10,0.00733517); METoptb12->SetBinContent(11,0.006803405); METoptb12->SetBinContent(12,0.001286636); METoptb12->SetBinContent(13,0.001514662); METoptb12->SetBinContent(14,0.001614657); METoptb12->SetBinContent(15,1.473949e-05); METoptb12->SetBinContent(16,0.0005588729); METoptb12->SetBinError(3,9.230618e-05); METoptb12->SetBinError(4,0.0008074678); METoptb12->SetBinError(5,0.004742746); METoptb12->SetBinError(6,0.00817298); METoptb12->SetBinError(7,0.00624437); METoptb12->SetBinError(8,0.003302222); METoptb12->SetBinError(9,0.002959757); METoptb12->SetBinError(10,0.001838302); METoptb12->SetBinError(11,0.001824161); METoptb12->SetBinError(12,0.0004068701); METoptb12->SetBinError(13,0.001005052); METoptb12->SetBinError(14,0.001013051); METoptb12->SetBinError(15,1.473949e-05); METoptb12->SetBinError(16,0.0002585905); METoptb12->SetEntries(7038); ci = TColor::GetColor("#00ffff"); METoptb12->SetFillColor(ci); ci = TColor::GetColor("#00ffff"); METoptb12->SetLineColor(ci); ci = TColor::GetColor("#00ffff"); METoptb12->SetMarkerColor(ci); METoptb12->SetMarkerStyle(20); METoptb12->GetXaxis()->SetTitle("METoptb1"); METoptb12->GetXaxis()->SetLabelFont(42); METoptb12->GetXaxis()->SetLabelSize(0.035); METoptb12->GetXaxis()->SetTitleSize(0.035); METoptb12->GetXaxis()->SetTitleFont(42); METoptb12->GetYaxis()->SetTitle("Events/pb"); METoptb12->GetYaxis()->SetLabelFont(42); METoptb12->GetYaxis()->SetLabelSize(0.035); METoptb12->GetYaxis()->SetTitleSize(0.035); METoptb12->GetYaxis()->SetTitleFont(42); METoptb12->GetZaxis()->SetLabelFont(42); METoptb12->GetZaxis()->SetLabelSize(0.035); METoptb12->GetZaxis()->SetTitleSize(0.035); METoptb12->GetZaxis()->SetTitleFont(42); b1/METoptb1->Add(METoptb1,""); TH1D *METoptb13 = new TH1D("METoptb13","MET/p_{T}^{lead jet}",15,0,3); METoptb13->SetBinContent(3,0.0001381272); METoptb13->SetBinContent(4,0.001684868); METoptb13->SetBinContent(5,0.03979096); METoptb13->SetBinContent(6,0.0814113); METoptb13->SetBinContent(7,0.02347692); METoptb13->SetBinContent(8,0.007564713); METoptb13->SetBinContent(9,0.003744978); METoptb13->SetBinContent(10,0.001842647); METoptb13->SetBinContent(11,0.001370888); METoptb13->SetBinContent(12,0.0008194819); METoptb13->SetBinContent(13,0.0002425362); METoptb13->SetBinContent(14,0.0001407686); METoptb13->SetBinContent(15,5.630742e-05); METoptb13->SetBinContent(16,0.000334906); METoptb13->SetBinError(3,1.668347e-05); METoptb13->SetBinError(4,0.000153288); METoptb13->SetBinError(5,0.0010011); METoptb13->SetBinError(6,0.001655242); METoptb13->SetBinError(7,0.001009929); METoptb13->SetBinError(8,0.0005623021); METoptb13->SetBinError(9,0.000437522); METoptb13->SetBinError(10,0.0002517068); METoptb13->SetBinError(11,0.0002866502); METoptb13->SetBinError(12,0.0001883731); METoptb13->SetBinError(13,0.0001139839); METoptb13->SetBinError(14,6.295361e-05); METoptb13->SetBinError(15,3.981536e-05); METoptb13->SetBinError(16,9.382382e-05); METoptb13->SetEntries(10014); ci = TColor::GetColor("#ffcc00"); METoptb13->SetFillColor(ci); ci = TColor::GetColor("#ffcc00"); METoptb13->SetLineColor(ci); ci = TColor::GetColor("#ffcc00"); METoptb13->SetMarkerColor(ci); METoptb13->SetMarkerStyle(21); METoptb13->GetXaxis()->SetTitle("METoptb1"); METoptb13->GetXaxis()->SetLabelFont(42); METoptb13->GetXaxis()->SetLabelSize(0.035); METoptb13->GetXaxis()->SetTitleSize(0.035); METoptb13->GetXaxis()->SetTitleFont(42); METoptb13->GetYaxis()->SetTitle("Events/pb"); METoptb13->GetYaxis()->SetLabelFont(42); METoptb13->GetYaxis()->SetLabelSize(0.035); METoptb13->GetYaxis()->SetTitleSize(0.035); METoptb13->GetYaxis()->SetTitleFont(42); METoptb13->GetZaxis()->SetLabelFont(42); METoptb13->GetZaxis()->SetLabelSize(0.035); METoptb13->GetZaxis()->SetTitleSize(0.035); METoptb13->GetZaxis()->SetTitleFont(42); b1/METoptb1->Add(METoptb1,""); TH1D *METoptb14 = new TH1D("METoptb14","MET/p_{T}^{lead jet}",15,0,3); METoptb14->SetBinContent(3,1.542458e-05); METoptb14->SetBinContent(4,0.0003084915); METoptb14->SetBinContent(5,0.003871569); METoptb14->SetBinContent(6,0.004072088); METoptb14->SetBinContent(7,0.001465335); METoptb14->SetBinContent(8,0.0006941059); METoptb14->SetBinContent(9,0.0003239161); METoptb14->SetBinContent(10,0.0002467932); METoptb14->SetBinContent(11,9.254746e-05); METoptb14->SetBinContent(12,9.254746e-05); METoptb14->SetBinContent(13,4.627373e-05); METoptb14->SetBinContent(14,1.542458e-05); METoptb14->SetBinContent(15,1.542458e-05); METoptb14->SetBinContent(16,3.084915e-05); METoptb14->SetBinError(3,1.542458e-05); METoptb14->SetBinError(4,6.89808e-05); METoptb14->SetBinError(5,0.0002443712); METoptb14->SetBinError(6,0.0002506197); METoptb14->SetBinError(7,0.0001503402); METoptb14->SetBinError(8,0.0001034712); METoptb14->SetBinError(9,7.068429e-05); METoptb14->SetBinError(10,6.16983e-05); METoptb14->SetBinError(11,3.778234e-05); METoptb14->SetBinError(12,3.778234e-05); METoptb14->SetBinError(13,2.671615e-05); METoptb14->SetBinError(14,1.542458e-05); METoptb14->SetBinError(15,1.542458e-05); METoptb14->SetBinError(16,2.181364e-05); METoptb14->SetEntries(732); ci = TColor::GetColor("#ff0000"); METoptb14->SetFillColor(ci); ci = TColor::GetColor("#ff0000"); METoptb14->SetLineColor(ci); ci = TColor::GetColor("#ff0000"); METoptb14->SetMarkerColor(ci); METoptb14->SetMarkerStyle(20); METoptb14->GetXaxis()->SetTitle("METoptb1"); METoptb14->GetXaxis()->SetLabelFont(42); METoptb14->GetXaxis()->SetLabelSize(0.035); METoptb14->GetXaxis()->SetTitleSize(0.035); METoptb14->GetXaxis()->SetTitleFont(42); METoptb14->GetYaxis()->SetTitle("Events/pb"); METoptb14->GetYaxis()->SetLabelFont(42); METoptb14->GetYaxis()->SetLabelSize(0.035); METoptb14->GetYaxis()->SetTitleSize(0.035); METoptb14->GetYaxis()->SetTitleFont(42); METoptb14->GetZaxis()->SetLabelFont(42); METoptb14->GetZaxis()->SetLabelSize(0.035); METoptb14->GetZaxis()->SetTitleSize(0.035); METoptb14->GetZaxis()->SetTitleFont(42); b1/METoptb1->Add(METoptb1,""); TH1D *METoptb15 = new TH1D("METoptb15","MET/p_{T}^{lead jet}",15,0,3); METoptb15->SetBinContent(7,3.35433e-05); METoptb15->SetBinError(7,2.371869e-05); METoptb15->SetEntries(2); ci = TColor::GetColor("#0000ff"); METoptb15->SetFillColor(ci); ci = TColor::GetColor("#0000ff"); METoptb15->SetLineColor(ci); ci = TColor::GetColor("#0000ff"); METoptb15->SetMarkerColor(ci); METoptb15->SetMarkerStyle(21); METoptb15->GetXaxis()->SetTitle("METoptb1"); METoptb15->GetXaxis()->SetLabelFont(42); METoptb15->GetXaxis()->SetLabelSize(0.035); METoptb15->GetXaxis()->SetTitleSize(0.035); METoptb15->GetXaxis()->SetTitleFont(42); METoptb15->GetYaxis()->SetTitle("Events/pb"); METoptb15->GetYaxis()->SetLabelFont(42); METoptb15->GetYaxis()->SetLabelSize(0.035); METoptb15->GetYaxis()->SetTitleSize(0.035); METoptb15->GetYaxis()->SetTitleFont(42); METoptb15->GetZaxis()->SetLabelFont(42); METoptb15->GetZaxis()->SetLabelSize(0.035); METoptb15->GetZaxis()->SetTitleSize(0.035); METoptb15->GetZaxis()->SetTitleFont(42); b1/METoptb1->Add(METoptb1,""); b1/METoptb1->Draw("nostack"); TPaveText *pt = new TPaveText(0.3362644,0.9342857,0.6637356,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("b1/METoptb1"); pt->Draw(); TLegend *leg = new TLegend(0.54023,0.639881,0.938218,0.924107,NULL,"brNDC"); leg->SetBorderSize(1); leg->SetTextSize(0.034965); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); TLegendEntry *entry=leg->AddEntry("METoptb1","b1/METoptb1_QCD_b1/","lp"); ci = TColor::GetColor("#00cc00"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#00cc00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(22); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METoptb1","b1/METoptb1_WJetsToLNu_b1/","lp"); ci = TColor::GetColor("#00ffff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#00ffff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METoptb1","b1/METoptb1_ZJetsToNuNu_b1/","lp"); ci = TColor::GetColor("#ffcc00"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#ffcc00"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METoptb1","b1/METoptb1_signal_b1/","lp"); ci = TColor::GetColor("#ff0000"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#ff0000"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(20); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("METoptb1","b1/METoptb1_ttbar_b1/","lp"); ci = TColor::GetColor("#0000ff"); entry->SetLineColor(ci); entry->SetLineStyle(1); entry->SetLineWidth(1); ci = TColor::GetColor("#0000ff"); entry->SetMarkerColor(ci); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); b1/METoptb1->Modified(); b1/METoptb1->cd(); b1/METoptb1->SetSelected(b1/METoptb1); }
void TrigEffVsPT() { //=========Macro generated from canvas: c1/c1 //========= (Mon Apr 4 17:26:08 2016) by ROOT version6.02/05 TCanvas *c1 = new TCanvas("c1", "c1",40,62,700,500); c1->Range(-21.9875,-0.1355347,197.8875,1.219812); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetFrameBorderMode(0); c1->SetFrameBorderMode(0); Double_t divide_pTNum_by_pTDen_fx3002[159] = { 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, 35.5, 36.5, 37.5, 38.5, 39.5, 40.5, 41.5, 42.5, 43.5, 44.5, 45.5, 46.5, 47.5, 48.5, 49.5, 50.5, 51.5, 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5, 59.5, 60.5, 61.5, 62.5, 63.5, 64.5, 65.5, 66.5, 67.5, 68.5, 69.5, 70.5, 71.5, 72.5, 73.5, 74.5, 75.5, 76.5, 77.5, 78.5, 79.5, 80.5, 81.5, 82.5, 83.5, 84.5, 85.5, 86.5, 87.5, 88.5, 89.5, 90.5, 91.5, 92.5, 93.5, 94.5, 95.5, 96.5, 97.5, 98.5, 99.5, 100.5, 101.5, 102.5, 103.5, 104.5, 105.5, 106.5, 107.5, 108.5, 109.5, 110.5, 111.5, 112.5, 113.5, 114.5, 115.5, 116.5, 117.5, 118.5, 119.5, 120.5, 121.5, 122.5, 123.5, 124.5, 125.5, 126.5, 127.5, 128.5, 129.5, 130.5, 131.5, 132.5, 133.5, 134.5, 135.5, 136.5, 137.5, 138.5, 139.5, 140.5, 141.5, 142.5, 143.5, 144.5, 145.5, 146.5, 147.5, 148.5, 149.5, 150.5, 151.5, 152.5, 153.5, 154.5, 155.5, 156.5, 157.5, 158.5, 159.5}; Double_t divide_pTNum_by_pTDen_fy3002[159] = { 0, 0, 0, 0, 0, 0, 0, 0, 0.03614458, 0.03225806, 0.04651163, 0.07523511, 0.06306306, 0.1108033, 0.2036199, 0.2776573, 0.2901354, 0.3161398, 0.3319027, 0.3609227, 0.4055767, 0.4454245, 0.4704684, 0.4811408, 0.5096558, 0.5446429, 0.5667125, 0.6028152, 0.5823847, 0.6171786, 0.6299342, 0.6567639, 0.6479401, 0.6519581, 0.6693333, 0.655409, 0.6604651, 0.6614665, 0.6658071, 0.6625603, 0.6586281, 0.6625135, 0.6593096, 0.6446613, 0.6546584, 0.6060415, 0.6417445, 0.6329028, 0.6351989, 0.6368305, 0.607064, 0.6214834, 0.6096718, 0.6292864, 0.610951, 0.6228814, 0.6332139, 0.6213942, 0.6441799, 0.6062323, 0.670347, 0.647351, 0.6233522, 0.6257426, 0.6515152, 0.6252874, 0.6153846, 0.6089239, 0.6155718, 0.6458924, 0.6666667, 0.6433121, 0.6644951, 0.6184211, 0.631769, 0.6104418, 0.6812227, 0.626556, 0.6306306, 0.6346154, 0.6764706, 0.6590909, 0.67, 0.6428571, 0.6354167, 0.6433121, 0.6056338, 0.6792453, 0.6453901, 0.7076923, 0.6551724, 0.6466165, 0.616, 0.5714286, 0.7196262, 0.6608696, 0.7008547, 0.6705882, 0.627451, 0.6734694, 0.7125, 0.6333333, 0.6263736, 0.6829268, 0.6363636, 0.6271186, 0.6351351, 0.6617647, 0.6153846, 0.6140351, 0.7166667, 0.6461538, 0.640625, 0.7843137, 0.625, 0.6545455, 0.6530612, 0.7358491, 0.6363636, 0.675, 0.6176471, 0.6923077, 0.7115385, 0.7272727, 0.575, 0.6956522, 0.6578947, 0.6153846, 0.6875, 0.59375, 0.7272727, 0.7307692, 0.8, 0.6315789, 0.7419355, 0.6538462, 0.6111111, 0.8666667, 0.7727273, 0.7407407, 0.5294118, 0.6666667, 0.8125, 0.7826087, 0.5555556, 0.8235294, 0.7272727, 0.8333333, 0.6521739, 0.8148148, 0.6774194, 0.7777778, 0.9166667, 0.7083333, 0.8947368, 0.7083333, 0.75, 0.8, 0.6842105}; Double_t divide_pTNum_by_pTDen_felx3002[159] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; Double_t divide_pTNum_by_pTDen_fely3002[159] = { 0, 0, 0, 0, 0, 0, 0, 0, 0.01424501, 0.01182106, 0.01307905, 0.0148767, 0.01338219, 0.0167353, 0.01955955, 0.02141473, 0.02048276, 0.01946384, 0.01826363, 0.01816129, 0.01797836, 0.01698252, 0.01639732, 0.01558938, 0.01490721, 0.01398498, 0.01338163, 0.01247164, 0.01241802, 0.0119423, 0.01164907, 0.01128324, 0.01139334, 0.01154595, 0.01122103, 0.01126201, 0.0111059, 0.01113433, 0.01105507, 0.01129719, 0.011329, 0.01136363, 0.01164698, 0.01183621, 0.0122555, 0.012637, 0.01236691, 0.01299598, 0.01292659, 0.01349144, 0.01369241, 0.0146882, 0.01485829, 0.0152839, 0.01569328, 0.01643005, 0.0174098, 0.01755728, 0.01825984, 0.01923883, 0.01972326, 0.02050663, 0.02219078, 0.0227625, 0.02356934, 0.02463147, 0.02531514, 0.02657808, 0.02547575, 0.02726831, 0.02742845, 0.0290618, 0.02909793, 0.02986797, 0.03123297, 0.03331463, 0.03375264, 0.0337219, 0.03519234, 0.03639629, 0.03604705, 0.03943298, 0.0365714, 0.03900023, 0.03799608, 0.04226438, 0.04517201, 0.04125456, 0.04479118, 0.04531704, 0.04392846, 0.04623055, 0.04830916, 0.04999481, 0.05014059, 0.04980588, 0.04828892, 0.05873718, 0.05386959, 0.05414687, 0.05946033, 0.07240254, 0.05740722, 0.05960279, 0.0685527, 0.07319036, 0.06429371, 0.06688272, 0.06944845, 0.07479622, 0.07003433, 0.06896539, 0.06967983, 0.07324028, 0.06993298, 0.07566598, 0.08088505, 0.07442052, 0.08636707, 0.09041778, 0.100413, 0.09122868, 0.07636118, 0.08354662, 0.09151811, 0.08267847, 0.093599, 0.09280913, 0.1027371, 0.1040033, 0.09928021, 0.114603, 0.1126679, 0.141036, 0.1023462, 0.1170398, 0.09719751, 0.1495371, 0.1245198, 0.1114622, 0.1472162, 0.1624937, 0.1493986, 0.1203235, 0.1437669, 0.1424027, 0.1271807, 0.1359989, 0.1258757, 0.105875, 0.1049908, 0.1411451, 0.1665196, 0.1213505, 0.1223217, 0.1213505, 0.2395668, 0.1570613, 0.140625}; Double_t divide_pTNum_by_pTDen_fehx3002[159] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5}; Double_t divide_pTNum_by_pTDen_fehy3002[159] = { 0.8413447, 0.2642294, 0.2312605, 0.08794144, 0.04985387, 0.02457175, 0.02093884, 0.01450506, 0.02096488, 0.016943, 0.01710414, 0.01781691, 0.01629701, 0.0190684, 0.02097788, 0.02242814, 0.02133294, 0.02010187, 0.01876347, 0.01855285, 0.01822619, 0.0171068, 0.01645935, 0.01562511, 0.01489053, 0.01391675, 0.01328748, 0.01234266, 0.01231689, 0.01180577, 0.01150319, 0.01111294, 0.01123125, 0.01137424, 0.01103603, 0.01109408, 0.01093612, 0.01096241, 0.01087998, 0.01111885, 0.01115489, 0.01118329, 0.0114622, 0.01166602, 0.01205842, 0.01250016, 0.01218575, 0.01281047, 0.01273941, 0.0132851, 0.01353055, 0.01447495, 0.01466328, 0.01503685, 0.01547347, 0.01616115, 0.01708031, 0.01725526, 0.01786425, 0.01892658, 0.01916373, 0.01999845, 0.02170594, 0.02224226, 0.02288234, 0.02402777, 0.02473333, 0.02597728, 0.02488574, 0.02639727, 0.02639977, 0.02809714, 0.02796386, 0.0290446, 0.03022461, 0.03237231, 0.03206236, 0.03260465, 0.03393726, 0.03501296, 0.03419326, 0.03748845, 0.03474937, 0.03731486, 0.03648476, 0.04029473, 0.04356378, 0.03881819, 0.0425576, 0.04183103, 0.04161147, 0.04383745, 0.04629295, 0.04869026, 0.04562121, 0.04674988, 0.04452976, 0.05429461, 0.05113218, 0.0502514, 0.05354061, 0.06741836, 0.05435089, 0.0546516, 0.06393837, 0.06835608, 0.06023675, 0.06156721, 0.0654862, 0.07030353, 0.06186905, 0.06393668, 0.06476413, 0.06036601, 0.06556793, 0.06932692, 0.07379811, 0.0642642, 0.07930672, 0.08036346, 0.09243358, 0.07985686, 0.0671006, 0.07165313, 0.08724141, 0.07295313, 0.08404097, 0.08603711, 0.08908149, 0.0972359, 0.08315645, 0.09350665, 0.08352346, 0.1245183, 0.08395298, 0.1031432, 0.09010505, 0.08563225, 0.09442371, 0.09027391, 0.1430906, 0.1355138, 0.100212, 0.09048927, 0.1364236, 0.09442668, 0.1023895, 0.08927179, 0.1102307, 0.077549, 0.09164621, 0.1031167, 0.06904031, 0.1007064, 0.06768965, 0.1007064, 0.1596593, 0.1067507, 0.1173389}; TGraphAsymmErrors *grae = new TGraphAsymmErrors(159,divide_pTNum_by_pTDen_fx3002,divide_pTNum_by_pTDen_fy3002,divide_pTNum_by_pTDen_felx3002,divide_pTNum_by_pTDen_fehx3002,divide_pTNum_by_pTDen_fely3002,divide_pTNum_by_pTDen_fehy3002); grae->SetName("divide_pTNum_by_pTDen"); grae->SetTitle("pTNum"); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); grae->SetLineColor(ci); TH1F *Graph_divide_pTNum_by_pTDen3002 = new TH1F("Graph_divide_pTNum_by_pTDen3002","pTNum",159,0,175.9); Graph_divide_pTNum_by_pTDen3002->SetMinimum(0); Graph_divide_pTNum_by_pTDen3002->SetMaximum(1.084278); Graph_divide_pTNum_by_pTDen3002->SetDirectory(0); Graph_divide_pTNum_by_pTDen3002->SetStats(0); ci = TColor::GetColor("#000099"); Graph_divide_pTNum_by_pTDen3002->SetLineColor(ci); Graph_divide_pTNum_by_pTDen3002->GetXaxis()->SetTitle("GEN p_{T} [GeV]"); Graph_divide_pTNum_by_pTDen3002->GetXaxis()->SetLabelFont(42); Graph_divide_pTNum_by_pTDen3002->GetXaxis()->SetLabelSize(0.035); Graph_divide_pTNum_by_pTDen3002->GetXaxis()->SetTitleSize(0.035); Graph_divide_pTNum_by_pTDen3002->GetXaxis()->SetTitleFont(42); Graph_divide_pTNum_by_pTDen3002->GetYaxis()->SetTitle("HLT Efficiency"); Graph_divide_pTNum_by_pTDen3002->GetYaxis()->SetLabelFont(42); Graph_divide_pTNum_by_pTDen3002->GetYaxis()->SetLabelSize(0.035); Graph_divide_pTNum_by_pTDen3002->GetYaxis()->SetTitleSize(0.035); Graph_divide_pTNum_by_pTDen3002->GetYaxis()->SetTitleFont(42); Graph_divide_pTNum_by_pTDen3002->GetZaxis()->SetLabelFont(42); Graph_divide_pTNum_by_pTDen3002->GetZaxis()->SetLabelSize(0.035); Graph_divide_pTNum_by_pTDen3002->GetZaxis()->SetTitleSize(0.035); Graph_divide_pTNum_by_pTDen3002->GetZaxis()->SetTitleFont(42); grae->SetHistogram(Graph_divide_pTNum_by_pTDen3002); grae->Draw("alp"); TPaveText *pt = new TPaveText(0.431092,0.9339831,0.568908,0.995,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetFillColor(0); pt->SetFillStyle(0); pt->SetTextFont(42); TText *AText = pt->AddText("pTNum"); pt->Draw(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
TCanvas* DrawComparison(TH1D* prediction, TH1D* selection, TString Title, TString LumiTitle, TString xTitle, bool isData) { double MinX = selection->GetXaxis()->GetXmin(); double MaxX = selection->GetXaxis()->GetXmax(); double MaxY = selection->GetMaximum(); double YRangeMax = MaxY; TString titlePrediction; TString titleSelection; TString RatioTitle; if( isData ){ titlePrediction = "Data"; titleSelection = "MC"; RatioTitle = "(Data-MC)/MC"; } else { titlePrediction = "Data-driven Pred. from MC"; titleSelection = "MC Expectation"; RatioTitle = "(Pred-MC)/MC"; } //static Int_t c_LightBrown = TColor::GetColor( "#D9D9CC" ); static Int_t c_LightGray = TColor::GetColor( "#DDDDDD" ); prediction->SetAxisRange(MinX, MaxX, "X"); prediction->GetYaxis()->SetRangeUser(0.005, YRangeMax); prediction->SetMarkerStyle(20); prediction->SetMarkerSize(0.9); prediction->SetMarkerColor(kBlack); prediction->SetXTitle(xTitle); prediction->SetYTitle("Events"); selection->SetAxisRange(MinX, MaxX, "X"); selection->GetYaxis()->SetRangeUser(0.05, YRangeMax); // selection->SetFillColor(c_LightBrown); selection->SetFillColor(c_LightGray); selection->SetTitle(""); selection->SetXTitle(xTitle); selection->SetYTitle("Events"); TCanvas *c = new TCanvas("ca", "Comparison and ratio of two histos", 700, 700); TPad *pad1 = new TPad("pad1a", "pad1a", 0, 0.35, 1, 1); //pad1->SetLogy(); pad1->SetBottomMargin(0); pad1->Draw(); pad1->cd(); selection->DrawCopy("hist"); prediction->Draw("same"); selection->SetFillColor(kAzure-3); selection->SetFillStyle(3354); selection->DrawCopy("e2same"); selection->SetFillStyle(1001); // selection->SetFillColor(c_LightBrown); selection->SetFillColor(c_LightGray); TLegend* leg1 = new TLegend(0.48, 0.63, 0.95, 0.83); leg1->SetFillStyle(0); leg1->SetLineStyle(1); leg1->SetTextFont(42); leg1->SetTextSize(0.04); leg1->AddEntry(selection, titleSelection, "lf"); leg1->AddEntry(prediction, titlePrediction, "lep"); leg1->Draw("same"); TPaveText* pt = new TPaveText(0.11, 0.98, 0.95, 0.86, "NDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(12); pt->SetTextSize(0.045); pt->AddText(Title); pt->AddText(LumiTitle); pt->Draw(); c->cd(); TPad *pad2 = new TPad("pad2a", "pad2a", 0, 0, 1, 0.35); pad2->SetTopMargin(0); pad2->Draw(); pad2->cd(); TH1D* r = new TH1D(*selection); r->SetTitle(""); r->SetLabelSize(0.08, "XYZ"); r->SetLabelOffset(0.01, "XYZ"); r->SetTitleSize(0.09, "XYZ"); r->SetTitleOffset(0.65, "Y"); r->SetTickLength(0.05); r->SetYTitle(RatioTitle); r->SetStats(0); r->SetMarkerStyle(20); r->SetMarkerSize(0.9); r->SetMarkerColor(kBlack); r->Reset(); r->Add(prediction, 1); r->Add(selection, -1); r->Divide(selection); r->SetMaximum(1.2); r->SetMinimum(-1.2); r->Draw("ep"); TLine l; l.DrawLine(MinX, 0., MaxX, 0.); c->cd(); return c; }