def processSampleNames(_inputNames, _selectorKeys, _plotConfig = ''): snames = [] if _plotConfig: # if a plot config is specified, use the samples for that snames = plotconfig.getConfig(_plotConfig).samples() else: snames = _inputNames # handle special group names if 'all' in snames: snames.remove('all') snames = _selectorKeys if 'data16' in snames: snames.remove('data16') snames += [key for key in _selectorKeys if '16' in key and allsamples[key].data] if 'bkgd' in snames: snames.remove('bkgd') snames += [key for key in _selectorKeys if not allsamples[key].data and not key.startswith('dm') and not key.startswith('add') and not key.endswith('-d')] if 'dmfs' in snames: snames.remove('dmfs') snames += [key for key in _selectorKeys if key.startswith('dm') and key[3:5] == 'fs'] if 'dm' in snames: snames.remove('dm') snames += [key for key in _selectorKeys if key.startswith('dm') and not key[3:5] == 'fs'] if 'add' in snames: snames.remove('add') snames += [key for key in _selectorKeys if key.startswith('add')] if 'fs' in snames: snames.remove('fs') snames += [key for key in _selectorKeys if 'fs' in key] # filter out empty samples for name in list(snames): if '*' in name: # wild card snames.remove(name) snames.extend([s.name for s in allsamples.getmany(name)]) try: samp = allsamples[name] except KeyError: print name, "is not in datasets.csv. Removing it from the list of samples to run over." snames.remove(name) snames = [name for name in snames if allsamples[name].sumw != 0.] return snames
def processSampleNames(_inputNames, _selectorKeys, _plotConfig = ''): snames = [] if _plotConfig: # if a plot config is specified, use the samples for that snames = plotconfig.getConfig(_plotConfig).samples() else: snames = _inputNames # handle special group names if 'all' in snames: snames.remove('all') snames = _selectorKeys if 'data16' in snames: snames.remove('data16') snames += [key for key in _selectorKeys if '16' in key and allsamples[key].data] if 'bkgd' in snames: snames.remove('bkgd') snames += [key for key in _selectorKeys if not allsamples[key].data and not key.startswith('dm') and not key.startswith('add') and not key.endswith('-d')] if 'dmfs' in snames: snames.remove('dmfs') snames += [key for key in _selectorKeys if key.startswith('dm') and key[3:5] == 'fs'] if 'dm' in snames: snames.remove('dm') snames += [key for key in _selectorKeys if key.startswith('dm') and not key[3:5] == 'fs'] if 'add' in snames: snames.remove('add') snames += [key for key in _selectorKeys if key.startswith('add')] if 'fs' in snames: snames.remove('fs') snames += [key for key in _selectorKeys if 'fs' in key] # filter out empty samples tmp = [name for name in snames if allsamples[name].sumw != 0.] snames = tmp return snames
args = argParser.parse_args() sys.argv = [] import ROOT ROOT.gROOT.SetBatch(True) from plotstyle import WEBDIR, SimpleCanvas, DataMCCanvas from datasets import SampleDefList, allsamples if not args.skimDir: from config import skimDir args.skimDir = skimDir if args.plotConfigFile: execfile(args.plotConfigFile) plotConfig = getConfig(args.config) else: from main.plotconfig import getConfig plotConfig = getConfig(args.config) if args.samplesList: allsamples = SampleDefList(listpath = args.samplesList) if len(args.plots) == 0: args.plots = [v.name for v in plotConfig.variables] # backward compatibility if args.countOnly: args.plots = ['count'] if args.bbb:
args = argParser.parse_args() sys.argv = [] import ROOT ROOT.gSystem.Load(config.libsimpletree) ROOT.gSystem.AddIncludePath('-I' + config.dataformats + '/interface') ROOT.gROOT.LoadMacro(thisdir + '/Skimmer.cc+') snames = [] if args.plotConfig: # if a plot config is specified, use the samples for that snames = plotconfig.getConfig(args.plotConfig).samples() else: snames = args.snames # handle special group names if 'all' in snames: snames.remove('all') snames = selectors.keys() elif 'dmfs' in snames: snames.remove('dmfs') snames += [key for key in selectors.keys() if key.startswith('dm') and key[3:5] == 'fs'] elif 'dm' in snames: snames.remove('dm') snames += [key for key in selectors.keys() if key.startswith('dm')] elif 'add' in snames:
import re import ROOT thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import * from datasets import allsamples import config from main.plotconfig import getConfig from main.plot import getHist, formatHist, printBinByBin varname = argv[1] plotConfig = getConfig('monoph') vardef = next(v for v in plotConfig.variables if v.name == varname) stack = {} for group in plotConfig.bkgGroups: totalw = 0. for sname in group.samples: if group.region: region = group.region hname = sname + '_' + group.region else: region = plotConfig.name hname = '' hist = getHist(sname, region, vardef, plotConfig.baseline, hname = hname, plotAcceptance = True)
import math import re import ROOT from pprint import pprint ROOT.gROOT.SetBatch(True) thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import * from datasets import allsamples import config from main.plotconfig import getConfig monophConfig = getConfig("monoph") source = ROOT.TFile.Open(args.input) variable = args.variable # lumi = config.jsonLumiBlinded lumi = 0.0 for sName in monophConfig.obs.samples: lumi += allsamples[sName].lumi / monophConfig.prescales[sName] if args.lumi > 0.0: lumiScale = args.lumi * 1000.0 / lumi # gather process names signal = args.model processes = [signal] + [g.name for g in monophConfig.bkgGroups]
r.gROOT.SetBatch(True) sys.path.append( "/home/ballen/cms/cmssw/042/CMSSW_7_4_6/src/MitMonoX/monophoton") from datasets import allsamples as allsamples74 thisdir = os.path.dirname(os.path.realpath(__file__)) basedir = os.path.dirname(thisdir) sys.path.append(basedir) from plotstyle import * from datasets import allsamples import config from main.plotconfig import getConfig monophConfig = getConfig('monoph') source80 = r.TFile.Open(args.input[0]) source74 = r.TFile.Open(args.input[1]) lumi = 0. for sName in monophConfig.obs.samples: lumi += allsamples[sName].lumi # gather process names spins = [0., 1., 2.] mmeds = [10, 20, 50, 100, 200, 500, 1000, 2000] mdms = [1, 10, 50, 150, 500, 1000, 2000] processes = [] for sample in allsamples: if not sample.name.startswith('dm'): continue
if __name__ == '__main__': from argparse import ArgumentParser argParser = ArgumentParser(description = 'Plot and count') argParser.add_argument('region', metavar = 'REGION', help = 'Control or signal region name.') argParser.add_argument('--count-only', '-C', action = 'store_true', dest = 'countOnly', help = 'Just display the event counts.') argParser.add_argument('--bin-by-bin', '-y', metavar = 'PLOT', dest = 'bbb', default = '', help = 'Print out bin-by-bin breakdown of the backgrounds and observation.') argParser.add_argument('--blind', '-b', metavar = 'PRESCALE', dest = 'blind', type = int, default = 1, help = 'Prescale for blinding.') argParser.add_argument('--clear-dir', '-R', action = 'store_true', dest = 'clearDir', help = 'Clear the plot directory first.') args = argParser.parse_args() sys.argv = [] plotConfig = getConfig(args.region) lumi = 0. for sName in plotConfig.obs.samples: if type(sName) is tuple: lumi += allsamples[sName[0]].lumi else: lumi += allsamples[sName].lumi if not args.countOnly or args.bbb != '': if args.bbb: stack = {} canvas = DataMCCanvas(lumi = lumi) simpleCanvas = SimpleCanvas(lumi = lumi, sim = True)
matches = re.match('([^_]+)_' + region + '_([^_]+)_([^_]+)_bin[0-9]+_tf', v.GetName()) if matches: proc = matches.group(1) if proc not in floatNames: floatNames.append(proc) floatName = matches.group(1) if len(floatNames) != 0: postfitSub = postfitTotal.Clone('subdominant') for proc in floatNames: postfitSub.Add(postfitDir.Get(region + '/' + proc), -1.) else: postfitSub = None plotConfig = getConfig(region) lumi = 0. for sample in plotConfig.obs.samples: lumi += sample.lumi / plotConfig.prescales[sample] if not SIMPLE: printRegionHeader(region, prefitTotal) if pdir == 's': pftitle = 'Signal+background fit' elif pdir == 'c': pftitle = 'CR-only fit' else: pftitle = 'Background-only fit'