Hi developers,
I am applying different cuts on 2D histogram and divide it by another 2D histogram without cuts. But I am getting the same results of all the three histograms. plz help
macro is
void ratio_cuts()
{
TFile *f = new TFile("May26_2.root");
TTree *t2 = (TTree*)f->Get("demo/AnaTree");
// TH2F *h2 = new TH2F("h2","hist_vetoMu",100,0,300,100,-3,3);
// TH2F *h1 = new TH2F("h1","hist_SelMu",100,0,300,100,-3,3);
// TH2F *h = new TH2F("h3","hist_ratio",100,0,300,100,-3,3);
// h2->GetXaxis()->SetTitle("VetoMu_pt");
// h2->GetYaxis()->SetTitle("VetoMu_eta");
// h1->GetXaxis()->SetTitle("SelMu_pt");
// h1->GetYaxis()->SetTitle("SelMu_eta");
t2->Draw("selNonIsoMu_eta:selNonIsoMu_pt >> h2","","goff");
t2->Draw("selNonIsoMu_eta:selNonIsoMu_pt >> h1","","goff");
TCanvas *c1 = new TCanvas("c1","c1",800,600) ;
c1->Divide(2,2);
c1->cd(1);
{
float selNonIsoMu_pt, selNonIsoMu_eta;
int selNonIsoMu_idTight, selNonIsoMu_ismuon, selNonIsoMu_iso, selNonIsoMu;
for(int m=0; m<selNonIsoMu;m++)
{
if(selNonIsoMu_pt[m]>20) continue;
if(selNonIsoMu_eta[m]<2.5) continue;
if(selNonIsoMu_idTight[m]==1) continue;
if(selNonIsoMu_ismuon[m]==1) continue;
if(selNonIsoMu_iso[m]<0.12) continue;
}
double bins_x[] = {10, 20, 40, 70, 100};
double bins_y[] = {0, 1, 1.5, 2.5};
TH2F *h1 = new TH2F("tight mu", "tight muons;tight_Pt_{T}^{} [GeV/c];#eta",
(sizeof(bins_x) / sizeof(double) - 1), bins_x,
(sizeof(bins_y) / sizeof(double) - 1), bins_y);
for (int i = 1; i <= h1->GetNbinsX(); i++)
for (int j = 1; j <= h1->GetNbinsY(); j++)
h1->SetBinContent(i, j, (i * i + j * j * j));
h1->Draw("colz texte");
}
h1->Draw("colz texte");
c1->cd(2);
{
double bins_x[] = {10, 20, 40, 70, 100};
double bins_y[] = {0, 1, 1.5, 2.5};
TH2F *h2 = new TH2F("loose mu", "loose muons;loose_Pt_{T}^{} [GeV/c];#eta",
(sizeof(bins_x) / sizeof(double) - 1), bins_x,
(sizeof(bins_y) / sizeof(double) - 1), bins_y);
for (int i = 1; i <= h2->GetNbinsX(); i++)
for (int j = 1; j <= h2->GetNbinsY(); j++)
h2->SetBinContent(i, j, (i * i + j * j * j));
h2->Draw("colz texte");
}
h2->Draw("colz texte");
h = (TH2F*)h1->Clone();
// h->GetXaxis()->SetTitle("pt ");
// h->GetYaxis()->SetTitle("eta ");
// h->SetTitle("fake_h1/h2_without cuts");
h->Divide(h2);
c1->cd(3);
h->Draw("colz texte");
{
double bins_x[] = {10, 20, 40, 70, 100};
double bins_y[] = {0, 1, 1.5, 2.5};
TH2F *h = new TH2F("ratio", "tight/loose;Pt_{T}^{} [GeV/c];#eta",
(sizeof(bins_x) / sizeof(double) - 1), bins_x,
(sizeof(bins_y) / sizeof(double) - 1), bins_y);
for (int i = 1; i <= h->GetNbinsX(); i++)
for (int j = 1; j <= h->GetNbinsY(); j++)
h->SetBinContent(i, j, (i * i + j * j * j));
h->Draw("colz texte");
}
c1->SaveAs("ratio.png");
}
source file path is /afs/cern.ch/user/n/nmajeed/public