TH1D *hTemp(TString ifile, TString dirname, TString hname) { TH1D *h=readHist(dirname+hname,ifile,2); TH1D *h_temp=h->Clone(); h_temp->Reset(); Double_t con, err; Int_t nB=h->GetNbinsX(); for (Int_t i=0; i<nB; i++) { con=h->IntegralAndError(i,nB+1,err); h_temp->SetBinContent(i,con); h_temp->SetBinError(i,err); } return h_temp; }
void compare_samples(TString sample="Singlemu", TString mode="rate") { TString ifile1, ifile2, data; if (sample=="Minbias") { ifile1="l1Ntuple_ZeroBias_RunD_oldPMTs_HF-.root"; ifile2="l1Ntuple_ZeroBias_RunD_upgradedPMTs_HF-.root"; data="MinBias Run2012D"; } else if (sample=="Singlemu") { // ifile1="l1Ntuple_IsoMu_RunC_1509.root"; ifile1="l1Ntuple_SingleMu_RunD_oldPMTs.root"; ifile2="l1Ntuple_SingleMu_RunD_upgradedPMTs.root"; data="singleMu 2012D"; } TString dirname="l1ExtraJets/"; TH1D *ptJet_e, *ptJet_c, *ptJet_l; TH1D *ptJetHF_e, *ptJetHF_c, *ptJetHF_l; // Compute cummulative histograms if (mode=="rate") { // // Central + Tau jets ptJet_e=hTemp(ifile1,dirname,"ptJet_early"); ptJet_c=hTemp(ifile1,dirname,"ptJet_central"); ptJet_l=hTemp(ifile1,dirname,"ptJet_late"); // HFjets ptJetHF_e=hTemp(ifile1,dirname,"ptJetHF_early"); ptJetHF_c=hTemp(ifile1,dirname,"ptJetHF_central"); ptJetHF_l=hTemp(ifile1,dirname,"ptJetHF_late"); ptJetHF2_e=hTemp(ifile2,dirname,"ptJetHF_early"); ptJetHF2_c=hTemp(ifile2,dirname,"ptJetHF_central"); ptJetHF2_l=hTemp(ifile2,dirname,"ptJetHF_late"); } else if (mode=="norate") { ptJet_e=readHist(dirname+"ptJet_early",ifile1,4); ptJet_c=readHist(dirname+"ptJet_central",ifile1,4); ptJet_l=readHist(dirname+"ptJet_late",ifile1,4); ptJetHF_e=readHist(dirname+"ptJetHF_early",ifile1,4); ptJetHF_c=readHist(dirname+"ptJetHF_central",ifile1,4); ptJetHF_l=readHist(dirname+"ptJetHF_late",ifile1,4); ptJetHF2_e=readHist(dirname+"ptJetHF_early",ifile2,4); ptJetHF2_c=readHist(dirname+"ptJetHF_central",ifile2,4); ptJetHF2_l=readHist(dirname+"ptJetHF_late",ifile2,4); } TH1D *etaJet_e=readHist(dirname+"etaJet_early",ifile1,2); TH1D *etaJet_c=readHist(dirname+"etaJet_central",ifile1,2); TH1D *etaJet_l=readHist(dirname+"etaJet_late",ifile1,2); TH1D *etaJetHF_e=readHist(dirname+"etaJetHF_early",ifile1,2); TH1D *etaJetHF_c=readHist(dirname+"etaJetHF_central",ifile1,2); TH1D *etaJetHF_l=readHist(dirname+"etaJetHF_late",ifile1,2); TH1D *phiJet_e=readHist(dirname+"phiJet_early",ifile1,0); TH1D *phiJet_c=readHist(dirname+"phiJet_central",ifile1,0); TH1D *phiJet_l=readHist(dirname+"phiJet_late",ifile1,0); setTDRStyle(); // Central+Tau Jets TCanvas *c1=getaCanvas("c1"); c1->Divide(1,2); TPad *pad1 = new TPad("pad1", "The pad with the function",0.05,0.4,0.95,0.95); pad1->Draw(); // pad1->Range(-112.6742,-73.17708,1143.438,551.3021); pad1->SetFillColor(0); pad1->SetBorderMode(0); pad1->SetBorderSize(2); // pad1->SetGridx(); // pad1->SetGridy(); pad1->SetLeftMargin(0.1271439); pad1->SetRightMargin(0.07307979); pad1->SetTopMargin(0.08215179); pad1->SetBottomMargin(0.117181); pad1->SetFrameBorderMode(0); pad1->SetFrameBorderMode(0); TPad *pad2 = new TPad("pad2", "The pad with the histogram",0.05,0.05,0.95,0.4); pad2->Draw(); // pad2->Range(-153.3652,-2.142584,1185.427,5.367464); pad2->SetFillColor(0); pad2->SetBorderMode(0); pad2->SetBorderSize(2); pad2->SetGridx(); pad2->SetGridy(); pad2->SetLeftMargin(0.1215511); pad2->SetRightMargin(0.07867263); pad2->SetTopMargin(0.04892967); pad2->SetBottomMargin(0.3521407); pad2->SetFrameBorderMode(0); pad2->SetFrameBorderMode(0); pad1->cd(); gPad->SetLogy(); // gPad->SetGridx(); gPad->SetGridy(); TLegend *leg = legend(); leg->SetHeader(data); // leg->AddEntry(ptJet_e,"BX=-1","LF"); leg->AddEntry(ptJet_c,"BX=0","LF"); leg->AddEntry(ptJet_e,"BX=-1","LF"); // leg->AddEntry(ptJet_l,"BX=+1","LF"); ptJet_c->Draw("EHIST"); ptJet_c->SetLineColor(1); ptJet_c->SetLineWidth(2); ptJet_c->GetXaxis()->SetRangeUser(0.,260.); ptJet_c->GetYaxis()->SetRangeUser(1.01,100000000.); if (mode=="rate") { ptJet_c->SetTitle(";L1Jet E_{T} Threshold (GeV);a.u."); } else { ptJet_c->SetTitle(";L1Jet E_{T} (GeV);a.u."); } ptJet_e->Draw("EHISTSAMES"); ptJet_e->SetLineColor(1); ptJet_e->SetLineColor(2); ptJet_e->SetLineStyle(1);ptJet_e->SetLineWidth(2); // ptJet_l->Draw("EHISTSAMES"); // ptJet_l->SetLineColor(1); ptJet_l->SetLineColor(4); // ptJet_l->SetLineStyle(3); leg->Draw("SAME"); // TPad *p2=getaPad_dn("p2"); p2->Draw(); // p2->cd(); //c1->cd(2); pad2->cd(); gPad->SetGridx(); gPad->SetGridy(); TH1D *r1_e = ptJet_e->Clone(); r1_e->Divide(ptJet_c); TH1D *r1_l = ptJet_l->Clone(); r1_l->Divide(ptJet_c); TLegend *leg = legend(); leg->SetHeader(data); leg->AddEntry(r1_e,"BX=-1","LF"); //leg->AddEntry(r1_l,"BX=+1","LF"); r1_e->Draw("EHIST");r1_e->SetLineColor(4); // r1_l->Draw("EHISTSAME"); r1_l->SetLineColor(4); r1_e->GetYaxis()->SetRangeUser(-0.01,1.0); r1_e->GetXaxis()->SetRangeUser(0.,260.); r1_e->SetLineWidth(2); r1_l->SetLineWidth(2); if (mode=="rate") { r1_e->SetTitle(";L1Jet E_{T} Threshold (GeV);Ratio"); } else { r1_e->SetTitle(";L1Jet E_{T} (GeV);Ratio"); } // r1_e->SetTitle(";L1Jet E_{T} (GeV);ratio"); r1_e->GetXaxis()->SetLabelSize(.1); r1_e->GetYaxis()->SetLabelSize(.1); r1_e->GetXaxis()->SetTitleSize(.09); r1_e->GetYaxis()->SetTitleSize(.095); r1_e->GetXaxis()->SetTitleOffset(1.0); r1_e->GetYaxis()->SetTitleOffset(0.6); //leg->Draw("SAME"); //return; // Eta Jets TCanvas *c2=getaCanvas("c2"); c2->Divide(1,2); // TPad *p1=getaPad_up("p1"); p1->Draw(); // p1->cd(); TPad *pad3 = new TPad("pad3", "The pad with the function",0.05,0.4,0.95,0.95); pad3->Draw(); // pad3->Range(-112.6742,-73.17708,1143.438,551.3021); pad3->SetFillColor(0); pad3->SetBorderMode(0); pad3->SetBorderSize(2); // pad3->SetGridx(); // pad3->SetGridy(); pad3->SetLeftMargin(0.1271439); pad3->SetRightMargin(0.07307979); pad3->SetTopMargin(0.08215179); pad3->SetBottomMargin(0.117181); pad3->SetFrameBorderMode(0); pad3->SetFrameBorderMode(0); TPad *pad4 = new TPad("pad4", "The pad with the histogram",0.05,0.1,0.95,0.4); pad4->Draw(); // pad4->Range(-153.3652,-2.142584,1185.427,5.367464); pad4->SetFillColor(0); pad4->SetBorderMode(0); pad4->SetBorderSize(2); pad4->SetGridx(); pad4->SetGridy(); pad4->SetLeftMargin(0.1215511); pad4->SetRightMargin(0.07867263); pad4->SetTopMargin(0.04892967); pad4->SetBottomMargin(0.3521407); pad4->SetFrameBorderMode(0); pad4->SetFrameBorderMode(0); pad3->cd(); // c2->cd(1); // gPad->SetGridx(); gPad->SetGridy(); TLegend *leg = legend(); leg->SetHeader(data); // leg->AddEntry(etaJet_e,"BX=-1","LF"); leg->AddEntry(etaJet_c,"BX=0","LF"); // leg->AddEntry(etaJet_l,"BX=+1","LF"); leg->AddEntry(etaJet_e,"BX=-1","LF"); etaJet_c->Draw("EHIST"); etaJet_c->SetLineColor(1); etaJet_c->SetLineWidth(2); etaJet_c->SetTitle(";L1Jet #eta;a.u."); // etaJet_c->GetYaxis()->SetRangeUser(1.01,100000000.); etaJet_e->Draw("EHISTSAMES"); etaJet_e->SetLineColor(1); etaJet_e->SetLineColor(2); etaJet_e->SetLineStyle(1);etaJet_e->SetLineWidth(2); // etaJet_l->Draw("EHISTSAMES"); // etaJet_l->SetLineColor(1); etaJet_l->SetLineColor(4); etaJet_l->SetLineStyle(3); leg->Draw("SAME"); pad4->cd(); // c2->cd(2); gPad->SetGridx(); gPad->SetGridy(); TH1D *r2_e = etaJet_e->Clone(); r2_e->Divide(etaJet_c); TH1D *r2_l = etaJet_l->Clone(); r2_l->Divide(etaJet_c); TLegend *leg = legend(); leg->SetHeader(data); leg->AddEntry(r2_e,"BX=-1","LF"); // leg->AddEntry(etaJet_c,"BX=0","LF"); // leg->AddEntry(r2_l,"BX=+1","LF"); r2_e->Draw("HIST");r2_e->SetLineColor(4);r2_e->SetLineWidth(2); // r2_l->Draw("HISTSAME"); r2_l->SetLineColor(4); r2_e->GetYaxis()->SetRangeUser(-0.01,1.0); //r2_e->GetXaxis()->SetRangeUser(0.,300.); r2_e->SetLineWidth(2); r2_l->SetLineWidth(2); r2_e->SetTitle(";L1Jet #eta;Ratio "); r2_e->GetXaxis()->SetTitleSize(.09); r2_e->GetYaxis()->SetTitleSize(.095); r2_e->GetXaxis()->SetTitleOffset(1.0); r2_e->GetYaxis()->SetTitleOffset(0.6); r2_e->GetXaxis()->SetLabelSize(.1); r2_e->GetYaxis()->SetLabelSize(.1); // leg->Draw("SAME"); // HF jets TCanvas *c3=getaCanvas("c3"); c3->Divide(1,2); TPad *pad5 = new TPad("pad5", "The pad with the function",0.05,0.4,0.95,0.95); pad5->Draw(); // pad5->Range(-112.6742,-73.17708,1143.438,551.3021); pad5->SetFillColor(0); pad5->SetBorderMode(0); pad5->SetBorderSize(2); // pad5->SetGridx(); // pad5->SetGridy(); pad5->SetLeftMargin(0.1271439); pad5->SetRightMargin(0.07307979); pad5->SetTopMargin(0.08215179); pad5->SetBottomMargin(0.117181); pad5->SetFrameBorderMode(0); pad5->SetFrameBorderMode(0); TPad *pad6 = new TPad("pad6", "The pad with the histogram",0.05,0.1,0.95,0.4); pad6->Draw(); // pad6->Range(-153.3652,-2.142584,1185.427,5.367464); pad6->SetFillColor(0); pad6->SetBorderMode(0); pad6->SetBorderSize(2); pad6->SetGridx(); pad6->SetGridy(); pad6->SetLeftMargin(0.1215511); pad6->SetRightMargin(0.07867263); pad6->SetTopMargin(0.04892967); pad6->SetBottomMargin(0.3521407); pad6->SetFrameBorderMode(0); pad6->SetFrameBorderMode(0); pad5->cd(); // c3->cd(1); gPad->SetLogy(); // gPad->SetGridx(); gPad->SetGridy(); TLegend *leg = legend(); leg->SetHeader(data); // leg->AddEntry(ptJetHF_e,"BX=-1","LF"); leg->AddEntry(ptJetHF_c,"old PMTs region: BX=0 Jet","LF"); leg->AddEntry(ptJetHF2_c,"upgraded PMTs region: BX=0 Jet","LF"); leg->AddEntry(ptJetHF_e,"old PMTs region: BX=-1 Jet","LF"); leg->AddEntry(ptJetHF2_e,"upgraded PMTs region: BX=-1 Jet","LF"); ptJetHF_c->Rebin(2); ptJetHF2_c->Rebin(2); ptJetHF_e->Rebin(2); ptJetHF2_e->Rebin(2); ptJetHF_c->Draw("EHIST"); ptJetHF2_c->Draw("EHISTSAME"); ptJetHF2_c->SetLineColor(1); //ptJetHF2_c->SetLineWidth(2); // ptJetHF2_c->SetFillStyle(3002); ptJetHF2_c->SetFillColor(1); ptJetHF_c->SetLineColor(1); ptJetHF_c->SetLineWidth(2); ptJetHF_c->GetXaxis()->SetRangeUser(0.,260.); ptJetHF_c->GetYaxis()->SetRangeUser(1.01,100000000.); // ptJetHF_c->SetTitle(";L1 FwdJet E_{T} (GeV);a.u."); if (mode=="rate") { ptJetHF_c->SetTitle(";L1 FwdJet E_{T} Threshold (GeV);a.u."); } else { ptJetHF_c->SetTitle(";L1 FwdJet E_{T} (GeV);a.u."); } ptJetHF_e->Draw("EHISTSAME"); ptJetHF2_e->Draw("EHISTSAME"); ptJetHF2_e->SetLineColor(2);// ptJetHF2_e->SetLineWidth(2); // ptJetHF2_e->SetFillStyle(3002);ptJetHF2_e->SetFillColor(2); ptJetHF_e->SetLineColor(2); ptJetHF_e->SetLineStyle(1); ptJetHF_e->SetLineWidth(2); // ptJetHF_l->Draw("EHISTSAMES"); // ptJetHF_l->SetLineColor(1); ptJetHF_l->SetLineColor(4); // ptJetHF_l->SetLineStyle(3); leg->Draw("SAME"); // TPad *p2=getaPad_dn("p2"); p2->Draw(); // p2->cd(); // c3->cd(2); pad6->cd(); gPad->SetGridx(); gPad->SetGridy(); TH1D *r1HF_e = ptJetHF_e->Clone(); r1HF_e->Divide(ptJetHF_c); TH1D *r1HF2_e = ptJetHF2_e->Clone(); r1HF2_e->Divide(ptJetHF2_c); TLegend *leg = legend(); leg->AddEntry(r1HF_e,"old PMTs region","LF"); leg->AddEntry(r1HF2_e,"upgraded PMTs region","LF"); // leg->AddEntry(ptJetHF_c,"BX=0","LF"); // leg->AddEntry(r1HF_l,"BX=+1","LF"); r1HF_e->Draw("EHIST");r1HF_e->SetLineColor(4); // r1HF_l->Draw("EHISTSAME"); r1HF_l->SetLineColor(4); r1HF2_e->Draw("EHISTSAME"); //r1HF2_e->SetLineColor(kBlack-6); //r1HF2_e->SetFillColor(4); r1HF2_e->SetLineColor(4); r1HF2_e->SetLineWidth(0.5); r1HF_e->GetYaxis()->SetRangeUser(-0.01,1.0); r1HF_e->GetXaxis()->SetRangeUser(0.,260.); r1HF_e->SetLineWidth(2); //r1HF2_e->SetLineWidth(1); // r1HF_e->SetTitle(";L1 FwdJet E_{T} (GeV);ratio"); if (mode=="rate") { r1HF_e->SetTitle(";L1 FwdJet E_{T} Threshold (GeV);Ratio"); } else { r1HF_e->SetTitle(";L1 FwdJet E_{T} (GeV);Ratio"); } r1HF_e->GetXaxis()->SetTitleSize(.09); r1HF_e->GetYaxis()->SetTitleSize(.095); r1HF_e->GetXaxis()->SetTitleOffset(1.0); r1HF_e->GetYaxis()->SetTitleOffset(0.6); r1HF_e->GetXaxis()->SetLabelSize(.1); r1HF_e->GetYaxis()->SetLabelSize(.1); leg->Draw("SAME"); TCanvas *cf=getanotherCanvas("cf"); gPad->SetGridx(); gPad->SetGridy(); TLegend *leg = legend(); leg->AddEntry(r1HF_e,"old PMTs region","LF"); leg->AddEntry(r1HF2_e,"upgraded PMTs region","LF"); r1HF_e->Draw("EHIST");r1HF_e->SetLineColor(4); // r1HF2_e->SetLineColor(1); r1HF2_e->Draw("EHISTSAME"); //r1HF2_e->SetLineColor(kBlack-6); r1HF2_e->SetLineWidth(2); r1HF2_e->SetLineStyle(2); r1HF_e->GetXaxis()->SetRangeUser(0.,170.); r1HF_e->GetYaxis()->SetRangeUser(0.001,0.3); r1HF_e->GetXaxis()->SetTitleSize(.05); r1HF_e->GetYaxis()->SetTitleSize(.05); r1HF_e->GetXaxis()->SetTitleOffset(1.0); r1HF_e->GetYaxis()->SetTitleOffset(0.6); r1HF_e->GetXaxis()->SetLabelSize(.05); r1HF_e->GetYaxis()->SetLabelSize(.05); leg->Draw("SAME"); }
void make_weights(TString tag="sel", TString var="_qt", Bool_t asym=true) { TString ifile="plotter_2015_11_12.root"; TString dydir, dydir2; // DY+jets dydir="Ztoll_M-50"; dydir2="Ztoll_M-10to50"; TString gdir, gdir2, gdir3, gdir4, gdir5; // G+jets gdir="GJets_HT-40to100"; gdir2="GJets_HT-100to200"; gdir3="GJets_HT-200to400"; gdir4="GJets_HT-400to600"; gdir5="GJets_HT-600toInf"; Bool_t bfit=false; double xmin,xmax; double ymin, ymax; ymin=0.5; ymax=1000000.; if (var=="_qt") { // bfit=true; xmin=45.01; xmax=1000.01; } else if ( (var=="_met") || var=="_mt") { xmin=1.; xmax=1000.0; } setTDRStyle(); // TString cat1,cat2,hcat[2]; // cat1="eq0jets"; hcat[1]="geq1jets"; hcat[2]="vbf"; TString hcat[3]={"eq0jets","geq1jets","vbf"}; TString cat="ee"; Int_t rbin=5; TH1F *h_zpt_ee_1=readHist(cat+hcat[0]+var,ifile,dydir,rbin); //h_zpt_ee->Scale(dyweight); TH1F *h_zpt_ee_2=readHist(cat+hcat[1]+var,ifile,dydir,rbin); TH1F *h_zpt_ee_3=readHist(cat+hcat[2]+var,ifile,dydir,rbin); h_zpt_ee_1->SetFillColor(0); h_zpt_ee_2->SetFillColor(0); h_zpt_ee_3->SetFillColor(0); // Adddy2 // TH1F *h2_zpt_ee_1=readHist(cat+hcat[0]+var,ifile,dydir2,rbin); //h_zpt_ee->Scale(dyweight); // TH1F *h2_zpt_ee_2=readHist(cat+hcat[1]+var,ifile,dydir2,rbin); // TH1F *h2_zpt_ee_3=readHist(cat+hcat[2]+var,ifile,dydir2,rbin); // h_zpt_ee_1->Add(h2_zpt_ee_1); // h_zpt_ee_2->Add(h2_zpt_ee_2); // h_zpt_ee_3->Add(h2_zpt_ee_3); TCanvas *c=getanotherCanvas("c"); c->Divide(3,1); c->cd(1); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[0]); h_zpt_ee_1->Draw("EHIST"); if (bfit) h_zpt_ee_1->Fit("pol2","FR+","EHISTSAME",60.,500.); h_zpt_ee_1->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_ee_1->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); c->cd(2); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[1]); h_zpt_ee_2->Draw("EHIST"); if (bfit) h_zpt_ee_2->Fit("pol2","FR+","EHIST",60.,500.); h_zpt_ee_2->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_ee_2->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); c->cd(3); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[2]); h_zpt_ee_3->Draw("EHIST"); if (bfit) h_zpt_ee_3->Fit("pol2","FR+","",60.,500.); h_zpt_ee_3->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_ee_3->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); // DIMUONS cat="mumu"; TH1F *h_zpt_mm_1=readHist(cat+hcat[0]+var,ifile,dydir,rbin);//h_zpt_mm->Scale(dyweight); TH1F *h_zpt_mm_2=readHist(cat+hcat[1]+var,ifile,dydir,rbin);//h_zpt_mm_2->Scale(dyweight); TH1F *h_zpt_mm_3=readHist(cat+hcat[2]+var,ifile,dydir,rbin);//h_zpt_mm_3->Scale(dyweight); h_zpt_mm_1->SetFillColor(0); h_zpt_mm_2->SetFillColor(0); h_zpt_mm_3->SetFillColor(0); // Adddy2 // TH1F *h2_zpt_mm_1=readHist(cat+hcat[0]+var,ifile,dydir2,rbin); //h_zpt_mm->Scale(dyweight); // TH1F *h2_zpt_mm_2=readHist(cat+hcat[1]+var,ifile,dydir2,rbin); // TH1F *h2_zpt_mm_3=readHist(cat+hcat[2]+var,ifile,dydir2,rbin); // h_zpt_mm_1->Add(h2_zpt_mm_1); // h_zpt_mm_2->Add(h2_zpt_mm_2); // h_zpt_mm_3->Add(h2_zpt_mm_3); TCanvas *cm=getanotherCanvas("cm"); cm->Divide(3,1); cm->cd(1); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[0]); h_zpt_mm_1->Draw("EHIST"); h_zpt_mm_1->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_mm_1->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cm->cd(2); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[1]); h_zpt_mm_2->Draw("EHIST"); h_zpt_mm_2->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_mm_2->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cm->cd(3); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[2]); h_zpt_mm_3->Draw("EHIST"); h_zpt_mm_3->GetXaxis()->SetRangeUser(xmin,xmax); h_zpt_mm_3->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); // Photon+jet weight //double gweight= ((224012.*20.*1000.)/12365798.); cat="ee"; // var="_phopt"; // Photon + Jet // std::cout << "=0jets: " << cat+hcat[0]+var << std::endl; // std::cout << ">=2: " << cat+hcat[1]+var << std::endl; // std::cout << "VBF: " << cat+hcat[2]+var << std::endl; TH1F *h_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir,rbin);// h_zpt_gj->Scale(gweight);//h_zpt_gj->Sumw2(); TH1F *h_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir,rbin); //h_zpt_gj_2->Scale(gweight);//h_zpt_gj_2->Sumw2(); TH1F *h_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir,rbin);// h_zpt_gj_3->Scale(gweight);//h_zpt_gj_3->Sumw2(); h_zpt_gj_1->SetFillColor(0); h_zpt_gj_2->SetFillColor(0); h_zpt_gj_3->SetFillColor(0); TH1F *h2_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir2,rbin); TH1F *h2_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir2,rbin); TH1F *h2_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir2,rbin); h2_zpt_gj_1->SetFillColor(0); h2_zpt_gj_2->SetFillColor(0); h2_zpt_gj_3->SetFillColor(0); TH1F *h3_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir3,rbin); TH1F *h3_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir3,rbin); TH1F *h3_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir3,rbin); h3_zpt_gj_1->SetFillColor(0); h3_zpt_gj_2->SetFillColor(0); h3_zpt_gj_3->SetFillColor(0); TH1F *h4_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir4,rbin); TH1F *h4_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir4,rbin); TH1F *h4_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir4,rbin); h4_zpt_gj_1->SetFillColor(0); h4_zpt_gj_2->SetFillColor(0); h4_zpt_gj_3->SetFillColor(0); TH1F *h5_zpt_gj_1=readHist(cat+hcat[0]+var,ifile,gdir5,rbin); TH1F *h5_zpt_gj_2=readHist(cat+hcat[1]+var,ifile,gdir5,rbin); TH1F *h5_zpt_gj_3=readHist(cat+hcat[2]+var,ifile,gdir5,rbin); h5_zpt_gj_1->SetFillColor(0); h5_zpt_gj_2->SetFillColor(0); h5_zpt_gj_3->SetFillColor(0); h_zpt_gj_1->Add(h2_zpt_gj_1); h_zpt_gj_1->Add(h3_zpt_gj_1); h_zpt_gj_1->Add(h4_zpt_gj_1); h_zpt_gj_1->Add(h5_zpt_gj_1); h_zpt_gj_2->Add(h2_zpt_gj_2); h_zpt_gj_2->Add(h3_zpt_gj_2); h_zpt_gj_2->Add(h4_zpt_gj_2); h_zpt_gj_2->Add(h5_zpt_gj_2); h_zpt_gj_3->Add(h2_zpt_gj_3); h_zpt_gj_3->Add(h3_zpt_gj_3); h_zpt_gj_3->Add(h4_zpt_gj_3); h_zpt_gj_3->Add(h5_zpt_gj_3); cat="g+jet"; TCanvas *cg=getanotherCanvas("cg"); cg->Divide(3,1); cg->cd(1); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[0]); // fermiFunction->SetParameters(params); h_zpt_gj_1->Draw("EHIST"); h_zpt_gj_1->GetXaxis()->SetRangeUser(xmin,xmax); //h_zpt_gj->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cg->cd(2); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[1]); //fermiFunction->SetParameters(params); h_zpt_gj_2->Draw("EHIST"); h_zpt_gj_2->GetXaxis()->SetRangeUser(xmin,xmax); //h_zpt_gj_2->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); cg->cd(3); gPad->SetLogy(); gPad->SetLogx(); TLegend *leg=legend(); leg->SetHeader(cat+" : "+hcat[2]); // fermiFunction->SetParameters(params); h_zpt_gj_3->Draw("EHIST"); h_zpt_gj_3->GetXaxis()->SetRangeUser(xmin,xmax); //h_zpt_gj_3->GetYaxis()->SetRangeUser(ymin,ymax); leg->Draw("SAME"); // Superimpose all rbin=1; Double_t xbins[27] = {0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80, 90, 100, 125, 150, 175, 200, 250, 300, 400, 500, 1000,1500}; // hee1->Rebin(26,"nhee1",xbins); hee2->Rebin(26,"nhee2",xbins); hee3->Rebin(26,"nhee3",xbins); // hmm1->Rebin(26,"nhmm1",xbins); hmm2->Rebin(26,"nhmm2",xbins); hmm3->Rebin(26,"nhmm3",xbins); TCanvas *call=getanotherCanvas("call"); call->Divide(3,1); // TH1F *h_ee1=h_zpt_ee_1->Clone(); h_ee1->Rebin(rbin); // TH1F *h_mm1=h_zpt_mm_1->Clone(); h_mm1->Rebin(rbin); // TH1F *h_gj1=h_zpt_gj_1->Clone(); h_gj1->Rebin(rbin); if (asym) { h_zpt_ee_1->Rebin(26,"h_ee1",xbins); h_zpt_mm_1->Rebin(26,"h_mm1",xbins); h_zpt_gj_1->Rebin(26,"h_gj1",xbins); } else { TH1F *h_ee1=h_zpt_ee_1->Clone(); h_ee1->Rebin(rbin); TH1F *h_mm1=h_zpt_mm_1->Clone(); h_mm1->Rebin(rbin); TH1F *h_gj1=h_zpt_gj_1->Clone(); h_gj1->Rebin(rbin); } // h_ee1->Scale(1./h_ee1->Integral()); // h_mm1->Scale(1./h_mm1->Integral()); // h_gj1->Scale(1./h_gj1->Integral()); if (asym) { h_zpt_ee_2->Rebin(26,"h_ee2",xbins); h_zpt_mm_2->Rebin(26,"h_mm2",xbins); h_zpt_gj_2->Rebin(26,"h_gj2",xbins); } else { TH1F *h_ee2=h_zpt_ee_2->Clone(); h_ee2->Rebin(rbin); TH1F *h_mm2=h_zpt_mm_2->Clone(); h_mm2->Rebin(rbin); TH1F *h_gj2=h_zpt_gj_2->Clone(); h_gj2->Rebin(rbin); } // h_ee2->Scale(1./h_ee2->Integral()); // h_mm2->Scale(1./h_mm2->Integral()); // h_gj2->Scale(1./h_gj2->Integral()); if (asym) { h_zpt_ee_3->Rebin(26,"h_ee3",xbins); h_zpt_mm_3->Rebin(26,"h_mm3",xbins); h_zpt_gj_3->Rebin(26,"h_gj3",xbins); } else { TH1F *h_ee3=h_zpt_ee_3->Clone(); h_ee3->Rebin(rbin); TH1F *h_mm3=h_zpt_mm_3->Clone(); h_mm3->Rebin(rbin); TH1F *h_gj3=h_zpt_gj_3->Clone(); h_gj3->Rebin(rbin); } // h_ee3->Scale(1./h_ee3->Integral()); // h_mm3->Scale(1./h_mm3->Integral()); // h_gj3->Scale(1./h_gj3->Integral()); call->cd(1); gPad->SetLogy(); TLegend *leg=legend(); leg->SetHeader("=0 jets"); leg->AddEntry(h_ee1,"ee","LP"); leg->AddEntry(h_mm1,"#mu#mu","LP"); leg->AddEntry(h_gj1,"#gamma+jet","LP"); h_ee1->Draw("ehist"); h_ee1->GetXaxis()->SetRangeUser(xmin,xmax); h_ee1->SetLineColor(kBlue); h_ee1->SetMarkerColor(kBlue); h_ee1->SetLineWidth(2); h_ee1->SetMarkerStyle(20); h_ee1->SetMarkerSize(0.3); h_mm1->Draw("ehistsame"); h_mm1->SetLineColor(kBlue-6); h_mm1->SetMarkerColor(kBlue-6); h_mm1->SetLineWidth(2); h_mm1->SetMarkerStyle(22); h_mm1->SetMarkerSize(0.3); h_gj1->Draw("ehistsame"); h_gj1->SetLineColor(kRed+1); h_gj1->SetMarkerColor(kRed+1); h_gj1->SetLineWidth(2); h_gj1->SetMarkerStyle(29); h_gj1->SetMarkerSize(0.3); leg->Draw("SAME"); call->cd(2); gPad->SetLogy(); TLegend *leg=legend(); leg->SetHeader(">= 1jets"); leg->AddEntry(h_ee2,"ee","LP"); leg->AddEntry(h_mm2,"#mu#mu","LP"); leg->AddEntry(h_gj2,"#gamma+jet","LP"); h_ee2->Draw("ehist"); h_ee2->GetXaxis()->SetRangeUser(xmin,xmax); h_ee2->SetLineColor(kBlue); h_ee2->SetMarkerColor(kBlue); h_ee2->SetLineWidth(2); h_ee2->SetMarkerStyle(20); h_ee2->SetMarkerSize(0.3); h_mm2->Draw("ehistsame"); h_mm2->SetLineColor(kBlue-6); h_mm2->SetMarkerColor(kBlue-6); h_mm2->SetLineWidth(2); h_mm2->SetMarkerStyle(22); h_mm2->SetMarkerSize(0.3); h_gj2->Draw("ehistsame"); h_gj2->SetLineColor(kRed+1); h_gj2->SetMarkerColor(kRed+1); h_gj2->SetLineWidth(2); h_gj2->SetMarkerStyle(29); h_gj2->SetMarkerSize(0.3); leg->Draw("SAME"); call->cd(3); gPad->SetLogy(); TLegend *leg=legend(); leg->SetHeader("VBF"); leg->AddEntry(h_ee3,"ee","LP"); leg->AddEntry(h_mm3,"#mu#mu","LP"); leg->AddEntry(h_gj3,"#gamma+jet","LP"); h_ee3->Draw("ehist"); h_ee3->GetXaxis()->SetRangeUser(xmin,10000000.); h_ee3->SetLineColor(kBlue); h_ee3->SetMarkerColor(kBlue); h_ee3->SetLineWidth(2); h_ee3->SetMarkerStyle(20); h_ee3->SetMarkerSize(0.3); h_mm3->Draw("ehistsame"); h_mm3->SetLineColor(kBlue-6); h_mm3->SetMarkerColor(kBlue-6); h_mm3->SetLineWidth(2); h_mm3->SetMarkerStyle(22); h_mm3->SetMarkerSize(0.3); h_gj3->Draw("ehistsame"); h_gj3->SetLineColor(kRed+1); h_gj3->SetMarkerColor(kRed+1); h_gj3->SetLineWidth(2); h_gj3->SetMarkerStyle(29); h_gj3->SetMarkerSize(0.3); leg->Draw("SAME"); // return; // REDRAW in one CANVAS TCanvas *call1 = new TCanvas("call1"); call1->SetWindowSize(500,600); call1->cd(); //distributions TPad *t1 = new TPad("p1","p1",0,0.3,1.0,1.0); t1->Draw(); t1->cd(); t1->SetLogy(); t1->SetLogx(); t1->SetTopMargin(0.08); t1->SetBottomMargin(0); t1->SetRightMargin(0.05); h_ee1->SetTitle("ee"); h_ee1->GetYaxis()->SetLabelSize(0.06); h_ee1->GetYaxis()->SetTitleSize(0.05); h_ee1->GetYaxis()->SetTitleOffset(0.9); h_ee1->GetYaxis()->SetLabelSize(0.05); h_ee1->GetXaxis()->SetRangeUser(25.01,1000.01); h_ee1->GetYaxis()->SetTitle("Events / 100 pb^{-1}"); // h_ee1->SetLineColor(1); // h_ee1->SetMarkerColor(1); // h_ee1->SetMarkerStyle(1); // h_ee1->SetFillStyle(3001); // h_ee1->SetFillColor(5); h_ee1->Draw("ehistsame"); h_mm1->SetTitle("#mu#mu"); h_mm1->Draw("ehistsame"); // h_mm1->SetMarkerColor(9); // h_mm1->SetMarkerStyle(20); // h_mm1->SetMarkerSize(0.8); h_gj1->SetTitle("#gamma + jets"); h_gj1->Draw("ehistsame"); // h_gj1->SetFillColor(kRed+1); h_gj1->SetFillStyle(3001); TPaveText *pave = new TPaveText(0.7,0.85,0.95,0.9,"brNDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->AddText("=0 jets"); pave->Draw(); TLegend *leg=new TLegend(0.6,0.6,0.9,0.8); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextAlign(12); leg->SetTextSize(0.05); leg->SetNColumns(2); leg->AddEntry(h_ee1,"ee","L"); leg->AddEntry(h_mm1,"#mu#mu","L"); leg->AddEntry(h_gj1,"#gamma+jets","L"); leg->Draw("same"); //closure call1->cd(); TPad *t2 = new TPad("p2","p2",0,0.0,1.0,0.3); t2->SetTopMargin(0); t2->SetBottomMargin(0.25); t2->SetRightMargin(0.05); t2->Draw(); t2->cd(); t2->SetLogx(); t2->SetGridx(); t2->SetGridy(); leg = new TLegend(0.6,0.6,0.9,0.8,"","brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(3001); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.11); leg->SetTextAlign(12); TH1D *hee1=h_ee1->Clone(); hee1->Divide(h_gj1); TH1D *hmm1=h_mm1->Clone(); hmm1->Divide(h_gj1); hee1->Draw("e"); hee1->SetLineColor(kBlue); hee1->SetMarkerColor(kBlue);hee1->SetLineWidth(2); hmm1->Draw("esame"); hmm1->SetLineColor(kBlue-6); hmm1->SetMarkerColor(kBlue-6);hmm1->SetLineWidth(2); hee1->GetYaxis()->SetRangeUser(-0.1,0.5); // hee1->GetYaxis()->SetRangeUser(-0.2,1.74); hee1->GetXaxis()->SetTitle(hee1->GetXaxis()->GetTitle()); hee1->GetXaxis()->SetLabelSize(0.12); hee1->GetXaxis()->SetTitleSize(0.14); hee1->GetXaxis()->SetTitleOffset(0.8); hee1->GetYaxis()->SetLabelSize(0.12); hee1->GetYaxis()->SetNdivisions(5); hee1->GetYaxis()->SetTitleSize(0.12); //gr->GetYaxis()->SetTitle("Pred. rel. bias"); hee1->GetYaxis()->SetTitle("Weight"); hee1->GetYaxis()->SetTitleOffset(0.3); hee1->GetXaxis()->SetRangeUser(25.01,1000.01); leg->AddEntry(hee1,"ee","L"); leg->AddEntry(hmm1,"#mu#mu","L"); leg->Draw(); leg->SetNColumns(4); // 2 TCanvas *call2 = new TCanvas("call2"); call2->SetWindowSize(500,600); call2->cd(); //distributions TPad *t1 = new TPad("p1","p1",0,0.3,1.0,1.0); t1->Draw(); t1->cd(); t1->SetLogy(); t1->SetLogx(); t1->SetTopMargin(0.08); t1->SetBottomMargin(0); t1->SetRightMargin(0.05); h_ee2->SetTitle("ee"); h_ee2->GetYaxis()->SetLabelSize(0.06); h_ee2->GetYaxis()->SetTitleSize(0.05); h_ee2->GetYaxis()->SetTitleOffset(0.9); h_ee2->GetYaxis()->SetLabelSize(0.05); h_ee2->GetXaxis()->SetRangeUser(25.01,1000.01); h_ee2->GetYaxis()->SetTitle("Events / 100 pb^{-1}"); h_ee2->Draw("ehistsame"); h_mm2->SetTitle("#mu#mu"); h_mm2->Draw("ehistsame"); // h_mm2->SetMarkerColor(9); // h_mm2->SetMarkerStyle(20); // h_mm2->SetMarkerSize(0.8); h_gj2->SetTitle("#gamma + jets"); h_gj2->Draw("ehistsame"); TPaveText *pave = new TPaveText(0.7,0.85,0.95,0.9,"brNDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->AddText(">=1 jet"); pave->Draw(); TLegend *leg=new TLegend(0.6,0.6,0.9,0.8); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextAlign(12); leg->SetTextSize(0.05); leg->SetNColumns(2); leg->AddEntry(h_ee2,"ee","L"); leg->AddEntry(h_mm2,"#mu#mu","L"); leg->AddEntry(h_gj1,"#gamma+jets","L"); leg->Draw("same"); //closure call2->cd(); TPad *t2 = new TPad("p2","p2",0,0.0,1.0,0.3); t2->SetTopMargin(0); t2->SetBottomMargin(0.25); t2->SetRightMargin(0.05); t2->Draw(); t2->cd(); t2->SetLogx(); t2->SetGridx(); t2->SetGridy(); leg = new TLegend(0.6,0.6,0.9,0.8,"","brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(3001); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.11); leg->SetTextAlign(12); TH1D *hee2=h_ee2->Clone(); hee2->Divide(h_gj2); TH1D *hmm2=h_mm2->Clone(); hmm2->Divide(h_gj2); hee2->Draw("e"); hee2->SetLineColor(kBlue); hee2->SetMarkerColor(kBlue);hee2->SetLineWidth(2); hmm2->Draw("esame"); hmm2->SetLineColor(kBlue-6); hmm2->SetMarkerColor(kBlue-6);hmm2->SetLineWidth(2); hee2->GetYaxis()->SetRangeUser(-0.2,0.2); // hee2->GetYaxis()->SetRangeUser(-0.2,1.74); hee2->GetXaxis()->SetTitle(hee2->GetXaxis()->GetTitle()); hee2->GetXaxis()->SetLabelSize(0.12); hee2->GetXaxis()->SetTitleSize(0.14); hee2->GetXaxis()->SetTitleOffset(0.8); hee2->GetYaxis()->SetLabelSize(0.12); hee2->GetYaxis()->SetNdivisions(5); hee2->GetYaxis()->SetTitleSize(0.12); //gr->GetYaxis()->SetTitle("Pred. rel. bias"); hee2->GetYaxis()->SetTitle("Weight"); hee2->GetYaxis()->SetTitleOffset(0.3); hee2->GetXaxis()->SetRangeUser(25.01,1000.01); leg->AddEntry(hee2,"ee","L"); leg->AddEntry(hmm2,"#mu#mu","L"); leg->Draw(); leg->SetNColumns(4); // 3 TCanvas *call3 = new TCanvas("call3"); call3->SetWindowSize(500,600); call3->cd(); //distributions TPad *t1 = new TPad("p1","p1",0,0.3,1.0,1.0); t1->Draw(); t1->cd(); t1->SetLogy(); t1->SetLogx(); t1->SetTopMargin(0.08); t1->SetBottomMargin(0); t1->SetRightMargin(0.05); h_ee3->SetTitle("ee"); h_ee3->GetYaxis()->SetLabelSize(0.06); h_ee3->GetYaxis()->SetTitleSize(0.05); h_ee3->GetYaxis()->SetTitleOffset(0.9); h_ee3->GetYaxis()->SetLabelSize(0.05); h_ee3->GetXaxis()->SetRangeUser(25.01,1000.01); h_ee3->GetYaxis()->SetTitle("Events / 100 pb^{-1}"); h_ee3->Draw("ehistsame"); h_mm3->SetTitle("#mu#mu"); h_mm3->Draw("ehistsame"); // h_mm3->SetMarkerColor(9); // h_mm3->SetMarkerStyle(20); // h_mm3->SetMarkerSize(0.8); h_gj3->SetTitle("#gamma + jets"); h_gj3->Draw("ehistsame"); TPaveText *pave = new TPaveText(0.7,0.85,0.95,0.9,"brNDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->SetTextSize(0.05); pave->SetTextColor(kBlue); pave->AddText("VBF"); pave->Draw(); TLegend *leg=new TLegend(0.6,0.6,0.9,0.8); leg->SetBorderSize(0); leg->SetFillStyle(0); leg->SetTextFont(42); leg->SetTextAlign(12); leg->SetTextSize(0.05); leg->SetNColumns(2); leg->AddEntry(h_ee3,"ee","L"); leg->AddEntry(h_mm3,"#mu#mu","L"); leg->AddEntry(h_gj1,"#gamma+jets","L"); leg->Draw("same"); //closure call3->cd(); TPad *t2 = new TPad("p2","p2",0,0.0,1.0,0.3); t2->SetTopMargin(0); t2->SetBottomMargin(0.25); t2->SetRightMargin(0.05); t2->Draw(); t2->cd(); t2->SetLogx(); t2->SetGridx(); t2->SetGridy(); leg = new TLegend(0.6,0.6,0.9,0.8,"","brNDC"); leg->SetBorderSize(0); leg->SetFillStyle(3001); leg->SetFillColor(0); leg->SetTextFont(42); leg->SetTextSize(0.11); leg->SetTextAlign(12); TH1D *hee3=h_ee3->Clone(); hee3->Divide(h_gj3); TH1D *hmm3=h_mm3->Clone(); hmm3->Divide(h_gj3); hee3->Draw("e"); hee3->SetLineColor(kBlue); hee3->SetMarkerColor(kBlue);hee3->SetLineWidth(2); hmm3->Draw("esame"); hmm3->SetLineColor(kBlue-6); hmm3->SetMarkerColor(kBlue-6);hmm3->SetLineWidth(2); hee3->GetYaxis()->SetRangeUser(-0.4,0.2); // hee3->GetYaxis()->SetRangeUser(-0.2,1.74); hee3->GetXaxis()->SetTitle(hee3->GetXaxis()->GetTitle()); hee3->GetXaxis()->SetLabelSize(0.12); hee3->GetXaxis()->SetTitleSize(0.14); hee3->GetXaxis()->SetTitleOffset(0.8); hee3->GetYaxis()->SetLabelSize(0.12); hee3->GetYaxis()->SetNdivisions(5); hee3->GetYaxis()->SetTitleSize(0.12); //gr->GetYaxis()->SetTitle("Pred. rel. bias"); hee3->GetYaxis()->SetTitle("Weight"); hee3->GetYaxis()->SetTitleOffset(0.3); hee3->GetXaxis()->SetRangeUser(25.01,1000.01); leg->AddEntry(hee3,"ee","L"); leg->AddEntry(hmm3,"#mu#mu","L"); leg->Draw(); leg->SetNColumns(4); // return; // printWeight(hee1); // printWeight(hee1); // return; // TH1F *n_hee1=hee1->Clone(); // gDirectory->ls(); return; // TFile *outfile=new TFile("photonWeights_Spring15_ght.root","recreate"); // TDirectory *dir=outfile->mkdir("photonWgt_graphs",""); dir->cd(); // Graphs TCanvas *gff=getanotherCanvas("gff"); gff->Divide(3,1); gff->cd(1); gPad->SetGridy(); gPad->SetGridx(); // GRaph1 TGraphErrors *gr_e1=new TGraphErrors(hee1); gr_e1->SetName("eeeq0jets_qt_datafitwgts"); TGraphErrors *gr_m1=new TGraphErrors(hmm1); gr_m1->SetName("mumueq0jets_qt_datafitwgts"); TLegend *leg=legend(); leg->SetHeader("0jet category"); leg->AddEntry(gr_e1,"ee","LP"); leg->AddEntry(gr_m1,"#mu#mu","LP"); gr_e1->Draw("AP"); gr_e1->SetMarkerSize(0.1); gr_e1->SetMarkerColor(4); gr_m1->Draw("P"); gr_m1->SetMarkerSize(0.1); gr_m1->SetMarkerColor(2); leg->Draw("SAME"); gff->cd(2); gPad->SetGridy(); gPad->SetGridx(); // GRaph1 TGraphErrors *gr_e2=new TGraphErrors(hee2);gr_e2->SetName("eegeq1jets_qt_datafitwgts"); TGraphErrors *gr_m2=new TGraphErrors(hmm2);gr_m2->SetName("mumugeq1jets_qt_datafitwgts"); TLegend *leg=legend(); leg->SetHeader(">=1jet category"); leg->AddEntry(gr_e2,"ee","LP"); leg->AddEntry(gr_m2,"#mu#mu","LP"); gr_e2->Draw("AP"); gr_e2->SetMarkerSize(0.2); gr_e2->SetMarkerColor(4); gr_m2->Draw("P"); gr_m2->SetMarkerSize(0.2); gr_m2->SetMarkerColor(2); leg->Draw("SAME"); gff->cd(3); gPad->SetGridy(); gPad->SetGridx(); // GRaph1 TGraphErrors *gr_e3=new TGraphErrors(hee3);gr_e3->SetName("eevbf_qt_datafitwgts"); TGraphErrors *gr_m3=new TGraphErrors(hmm3);gr_m3->SetName("mumuvbf_qt_datafitwgts"); TLegend *leg=legend(); leg->SetHeader("VBF category"); leg->AddEntry(gr_e3,"ee","LP"); leg->AddEntry(gr_m3,"#mu#mu","LP"); gr_e3->Draw("AP"); gr_e3->SetMarkerSize(0.2); gr_e3->SetMarkerColor(4); gr_m3->Draw("P"); gr_m3->SetMarkerSize(0.2); gr_m3->SetMarkerColor(2); leg->Draw("SAME"); TFile *outfile=new TFile("photonWeights_Spring15.root","recreate"); gr_e1->Write(); gr_m1->Write(); gr_e2->Write(); gr_m2->Write(); gr_e3->Write(); gr_m3->Write(); outfile->Write(); outfile->Close(); }
// ----------------------------------------------------------------------------- // TCanvas* aDrawBkgdPlots( TString path, TString canvas_name, TString name, TString dirmame, int rebin, bool norm, bool log, TDirectory* file ) { // SetSomeStyles(); // Create legend TLegend* legend = new TLegend( 0.75, 0.65, 0.92, 0.92, NULL, "brNDC" ); legend->SetFillColor(0); legend->SetLineColor(0); // Create canvas TCanvas* aCanvas = getaCanvas( canvas_name, file, log ); // Create histograms TH1D* qcd = readHist( path, name, "IC5Calo_QCD_Pythia_Merged.root", dirmame, rebin ); TH1D* tt_jets = readHist( path, name, "IC5Calo_TTbarJets.root", dirmame, rebin ); TH1D* w_jets = readHist( path, name, "IC5Calo_WJets.root", dirmame, rebin ); TH1D* z_inv = readHist( path, name, "IC5Calo_Zinv.root", dirmame, rebin ); TH1D* z_jets = readHist( path, name, "IC5Calo_ZJets.root", dirmame, rebin ); TH1D* lm0 = readHist( path, name, "IC5Calo_LM0.root", dirmame, rebin ); TH1D* lm1 = readHist( path, name, "IC5Calo_LM1.root", dirmame, rebin ); // Combine Z+jets and Z->inv TH1D* z_all = z_inv->Clone(); z_all->Add(z_jets,1); // TH1D* z_all = 0; // if ( z_inv && z_jets ) { // z_all = z_inv->Clone(); // z_all->Add(z_jets,1); // } else if ( z_inv ) { // z_all = z_inv->Clone(); // } else if ( z_jets ) { // z_all = z_jets->Clone(); // } // Select Z+jets and Z->inv separate or not bool combine = true; // Line colour and fill if ( qcd ) qcd->SetLineColor(kGreen+2); if ( qcd ) qcd->SetFillColor(kGreen+2); if ( qcd ) qcd->SetFillStyle(3003); if ( tt_jets ) tt_jets->SetLineColor(kBlue); if ( tt_jets ) tt_jets->SetLineStyle(1); if ( tt_jets ) tt_jets->SetLineWidth(1); w_jets->SetLineColor(kBlue); w_jets->SetLineStyle(3); w_jets->SetLineWidth(1); if ( combine ) { z_all->SetLineColor(kBlack); z_all->SetLineStyle(3); z_all->SetLineWidth(1); } else { z_inv->SetLineColor(kBlack); z_inv->SetLineStyle(1); z_inv->SetLineWidth(1); z_jets->SetLineColor(kBlack); z_jets->SetLineStyle(3); z_jets->SetLineWidth(1); } lm0->SetLineColor(kRed); lm0->SetLineStyle(1); lm0->SetLineWidth(2); lm1->SetLineColor(kRed); lm1->SetLineStyle(3); lm1->SetLineWidth(2); // Populate legend legend->AddEntry( qcd, " QCD", "f" ); legend->AddEntry( lm0, " SUSY LM0", "L" ); legend->AddEntry( lm1, " SUSY LM1", "L" ); legend->AddEntry( tt_jets, " t#bar{t}+jets", "L" ); legend->AddEntry( w_jets, " W+jets", "L" ); if ( combine ) { legend->AddEntry( z_all, " Z", "L" ); } else { legend->AddEntry( z_jets, " Z+jets", "L" ); legend->AddEntry( z_inv, " Z#rightarrow#nu#nu", "L" ); } // Calc maximum number of entries double aMax = 0.; if ( qcd->GetMaximum() > aMax ) { aMax = qcd->GetMaximum(); } if ( lm0->GetMaximum() > aMax ) { aMax = lm0->GetMaximum(); } if ( lm1->GetMaximum() > aMax ) { aMax = lm1->GetMaximum(); } if ( tt_jets->GetMaximum() > aMax ) { aMax = tt_jets->GetMaximum(); } if ( w_jets->GetMaximum() > aMax ) { aMax = w_jets->GetMaximum(); } if ( combine ) { if ( z_all->GetMaximum() > aMax ) { aMax = z_all->GetMaximum(); } } else { if ( z_inv->GetMaximum() > aMax ) { aMax = z_inv->GetMaximum(); } if ( z_jets->GetMaximum() > aMax ) { aMax = z_jets->GetMaximum(); } } // Calc minimum number of entries double aMin = 1.e12; if ( qcd->GetMinimum(1.e-12) < aMin ) { aMin = qcd->GetMinimum(1.e-12); } if ( lm0->GetMinimum(1.e-12) < aMin ) { aMin = lm0->GetMinimum(1.e-12); } if ( lm1->GetMinimum(1.e-12) < aMin ) { aMin = lm1->GetMinimum(1.e-12); } if ( tt_jets->GetMinimum(1.e-12) < aMin ) { aMin = tt_jets->GetMinimum(1.e-12); } if ( w_jets->GetMinimum(1.e-12) < aMin ) { aMin = w_jets->GetMinimum(1.e-12); } if ( combine ) { if ( z_all->GetMinimum(1.e-12) < aMin ) { aMin = z_all->GetMinimum(1.e-12); } } else { if ( z_inv->GetMinimum(1.e-12) < aMin ) { aMin = z_inv->GetMinimum(1.e-12); } if ( z_jets->GetMinimum(1.e-12) < aMin ) { aMin = z_jets->GetMinimum(1.e-12); } } if ( qcd ) qcd->GetYaxis()->SetTitleOffset(1.43); if ( qcd ) qcd->GetYaxis()->SetTitleSize(0.06); if ( qcd ) qcd->GetXaxis()->SetTitleSize(0.06); if ( qcd ) qcd->GetXaxis()->SetTitleOffset(0.9); if ( log ) { if ( qcd ) qcd->SetMaximum( aMax * 10. ); if ( qcd ) qcd->SetMinimum( aMin * 0.1 ); } else { if ( qcd ) qcd->SetMaximum( aMax * 1.1 ); if ( qcd ) qcd->SetMinimum( aMin * 0.9 ); } if ( norm ) { if ( qcd ) qcd->DrawNormalized("Ehist"); if ( lm0->GetEntries() > 0. ) { lm0->DrawNormalized("hsame"); } if ( lm1->GetEntries() > 0. ) { lm1->DrawNormalized("hsame"); } if ( tt_jets->GetEntries() > 0. ) { tt_jets->DrawNormalized("hsame"); } if ( w_jets->GetEntries() > 0. ) { w_jets->DrawNormalized("hsame"); } if ( combine ) { if ( z_all->GetEntries() > 0. ) { z_all->DrawNormalized("hsame"); } } else { if ( z_inv->GetEntries() > 0. ) { z_inv->DrawNormalized("hsame"); } if ( z_jets->GetEntries() > 0. ) { z_jets->DrawNormalized("hsame"); } } } else { if ( qcd ) qcd->Draw("h"); lm0->Draw("sameH"); lm1->Draw("sameH"); if ( tt_jets ) tt_jets->Draw("sameh"); w_jets->Draw("sameH"); if ( combine ) { z_all->Draw("sameH"); } else { z_inv->Draw("sameH"); z_jets->Draw("sameH"); } } file->cd(); legend->Draw("same"); aCanvas->Write(); return aCanvas; }
TGraphAsymmErrors* drawEff(TString hname1, TString hname2, TString filename, TString header, TString xtitle, int rebin, bool asymBin, float xlow, float xhigh, float xmin, float xmax, int icol, int imark, TString draw, double mup){//,double y, double c) { TH1D *ref = readHist(hname1, filename, rebin); TH1D *sel = readHist(hname2, filename, rebin); ref->SetName(hname1+header); sel->SetName(hname2+header); TGraphAsymmErrors *Eff = new TGraphAsymmErrors(); if (asymBin) { Double_t xbins[14]={0.,4.,6.,8.,10.,12.,14.,18. 22.,28.,34.,42.,52.,100.}; sel->Rebin(14,"nsel",xbins); ref->Rebin(14,"nref",xbins); Eff->BayesDivide(nsel, nref); } else { Eff->BayesDivide(sel, ref); //Eff->Divide(sel,ref,"cl=0.683 b(1,1) mode"); //Eff->Divide(sel,ref,"cl=0.683 b(1,1) mode v n"); } Double_t Nbins=(double)ref->GetNbinsX(); Double_t Nconv=(xhigh-xlow)/100.; if (Nbins>=Nconv) { cout << "Histo bins >= Nconvolution steps; OK" << endl; } else { cout << "Histo bins < Nconvolution steps!!! Not OK" << endl; } // gStyle->SetOptStat(1); gStyle->SetOptFit(0); TF1 *fermiFunction = new TF1("fermiFunction",expgaus,xlow,xhigh,5); Double_t params[5] = {1.,mup,20.,1.,xlow}; fermiFunction->SetParameters(params); fermiFunction->SetParNames("#epsilon","#mu","#sigma","#lambda","xlow"); if (hname2 != "L1JetAnalysis/SumEt60" ){ fermiFunction->FixParameter(4,xlow); // fermiFunction->SetParLimits(1,100.,150.); } // fermiFunction->SetParLimits(1,100.,150.); fermiFunction->SetParLimits(0,0.0,1.0); fermiFunction->SetLineColor(icol); fermiFunction->SetLineWidth(3); for(int i=0; i != 1 ; i++){ Eff->Fit("fermiFunction","RS+"); } Eff->SetLineWidth(2); Eff->SetMarkerStyle(imark); Eff->SetMarkerSize(0.5); Eff->SetMarkerColor(icol); Eff->SetLineColor(icol); Eff->GetXaxis()->SetTitle(xtitle); Eff->GetYaxis()->SetTitle("Trigger Efficiency"); // Eff->GetXaxis()->SetLabelSize(0.03); // Eff->GetYaxis()->SetLabelSize(0.03); Eff->GetXaxis()->SetTitleSize(0.05); Eff->GetYaxis()->SetTitleSize(0.05); Eff->GetXaxis()->SetTitleOffset(1.); Eff->GetYaxis()->SetRangeUser(0.,1.1); Eff->GetXaxis()->SetRangeUser((xmin+0.01),xmax); Eff->GetXaxis()->SetMoreLogLabels(); Double_t xpoint; Double_t ypoint; TF1 *fit = Eff->GetFunction("fermiFunction"); if (draw=="") { Eff->Draw("AP"); } else { Eff->Draw("P"); } return Eff; }