Skip to content

Commit

Permalink
Merge pull request cms-sw#166 from amarini/taunu_and_hmm
Browse files Browse the repository at this point in the history
Hmm
  • Loading branch information
amarini authored Aug 7, 2017
2 parents f300cd6 + 59b1cae commit 1671169
Show file tree
Hide file tree
Showing 19 changed files with 2,106 additions and 28 deletions.
19 changes: 19 additions & 0 deletions aux/mcdb.TauNu.2017.dat

Large diffs are not rendered by default.

Binary file modified aux/pileup.TauNu.moriond.root
Binary file not shown.
3 changes: 2 additions & 1 deletion dat/configHmumu.dat
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ include=dat/hmumu.dat
MCDB=aux/mcdb.TauNu.2017.dat
pileup=aux/pileup.TauNu.moriond.root
#Correct=ScaleAndSmear
Correct=ScaleAndSmear,KaMuCa,JetFilter2016
#Correct=ScaleAndSmear,KaMuCa,JetFilter2016
Correct=ScaleAndSmear,KaMuCa
#Correct=ScaleAndSmear,RochesterCorrections

Analysis=JsonAnalysis,MetFiltersAnalysis,HmumuAnalysis
85 changes: 85 additions & 0 deletions dat/configHmumuUEPS.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
include=dat/configHmumu.dat
sub=systDir|/eos/user/a/amarini/Nero/v2.2.1/Syst
sub=amariniUser|/store/user/amarini/Nero/v2.2.1

#only signal!!!
Files=
## Signal
#include=dat/catalog/2017.moriond/hmm.dat

addfiles=%(amariniUser)s/GluGlu_HToMuMu_M125_13TeV_powheg_pythia8
addfiles=%(amariniUser)s/VBF_HToMuMu_M125_13TeV_powheg_pythia8
addfiles=%(amariniUser)s/WMinusH_HToMuMu_M125_13TeV_powheg_pythia8
addfiles=%(amariniUser)s/WPlusH_HToMuMu_M125_13TeV_powheg_pythia8
addfiles=%(amariniUser)s/ZH_HToMuMu_M125_13TeV_powheg_pythia8
addfiles=/eos/user/a/amarini/Nero/v2.2.1/ttH_HToMuMu_M125_13TeV_powheg_pythia8_v2

addfiles=%(systDir)s/GluGlu_HToMuMu_M125_PSDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/GluGlu_HToMuMu_M125_PSUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/GluGlu_HToMuMu_M125_TuneDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/GluGlu_HToMuMu_M125_TuneUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/VBF_HToMuMu_M125_PSDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/VBF_HToMuMu_M125_PSUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/VBF_HToMuMu_M125_TuneDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/VBF_HToMuMu_M125_TuneUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/WMinusH_HToMuMu_M125_PSDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/WMinusH_HToMuMu_M125_PSUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/WMinusH_HToMuMu_M125_TuneDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/WMinusH_HToMuMu_M125_TuneUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/WPlusH_HToMuMu_M125_PSDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/WPlusH_HToMuMu_M125_PSUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/WPlusH_HToMuMu_M125_TuneDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/WPlusH_HToMuMu_M125_TuneUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/ZH_HToMuMu_M125_PSDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/ZH_HToMuMu_M125_PSUp_13TeV_powheg_pythia8
addfiles=%(systDir)s/ZH_HToMuMu_M125_TuneDown_13TeV_powheg_pythia8
addfiles=%(systDir)s/ZH_HToMuMu_M125_TuneUp_13TeV_powheg_pythia8

addConfig=HmumuAnalysis|labels.clear()

### PSUp
addConfig=HmumuAnalysis|AddLabel('GluGlu_HToMuMu_M125_PSUp')
addConfig=HmumuAnalysis|AddLabel('VBF_HToMuMu_M125_PSUp')
addConfig=HmumuAnalysis|AddLabel('ZH_HToMuMu_M125_PSUp')
addConfig=HmumuAnalysis|AddLabel('WMinusH_HToMuMu_M125_PSUp')
addConfig=HmumuAnalysis|AddLabel('WPlusH_HToMuMu_M125_PSUp')
addConfig=HmumuAnalysis|AddLabel('ttH_HToMuMu_M125_PSUp')

### PSDown
addConfig=HmumuAnalysis|AddLabel('GluGlu_HToMuMu_M125_PSDown')
addConfig=HmumuAnalysis|AddLabel('VBF_HToMuMu_M125_PSDown')
addConfig=HmumuAnalysis|AddLabel('ZH_HToMuMu_M125_PSDown')
addConfig=HmumuAnalysis|AddLabel('WMinusH_HToMuMu_M125_PSDown')
addConfig=HmumuAnalysis|AddLabel('WPlusH_HToMuMu_M125_PSDown')
addConfig=HmumuAnalysis|AddLabel('ttH_HToMuMu_M125_PSDown')

### TuneUp
addConfig=HmumuAnalysis|AddLabel('GluGlu_HToMuMu_M125_TuneUp')
addConfig=HmumuAnalysis|AddLabel('VBF_HToMuMu_M125_TuneUp')
addConfig=HmumuAnalysis|AddLabel('ZH_HToMuMu_M125_TuneUp')
addConfig=HmumuAnalysis|AddLabel('WMinusH_HToMuMu_M125_TuneUp')
addConfig=HmumuAnalysis|AddLabel('WPlusH_HToMuMu_M125_TuneUp')
addConfig=HmumuAnalysis|AddLabel('ttH_HToMuMu_M125_TuneUp')

### TuneDown
addConfig=HmumuAnalysis|AddLabel('GluGlu_HToMuMu_M125_TuneDown')
addConfig=HmumuAnalysis|AddLabel('VBF_HToMuMu_M125_TuneDown')
addConfig=HmumuAnalysis|AddLabel('ZH_HToMuMu_M125_TuneDown')
addConfig=HmumuAnalysis|AddLabel('WMinusH_HToMuMu_M125_TuneDown')
addConfig=HmumuAnalysis|AddLabel('WPlusH_HToMuMu_M125_TuneDown')
addConfig=HmumuAnalysis|AddLabel('ttH_HToMuMu_M125_TuneDown')


################ NOMINAL ############
addConfig=HmumuAnalysis|AddLabel('GluGlu_HToMuMu_M125')
addConfig=HmumuAnalysis|AddLabel('VBF_HToMuMu_M125')
addConfig=HmumuAnalysis|AddLabel('ZH_HToMuMu_M125')
addConfig=HmumuAnalysis|AddLabel('WMinusH_HToMuMu_M125')
addConfig=HmumuAnalysis|AddLabel('WPlusH_HToMuMu_M125')
addConfig=HmumuAnalysis|AddLabel('ttH_HToMuMu_M125')

Smear=NONE

## be less peaky, given the n. of systs
#Final=true
EntryPerSecond=10
23 changes: 21 additions & 2 deletions python/hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def __init__(self):
## DATACARD specific ##

self.datacard_procs=['BKG','GluGlu','VBF','WPlusH','WMinusH','ttH','ZH']

##BKG functions after bias
self.bkg_functions=[]

self.computeVersioning()

Expand Down Expand Up @@ -88,7 +91,7 @@ def computeVersioning(self):
def Print(self):
print "--- Hmm Configurator ---"
print "Name:",self.__class__.__name__
for x in ["xmin","xmax","muCategories","procCategories","categories","sig_mass_points","processes","datacard_procs","sigfit_scale_unc","sigfit_smear_unc","catVersion","fitVersion"]:
for x in ["xmin","xmax","muCategories","procCategories","categories","sig_mass_points","processes","datacard_procs","sigfit_scale_unc","sigfit_smear_unc","catVersion","fitVersion","bkg_functions"]:
print x+"=",eval("self."+x)
print "------------------------"
print "125: BR",self.br(125)
Expand Down Expand Up @@ -230,7 +233,7 @@ def __init__(self):
self.categories=[ "cat%d"%x for x in range(0,13)]
self.procCategories=[]
self.muCategories=[]
self.sigfit_gaussians=[]
self.sigfit_gaussians={}
#self.readScaleUnc()
self.SimpleScaleAndSmear()
self.computeVersioning()
Expand All @@ -248,6 +251,22 @@ def __init__(self):
HmmConfigAutoCat.__init__(self)
self.categories=[ "cat%d"%x for x in range(0,16)]
self.computeVersioning()
self.sigfit_gaussians[("cat1","GluGlu")] = 2 ## 11
self.sigfit_gaussians[("cat14","GluGlu")] = 1 ## 11
self.sigfit_gaussians[("cat15","GluGlu")] = 1 ## 11
self.sigfit_gaussians[("cat14","VBF")] = 1 ## 11
self.sigfit_gaussians[("cat15","VBF")] = 1 ## 11
self.sigfit_gaussians[("cat14","WPlusH")] = 1 ## 11
self.sigfit_gaussians[("cat15","WPlusH")] = 1 ## 11
self.sigfit_gaussians[("cat14","WMinusH")] = 1 ## 11
self.sigfit_gaussians[("cat15","WMinusH")] = 1 ## 11
self.sigfit_gaussians[("cat14","ZH")] = 2 ## 11
self.sigfit_gaussians[("cat15","ZH")] = 1 ## 11
self.sigfit_gaussians[("cat1","ttH")] = 2 ## 11
self.sigfit_gaussians[("cat1","ttH")] = 3 ## 11

self.bkg_functions=["zmod2_cat0_ord5","exp_cat1_ord3","zmod2_cat2_ord5","exp_cat3_ord3","zmod2_cat4_ord5","zmod_cat5_ord1","zmod2_cat6_ord5","zmod2_cat7_ord5","zmod2_cat8_ord5","zmod2_cat9_ord5","zmod_cat10_ord1","zmod_cat11_ord1","zmod2_cat12_ord5","zmod_cat13_ord1","bern2_cat14_ord4","bern2_cat15_ord5"]


hmmTTH =HmmConfigTTH()
hmmWithTTH =HmmConfigWithTTH()
Expand Down
69 changes: 69 additions & 0 deletions script/Hmumu/makeBackgroundPlots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import ROOT
import os,sys
from array import array
import re,math
from optparse import OptionParser, OptionGroup
print "-> Looking for basepath"
basepath = ""
mypath = os.path.abspath(os.getcwd())
while mypath != "" and mypath != "/":
if "ChargedHiggs" in os.path.basename(mypath):
basepath = os.path.abspath(mypath)
mypath = os.path.dirname(mypath)
print "-> Base Path is " + basepath
sys.path.insert(0,basepath)
sys.path.insert(0,basepath +"/python")
from hmm import hmm,hmmAutoCat,hmmWithTTH, Stack
parser=OptionParser()
parser.add_option("-i","--input",type='string',help="Input ROOT file. [%default]", default="Background.root")
parser.add_option("","--hmm",dest="hmm",type="string",help="HmmConfig instance [%default]",default="hmmWithTTH")
parser.add_option("","--unblind",dest="blind",action='store_false',help="Un/Blind plots [%default]",default=True)
parser.add_option("-p","--plot",type='string',help="Plot Dir [%default]", default="Hmumu/Plot/bkg")
opts,args= parser.parse_args()


fIn = ROOT.TFile.Open(opts.input)
if fIn == None:
print "<*> Error,",opts.input,"no such file or directory"

w = fIn.Get("w")
if w == None:
print "<*> Error, unable to locate workspace w in input file"

config= eval(opts.hmm)
config.Print()

if len(config.bkg_functions) == 0 :
print "<*> Error, no bkg functions in configuration"

try:
os.mkdir(opts.plot)
except OSError:
pass

obj=[]
for icat,cat in enumerate(config.categories):
print "* Doing cat",cat
x = w.var("mmm")
x.SetTitle("m_{#mu#mu} [GeV]")
c=ROOT.TCanvas(cat,cat,800,800)
p=x.frame()
data=w.data("dataObs_"+cat)
if opts.blind:
data.plotOn(p,ROOT.RooFit.Name("data"), ROOT.RooFit.CutRange("unblindReg_1"),ROOT.RooFit.Binning(200));
data.plotOn(p,ROOT.RooFit.Name("data"), ROOT.RooFit.CutRange("unblindReg_2"),ROOT.RooFit.Binning(200));
data.plotOn(p,ROOT.RooFit.Name("data"), ROOT.RooFit.Invisible(),ROOT.RooFit.Binning(200));
p.SetMinimum(0.1);
else:
data.plotOn(p,ROOT.RooFit.Name("data"),ROOT.RooFit.Binning(200));
pdf=w.pdf( config.bkg_functions[icat])
pdf.plotOn(p)

obj.extend([data,c,p,pdf])
p.Draw()
c.SaveAs(opts.plot +"/final_bkg_"+ cat+ ".pdf" );
c.SaveAs(opts.plot +"/final_bkg_"+ cat+ ".png" );
#raw_input("ok?")



67 changes: 67 additions & 0 deletions script/makeFinalPlotsHmm.py → script/Hmumu/makeFinalPlotsHmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,58 @@ def SoB(h,hdata,low,high,type=""):
c.SaveAs(opts.outdir + "/effAcc.pdf")
c.SaveAs(opts.outdir + "/effAcc.png")

if doSig:## EA plot inclusive only

c=ROOT.TCanvas("c_"+cat+"_ea","canvas",800,800)
###
dummy = ROOT.TH2F("dummy","",10,120,130,100,0,1);
dummy.SetStats(0);

## Set Style and draw
c.SetTopMargin(0.05)
c.SetRightMargin(0.05)
c.SetBottomMargin(0.15)
c.SetLeftMargin(0.15)

dummy.Draw("AXIS")
dummy.GetXaxis().SetTitle("m_{H} [GeV]")
dummy.GetXaxis().SetTitleOffset(1.3)
dummy.GetYaxis().SetTitle("#varepsilon A")
dummy.GetYaxis().SetTitleOffset(1.4)
dummy.GetYaxis().SetRangeUser(.26,.75)

txt=ROOT.TLatex()
txt.SetNDC()
txt.SetTextFont(43)
#txt.SetTextSize(20)
#txt.SetTextAlign(31)
#txt.DrawLatex(.95,.96,"%.1f fb^{-1} (13 TeV)"%(float(config.lumi()/1000.)))
txt.SetTextSize(30)
txt.SetTextAlign(13)
txt.DrawLatex(.16,.93,"#bf{CMS} #scale[0.7]{#it{Simulation Preliminary}}")

x0=.5
y0=.20
leg = ROOT.TLegend(x0,y0,x0+.4,y0+.15)
leg.SetFillStyle(0)
leg.SetBorderSize(0)
leg.SetNColumns(2)
leg.AddEntry(g['tot'],"SM H","L")
leg.AddEntry(g['stat'],"stat. err","F")
g['tot'] . Draw("3 SAME")
g['tot'] . Draw("LX SAME")
leg.Draw()

dummy.Draw("AXIS SAME")
dummy.Draw("AXIS X+ Y+ SAME")
c.Modify()
c.Update()
if opts.outdir=="":
raw_input("ok?")
else:
c.SaveAs(opts.outdir + "/effAcc_incl.pdf")
c.SaveAs(opts.outdir + "/effAcc_incl.png")

rebin=opts.rebin
doBkg=not opts.noBkg
if doBkg:
Expand Down Expand Up @@ -727,6 +779,21 @@ def SoB(h,hdata,low,high,type=""):
if 'BdtOnH' in opts.var and opts.doRemap:
dummy.GetXaxis().SetTitle("BDT Quantile")

if 'Met' in opts.var:
dummy.GetXaxis().SetTitle("E_{T}^{miss}[GeV]")
elif 'NJets' in opts.var:
dummy.GetXaxis().SetTitle("N_{jets}")
elif 'NBJets' in opts.var:
dummy.GetXaxis().SetTitle("N_{b jets}")
elif 'EtaJet1' in opts.var:
dummy.GetXaxis().SetTitle("#eta_{1 jet}")
elif 'EtaJet2' in opts.var:
dummy.GetXaxis().SetTitle("#eta_{2 jet}")
elif 'PtJet1' in opts.var:
dummy.GetXaxis().SetTitle("p_{T}^{1 jet} [GeV]")
elif 'PtJet2' in opts.var:
dummy.GetXaxis().SetTitle("p_{T}^{2 jet} [GeV]")

dummy.GetXaxis().SetTitleOffset(2.0)
dummy.GetYaxis().SetTitle("Events")
dummy.GetYaxis().SetTitleOffset(2.0)
Expand Down
2 changes: 1 addition & 1 deletion script/Hmumu/plotBiasAsimov.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
w= fData.Get(opts.data.split(':')[1])
data_roo=w.data(opts.data.split(':')[2])
data=data_roo.createHistogram("mmm")
data.Rebin(5)
data.Rebin(20)
for i in range(0,data.GetNbinsX()):
x=data.GetBinCenter(i)
ydata=data.GetBinContent(i)
Expand Down
Loading

0 comments on commit 1671169

Please sign in to comment.