def __init__(self, configurations, sampleDict, signalsampleIds=[6], datasampleIds=[9], scaleSignal="integral", drawRatios=False, pullRange=0.8, fileName="BDT_training_mva.root", sysName="", endings=["pdf"], directory="plots", overFlowLastBin=True, underFlowFirstBin=False, calculateSeparation=True, verbose=False, treeName='Tree'): self._sampleDict = sampleDict # List of signal sample names; if set, will be drawn as separate line self._signalsampleIds = signalsampleIds # That's fixed for now self._datasampleIds = datasampleIds # Scale signal to "integral" or "luminosity" (i.e. cross section) self._scaleSignal = scaleSignal """ a configuration is a list of dicts that contain the following information "var": variable name (string) "legend": "none", "top left", "top right" "logy": True/False """ self._configurations = configurations # In which formats the plots are given out self._endings = endings self._directory = directory # Whether the ratio below the plot shall be drawn self._drawRatios = drawRatios self._pullRange = 0.8 self._errorBandFillColor = 14 self._errorBandStyle = 3354 # Pattern for file name: {0}: sample name, {1}: lepton name, {2}: sys addendum self._fileName = fileName self._treeName = treeName self._tree = 0 # For a shape systematic based on up/down files: # Legend entry - if this is present, the systematic uncertainty will be drawn self._sysName = sysName # Whether to calculate and print separation measures self._calculateSeparation = calculateSeparation # Be verbose or not self._verbose = verbose # Whether to put the overflow into the last bin self._overFlowLastBin = overFlowLastBin # Whether to put the underflow into the first bin self._underFlowFirstBin = underFlowFirstBin # List of open root files self._rootFiles = {} PlotStyle.initStyle()
# remove duplicates, just in case infiles = list(set(infiles)) if args.outdir == 'ZZA_NORMAL': outdir = os.path.join(os.environ["zza"], '/plots/cutSummary') else: # remove trailing slash if args.outdir.endswith('/'): outdir = args.outdir[:-1] else: outdir = args.outdir makeDirectory(outdir) # Look decent style = PlotStyle() histos = {} numbers = {} cutNames = {} cutCountMax = -1 # Loop over inputs, making one histogram for each channel in each input for infile in infiles: sample = infile.replace('_cutflow','').replace('.txt','').split('/')[-1] with open(infile, 'r') as f: channel = '' cutCount = 0 # loop over lines for line in f:
rlog["/ROOT.TCanvas.Print"].setLevel(rlog.WARNING) rlog["/ROOT.TUnixSystem.SetDisplay"].setLevel(rlog.ERROR) from rootpy.io import root_open from rootpy.plotting import Hist, Canvas, Legend, Pad, Graph from rootpy.ROOT import TLine from rootpy.plotting.utils import draw from rootpy import asrootpy from glob import glob from os import path from PlotStyle import PlotStyle style = PlotStyle() masses = [125, 300, 750, 1000, 1500, 2500] outdir = '/afs/cern.ch/user/n/nawoods/www/muonHighMassResults/' fileList = glob('/data/nawoods/ntuples/zzNtuples_mc_76HighPtID_0/results/*.root') fileListLeg = glob('/data/nawoods/ntuples/zzNtuples_mc_76HighPtID_0/results_legacy/*.root') files = {} filesLeg = {} for m in masses: for f in fileList: if str(m) in f: files[m] = root_open(f)