def main(): if options.save and options.outdir != None and not os.path.isdir( options.outdir): log.info('Make directory: %s' % options.outdir) os.makedirs(options.outdir) if len(args) == 0: raise Exception('main - need at least one argument: %s' % (args)) rfiles = [] for arg in args: if not os.path.isfile(arg): raise Exception('main - invalid input file: %s' % (arg)) rfiles += [ROOT.TFile(arg, 'READ')] Config.loadPhysicsProjectLib(ROOT, options) can = makeCanvas('c') hists = getAllHistNames(rfiles[0], 'data') for h in hists: if 'ElecLoose' in h or 'MuonLoose' in h or 'TauLoose' in h or 'BJet' in h: plot1d(rfiles, can, 'data/no_cut/plotRecoLep/%s' % (h)) else: plot1d(rfiles, can, 'data/%s' % (h))
def main(): if options.save and options.outdir != None and not os.path.isdir( options.outdir): log.info('Make directory: %s' % options.outdir) os.makedirs(options.outdir) if len(args) == 0: raise Exception('main - need at least one argument: %s' % (args)) rfiles = [] for arg in args: if not os.path.isfile(arg): raise Exception('main - invalid input file: %s' % (arg)) rfiles += [ROOT.TFile(arg, 'READ')] Config.loadPhysicsProjectLib(ROOT, options) regions = getListOfRegions(rfiles[0]) can = makeCanvas('c') for r in regions: hists = getAllHistNames(rfiles[0], r) for h in hists: if h.startswith('MatchedTauW/'): plot1d(rfiles, can, '%s/plotTruthTau/%s' % (r, h))
def main(): if options.save and options.outdir != None and not os.path.isdir( options.outdir): log.info('Make directory: %s' % options.outdir) os.makedirs(options.outdir) if len(args) == 0: raise Exception('main - need at least one argument: %s' % (args)) rfiles = [] for arg in args: if not os.path.isfile(arg): raise Exception('main - invalid input file: %s' % (arg)) rfiles += [ROOT.TFile(arg, 'READ')] Config.loadPhysicsProjectLib(ROOT, options) regions = getListOfRegions(rfiles[0]) can = makeCanvas('c') for r in regions: hists = getAllHistNames(rfiles[0], r) for h in hists: if 'W1' in h: plotIntegralRatio(rfiles, can, '%s/plotRecoLep/%s' % (r, h)) elif h == 'RecTauOLElec1/Pt': plotIntegralRatio(rfiles, can, '%s/plotRecoLep/%s' % (r, h))
def main(): if options.save and options.outdir != None and not os.path.isdir( options.outdir): log.info('Make directory: %s' % options.outdir) os.makedirs(options.outdir) if len(args) == 0: raise Exception('main - need at least one argument: %s' % (args)) rfiles = [] for arg in args: if not os.path.isfile(arg): raise Exception('main - invalid input file: %s' % (arg)) rfiles += [ROOT.TFile(arg, 'READ')] Config.loadPhysicsProjectLib(ROOT, options) #regions = getListOfRegions(rfiles[0]) regions = ['plot_prepCand_1lep_1tau_2bjet'] regions += ['plot_prepCand_1lep_2bjet'] regions += ['plot_prepCand_nocut'] can = makeCanvas('c') for r in regions: hists = getAllHistNames(rfiles[0], r) for h in hists: if "/TruthMatch_" in h: plot2d(rfiles, can, '%s/%s' % (r, h))
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()
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
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))