Example #1
0
        TreeName=name,
        branchblock=branchblock.getvalue(),
        setbranchesblock=setbranchesblock.getvalue(),
        getbranchesblock=getbranchesblock.getvalue()
    )

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('template_file',
                        help='File path to .root file with template TTree')
    parser.add_argument('tree_path', help='Path in .root file to TTree')
    parser.add_argument('ClassName', help='Name of cython proxy class')

    args = parser.parse_args()

    file = ROOT.TFile(resolve_file(args.template_file), 'READ')
    tree = file.Get(args.tree_path)

    with open('%s.pyx' % args.ClassName, 'w') as pyx_file:
        pyx_file.write(make_pyx(args.ClassName, tree))

    # Figure out the root include and lib paths
    incdir = subprocess.Popen(
        ['root-config', '--incdir'],
        stdout=subprocess.PIPE).communicate()[0].strip()
    libdir = subprocess.Popen(
        ['root-config', '--libdir'],
        stdout=subprocess.PIPE).communicate()[0].strip()

    with open('%s_setup.py' % args.ClassName, 'w') as setup_file:
        setup_file.write(_setup_template.format(
Example #2
0
    parser.add_argument('--debug',
                        action='store_const',
                        const=True,
                        default=False,
                        help='Print debug output')

    args = parser.parse_args()
    import ROOT

    files = []
    if '.txt' in args.input:
        with open(args.input) as input_files:
            for input_file in input_files:
                input_file = input_file.strip()
                if input_file and '#' not in input_file:
                    files.append(resolve_file(input_file))
    else:
        files = [resolve_file(x.strip()) for x in args.input.split(',')]

    level = logging.INFO
    if args.debug:
        level = logging.DEBUG
    logging.basicConfig(stream=sys.stderr, level=level)

    log.info("Extracting meta info from %i files", len(files))

    total_events = 0
    run_lumis = {}

    for file in files:
        log.debug("OPEN file %s", file)
                        const=True, default=False,
                        help='If true, include the run-lumi mask result')
    parser.add_argument('--debug', action='store_const',
                        const=True, default=False,
                        help='Print debug output')

    args = parser.parse_args()
    import ROOT

    files = []
    if '.txt' in args.input:
        with open(args.input) as input_files:
            for input_file in input_files:
                input_file = input_file.strip()
                if input_file and '#' not in input_file:
                    files.append(resolve_file(input_file))
    else:
        files = [resolve_file(x.strip()) for x in args.input.split(',')]

    level = logging.INFO
    if args.debug:
        level = logging.DEBUG
    logging.basicConfig(stream=sys.stderr, level=level)

    log.info("Extracting meta info from %i files", len(files))

    total_events = 0
    run_lumis = {}

    for file in files:
        log.debug("OPEN file %s", file)