示例#1
0
def kinematicDistributions(region):
	ROOT.gROOT.SetBatch()
	for var in samples[0].regions[0].mm.histos['nom'].keys():
		print 'at variable:', var
		for t in ['tt', 'tl', 'll']:
			print 'at type:', t
			for sys in ['nom', 'jesup', 'jesdn', 'jer', 'bup', 'bdn']:
				print 'at systematic:', sys
				legend = lib.makeLegend(0.6, 0.6, 0.8, 0.87)
				legend.SetTextSize(0.04)
				mcstack = ROOT.THStack('mcstack', 'mcstack')
				mcint = 0.
				for sample in samples:
					if  incQCD == False:
						if 'qcd' in sample.name: continue
					if sample == totals or sample.isdata: continue
					#
					reg = SRs.index(region)
					print sample.name
					sample.regions[reg].mm.histos[sys][var][t].SetFillColor(sample.color)
					mcint += sample.regions[reg].mm.histos[sys][var][t].Integral()
					mcstack.Add(sample.regions[reg].mm.histos[sys][var][t])
					legend.AddEntry(sample.regions[reg].mm.histos[sys][var][t], sample.name, 'f')

				legend.AddEntry(doublemu.regions[reg].mm.histos[sys][var][t], doublemu.name, 'pe')
				func = helper.canvasWithRatio(mcstack, doublemu.regions[reg].mm.histos[sys][var][t], legend)
				c = func[0] #don't ask me why this is necessary
				print c.ls()
				c.Update()
				c.FindObject('ratio').GetXaxis().SetTitle(helper.getLatexVariable(var))
				c.FindObject('mcstack').SetTitle(helper.getLatexType(t))
				c.Draw()
				helper.saveAll(c, 'figs/'+var+'_'+doublemu.regions[reg].name+'_'+sys+'_'+t)
	return
示例#2
0
def isoplots(region):
	ROOT.gROOT.SetBatch()
	reg = SRs.index(region)
	for key in samples[0].regions[reg].histos.keys():
		if not key in ['muiso', 'muisoT', 'muisoL', 'muisoTL', 'muisoTLT', 'muisoTLL', 'muip', 'muipTL',  
		               'eliso', 'elisoT', 'elisoL', 'elisoTL', 'elisoTLT', 'elisoTLL', 'elip', 'elipTL' ]: continue
		if 'mu' in key:
			mulegend = lib.makeLegend(0.4, 0.6, 0.6, 0.87)
			mulegend.SetTextSize(0.04)
			mumcstack = ROOT.THStack('mumcstack', 'mumcstack')
			mumcint = 0.
		if 'el' in key:
			ellegend = lib.makeLegend(0.6, 0.6, 0.8, 0.8)
			ellegend.SetTextSize(0.04)
			elmcstack = ROOT.THStack('elmcstack', 'elmcstack')
			elmcint = 0.
		for sample in samples:
			if sample == totals or sample.isdata: continue
			#muons 
			if 'mu' in key:
				sample.regions[reg].histos[key].SetFillColor(sample.color)
				mumcint += sample.regions[reg].histos[key].Integral()
				mumcstack.Add(sample.regions[reg].histos[key])
				mulegend.AddEntry(sample.regions[reg].histos[key], sample.name, 'f')
			#electrons 
			if 'el' in key:
				sample.regions[reg].histos[key].SetFillColor(sample.color)
				elmcint += sample.regions[reg].histos[key].Integral()
				elmcstack.Add(sample.regions[reg].histos[key])
				ellegend.AddEntry(sample.regions[reg].histos[key], sample.name, 'f')
		
		if 'mu' in key:
			mulegend.AddEntry(doublemu.regions[reg].histos[key], doublemu.name, 'pe')
			mufunc = helper.canvasWithRatio(mumcstack, doublemu.regions[reg].histos[key], mulegend)
			cmu = mufunc[0] #don't ask me why this is necessary
			cmu.Update()
			cmu.Draw()
			helper.saveAll(cmu, 'figs/'+key+'_sideband_'+samples[0].regions[reg].name)
	 
		if 'el' in key:
			ellegend.AddEntry(doubleel.regions[reg].histos[key], doubleel.name, 'pe')
			elfunc = helper.canvasWithRatio(elmcstack, doubleel.regions[reg].histos[key], ellegend)
			cel = elfunc[0] #don't ask me why this is necessary
			cel.Update()
			cel.Draw()
			helper.saveAll(cel, 'figs/'+key+'_sideband_'+samples[0].regions[reg].name)
	return