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)
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)) graph.SetPointError(i, graph.GetEX()[i], 0)
#------------------------------------------------------------------------------ ## 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, styles = [20, 25, 22],
sources = zip(filenames, wsnames, sreco_snapshots), getters = ( lambda ws, i = iter(bincenters): i.next(), # x lambda ws, i = iter(sreco_lyon): i.next(), # y lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws, i = iter(esreco_lyon): i.next(), # ey ), xtitle = 'E_{T}^{#gamma} (GeV)', ytitle = 's_{reco} = E^{#gamma}_{reco}/E^{kin}_{reco} - 1 (%)', title = 'Lyon', ) frp.getdata() frp.makegraph() ## Caltech frp.getters = var_vs_pt('#Deltas') frp.title = 'Caltech' frp.getdata() frp.makegraph() ## Compare Caltech and Lyon scale canvases.next() frp.plotall(title = 'Barrel, R_{9} < 0.94, Baseline', styles = [20, 25]) plotters.append(frp) #------------------------------------------------------------------------------ ## S width Comparison ## Lyon frp = FitResultPlotter(
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, styles=[20, 25, 22],
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]) plotters.append(plotter)