def showRatios(ratios, outUrl): """shows the ratio plots""" ROOT.gStyle.SetOptTitle(0) ROOT.gStyle.SetOptStat(0) ROOT.gROOT.SetBatch(True) os.system('rm %s' % outUrl) outDir = os.path.dirname(outUrl) COLOURS = [1, '#f4a582', '#bababa', '#abdda4'] for key in ratios: p = Plot(key + '_ratio', com='13 TeV') p.doPoissonErrorBars = False p.ratiorange = (0.68, 1.34) p.spimposeWithErrors = True ic = 0 for h in ratios[key]: p.add(h=h, title=h.GetTitle(), color=COLOURS[ic], isData=False, spImpose=True, isSyst=False) ic += 1 p.show(outDir=outDir, lumi=41400, noStack=False, saveTeX=False, noRatio=True) p.appendTo(outUrl) p.reset()
def main(args): parser = argparse.ArgumentParser(description='usage: %prog [options]') parser.add_argument( '-i', '--input', dest='input', default= '/eos/cms/store/cmst3/user/psilva/ExclusiveAna/final/ab05162/analysis_0p04/', help='input directory with the files [default: %default]') parser.add_argument( '--sig', dest='sig', default= '{boson}_m_X_{mass}_xangle_{xangle}_2017_preTS2_opt_v1_simu_reco.root', help='signal point [%default]') parser.add_argument('--massList', dest='massList', default='800,1000,1200', help='signal mass list (CSV) [%default]') parser.add_argument( '--selCuts', dest='selCuts', default='bosonpt>40 && l1pt>30 && l2pt>20', help='preselection for Z categories [default: %default]') parser.add_argument('--doPerAngle', dest='doPerAngle', default=False, help='do per crossing angle [default: %default]', action='store_true') parser.add_argument('--lumi', dest='lumi', default=37500., type=float, help='integrated luminosity [default: %default]') parser.add_argument('-o', '--output', dest='output', default='analysis/bkg', help='Output directory [default: %default]') opt = parser.parse_args(args) ROOT.gROOT.SetBatch(True) ROOT.gStyle.SetOptTitle(0) ROOT.gStyle.SetOptStat(0) os.system('mkdir -p %s' % opt.output) selCuts = [(opt.selCuts, '', 'e#mu')] if opt.doPerAngle: for xangle in VALIDLHCXANGLES: selCuts.append((opt.selCuts + ' && xangle==%d' % xangle, '_%d' % xangle, 'e#mu, %d #murad' % xangle)) for cuts, pfix, catTitle in selCuts: os.system('rm %s/plotter_%s.root' % (opt.output, pfix)) data = fillShapes(inputDir=opt.input, selCuts=cuts, proc='MuonEG') #sigs={} #for m in opt.massList.split(): # if not m in sigs: sigs[m]={} # for xangle in VALIDLHCXANGLES: # newSigs=fillShapes(inputDir=opt.input,selCuts=opt.selCuts,tag=opt.sig.format(mass=m,xangle=xangle)) # for dist in newSigs: # if not dist in sigs[m]: # sigs[m]=newSigs[dist]['data'].Clone('{0}_{1}'.format(dist,m)) # #FIXME scale me according to xsec #FIXME plot me for dist in data: pname = dist + pfix for c in [':', ',', '>', '=', '(', ')', '-', '<', '?']: pname = pname.replace(c, '') p = Plot(pname) p.doChi2 = True p.nominalDistForSystsName = 'background' #if dist=='mmiss': # newBins=range(0,1000,40)+[1000,1100,1200,1500,2000] # print 'Rebinning',dist,'to',newBins # for k in data[dist]: # data[dist][k]=rebinUnequalBinSize(data[dist][k],newBins) #main distributions #doDivideByBinWidth=True if dist=='mmiss' or dist=='(bosony>=0?mmiss:-mmiss)' else False #if doDivideByBinWidth: # p.doPoissonErrorBars=False p.add(data[dist]['data'], title='data', color=ROOT.kBlack, isData=True, spImpose=False, isSyst=False) #,doDivideByBinWidth=doDivideByBinWidth) p.add(data[dist]['bkg'], title='background', color=ROOT.TColor.GetColor('#1f78b4'), isData=False, spImpose=False, isSyst=False) #,doDivideByBinWidth=doDivideByBinWidth) #background systematics for syst in [ '{0}_bkgshape_MuonEG_obsUp', '{0}_bkgshape_MuonEG_obsDown', '{0}_bkgsinglediff_MuonEG_obsDown', '{0}_bkgsinglediff_MuonEG_obsUp' ]: p.add(data[dist][syst.format(dist)], title=syst, color=ROOT.TColor.GetColor('#1f78b4'), isData=False, spImpose=False, isSyst=True) #doDivideByBinWidth=doDivideByBinWidth) #p.ratiorange=[0.78,1.22] #p.ratiorange=[0.58,1.42] p.ratiorange = [0., 2.] p.show(opt.output, opt.lumi, extraText=catTitle) p.appendTo('%s/plotter_%s.root' % (opt.output, pfix)) p.reset()
def main(args): parser = argparse.ArgumentParser(description='usage: %prog [options]') parser.add_argument( '-i', '--input', dest='input', default= '/eos/cms/store/cmst3/user/psilva/ExclusiveAna/final/ab05162/analysis_0p04/', help='input directory with the files [default: %default]') parser.add_argument( '--selCuts', dest='selCuts', default='bosonpt>40 && l1pt>30 && l2pt>20', help='preselection for Z categories [default: %default]') parser.add_argument('--doPerNch', dest='doPerNch', default=False, action='store_true', help='break-down per Nch [default: %default]') parser.add_argument('--doPerEra', dest='doPerEra', default=False, action='store_true', help='break-down per era [default: %default]') parser.add_argument( '--doPerPU', dest='doPerPU', default=False, action='store_true', help='break-down per pileup category [default: %default]') parser.add_argument('--doPerAngle', dest='doPerAngle', default=False, action='store_true', help='break-down per angle [default: %default]') parser.add_argument('--lumi', dest='lumi', default=37500., type=float, help='integrated luminosity [default: %default]') parser.add_argument('-o', '--output', dest='output', default='analysis/bkg', help='Output directory [default: %default]') opt = parser.parse_args(args) ROOT.gROOT.SetBatch(True) ROOT.gStyle.SetOptTitle(0) ROOT.gStyle.SetOptStat(0) os.system('mkdir -p %s' % opt.output) #do all possible combinations of these categories baseCats = ['protonCat==%d' % (i + 1) for i in range(4)] subCats = [''] if opt.doPerEra: subCats += ['era==%d' % int(ord(x)) for x in 'BCDEF'] if opt.doPerPU: subCats += ['nvtx<20', 'nvtx>=20'] if opt.doPerAngle: subCats += ['xangle==%d' % i for i in [120, 130, 140, 150]] if opt.doPerNch: subCats += ['nch<15', 'nch>=15'] catList = list(itertools.product(baseCats, subCats)) outF = '%s/plotter_embkg.root' % opt.output os.system('rm %s' % outF) print '[doBackgroundValidation] with %d variations to test' % len(catList) print '\t output will be available in', outF for i, cat in enumerate(catList): selCut = '' for c in cat: if len(c) == 0: continue selCut += '%s&&' % c selCut += opt.selCuts titleCut = parseTitleFromCut(selCut) print '\t', i, selCut data = fillShapes(inputDir=opt.input, selCuts=selCut, proc='MuonEG') for dist in data: pname = '%s_%d' % (dist, i) for c in [':', ',', '>', '=', '(', ')', '-', '<', '?']: pname = pname.replace(c, '') p = Plot(pname) p.doChi2 = False #True p.nominalDistForSystsName = 'background' #if dist=='mmiss': # newBins=range(0,1000,40)+[1000,1100,1200,1500,2000] # print 'Rebinning',dist,'to',newBins # for k in data[dist]: # data[dist][k]=rebinUnequalBinSize(data[dist][k],newBins) p.add(data[dist]['data'], title='data', color=ROOT.kBlack, isData=True, spImpose=False, isSyst=False) p.add(data[dist]['bkg'], title='background', color=ROOT.kCyan - 6, isData=False, spImpose=False, isSyst=False) #background systematics ci = 1 for syst in [ '{0}_bkgshape_MuonEG_obsUp', '{0}_bkgshape_MuonEG_obsDown', '{0}_bkgsinglediffUp_MuonEG_obs', '{0}_bkgsinglediffDown_MuonEG_obs', ]: ci = ci + 1 p.add( data[dist][syst.format(dist)], title=syst, color=ROOT.kCyan - 6, #ci isData=False, spImpose=False, #True, isSyst=True) #False) #p.ratiorange=[0.78,1.22] p.ratiorange = [0.58, 1.43] p.show(opt.output, opt.lumi, extraText='\\'.join(titleCut)) p.appendTo(outF) p.reset()