#include #include #include #include #include #include void nt2() { TFile *f1 = TFile::Open("tt_final_new.root"); TH2D *h1_orig; gDirectory->GetObject("third_tight_mu_pt_eta", h1_orig); TH2D *h2_orig; gDirectory->GetObject("third_loose_mu_pt_eta", h2_orig); TH2D *nt2_orig; gDirectory->GetObject("nt2_pt_eta", nt2_orig); #if 0 /* 0 or 1 */ double bins_x[] = {10., 20., 40., 70., 100.}; double bins_y[] = {0., 1., 1.5, 2.5}; int nxf = 0, nyf = 0; // use / draw all bins int nxl = 0, nyl = 0; // use / draw all bins #elif 0 /* 0 or 1 */ double bins_x[] = {0., 10., 20., 40., 70., 100., 300.}; double bins_y[] = {-3., 0., 1., 1.5, 2.5, 3.}; int nxf = 2, nyf = 2; // the first bin to use / draw int nxl = (sizeof(bins_x) / sizeof(double) - 2); // the last bin to use / draw int nyl = (sizeof(bins_y) / sizeof(double) - 2); // the last bin to use / draw #else /* 0 or 1 */ double bins_x[] = { h1_orig->GetXaxis()->GetXmin(), h1_orig->GetXaxis()->GetBinLowEdge(h1_orig->GetXaxis()->FindFixBin(10.)), h1_orig->GetXaxis()->GetBinLowEdge(h1_orig->GetXaxis()->FindFixBin(20.)), h1_orig->GetXaxis()->GetBinLowEdge(h1_orig->GetXaxis()->FindFixBin(40.)), h1_orig->GetXaxis()->GetBinLowEdge(h1_orig->GetXaxis()->FindFixBin(70.)), h1_orig->GetXaxis()->GetBinLowEdge(h1_orig->GetXaxis()->FindFixBin(100.) + 1), h1_orig->GetXaxis()->GetXmax() }; double bins_y[] = { h1_orig->GetYaxis()->GetXmin(), h1_orig->GetYaxis()->GetBinLowEdge(h1_orig->GetYaxis()->FindFixBin(0.)), h1_orig->GetYaxis()->GetBinLowEdge(h1_orig->GetYaxis()->FindFixBin(1.)), h1_orig->GetYaxis()->GetBinLowEdge(h1_orig->GetYaxis()->FindFixBin(1.5)), h1_orig->GetYaxis()->GetBinLowEdge(h1_orig->GetYaxis()->FindFixBin(2.5) + 1), h1_orig->GetYaxis()->GetXmax() }; int nxf = 2, nyf = 2; // the first bin to use / draw int nxl = (sizeof(bins_x) / sizeof(double) - 2); // the last bin to use / draw int nyl = (sizeof(bins_y) / sizeof(double) - 2); // the last bin to use / draw #endif /* 0 or 1 */ TH2D *h1 = new TH2D("h1", "tight muons", (sizeof(bins_x) / sizeof(double) - 1), bins_x, (sizeof(bins_y) / sizeof(double) - 1), bins_y); h1->Sumw2(kTRUE); h1->Add(h1_orig); TH2D *h2 = new TH2D("h2", "loose muons", (sizeof(bins_x) / sizeof(double) - 1), bins_x, (sizeof(bins_y) / sizeof(double) - 1), bins_y); h2->Sumw2(kTRUE); h2->Add(h2_orig); TH2D *nt2 = new TH2D("nt2", "b-jets", (sizeof(bins_x) / sizeof(double) - 1), bins_x, (sizeof(bins_y) / sizeof(double) - 1), bins_y); nt2->Sumw2(kTRUE); nt2->Add(nt2_orig); #if 0 /* 0 or 1 */ h1->GetXaxis()->SetRange(nxf, nxl); h1->GetYaxis()->SetRange(nyf, nyl); h2->GetXaxis()->SetRange(nxf, nxl); h2->GetYaxis()->SetRange(nyf, nyl); nt2->GetXaxis()->SetRange(nxf, nxl); nt2->GetYaxis()->SetRange(nyf, nyl); #endif /* 0 or 1 */ TH2D *f = ((TH2D *)(h1->Clone())); f->SetNameTitle("f", "tight/loose"); f->Divide(h2); double mul = 1.0; #if 0 /* 0 or 1 */ // use all entries if (h2->GetEntries() != 0.0) mul = h1->GetEntries() / h2->GetEntries(); #else /* 0 or 1 */ // use bins in the set bin ranges // if (h2->GetEffectiveEntries() != 0.0) mul = h1->GetEffectiveEntries() / h2->GetEffectiveEntries(); if (h2->Integral() != 0.0) mul = h1->Integral() / h2->Integral(); #endif /* 0 or 1 */ if (mul != 1.0) mul /= (1.0 - mul); TH2D *Nt3 = ((TH2D *)(nt2->Clone())); Nt3->SetNameTitle("Nt3", "normalized b-jets"); Nt3->Scale(mul); gStyle->SetOptStat("neMRuoI"); TCanvas *c1 = new TCanvas("c1", "c1", 800, 600); c1->Divide(2, 2); c1->cd(1); f->Draw("colz text e"); c1->cd(2); h1->Draw("colz text e"); c1->cd(3); nt2->Draw("colz text e"); c1->cd(4); Nt3->Draw("colz text e"); }