data_hist_pos.plotOn(fitFrame_PosPdg,rf.LineColor(ROOT.kRed)) model_total_pos.plotOn(fitFrame_PosPdg,rf.LineStyle(ROOT.kDashed)) model_total_pos.plotOn(fitFrame_PosPdg,rf.Components("model_WJets_pos"),rf.LineColor(ROOT.kGreen)) model_total_pos.plotOn(fitFrame_PosPdg,rf.Components("model_TTJets"),rf.LineColor(ROOT.kBlue)) #model_total_pos.plotOn(fitFrame_PosPdg,rf.Components("model_Diboson_pos"),rf.LineColor(ROOT.kOrange+7)) fitFrame_NegPdg=x.frame(rf.Bins(50),rf.Title("FitModel")) model_total_neg.paramOn(fitFrame_NegPdg,rf.Layout(0.42,0.9,0.9)) data_hist_neg.plotOn(fitFrame_NegPdg,rf.LineColor(ROOT.kRed)) model_total_neg.plotOn(fitFrame_NegPdg,rf.LineStyle(ROOT.kDashed)) model_total_neg.plotOn(fitFrame_NegPdg,rf.Components("model_WJets_neg"),rf.LineColor(ROOT.kGreen)) model_total_neg.plotOn(fitFrame_NegPdg,rf.Components("model_TTJets"),rf.LineColor(ROOT.kBlue)) #model_total_neg.plotOn(fitFrame_NegPdg,rf.Components("model_Diboson_neg"),rf.LineColor(ROOT.kOrange+7)) if i == 0: pos_val = af(yield_WJets_pos.getVal(), yield_WJets_pos.getErrorHi(), -yield_WJets_pos.getErrorLo()) neg_val = af(yield_WJets_neg.getVal(), yield_WJets_neg.getErrorHi(), -yield_WJets_neg.getErrorLo()) f_pos = af(WJetsTemp_pos.GetBinContent(1), WJetsTemp_pos.GetBinError(1)) f_neg = af(WJetsTemp_neg.GetBinContent(1), WJetsTemp_neg.GetBinError(1)) W_0b = f_pos*pos_val + f_neg*neg_val SF_W = (pos_val+neg_val) / W_prefit print "yield_TTJets, again:", yield_TTJets.getVal() SF_top = af(yield_TTJets.getVal()*2, yield_TTJets.getErrorHi()*math.sqrt(2)) / tt_prefit #c1=ROOT.TCanvas("c1","FitModel",650,1000) #ROOT.gROOT.SetStyle("Plain") #c1.Divide(1,2) #c1.cd(1) #ROOT.gROOT.SetStyle("Plain")#Removesgraybackgroundfromplots #ROOT.gPad.SetLeftMargin(0.15) #fitFrame_PosPdg.GetYaxis().SetTitleOffset(1.4)
def getIntegralAndError(hist): err = ROOT.Double() val = hist.IntegralAndError(0,1000,err) return af(val,err)
data_hist_pos.plotOn(fitFrame_PosPdg,rf.LineColor(ROOT.kRed)) model_total_pos.plotOn(fitFrame_PosPdg,rf.LineStyle(ROOT.kDashed)) model_total_pos.plotOn(fitFrame_PosPdg,rf.Components("model_WJets_pos"),rf.LineColor(ROOT.kGreen)) model_total_pos.plotOn(fitFrame_PosPdg,rf.Components("model_TTJets"),rf.LineColor(ROOT.kBlue)) #model_total_pos.plotOn(fitFrame_PosPdg,rf.Components("model_Diboson_pos"),rf.LineColor(ROOT.kOrange+7)) fitFrame_NegPdg=x.frame(rf.Bins(50),rf.Title("FitModel")) model_total_neg.paramOn(fitFrame_NegPdg,rf.Layout(0.42,0.9,0.9)) data_hist_neg.plotOn(fitFrame_NegPdg,rf.LineColor(ROOT.kRed)) model_total_neg.plotOn(fitFrame_NegPdg,rf.LineStyle(ROOT.kDashed)) model_total_neg.plotOn(fitFrame_NegPdg,rf.Components("model_WJets_neg"),rf.LineColor(ROOT.kGreen)) model_total_neg.plotOn(fitFrame_NegPdg,rf.Components("model_TTJets"),rf.LineColor(ROOT.kBlue)) #model_total_neg.plotOn(fitFrame_NegPdg,rf.Components("model_Diboson_neg"),rf.LineColor(ROOT.kOrange+7)) if i == 0: pos_val = af(yield_WJets_pos.getVal(), yield_WJets_pos.getErrorHi(), -yield_WJets_pos.getErrorLo()) neg_val = af(yield_WJets_neg.getVal(), yield_WJets_neg.getErrorHi(), -yield_WJets_neg.getErrorLo()) f_pos = af(WJetsTemp_pos.GetBinContent(1), WJetsTemp_pos.GetBinError(1)) f_neg = af(WJetsTemp_neg.GetBinContent(1), WJetsTemp_neg.GetBinError(1)) W_0b_fit = f_pos*pos_val + f_neg*neg_val print W_0b_fit SF_W = (pos_val+neg_val) / W_prefit print "yield_TTJets, again:", yield_TTJets.getVal() SF_top = af(yield_TTJets.getVal()*2, yield_TTJets.getErrorHi()*math.sqrt(2)) / tt_prefit f_top = af(TTJetsTemp.GetBinContent(1), TTJetsTemp.GetBinError(1)) tt_0b = f_top*af(yield_TTJets.getVal()*2, yield_TTJets.getErrorHi()*math.sqrt(2)) W_0b_pred = af(int(DataHist_pos.GetBinContent(1)+DataHist_neg.GetBinContent(1))) - tt_0b print af(int(DataHist_pos.GetBinContent(1)+DataHist_neg.GetBinContent(1))) print W_0b_pred