Example #1
0
import math
import os
import re
import sys
import logging
import string
import ROOT

import PhysicsProject.PhysicsProjectConfig as Config
import PhysicsProject.PhysicsProjectXSec as XSec
import PhysicsProject.PhysicsProjectInfo as ttH

if options.batch or not options.wait:
    ROOT.gROOT.SetBatch(True)

log = Config.getLog(__name__, debug=options.debug)

#================================================================================


class OneCol:
    def __init__(self,
                 name,
                 title,
                 hist,
                 no_err=False,
                 no_dec=False,
                 do_sqrt=False):

        self.name = name
        self.title = title
Example #2
0
p.add_option('--pref', type='string', default=None, dest='pref')
p.add_option('--post', type='string', default=None, dest='post')
p.add_option('--outdir', '-o', type='string', default=None, dest='outdir')
p.add_option('--skey', type='string', default='', dest='skey')
p.add_option('--hkey', type='string', default=None, dest='hkey')
p.add_option('--rkey', type='string', default=None, dest='rkey')
p.add_option('--region', type='string', default=None, dest='region')

(options, args) = p.parse_args()

import ROOT

if not options.wait:
    ROOT.gROOT.SetBatch(True)

log = Config.getLog(os.path.basename(__file__), debug=options.debug)

canvases = {}


#=============================================================================
def updateCanvas(can, name=None):

    if not can:
        sys.exit(0)

    can.Modified()
    can.Update()

    if options.wait:
        can.WaitPrimitive()
Example #3
0
def main():

    timeStart = time.time()

    #
    # Parse command line options
    #
    import PhysicsProject.PhysicsProjectConfig as config

    p = config.prepareOptionParser()
    (options, args) = p.parse_args()

    log = config.getLog(__name__, debug=options.debug)
    log.info('Start time: %s' % time.asctime())

    #
    # Recursively search for ROOT files in input paths
    #
    root_files = sorted(
        config.findInputLocalFiles(args,
                                   options.filekey,
                                   options.dirskey,
                                   save_files=options.save_files,
                                   print_files=False))

    if options.xsec_list:
        files = config.selectInputFiles(root_files, options)
    else:
        files = root_files

    log.info('%4d file(s) selected from %d input ROOT files' %
             (len(files), len(root_files)))

    #
    # Filter files
    #
    if options.filekey:
        store = files
        files = []

        for fpath in store:
            if re.search(options.filekey, os.path.basename(fpath)):
                files += [fpath]

        log.info('%4d file(s) passed filter: --file-key=\"%s\"' %
                 (len(files), options.filekey))

    if options.save_files:
        log.info('Save input files to: %s' % options.save_files)

        ofile = open(options.save_files, 'w')

        for file in files:
            ofile.write('%s\n' % file)

        ofile.close()

    log.info('Process %d input file(s)' % len(files))
    for file in files:
        print '   %s' % file

    #
    # Configure python RunConfig wrapper around C++ RunModule
    #
    import ROOT
    from PhysicsProject.PhysicsProjectExample import prepareJobConfig

    if options.batch:
        ROOT.gROOT.SetBatch(True)

    run = prepareJobConfig(ROOT, options)

    for file in files:
        run.StoreInputFile(file)

    if options.print_vars:
        ROOT.Anp.Cut.PrintCutNames()

    run.ExecuteRegistry()

    log.info('Run python post processing code...')

    log.info('Local time: %s' % time.asctime())
    log.info('Total time: %.1fs' % (time.time() - timeStart))