def make_resolution_plots(): ''' Makes canvases with resolution plots. ''' global plotters #========================================================================== for cfg in get_resolution_configs()[:]: ## MC, EB, 2011A+B, 1 of 4 statistically independent tests xtitle = 'E_{T}^{#gamma} (GeV)' ytitle = 'E^{#gamma} Resolution (%)' plotter = FitResultPlotter(cfg.sources1, cfg.getters1, xtitle, ytitle, title = 'MC Truth') plotter.getdata() plotter.makegraph() plotter.sources = cfg.sources2 plotter.getters = cfg.getters2 plotter.title = 'MC Fit' plotter.getdata() plotter.makegraph() plotter.sources = cfg.sources3 plotter.getters = cfg.getters3 plotter.title = 'Data Fit' plotter.getdata() plotter.makegraph() canvases.next('c_' + cfg.name).SetGrid() plotter.plotall(title = cfg.title, styles = [20, 25, 26], colors = [ROOT.kBlack, ROOT.kBlue, ROOT.kRed]) plotters.append(plotter)
def make_scale_plots(configurations): ''' For each configuration in the given list, overlays the graphs of scale versus pt for all sets of measurements specified. These measurements are either from the true or the PHOSPHOR fit. ''' for cfg in configurations[:2]: ## Only check EE 2011AB #if (not 'EE_lowR9' in cfg.name) or (not 'AB' in cfg.name): #continue ### Only check 2011AB #if not 'AB' in cfg.name: #continue ## MC, EB, 2011A+B, 1 of 4 statistically independent tests plotter = FitResultPlotter(cfg.sources[1], cfg.getters_true[1], cfg.xtitle, cfg.ytitle, title = 'MC Truth 1', name=cfg.name) for i in range(1,5): plotter.sources = cfg.sources[i] plotter.getters = cfg.getters_true[i] plotter.title = 'MC Truth %d' % i plotter.getdata() plotter.makegraph() for i in range(1,5): plotter.sources = cfg.sources[i] plotter.getters = cfg.getters_fit[i] plotter.title = 'MC Fit %d' % i plotter.getdata() plotter.makegraph() canvases.next('c_' + cfg.name).SetGrid() plotter.plotall(title = cfg.title, xrange = (0, 80), legend_position = 'topright') plotter.graphs[0].Draw('p') canvases.canvases[-1].Modified() canvases.canvases[-1].Update() canvases.update() plotters.append(plotter)
def make_plots(configurations): """ For each configuration in the given list, overlays the graphs of scale versus pt for all sets of measurements specified. These measurements are either from the true or the PHOSPHOR fit. """ for cfg in configurations[:]: ## Only check EE 2011AB # if (not 'EE_lowR9' in cfg.name) or (not 'AB' in cfg.name): # continue ### Only check 2011AB # if not 'AB' in cfg.name: # continue ## MC, EB, 2011A+B, 1 of 4 statistically independent tests plotter = FitResultPlotter( cfg.sources[0], cfg.getters[0], cfg.xtitle, cfg.ytitle, title=cfg.titles[0], name=cfg.name, xasymmerrors=True, yasymmerrors=True, colors=[ROOT.kBlack], ) for isources, igetters, ititle in zip(cfg.sources, cfg.getters, cfg.titles): plotter.sources = isources plotter.getters = igetters plotter.title = ititle plotter.getdata() plotter.makegraph() plotter.graph.Fit("pol1") canvases.next("c_" + cfg.name).SetGrid() plotter.graph.Draw("ap") plotter.graph.GetXaxis().SetTitle(cfg.xtitle) plotter.graph.GetYaxis().SetTitle(cfg.ytitle) # if 'EE_highR9' in cfg.name: # plotter.plotall(title = cfg.title, ##xrange = (0, 10), ##yrange = (0, 10), # legend_position = 'topright') # else: # plotter.plotall(title = cfg.title, ##xrange = (5, 55), # legend_position = 'topright') # plotter.graphs[0].Draw('p') canvases.canvases[-1].Modified() canvases.canvases[-1].Update() canvases.update() plotters.append(plotter)
def make_plots(configurations): ''' For each configuration in the given list, overlays the graphs of scale versus pt for all sets of measurements specified. These measurements are either from the true or the PHOSPHOR fit. ''' for cfg in configurations[:]: ## Only check EE 2011AB #if (not 'EE_lowR9' in cfg.name) or (not 'AB' in cfg.name): #continue ### Only check 2011AB #if not 'AB' in cfg.name: #continue ## MC, EB, 2011A+B, 1 of 4 statistically independent tests plotter = FitResultPlotter(cfg.sources[0], cfg.getters[0], cfg.xtitle, cfg.ytitle, title = cfg.titles[0], name=cfg.name, yasymmerrors=True) for isources, igetters, ititle in zip(cfg.sources, cfg.getters, cfg.titles): plotter.sources = isources plotter.getters = igetters plotter.title = ititle plotter.getdata() plotter.makegraph() plotter.plot() canvases.next('c_' + cfg.name).SetGrid() ## Check if there is a problem with the ranges # yrange = 'auto' yrange = (-10, 10) for graph in plotter.graphs: if (graph.GetHistogram().GetMaximum() - graph.GetHistogram().GetMinimum()) < 0.1: print cfg.name, graph.GetTitle(), 'min:', graph.GetMaximum(), print ', max:', graph.GetMaximum yrange = (-5, 10) plotter.plotall(title = cfg.title, xrange = (5, 55), yrange = yrange, legend_position = 'topright') #plotter.graphs[0].Draw('p') canvases.canvases[-1].Modified() canvases.canvases[-1].Update() canvases.update() plotters.append(plotter)
def plot_xy(xname, yname, filemask, xtype='var', ytype='var'): filename = filemask % ptbinedges[0] ## Mass scale vs photon scale frp = FitResultPlotter( sources = sources(filename, wsname), getters = xygetters(xname, yname, xtype, ytype), xtitle = axistitles[xname], ytitle = axistitles[yname], title = 'Dummy Legend Entry', ) for ptrange in ptbinedges: filename = filemask % ptrange frp.sources = sources(filename, wsname) frp.title = 'E_{T}^{#gamma} #in [%d, %d] GeV' % ptrange frp.getdata() frp.makegraph() canvases.next(yname + '_vs_' + xname).SetGrid() frp.plotall(title = ptitle) frps.append(frp)
plotter = FitResultPlotter(None, None) for etar9 in cats: frp = FitResultPlotter( sources='dummy', getters=var_vs_pt('#Deltas'), xtitle='E_{T}^{#gamma} (GeV)', ytitle='s_{gen} = E^{#gamma}_{reco}/E^{#gamma}_{gen} - 1 (%)', ) for fitrange, title in zip(['FitRange' + x for x in '65 68 71'.split()], '-3% Nominal +3%'.split()): filenames = [os.path.join(path, 'strue_%s.root' % fitrange)] * n snapshots = [ snapshot.format(f=fitrange, c=etar9.name, l=lo, h=hi) for lo, hi in binedges ] frp.sources = zip(filenames, workspaces, snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = title frp.getdata() frp.makegraph() canvases.next('strue_FitRangeSystematics' + etar9.name) frp.plotall(title=etar9.title) plotters.append(frp) graph = frp.graphs[0].Clone('g_' + etar9.name) for i in range(graph.GetN()): x = graph.GetX()[i] ylo = min([g.GetY()[i] for g in frp.graphs]) yhi = max([g.GetY()[i] for g in frp.graphs]) graph.SetPoint(i, x, 0.5 * (yhi - ylo))
for cfg in cfgs: #------------------------------------------------------------------------------ ## Scale Comparison ## Baseline v2 frp = FitResultPlotter( sources = zip(cfg.filenames1, cfg.wsnames, cfg.sreco_snapshots1), getters = var_vs_pt('#Deltas'), xtitle = 'E_{T}^{#gamma} (GeV)', ytitle = 's_{reco} = E^{#gamma}_{reco}/E^{kin}_{reco} - 1 (%)', title = 'Baseline v2', ) frp.getdata() frp.makegraph() ## Proposal 2 frp.sources = zip(cfg.filenames2, cfg.wsnames, cfg.sreco_snapshots2) frp.getters = var_vs_pt('#Deltas') frp.title = 'm_{#mu#mu} < 90 GeV' frp.getdata() frp.makegraph() ## True frp.sources = zip(cfg.filenames2, cfg.wsnames, cfg.strue_snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = 'MC Truth' frp.getdata() frp.makegraph() ## Compare Proposal 1, Baseline and MC truth scale canvases.next('s_' + cfg.name).SetGrid() frp.plotall(title = cfg.title,
lambda ws, i=iter(ktransmc[cfg.name]['sreco']): ( ws.var('#Deltas').getVal() + i.next() # y ), lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws, i=iter(ktransmc[cfg.name]['esreco']): (oplus(ws.var('#Deltas').getError(), i.next())), # ey ), xtitle='E_{T}^{#gamma} (GeV)', ytitle='s_{reco} = E^{#gamma}_{reco}/E^{kin}_{reco} - 1 (%)', title='PDF Morph', ) frp.getdata() frp.makegraph() ## New Baseline frp.sources = zip(cfg.filenames, cfg.wsnames, cfg.sreco_snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = 'Baseline' frp.getdata() frp.makegraph() ## True frp.sources = zip(cfg.filenames, cfg.wsnames, cfg.strue_snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = 'MC Truth' frp.getdata() frp.makegraph() ## Compare New Baseline, MC PDF and MC truth scale canvases.next('s_' + cfg.name).SetGrid() frp.plotall(title=cfg.title,
) resolution_configurations.append(cfg) ## End of loop categories plotters = [] #============================================================================== for cfg in scale_configurations[:]: ## MC, EB, 2011A+B, 1 of 4 statistically independent tests plotter = FitResultPlotter(cfg.sources1, cfg.getters1, cfg.xtitle, cfg.ytitle, title = 'MC Truth') plotter.getdata() plotter.makegraph() plotter.sources = cfg.sources2 plotter.getters = cfg.getters2 plotter.title = 'MC Fit' plotter.getdata() plotter.makegraph() plotter.sources = cfg.sources3 plotter.getters = cfg.getters3 plotter.title = 'Data Fit' plotter.getdata() plotter.makegraph() canvases.next('c_' + cfg.name).SetGrid() plotter.plotall(title = cfg.title, styles = [20, 25, 26], colors = [ROOT.kBlack, ROOT.kBlue, ROOT.kRed])
ws.var('#Deltas').getVal() + i.next() # y ), lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws, i = iter(ktransmc[cfg.name]['esreco']): ( oplus(ws.var('#Deltas').getError(), i.next()) ), # ey ), xtitle = 'E_{T}^{#gamma} (GeV)', ytitle = 's_{reco} = E^{#gamma}_{reco}/E^{kin}_{reco} - 1 (%)', title = 'PDF Morph', ) frp.getdata() frp.makegraph() ## New Baseline frp.sources = zip(cfg.filenames, cfg.wsnames, cfg.sreco_snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = 'Baseline' frp.getdata() frp.makegraph() ## True frp.sources = zip(cfg.filenames, cfg.wsnames, cfg.strue_snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = 'MC Truth' frp.getdata() frp.makegraph() ## Compare New Baseline, MC PDF and MC truth scale canvases.next('s_' + cfg.name).SetGrid() frp.plotall(title = cfg.title,
workspaces = ['ws1'] * n snapshot = 'sFit_strue_mc_Nominal{f}_mmMass80_{c}_PhoEt{l}-{h}_bifurGauss' plotter = FitResultPlotter(None, None) for etar9 in cats: frp = FitResultPlotter( sources = 'dummy', getters = var_vs_pt('#Deltas'), xtitle = 'E_{T}^{#gamma} (GeV)', ytitle = 's_{gen} = E^{#gamma}_{reco}/E^{#gamma}_{gen} - 1 (%)', ) for fitrange, title in zip(['FitRange' + x for x in '65 68 71'.split()], '-3% Nominal +3%'.split()): filenames = [os.path.join(path, 'strue_%s.root' % fitrange)] * n snapshots = [snapshot.format(f=fitrange, c=etar9.name, l=lo, h=hi) for lo, hi in binedges] frp.sources = zip(filenames, workspaces, snapshots) frp.getters = var_vs_pt('#Deltas') frp.title = title frp.getdata() frp.makegraph() canvases.next('strue_FitRangeSystematics' + etar9.name) frp.plotall(title=etar9.title) plotters.append(frp) graph = frp.graphs[0].Clone('g_' + etar9.name) for i in range(graph.GetN()): x = graph.GetX()[i] ylo = min([g.GetY()[i] for g in frp.graphs]) yhi = max([g.GetY()[i] for g in frp.graphs]) graph.SetPoint(i, x, 0.5 * (yhi - ylo))