std::string Path::Encode(fs::path const& path) const { // Find the shortest encoding of path made relative to each token std::string shortest = path.string(); size_t length = boost::distance(path); for (size_t i = 0; i < paths.size(); ++i) { if (paths[i].empty()) continue; const auto p = MakeRelative(path, tokens[i]); const size_t d = boost::distance(p); if (d < length) { length = d; shortest = (tokens[i]/p).string(); } } return shortest; }
fs::path Path::MakeRelative(fs::path const& path, std::string const& token) const { int idx = find_token(token.c_str(), token.size()); if (idx == -1) throw agi::InternalError("Bad token: " + token); return MakeRelative(path, paths[idx]); }
void PlotGluonFusionHiggsShapeSystematics() { TFile *file = new TFile("/data/blue/sixie/Thesis/Limits/MVAIDIsoCombinedDetIsoSameSigWP/130/hww130_of_0j.input.root","READ"); TH1F *DefaultShape; TH1F *UpShape; TH1F *DownShape; TCanvas *cv ; TLegend *legend; //************************* //ggH signal - DF 0Jet //************************* DefaultShape = (TH1F*)file->Get("histo_ggH"); UpShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingUp"); DownShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); //Make relative histograms UpShapeRelative = MakeRelative(UpShape,DefaultShape); DownShapeRelative = MakeRelative(DownShape,DefaultShape); cv = new TCanvas("cv","cv",800,600); pad1 = new TPad("pad1","pad1", 0,0.2,1,1); pad1->SetBottomMargin(0.125); pad1->Draw(); pad1->cd(); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Systematics Shape (Up)", "L"); legend->AddEntry(DownShape, "Systematics Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Number of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.1); DefaultShape->GetXaxis()->SetTitleOffset(1.05); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,13); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->cd(); pad2 = new TPad("pad2","pad2", 0,0,1,0.2); pad1->SetTopMargin(0.01); pad2->Draw(); pad2->cd(); UpShapeRelative->GetYaxis()->SetTitle("% Difference"); UpShapeRelative->GetYaxis()->SetTitleSize(0.15); UpShapeRelative->GetYaxis()->SetTitleOffset(0.3); UpShapeRelative->GetYaxis()->SetRangeUser(-3,3); UpShapeRelative->GetYaxis()->SetLabelSize(0.15); UpShapeRelative->GetXaxis()->SetLabelSize(0.0); UpShapeRelative->SetLineColor(kBlue); UpShapeRelative->SetMarkerColor(kBlue); UpShapeRelative->Draw("hist"); DownShapeRelative->SetLineColor(kRed); DownShapeRelative->SetMarkerColor(kRed); DownShapeRelative->Draw("hist,same"); cv->SaveAs("ggHShapeVariation_ggH_0Jet_DF.png"); cv->SaveAs("ggHShapeVariation_ggH_0Jet_DF.eps"); //************************* //ggH signal - SF 0Jet //************************* file = new TFile("/data/blue/sixie/Thesis/Limits/MVAIDIsoCombinedDetIsoSameSigWP/130/hww130_sf_0j.input.root","READ"); DefaultShape = (TH1F*)file->Get("histo_ggH"); UpShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingUp"); DownShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingDown"); assert(DefaultShape); assert(UpShape); assert(DownShape); //Make relative histograms UpShapeRelative = MakeRelative(UpShape,DefaultShape); DownShapeRelative = MakeRelative(DownShape,DefaultShape); cv = new TCanvas("cv","cv",800,600); pad1 = new TPad("pad1","pad1", 0,0.2,1,1); pad1->SetBottomMargin(0.125); pad1->Draw(); pad1->cd(); legend = new TLegend(0.2, 0.6, 0.5, 0.9); legend->SetTextSize(0.04); legend->SetBorderSize(0); legend->SetFillColor(kWhite); legend->AddEntry(DefaultShape, "Default Shape", "L"); legend->AddEntry(UpShape, "Systematics Shape (Up)", "L"); legend->AddEntry(DownShape, "Systematics Shape (Down)", "L"); DefaultShape->SetLineColor(kBlack); UpShape->SetLineColor(kBlue); DownShape->SetLineColor(kRed); DefaultShape->SetLineWidth(2); UpShape->SetLineWidth(2); DownShape->SetLineWidth(2); DefaultShape->SetTitle(""); DefaultShape->GetXaxis()->SetTitle("MVA discriminator"); DefaultShape->GetYaxis()->SetTitle("Number of Events"); DefaultShape->GetYaxis()->SetTitleOffset(1.1); DefaultShape->GetXaxis()->SetTitleOffset(1.05); DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0); DefaultShape->GetYaxis()->SetRangeUser(0.0,5.5); DefaultShape->Draw("hist"); UpShape->Draw("same,hist"); DownShape->Draw("same,hist"); legend->Draw(); cv->cd(); pad2 = new TPad("pad2","pad2", 0,0,1,0.2); pad1->SetTopMargin(0.01); pad2->Draw(); pad2->cd(); UpShapeRelative->GetYaxis()->SetTitle("% Difference"); UpShapeRelative->GetYaxis()->SetTitleSize(0.15); UpShapeRelative->GetYaxis()->SetTitleOffset(0.3); UpShapeRelative->GetYaxis()->SetRangeUser(-3,3); UpShapeRelative->GetYaxis()->SetLabelSize(0.15); UpShapeRelative->GetXaxis()->SetLabelSize(0.0); UpShapeRelative->SetLineColor(kBlue); UpShapeRelative->SetMarkerColor(kBlue); UpShapeRelative->Draw("hist"); DownShapeRelative->SetLineColor(kRed); DownShapeRelative->SetMarkerColor(kRed); DownShapeRelative->Draw("hist,same"); cv->SaveAs("ggHShapeVariation_ggH_0Jet_SF.png"); cv->SaveAs("ggHShapeVariation_ggH_0Jet_SF.eps"); }