def plotVar(self, var, bins=None, xmin=None, xmax=None, ymin=None, ymax=None, reweight=False): d3t3Weights = None d3t4Weights = None ttbarErrorWeights = None if reweight: ttbarWeights = -getattr(self.dft3, weightName) * getattr( self.dft3, FvTName) # multijetWeights = np.concatenate((self.dfd3.mcPseudoTagWeight * self.dfd3.FvT, -self.dft3.mcPseudoTagWeight * self.dft3.FvT)) multijet = self.dfd3[var] multijetWeights = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvTName) # backgroundWeights = np.concatenate((self.dfd3.mcPseudoTagWeight * self.dfd3.FvT, -self.dft3.mcPseudoTagWeight * self.dft3.FvT, self.dft4.mcPseudoTagWeight)) background = np.concatenate((self.dfd3[var], self.dft4[var])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName) * getattr(self.dfd3, FvTName), getattr(self.dft4, weightName))) # ttbar estimates from reweighted threetag data d3t3Weights = -1 * multijetWeights * getattr( self.dfd3, 'FvT_pt3') / getattr(self.dfd3, 'FvT_pd3') d3t4Weights = getattr(self.dfd3, weightName) * getattr( self.dfd3, 'FvT_pt4') / getattr(self.dfd3, 'FvT_pd3') ttbarErrorWeights = np.concatenate( (getattr(self.dft4, weightName), -d3t4Weights, ttbarWeights, -d3t3Weights)) ttbarError = np.concatenate((self.dft4[var], self.dfd3[var], self.dft3[var], self.dfd3[var])) else: ttbarWeights = -getattr(self.dft3, weightName) multijet = np.concatenate((self.dfd3[var], self.dft3[var])) multijetWeights = np.concatenate( (getattr(self.dfd3, weightName), -getattr(self.dft3, weightName))) # multijetWeights = self.dfd3.mcPseudoTagWeight # background = np.concatenate((self.dfd3[var], self.dft3[var], self.dft4[var])) # backgroundWeights = np.concatenate((self.dfd3.mcPseudoTagWeight, -self.dft3.mcPseudoTagWeight, self.dft4.mcPseudoTagWeight)) background = np.concatenate( (self.dfd3[var], self.dft3[var], self.dft4[var])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName), -getattr(self.dft3, weightName), getattr(self.dft4, weightName))) # backgroundWeights = np.concatenate((self.dfd3.mcPseudoTagWeight, self.dft4.mcPseudoTagWeight)) self.dsd4 = pltHelper.dataSet(name=d4.name, points=self.dfd4[var], weights=getattr(self.dfd4, weightName), color=d4.color, alpha=1.0, linewidth=1) self.bkgd = pltHelper.dataSet(name='Background Model', points=background, weights=backgroundWeights, color='brown', alpha=1.0, linewidth=1) self.dst4 = pltHelper.dataSet(name=t4.name, points=self.dft4[var], weights=getattr(self.dft4, weightName), color=t4.color, alpha=1.0, linewidth=1) self.dsm3 = pltHelper.dataSet(name='ThreeTag Multijet', points=multijet, weights=multijetWeights, color=d3.color, alpha=1.0, linewidth=1) self.dst3 = pltHelper.dataSet(name=t3.name, points=self.dft3[var], weights=ttbarWeights, color=t3.color, alpha=1.0, linewidth=1) datasets = [self.dsd4, self.bkgd, self.dst4, self.dsm3, self.dst3] if d3t3Weights is not None: self.dsd3t3 = pltHelper.dataSet(name=r'ThreeTag $t\bar{t}$ est.', points=self.dfd3[var], weights=d3t3Weights, color=t3.color, alpha=0.5, linewidth=2) datasets += [self.dsd3t3] if d3t4Weights is not None: self.dsd3t4 = pltHelper.dataSet(name=r'FourTag $t\bar{t}$ est.', points=self.dfd3[var], weights=d3t4Weights, color=t4.color, alpha=0.5, linewidth=2) datasets += [self.dsd3t4] if ttbarErrorWeights is not None: self.dste = pltHelper.dataSet( name=r'$t\bar{t}$ MC - $t\bar{t}$ est.', points=ttbarError, weights=ttbarErrorWeights, color='black', alpha=0.5, linewidth=2) datasets += [self.dste] if self.dfzz is not None: self.dszz = pltHelper.dataSet( name=zz.name, points=self.dfzz[var], weights=getattr(self.dfzz, weightName) * 100, color=zz.color, alpha=1.0, linewidth=1) datasets += [self.dszz] if self.dfzh is not None: self.dszh = pltHelper.dataSet( name=zh.name, points=self.dfzh[var], weights=getattr(self.dfzh, weightName) * 100, color=zh.color, alpha=1.0, linewidth=1) datasets += [self.dszh] if type(bins) != list: if not bins: bins = 50 if type(xmin) == type(None): xmin = self.dfSelected[var].min() if type(xmax) == type(None): xmax = self.dfSelected[var].max() width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(0, bins + 1)] args = { 'dataSets': datasets, 'ratio': [0, 1], 'ratioRange': [0.9, 1.1] if reweight else [0.5, 1.5], 'ratioTitle': 'Data / Model', 'bins': bins, 'xmin': xmin, 'xmax': xmax, 'ymin': ymin, 'ymax': ymax, 'xlabel': var.replace('_', ' '), 'ylabel': 'Events / Bin', } fig = pltHelper.histPlotter(**args) figName = outputDir + "/" + var + ('_reweight' if reweight else '') + '.pdf' fig.savefig(figName) print(figName)
def plotCompVar(self, var, legName, bins=None, xmin=None, xmax=None, regName=""): #ttbarWeights = -getattr(self.dft3,weightName) * getattr(self.dft3,FvTName) plotVar1 = self.dfd3[var[0]] plotVar2 = self.dfd3[var[1]] multijetWeights = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvTName) #self.dsd4 = pltHelper.dataSet(name=d4.name, # points =self.dfd4[var], # weights=getattr(self.dfd4,weightName), # color=d4.color, alpha=1.0, linewidth=1) #self.bkgd = pltHelper.dataSet(name='Background Model', # points =background, # weights=backgroundWeights, # color='brown', alpha=1.0, linewidth=1) #self.dst4 = pltHelper.dataSet(name=t4.name, # points =self.dft4[var], # weights=getattr(self.dft4,weightName), # color=t4.color, alpha=1.0, linewidth=1) self.dv1 = pltHelper.dataSet(name=legName[0], points=plotVar1, weights=multijetWeights, color='red', alpha=1.0, linewidth=1) self.dv2 = pltHelper.dataSet(name=legName[1], points=plotVar2, weights=multijetWeights, color='blue', alpha=1.0, linewidth=1) #datasets = [self.dsd4,self.bkgd,self.dst4,self.dsm3,self.dst3] datasets = [self.dv1, self.dv2] if not bins: bins = 50 if type(xmin) == type(None): xmin = self.dfSelected[var[0]].min() if type(xmax) == type(None): xmax = self.dfSelected[var[0]].max() width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(-1, bins + 1)] xlabel = var[0] + "_vs_" + var[1] args = { 'dataSets': datasets, 'ratio': [0, 1], 'ratioRange': [0.5, 1.5], 'ratioTitle': legName[0] + ' / ' + legName[1], 'bins': bins, 'xlabel': xlabel.replace('_', ' '), 'ylabel': 'Events / Bin', } fig = pltHelper.histPlotter(**args) figName = outputDir + "/" + regName + "_" + xlabel + '.pdf' fig.savefig(figName) print(figName)
def plotRWVar(self, var, FvT1Name, FvT2Name, legName1, legName2, bins=None, xmin=None, xmax=None, regName=""): #ttbarWeights = -getattr(self.dft3,weightName) * getattr(self.dft3,FvTName) if type(var) == list: multijet = self.dfd3[var[0]] - self.dfd3[var[1]] else: multijet = self.dfd3[var] multijetWeights_1 = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvT1Name) multijetWeights_2 = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvT2Name) self.dsm3_1 = pltHelper.dataSet(name=legName1, points=multijet, weights=multijetWeights_1, color='red', alpha=1.0, linewidth=1) self.dsm3_2 = pltHelper.dataSet(name=legName2, points=multijet, weights=multijetWeights_2, color='blue', alpha=1.0, linewidth=1) #datasets = [self.dsd4,self.bkgd,self.dst4,self.dsm3,self.dst3] datasets = [self.dsm3_1, self.dsm3_2] if not bins: bins = 50 if type(var) != list: if type(xmin) == type(None): xmin = self.dfSelected[var].min() if type(xmax) == type(None): xmax = self.dfSelected[var].max() else: xmin = -1 xmax = 1 width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(-1, bins + 1)] if type(var) == list: xlabel = var[0] + "_minus_" + var[1] else: xlabel = var args = { 'dataSets': datasets, 'ratio': [0, 1], 'ratioRange': [0.8, 1.2], 'ratioTitle': legName1 + ' / ' + legName2, 'bins': bins, 'xlabel': xlabel.replace('_', ' '), 'ylabel': 'Events / Bin', } fig = pltHelper.histPlotter(**args) figName = outputDir + "/" + regName + "_" + xlabel + '_rw' + legName1 + '_vs_' + legName2 + '.pdf' fig.savefig(figName) print(figName)
def plotVar(self, var, bins=None, xmin=None, xmax=None, regName=""): #ttbarWeights = -getattr(self.dft3,weightName) * getattr(self.dft3,FvTName) if type(var) == list: multijet = self.dfd3[var[0]] - self.dfd3[var[1]] else: multijet = self.dfd3[var] multijetWeights = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvTName) #background = np.concatenate((self.dfd3[var], self.dft4[var])) #backgroundWeights = np.concatenate((getattr(self.dfd3,weightName) * getattr(self.dfd3,FvTName), getattr(self.dft4,weightName))) #self.dsd4 = pltHelper.dataSet(name=d4.name, # points =self.dfd4[var], # weights=getattr(self.dfd4,weightName), # color=d4.color, alpha=1.0, linewidth=1) #self.bkgd = pltHelper.dataSet(name='Background Model', # points =background, # weights=backgroundWeights, # color='brown', alpha=1.0, linewidth=1) #self.dst4 = pltHelper.dataSet(name=t4.name, # points =self.dft4[var], # weights=getattr(self.dft4,weightName), # color=t4.color, alpha=1.0, linewidth=1) self.dsm3 = pltHelper.dataSet(name='ThreeTag Multijet', points=multijet, weights=multijetWeights, color=d3.color, alpha=1.0, linewidth=1) #self.dst3 = pltHelper.dataSet(name=t3.name, # points=self.dft3[var], # weights=ttbarWeights, # color=t3.color, alpha=1.0, linewidth=1) #datasets = [self.dsd4,self.bkgd,self.dst4,self.dsm3,self.dst3] datasets = [self.dsm3] if not bins: bins = 50 if type(var) != list: if type(xmin) == type(None): xmin = self.dfSelected[var].min() if type(xmax) == type(None): xmax = self.dfSelected[var].max() else: xmin = -1 xmax = 1 width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(-1, bins + 1)] if type(var) == list: xlabel = var[0] + "_minus_" + var[1] else: xlabel = var args = { 'dataSets': datasets, #'ratio': [0,1], #'ratioRange': [0.5,1.5], #'ratioTitle': 'Data / Model', 'bins': bins, 'xlabel': xlabel.replace('_', ' '), 'ylabel': 'Events / Bin', } fig = pltHelper.histPlotter(**args) figName = outputDir + "/" + regName + "_" + xlabel + '.pdf' fig.savefig(figName) print(figName)
def plotVar(self, var, bins=None, xmin=None, xmax=None, ymin=None, ymax=None, reweight=False, variance=False, overflow=False): d3t3Weights = None d3t4Weights = None ttbarErrorWeights = None if reweight: ttbarWeights = -getattr(self.dft3, weightName) * getattr( self.dft3, FvTName) multijet = self.dfd3[var] multijetWeights = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvTName) background = np.concatenate((self.dfd3[var], self.dft4[var])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName) * getattr(self.dfd3, FvTName), getattr(self.dft4, weightName))) # ttbar estimates from reweighted threetag data d3t3Weights = -1 * multijetWeights * getattr( self.dfd3, 'FvT_pt3') / getattr(self.dfd3, 'FvT_pd3') d3t4Weights = getattr(self.dfd3, weightName) * getattr( self.dfd3, 'FvT_pt4') / getattr(self.dfd3, 'FvT_pd3') ttbarErrorWeights = np.concatenate( (getattr(self.dft4, weightName), -d3t4Weights, ttbarWeights, -d3t3Weights)) ttbarError = np.concatenate((self.dft4[var], self.dfd3[var], self.dft3[var], self.dfd3[var])) else: ttbarWeights = -getattr(self.dft3, weightName) multijet = np.concatenate((self.dfd3[var], self.dft3[var])) multijetWeights = np.concatenate( (getattr(self.dfd3, weightName), -getattr(self.dft3, weightName))) background = np.concatenate( (self.dfd3[var], self.dft3[var], self.dft4[var])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName), -getattr(self.dft3, weightName), getattr(self.dft4, weightName))) self.dsd4 = pltHelper.dataSet(name=d4.name, points=self.dfd4[var], weights=getattr(self.dfd4, weightName), color=d4.color, alpha=1.0, linewidth=1) self.bkgd = pltHelper.dataSet(name='Background Model', points=background, weights=backgroundWeights, color='brown', alpha=1.0, linewidth=1) self.dst4 = pltHelper.dataSet(name=t4.name, points=self.dft4[var], weights=getattr(self.dft4, weightName), color=t4.color, alpha=1.0, linewidth=1) self.dsm3 = pltHelper.dataSet(name='ThreeTag Multijet', points=multijet, weights=multijetWeights, color=d3.color, alpha=1.0, linewidth=1) self.dst3 = pltHelper.dataSet(name=t3.name, points=self.dft3[var], weights=ttbarWeights, color=t3.color, alpha=1.0, linewidth=1) datasets = [self.dsd4, self.bkgd, self.dst4, self.dsm3, self.dst3] if variance: self.dsm3_variance = pltHelper.dataSet( name='3b MJ Weight SD', points=multijet, weights=multijetWeights * getattr(self.dfd3, FvTName + '_std'), color=d3.color, alpha=0.5, linewidth=1) datasets += [self.dsm3_variance] if d3t3Weights is not None: self.dsd3t3 = pltHelper.dataSet(name=r'ThreeTag $t\bar{t}$ est.', points=self.dfd3[var], weights=d3t3Weights, color=t3.color, alpha=0.5, linewidth=2) datasets += [self.dsd3t3] if d3t4Weights is not None: self.dsd3t4 = pltHelper.dataSet(name=r'FourTag $t\bar{t}$ est.', points=self.dfd3[var], weights=d3t4Weights, color=t4.color, alpha=0.5, linewidth=2) datasets += [self.dsd3t4] if ttbarErrorWeights is not None: self.dste = pltHelper.dataSet( name=r'$t\bar{t}$ MC - $t\bar{t}$ est.', points=ttbarError, weights=ttbarErrorWeights, color='black', alpha=0.5, linewidth=2) datasets += [self.dste] if self.dfzz is not None: self.dszz = pltHelper.dataSet( name=zz.name, points=self.dfzz[var], weights=getattr(self.dfzz, weightName) * 100, color=zz.color, alpha=1.0, linewidth=1) datasets += [self.dszz] if self.dfzh is not None: self.dszh = pltHelper.dataSet( name=zh.name, points=self.dfzh[var], weights=getattr(self.dfzh, weightName) * 100, color=zh.color, alpha=1.0, linewidth=1) datasets += [self.dszh] if type(bins) != list: if not bins: bins = 50 if type(xmin) == type(None): xmin = self.dfSelected[var].min() if type(xmax) == type(None): xmax = self.dfSelected[var].max() width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(0, bins + 1)] if reweight: chisquare = pltHelper.histChisquare(obs=self.dsd4.points, obs_w=self.dsd4.weights, exp=self.bkgd.points, exp_w=self.bkgd.weights, bins=bins, overflow=overflow) args = { 'dataSets': datasets, 'ratio': [0, 1], 'ratioRange': [0.9, 1.1] if reweight else [0.5, 1.5], 'ratioTitle': 'Data / Model', 'bins': bins, 'xmin': xmin, 'xmax': xmax, 'ymin': ymin, 'ymax': ymax, 'xlabel': var.replace('_', ' '), 'ylabel': 'Events / Bin', 'overflow': overflow, } fig = pltHelper.histPlotter(**args) if reweight: fig.sub1.annotate( '$\chi^2/$NDF = %1.2f (%1.0f$\%%$)' % (chisquare.chi2 / chisquare.ndfs, chisquare.prob * 100), (1.0, 1.02), horizontalalignment='right', xycoords='axes fraction') figName = outputDir + "/" + var + ('_reweight' if reweight else '') + '.pdf' fig.savefig(figName) print(figName)
def plotVar(self, var, bins=None, xmin=None, xmax=None, reweight=False, regName=""): if reweight: ttbarWeights = -getattr(self.dft3, weightName) * getattr( self.dft3, FvTName) # multijetWeights = np.concatenate((self.dfd3.mcPseudoTagWeight * self.dfd3.FvT, -self.dft3.mcPseudoTagWeight * self.dft3.FvT)) multijet = self.dfd3[var] multijetWeights = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvTName) # backgroundWeights = np.concatenate((self.dfd3.mcPseudoTagWeight * self.dfd3.FvT, -self.dft3.mcPseudoTagWeight * self.dft3.FvT, self.dft4.mcPseudoTagWeight)) background = np.concatenate((self.dfd3[var], self.dft4[var])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName) * getattr(self.dfd3, FvTName), getattr(self.dft4, weightName))) else: ttbarWeights = -getattr(self.dft3, weightName) multijet = np.concatenate((self.dfd3[var], self.dft3[var])) multijetWeights = np.concatenate( (getattr(self.dfd3, weightName), -getattr(self.dft3, weightName))) # multijetWeights = self.dfd3.mcPseudoTagWeight # background = np.concatenate((self.dfd3[var], self.dft3[var], self.dft4[var])) # backgroundWeights = np.concatenate((self.dfd3.mcPseudoTagWeight, -self.dft3.mcPseudoTagWeight, self.dft4.mcPseudoTagWeight)) background = np.concatenate( (self.dfd3[var], self.dft3[var], self.dft4[var])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName), -getattr(self.dft3, weightName), getattr(self.dft4, weightName))) # backgroundWeights = np.concatenate((self.dfd3.mcPseudoTagWeight, self.dft4.mcPseudoTagWeight)) print(self.bkgd[var]) self.dsd4 = pltHelper.dataSet(name=d4.name, points=self.dfd4[var], weights=getattr(self.dfd4, weightName), color=d4.color, alpha=1.0, linewidth=1) self.bkgd = pltHelper.dataSet(name='Background Model', points=background, weights=backgroundWeights, color='brown', alpha=1.0, linewidth=1) self.dst4 = pltHelper.dataSet(name=t4.name, points=self.dft4[var], weights=getattr(self.dft4, weightName), color=t4.color, alpha=1.0, linewidth=1) self.dsm3 = pltHelper.dataSet(name='ThreeTag Multijet', points=multijet, weights=multijetWeights, color=d3.color, alpha=1.0, linewidth=1) self.dst3 = pltHelper.dataSet(name=t3.name, points=self.dft3[var], weights=ttbarWeights, color=t3.color, alpha=1.0, linewidth=1) datasets = [self.dsd4, self.bkgd, self.dst4, self.dsm3, self.dst3] if self.dfzz is not None: self.dszz = pltHelper.dataSet( name=zz.name, points=self.dfzz[var], weights=getattr(self.dfzz, weightName) * 100, color=zz.color, alpha=1.0, linewidth=1) datasets += [self.dszz] if self.dfzh is not None: self.dszh = pltHelper.dataSet( name=zh.name, points=self.dfzh[var], weights=getattr(self.dfzh, weightName) * 100, color=zh.color, alpha=1.0, linewidth=1) datasets += [self.dszh] if type(bins) != list: if not bins: bins = 50 if type(xmin) == type(None): xmin = self.dfSelected[var].min() if type(xmax) == type(None): xmax = self.dfSelected[var].max() width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(-1, bins + 1)] args = { 'dataSets': datasets, 'ratio': [0, 1], 'ratioRange': [0.5, 1.5], 'ratioTitle': 'Data / Model', 'bins': bins, 'xlabel': var.replace('_', ' '), 'ylabel': 'Events / Bin', } fig = pltHelper.histPlotter(**args) figName = outputDir + "/" + regName + "_" + var + ( '_reweight' if reweight else '') + '.pdf' fig.savefig(figName) print(figName)
import matplotlibHelpers as pltHelper import numpy as np args={'points': np.random.rand(7000), 'weights': np.random.rand(7000), 'color': 'blue', 'alpha': 1.0, 'linewidth': 1, 'name': 'Output', } train=pltHelper.dataSet(**args) args={'points': np.random.rand(3000), 'weights': np.random.rand(3000), 'color': 'blue', 'alpha': 0.5, 'linewidth': 2, } valid=pltHelper.dataSet(**args) args={'points': np.zeros(0), 'weights': np.zeros(0), 'color': 'black', 'alpha': 1.0, 'linewidth': 1, 'name': 'Training Set', } trainLegend=pltHelper.dataSet(**args) args={'points': np.zeros(0), 'weights': np.zeros(0),
def plotVar(self, var, FvTName, outName, bins=None, xmin=None, xmax=None, regName=""): if type(FvTName) == list: ttbarWeights = -getattr(self.dft3, weightName) * 1. / 3 * ( getattr(self.dft3, FvTName[0]) + getattr( self.dft3, FvTName[1]) + getattr(self.dft3, FvTName[2])) multijetWeights = getattr(self.dfd3, weightName) * 1. / 3 * ( getattr(self.dfd3, FvTName[0]) + getattr( self.dfd3, FvTName[1]) + getattr(self.dfd3, FvTName[2])) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName) * 1. / 3 * (getattr(self.dfd3, FvTName[0]) + getattr( self.dfd3, FvTName[1]) + getattr(self.dfd3, FvTName[2])), getattr(self.dft4, weightName))) else: ttbarWeights = -getattr(self.dft3, weightName) * getattr( self.dft3, FvTName) multijetWeights = getattr(self.dfd3, weightName) * getattr( self.dfd3, FvTName) backgroundWeights = np.concatenate( (getattr(self.dfd3, weightName) * getattr(self.dfd3, FvTName), getattr(self.dft4, weightName))) multijet = self.dfd3[var] if type( var) != list else self.dfd3[var[0]] - self.dfd3[var[1]] #dfd3var = self.dfd3[var] if type(var) != list else self.dfd3[var[0]] - self.dfd3[var[1]] dft4var = self.dft4[var] if type( var) != list else self.dft4[var[0]] - self.dft4[var[1]] dfd4var = self.dfd4[var] if type( var) != list else self.dfd4[var[0]] - self.dfd4[var[1]] dft3var = self.dft3[var] if type( var) != list else self.dft3[var[0]] - self.dft3[var[1]] background = np.concatenate((multijet, dft4var)) self.dsd4 = pltHelper.dataSet(name=d4.name, points=dfd4var, weights=getattr(self.dfd4, weightName), color=d4.color, alpha=1.0, linewidth=1) self.bkgd = pltHelper.dataSet(name='Background Model', points=background, weights=backgroundWeights, color='brown', alpha=1.0, linewidth=1) self.dst4 = pltHelper.dataSet(name=t4.name, points=dft4var, weights=getattr(self.dft4, weightName), color=t4.color, alpha=1.0, linewidth=1) self.dsm3 = pltHelper.dataSet(name='ThreeTag Multijet', points=multijet, weights=multijetWeights, color=d3.color, alpha=1.0, linewidth=1) self.dst3 = pltHelper.dataSet(name=t3.name, points=dft3var, weights=ttbarWeights, color=t3.color, alpha=1.0, linewidth=1) datasets = [self.dsd4, self.bkgd, self.dst4, self.dsm3, self.dst3] if self.dfzz is not None: self.dszz = pltHelper.dataSet( name=zz.name, points=self.dfzz[var], weights=getattr(self.dfzz, weightName) * 100, color=zz.color, alpha=1.0, linewidth=1) datasets += [self.dszz] if self.dfzh is not None: self.dszh = pltHelper.dataSet( name=zh.name, points=self.dfzh[var], weights=getattr(self.dfzh, weightName) * 100, color=zh.color, alpha=1.0, linewidth=1) datasets += [self.dszh] if type(bins) != list: if not bins: bins = 50 if type(var) == list: if type(xmin) == type(None): xmin = self.dfSelected[var[0]].min() if type(xmax) == type(None): xmax = self.dfSelected[var[0]].max() else: if type(xmin) == type(None): xmin = self.dfSelected[var].min() if type(xmax) == type(None): xmax = self.dfSelected[var].max() width = (xmax - xmin) / bins bins = [xmin + b * width for b in range(-1, bins + 1)] if type(var) == list: xlabel = var[0] + "_minus_" + var[1] else: xlabel = var args = { 'dataSets': datasets, 'ratio': [0, 1], 'ratioRange': [0.5, 1.5], 'ratioTitle': 'Data / Model', 'bins': bins, 'xlabel': xlabel.replace('_', ' '), 'ylabel': 'Events / Bin', } fig = pltHelper.histPlotter(**args) figName = outputDir + "/" + regName + "_" + xlabel + outName + '.pdf' fig.savefig(figName) print(figName)