Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
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)
Пример #6
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()

    ## mmMass < 85 GeV
    frp.sources = zip(cfg.filenames3, cfg.wsnames, cfg.sreco_snapshots3)
    frp.getters = var_vs_pt('#Deltas')
    frp.title = 'm_{#mu#mu} < 85 GeV'
    frp.getdata()
    frp.makegraph()

    ## mmMass < 90 GeV
    frp.sources = zip(cfg.filenames4, cfg.wsnames, cfg.sreco_snapshots4)
    frp.getters = var_vs_pt('#Deltas')
    frp.title = 'm_{#mu#mu} + m_{#mu#mu#gamma} < 190 GeV'
    frp.getdata()
    frp.makegraph()

    ## True
    frp.sources = zip(cfg.filenames3, cfg.wsnames, cfg.strue_snapshots)
    frp.getters = var_vs_pt('#Deltas')
    frp.title = 'MC Truth'
    frp.getdata()
    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(
    sources = zip(filenames, wsnames, sreco_snapshots),
Пример #8
0
        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 = 'Baseline',
        )
    frp.getdata()
    frp.makegraph()

    ## Proposal 1
    frp.getters = var_vs_pt('#Deltas')
    frp.title = 'Proposal 1'
    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 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])
Пример #9
0
        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
    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 Caltech, Lyon and MC truth scale
    canvases.next('s_' + cfg.name).SetGrid()
    frp.plotall(title=cfg.title,
                styles=[20, 25, 22],
                colors=[kBlue, kRed, kBlack])
Пример #10
0
            ),
            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],
                colors=[kBlue, kRed, kBlack])
Пример #11
0
    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(
    sources=zip(filenames, wsnames, sreco_snapshots),
    getters=(
Пример #12
0
## 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)
## End of loop over configurations.
Пример #13
0
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()
    
    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.
Пример #14
0
            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],
                colors = [kBlue, kRed, kBlack])
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))
        graph.SetPointError(i, graph.GetEX()[i], 0)
Пример #16
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],
                colors = [kBlue, kRed, kBlack])
Пример #17
0
    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)
Пример #18
0
        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
    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 Caltech, Lyon and MC truth scale
    canvases.next('s_' + cfg.name).SetGrid()
    frp.plotall(title = cfg.title,
                styles = [20, 25, 22],
                colors = [kBlue, kRed, kBlack])