def __call__(self, options, args): self.loadRootStyle() graphs = map( lambda x: (scaleGraph(self.open(x[0]).Get("onesigma"), x[2]), x[1]), zip(options.compare_files, options.compare_labels, options.rescale)) canv = ROOT.TCanvas("shape_cmp_%s" % options.label, options.label) canv.cd() canv.SetLogy() legend = ROOT.TLegend(0.56, 0.51, 0.86, 0.76) legend.AddEntry(None, options.label, "") g0 = graphs[0][0] g0.Draw("al") legend.AddEntry(g0, graphs[0][1], "le") style_utils.apply(g0, [["colors", ROOT.kBlue]]) for g in graphs[1:]: g[0].Draw("l") legend.AddEntry(g[0], g[1], "le") style_utils.apply(g[0], [["colors", ROOT.kRed]]) legend.Draw() self.keep(graphs) self.keep([canv, legend]) self.autosave(True)
def __call__(self,options,args): self.loadRootStyle() graphs = map(lambda x: ( scaleGraph(self.open(x[0]).Get("onesigma"),x[2]),x[1]), zip(options.compare_files,options.compare_labels,options.rescale) ) canv = ROOT.TCanvas("shape_cmp_%s" % options.label,options.label) canv.cd() canv.SetLogy() legend = ROOT.TLegend(0.56,0.51,0.86,0.76) legend.AddEntry(None,options.label,"") g0 = graphs[0][0] g0.Draw("al") legend.AddEntry(g0,graphs[0][1],"le") style_utils.apply(g0, [["colors",ROOT.kBlue]] ) for g in graphs[1:]: g[0].Draw("l") legend.AddEntry(g[0],g[1],"le") style_utils.apply(g[0], [["colors",ROOT.kRed]] ) legend.Draw() self.keep( graphs ) self.keep( [canv,legend] ) self.autosave(True)
def plotPval(self,options,coup,tfile): observed = ROOT.theBand( tfile, 1, 0, ROOT.Observed, 0.95 ) basicStyle = [["SetMarkerSize",0.6],["SetLineWidth",3], ["SetTitle",";m_{G} (GeV);p_{0}"]] if not options.spin2: basicStyle.append(["SetTitle",";m_{S} (GeV);p_{0}"]) commonStyle = ["Sort"]+basicStyle observedStyle = commonStyle+[["SetMarkerStyle",ROOT.kFullCircle],["colors",ROOT.kBlue]] style_utils.apply(observed,[["SetName","observed_%s"%coup]]+observedStyle) xmin,xmax = options.x_range canv = ROOT.TCanvas("pvalues_k%s"%coup,"pvalues_k%s"%coup) canv.SetLogy() canv.SetLogx() ## legend = ROOT.TLegend(0.5,0.6,0.8,0.75) ## legend = ROOT.TLegend(0.6,0.6,0.9,0.75) legend = ROOT.TLegend(0.56,0.6,0.86,0.75) legend.SetFillStyle(0) kappa = "0."+coup[1:] observed.Draw("apl") ## observed.Draw("al") ## observed.GetYaxis().SetRangeUser(1e-5,0.55) observed.GetYaxis().SetRangeUser(1e-3,0.55) ## observed.GetXaxis().SetRangeUser(450,3000) ## observed.GetXaxis().SetRangeUser(450,5000) observed.GetXaxis().SetRangeUser(xmin,xmax) observed.GetXaxis().SetMoreLogLabels() ## xmin,xmax=observed.GetXaxis().GetXmin(),observed.GetXaxis().GetXmax() ## xmin,xmax=450,3000 # xmin,xmax=450,5000 spots = filter(lambda x: x>observed.GetYaxis().GetXmin(), map(lambda x: (x,ROOT.RooStats.SignificanceToPValue(x)), xrange(1,5) ) ) lines = map( lambda y: ROOT.TLine(xmin,y[1],xmax,y[1]), spots ) map( lambda x: style_utils.apply(x,[["SetLineColor",ROOT.kGray+3],["SetLineStyle",7]]), lines ) labels = map( lambda y: ROOT.TLatex(xmax*1.01,y[1]*0.9,"#color[%d]{%d #sigma}" % (ROOT.kGray+2,y[0])), spots ) map( lambda x: style_utils.apply(x,[["SetTextSize",0.05]]), labels ) map( lambda x: x.Draw("same"), lines+labels ) self.keep(lines+labels) if options.spin2: legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") else: kappa = float(kappa) legend.AddEntry(None,"#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.),"") legend.AddEntry(observed,"Observed p_{0}","l") self.keep(legend,True) legend.Draw() self.graphs.extend([observed]) self.keep( [canv,observed] ) self.format(canv,options.postproc)
def plotLimit(self,options,coup,tfile): ## TGraphAsymmErrors *theBand(TFile *file, int doSyst, int whichChannel, BandType type, double width=0.68) { if options.asimov_expected: ROOT.use_precomputed_quantiles = True bandType = ROOT.Median else: bandType = ROOT.Median expected68 = ROOT.theBand( tfile, 1, 0, bandType, 0.68 ) expected95 = ROOT.theBand( tfile, 1, 0, bandType, 0.95 ) observed = ROOT.theBand( tfile, 1, 0, ROOT.Observed, 0.95 ) unit = "fb" if options.use_fb else "pb" basicStyle = [["SetMarkerSize",0.6],["SetLineWidth",3], ["SetTitle",";m_{G} (GeV);95%% C.L. limit #sigma(pp#rightarrow G#rightarrow#gamma#gamma) (%s)" % unit]] commonStyle = [[self.scaleByXsec,coup],"Sort"]+basicStyle ## expectedStyle = commonStyle+[["SetMarkerStyle",ROOT.kOpenCircle]] expectedStyle = commonStyle+[["SetMarkerSize",0]] observedStyle = commonStyle+[["SetMarkerStyle",ROOT.kFullCircle]] style_utils.apply( expected68, [["colors",ROOT.kYellow],["SetName","expected68_%s"%coup]]+expectedStyle ) style_utils.apply( expected95, [["colors",ROOT.kGreen],["SetName","expected95_%s"%coup]]+expectedStyle ) expected = ROOT.TGraph(expected68) style_utils.apply( expected, [["colors",ROOT.kBlack],["SetLineStyle",7],["SetName","expected_%s"%coup]]) style_utils.apply(observed,[["SetName","observed_%s"%coup]]+observedStyle) canv = ROOT.TCanvas("limits_k%s"%coup,"limits_k%s"%coup) canv.SetLogx() legend = ROOT.TLegend(0.6,0.6,0.9,0.9) expected95.Draw("AE3") expected95.GetXaxis().SetRangeUser(450,5500) expected95.GetXaxis().SetMoreLogLabels() expected68.Draw("E3L") expected.Draw("L") kappa = "0."+coup[1:] legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") legend.AddEntry(expected,"Expected limit","l") legend.AddEntry(expected68," \pm 1 \sigma","f") legend.AddEntry(expected95," \pm 2 \sigma","f") if options.unblind: observed.Draw("PL") ## observed.Draw("L") legend.AddEntry(observed,"Observed limit","l") if coup in self.xsections_: grav = self.xsections_[coup] style_utils.apply( grav, basicStyle+[["SetLineStyle",9],["colors",ROOT.myColorB2]] ) grav.Draw("L") legend.AddEntry(grav,"G_{RS}#rightarrow#gamma#gamma (LO)","l").SetLineStyle(0) self.keep(legend,True) legend.Draw() self.graphs.extend([observed,expected,expected68,expected95]) self.keep( [canv,observed,expected,expected68,expected95] ) self.format(canv,options.postproc)
def plotPval(self, options, coup, tfile): observed = ROOT.theBand(tfile, 1, 0, ROOT.Observed, 0.95) basicStyle = [["SetMarkerSize", 0.6], ["SetLineWidth", 3], ["SetTitle", ";M_{G} (GeV);p_{0}"]] commonStyle = ["Sort"] + basicStyle observedStyle = commonStyle + [["SetMarkerStyle", ROOT.kFullCircle], ["colors", ROOT.kBlue]] style_utils.apply(observed, [["SetName", "observed_%s" % coup]] + observedStyle) canv = ROOT.TCanvas("pvalues_k%s" % coup, "pvalues_k%s" % coup) canv.SetLogy() canv.SetLogx() legend = ROOT.TLegend(0.5, 0.6, 0.8, 0.75) legend.SetFillStyle(0) kappa = "0." + coup[1:] observed.Draw("apl") ## observed.Draw("al") ## observed.GetYaxis().SetRangeUser(1e-5,0.55) observed.GetYaxis().SetRangeUser(1e-3, 0.55) observed.GetXaxis().SetRangeUser(450, 5000) observed.GetXaxis().SetMoreLogLabels() ## xmin,xmax=observed.GetXaxis().GetXmin(),observed.GetXaxis().GetXmax() xmin, xmax = 450, 5000 spots = filter( lambda x: x > observed.GetYaxis().GetXmin(), map(lambda x: (x, ROOT.RooStats.SignificanceToPValue(x)), xrange(1, 5))) lines = map(lambda y: ROOT.TLine(xmin, y[1], xmax, y[1]), spots) map( lambda x: style_utils.apply(x, [["SetLineColor", ROOT.kGray + 3], ["SetLineStyle", 7]]), lines) labels = map( lambda y: ROOT.TLatex( xmax * 1.01, y[1] * 0.9, "#color[%d]{%d #sigma}" % (ROOT.kGray + 2, y[0])), spots) map(lambda x: style_utils.apply(x, [["SetTextSize", 0.05]]), labels) map(lambda x: x.Draw("same"), lines + labels) self.keep(lines + labels) legend.AddEntry(None, "#tilde{#kappa} = %s" % kappa, "") legend.AddEntry(observed, "Observed p_{0}", "l") self.keep(legend, True) legend.Draw() self.graphs.extend([observed]) self.keep([canv, observed]) self.format(canv, options.postproc)
def drawLines(self,ref,xmin=450,xmax=5000): spots = filter(lambda y: y[1]>float(ref.GetYaxis().GetXmin()), map(lambda x: (x,ROOT.RooStats.SignificanceToPValue(x)), xrange(1,5) ) ) lines = map( lambda y: ROOT.TLine(xmin,y[1],xmax,y[1]), spots ) map( lambda x: style_utils.apply(x,[["SetLineColor",ROOT.kGray+3],["SetLineStyle",7]]), lines ) labels = map( lambda y: ROOT.TLatex(xmax*1.01,y[1]*0.9,"#color[%d]{%d #sigma}" % (ROOT.kGray+2,y[0])), spots ) map( lambda x: style_utils.apply(x,[["SetTextSize",0.05]]), labels ) map( lambda x: x.Draw("same"), lines+labels ) self.keep(lines+labels)
def drawLines(self,ref,xmin=450,xmax=5000): spots = filter(lambda x: x>ref.GetYaxis().GetXmin(), map(lambda x: (x,ROOT.RooStats.SignificanceToPValue(x)), xrange(1,5) ) ) lines = map( lambda y: ROOT.TLine(xmin,y[1],xmax,y[1]), spots ) map( lambda x: style_utils.apply(x,[["SetLineColor",ROOT.kGray+3],["SetLineStyle",7]]), lines ) labels = map( lambda y: ROOT.TLatex(xmax*1.01,y[1]*0.9,"#color[%d]{%d #sigma}" % (ROOT.kGray+2,y[0])), spots ) map( lambda x: style_utils.apply(x,[["SetTextSize",0.05]]), labels ) map( lambda x: x.Draw("same"), lines+labels ) self.keep(lines+labels)
def plotComparison(self,options,coup,observed): cobserved = map(lambda x: (filter(lambda y: y.GetName().ends, x[0])[0],x[1]), observed) print cobserved styles = [ [["colors",ROOT.kBlue]], [["colors",ROOT.kOrange]], [["colors",ROOT.kGreen+1]] ] map(lambda x: style_utils.apply(x[0],[["SetMarkerSize",0.5],["SetLineWidth",1]]+styles.pop(0)), cobserved) canv = ROOT.TCanvas("comparison_%s" % coup,"comparison_%s" % coup) legend = ROOT.TLegend(0.55,0.51,0.85,0.76) legend.SetFillStyle(0) kappa = "0."+coup[1:] legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") g0 = cobserved[0][0] g0.Draw("apl") for gr,nam in cobserved: legend.AddEntry(gr,nam,"l") for gr,nam in reversed(cobserved): gr.Draw("pl") legend.Draw("same") g0.GetXaxis().SetRangeUser(450,5000) g0.GetXaxis().SetMoreLogLabels() canv.SetLogx() if options.do_pvalues: canv.SetLogy() g0.GetYaxis().SetRangeUser(1e-3,0.55) self.drawLines(g0) self.keep([canv,legend]) self.format(canv,options.postproc)
def plotNLLScan(self, options): graphs = map( lambda x: ( map( lambda z: scan1D( z, x[2], x[ 1], "#sigma^{13TeV} #upoint B_{#gamma #gamma} (fb)" ), ##"\sigma^{13TeV} \cdot BR_{\gamma \gamma} (fb)"), filter(lambda y: y.GetName() == "limit", x[0]))[0], x[1]), self.compare) styles = [[["colors", ROOT.kBlack]], [["colors", ROOT.kBlue]], [["colors", ROOT.kRed]]] map( lambda x: style_utils.apply(x[0], [["SetMarkerSize", 0.3], ["SetLineWidth", 2]] + styles. pop(0)), graphs) canv = ROOT.TCanvas("nll_scan_%s" % options.label, "nll_scan_%s" % options.label) legend = ROOT.TLegend(*options.legend) g0 = graphs[0][0] txt = "" if options.spin2: txt += "J=2" else: txt += "J=0" legend.AddEntry(None, "m=%1.0f GeV, %s" % (options.mass, txt), "") if len(options.couplings) == 1: kappa = float("0.%s" % options.couplings[0][1:]) legend.AddEntry( None, "#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4 * kappa * kappa * 100.), "") legend.AddEntry(None, " ", "") ## if options.spin2: ### legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") ### else: ### kappa = float(kappa) ### legend.AddEntry(None,"#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.),"") if len(options.x_range) != 0: g0.GetXaxis().SetRangeUser(*options.x_range) if len(options.y_range) != 0: g0.GetYaxis().SetRangeUser(*options.y_range) g0.GetYaxis().SetLimits(*options.y_range) g0.Draw("ac") for gr, nam in graphs: legend.AddEntry(gr, nam, "l") self.keep(gr) for gr, nam in reversed(graphs): gr.Draw("c") legend.Draw("same") ## xmin,xmax = options.x_range self.keep([canv, legend]) self.format(canv, options.postproc)
def __call__(self, options, args): self.loadRootStyle() self.evlists = {} files = map(self.open, options.file_names) graphs = map(lambda x: x.Get("onesigma"), files) map( lambda x: scaleGraph( x, 1. / reduce(lambda z, w: z + w, [x.GetY()[i] for i in xrange(x.GetN())])), graphs) styles = [[["colors", ROOT.kBlue], ["SetFillColorAlpha", [ROOT.kBlue, 0.5]]], [["colors", ROOT.kRed], ["SetFillColorAlpha", [ROOT.kRed, 0.5]]]] common = [ ["xtitle", "m_{#gamma#gamma} (GeV)"], [ "ytitle", "1 / N #times #Delta N / #Delta m_{#gamma#gamma} (1 / 20 GeV)" ] ] map(lambda x: style_utils.apply(x[0], x[1] + common), zip(graphs, styles)) map(lambda x: x[0].SetTitle(x[1]), zip(graphs, self.options.file_labels)) canv = ROOT.TCanvas("compareshape_%s" % (options.label), "compareshape_%s" % (options.label)) legend = ROOT.TLegend(*options.legend) canv.cd() canv.SetLogy() print graphs graphs[0].Draw("ape3") for g in graphs[1:]: g.Draw("pe3") ptCMS = ROOT.TLatex(0.28, 0.25, self.options.label) ptCMS.SetNDC() ## ptCMS.SetTextFont(61) ptCMS.SetTextSize(0.04) ptCMS.Draw("same") for g in graphs: legend.AddEntry(g) legend.Draw("same") self.keep(graphs) self.keep([canv, legend]) self.format(canv, options.postproc) self.autosave(True)
def plotPval(self,options,coup,tfile): observed = ROOT.theBand( tfile, 1, 0, ROOT.Observed, 0.95 ) basicStyle = [["SetMarkerSize",1],["SetLineWidth",3], ["SetTitle",";M_{G} (GeV);p_{0}"]] commonStyle = ["Sort"]+basicStyle observedStyle = commonStyle+[["SetMarkerStyle",ROOT.kFullCircle],["colors",ROOT.kBlue]] style_utils.apply(observed,[["SetName","observed_%s"%coup]]+observedStyle) canv = ROOT.TCanvas("pvalues_k%s"%coup,"pvalues_k%s"%coup) canv.SetLogy() canv.SetLogx() legend = ROOT.TLegend(0.5,0.6,0.8,0.75) kappa = "0."+coup[1:] observed.Draw("apl") observed.GetYaxis().SetRangeUser(1e-5,0.55) observed.GetXaxis().SetRangeUser(450,5500) observed.GetXaxis().SetMoreLogLabels() ## xmin,xmax=observed.GetXaxis().GetXmin(),observed.GetXaxis().GetXmax() xmin,xmax=450,5500 spots = map(lambda x: (x,ROOT.RooStats.SignificanceToPValue(x)), xrange(1,5) ) lines = map( lambda y: ROOT.TLine(xmin,y[1],xmax,y[1]), spots ) map( lambda x: style_utils.apply(x,[["SetLineColor",ROOT.kGray+3],["SetLineStyle",7]]), lines ) labels = map( lambda y: ROOT.TLatex(xmax*1.01,y[1]*0.9,"#color[%d]{%d #sigma}" % (ROOT.kGray+2,y[0])), spots ) map( lambda x: style_utils.apply(x,[["SetTextSize",0.05]]), labels ) map( lambda x: x.Draw("same"), lines+labels ) self.keep(lines+labels) legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") legend.AddEntry(observed,"Observed p_{0}","l") self.keep(legend,True) legend.Draw() self.graphs.extend([observed]) self.keep( [canv,observed] )
def plotComparison(self,options,coup,observed): cobserved = map(lambda x: (filter(lambda y: y.GetName().endswith("_%s" % coup), x[0])[0],x[1]), observed) print cobserved ## styles = [ [["colors",ROOT.kBlue]], [["colors",ROOT.kRed+1]], [["colors",ROOT.kMagenta-2]] ] styles = [ [["colors",ROOT.kBlack]], [["colors",ROOT.kBlue],["SetLineStyle",2]], [["colors",ROOT.kRed],["SetLineStyle",2]] ] map(lambda x: style_utils.apply(x[0],[["SetMarkerSize",0.3],["SetLineWidth",2]]+styles.pop(0)), cobserved) canv = ROOT.TCanvas("comparison_%s" % coup,"comparison_%s" % coup) legend = ROOT.TLegend(*options.legend) ## legend = ROOT.TLegend(0.56,0.51,0.86,0.76) ## legend = ROOT.TLegend(0.6,0.51,0.9,0.76) ## legend = ROOT.TLegend(0.6,0.2,0.9,0.42) ## legend = ROOT.TLegend(0.45,0.2,0.75,0.42) legend.SetFillStyle(0) kappa = "0."+coup[1:] g0 = cobserved[0][0] if options.spin2: legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") g0.GetXaxis().SetTitle("m_{G} (GeV)") else: kappa = float(kappa) legend.AddEntry(None,"#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.),"") g0.GetXaxis().SetTitle("m_{S} (GeV)") g0.Draw("apl") for gr,nam in cobserved: legend.AddEntry(gr,nam,"l") for gr,nam in reversed(cobserved): gr.Draw("pl") legend.Draw("same") xmin,xmax = options.x_range ## g0.GetXaxis().SetRangeUser(450,5000) ## g0.GetXaxis().SetRangeUser(500,3000) ## g0.GetXaxis().SetRangeUser(500,850) ## g0.GetXaxis().SetRangeUser(850,3000) g0.GetXaxis().SetRangeUser(xmin,xmax) g0.GetXaxis().SetMoreLogLabels() canv.SetLogx() if options.do_pvalues: canv.SetLogy() g0.GetYaxis().SetRangeUser(1e-3,0.55) self.drawLines(g0,xmin,xmax) ## self.drawLines(g0,450,5000) ## self.drawLines(g0,500,3000) ## self.drawLines(g0,500,850) ## self.drawLines(g0,850,3000) self.keep([canv,legend]) self.format(canv,options.postproc)
def plotResults(self,options,args): flist = glob.glob("%s/scan*.json" % (options.input_dir) ) points = filter(lambda x: x!=None, map(self.loadPoint, flist) ) keys = set( map( lambda x: "%s_%s" % (x["label"],x["kmpl"]), points ) ) scans = {} for key in keys: scans[key] = [] map( lambda x: scans["%s_%s" % (x["label"],x["kmpl"])].append(x), points ) graphs = map( self.graphFromScan, scans.iteritems() ) kmpls = set( map( lambda x: x["kmpl"], points ) ) common = [["SetTitle",";M_{G} (GeV);#sigma #times BR (Z_{0} = %1.1f) (pb)" % self.options.target ]] styles = [ [["colors",ROOT.kRed],["SetMarkerStyle",ROOT.kFullCircle]], [["colors",ROOT.kRed+1],["SetMarkerStyle",ROOT.kOpenCircle],["SetLineStyle",7]], [["colors",ROOT.kBlue],["SetMarkerStyle",ROOT.kFullTriangleUp]], [["colors",ROOT.kBlue+1],["SetMarkerStyle",ROOT.kOpenTriangleUp],["SetLineStyle",7]], [["colors",ROOT.kGreen],["SetMarkerStyle",ROOT.kFullDiamond]], [["colors",ROOT.kGreen+1],["SetMarkerStyle",ROOT.kOpenDiamond],["SetLineStyle",7]], ] for kmpl in kmpls: kgraphs = sorted( filter( lambda x: x.GetName().startswith("%s_" % kmpl), graphs ), key=lambda x: x.GetName() ) kstyles = [ styles[0], styles[3] ] if len( kgraphs ) == 2 else styles map( lambda x: style_utils.apply(x[0],common+x[1]), zip(kgraphs,kstyles) ) cname = "zscan_k%s"%kmpl if options.min_mass: cname += "_%1.0f" % options.min_mass if options.max_mass: cname += "_%1.0f" % options.max_mass canv = ROOT.TCanvas(cname,cname) ## canv.SetLogy() legend = ROOT.TLegend(0.5,0.6,0.8,0.9) legend.AddEntry(None,"#tilde{#kappa} = 0.%s" % kmpl[1:],"") kgraphs[0].Draw("apl") for gr in kgraphs: gr.Draw("pl") map( lambda x: legend.AddEntry(x,x.GetName(),"lp" ), kgraphs ) legend.Draw("same") self.keep( [canv,legend] ) self.autosave(True) gfile = self.open("%s/graphs_zscan.root" % (options.input_dir),"recreate") gfile.cd() for gr in graphs: gr.Write() gfile.Close()
def plotComparison(self,options,coup,observed): cobserved = map(lambda x: (filter(lambda y: y.GetName().endswith("_%s" % coup), x[0])[0],x[1]), observed) print cobserved ## styles = [ [["colors",ROOT.kBlue]], [["colors",ROOT.kRed+1]], [["colors",ROOT.kMagenta-2]] ] styles = [ [["colors",ROOT.kBlack]], [["colors",ROOT.kBlue],["SetLineStyle",2]], [["colors",ROOT.kRed],["SetLineStyle",2]] ] map(lambda x: style_utils.apply(x[0],[["SetMarkerSize",0.3],["SetLineWidth",2]]+styles.pop(0)), cobserved) canv = ROOT.TCanvas("comparison_%s" % coup,"comparison_%s" % coup) legend = ROOT.TLegend(*options.legend) ## legend = ROOT.TLegend(0.56,0.51,0.86,0.76) ## legend = ROOT.TLegend(0.6,0.51,0.9,0.76) ## legend = ROOT.TLegend(0.6,0.2,0.9,0.42) ## legend = ROOT.TLegend(0.45,0.2,0.75,0.42) legend.SetFillStyle(0) kappa = "0."+coup[1:] legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") g0 = cobserved[0][0] g0.GetXaxis().SetTitle("m_{G} (GeV)") g0.Draw("apl") for gr,nam in cobserved: legend.AddEntry(gr,nam,"l") for gr,nam in reversed(cobserved): gr.Draw("pl") legend.Draw("same") xmin,xmax = options.x_range ## g0.GetXaxis().SetRangeUser(450,5000) ## g0.GetXaxis().SetRangeUser(500,3000) ## g0.GetXaxis().SetRangeUser(500,850) ## g0.GetXaxis().SetRangeUser(850,3000) g0.GetXaxis().SetRangeUser(xmin,xmax) g0.GetXaxis().SetMoreLogLabels() canv.SetLogx() if options.do_pvalues: canv.SetLogy() g0.GetYaxis().SetRangeUser(1e-3,0.55) self.drawLines(g0,xmin,xmax) ## self.drawLines(g0,450,5000) ## self.drawLines(g0,500,3000) ## self.drawLines(g0,500,850) ## self.drawLines(g0,850,3000) self.keep([canv,legend]) self.format(canv,options.postproc)
def plotNLLScan(self,options): graphs = map(lambda x: (map(lambda z: scan1D(z,x[2],x[1],"#sigma^{13TeV} #upoint B_{#gamma #gamma} (fb)"),##"\sigma^{13TeV} \cdot BR_{\gamma \gamma} (fb)"), filter(lambda y: y.GetName() == "limit", x[0]))[0],x[1]), self.compare) styles = [ [["colors",ROOT.kBlack]], [["colors",ROOT.kBlue]], [["colors",ROOT.kRed]] ] map(lambda x: style_utils.apply(x[0],[["SetMarkerSize",0.3],["SetLineWidth",2]]+styles.pop(0)), graphs) canv = ROOT.TCanvas("nll_scan_%s" % options.label,"nll_scan_%s" % options.label) legend = ROOT.TLegend(*options.legend) g0 = graphs[0][0] txt = "" if options.spin2: txt += "J=2" else: txt += "J=0" legend.AddEntry(None,"m=%1.0f GeV, %s" % (options.mass,txt),"") if len(options.couplings) == 1: kappa = float("0.%s" % options.couplings[0][1:]) legend.AddEntry(None,"#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.),"") legend.AddEntry(None," ","") ## if options.spin2: ### legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") ### else: ### kappa = float(kappa) ### legend.AddEntry(None,"#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.),"") if len(options.x_range) != 0: g0.GetXaxis().SetRangeUser(*options.x_range) if len(options.y_range) != 0: g0.GetYaxis().SetRangeUser(*options.y_range) g0.GetYaxis().SetLimits(*options.y_range) g0.Draw("ac") for gr,nam in graphs: legend.AddEntry(gr,nam,"l") self.keep(gr) for gr,nam in reversed(graphs): gr.Draw("c") legend.Draw("same") ## xmin,xmax = options.x_range self.keep([canv,legend]) self.format(canv,options.postproc)
def __call__(self,options,args): self.loadRootStyle() self.evlists = {} files = map( self.open, options.file_names) graphs = map(lambda x: x.Get("onesigma"), files ) map(lambda x: scaleGraph(x,1./reduce(lambda z,w: z+w, [ x.GetY()[i] for i in xrange(x.GetN())] )), graphs ) styles = [ [["colors",ROOT.kBlue],["SetFillColorAlpha",[ROOT.kBlue,0.5]]], [["colors",ROOT.kRed],["SetFillColorAlpha",[ROOT.kRed,0.5]]] ] common = [["xtitle","m_{#gamma#gamma} (GeV)"],["ytitle","1 / N #times #Delta N / #Delta m_{#gamma#gamma} (1 / 20 GeV)"]] map(lambda x: style_utils.apply(x[0],x[1]+common), zip(graphs,styles) ) map(lambda x: x[0].SetTitle(x[1]), zip(graphs,self.options.file_labels) ) canv = ROOT.TCanvas("compareshape_%s" % (options.label),"compareshape_%s" % (options.label) ) legend = ROOT.TLegend(*options.legend) canv.cd() canv.SetLogy() print graphs graphs[0].Draw("ape3") for g in graphs[1:]: g.Draw("pe3") ptCMS=ROOT.TLatex(0.28,0.25,self.options.label) ptCMS.SetNDC() ## ptCMS.SetTextFont(61) ptCMS.SetTextSize(0.04) ptCMS.Draw("same") for g in graphs: legend.AddEntry(g) legend.Draw("same") self.keep(graphs) self.keep([canv,legend]) self.format(canv,options.postproc) self.autosave(True)
def plotBias(self,options,args): coups = sorted( set( map(lambda x: x['coup'], options.bias ) ), cmp=lambda x,y: -cmp( float("0."+x[1:]), float("0."+y[1:]), ) ) cats = set( map(lambda x: x['cat'], options.bias ) ) prod = itertools.product(coups,cats) graphs = map(lambda x: self.graphFromBiasPoints("_".join(x[0]),x[1]), map(lambda y: (y,filter(lambda z: z['coup'] == y[0] and z['cat'] == y[1], options.bias )), prod ) ) ## map( lambda x: x.Print("V"), graphs ) common = [["SetLineWidth",2],["SetTitle",";M_{G} (GeV);N_{bias} / ( #varepsilon A L ) (pb)" ]] styles = [ [["colors",ROOT.kRed],["SetMarkerStyle",ROOT.kFullCircle]], [["colors",ROOT.kRed+1],["SetMarkerStyle",ROOT.kOpenCircle],["SetLineStyle",7]], [["colors",ROOT.kBlue],["SetMarkerStyle",ROOT.kFullTriangleUp]], [["colors",ROOT.kBlue+1],["SetMarkerStyle",ROOT.kOpenTriangleUp],["SetLineStyle",7]], [["colors",ROOT.kGreen],["SetMarkerStyle",ROOT.kFullDiamond]], [["colors",ROOT.kGreen+1],["SetMarkerStyle",ROOT.kOpenDiamond],["SetLineStyle",7]], [["colors",ROOT.kOrange]], [["colors",ROOT.kOrange+1],["SetLineStyle",7]], ] for cat in cats: canv = ROOT.TCanvas("bias_%s" % cat,"bias_%s" % cat) canv.SetLogy() legend = ROOT.TLegend(0.5,0.6,0.8,0.9) cgraphs = filter(lambda x: cat in x.GetName(), graphs ) map( lambda x: style_utils.apply(x[0],common+x[1]), zip(cgraphs,styles) ) cgraphs[0].Draw("al") for g in cgraphs[1:]: g.Draw("l") for g in cgraphs: legend.AddEntry(g,g.GetName(),"l") legend.Draw() self.keep([canv,cgraphs,legend]) self.autosave(True) gfile = self.open("graphs_bias.root","recreate") gfile.cd() for gr in graphs: gr.Write() gfile.Close()
def plotComparison(self, options, coup, observed): cobserved = map( lambda x: (filter(lambda y: y.GetName().ends, x[0])[0], x[1]), observed) print cobserved styles = [[["colors", ROOT.kBlue]], [["colors", ROOT.kOrange]], [["colors", ROOT.kGreen + 1]]] map( lambda x: style_utils.apply(x[0], [["SetMarkerSize", 0.5], ["SetLineWidth", 1]] + styles. pop(0)), cobserved) canv = ROOT.TCanvas("comparison_%s" % coup, "comparison_%s" % coup) legend = ROOT.TLegend(0.55, 0.51, 0.85, 0.76) legend.SetFillStyle(0) kappa = "0." + coup[1:] legend.AddEntry(None, "#tilde{#kappa} = %s" % kappa, "") g0 = cobserved[0][0] g0.Draw("apl") for gr, nam in cobserved: legend.AddEntry(gr, nam, "l") for gr, nam in reversed(cobserved): gr.Draw("pl") legend.Draw("same") g0.GetXaxis().SetRangeUser(450, 5000) g0.GetXaxis().SetMoreLogLabels() canv.SetLogx() if options.do_pvalues: canv.SetLogy() g0.GetYaxis().SetRangeUser(1e-3, 0.55) self.drawLines(g0) self.keep([canv, legend]) self.format(canv, options.postproc)
def compareSensitivity(self,options,args): ## self.open(options.limit_bias_file).GetListOfKeys().Print() bias_limits = filter(lambda x: "expected_" in x.GetName(), getObjects( [self.open(options.limit_bias_file)], types=["TGraph"] ) ) if options.limit_bias_file else [] no_bias_limits = filter(lambda x: "expected_" in x.GetName(), getObjects( [self.open(options.limit_no_bias_file)], types=["TGraph"] ) ) if options.limit_no_bias_file else [] bias_zscans = filter(lambda x: "_bias" in x.GetName(), getObjects( [self.open(options.zscan_bias_file)], types=["TGraph"] ) ) if options.zscan_bias_file else [] no_bias_zscans = filter(lambda x: "_nobias" in x.GetName(), getObjects( [self.open(options.zscan_no_bias_file)], types=["TGraph"] ) ) if options.zscan_bias_file else [] biases = getObjects( [self.open(options.bias_file)], types=["TGraph"] ) if options.bias_file else [] ## print bias_limits, no_bias_limits, bias_zscan, no_bias_zscan, biases print bias_zscans, no_bias_zscans, coups = map( lambda x: x.GetName().replace("expected_",""), bias_limits ) print coups common = [["SetLineStyle",0],["SetMarkerSize",1],["SetLineWidth",2]] styles = [ [["colors",ROOT.kRed],["SetMarkerStyle",ROOT.kFullCircle]], [["colors",ROOT.kBlue],["SetMarkerStyle",ROOT.kFullTriangleUp]], [["colors",ROOT.kGreen],["SetMarkerStyle",ROOT.kFullDiamond]], [["colors",ROOT.kGreen+1],["SetMarkerStyle",ROOT.kOpenDiamond]], ] for coup in coups: bias_limit = filter(lambda x: x.GetName().endswith("_%s" % coup), bias_limits ) no_bias_limit = filter(lambda x: x.GetName().endswith("_%s" % coup), no_bias_limits ) bias_zscan = filter(lambda x: x.GetName().startswith("%s_" % coup), bias_zscans ) no_bias_zscan = filter(lambda x: x.GetName().startswith("%s_" % coup), no_bias_zscans ) bias_terms = filter(lambda x: x.GetName().startswith("%s_" % coup), biases ) for g in bias_limit: g.SetTitle("expected limit bias") for g in no_bias_limit: g.SetTitle("expected limit no bias") for g in bias_zscan: g.SetTitle("expected #sigma #times BR (Z_{0}=3) bias") for g in no_bias_zscan: g.SetTitle("expected #sigma #times BR (Z_{0}=3) no bias") for g in bias_terms: g.SetTitle("bias term %s" % g.GetName().split("_")[-1]) print bias_zscan, no_bias_zscan if len(bias_limit) > 0: graphs = bias_limit+no_bias_limit+bias_terms map( lambda x: style_utils.apply(x[0],common+x[1]), zip(graphs,styles) ) canv = ROOT.TCanvas("limits_comparison_%s" % coup,"limits_comparison_%s" % coup) legend = ROOT.TLegend(0.5,0.6,0.8,0.9) legend.AddEntry(None,"#tilde{#kappa} = 0.%s" % coup[1:],"") ypoints = reduce( lambda x,y: x+y, map(lambda g: [g.GetY()[ip] for ip in xrange(g.GetN())], graphs ) ) ymin = min( ypoints ) ymax = max( ypoints ) graphs[0].Draw("al") graphs[0].GetYaxis().SetRangeUser(0.5*ymin,1.5*ymax) for g in graphs[1:]: g.Draw("l") for g in graphs: legend.AddEntry(g,g.GetTitle(),"l") legend.Draw() self.keep([canv,graphs,legend]) self.autosave(True) if len(bias_zscan) > 0: graphs = bias_zscan+no_bias_zscan+bias_terms map( lambda x: style_utils.apply(x[0],common+x[1]), zip(graphs,styles) ) canv = ROOT.TCanvas("zscans_comparison_%s" % coup,"zscans_comparison_%s" % coup) legend = ROOT.TLegend(0.5,0.6,0.8,0.9) legend.AddEntry(None,"#tilde{#kappa} = 0.%s" % coup[1:],"") ypoints = reduce( lambda x,y: x+y, map(lambda g: [g.GetY()[ip] for ip in xrange(g.GetN())], graphs ) ) ymin = min( ypoints ) ymax = max( ypoints ) graphs[0].Draw("al") graphs[0].GetYaxis().SetRangeUser(0.5*ymin,1.5*ymax) for g in graphs[1:]: g.Draw("l") for g in graphs: legend.AddEntry(g,g.GetTitle(),"l") legend.Draw() print canv self.keep([canv,graphs,legend]) self.autosave(True)
def compareExpectedLivia(self, options, isOrigSel, isChiara): #original selection tfile_boostchiaramet80_H = self.open( "ntuples4fit_newboostchiara_met80_cic_default_shapes_lumi_2.245/graphs_Asymptotic.root" ) tfile_boostchiaramet80_noH = self.open( "ntuples4fit_newboostchiara_met80_noH_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root" ) tfile_boostchiaramet80_nosyst = self.open( "ntuples4fit_newboostchiara_met80_noSyst_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root" ) #74X tfile_opt3_74X_H = self.open( "ntuples4fit_vtx0_OptSel3_74X_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root" ) tfile_opt4_74X_H = self.open( "ntuples4fit_vtx0_OptSel4_74X_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root" ) tfile_ABCD_opt1_74X = self.open( "ABCD_74X_OptSel1/graphs_Asymptotic.root") tfile_ABCD_opt2_74X = self.open( "ABCD_74X_OptSel2/graphs_Asymptotic.root") tfile_CC_opt2_74X = self.open( "ChiaraCC_74X_OptSel2/graphs_Asymptotic.root") tfile_CC_opt1_74X = self.open( "ChiaraCC_74X_OptSel1/graphs_Asymptotic.root") #76X tfile_opt3_76X_H = self.open( "ntuples4fit_vtx0_OptSel3_76X_cic_default_shapes_lumi_2.3/graphs_Asymptotic.root" ) tfile_opt4_76X_H = self.open( "ntuples4fit_vtx0_OptSel4_76X_cic_default_shapes_lumi_2.3/graphs_Asymptotic.root" ) tfile_ABCD_opt1_76X = self.open( "ABCD_76X_OptSel1/graphs_Asymptotic.root") tfile_ABCD_opt2_76X = self.open( "ABCD_76X_OptSel2/graphs_Asymptotic.root") tfile_ABCD_opt3_76X = self.open( "ABCD_76X_OptSel3/graphs_Asymptotic.root") tfile_CC_opt2_76X = self.open( "ChiaraCC_76X_OptSel2/graphs_Asymptotic.root") tfile_CC_opt1_76X = self.open( "ChiaraCC_76X_OptSel1/graphs_Asymptotic.root") tfile_LS_opt1_76X = self.open( "Livia_76X_OptSel1/graphs_Asymptotic.root") tfile_LS_opt1_76X_noSyst = self.open( "Livia_76X_OptSel1/graphs_Asymptotic.root") #76X hybridNew tfile_LS_opt1_76X_HybridNew = self.open("hybNew.root") gr_boostchiaramet80_H = tfile_boostchiaramet80_H.Get("expected_2HDM") gr_boostchiaramet80_noH = tfile_boostchiaramet80_noH.Get( "expected_2HDM") gr_boostchiaramet80_nosyst = tfile_boostchiaramet80_nosyst.Get( "expected_2HDM") gr_opt3_74X_H = tfile_opt3_74X_H.Get("expected_2HDM") gr_opt4_74X_H = tfile_opt4_74X_H.Get("expected_2HDM") gr_ABCD_opt1_74X = tfile_ABCD_opt1_74X.Get("expected_2HDM") gr_ABCD_opt2_74X = tfile_ABCD_opt2_74X.Get("expected_2HDM") gr_CC_opt2_74X = tfile_CC_opt2_74X.Get("expected_2HDM") gr_CC_opt1_74X = tfile_CC_opt1_74X.Get("expected_2HDM") gr_opt3_76X_H = tfile_opt3_76X_H.Get("expected_2HDM") gr_opt4_76X_H = tfile_opt4_76X_H.Get("expected_2HDM") gr_ABCD_opt1_76X = tfile_ABCD_opt1_76X.Get("expected_2HDM") gr_ABCD_opt2_76X = tfile_ABCD_opt2_76X.Get("expected_2HDM") gr_ABCD_opt3_76X = tfile_ABCD_opt3_76X.Get("expected_2HDM") gr_CC_opt2_76X = tfile_CC_opt2_76X.Get("expected_2HDM") gr_CC_opt1_76X = tfile_CC_opt1_76X.Get("expected_2HDM") gr_LS_opt1_76X = tfile_LS_opt1_76X.Get("expected_2HDM") gr_LS_opt1_76X_noSyst = tfile_LS_opt1_76X_noSyst.Get("expected_2HDM") gr_LS_opt1_76X_HybridNew = tfile_LS_opt1_76X_HybridNew.Get("Graph") unit = "fb" if options.use_fb else "pb" basicStyle = [ ["SetMarkerSize", 0.6], ["SetLineWidth", 3], [ "SetTitle", ";M_{Z`} (GeV);95%% C.L. #sigma(pp#rightarrow Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma ) (%s)" % unit ] ] expectedStyle = [["SetMarkerSize", 0]] + basicStyle style_utils.apply(gr_boostchiaramet80_H, [["colors", ROOT.kRed], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet80_noH, [["colors", ROOT.kBlue], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet80_nosyst, [["colors", ROOT.kOrange], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_opt3_74X_H, [["colors", ROOT.kRed], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_opt4_74X_H, [["colors", ROOT.kBlue], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_ABCD_opt1_74X, [["colors", ROOT.kMagenta], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_ABCD_opt2_74X, [["colors", ROOT.kOrange], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_CC_opt2_74X, [["colors", ROOT.kSpring + 9], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_CC_opt1_74X, [["colors", ROOT.kAzure + 7], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_opt3_76X_H, [["colors", ROOT.kRed], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_opt4_76X_H, [["colors", ROOT.kBlue], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_ABCD_opt1_76X, [["colors", ROOT.kMagenta], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_ABCD_opt2_76X, [["colors", ROOT.kOrange], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_ABCD_opt3_76X, [["colors", ROOT.kBlack], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_CC_opt2_76X, [["colors", ROOT.kSpring + 9], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_CC_opt1_76X, [["colors", ROOT.kAzure + 7], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_LS_opt1_76X, [["colors", ROOT.kAzure + 7], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_LS_opt1_76X_HybridNew, [["colors", ROOT.kMagenta], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_LS_opt1_76X_noSyst, [["colors", ROOT.kBlue], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) isH = True title = ROOT.TString() title = "Comparison_" isNewSel = False legend = ROOT.TLegend(0.19, 0.7, 0.79, 0.9) #show the effect of the resonant bkg # legend.AddEntry(gr_boostchiaramet80_H,"Adding the Higgs resonant background","l") # legend.AddEntry(gr_boostchiaramet80_noH,"Fitting only the non-resonant background","l") #show the effect of the syst #legend.AddEntry(gr_boostchiaramet80_H,"With systematic uncertainty","l") #legend.AddEntry(gr_boostchiaramet80_nosyst,"W/O systematic uncertainty","l") is74X = False isHremoval = False isSyst = False isOpts = True isRels = False isABCD = True #compare opt3 and opt4 if is74X and isOpts: legend.AddEntry(gr_ABCD_opt1_74X, "ABCD Option 1 74X", "l") # legend.AddEntry(gr_ABCD_opt2_74X,"ABCD Option 2 74X","l") legend.AddEntry(gr_CC_opt1_74X, "C&C Option 1 74X", "l") # legend.AddEntry(gr_CC_opt2_74X,"C&C Option 2 74X","l") legend.AddEntry(gr_opt3_74X_H, "Option 3 74X", "l") # legend.AddEntry(gr_opt4_74X_H,"Option 4 74X","l") if not is74X and isOpts: # legend.AddEntry(gr_opt3_76X_H,"FIT 76X","l") # legend.AddEntry(gr_ABCD_opt1_76X,"ABCD 76X","l") # legend.AddEntry(gr_ABCD_opt2_76X,"Option 2 76X","l") legend.AddEntry(gr_LS_opt1_76X, "Asymptotic", "l") legend.AddEntry(gr_LS_opt1_76X_HybridNew, "Full CLs", "l") # legend.AddEntry(gr_LS_opt1_76X_noSyst,"Mass Sidebands 76X w/o syst","l") # legend.AddEntry(gr_ABCD_opt3_76X,"ABCD Option 3 76X","l") # legend.AddEntry(gr_opt4_76X_H,"Option 4 76X","l") if isRels and isABCD: legend.AddEntry(gr_ABCD_opt1_74X, "ABCD Option 1 74X", "l") # legend.AddEntry(gr_ABCD_opt1_76X,"ABCD Option 1 76X","l") legend.AddEntry(gr_ABCD_opt2_74X, "ABCD Option 2 74X", "l") # legend.AddEntry(gr_ABCD_opt2_76X,"ABCD Option 2 76X","l") legend.AddEntry(gr_CC_opt1_74X, "C&C Option 1 74X", "l") legend.AddEntry(gr_CC_opt2_74X, "C&C Option 2 74X", "l") if isRels and not isABCD: legend.AddEntry(gr_opt3_74X_H, "Option 3 74X", "l") # legend.AddEntry(gr_opt3_76X_H,"Option 3 76X","l") legend.AddEntry(gr_opt4_74X_H, "Option 4 74X", "l") # legend.AddEntry(gr_opt4_76X_H,"Option 4 76X","l") if isOrigSel: title += "limits_pho" if not isOrigSel and not isChiara: title += "limits_boost" if not isOrigSel and isChiara: title += "limits_boostchiara" if not isOrigSel and isChiara and isHremoval: title += "limits_boostchiara_HremovalCheck" if not isOrigSel and isChiara and isSyst: title += "limits_boostchiara_SYSTremovalCheck" if not isOrigSel and isChiara and isOpts and is74X: title += "limits_OptsCheck_74X_wCC" if not isOrigSel and isChiara and isOpts and not is74X: title += "limits_OptsCheck_76X_Allsel_HybridNew" if not isOrigSel and isChiara and isRels and isABCD: title += "limits_RelsCheck_ABCD_74" if not isOrigSel and isChiara and isRels and not isABCD: title += "limits_RelsCheck_FIT_74" canv = ROOT.TCanvas(title, title) canv.SetLogx() # if isOrigSel and not hasMetCut and not lookAtmet: # if isOrigSel and hasMetCut and not lookAtmet: if not isOrigSel and isChiara and isH: gr_boostchiaramet80_H.Draw("APL") gr_boostchiaramet80_H.GetYaxis().SetRangeUser(2., 12.) if isHremoval: gr_boostchiaramet80_noH.Draw("PLsame") if isSyst: gr_boostchiaramet80_nosyst.Draw("PLsame") if not isOrigSel and isChiara and isOpts and is74X: gr_opt3_74X_H.Draw("APL") gr_opt3_74X_H.GetYaxis().SetRangeUser(0., 12.) gr_ABCD_opt1_74X.Draw("PLsame") # gr_ABCD_opt2_74X.Draw("PLsame") # gr_opt4_74X_H.Draw("PLsame") gr_CC_opt1_74X.Draw("PLsame") # gr_CC_opt2_74X.Draw("PLsame") if not isOrigSel and isChiara and isOpts and not is74X: # gr_opt3_76X_H.Draw("APL") # gr_opt3_76X_H.GetYaxis().SetRangeUser(0.,12.) #gr_ABCD_opt3_76X.Draw("PLsame") # gr_ABCD_opt1_76X.Draw("PLsame") # gr_CC_opt1_76X.Draw("PLsame") # gr_ABCD_opt2_76X.Draw("PLsame") # gr_opt4_76X_H.Draw("PLsame") gr_LS_opt1_76X.Draw("APL") gr_LS_opt1_76X_HybridNew.Draw("PLsame") # gr_LS_opt1_76X_noSyst.Draw("PLsame") gr_LS_opt1_76X.GetYaxis().SetRangeUser(0., 12.) if not isOrigSel and isChiara and isRels and not isABCD: gr_opt3_74X_H.Draw("APL") gr_opt3_74X_H.GetYaxis().SetRangeUser(0., 12.) # gr_opt3_76X_H.Draw("PLsame") # gr_opt4_76X_H.Draw("PLsame") gr_opt4_74X_H.Draw("PLsame") if not isOrigSel and isChiara and isRels and isABCD: # gr_ABCD_opt1_74X.Draw("APL") gr_LS_opt1_76X.Draw("APL") # gr_LS_opt1_76X_noSyst.Draw("PLsame") # gr_ABCD_opt1_74X.GetYaxis().SetRangeUser(0.,12.) # gr_CC_opt1_74X.Draw("PLsame") # gr_CC_opt2_74X.Draw("PLsame") # gr_ABCD_opt1_76X.Draw("PLsame") # gr_ABCD_opt2_74X.Draw("PLsame") # gr_ABCD_opt2_76X.Draw("PLsame") addCmsLumi(canv, 4, 1, "Simulation") self.keep(legend, True) #if not isH: legend.Draw() self.keep([canv, gr_opt4_74X_H]) self.format(canv, options.postproc)
def plotLimit(self, options, coup, tfile): ## TGraphAsymmErrors *theBand(TFile *file, int doSyst, int whichChannel, BandType type, double width=0.68) { tfile_xsecTheo = self.open("Signal_crossSections.root") tfile_gz08 = self.open("gz08_fbU.root") theo = tfile_xsecTheo.Get("xsec_2HDM") gz08 = tfile_gz08.Get("xsec_2HDM") if options.asimov_expected: ROOT.use_precomputed_quantiles = True bandType = ROOT.Median else: bandType = ROOT.Median expected68 = ROOT.theBand(tfile, 1, 0, bandType, 0.68) expected95 = ROOT.theBand(tfile, 1, 0, bandType, 0.95) observed = ROOT.theBand(tfile, 1, 0, ROOT.Observed, 0.95) # print expected68.GetN() # print expected95.GetN() unit = "fb" if options.use_fb else "pb" basicStyle = [ ["SetMarkerSize", 0.6], ["SetLineWidth", 3], [ "SetTitle", ";M_{Z`} (GeV);95%% C.L. #sigma(pp#rightarrow Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma ) (%s)" % unit ] ] commonStyle = [[self.scaleByXsec, coup], "Sort"] + basicStyle ## expectedStyle = commonStyle+[["SetMarkerStyle",ROOT.kOpenCircle]] expectedStyle = commonStyle + [["SetMarkerSize", 0]] observedStyle = commonStyle + [["SetMarkerStyle", ROOT.kFullCircle]] theoStyle = [["SetMarkerSize", 0]] + basicStyle style_utils.apply( theo, [["colors", ROOT.kRed], ["SetLineStyle", 5], ["SetName", "theo"]] + theoStyle) style_utils.apply(gz08, [["colors", ROOT.kBlue], ["SetLineStyle", 5], ["SetName", "theo"]] + theoStyle) style_utils.apply( expected68, [["colors", ROOT.kYellow], ["SetName", "expected68_%s" % coup]] + expectedStyle) style_utils.apply( expected95, [["colors", ROOT.kGreen], ["SetName", "expected95_%s" % coup]] + expectedStyle) expected = ROOT.TGraph(expected68) style_utils.apply(expected, [["colors", ROOT.kBlack], ["SetLineStyle", 7], ["SetName", "expected_%s" % coup]]) style_utils.apply(observed, [["SetName", "observed_%s" % coup]] + observedStyle) canv = ROOT.TCanvas("limits_k%s_mA0%s" % (coup, options.mA0), "limits_k%s_mA0%s" % (coup, options.mA0)) canv.SetLogx() canv.SetLogy() canv.SetGridx() canv.SetGridy() legend = ROOT.TLegend(0.2, 0.67, 0.8, 0.9) expected95.Draw("APE3") expected95.GetXaxis().SetRangeUser(600, 2550) expected95.GetYaxis().SetRangeUser(0.008, 200) expected95.GetXaxis().SetMoreLogLabels() expected68.Draw("E3PL") expected.Draw("PL") theo.Draw("PL") gz08.Draw("PL") #kappa = "0."+coup[1:] #legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") legend.SetHeader("Limits for 2HDM with mA0 = %s GeV" % options.mA0) legend.AddEntry(theo, "2HDM - g_{Z} constrained", "l") legend.AddEntry(gz08, "2HDM - g_{Z} = 0.8", "l") legend.AddEntry(expected, "Expected limit", "l") legend.AddEntry(expected68, " \pm 1 \sigma", "f") legend.AddEntry(expected95, " \pm 2 \sigma", "f") if options.unblind: observed.Draw("PL") ## observed.Draw("L") legend.AddEntry(observed, "Observed limit", "l") #if coup in self.xsections_: # grav = self.xsections_[coup] # style_utils.apply( grav, basicStyle+[["SetLineStyle",9],["colors",ROOT.myColorB2]] ) # grav.Draw("L") # legend.AddEntry(grav,"Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma","l").SetLineStyle(0) canv.RedrawAxis() self.keep(legend, True) legend.Draw() self.graphs.extend( [gz08, theo, observed, expected, expected68, expected95]) self.keep( [gz08, theo, canv, observed, expected, expected68, expected95]) self.format(canv, options.postproc)
def compareExpectedLivia(self, options, isOrigSel, isChiara): #original selection #tfile_pho_all=self.open("ntuples4fit_pho_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") tfile_phomet50_all = self.open( "ntuples4fit_pho_met50_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) tfile_phomet70_all = self.open( "ntuples4fit_pho_met70_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) tfile_phomet80_all = self.open( "ntuples4fit_pho_met80_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) #tfile_phoptgg80met80_all=self.open("ntuples4fit_phoptgg80met80_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") #tfile_pho_METCAT=self.open("ntuples4fit_phoMETcat50_80_cic_default_shapes_lumi_2.246_METCAT/graphs_Asymptotic.root") #look at boost selection #tfile_boost_all=self.open("ntuples4fit_boost_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") tfile_boostmet50_all = self.open( "ntuples4fit_boost_met50_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) tfile_boostmet70_all = self.open( "ntuples4fit_boost_met70_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) tfile_boostmet80_all = self.open( "ntuples4fit_boost_met80_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) #tfile_boostptgg80met80_all=self.open("ntuples4fit_boostptgg80met80_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") #tfile_boost_METCAT=self.open("ntuples4fit_boostMETcat50_80_cic_default_shapes_lumi_2.246_METCAT/graphs_Asymptotic.root") #look at boostm selection optimized #tfile_boostchiara_all=self.open("ntuples4fit_boostchiara_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") tfile_boostchiaramet50_all = self.open( "ntuples4fit_boostchiara_met50_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) tfile_boostchiaramet70_all = self.open( "ntuples4fit_boostchiara_met70_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) tfile_boostchiaramet80_all = self.open( "ntuples4fit_boostchiara_met80_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root" ) #tfile_boostchiaraptgg80met80_all=self.open("ntuples4fit_boostchiaraptgg80met80_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") #tfile_boostchiara_METCAT=self.open("ntuples4fit_boostchiaraMETcat50_80_cic_default_shapes_lumi_2.246_METCAT/graphs_Asymptotic.root") tfile_boostchiaramet80_H = self.open( "ntuples4fit_boostchiaramet80_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root" ) tfile_boostchiaramet80_noH = self.open( "ntuples4fit_boostchiaramet80_noH_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root" ) gr_phomet50_all = tfile_phomet50_all.Get("expected_2HDM") gr_phomet70_all = tfile_phomet70_all.Get("expected_2HDM") gr_phomet80_all = tfile_phomet80_all.Get("expected_2HDM") gr_boostmet50_all = tfile_boostmet50_all.Get("expected_2HDM") gr_boostmet70_all = tfile_boostmet70_all.Get("expected_2HDM") gr_boostmet80_all = tfile_boostmet80_all.Get("expected_2HDM") gr_boostchiaramet50_all = tfile_boostchiaramet50_all.Get( "expected_2HDM") gr_boostchiaramet70_all = tfile_boostchiaramet70_all.Get( "expected_2HDM") gr_boostchiaramet80_all = tfile_boostchiaramet80_all.Get( "expected_2HDM") gr_boostchiaramet80_H = tfile_boostchiaramet80_H.Get("expected_2HDM") gr_boostchiaramet80_noH = tfile_boostchiaramet80_noH.Get( "expected_2HDM") unit = "fb" if options.use_fb else "pb" basicStyle = [ ["SetMarkerSize", 0.6], ["SetLineWidth", 3], [ "SetTitle", ";M_{Z`} (GeV);95%% C.L. #sigma(pp#rightarrow Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma ) (%s)" % unit ] ] expectedStyle = [["SetMarkerSize", 0]] + basicStyle style_utils.apply(gr_phomet50_all, [["colors", ROOT.kPink - 8], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_phomet70_all, [["colors", ROOT.kPink + 2], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_phomet80_all, [["colors", ROOT.kRed - 7], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostmet50_all, [["colors", ROOT.kPink - 8], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostmet70_all, [["colors", ROOT.kPink + 2], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostmet80_all, [["colors", ROOT.kRed - 7], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet50_all, [["colors", ROOT.kPink - 8], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet70_all, [["colors", ROOT.kPink + 2], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet80_all, [["colors", ROOT.kRed - 7], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet80_H, [["colors", ROOT.kRed], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_boostchiaramet80_noH, [["colors", ROOT.kBlue], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) isH = True title = ROOT.TString() title = "Comparison_" isNewSel = False legend = ROOT.TLegend(0.2, 0.7, 0.9, 0.9) # legend.AddEntry(gr_pho_all,"All events ","l") # legend.AddEntry(gr_phomet50_all,"All events with MET > 50 GeV","l") # legend.AddEntry(gr_phomet70_all,"All events with MET > 70 GeV","l") #legend.AddEntry(gr_phomet80_all,"All events with MET > 80 GeV","l") # legend.AddEntry(gr_pho_METCAT,"Comb. MET in [50-80] and MET> 80 GeV","l") #legend.AddEntry(gr_phoptgg80met80_all,"All events with MET > 80 GeV and pT > 80 GeV","l") #legend_H = ROOT.TLegend(0.2,0.7,0.9,0.9) legend.AddEntry(gr_boostchiaramet80_H, "Adding the Higgs resonant background", "l") legend.AddEntry(gr_boostchiaramet80_noH, "Fitting only the non-resonant background", "l") if isOrigSel: title += "limits_pho" if not isOrigSel and not isChiara: title += "limits_boost" if not isOrigSel and isChiara: title += "limits_boostchiara" if not isOrigSel and isChiara and isH: title += "limits_boostchiara_HremovalCheck" canv = ROOT.TCanvas(title, title) canv.SetLogx() # if isOrigSel and not hasMetCut and not lookAtmet: # if isOrigSel and hasMetCut and not lookAtmet: if isOrigSel: gr_phomet80_all.Draw("APL") gr_phomet80_all.GetYaxis().SetRangeUser(0., 40.) gr_phomet50_all.Draw("PLsame") gr_phomet70_all.Draw("PLsame") if not isOrigSel and not isChiara: gr_boostmet80_all.Draw("APL") gr_boostmet80_all.GetYaxis().SetRangeUser(0., 40.) gr_boostmet50_all.Draw("PLsame") gr_boostmet70_all.Draw("PLsame") if not isOrigSel and isChiara: gr_boostchiaramet80_all.Draw("APL") gr_boostchiaramet80_all.GetYaxis().SetRangeUser(0., 40.) gr_boostchiaramet50_all.Draw("PLsame") gr_boostchiaramet70_all.Draw("PLsame") if not isOrigSel and isChiara and isH: gr_boostchiaramet80_H.Draw("APL") gr_boostchiaramet80_H.GetYaxis().SetRangeUser(0., 15.) gr_boostchiaramet80_noH.Draw("PLsame") self.keep(legend, True) #if not isH: legend.Draw() self.keep( [canv, gr_phomet80_all] ) #,gr_phomet50_all, gr_phomet50_4CAT,gr_newSel_all, gr_newSel_4CAT,gr_newSelmet50_all, gr_newSelmet50_4CAT] ) self.format(canv, options.postproc)
def analyzeBias(self,options,args): summary = {} ROOT.gStyle.SetOptStat(1111) ROOT.gStyle.SetOptFit(1) profiles = {} bprofiles = {} cprofiles = {} xfirst = 1e5 xlast = 0. for fname,label in zip(options.bias_files,options.bias_labels): fin = self.open(fname) for key in ROOT.TIter(fin.GetListOfKeys()): name = key.GetName() if name.startswith("tree_bias"): toks = name.split("_",5)[2:] print toks ## ['pp', 'EBEB', 'dijet', 'testRange_2500_3500'] comp,cat,model,rng = toks tree = key.ReadObj() toks.append(label) nlabel = "_".join(toks) slabel = "_".join([cat,model,label]) bias_func = None print slabel print options.bias_param.keys() if slabel in options.bias_param: bias_func = ROOT.TF1("err_correction",options.bias_param[slabel],0,2e+6) ## bias_func.Print() if not slabel in profiles: profile = ROOT.TGraphErrors() bprofile = ROOT.TGraphErrors() profiles[slabel] = profile bprofiles[slabel] = bprofile self.keep( [profile,bprofile] ) if bias_func: cprofile = ROOT.TGraphErrors() cprofiles[slabel] = cprofile self.keep( [cprofile] ) else: profile = profiles[slabel] bprofile = bprofiles[slabel] if bias_func: cprofile = cprofiles[slabel] xmin,xmax = [float(t) for t in rng.split("_")[1:]] xfirst = min(xmin,xfirst) xlast = max(xmax,xlast) ibin = profile.GetN() tree.Draw("bias>>h_bias_%s(50,-4.005,4.005)" % nlabel) hb = ROOT.gDirectory.Get("h_bias_%s" % nlabel ) hb.Fit("gaus","L+Q") canv = ROOT.TCanvas(nlabel,nlabel) canv.cd() hb.Draw() self.keep( [canv,hb] ) self.autosave(True) gaus = hb.GetListOfFunctions().At(0) prb = array.array('d',[0.5]) med = array.array('d',[0.]) hb.GetQuantiles(len(prb),med,prb) tree.Draw("abs(bias)>>h_coverage_%s(501,0,5.01)" % nlabel ) hc = ROOT.gDirectory.Get("h_coverage_%s" % nlabel ) prb = array.array('d',[0.683]) qtl = array.array('d',[0.]) hc.GetQuantiles(len(prb),qtl,prb) tree.Draw("fit-truth>>h_deviation_%s(501,-100.2,100.2)" % nlabel ) hd = ROOT.gDirectory.Get("h_deviation_%s" % ("_".join(toks))) hd.Fit("gaus","L+Q") gausd = hd.GetListOfFunctions().At(0) medd = array.array('d',[0.]) hd.GetQuantiles(len(prb),medd,prb) profile.SetPoint(ibin,0.5*(xmax+xmin),abs(medd[0])/(xmax-xmin)) ## profile.SetPoint(ibin,0.5*(xmax+xmin),abs(medd[0])) profile.SetPointError(ibin,0.5*(xmax-xmin),0.) ## bprofile.SetPoint(ibin,0.5*(xmax+xmin),med[0]) bprofile.SetPoint(ibin,0.5*(xmax+xmin),gaus.GetParameter(1)/(gaus.GetParameter(2))) bprofile.SetPointError(ibin,0.5*(xmax-xmin),0.) tree.GetEntry(0) summary[nlabel] = [ gaus.GetParameter(1), gaus.GetParError(1), gaus.GetParameter(2), gaus.GetParError(2), med[0], qtl[0], gausd.GetParameter(1), gausd.GetParError(1), medd[0], medd[0]/med[0], tree.truth ] if bias_func: tree.SetAlias("berr","(fit-truth)/bias*%f" % max(1.,gaus.GetParameter(2))) ## tree.SetAlias("berr","%f+0." % max(1.,gaus.GetParameter(2))) tree.SetAlias("corr_bias","(fit-truth)/sqrt(berr^2+%f^2)" % (bias_func.Integral(xmin,xmax)*options.scale_bias) ) tree.Draw("corr_bias>>h_corr_bias_%s(501,-5.005,5.005)" % nlabel ) hc = ROOT.gDirectory.Get("h_corr_bias_%s" % nlabel ) hc.Fit("gaus","L+Q") hc.Print() gausc = hc.GetListOfFunctions().At(0) medc = array.array('d',[0.]) hc.GetQuantiles(len(prb),medc,prb) cprofile.SetPoint(ibin,0.5*(xmax+xmin),gausc.GetParameter(1)) cprofile.SetPointError(ibin,0.5*(xmax-xmin),0.) summary[nlabel].extend( [medc[0], gausc.GetParameter(1), gausc.GetParameter(2)] ) ### styles = [ [ (style_utils.colors,ROOT.kBlack) ], [ (style_utils.colors,ROOT.kRed) ], ### [ (style_utils.colors,ROOT.kBlue) ], [ (style_utils.colors,ROOT.kGreen+1) ], ### [ (style_utils.colors,ROOT.kOrange) ], [ (style_utils.colors,ROOT.kMagenta+1) ] ### ] colors = [ ROOT.kRed, ROOT.kBlue, ROOT.kGreen+1, ROOT.kOrange, ROOT.kCyan, ROOT.kMagenta, ROOT.kYellow, ROOT.kGray ] markers = [ROOT.kFullCircle,ROOT.kOpenCircle,ROOT.kCyan, ROOT.kMagenta, ROOT.kYellow, ROOT.kGray ] styles = [] keys = sorted(bprofiles.keys()) nfuncs = len(options.bias_labels) ncat = len(keys) / nfuncs for icat in range(ncat): for ifunc in range(nfuncs): styles.append( [ (style_utils.colors,colors[ifunc%len(colors)]+icat), ("SetMarkerStyle",markers[icat % len(markers)]) ] ) ROOT.gStyle.SetOptFit(0) canv = ROOT.TCanvas("profile_bias","profile_bias") canv.SetLogx() canv.SetLogy() canv.SetGridy() leg = ROOT.TLegend(0.6,0.6,0.9,0.9) leg.SetFillStyle(0) profiles[keys[0]].GetXaxis().SetRangeUser(xfirst,xlast) bprofiles[keys[0]].GetXaxis().SetRangeUser(xfirst,xlast) ckeys = sorted(cprofiles.keys()) print ckeys if len(ckeys) > 0: cprofiles[ckeys[0]].GetXaxis().SetRangeUser(xfirst,xlast) first = True cstyles = copy(styles) fits = [] ## for key,profile in profiles.iteritems(): for key in keys: profile = profiles[key] profile.Sort() profile.Print() style = cstyles.pop(0) ## ## func = ROOT.TF1("bfunc","(x>[0])*( [1]/([0]+x)+[2] )") ## func = ROOT.TF1("bfunc","[0]*pow(x/%f,[1])+[2]"% max(600,xfirst),max(600,xfirst),xlast) ## # func.SetParameters(300.,1.,1.e-3) ## func.SetParameters(1.e-2,-4,1.e-5) ## profile.Fit(func,"R+") ## fit = profile.GetListOfFunctions().At(0) ## fits.append([key,fit]) if key in options.bias_param: bias_func = ROOT.TF1("err_correction_%s" % key,options.bias_param[key],xfirst,xlast) style_utils.apply( bias_func, style[:1] ) bias_func.Draw("same") self.keep(bias_func) style_utils.apply( profile, style ) leg.AddEntry(profile,key,"pe") if first: profile.Draw("AP") profile.GetXaxis().SetMoreLogLabels() profile.GetXaxis().SetTitle("mass") ## profile.GetYaxis().SetRangeUser(0.001,0.3) profile.GetYaxis().SetRangeUser(0.00001,0.2) ## profile.GetYaxis().SetRangeUser(0.,6.) profile.GetYaxis().SetTitle("| n_{fit} - n_{true} | / GeV") ## profile.GetYaxis().SetTitle("| n_{fit} - n_{true} |") first = False else: profile.Draw("P") ## fit.Draw("same") leg.Draw("same") bcanv = ROOT.TCanvas("profile_pull","profile_pull") # bcanv.SetLogx() bcanv.SetGridy() bcanv.SetGridx() bleg = ROOT.TLegend(0.2,0.12,0.6,0.32) bleg.SetFillStyle(0) first = True cstyles = copy(styles) frame = ROOT.TH2F("frame","frame",100,xfirst,xlast,100,-5,5); frame.SetStats(False) frame.Draw() frame.GetYaxis().SetRangeUser(-2.,2.) frame.GetXaxis().SetTitle("mass") frame.GetXaxis().SetMoreLogLabels() frame.GetYaxis().SetTitle("( n_{fit} - n_{true} )/ \sigma_{fit}") box = ROOT.TBox(xfirst,-0.5,xlast,0.5) ## box.SetFillColorAlpha(ROOT.kGray,0.1) box.SetFillColor(ROOT.kGray) box.Draw("same") self.keep([frame,box]) for key in keys: profile = bprofiles[key] profile.Sort() style_utils.apply( profile, cstyles.pop(0) ) print key key2=key.replace("all_pow_","") key2+=" GeV" print key2 bleg.AddEntry(profile,key2,"pe") profile.Draw("P") bleg.Draw("same") bcanv.RedrawAxis() bcanv.Modified() bcanv.Update() self.keep( [canv,leg,bcanv,bleg#,box ] ) if len(ckeys) > 0: ccanv = ROOT.TCanvas("profile_corr_pull","profile_corr_pull") ccanv.SetLogx() ccanv.SetGridy() ccanv.SetGridx() cleg = ROOT.TLegend(0.2,0.12,0.6,0.52) cleg.SetFillStyle(0) first = True cstyles = copy(styles) cframe = ROOT.TH2F("cframe","cframe",100,xfirst,xlast,100,-3,2); cframe.SetStats(False) cframe.Draw() cframe.GetXaxis().SetTitle("mass") cframe.GetXaxis().SetMoreLogLabels() cframe.GetYaxis().SetTitle("( n_{fit} - n_{true} )/ ( \sigma_{fit} \oplus bias )") box.Draw("same") self.keep([cframe]) for key in ckeys: profile = cprofiles[key] profile.Sort() style_utils.apply( profile, cstyles.pop(0) ) cleg.AddEntry(profile,key,"pe") profile.Draw("P") cleg.Draw("same") ccanv.RedrawAxis() ccanv.Modified() ccanv.Update() self.keep( [ccanv,cleg] ) self.autosave(True) keys = sorted(summary.keys()) maxl = 0 for key in keys: maxl = max(len(key),maxl) summarystr = "" for name,fit in fits: summarystr += "%s %s\n" % ( name, fit.GetExpFormula("p") ) summarystr += "test region".ljust(maxl+3) for field in ["pmean","err","psig","err","pmedian","p68","bmean","err","bmedian","smedian","truth","corr_bmedian","corr_bmean","corr_bsigma"]: summarystr += field.rjust(9) summarystr += "\n" for key in keys: val = summary[key] summarystr += ("%s, " % key).ljust(maxl+3) for v in val: summarystr += ("%1.3g," %v).rjust(9) summarystr += "\n" print summarystr summaryf = open("%s/README.txt" % options.outdir,"w+") summaryf.write(summarystr) summaryf.close()
def plotLimit(self, options, coup, tfile): ## TGraphAsymmErrors *theBand(TFile *file, int doSyst, int whichChannel, BandType type, double width=0.68) { tfile_xsecTheo = self.open("theory_Zbaryonic_mZ1000.root") # tfile_xsecTheo=self.open("theory_Zbaryonic_mZ1000") theo = tfile_xsecTheo.Get("Graph") if options.asimov_expected: ROOT.use_precomputed_quantiles = True bandType = ROOT.Median else: bandType = ROOT.Median expected68Orig = ROOT.theBand(tfile, 1, 0, bandType, 0.68) expected95Orig = ROOT.theBand(tfile, 1, 0, bandType, 0.95) observed = ROOT.theBand(tfile, 1, 0, ROOT.Observed, 0.95) print "-------------------------------------------------------", observed.GetN( ) # print expected68.GetN() # print expected95.GetN() expected68 = scaleGraphLivia(expected68Orig, 2) expected95 = scaleGraphLivia(expected95Orig, 2) unit = "fb" if options.use_fb else "pb" basicStyle = [ ["SetMarkerSize", 0.6], ["SetLineWidth", 3], [ "SetTitle", ";M_{Z`} (GeV);95%% C.L. #sigma(pp#rightarrow Z'_{B}H #rightarrow#chi#chi#gamma#gamma ) (%s)" % unit ] ] commonStyle = [[self.scaleByXsec, coup], "Sort"] + basicStyle ## expectedStyle = commonStyle+[["SetMarkerStyle",ROOT.kOpenCircle]] expectedStyle = commonStyle + [["SetMarkerSize", 0]] observedStyle = commonStyle + [["SetMarkerStyle", ROOT.kFullCircle]] theoStyle = [["SetMarkerSize", 0]] + basicStyle style_utils.apply(theo, [["colors", ROOT.kBlue], ["SetLineStyle", 5], ["SetName", "theo"]] + theoStyle) # style_utils.apply( gz08, [["colors",ROOT.kBlue],["SetLineStyle",5],["SetName","theo"]]+theoStyle ) style_utils.apply( expected68, [["colors", ROOT.kYellow], ["SetName", "expected68_%s" % coup]] + expectedStyle) style_utils.apply( expected95, [["colors", ROOT.kGreen], ["SetName", "expected95_%s" % coup]] + expectedStyle) expected = ROOT.TGraph(expected68) style_utils.apply(expected, [["colors", ROOT.kBlack], ["SetLineStyle", 7], ["SetName", "expected_%s" % coup]]) style_utils.apply(observed, [["SetName", "observed_%s" % coup]] + observedStyle) canv = ROOT.TCanvas("limits_ZPBaryonic_mZP%s" % options.mZP, "limits_ZPBaryonic_mZP%s" % options.mZP) canv.SetLogx() canv.SetLogy() canv.SetGridx() canv.SetGridy() legend = ROOT.TLegend(0.35, 0.65, 0.75, 0.9) expected95.Draw("APE3") expected95.GetXaxis().SetRangeUser(600, 2550) expected95.GetYaxis().SetRangeUser(0.0001, 500) expected95.GetXaxis().SetMoreLogLabels() expected68.Draw("E3PL") expected.Draw("PL") theo.Draw("PL") #kappa = "0."+coup[1:] #legend.AddEntry(None,"#tilde{#kappa} = %s" % kappa,"") legend.AddEntry(theo, "Z' baryonic - g_{q} = 0.25", "l") # legend.AddEntry(,"Z' baryonic - g_{q} = 0.25","l") legend.AddEntry(expected, "Expected limit", "l") legend.AddEntry(expected68, " \pm 1 \sigma", "f") legend.AddEntry(expected95, " \pm 2 \sigma", "f") #if options.unblind: #observed.Draw("PL") observed.Draw("PL") legend.AddEntry(observed, "Observed limit", "l") #if coup in self.xsections_: # grav = self.xsections_[coup] # style_utils.apply( grav, basicStyle+[["SetLineStyle",9],["colors",ROOT.myColorB2]] ) # grav.Draw("L") # legend.AddEntry(grav,"Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma","l").SetLineStyle(0) canv.RedrawAxis() self.keep(legend, True) legend.Draw() self.graphs.extend([theo, observed, expected, expected68, expected95]) self.keep([theo, canv, observed, expected, expected68, expected95]) print "bbb" self.format(canv, options.postproc)
def analyzeBias(self, options, args): summary = {} ROOT.gStyle.SetOptStat(1111) ROOT.gStyle.SetOptFit(1) profiles = {} bprofiles = {} cprofiles = {} xfirst = 1e5 xlast = 0. for fname, label in zip(options.bias_files, options.bias_labels): fin = self.open(fname) for key in ROOT.TIter(fin.GetListOfKeys()): name = key.GetName() if name.startswith("tree_bias"): toks = name.split("_", 5)[2:] print toks ## ['pp', 'EBEB', 'dijet', 'testRange_2500_3500'] comp, cat, model, rng = toks tree = key.ReadObj() toks.append(label) nlabel = "_".join(toks) slabel = "_".join([cat, model, label]) bias_func = None print slabel print options.bias_param.keys() if slabel in options.bias_param: bias_func = ROOT.TF1("err_correction", options.bias_param[slabel], 0, 2e+6) ## bias_func.Print() if not slabel in profiles: profile = ROOT.TGraphErrors() bprofile = ROOT.TGraphErrors() profiles[slabel] = profile bprofiles[slabel] = bprofile self.keep([profile, bprofile]) if bias_func: cprofile = ROOT.TGraphErrors() cprofiles[slabel] = cprofile self.keep([cprofile]) else: profile = profiles[slabel] bprofile = bprofiles[slabel] if bias_func: cprofile = cprofiles[slabel] xmin, xmax = [float(t) for t in rng.split("_")[1:]] xfirst = min(xmin, xfirst) xlast = max(xmax, xlast) ibin = profile.GetN() tree.Draw("bias>>h_bias_%s(501,-5.005,5.005)" % nlabel) hb = ROOT.gDirectory.Get("h_bias_%s" % nlabel) hb.Fit("gaus", "L+Q") canv = ROOT.TCanvas(nlabel, nlabel) canv.cd() hb.Draw() self.keep([canv, hb]) self.autosave(True) gaus = hb.GetListOfFunctions().At(0) prb = array.array('d', [0.5]) med = array.array('d', [0.]) hb.GetQuantiles(len(prb), med, prb) tree.Draw("abs(bias)>>h_coverage_%s(501,0,5.01)" % nlabel) hc = ROOT.gDirectory.Get("h_coverage_%s" % nlabel) prb = array.array('d', [0.683]) qtl = array.array('d', [0.]) hc.GetQuantiles(len(prb), qtl, prb) tree.Draw("fit-truth>>h_deviation_%s(501,-100.2,100.2)" % nlabel) hd = ROOT.gDirectory.Get("h_deviation_%s" % ("_".join(toks))) hd.Fit("gaus", "L+Q") gausd = hd.GetListOfFunctions().At(0) medd = array.array('d', [0.]) hd.GetQuantiles(len(prb), medd, prb) profile.SetPoint(ibin, 0.5 * (xmax + xmin), abs(medd[0]) / (xmax - xmin)) ## profile.SetPoint(ibin,0.5*(xmax+xmin),abs(medd[0])) profile.SetPointError(ibin, 0.5 * (xmax - xmin), 0.) ## bprofile.SetPoint(ibin,0.5*(xmax+xmin),med[0]) bprofile.SetPoint( ibin, 0.5 * (xmax + xmin), gaus.GetParameter(1) / (gaus.GetParameter(2))) bprofile.SetPointError(ibin, 0.5 * (xmax - xmin), 0.) tree.GetEntry(0) summary[nlabel] = [ gaus.GetParameter(1), gaus.GetParError(1), gaus.GetParameter(2), gaus.GetParError(2), med[0], qtl[0], gausd.GetParameter(1), gausd.GetParError(1), medd[0], medd[0] / med[0], tree.truth ] if bias_func: tree.SetAlias( "berr", "(fit-truth)/bias*%f" % max(1., gaus.GetParameter(2))) ## tree.SetAlias("berr","%f+0." % max(1.,gaus.GetParameter(2))) tree.SetAlias( "corr_bias", "(fit-truth)/sqrt(berr^2+%f^2)" % (bias_func.Integral(xmin, xmax) * options.scale_bias)) tree.Draw( "corr_bias>>h_corr_bias_%s(501,-5.005,5.005)" % nlabel) hc = ROOT.gDirectory.Get("h_corr_bias_%s" % nlabel) hc.Fit("gaus", "L+Q") hc.Print() gausc = hc.GetListOfFunctions().At(0) medc = array.array('d', [0.]) hc.GetQuantiles(len(prb), medc, prb) cprofile.SetPoint(ibin, 0.5 * (xmax + xmin), gausc.GetParameter(1)) cprofile.SetPointError(ibin, 0.5 * (xmax - xmin), 0.) summary[nlabel].extend([ medc[0], gausc.GetParameter(1), gausc.GetParameter(2) ]) ### styles = [ [ (style_utils.colors,ROOT.kBlack) ], [ (style_utils.colors,ROOT.kRed) ], ### [ (style_utils.colors,ROOT.kBlue) ], [ (style_utils.colors,ROOT.kGreen+1) ], ### [ (style_utils.colors,ROOT.kOrange) ], [ (style_utils.colors,ROOT.kMagenta+1) ] ### ] colors = [ ROOT.kRed, ROOT.kBlue, ROOT.kGreen + 1, ROOT.kOrange, ROOT.kCyan, ROOT.kMagenta, ROOT.kYellow, ROOT.kGray ] markers = [ ROOT.kFullCircle, ROOT.kOpenCircle, ROOT.kCyan, ROOT.kMagenta, ROOT.kYellow, ROOT.kGray ] styles = [] keys = sorted(bprofiles.keys()) nfuncs = len(options.bias_labels) ncat = len(keys) / nfuncs for icat in range(ncat): for ifunc in range(nfuncs): styles.append([ (style_utils.colors, colors[ifunc % len(colors)] + icat), ("SetMarkerStyle", markers[icat % len(markers)]) ]) ROOT.gStyle.SetOptFit(0) canv = ROOT.TCanvas("profile_bias", "profile_bias") canv.SetLogx() canv.SetLogy() canv.SetGridy() leg = ROOT.TLegend(0.6, 0.6, 0.9, 0.9) leg.SetFillStyle(0) profiles[keys[0]].GetXaxis().SetRangeUser(xfirst, xlast) bprofiles[keys[0]].GetXaxis().SetRangeUser(xfirst, xlast) ckeys = sorted(cprofiles.keys()) print ckeys if len(ckeys) > 0: cprofiles[ckeys[0]].GetXaxis().SetRangeUser(xfirst, xlast) first = True cstyles = copy(styles) fits = [] ## for key,profile in profiles.iteritems(): for key in keys: profile = profiles[key] profile.Sort() profile.Print() style = cstyles.pop(0) ## ## func = ROOT.TF1("bfunc","(x>[0])*( [1]/([0]+x)+[2] )") ## func = ROOT.TF1("bfunc","[0]*pow(x/%f,[1])+[2]"% max(600,xfirst),max(600,xfirst),xlast) ## # func.SetParameters(300.,1.,1.e-3) ## func.SetParameters(1.e-2,-4,1.e-5) ## profile.Fit(func,"R+") ## fit = profile.GetListOfFunctions().At(0) ## fits.append([key,fit]) if key in options.bias_param: bias_func = ROOT.TF1("err_correction_%s" % key, options.bias_param[key], xfirst, xlast) style_utils.apply(bias_func, style[:1]) bias_func.Draw("same") self.keep(bias_func) style_utils.apply(profile, style) leg.AddEntry(profile, key, "pe") if first: profile.Draw("AP") profile.GetXaxis().SetMoreLogLabels() profile.GetXaxis().SetTitle("mass") ## profile.GetYaxis().SetRangeUser(0.001,0.3) profile.GetYaxis().SetRangeUser(0.00001, 0.2) ## profile.GetYaxis().SetRangeUser(0.,6.) profile.GetYaxis().SetTitle("| n_{fit} - n_{true} | / GeV") ## profile.GetYaxis().SetTitle("| n_{fit} - n_{true} |") first = False else: profile.Draw("P") ## fit.Draw("same") leg.Draw("same") bcanv = ROOT.TCanvas("profile_pull", "profile_pull") bcanv.SetLogx() bcanv.SetGridy() bcanv.SetGridx() bleg = ROOT.TLegend(0.2, 0.12, 0.6, 0.52) bleg.SetFillStyle(0) first = True cstyles = copy(styles) frame = ROOT.TH2F("frame", "frame", 100, xfirst, xlast, 100, -3, 2) frame.SetStats(False) frame.Draw() frame.GetXaxis().SetTitle("mass") frame.GetXaxis().SetMoreLogLabels() frame.GetYaxis().SetTitle("( n_{fit} - n_{true} )/ \sigma_{fit}") box = ROOT.TBox(xfirst, -0.5, xlast, 0.5) ## box.SetFillColorAlpha(ROOT.kGray,0.1) box.SetFillColor(ROOT.kGray) box.Draw("same") self.keep([frame, box]) for key in keys: profile = bprofiles[key] profile.Sort() style_utils.apply(profile, cstyles.pop(0)) bleg.AddEntry(profile, key, "pe") profile.Draw("P") bleg.Draw("same") bcanv.RedrawAxis() bcanv.Modified() bcanv.Update() self.keep([ canv, leg, bcanv, bleg #,box ]) if len(ckeys) > 0: ccanv = ROOT.TCanvas("profile_corr_pull", "profile_corr_pull") ccanv.SetLogx() ccanv.SetGridy() ccanv.SetGridx() cleg = ROOT.TLegend(0.2, 0.12, 0.6, 0.52) cleg.SetFillStyle(0) first = True cstyles = copy(styles) cframe = ROOT.TH2F("cframe", "cframe", 100, xfirst, xlast, 100, -3, 2) cframe.SetStats(False) cframe.Draw() cframe.GetXaxis().SetTitle("mass") cframe.GetXaxis().SetMoreLogLabels() cframe.GetYaxis().SetTitle( "( n_{fit} - n_{true} )/ ( \sigma_{fit} \oplus bias )") box.Draw("same") self.keep([cframe]) for key in ckeys: profile = cprofiles[key] profile.Sort() style_utils.apply(profile, cstyles.pop(0)) cleg.AddEntry(profile, key, "pe") profile.Draw("P") cleg.Draw("same") ccanv.RedrawAxis() ccanv.Modified() ccanv.Update() self.keep([ccanv, cleg]) self.autosave(True) keys = sorted(summary.keys()) maxl = 0 for key in keys: maxl = max(len(key), maxl) summarystr = "" for name, fit in fits: summarystr += "%s %s\n" % (name, fit.GetExpFormula("p")) summarystr += "test region".ljust(maxl + 3) for field in [ "pmean", "err", "psig", "err", "pmedian", "p68", "bmean", "err", "bmedian", "smedian", "truth", "corr_bmedian", "corr_bmean", "corr_bsigma" ]: summarystr += field.rjust(9) summarystr += "\n" for key in keys: val = summary[key] summarystr += ("%s, " % key).ljust(maxl + 3) for v in val: summarystr += ("%1.3g," % v).rjust(9) summarystr += "\n" print summarystr summaryf = open("%s/README.txt" % options.outdir, "w+") summaryf.write(summarystr) summaryf.close()
def compareExpectedLivia(self,options, isOrigSel, isChiara): #original selection #tfile_pho_all=self.open("ntuples4fit_pho_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") tfile_phomet50_all=self.open("ntuples4fit_pho_met50_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") tfile_phomet70_all=self.open("ntuples4fit_pho_met70_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") tfile_phomet80_all=self.open("ntuples4fit_pho_met80_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") #tfile_phoptgg80met80_all=self.open("ntuples4fit_phoptgg80met80_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") #tfile_pho_METCAT=self.open("ntuples4fit_phoMETcat50_80_cic_default_shapes_lumi_2.246_METCAT/graphs_Asymptotic.root") #look at boost selection #tfile_boost_all=self.open("ntuples4fit_boost_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") tfile_boostmet50_all=self.open("ntuples4fit_boost_met50_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") tfile_boostmet70_all=self.open("ntuples4fit_boost_met70_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") tfile_boostmet80_all=self.open("ntuples4fit_boost_met80_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") #tfile_boostptgg80met80_all=self.open("ntuples4fit_boostptgg80met80_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") #tfile_boost_METCAT=self.open("ntuples4fit_boostMETcat50_80_cic_default_shapes_lumi_2.246_METCAT/graphs_Asymptotic.root") #look at boostm selection optimized #tfile_boostchiara_all=self.open("ntuples4fit_boostchiara_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") tfile_boostchiaramet50_all=self.open("ntuples4fit_boostchiara_met50_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") tfile_boostchiaramet70_all=self.open("ntuples4fit_boostchiara_met70_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") tfile_boostchiaramet80_all=self.open("ntuples4fit_boostchiara_met80_cic_default_shapes_lumi_2.245_All/graphs_Asymptotic.root") #tfile_boostchiaraptgg80met80_all=self.open("ntuples4fit_boostchiaraptgg80met80_cic_default_shapes_lumi_2.246_All/graphs_Asymptotic.root") #tfile_boostchiara_METCAT=self.open("ntuples4fit_boostchiaraMETcat50_80_cic_default_shapes_lumi_2.246_METCAT/graphs_Asymptotic.root") tfile_boostchiaramet80_H=self.open("ntuples4fit_boostchiaramet80_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root") tfile_boostchiaramet80_noH=self.open("ntuples4fit_boostchiaramet80_noH_cic_default_shapes_lumi_2.246/graphs_Asymptotic.root") gr_phomet50_all=tfile_phomet50_all.Get("expected_2HDM") gr_phomet70_all=tfile_phomet70_all.Get("expected_2HDM") gr_phomet80_all=tfile_phomet80_all.Get("expected_2HDM") gr_boostmet50_all=tfile_boostmet50_all.Get("expected_2HDM") gr_boostmet70_all=tfile_boostmet70_all.Get("expected_2HDM") gr_boostmet80_all=tfile_boostmet80_all.Get("expected_2HDM") gr_boostchiaramet50_all=tfile_boostchiaramet50_all.Get("expected_2HDM") gr_boostchiaramet70_all=tfile_boostchiaramet70_all.Get("expected_2HDM") gr_boostchiaramet80_all=tfile_boostchiaramet80_all.Get("expected_2HDM") gr_boostchiaramet80_H=tfile_boostchiaramet80_H.Get("expected_2HDM") gr_boostchiaramet80_noH=tfile_boostchiaramet80_noH.Get("expected_2HDM") unit = "fb" if options.use_fb else "pb" basicStyle = [["SetMarkerSize",0.6],["SetLineWidth",3], ["SetTitle",";M_{Z`} (GeV);95%% C.L. #sigma(pp#rightarrow Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma ) (%s)" % unit]] expectedStyle = [["SetMarkerSize",0]]+basicStyle style_utils.apply( gr_phomet50_all, [["colors",ROOT.kPink-8],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_phomet70_all, [["colors",ROOT.kPink+2],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_phomet80_all, [["colors",ROOT.kRed-7],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostmet50_all, [["colors",ROOT.kPink-8],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostmet70_all, [["colors",ROOT.kPink+2],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostmet80_all, [["colors",ROOT.kRed-7],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostchiaramet50_all, [["colors",ROOT.kPink-8],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostchiaramet70_all, [["colors",ROOT.kPink+2],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostchiaramet80_all, [["colors",ROOT.kRed-7],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostchiaramet80_H, [["colors",ROOT.kRed],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply( gr_boostchiaramet80_noH, [["colors",ROOT.kBlue],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) isH=True title=ROOT.TString() title="Comparison_" isNewSel=False legend = ROOT.TLegend(0.2,0.7,0.9,0.9) # legend.AddEntry(gr_pho_all,"All events ","l") # legend.AddEntry(gr_phomet50_all,"All events with MET > 50 GeV","l") # legend.AddEntry(gr_phomet70_all,"All events with MET > 70 GeV","l") #legend.AddEntry(gr_phomet80_all,"All events with MET > 80 GeV","l") # legend.AddEntry(gr_pho_METCAT,"Comb. MET in [50-80] and MET> 80 GeV","l") #legend.AddEntry(gr_phoptgg80met80_all,"All events with MET > 80 GeV and pT > 80 GeV","l") #legend_H = ROOT.TLegend(0.2,0.7,0.9,0.9) legend.AddEntry(gr_boostchiaramet80_H,"Adding the Higgs resonant background","l") legend.AddEntry(gr_boostchiaramet80_noH,"Fitting only the non-resonant background","l") if isOrigSel: title+="limits_pho" if not isOrigSel and not isChiara: title+="limits_boost" if not isOrigSel and isChiara: title+="limits_boostchiara" if not isOrigSel and isChiara and isH: title+="limits_boostchiara_HremovalCheck" canv = ROOT.TCanvas(title,title) canv.SetLogx() # if isOrigSel and not hasMetCut and not lookAtmet: # if isOrigSel and hasMetCut and not lookAtmet: if isOrigSel: gr_phomet80_all.Draw("APL") gr_phomet80_all.GetYaxis().SetRangeUser(0.,40.) gr_phomet50_all.Draw("PLsame") gr_phomet70_all.Draw("PLsame") if not isOrigSel and not isChiara: gr_boostmet80_all.Draw("APL") gr_boostmet80_all.GetYaxis().SetRangeUser(0.,40.) gr_boostmet50_all.Draw("PLsame") gr_boostmet70_all.Draw("PLsame") if not isOrigSel and isChiara: gr_boostchiaramet80_all.Draw("APL") gr_boostchiaramet80_all.GetYaxis().SetRangeUser(0.,40.) gr_boostchiaramet50_all.Draw("PLsame") gr_boostchiaramet70_all.Draw("PLsame") if not isOrigSel and isChiara and isH: gr_boostchiaramet80_H.Draw("APL") gr_boostchiaramet80_H.GetYaxis().SetRangeUser(0.,15.) gr_boostchiaramet80_noH.Draw("PLsame") self.keep(legend,True) #if not isH: legend.Draw() self.keep( [canv,gr_phomet80_all] )#,gr_phomet50_all, gr_phomet50_4CAT,gr_newSel_all, gr_newSel_4CAT,gr_newSelmet50_all, gr_newSelmet50_4CAT] ) self.format(canv,options.postproc)
def plotFitBands(self,options,frame,dset,pdf,obs,roocurve,binning=None,slabel=None): wd = ROOT.gDirectory params = pdf.getDependents( self.pdfPars_ ) snap = params.snapshot() nlim = ROOT.RooRealVar("nlim%s" % dset.GetName(),"",0.0,0.0,1e+5) nbias = ROOT.RooRealVar("nbias%s" % dset.GetName(),"",0.0,-1.e+5,1e+5) sbias = ROOT.RooRealVar("sbias%s" % dset.GetName(),"",0.0,-1.e+5,1e+5) sbias.setConstant(True) biaspdf = ROOT.RooGaussian("nbiasPdf%s" % dset.GetName(),"",nbias,ROOT.RooFit.RooConst(0.),sbias) nsum = ROOT.RooAddition("nsum%s"%dset.GetName(),"",ROOT.RooArgList(nlim,nbias)) onesigma = ROOT.TGraphAsymmErrors() twosigma = ROOT.TGraphAsymmErrors() bias = ROOT.TGraphAsymmErrors() bands = [onesigma,twosigma,bias] styles = [ [(style_utils.colors,ROOT.kYellow)], [(style_utils.colors,ROOT.kGreen+1)], [(style_utils.colors,ROOT.kOrange)] ] for band in bands: style_utils.apply( band, styles.pop(0) ) self.keep(bands) bins = [] if binning: roobins = obs.getBinning(binning) for ibin in range(roobins.numBins()): bins.append( (roobins.binCenter(ibin), roobins.binLow(ibin), roobins.binHigh(ibin)) ) else: for ibin in range(1,frame.GetXaxis().GetNbins()+1): lowedge = frame.GetXaxis().GetBinLowEdge(ibin) upedge = frame.GetXaxis().GetBinUpEdge(ibin) center = frame.GetXaxis().GetBinCenter(ibin) bins.append( (center,lowedge,upedge) ) bias_func=None if slabel in options.bias_param: bias_func = ROOT.TF1("err_correction",options.bias_param[slabel],0,2e+6) for ibin,bin in enumerate(bins): center,lowedge,upedge = bin nombkg = roocurve.interpolate(center) onesigma.SetPoint(ibin,center,nombkg) twosigma.SetPoint(ibin,center,nombkg) nlim.setVal(nombkg) ## itr = snap.createIterator() ## var = itr.Next() ## while var: ## params[var.GetName()].setVal(var.getVal()) ## var = itr.Next() ## for f in ROOT.gROOT.GetListOfFiles(): ## print f.GetName() if options.verbose or ibin % 10 == 0: print "computing error band ", ibin, lowedge, upedge, nombkg, if nombkg < 5e-4: print continue obs.setRange("errRange",lowedge,upedge) if bias_func: nbias.setVal(0.) sbias.setVal(bias_func.Integral(lowedge,upedge)) epdf = ROOT.RooExtendPdf("epdf","",pdf,nsum,"errRange") nll = epdf.createNLL(dset,ROOT.RooFit.Extended(),ROOT.RooFit.ExternalConstraints( ROOT.RooArgSet(biaspdf) )) else: epdf = ROOT.RooExtendPdf("epdf","",pdf,nlim,"errRange") nll = epdf.createNLL(dset,ROOT.RooFit.Extended()) minim = ROOT.RooMinimizer(nll) minim.setMinimizerType("Minuit2") minim.setStrategy(0) minim.setPrintLevel( -1 if not options.verbose else 2) # minim.setPrintLevel(-1) minim.migrad() if nombkg > 1.5e-3: minim.minos(ROOT.RooArgSet(nlim)) errm, errp = -nlim.getErrorLo(),nlim.getErrorHi() else: result = minim.lastMinuitFit() errm = nlim.getPropagatedError(result) errp = errm onesigma.SetPointError(ibin,0.,0.,errm,errp) if options.verbose or ibin % 10 == 0: print errp, errm if nombkg > 1.5e-3: minim.setErrorLevel(1.91) minim.migrad() minim.minos(ROOT.RooArgSet(nlim)) errm, errp = -nlim.getErrorLo(),nlim.getErrorHi() else: result = minim.lastMinuitFit() errm = 2.*nlim.getError() errp = errm twosigma.SetPointError(ibin,0.,0.,errm,errp) del minim del nll frame.addObject(twosigma,"E3") frame.addObject(onesigma,"E3") itr = snap.createIterator() var = itr.Next() while var: params[var.GetName()].setVal(var.getVal()) var = itr.Next() wd.cd()
def compareExpectedLivia(self, options): #original selection # tfile_1cat=self.open("ntuples4fit_vtx0_OptSel1_80X_METCAT_mZ_600_cic_default_shapes_lumi_20_1CAT/graphs_Asymptotic.root") #tfile_2cat=self.open("ntuples4fit_vtx0_OptSel1_80X_METCAT_mZ_600_cic_default_shapes_lumi_20_2CAT/graphs_Asymptotic.root") #gr_1cat=tfile_1cat.Get("expected_001") #gr_2cat=tfile_2cat.Get("expected_001") tfile_cc2015 = self.open( "../Approval-Nominal/HybridNewCL/2HDM_A0300_SinglePoint_m600Sel/graphs_HybridNew.root" ) tfile_cc105 = self.open( "Datacards_ABCD_v80X_v5/cutncount_105/graphs_Asymptotic_mA0300.root" ) tfile_cc130 = self.open( "Datacards_ABCD_v80X_v5/cutncount_130/graphs_Asymptotic_mA0300.root" ) tfile_fit130 = self.open( "ntuples4fit_pho_met130_NEW_cic_default_shapes_lumi_34.7/graphs_Asymptotic_mA0300.root" ) tfile_fit105 = self.open( "ntuples4fit_pho_met105_cic_default_shapes_lumi_34.7/graphs_Asymptotic_mA0300.root" ) tfile_fit150 = self.open( "ntuples4fit_pho_met150_cic_default_shapes_lumi_34.7/graphs_Asymptotic_mA0300.root" ) tfile_fit130LV = self.open( "ntuples4fit_pho_met130_STD_cic_default_shapes_lumi_34.7/graphs_Asymptotic_mA0300.root" ) tfile_fit130LV_PI = self.open( "ntuples4fit_pho_met130_HYB_cic_default_shapes_lumi_34.7/graphs_Asymptotic_mA0300.root" ) # tfile_cc=self.open("ntuples4fit_vtx0_OptSel1_80X_METCAT_mZ_600_cic_default_shapes_lumi_35/graphs_Asymptotic.root") tfile_fit120 = self.open( "ntuples4fit_pho_met130_NEW_cic_default_shapes_lumi_34.7/graphs_Asymptotic_mA0300.root" ) # tfile_fit130=self.open("ntuples4fit_pho_met130_cic_default_shapes_lumi_34.7/graphs_Asymptotic.root") tfile_lowmet40 = self.open( "ntuples4fit_pho_met40_met130_cic_default_shapes_lumi_35.8/graphs_Asymptotic_mA0300.root" ) tfile_lowmet30 = self.open( "ntuples4fit_pho_met30_met130_cic_default_shapes_lumi_35.8/graphs_Asymptotic_mA0300.root" ) gr_cc2015 = tfile_cc2015.Get("expected_001") gr_cc105 = tfile_cc105.Get("expected_001") gr_cc130 = tfile_cc130.Get("expected_001") gr_fit105 = tfile_fit105.Get("expected_001") gr_fit120 = tfile_fit120.Get("expected_001") gr_fit130 = tfile_fit130.Get("expected_001") gr_fit150 = tfile_fit150.Get("expected_001") gr_fit130LV = tfile_fit130LV.Get("expected_001") gr_fit130LV_PI = tfile_fit130LV_PI.Get("expected_001") gr_fitlm40 = tfile_lowmet40.Get("expected_001") gr_fitlm30 = tfile_lowmet30.Get("expected_001") unit = "fb" if options.use_fb else "pb" basicStyle = [ ["SetMarkerSize", 0.6], ["SetLineWidth", 3], [ "SetTitle", ";M_{Z`} (GeV);95%% C.L. #sigma(pp#rightarrow Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma ) (%s)" % unit ] ] expectedStyle = [["SetMarkerSize", 0]] + basicStyle # style_utils.apply( gr_1cat, [["colors",ROOT.kRed],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) #style_utils.apply( gr_2cat, [["colors",ROOT.kBlue],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply(gr_cc2015, [["colors", ROOT.kOrange], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_cc105, [["colors", ROOT.kAzure + 10], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_cc130, [["colors", ROOT.kMagenta - 9], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fit105, [["colors", ROOT.kBlue], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fit120, [["colors", ROOT.kViolet + 5], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fit130, [["colors", ROOT.kViolet], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fit130LV, [["colors", ROOT.kOrange], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fit130LV_PI, [["colors", ROOT.kRed], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fit150, [["colors", ROOT.kMagenta + 3], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fitlm40, [["colors", ROOT.kMagenta], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_fitlm30, [["colors", ROOT.kAzure + 10], ["SetLineStyle", 7], ["SetName", "gr_pho"]] + expectedStyle) title = ROOT.TString() title = "Comparison_LowMetThresholds_MA300" isNewSel = False legend = ROOT.TLegend(0.39, 0.7, 0.89, 0.9) #legend.AddEntry(gr_1cat,"1 CAT","l") #legend.AddEntry(gr_2cat,"2 CAT","l") # legend.AddEntry(gr_cc2015,"CC MET> 105 GeV - 2015","l") # legend.AddEntry(gr_fit105,"Fit MET > 105 GeV","l") # legend.AddEntry(gr_cc105,"CC MET> 105 GeV -2016","l") # legend.AddEntry(gr_fit120,"Fit MET > 120 GeV","l") # legend.AddEntry(gr_fit130,"Loose Lepton Veto","l") # legend.AddEntry(gr_fit130LV,"Standard Analysis","l") # legend.AddEntry(gr_fit130LV_PI,"Hybrid Analysis","l") legend.AddEntry(gr_fitlm30, "MET> 30 GeV", "l") legend.AddEntry(gr_fitlm40, "MET> 40 GeV", "l") # legend.AddEntry(gr_cc130,"CC MET > 130 GeV - 2016","l") # legend.AddEntry(gr_fit150,"Fit MET > 150 GeV","l") title += "limits_categories" canv = ROOT.TCanvas(title, title) # canv.SetLogx() #gr_1cat.Draw("PLA") #gr_2cat.Draw("PLA") gr_fitlm30.GetYaxis().SetRangeUser(0.3, 0.7) # gr_fit130.Draw("PLA") # gr_fit105.Draw("PLSAME") # gr_cc2015.Draw("PLSAME") # gr_cc105.Draw("PLSAME") # gr_fit120.Draw("PLSAME") # gr_fit150.Draw("PLSAME") # gr_cc130.Draw("PLSAME") gr_fitlm30.Draw("APL") gr_fitlm40.Draw("PLSAME") addCmsLumi(canv, 4, 1, "Preliminary") self.keep(legend, True) #if not isH: legend.Draw() self.keep([canv, gr_cc130]) self.format(canv, options.postproc)
def plotPval(self, options, coup, tfile): observed = ROOT.theBand(tfile, 1, 0, ROOT.Observed, 0.95) basicStyle = [["SetMarkerSize", 0.6], ["SetLineWidth", 3], ["SetTitle", ";m_{G} (GeV);p_{0}"]] if not options.spin2: basicStyle.append(["SetTitle", ";m_{S} (GeV);p_{0}"]) commonStyle = ["Sort"] + basicStyle observedStyle = commonStyle + [["SetMarkerStyle", ROOT.kFullCircle], ["colors", ROOT.kBlue]] style_utils.apply(observed, [["SetName", "observed_%s" % coup]] + observedStyle) xmin, xmax = options.x_range canv = ROOT.TCanvas("pvalues_k%s" % coup, "pvalues_k%s" % coup) canv.SetLogy() canv.SetLogx() ## legend = ROOT.TLegend(0.5,0.6,0.8,0.75) ## legend = ROOT.TLegend(0.6,0.6,0.9,0.75) ## legend = ROOT.TLegend(0.56,0.6,0.86,0.75) legend = ROOT.TLegend(*options.legend) legend.SetFillStyle(0) kappa = "0." + coup[1:] observed.Draw("apl") ## observed.Draw("al") ## observed.GetYaxis().SetRangeUser(1e-5,0.55) observed.GetYaxis().SetRangeUser(1e-3, 0.55) if len(options.y_range) > 0: ## print "AAAAAAAAAAAAAAAA" observed.GetYaxis().SetRangeUser(*options.y_range) observed.GetYaxis().SetLimits(*options.y_range) observed.GetXaxis().SetRangeUser(xmin, xmax) observed.GetXaxis().SetMoreLogLabels() ## xmin,xmax=observed.GetXaxis().GetXmin(),observed.GetXaxis().GetXmax() ## xmin,xmax=450,3000 # xmin,xmax=450,5000 ### spots = filter(lambda x: x>observed.GetYaxis().GetXmin(), map(lambda x: (x,ROOT.RooStats.SignificanceToPValue(x)), xrange(1,5) ) ) ### ### lines = map( lambda y: ROOT.TLine(xmin,y[1],xmax,y[1]), spots ) ### map( lambda x: style_utils.apply(x,[["SetLineColor",ROOT.kGray+3],["SetLineStyle",7]]), lines ) ### ### labels = map( lambda y: ROOT.TLatex(xmax*1.01,y[1]*0.9,"#color[%d]{%d #sigma}" % (ROOT.kGray+2,y[0])), spots ) ### map( lambda x: style_utils.apply(x,[["SetTextSize",0.05]]), labels ) ### ### map( lambda x: x.Draw("same"), lines+labels ) self.drawLines(observed, xmin, xmax) ## self.keep(lines+labels) if options.spin2: legend.AddEntry(None, "#tilde{#kappa} = %s" % kappa, "") else: kappa = float(kappa) legend.AddEntry( None, "#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4 * kappa * kappa * 100.), "") legend.AddEntry(observed, "Observed p_{0}", "l") self.keep(legend, True) legend.Draw() self.graphs.extend([observed]) self.keep([canv, observed]) self.format(canv, options.postproc)
def plotComparison(self,options,coup,observed): cobserved = map(lambda x: (filter(lambda y: y.GetName().endswith("_%s" % coup), x[0])[0],x[1]), observed) print cobserved ## styles = [ [["colors",ROOT.kBlue]], [["colors",ROOT.kRed+1]], [["colors",ROOT.kMagenta-2]] ] styles = [ [["colors",ROOT.kBlack]], [["colors",ROOT.kBlue],["SetLineStyle",options.extra_lines_style]], [["colors",ROOT.kRed],["SetLineStyle",options.extra_lines_style]] ] map(lambda x: style_utils.apply(x[0],[["SetMarkerSize",0.3],["SetLineWidth",2]]+styles.pop(0)), cobserved) canv = ROOT.TCanvas("comparison_%s%s" % (options.label,coup),"comparison_%s%s" % (options.label,coup) ) legend = ROOT.TLegend(*options.legend) ## legend = ROOT.TLegend(0.56,0.51,0.86,0.76) ## legend = ROOT.TLegend(0.6,0.51,0.9,0.76) ## legend = ROOT.TLegend(0.6,0.2,0.9,0.42) ## legend = ROOT.TLegend(0.45,0.2,0.75,0.42) legend.SetFillStyle(0) kappa = "0."+coup[1:] g0 = cobserved[0][0] ### kappa = float(kappa) ### if kappa >= 0.1: ### txt = "#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.) ### else: ### txt = "#frac{#Gamma}{m} = %g #times 10^{-4}" % (1.4*kappa*kappa*10000.) ### ### if options.spin2: ### txt += " J=2" ### g0.GetXaxis().SetTitle("m_{G} (GeV)") ### else: ### txt += " J=0" ### g0.GetXaxis().SetTitle("m_{S} (GeV)") kappa = float(kappa) txt = self.getLegendHeader(kappa,g0) legend.AddEntry(None,txt,"") if options.xtitle: g0.GetXaxis().SetTitle(options.xtitle) g0.Draw("al") for gr,nam in cobserved: legend.AddEntry(gr,nam,"l") for gr,nam in reversed(cobserved): gr.Draw("l") legend.Draw("same") xmin,xmax = options.x_range ## g0.GetXaxis().SetRangeUser(450,5000) ## g0.GetXaxis().SetRangeUser(500,3000) ## g0.GetXaxis().SetRangeUser(500,850) ## g0.GetXaxis().SetRangeUser(850,3000) g0.GetXaxis().SetRangeUser(xmin,xmax) g0.GetXaxis().SetMoreLogLabels() canv.SetLogx() if options.do_pvalues: canv.SetLogy() g0.GetYaxis().SetRangeUser(1e-3,0.55) ## g0.GetYaxis().SetRangeUser(1e-4,0.55) if len(options.y_range) > 0: ## print "AAAAAAAAAAAAAAAA" g0.GetYaxis().SetRangeUser(*options.y_range) g0.GetYaxis().SetLimits(*options.y_range) if options.do_pvalues: self.drawLines(g0,xmin,xmax) self.keep([canv,legend]) self.format(canv,options.postproc)
def plotComparison(self, options, coup, observed): cobserved = map( lambda x: (filter(lambda y: y.GetName().endswith("_%s" % coup), x[ 0])[0], x[1]), observed) print cobserved ## styles = [ [["colors",ROOT.kBlue]], [["colors",ROOT.kRed+1]], [["colors",ROOT.kMagenta-2]] ] styles = [[["colors", ROOT.kBlack]], [["colors", ROOT.kBlue], ["SetLineStyle", options.extra_lines_style]], [["colors", ROOT.kRed], ["SetLineStyle", options.extra_lines_style]]] map( lambda x: style_utils.apply(x[0], [["SetMarkerSize", 0.3], ["SetLineWidth", 2]] + styles. pop(0)), cobserved) canv = ROOT.TCanvas("comparison_%s%s" % (options.label, coup), "comparison_%s%s" % (options.label, coup)) legend = ROOT.TLegend(*options.legend) ## legend = ROOT.TLegend(0.56,0.51,0.86,0.76) ## legend = ROOT.TLegend(0.6,0.51,0.9,0.76) ## legend = ROOT.TLegend(0.6,0.2,0.9,0.42) ## legend = ROOT.TLegend(0.45,0.2,0.75,0.42) legend.SetFillStyle(0) kappa = "0." + coup[1:] g0 = cobserved[0][0] ### kappa = float(kappa) ### if kappa >= 0.1: ### txt = "#frac{#Gamma}{m} = %g #times 10^{-2}" % (1.4*kappa*kappa*100.) ### else: ### txt = "#frac{#Gamma}{m} = %g #times 10^{-4}" % (1.4*kappa*kappa*10000.) ### ### if options.spin2: ### txt += " J=2" ### g0.GetXaxis().SetTitle("m_{G} (GeV)") ### else: ### txt += " J=0" ### g0.GetXaxis().SetTitle("m_{S} (GeV)") kappa = float(kappa) txt = self.getLegendHeader(kappa, g0) legend.AddEntry(None, txt, "") if options.xtitle: g0.GetXaxis().SetTitle(options.xtitle) g0.Draw("al") for gr, nam in cobserved: legend.AddEntry(gr, nam, "l") for gr, nam in reversed(cobserved): gr.Draw("l") legend.Draw("same") xmin, xmax = options.x_range ## g0.GetXaxis().SetRangeUser(450,5000) ## g0.GetXaxis().SetRangeUser(500,3000) ## g0.GetXaxis().SetRangeUser(500,850) ## g0.GetXaxis().SetRangeUser(850,3000) g0.GetXaxis().SetRangeUser(xmin, xmax) g0.GetXaxis().SetMoreLogLabels() canv.SetLogx() if options.do_pvalues: canv.SetLogy() g0.GetYaxis().SetRangeUser(1e-3, 0.55) ## g0.GetYaxis().SetRangeUser(1e-4,0.55) if len(options.y_range) > 0: ## print "AAAAAAAAAAAAAAAA" g0.GetYaxis().SetRangeUser(*options.y_range) g0.GetYaxis().SetLimits(*options.y_range) if options.do_pvalues: self.drawLines(g0, xmin, xmax) self.keep([canv, legend]) self.format(canv, options.postproc)
def compareExpectedLivia(self, options): #original selection # tfile_1cat=self.open("ntuples4fit_vtx0_OptSel1_80X_METCAT_mZ_600_cic_default_shapes_lumi_20_1CAT/graphs_Asymptotic.root") #tfile_2cat=self.open("ntuples4fit_vtx0_OptSel1_80X_METCAT_mZ_600_cic_default_shapes_lumi_20_2CAT/graphs_Asymptotic.root") #gr_1cat=tfile_1cat.Get("expected_001") #gr_2cat=tfile_2cat.Get("expected_001") tfile_fitm200 = self.open( "ntuples4fit_pho_met130_LeptVetoNew_cic_default_shapes_lumi_34.7/graphs_Asymptotic_%s.root" % options.mZP) tfile_fitm200LV_PI = self.open( "ntuples4fit_pho_met130_LeptVetoNew_PhoIsoNew_cic_default_shapes_lumi_34.7/graphs_Asymptotic_%s.root" % options.mZP) unit = "fb" if options.use_fb else "pb" basicStyle = [ ["SetLineWidth", 3], [ "SetTitle", ";M_{#chi} (GeV);95% C.L. #mu(pp#rightarrow Z`#rightarrowA_{0}H #rightarrow#chi#chi#gamma#gamma ) " ] ] expectedStyle = basicStyle gr_200 = tfile_fitm200.Get("expected_001") gr_200.Print() gr_200LV_PI = tfile_fitm200LV_PI.Get("expected_001") gr_200LV_PI.Print() # style_utils.apply( gr_1cat, [["colors",ROOT.kRed],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) #style_utils.apply( gr_2cat, [["colors",ROOT.kBlue],["SetLineStyle",7],["SetName","gr_pho"]]+expectedStyle ) style_utils.apply(gr_200, [["colors", ROOT.kBlue - 8], ["SetLineStyle", 9], ["SetName", "gr_pho"]] + expectedStyle) style_utils.apply(gr_200LV_PI, [["colors", ROOT.kBlue + 8], ["SetLineStyle", 9], ["SetName", "gr_pho"]] + expectedStyle) # style_utils.apply( gr_15, [["colors",ROOT.kMagenta],["SetLineStyle",9],["SetName","gr_pho"]]+expectedStyle ) title = ROOT.TString() title = "Comparison_ScalarZp_%s" % options.mZP isNewSel = False legend = ROOT.TLegend(0.59, 0.55, 0.89, 0.9) #legend.AddEntry(gr_1cat,"1 CAT","l") #legend.AddEntry(gr_2cat,"2 CAT","l") legend.AddEntry(gr_200, "Standard Analysis ", "lp") legend.AddEntry(gr_200LV_PI, "Boosted Analysis ", "lp") line = ROOT.TLine(0.9, 1, 1010, 1) line.SetLineColor(ROOT.kRed) line.SetLineWidth(2) # line.SetLineStyle(ROOT.kDashed) title += "limits_categories_LVPI" canv = ROOT.TCanvas(title, title) # canv.SetLogx() # canv.SetLogy() gr_200.GetYaxis().SetRangeUser(0.01, 5.) gr_200.Draw("PLA") gr_200LV_PI.Draw("PLsame") # line.Draw("SAME") addCmsLumi(canv, 4, 1, "Preliminary") self.keep(legend, True) #if not isH: #legend.Draw() self.keep([canv, gr_200, gr_200LV_PI]) self.format(canv, options.postproc) # self.format(canv, options) canv.SaveAs("~/www/plotsMonoH/FitLimits/Comparison_ZP200.png")