Exemple #1
0
def draw_momenta_kkpi(figpath, datatype, mode, label, test):
    modekey = tools.get_modekey(mode)
    sname = attr.modes[modekey]['sname'].lower()
    figname = '%s_momenta' % sname

    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')

    #tab = DHadTable()
    #tab.row_append(['Name', 'Data/MC'])
                   
    # --------------------------------------------------
    h_pkm = {}; h_pkp = {}; h_ppi = {}
    h_pkm_c = {}; h_pkp_c = {}; h_ppi_c = {}

    for datatype in [datatype]:
        selfile = get_selfile(datatype, mode, label, test=test)
        selfile = selfile.replace('/trkmtm/', '/trkmtm2/')

        f = TFile(selfile)
        if datatype == 'signal': # or datatype == 'generic':
            tp = 'mc'
        #if datatype == 'data':
        #    tp = 'data'

        h_pkm[tp]= f.Get('h_pk'+tp)
        h_pkp[tp]= f.Get('h_ppi1'+tp)
        h_ppi[tp]= f.Get('h_ppiz'+tp)

        h_pkm_c[tp]= f.Get('h_pk_c'+tp)
        h_pkp_c[tp]= f.Get('h_ppi1_c'+tp)
        h_ppi_c[tp]= f.Get('h_ppiz_c'+tp)

        f.Clear()

    #ratio = h_pkm['data'].Integral()/h_pkm['mc'].Integral()

    c1 = TCanvas('c1', 'canvas', 900, 900)
    c1.Divide(2,2)
    c1.cd(1)
    h_pkm['mc'].Draw()
    #h_pkm['data'].Draw('PE')
    #h_pkm['mc'].Scale(ratio)
    #h_pkm['mc'].Draw('SAME')
    c1.cd(2)
    h_pkp['mc'].Draw()
    #h_pkp['data'].Draw('PE')
    #h_pkp['mc'].Scale(ratio)
    #h_pkp['mc'].Draw('SAME')
    c1.cd(3)
    c1.cd(4)
    h_ppi['mc'].Draw()
    #h_ppi['data'].Draw('PE')
    #h_ppi['mc'].Scale(ratio)
    #h_ppi['mc'].Draw('SAME')

    c1.Print(epsfile)
    tools.eps2pdf(epsfile)
Exemple #2
0
def draw_momenta_ks3pi(datatype, mode, label, test):
    modekey = tools.get_modekey(mode)
    sname = attr.modes[modekey]['sname'].lower()
    figname = '%s_momenta' % sname
    figpath = os.path.join(attr.figpath, label, 'trkmtm')
    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')
    tab = DHadTable()
    tab.row_append(['Name', 'Data/MC'])
                   
    # --------------------------------------------------
    h_pks = {}; h_ppi1 = {}; h_ppi2 = {}; h_ppim = {}
    h_pks_c = {}; h_ppi1_c = {}; h_ppi2_c = {}; h_ppim_c = {}

    for datatype in datatype.split('/'):
        selfile = get_selfile(datatype, mode, label, test=test)
        selfile = selfile.replace('/trkmtm/', '/trkmtm2/')

        f = TFile(selfile)
        if datatype == 'signal' or datatype == 'generic':
            tp = 'mc'
        if datatype == 'data':
            tp = 'data'

        h_pks[tp]= f.Get('h_pks'+tp)
        h_ppi1[tp]= f.Get('h_ppi1'+tp)
        h_ppi2[tp]= f.Get('h_ppi2'+tp)
        h_ppim[tp]= f.Get('h_ppim'+tp)

        h_pks_c[tp]= f.Get('h_pk_c'+tp)
        h_ppi1_c[tp]= f.Get('h_ppi1_c'+tp)
        h_ppi2_c[tp]= f.Get('h_ppi2_c'+tp)
        h_ppim_c[tp]= f.Get('h_ppim_c'+tp)

        f.Clear()

    ratio = h_pks['data'].Integral()/h_pks['mc'].Integral()

    c1 = TCanvas('c1', 'canvas', 900, 900)
    c1.Divide(2,2)
    c1.cd(1)
    h_pks['data'].Draw('PE')
    h_pks['mc'].Scale(ratio)
    h_pks['mc'].Draw('SAME')
    c1.cd(2)
    h_ppi1['data'].Draw('PE')
    h_ppi1['mc'].Scale(ratio)
    h_ppi1['mc'].Draw('SAME')
    c1.cd(3)
    h_ppi2['data'].Draw('PE')
    h_ppi2['mc'].Scale(ratio)
    h_ppi2['mc'].Draw('SAME')
    c1.cd(4)
    h_ppim['data'].Draw('PE')
    h_ppim['mc'].Scale(ratio)
    h_ppim['mc'].Draw('SAME')

    c1.Print(epsfile)
    tools.eps2pdf(epsfile)

    # --------------------------------------------------
    c1.Clear()
    c1.Divide(2,2)

    c1.cd(1)
    h_pks_c['data'].Draw('PE')
    lratio = h_pks_c['data'].Integral()/h_pks_c['mc'].Integral()
    #print 'k:', lratio/ratio
    tab.row_append(['K', lratio/ratio])

    h_pks_c['mc'].Scale(lratio)
    h_pks_c['mc'].Draw('SAME,HIST')
    c1.cd(2)
    h_ppi1_c['data'].Draw('PE')
    lratio = h_ppi1_c['data'].Integral()/h_ppi1_c['mc'].Integral()
    #print 'pi1:', lratio/ratio
    tab.row_append(['pi1', lratio/ratio])

    h_ppi1_c['mc'].Scale(lratio)
    h_ppi1_c['mc'].Draw('SAME,HIST')
    c1.cd(3)
    h_ppi2_c['data'].Draw('PE')
    lratio = h_ppi2_c['data'].Integral()/h_ppi2_c['mc'].Integral()
    #print 'pi2:', lratio/ratio
    tab.row_append(['pi2', lratio/ratio])

    h_ppi2_c['mc'].Scale(lratio)
    h_ppi2_c['mc'].Draw('SAME,HIST')
    c1.cd(4)
    h_ppim_c['data'].Draw('PE')
    lratio = h_ppim_c['data'].Integral()/h_ppim_c['mc'].Integral()
    #print 'pim:', lratio/ratio
    tab.row_append(['pim', lratio/ratio])

    h_ppim_c['mc'].Scale(lratio)
    h_ppim_c['mc'].Draw('SAME,HIST')
    
    tab.column_trim('Data/MC', rnd='.0001')

    figname = '%s_momentacor' % sname
    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')
    c1.Print(epsfile)
    tools.eps2pdf(epsfile)

    tabname = '%s_syst' % sname
    tab.output(tabname, label=label, export_html=False)
Exemple #3
0
def draw_momenta_kkpi(figpath, datatype, mode, label, test):
    modekey = tools.get_modekey(mode)
    sname = attr.modes[modekey]['sname'].lower()
    figname = '%s_momenta' % sname
    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')
    tab = DHadTable()
    tab.row_append(['Name', 'Data/MC'])
                   
    # --------------------------------------------------
    h_pkm = {}; h_pkp = {}; h_ppi = {}
    h_pkm_c = {}; h_pkp_c = {}; h_ppi_c = {}

    for datatype in datatype.split('/'):
        selfile = get_selfile(datatype, mode, label, test=test)
        selfile = selfile.replace('/trkmtm/', '/trkmtm2/')

        f = TFile(selfile)
        if datatype == 'signal' or datatype == 'generic':
            tp = 'mc'
        if datatype == 'data':
            tp = 'data'

        h_pkm[tp]= f.Get('h_pk'+tp)
        h_pkp[tp]= f.Get('h_ppi1'+tp)
        h_ppi[tp]= f.Get('h_ppiz'+tp)

        h_pkm_c[tp]= f.Get('h_pk_c'+tp)
        h_pkp_c[tp]= f.Get('h_ppi1_c'+tp)
        h_ppi_c[tp]= f.Get('h_ppiz_c'+tp)

        f.Clear()

    ratio = h_pkm['data'].Integral()/h_pkm['mc'].Integral()

    c1 = TCanvas('c1', 'canvas', 900, 900)
    c1.Divide(2,2)
    c1.cd(1)
    h_pkm['data'].Draw('PE')
    h_pkm['mc'].Scale(ratio)
    h_pkm['mc'].Draw('SAME')
    c1.cd(2)
    h_pkp['data'].Draw('PE')
    h_pkp['mc'].Scale(ratio)
    h_pkp['mc'].Draw('SAME')
    c1.cd(3)
    c1.cd(4)
    h_ppi['data'].Draw('PE')
    h_ppi['mc'].Scale(ratio)
    h_ppi['mc'].Draw('SAME')

    c1.Print(epsfile)
    tools.eps2pdf(epsfile)

    # --------------------------------------------------
    c1.Clear()
    c1.Divide(2,2)

    c1.cd(1)
    h_pkm_c['data'].Draw('PE')
    lratio = h_pkm_c['data'].Integral()/h_pkm_c['mc'].Integral()
    #print 'km:', lratio/ratio
    tab.row_append(['Km', lratio/ratio])

    h_pkm_c['mc'].Scale(lratio)
    h_pkm_c['mc'].Draw('SAME')


    c1.cd(2)
    h_pkp_c['data'].Draw('PE')
    lratio = h_pkp_c['data'].Integral()/h_pkp_c['mc'].Integral()
    #print 'kp:', lratio/ratio
    tab.row_append(['Kp', lratio/ratio])

    h_pkp_c['mc'].Scale(lratio)
    h_pkp_c['mc'].Draw('SAME')

    c1.cd(3)
    c1.cd(4)
    h_ppi_c['data'].Draw('PE')
    lratio = h_ppi_c['data'].Integral()/h_ppi_c['mc'].Integral()
    #print 'pi:', lratio/ratio
    tab.row_append(['pi', lratio/ratio])

    h_ppi_c['mc'].Scale(lratio)
    h_ppi_c['mc'].Draw('SAME')

    tab.column_trim('Data/MC', rnd='.0001')

    figname = '%s_momentacor' % sname
    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')
    c1.Print(epsfile)
    tools.eps2pdf(epsfile)

    tabname = '%s_syst' % sname
    tab.output(tabname, label=label, export_html=False)
Exemple #4
0
def draw_momenta_kpipi0(datatype, mode, label, test):
    modekey = tools.get_modekey(mode)
    sname = attr.modes[modekey]['sname'].lower()
    figname = '%s_momenta' % sname
    figpath = os.path.join(attr.figpath, label, 'trkmtm')
    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')

    h_mbc = {}; kpi1 = {} ; pipih = {}; 
    kpiz = {}; kpipih = {}; 
    h_pk = {}; h_ppi1 = {}; h_ppiz = {}
    h_pk_c = {}; h_ppi1_c = {}; h_ppiz_c = {}
    h_pk_sb = {}; h_ppi1_sb = {}; h_ppiz_sb = {}
    h_pk_sb_c = {}; h_ppi1_sb_c = {}; h_ppiz_sb_c = {}
    h_angk = {}; h_angpi1 = {}; h_angpiz = {}

    for datatype in datatype.split('/'):
        selfile = get_selfile(datatype, mode, label, test=test)
        selfile = selfile.replace('/trkmtm/', '/trkmtm2/')

        f = TFile(selfile)
        if datatype == 'signal' or datatype == 'generic':
            tp = 'mc'
        if datatype == 'data':
            tp = 'data'
            
        h_mbc[tp]= f.Get('h_mbc_'+tp)

        kpi1[tp]= f.Get('kpi1_'+tp)
        pipih[tp]= f.Get('pipih_'+tp)
        kpiz[tp]= f.Get('kpiz_'+tp)
        kpipih[tp]= f.Get('kpipih_'+tp)
    
        h_pk[tp]= f.Get('h_pk_'+tp)
        h_ppi1[tp]= f.Get('h_ppi1_'+tp)
        h_ppiz[tp]= f.Get('h_ppiz_'+tp)
        
        h_pk_c[tp]= f.Get('h_pk_c_'+tp)
        h_ppi1_c[tp]= f.Get('h_ppi1_c_'+tp)
        h_ppiz_c[tp]= f.Get('h_ppiz_c_'+tp)
   
        h_pk_sb[tp]= f.Get('h_pk_sb_'+tp)
        h_ppi1_sb[tp]= f.Get('h_ppi1_sb_'+tp)
        h_ppiz_sb[tp]= f.Get('h_ppiz_sb_'+tp)

        h_pk_sb_c[tp]= f.Get('h_pk_sb_c_'+tp)
        h_ppi1_sb_c[tp]= f.Get('h_ppi1_sb_c_'+tp)
        h_ppiz_sb_c[tp]= f.Get('h_ppiz_sb_c_'+tp)

        h_angk[tp]= f.Get('h_angk_'+tp)
        h_angpi1[tp]= f.Get('h_angpi1_'+tp)
        h_angpiz[tp]= f.Get('h_angpiz_'+tp)

        f.Clear()

    ratio = h_pk['data'].Integral()/h_pk['mc'].Integral()

    c1 = TCanvas('c1', 'canvas', 900, 900)
    c1.Divide(2,2)
    c1.cd(1)
    h_pk['data'].Draw('PE')
    h_pk['mc'].Scale(ratio)
    h_pk['mc'].Draw('SAME')
    c1.cd(2)
    h_ppi1['data'].Draw('PE')
    h_ppi1['mc'].Scale(ratio)
    h_ppi1['mc'].Draw('SAME')
    c1.cd(3)
    c1.cd(4)
    h_ppiz['data'].Draw('PE')
    h_ppiz['mc'].Scale(ratio)
    h_ppiz['mc'].Draw('SAME')

    c1.Print(epsfile)
    tools.eps2pdf(epsfile)

    tab = DHadTable()
    tab.row_append(['Name', 'Data/MC'])
                   
    c1.Clear()
    c1.Divide(2,2)
    c1.cd(1)
    h_pk_c['data'].Draw('PE')
    lratio = h_pk_c['data'].Integral()/h_pk_c['mc'].Integral()
    #print 'k:', lratio/ratio

    tab.row_append(['K', lratio/ratio])
    
    h_pk_c['mc'].Scale(lratio)
    h_pk_c['mc'].Draw('SAME')
    c1.cd(2)
    h_ppi1_c['data'].Draw('PE')
    lratio = h_ppi1_c['data'].Integral()/h_ppi1_c['mc'].Integral()
    #print 'pi1:', lratio/ratio

    tab.row_append(['pi1', lratio/ratio])

    h_ppi1_c['mc'].Scale(lratio)
    h_ppi1_c['mc'].Draw('SAME')
    c1.cd(3)
    c1.cd(4)
    h_ppiz_c['data'].Draw('PE')
    lratio = h_ppiz_c['data'].Integral()/h_ppiz_c['mc'].Integral()
    #print 'piz:', lratio/ratio

    tab.row_append(['piz', lratio/ratio])

    h_ppiz_c['mc'].Scale(lratio)
    h_ppiz_c['mc'].Draw('SAME')

    tab.column_trim('Data/MC', rnd='.0001')

    figname = '%s_momentacor' % sname
    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')
    c1.Print(epsfile)
    tools.eps2pdf(epsfile)

    tabname = '%s_syst' % sname
    tab.output(tabname, label=label, export_html=False)
Exemple #5
0
def main(opts, args):
    tools.set_root_style(stat=1, grid=0, PadTopMargin=0.1,
                         PadLeftMargin = 0.15)

    parsed = parse_args(args)
    datatype = parsed[0]
    tag = parsed[1]
    modes = parsed[2]
    label = parsed[3]

    if tag != 'single':
        # only deal with single tag
        raise NameError(tag)

    figpath = os.path.join(attr.figpath, label, 'trkmtm')
    
    for mode in modes:
        modekey = tools.get_modekey(mode)
        selfile = get_selfile(datatype, mode, label, test=opts.test)

        efffile = selfile.replace('.root', '.db')

        sname = attr.modes[modekey]['sname'].lower()
        f = TFile(selfile)

        effs = shelve.open(efffile)

        if sname == 'kpipi0':
            h_pk = {}; h_ppi1 = {}; h_ppiz = {}
            for tp in ('mc', 'mctruth'):
                h_pk[tp] = f.Get('h_pk_' + tp)
                h_ppi1[tp] = f.Get('h_ppi1_' + tp)
                h_ppiz[tp] = f.Get('h_ppiz_' + tp)
            draw_effmomenta_kpipi0(figpath, effs, sname, h_pk, h_ppi1, h_ppiz)
        elif sname == 'k3pi':
            h_pk = {}; h_ppi1 = {}; h_ppi2 = {}; h_ppim = {}
            for tp in ('mc', 'mctruth'):
                h_pk[tp] = f.Get('h_pk_' + tp)
                h_ppi1[tp] = f.Get('h_ppi1_' + tp)
                h_ppi2[tp] = f.Get('h_ppi2_' + tp)
                h_ppim[tp] = f.Get('h_ppim_' + tp)
            draw_effmomenta_k3pi(figpath, effs, sname, h_pk, h_ppi1, h_ppi2, h_ppim)
        elif sname == 'kpipi':
            h_pk = {}; h_ppi1 = {}; h_ppi2 = {}
            for tp in ('mc', 'mctruth'):
                h_pk[tp] = f.Get('h_pk_' + tp)
                h_ppi1[tp] = f.Get('h_ppi1_' + tp)
                h_ppi2[tp] = f.Get('h_ppi2_' + tp)
            draw_effmomenta_kpipi(figpath, effs, sname, h_pk, h_ppi1, h_ppi2)
        elif sname == 'kpipipi0':
            h_pk = {}; h_ppi1 = {}; h_ppi2 = {}; h_ppiz = {}
            for tp in ('mc', 'mctruth'):
                h_pk[tp] = f.Get('h_pk_' + tp)
                h_ppi1[tp] = f.Get('h_ppi1_' + tp)
                h_ppi2[tp] = f.Get('h_ppi2_' + tp)
                h_ppiz[tp] = f.Get('h_ppim_' + tp)
            draw_effmomenta_kpipipi0(figpath, effs, sname, h_pk, h_ppi1, h_ppi2, h_ppiz)
        elif sname == 'kspipi0':
            h_pks = {}; h_ppi1 = {}; h_ppiz = {}
            for tp in ('mc', 'mctruth'):
                h_pks[tp] = f.Get('h_pks_' + tp)
                h_ppi1[tp] = f.Get('h_ppi1_' + tp)
                h_ppiz[tp] = f.Get('h_ppiz_' + tp)
            draw_effmomenta_kspipi0(figpath, effs, sname, h_pks, h_ppi1, h_ppiz)
        elif sname == 'ks3pi':
            h_pks = {}; h_ppi1 = {}; h_ppi2 = {}; h_ppim = {}
            for tp in ('mc', 'mctruth'):
                h_pks[tp] = f.Get('h_pk_' + tp)
                h_ppi1[tp] = f.Get('h_ppi1_' + tp)
                h_ppi2[tp] = f.Get('h_ppi2_' + tp)
                h_ppim[tp] = f.Get('h_ppim_' + tp)
            draw_effmomenta_ks3pi(figpath, effs, sname, h_pks, h_ppi1, h_ppi2, h_ppim)
        elif sname == 'kkpi':
            h_pkm = {}; h_pkp = {}; h_ppi = {}
            for tp in ('mc', 'mctruth'):
                h_pkm[tp] = f.Get('h_pkm_' + tp)
                h_pkp[tp] = f.Get('h_pkp_' + tp)
                h_ppi[tp] = f.Get('h_ppi_' + tp)
            draw_effmomenta_kkpi(figpath, effs, sname, h_pkp, h_pkm, h_ppi)

        else:
            raise NameError(sname)
Exemple #6
0
def draw_momenta_kkpi(figpath, datatype, mode, label, test):
    modekey = tools.get_modekey(mode)
    sname = attr.modes[modekey]['sname'].lower()
    figname = '%s_momenta' % sname

    epsfile = set_file(extbase=figpath, comname=figname, ext='eps')

    #tab = DHadTable()
    #tab.row_append(['Name', 'Data/MC'])

    # --------------------------------------------------
    h_pkm = {}
    h_pkp = {}
    h_ppi = {}
    h_pkm_c = {}
    h_pkp_c = {}
    h_ppi_c = {}

    for datatype in [datatype]:
        selfile = get_selfile(datatype, mode, label, test=test)
        selfile = selfile.replace('/trkmtm/', '/trkmtm2/')

        f = TFile(selfile)
        if datatype == 'signal':  # or datatype == 'generic':
            tp = 'mc'
        #if datatype == 'data':
        #    tp = 'data'

        h_pkm[tp] = f.Get('h_pk' + tp)
        h_pkp[tp] = f.Get('h_ppi1' + tp)
        h_ppi[tp] = f.Get('h_ppiz' + tp)

        h_pkm_c[tp] = f.Get('h_pk_c' + tp)
        h_pkp_c[tp] = f.Get('h_ppi1_c' + tp)
        h_ppi_c[tp] = f.Get('h_ppiz_c' + tp)

        f.Clear()

    #ratio = h_pkm['data'].Integral()/h_pkm['mc'].Integral()

    c1 = TCanvas('c1', 'canvas', 900, 900)
    c1.Divide(2, 2)
    c1.cd(1)
    h_pkm['mc'].Draw()
    #h_pkm['data'].Draw('PE')
    #h_pkm['mc'].Scale(ratio)
    #h_pkm['mc'].Draw('SAME')
    c1.cd(2)
    h_pkp['mc'].Draw()
    #h_pkp['data'].Draw('PE')
    #h_pkp['mc'].Scale(ratio)
    #h_pkp['mc'].Draw('SAME')
    c1.cd(3)
    c1.cd(4)
    h_ppi['mc'].Draw()
    #h_ppi['data'].Draw('PE')
    #h_ppi['mc'].Scale(ratio)
    #h_ppi['mc'].Draw('SAME')

    c1.Print(epsfile)
    tools.eps2pdf(epsfile)