Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 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]:
        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)