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_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 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) 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() canvases.next('c_' + cfg.name).SetGrid() if 'EE_highR9' in cfg.name: plotter.plotall(title = cfg.title, xrange = (5, 55), yrange = (0, 15), 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 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)
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)
) 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) plotter.graphs.append(graph) plotter.titles.append(etar9.title) canvases.next('strue_FitRangeSystematics') plotter.xtitle = 'E_{T}^{#gamma} (GeV)'
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], colors = [kBlue, kRed, kBlack]) plotters.append(frp) #------------------------------------------------------------------------------ ## S width Comparison ## Baseline ## frp = FitResultPlotter( ## sources = zip(cfg.filenames, cfg.wsnames, cfg.sreco_snapshots), ## getters = ( ## lambda ws, i = iter(bincenters): i.next(), # x ## lambda ws, i = iter(lyonmc[cfg.name]['sigma']): i.next(), # y ## lambda ws, i = iter(binhalfwidths): i.next(), # ex ## lambda ws, i = iter(lyonmc[cfg.name]['esigma']): 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( sources = zip(filenames, wsnames, sreco_snapshots), getters = ( lambda ws, i = iter(bincenters): i.next(), # x lambda ws, i = iter(sigma_lyon): i.next(), # y lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws, i = iter(esigma_lyon): i.next(), # ey ), xtitle = 'E_{T}^{#gamma} (GeV)',
) 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], colors=[kBlue, kRed, kBlack]) plotters.append(frp) ## end of loop over cfgs if __name__ == '__main__': import user
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( sources=zip(filenames, wsnames, sreco_snapshots), getters=( lambda ws, i=iter(bincenters): i.next(), # x lambda ws, i=iter(sigma_lyon): i.next(), # y lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws, i=iter(esigma_lyon): i.next(), # ey ), xtitle='E_{T}^{#gamma} (GeV)',
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) ## End of loop over configurations. #============================================================================== for cfg in resolution_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'
) 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], colors = [kBlue, kRed, kBlack]) plotters.append(frp) ## end of loop over cfgs if __name__ == '__main__': import user
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) plotter.graphs.append(graph) plotter.titles.append(etar9.title) canvases.next('strue_FitRangeSystematics') plotter.xtitle = 'E_{T}^{#gamma} (GeV)'