method=args.bin_method, force_x_width=args.force_x_width, force_y_width=args.force_y_width) h_axis = h_proto h_axis = plot.TH2FromTGraph2D(graphs[types[0]]) # Create the debug output file if requested if args.debug_output is not None: debug = ROOT.TFile(args.debug_output, 'RECREATE') else: debug = None # Fill TH2s by interpolating the TGraph2Ds, then extract contours for c in types: print 'Filling histo for %s' % c hists[c] = h_proto.Clone(c) plot.fillTH2(hists[c], graphs[c]) contours[c] = plot.contourFromTH2(hists[c], CL, 5, frameValue=1) if debug is not None: debug.WriteTObject(hists[c], 'hist_%s' % c) for i, cont in enumerate(contours[c]): debug.WriteTObject(cont, 'cont_%s_%i' % (c, i)) # Setup the canvas: we'll use a two pad split, with a small top pad to contain # the CMS logo and the legend canv = ROOT.TCanvas(args.output, args.output) pads = plot.TwoPadSplit(0.8, 0, 0) pads[1].cd() h_axis.GetXaxis().SetTitle(args.x_title) h_axis.GetYaxis().SetTitle(args.y_title) h_axis.Draw()
hists = {} conts68 = {} conts95 = {} outfile = ROOT.TFile(args.output + ".root", "RECREATE") for scan in order: if scan not in infiles: continue graphs[scan], bestfits[scan] = read(scan, SETTINGS[scan]["xvar"], SETTINGS[scan]["yvar"], infiles[scan]) outfile.WriteTObject(graphs[scan], scan + "_graph") outfile.WriteTObject(bestfits[scan]) # hists[scan] = makeHist( # scan + '_hist', 40 * SETTINGS[scan]['multi'] * args.multi, graph_test) hists[scan] = plot.TH2FromTGraph2D(graphs[scan], method="BinCenterAligned") plot.fillTH2(hists[scan], graphs[scan]) # fillTH2(hists[scan], graphs[scan]) outfile.WriteTObject(hists[scan], hists[scan].GetName() + "_input") fixZeros(hists[scan]) outfile.WriteTObject(hists[scan], hists[scan].GetName() + "_processed") conts68[scan] = plot.contourFromTH2(hists[scan], ROOT.Math.chisquared_quantile_c(1 - 0.68, 2), frameValue=10) if scan in ["cms", "atlas", "comb"]: conts95[scan] = plot.contourFromTH2(hists[scan], ROOT.Math.chisquared_quantile_c(1 - 0.95, 2)) for i, c in enumerate(conts68[scan]): c.SetName("graph68_%s_%i" % (scan, i)) if args.thin > 1: newgr = ROOT.TGraph(c.GetN() / args.thin) needLast = True for a, p in enumerate(range(0, c.GetN(), args.thin)): if p == c.GetN() - 1: needLast = False
legend = ROOT.TLegend(0.14, 0.53, 0.35, 0.74, '', 'NBNDC') graphs = {} bestfits = {} hists = {} conts68 = {} conts95 = {} outfile = ROOT.TFile(args.output + '.root', 'RECREATE') order = ['default'] for scan in order: graphs[scan], bestfits[scan] = read(scan, args.x_axis, args.y_axis, infile) outfile.WriteTObject(graphs[scan], scan + '_graph') outfile.WriteTObject(bestfits[scan]) hists[scan] = axis.Clone(scan + '_hist') plot.fillTH2(hists[scan], graphs[scan]) outfile.WriteTObject(hists[scan], hists[scan].GetName() + '_input') fixZeros(hists[scan]) hists[scan].GetZaxis().SetTitle('-2 #Delta ln #Lambda(%s,%s)' % (x_axis, y_axis)) # hists[scan].GetZaxis().SetTitleOffset(0) hists[scan].SetContour(255) hists[scan].Draw('COLZSAME') hists[scan].SetMinimum(0) hists[scan].SetMaximum(20) outfile.WriteTObject(hists[scan], hists[scan].GetName() + '_processed') conts68[scan] = plot.contourFromTH2( hists[scan], ROOT.Math.chisquared_quantile_c(1 - 0.68, 2)) conts95[scan] = plot.contourFromTH2( hists[scan], ROOT.Math.chisquared_quantile_c(1 - 0.95, 2)) for i, c in enumerate(conts68[scan]):
#h_obs = plot.makeVarBinHist2D("h_obs", mA_list, tanb_list) #h_minus1sigma = plot.makeVarBinHist2D("h_minus1sigma", mA_list, tanb_list) #h_plus1sigma = plot.makeVarBinHist2D("h_plus1sigma", mA_list, tanb_list) #h_minus2sigma = plot.makeVarBinHist2D("h_minus2sigma", mA_list, tanb_list) #h_plus2sigma = plot.makeVarBinHist2D("h_plus2sigma", mA_list, tanb_list) h_exp = plot.makeHist2D("h_exp", mA_bins, tanb_bins, graph_exp) h_obs = plot.makeHist2D("h_obs", mA_bins, tanb_bins, graph_obs) h_minus1sigma = plot.makeHist2D("h_minus1sigma", mA_bins, tanb_bins, graph_minus1sigma) h_plus1sigma = plot.makeHist2D("h_plus1sigma", mA_bins, tanb_bins, graph_plus1sigma) h_minus2sigma = plot.makeHist2D("h_minus2sigma", mA_bins, tanb_bins, graph_minus2sigma) h_plus2sigma = plot.makeHist2D("h_plus2sigma", mA_bins, tanb_bins, graph_plus2sigma) plot.fillTH2(h_exp, graph_exp) plot.fillTH2(h_obs, graph_obs) plot.fillTH2(h_minus1sigma, graph_minus1sigma) plot.fillTH2(h_plus1sigma, graph_plus1sigma) plot.fillTH2(h_minus2sigma, graph_minus2sigma) plot.fillTH2(h_plus2sigma, graph_plus2sigma) axis.Draw() #Possibility to draw CLs heat map, would be a useful option, using e.g. #h_exp.Draw("colzsame") #Extract exclusion contours from the TH2Ds, use threshold 1.0 for limit and 0.05 for CLs threshold = 0.05 #threshold=1 cont_exp = plot.contourFromTH2(h_exp, threshold, 20) cont_obs = plot.contourFromTH2(h_obs, threshold, 5) cont_minus1sigma = plot.contourFromTH2(h_minus1sigma, threshold, 20)
h_proto = plot.TH2FromTGraph2D( graphs[types[0]], method=args.bin_method, force_x_width=args.force_x_width, force_y_width=args.force_y_width ) h_axis = h_proto h_axis = plot.TH2FromTGraph2D(graphs[types[0]]) # Create the debug output file if requested if args.debug_output is not None: debug = ROOT.TFile(args.debug_output, "RECREATE") else: debug = None # Fill TH2s by interpolating the TGraph2Ds, then extract contours for c in types: print "Filling histo for %s" % c hists[c] = h_proto.Clone(c) plot.fillTH2(hists[c], graphs[c]) contours[c] = plot.contourFromTH2(hists[c], CL, 5, frameValue=1) if debug is not None: debug.WriteTObject(hists[c], "hist_%s" % c) for i, cont in enumerate(contours[c]): debug.WriteTObject(cont, "cont_%s_%i" % (c, i)) # Setup the canvas: we'll use a two pad split, with a small top pad to contain # the CMS logo and the legend canv = ROOT.TCanvas(args.output, args.output) pads = plot.TwoPadSplit(0.8, 0, 0) pads[1].cd() h_axis.GetXaxis().SetTitle(args.x_title) h_axis.GetYaxis().SetTitle(args.y_title) h_axis.Draw()
#Note the binning of the TH2D for the interpolation should ~ match the initial input grid #Could in future implement variable binning here #h_exp = plot.makeVarBinHist2D("h_exp", mA_list, tanb_list) #h_obs = plot.makeVarBinHist2D("h_obs", mA_list, tanb_list) #h_minus1sigma = plot.makeVarBinHist2D("h_minus1sigma", mA_list, tanb_list) #h_plus1sigma = plot.makeVarBinHist2D("h_plus1sigma", mA_list, tanb_list) #h_minus2sigma = plot.makeVarBinHist2D("h_minus2sigma", mA_list, tanb_list) #h_plus2sigma = plot.makeVarBinHist2D("h_plus2sigma", mA_list, tanb_list) h_exp = plot.makeHist2D("h_exp", mA_bins, tanb_bins, graph_exp) h_obs = plot.makeHist2D("h_obs", mA_bins, tanb_bins, graph_obs) h_minus1sigma = plot.makeHist2D("h_minus1sigma", mA_bins, tanb_bins, graph_minus1sigma) h_plus1sigma = plot.makeHist2D("h_plus1sigma", mA_bins, tanb_bins, graph_plus1sigma) h_minus2sigma = plot.makeHist2D("h_minus2sigma", mA_bins, tanb_bins, graph_minus2sigma) h_plus2sigma = plot.makeHist2D("h_plus2sigma", mA_bins, tanb_bins, graph_plus2sigma) plot.fillTH2(h_exp, graph_exp) plot.fillTH2(h_obs, graph_obs) plot.fillTH2(h_minus1sigma, graph_minus1sigma) plot.fillTH2(h_plus1sigma, graph_plus1sigma) plot.fillTH2(h_minus2sigma, graph_minus2sigma) plot.fillTH2(h_plus2sigma, graph_plus2sigma) axis.Draw() #Possibility to draw CLs heat map, would be a useful option, using e.g. #h_exp.Draw("colzsame") #Extract exclusion contours from the TH2Ds, use threshold 1.0 for limit and 0.05 for CLs threshold=0.05 #threshold=1 cont_exp = plot.contourFromTH2(h_exp, threshold, 20) cont_obs = plot.contourFromTH2(h_obs, threshold, 5) cont_minus1sigma = plot.contourFromTH2(h_minus1sigma, threshold, 20)