#!/usr/bin/env python

import logging;
import os
logging.basicConfig()
log = logging.getLogger(os.path.basename(__file__))
log.setLevel(logging.INFO)

import ROOT
from rootpy.plotting import set_style, Canvas, Hist, Legend
set_style('ATLAS', shape='rect')

from tools.sample import Sample
from tools.fancy import syst_envelop, envelop
from tools import CATEGORIES_MERGED, CATEGORIES_MVA
from tools.plotting import raw_np_plot

ROOT.gROOT.SetBatch(True)


if __name__ == '__main__':
    
    import argparse
    from rootpy.io import root_open

    parser = argparse.ArgumentParser()
    parser.add_argument('file1')
    parser.add_argument('--mva', action='store_true', default=False)
    args = parser.parse_args()


    rfile = root_open(args.file1, 'read')

#     sample = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt', 'ZttEWK'])


    Higgs = Sample('Higgs', 'red', 'H#rightarrow#tau#tau', sub_samples=['ggH', 'VBFH', 'WH', 'ZH', 'ttH'])
    ztt = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt', 'ZttEWK'])
    Fake = Sample('Fake', 'green', 'Fake')
    samples = [Higgs, ztt, Fake]
        
    categories = CATEGORIES_MERGED
    if args.mva:
        categories = CATEGORIES_MVA
    
    out = root_open('./plots/np.root', 'recreate')
    for cat in categories:
        out.mkdir(cat)
        out.cd(cat)
        for sample in samples:
            out.mkdir('{}/{}'.format(cat, sample.name))

            systs = sample.syst_dict(cat, rfile)
            keys = systs.keys()
            
            jet_keys = filter(lambda k: 'jet_' in k, keys)
            met_keys = filter(lambda k: 'met_' in k, keys)
            tau_keys = filter(lambda k: 'tau_' in k, keys)
            theory_keys = filter(lambda k: 'theory_' in k, keys)
            other_keys = filter(lambda k: k not in jet_keys + met_keys + tau_keys + theory_keys, keys)

            log.info('{}/{}/jet'.format(cat, sample.name))
            out.mkdir('{}/{}/jet'.format(cat, sample.name))
            out.cd('{}/{}/jet'.format(cat, sample.name))
            for k in jet_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/met'.format(cat, sample.name))
            out.mkdir('{}/{}/met'.format(cat, sample.name))
            out.cd('{}/{}/met'.format(cat, sample.name))
            for k in met_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/tau'.format(cat, sample.name))
            out.mkdir('{}/{}/tau'.format(cat, sample.name))
            out.cd('{}/{}/tau'.format(cat, sample.name))
            for k in tau_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/theory'.format(cat, sample.name))
            out.mkdir('{}/{}/theory'.format(cat, sample.name))
            out.cd('{}/{}/theory'.format(cat, sample.name))
            for k in theory_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/other'.format(cat, sample.name))
            out.mkdir('{}/{}/other'.format(cat, sample.name))
            out.cd('{}/{}/other'.format(cat, sample.name))
            for k in other_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()


    out.Close()


de741e37e347786a974388d17e19adbe96a905a2
<mask token>

<mask token>
logging.basicConfig()
<mask token>
log.setLevel(logging.INFO)
<mask token>
set_style('ATLAS', shape='rect')
<mask token>
ROOT.gROOT.SetBatch(True)
if __name__ == '__main__':
    import argparse
    from rootpy.io import root_open
    parser = argparse.ArgumentParser()
    parser.add_argument('file1')
    parser.add_argument('--mva', action='store_true', default=False)
    args = parser.parse_args()
    rfile = root_open(args.file1, 'read')
    Higgs = Sample('Higgs', 'red', 'H#rightarrow#tau#tau', sub_samples=[
        'ggH', 'VBFH', 'WH', 'ZH', 'ttH'])
    ztt = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt',
        'ZttEWK'])
    Fake = Sample('Fake', 'green', 'Fake')
    samples = [Higgs, ztt, Fake]
    categories = CATEGORIES_MERGED
    if args.mva:
        categories = CATEGORIES_MVA
    out = root_open('./plots/np.root', 'recreate')
    for cat in categories:
        out.mkdir(cat)
        out.cd(cat)
        for sample in samples:
            out.mkdir('{}/{}'.format(cat, sample.name))
            systs = sample.syst_dict(cat, rfile)
            keys = systs.keys()
            jet_keys = filter(lambda k: 'jet_' in k, keys)
            met_keys = filter(lambda k: 'met_' in k, keys)
            tau_keys = filter(lambda k: 'tau_' in k, keys)
            theory_keys = filter(lambda k: 'theory_' in k, keys)
            other_keys = filter(lambda k: k not in jet_keys + met_keys +
                tau_keys + theory_keys, keys)
            log.info('{}/{}/jet'.format(cat, sample.name))
            out.mkdir('{}/{}/jet'.format(cat, sample.name))
            out.cd('{}/{}/jet'.format(cat, sample.name))
            for k in jet_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/met'.format(cat, sample.name))
            out.mkdir('{}/{}/met'.format(cat, sample.name))
            out.cd('{}/{}/met'.format(cat, sample.name))
            for k in met_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/tau'.format(cat, sample.name))
            out.mkdir('{}/{}/tau'.format(cat, sample.name))
            out.cd('{}/{}/tau'.format(cat, sample.name))
            for k in tau_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/theory'.format(cat, sample.name))
            out.mkdir('{}/{}/theory'.format(cat, sample.name))
            out.cd('{}/{}/theory'.format(cat, sample.name))
            for k in theory_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/other'.format(cat, sample.name))
            out.mkdir('{}/{}/other'.format(cat, sample.name))
            out.cd('{}/{}/other'.format(cat, sample.name))
            for k in other_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
    out.Close()

<mask token>
logging.basicConfig()
log = logging.getLogger(os.path.basename(__file__))
log.setLevel(logging.INFO)
<mask token>
set_style('ATLAS', shape='rect')
<mask token>
ROOT.gROOT.SetBatch(True)
if __name__ == '__main__':
    import argparse
    from rootpy.io import root_open
    parser = argparse.ArgumentParser()
    parser.add_argument('file1')
    parser.add_argument('--mva', action='store_true', default=False)
    args = parser.parse_args()
    rfile = root_open(args.file1, 'read')
    Higgs = Sample('Higgs', 'red', 'H#rightarrow#tau#tau', sub_samples=[
        'ggH', 'VBFH', 'WH', 'ZH', 'ttH'])
    ztt = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt',
        'ZttEWK'])
    Fake = Sample('Fake', 'green', 'Fake')
    samples = [Higgs, ztt, Fake]
    categories = CATEGORIES_MERGED
    if args.mva:
        categories = CATEGORIES_MVA
    out = root_open('./plots/np.root', 'recreate')
    for cat in categories:
        out.mkdir(cat)
        out.cd(cat)
        for sample in samples:
            out.mkdir('{}/{}'.format(cat, sample.name))
            systs = sample.syst_dict(cat, rfile)
            keys = systs.keys()
            jet_keys = filter(lambda k: 'jet_' in k, keys)
            met_keys = filter(lambda k: 'met_' in k, keys)
            tau_keys = filter(lambda k: 'tau_' in k, keys)
            theory_keys = filter(lambda k: 'theory_' in k, keys)
            other_keys = filter(lambda k: k not in jet_keys + met_keys +
                tau_keys + theory_keys, keys)
            log.info('{}/{}/jet'.format(cat, sample.name))
            out.mkdir('{}/{}/jet'.format(cat, sample.name))
            out.cd('{}/{}/jet'.format(cat, sample.name))
            for k in jet_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/met'.format(cat, sample.name))
            out.mkdir('{}/{}/met'.format(cat, sample.name))
            out.cd('{}/{}/met'.format(cat, sample.name))
            for k in met_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/tau'.format(cat, sample.name))
            out.mkdir('{}/{}/tau'.format(cat, sample.name))
            out.cd('{}/{}/tau'.format(cat, sample.name))
            for k in tau_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/theory'.format(cat, sample.name))
            out.mkdir('{}/{}/theory'.format(cat, sample.name))
            out.cd('{}/{}/theory'.format(cat, sample.name))
            for k in theory_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/other'.format(cat, sample.name))
            out.mkdir('{}/{}/other'.format(cat, sample.name))
            out.cd('{}/{}/other'.format(cat, sample.name))
            for k in other_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
    out.Close()

import logging
import os
logging.basicConfig()
log = logging.getLogger(os.path.basename(__file__))
log.setLevel(logging.INFO)
import ROOT
from rootpy.plotting import set_style, Canvas, Hist, Legend
set_style('ATLAS', shape='rect')
from tools.sample import Sample
from tools.fancy import syst_envelop, envelop
from tools import CATEGORIES_MERGED, CATEGORIES_MVA
from tools.plotting import raw_np_plot
ROOT.gROOT.SetBatch(True)
if __name__ == '__main__':
    import argparse
    from rootpy.io import root_open
    parser = argparse.ArgumentParser()
    parser.add_argument('file1')
    parser.add_argument('--mva', action='store_true', default=False)
    args = parser.parse_args()
    rfile = root_open(args.file1, 'read')
    Higgs = Sample('Higgs', 'red', 'H#rightarrow#tau#tau', sub_samples=[
        'ggH', 'VBFH', 'WH', 'ZH', 'ttH'])
    ztt = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt',
        'ZttEWK'])
    Fake = Sample('Fake', 'green', 'Fake')
    samples = [Higgs, ztt, Fake]
    categories = CATEGORIES_MERGED
    if args.mva:
        categories = CATEGORIES_MVA
    out = root_open('./plots/np.root', 'recreate')
    for cat in categories:
        out.mkdir(cat)
        out.cd(cat)
        for sample in samples:
            out.mkdir('{}/{}'.format(cat, sample.name))
            systs = sample.syst_dict(cat, rfile)
            keys = systs.keys()
            jet_keys = filter(lambda k: 'jet_' in k, keys)
            met_keys = filter(lambda k: 'met_' in k, keys)
            tau_keys = filter(lambda k: 'tau_' in k, keys)
            theory_keys = filter(lambda k: 'theory_' in k, keys)
            other_keys = filter(lambda k: k not in jet_keys + met_keys +
                tau_keys + theory_keys, keys)
            log.info('{}/{}/jet'.format(cat, sample.name))
            out.mkdir('{}/{}/jet'.format(cat, sample.name))
            out.cd('{}/{}/jet'.format(cat, sample.name))
            for k in jet_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/met'.format(cat, sample.name))
            out.mkdir('{}/{}/met'.format(cat, sample.name))
            out.cd('{}/{}/met'.format(cat, sample.name))
            for k in met_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/tau'.format(cat, sample.name))
            out.mkdir('{}/{}/tau'.format(cat, sample.name))
            out.cd('{}/{}/tau'.format(cat, sample.name))
            for k in tau_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/theory'.format(cat, sample.name))
            out.mkdir('{}/{}/theory'.format(cat, sample.name))
            out.cd('{}/{}/theory'.format(cat, sample.name))
            for k in theory_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
            log.info('{}/{}/other'.format(cat, sample.name))
            out.mkdir('{}/{}/other'.format(cat, sample.name))
            out.cd('{}/{}/other'.format(cat, sample.name))
            for k in other_keys:
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat,
                    sample.name))
                c.Write()
    out.Close()

#!/usr/bin/env python

import logging;
import os
logging.basicConfig()
log = logging.getLogger(os.path.basename(__file__))
log.setLevel(logging.INFO)

import ROOT
from rootpy.plotting import set_style, Canvas, Hist, Legend
set_style('ATLAS', shape='rect')

from tools.sample import Sample
from tools.fancy import syst_envelop, envelop
from tools import CATEGORIES_MERGED, CATEGORIES_MVA
from tools.plotting import raw_np_plot

ROOT.gROOT.SetBatch(True)


if __name__ == '__main__':
    
    import argparse
    from rootpy.io import root_open

    parser = argparse.ArgumentParser()
    parser.add_argument('file1')
    parser.add_argument('--mva', action='store_true', default=False)
    args = parser.parse_args()


    rfile = root_open(args.file1, 'read')

#     sample = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt', 'ZttEWK'])


    Higgs = Sample('Higgs', 'red', 'H#rightarrow#tau#tau', sub_samples=['ggH', 'VBFH', 'WH', 'ZH', 'ttH'])
    ztt = Sample('Ztt', 'blue', 'Z#rightarrow#tau#tau', sub_samples=['Ztt', 'ZttEWK'])
    Fake = Sample('Fake', 'green', 'Fake')
    samples = [Higgs, ztt, Fake]
        
    categories = CATEGORIES_MERGED
    if args.mva:
        categories = CATEGORIES_MVA
    
    out = root_open('./plots/np.root', 'recreate')
    for cat in categories:
        out.mkdir(cat)
        out.cd(cat)
        for sample in samples:
            out.mkdir('{}/{}'.format(cat, sample.name))

            systs = sample.syst_dict(cat, rfile)
            keys = systs.keys()
            
            jet_keys = filter(lambda k: 'jet_' in k, keys)
            met_keys = filter(lambda k: 'met_' in k, keys)
            tau_keys = filter(lambda k: 'tau_' in k, keys)
            theory_keys = filter(lambda k: 'theory_' in k, keys)
            other_keys = filter(lambda k: k not in jet_keys + met_keys + tau_keys + theory_keys, keys)

            log.info('{}/{}/jet'.format(cat, sample.name))
            out.mkdir('{}/{}/jet'.format(cat, sample.name))
            out.cd('{}/{}/jet'.format(cat, sample.name))
            for k in jet_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/met'.format(cat, sample.name))
            out.mkdir('{}/{}/met'.format(cat, sample.name))
            out.cd('{}/{}/met'.format(cat, sample.name))
            for k in met_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/tau'.format(cat, sample.name))
            out.mkdir('{}/{}/tau'.format(cat, sample.name))
            out.cd('{}/{}/tau'.format(cat, sample.name))
            for k in tau_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/theory'.format(cat, sample.name))
            out.mkdir('{}/{}/theory'.format(cat, sample.name))
            out.cd('{}/{}/theory'.format(cat, sample.name))
            for k in theory_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()

            log.info('{}/{}/other'.format(cat, sample.name))
            out.mkdir('{}/{}/other'.format(cat, sample.name))
            out.cd('{}/{}/other'.format(cat, sample.name))
            for k in other_keys:
                #                 log.info('\t {} \t {} \t {}'.format(k, systs[k]['high'], systs[k]['low']))
                c = raw_np_plot(rfile, k, cat, sample)
                c.name = k
                c.title = k
                c.SaveAs('./plots/np_plot_{0}_{1}_{2}.pdf'.format(k, cat, sample.name))
                c.Write()


    out.Close()

