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() canvases.next('c_' + cfg.name).SetGrid() ## Check if there is a problem with the ranges yrange = 'auto' 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)
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) 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() 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)
] oplus = lambda x, y: sqrt(x * x + y * y) for cfg in cfgs: #------------------------------------------------------------------------------ ## Scale Comparison ## PDF Morph: m translation for photon scale frp = FitResultPlotter( sources=zip(cfg.filenames, cfg.wsnames, cfg.strue_snapshots), getters=( lambda ws, i=iter(bincenters): i.next(), # x 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()
"""Returns functions that take a workspaces ws and return x, y, ex, ey where y and ey correspond to workspace variable of a given name and x and ex are pt bins.""" return ( lambda ws, i=iter(bincenters): i.next(), # x lambda ws: ws.var(name).getVal(), # y lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) categories = [c.name for c in cats] 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)
sgen_snapshots = ['sFit_sgen_mc_mmMass80_EB_lowR9_cbShape_PhoEt%d-%d_iter0' % (lo, hi) for lo, hi in binedges] def var_vs_pt(name): """Returns functions that take a workspaces ws and return x, y, ex, ey where y and ey correspond to workspace variable of a given name and x and ex are pt bins.""" return ( lambda ws, i = iter(bincenters): i.next(), # x lambda ws: ws.var(name).getVal(), # y lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) frp = FitResultPlotter( sources = zip(filenames, wsnames, strue_snapshots), getters = var_vs_pt('#Deltas'), xtitle = 'E_{T}^{#gamma} (GeV)', ytitle = 's_{true} = E^{#gamma}_{reco}/E^{#gamma}_{gen} - 1 (%)' ) canvases.next() frp.main() print frp.ytitle frp.dump() print ## MC truth resolution # canvases.next() # frp.main(getters = var_vs_pt('#sigma'), # ytitle = '#sigma(E^{#gamma}_{reco}/E^{#gamma}_{gen})') # frp.dump()
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)
% (lo, hi) for lo, hi in binedges], ## MC truth scale strue_snapshots = ['sFit_strue_mc_bifurGauss_mmMass90_EE_highR9_' 'PhoEt%d-%d' % (lo, hi) for lo, hi in binedges], ), ] 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)
def var_vs_pt(name): """Returns functions that take a workspaces ws and return x, y, ex, ey where y and ey correspond to workspace variable of a given name and x and ex are pt bins.""" return ( lambda ws, i=iter(bincenters): i.next(), # x lambda ws: ws.var(name).getVal(), # y lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) frp = FitResultPlotter( sources=zip(filenames, wsnames, strue_snapshots), getters=var_vs_pt('#Deltas'), xtitle='E_{T}^{#gamma} (GeV)', ytitle='s_{true} = E^{#gamma}_{reco}/E^{#gamma}_{gen} - 1 (%)') canvases.next() frp.main() print frp.ytitle frp.dump() print ## MC truth resolution # canvases.next() # frp.main(getters = var_vs_pt('#sigma'), # ytitle = '#sigma(E^{#gamma}_{reco}/E^{#gamma}_{gen})') # frp.dump()
def var_vs_pt(name): """Returns functions that take a workspaces ws and return x, y, ex, ey where y and ey correspond to workspace variable of a given name and x and ex are pt bins.""" return ( lambda ws, i = iter(bincenters): i.next(), # x lambda ws: ws.var(name).getVal(), # y lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) categories = [c.name for c in cats] 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
lambda ws: ws.var(name).getVal(), # y lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) plotters = [] #------------------------------------------------------------------------------ ## Scale Comparison ## Lyon frp = FitResultPlotter( 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
sgen_snapshots = ['sFit_sgen_mc_mmMass80_EB_lowR9_cbShape_PhoEt%d-%d_iter0' % (lo, hi) for lo, hi in binedges] def var_vs_pt(name): """Returns functions that take a workspaces ws and return x, y, ex, ey where y and ey correspond to workspace variable of a given name and x and ex are pt bins.""" return ( lambda ws, i = iter(bincenters): i.next(), # x lambda ws: ws.var(name).getVal(), # y lambda ws, i = iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) frp = FitResultPlotter( sources = zip(filenames, wsnames, strue_snapshots), getters = var_vs_pt('#Deltas'), xtitle = 'E_{T}^{#gamma} (GeV)', ytitle = 's_{true} = E^{#gamma}_{reco}/E^{#gamma}_{gen} - 1 (%)' ) canvases.next() frp.main() ## MC truth resolution # canvases.next() # frp.main(getters = var_vs_pt('#sigma'), # ytitle = '#sigma(E^{#gamma}_{reco}/E^{#gamma}_{gen})') # frp.dump() ## Scale from mmg canvases.next() frp.main(sources = zip(filenames, wsnames, sreco_snapshots),
lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) plotters = [] #------------------------------------------------------------------------------ ## Scale Comparison ## Lyon frp = FitResultPlotter( 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
'sFit_strue_mc_bifurGauss_mmMass80_EE_highR9_' 'PhoEt%d-%d' % (lo, hi) for lo, hi in binedges ], ), ] for cfg in cfgs: #------------------------------------------------------------------------------ ## Scale Comparison ## Lyon 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]['sreco']): i.next(), # y lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws, i=iter(lyonmc[cfg.name]['esreco']): 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() ## True
def make_resolution_plots(configurations): ''' For each configuration in the given list, overlays the graphs of resolution 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 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)
sources3 = make_list_of_sources(jobname_template3), getters1 = var_vs_pt_getter_factory('phoResTrue'), getters2 = var_vs_pt_getter_factory('phoRes'), getters3 = var_vs_pt_fitresult_getter_factory(fitresult, 'phoRes'), ) 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()
sources3 = make_list_of_sources(jobname_template3), getters1 = var_vs_pt_getter_factory('phoScaleTrue'), getters2 = var_vs_pt_getter_factory('#Deltas'), getters3 = var_vs_pt_getter_factory('phoScale'), ) scale_configurations.append(cfg) ## End of loop categories plotters = [] #============================================================================== for cfg in scale_configurations[:]: ## MC, EB, 2011A+B, 1 of 4 statistically independent tests xtitle = 'E_{T}^{#gamma} (GeV)' ytitle = 'E^{#gamma} Scale (%)' 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 = '2011 Baseline' plotter.getdata() plotter.makegraph() plotter.sources = cfg.sources3 plotter.getters = cfg.getters3 plotter.title = 'PHOSPHOR' plotter.getdata() plotter.makegraph()
def var_vs_pt(name): """Returns functions that take a workspaces ws and return x, y, ex, ey where y and ey correspond to workspace variable of a given name and x and ex are pt bins.""" return ( lambda ws, i=iter(bincenters): i.next(), # x lambda ws: ws.var(name).getVal(), # y lambda ws, i=iter(binhalfwidths): i.next(), # ex lambda ws: ws.var(name).getError(), # ey ) frp = FitResultPlotter( sources=zip(filenames, wsnames, strue_snapshots), getters=var_vs_pt('#Deltas'), xtitle='E_{T}^{#gamma} (GeV)', ytitle='s_{true} = E^{#gamma}_{reco}/E^{#gamma}_{gen} - 1 (%)') canvases.next() frp.main() ## MC truth resolution # canvases.next() # frp.main(getters = var_vs_pt('#sigma'), # ytitle = '#sigma(E^{#gamma}_{reco}/E^{#gamma}_{gen})') # frp.dump() ## Scale from mmg canvases.next() frp.main(sources=zip(filenames, wsnames, sreco_snapshots),
] oplus = lambda x, y: sqrt(x*x + y*y) for cfg in cfgs: #------------------------------------------------------------------------------ ## Scale Comparison ## PDF Morph: m translation for photon scale frp = FitResultPlotter( sources = zip(cfg.filenames, cfg.wsnames, cfg.strue_snapshots), getters = ( lambda ws, i = iter(bincenters): i.next(), # x 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()