Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compute the off-shell strength (not to be merged yet) #401

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions python/HiggsWidth2017.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from HiggsAnalysis.CombinedLimit.PhysicsModel import *


### This is the base python class to study the Higgs width

class HiggsWidth(PhysicsModel):
def __init__(self):
self.mHRange = []
self.GGsmfixed = False
self.is2l2nu = False
self.poiMap = []
self.pois = {}
self.verbose = False
self.xsec= 1.0
self.xsec_vbf= 1.0
self.m= 200
self.w= 10.
def setModelBuilder(self, modelBuilder):
PhysicsModel.setModelBuilder(self,modelBuilder)
self.modelBuilder.doModelBOnly = False

def getYieldScale(self,bin,process):
if process == "ggH_sonl": return "ggH_s_func"
elif process == "ggH_bonl": return "ggH_b_func"
elif process == "ggH_sand": return "ggH_sbi_func"
#if process == "qqH_sonl": return "qqH_s_func"
#elif process == "qqH_bonl": return "qqH_b_func"
#elif process == "qqH_sand": return "qqH_sbi_func"
else:
return 1

def setPhysicsOptions(self,physOptions):
for po in physOptions:
if po == "GGsmfixed":
print "Will fix CMS_zz4l_GGsm to 1 and float mu"
self.GGsmfixed = True
if po == "is2l2nu":
print "Will consider cards in 2l2nu style (separated S, B, S+B+I)"
self.is2l2nu = True
if po == "muAsPOI":
print "Will combine all ZZ cards"
self.isCombine = True
if po.startswith("m="):
self.m = float(po.replace("m=",""))
print "mass = ",self.m
if po.startswith("w="):
self.w = float(po.replace("w=",""))
print "width = ",self.w




def doParametersOfInterest(self):
"""Create POI and other parameters, and define the POI set."""
if self.modelBuilder.out.var("r"):
print "have r inside"
else:
self.modelBuilder.doVar("r[10,0,1000]")
if self.modelBuilder.out.var("fvbf"):
print "have fvbf inside"
else:
self.modelBuilder.doVar("fvbf[0,0,1]")
# if self.is2l2nu:
#self.setXsec()
#self.modelBuilder.factory_( "expr::CMS_zz2l2nu_mu(\"@0*(1-@1)*0.0673*0.2*2/1000./%f\", r,fvbf)" %(self.xsec))
#self.modelBuilder.factory_( "expr::CMS_zz2l2nu_mu_vbf(\"@0*@1*0.0673*0.2*2/1000./%f\", r,fvbf)" %(self.xsec_vbf))
#poi = "r"

poi = "r"

self.modelBuilder.factory_( "expr::ggH_s_func(\"@0-sqrt(@0)\", r)")
self.modelBuilder.factory_( "expr::ggH_b_func(\"1-sqrt(@0)\", r)")
self.modelBuilder.factory_( "expr::ggH_sbi_func(\"sqrt(@0)\", r)")

#self.modelBuilder.factory_( "expr::qqH_s_func(\"@0-sqrt(@0)\", CMS_zz2l2nu_mu_vbf)")
# self.modelBuilder.factory_( "expr::qqH_b_func(\"1-sqrt(@0)\", CMS_zz2l2nu_mu_vbf)")
# self.modelBuilder.factory_( "expr::qqH_sbi_func(\"sqrt(@0)\", CMS_zz2l2nu_mu_vbf)")


self.modelBuilder.doSet("POI",poi)



higgswidth = HiggsWidth()
10 changes: 10 additions & 0 deletions test/hzz2l2v/computeWidth/getTheLimit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

computeLimit --m 125 --in /eos/cms/store/user/hbrun/analysis/plotters/plotter_width_21sept.root --syst --index 17,17,17 --bins eq0jets,geq1jets,vbf --json $CMSSW_BASE/src/UserCode/llvv_fwk/test/hzz2l2v/samples_widthLimits.json --key 2l2v_datadriven_SM --BackExtrapol --statBinByBin 0.00001 --dropBckgBelow 0.00001 --subNRB --histo mt_shapes --histoVBF mt_shapes --systpostfix _13TeV --shape --skipQQH --signalSufix "_cp1.00_brn0.00" --blindWithSignal

sh combineCards.sh

text2workspace.py card_combined.dat -o workspace.root -P UserCode.llvv_fwk.HiggsWidth2017:higgswidth --PO verbose

combine -n Exp -M MultiDimFit workspace.root -t -1 --expectSignal=1 --algo=grid --points 300 --setPhysicsModelParameterRanges r=0.0,15
python plotMuScan.py
101 changes: 101 additions & 0 deletions test/hzz2l2v/computeWidth/plotMuScan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from ROOT import *
from tdrStyle import *
setTDRStyle()

import os,sys,glob
from array import array

r_exp = array('d',[])
nll_exp = array('d',[])
r_obs = array('d',[])
nll_obs = array('d',[])
zeros = array('d',[])

f_exp = TFile("higgsCombineExp.MultiDimFit.mH120.root","READ")
t_exp = f_exp.Get("limit")
for i in xrange(1,t_exp.GetEntries()):
t_exp.GetEntry(i)
r_exp.append(t_exp.r)
nll_exp.append(2.0*t_exp.deltaNLL)
zeros.append(0.0)
#f_obs = TFile("higgsCombineObs.MultiDimFit.mH125.root","READ")
#t_obs = f_obs.Get("limit")
#for i in xrange(1,t_obs.GetEntries()):
# t_obs.GetEntry(i)#
# r_obs.append(t_obs.r)
# nll_obs.append(2.0*t_obs.deltaNLL)
# zeros.append(0.0)

v_r_exp = TVectorD(len(r_exp),r_exp)
#v_r_obs = TVectorD(len(r_obs),r_obs)
v_nll_exp = TVectorD(len(nll_exp),nll_exp)
#v_nll_obs = TVectorD(len(nll_obs),nll_obs)
v_zeros = TVectorD(len(zeros),zeros)

c = TCanvas("c","c",800, 800)
c.SetRightMargin(0.06)
c.SetLeftMargin(0.2)

dummy = TH1D("dummy","dummy", 1, 0.0,10.)
dummy.SetBinContent(1,0.0)
dummy.GetXaxis().SetTitle('#mu_{off-shell}')
dummy.GetYaxis().SetTitle('-2 #Delta lnL')
dummy.SetLineColor(0)
dummy.SetLineWidth(0)
dummy.SetFillColor(0)
dummy.SetMinimum(0.0)
dummy.SetMaximum(5.0)
dummy.Draw()

latexf = TLatex()
latexf.SetTextSize(0.4*c.GetTopMargin())
latexf.SetTextColor(2)
f1 = TF1("f1","1.0",0.0,10.0)
f1.SetLineColor(2)
f1.SetLineWidth(2)
f1.Draw("lsame")
latexf.DrawLatex(2.5, 1.1,"68% CL")
f2 = TF1("f1","3.84",0.0,10.0)
f2.SetLineColor(2)
f2.SetLineWidth(2)
f2.Draw("lsame")
latexf.DrawLatex(2.5, 3.94,"95% CL")

gr_exp = TGraphAsymmErrors(v_r_exp,v_nll_exp,v_zeros,v_zeros,v_zeros,v_zeros)
gr_exp.SetLineColor(1)
gr_exp.SetLineWidth(2)
gr_exp.SetLineStyle(2)
gr_exp.Draw("Lsame")

#gr_obs = TGraphAsymmErrors(v_r_obs,v_nll_obs,v_zeros,v_zeros,v_zeros,v_zeros)
#gr_obs.SetLineColor(1)
#gr_obs.SetLineColor(1)
#gr_obs.SetLineWidth(2)
#gr_obs.Draw("Lsame")

latex2 = TLatex()
latex2.SetNDC()
latex2.SetTextSize(0.5*c.GetTopMargin())
latex2.SetTextFont(42)
latex2.SetTextAlign(31) # align right
latex2.DrawLatex(0.87, 0.95,"35.9 fb^{-1} (13 TeV)")
latex2.SetTextSize(0.7*c.GetTopMargin())
latex2.SetTextFont(62)
latex2.SetTextAlign(11) # align right
latex2.DrawLatex(0.20, 0.95, "CMS")
latex2.SetTextSize(0.6*c.GetTopMargin())
latex2.SetTextFont(52)
latex2.SetTextAlign(11)
latex2.DrawLatex(0.32, 0.95, "Preliminary")

legend = TLegend(.60,.14,.90,.26)
#legend.AddEntry(gr_obs , "Observed", "l")
legend.AddEntry(gr_exp , "Expected", "l")
legend.SetShadowColor(0)
legend.SetFillColor(0)
legend.SetLineColor(0)
legend.Draw("same")

gPad.RedrawAxis()

c.SaveAs("muscan.pdf")
146 changes: 146 additions & 0 deletions test/hzz2l2v/computeWidth/tdrStyle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import sys, ROOT
from ROOT import gStyle

def setTDRStyle():

# For the canvas:
ROOT . gStyle . SetCanvasBorderMode(0)
ROOT . gStyle . SetCanvasColor(0) # must be kWhite but I dunno how to do that in PyROOT
ROOT . gStyle . SetCanvasDefH(600) #Height of canvas
ROOT . gStyle . SetCanvasDefW(600) #Width of canvas
ROOT . gStyle . SetCanvasDefX(0) #POsition on screen
ROOT . gStyle . SetCanvasDefY(0)


# For the Pad:
ROOT . gStyle . SetPadBorderMode(0);
# ROOT . gStyle . SetPadBorderSize(Width_t size = 1);
ROOT . gStyle . SetPadColor(0); # kWhite
ROOT . gStyle . SetPadGridX(0); #false
ROOT . gStyle . SetPadGridY(0); #false
ROOT . gStyle . SetGridColor(0);
ROOT . gStyle . SetGridStyle(3);
ROOT . gStyle . SetGridWidth(1);

# For the frame:
ROOT . gStyle . SetFrameBorderMode(0);
ROOT . gStyle . SetFrameBorderSize(1);
ROOT . gStyle . SetFrameFillColor(0);
ROOT . gStyle . SetFrameFillStyle(0);
ROOT . gStyle . SetFrameLineColor(1);
ROOT . gStyle . SetFrameLineStyle(1);
ROOT . gStyle . SetFrameLineWidth(1);

# For the histo:
# ROOT . gStyle . SetHistFillColor(1);
# ROOT . gStyle . SetHistFillStyle(0);
ROOT . gStyle . SetHistLineColor(1);
ROOT . gStyle . SetHistLineStyle(0);
ROOT . gStyle . SetHistLineWidth(1);
# ROOT . gStyle . SetLegoInnerR(Float_t rad = 0.5);
# ROOT . gStyle . SetNumberContours(Int_t number = 20);

ROOT . gStyle . SetEndErrorSize(2);
#ROOT . gStyle . SetErrorMarker(20); #/ I COMMENTED THIS OUT
#ROOT . gStyle . SetErrorX(0.);

#ROOT . gStyle . SetMarkerStyle(20);


#For the fit/function:
ROOT . gStyle . SetOptFit(1011);
ROOT . gStyle . SetFitFormat("5.4g");
ROOT . gStyle . SetFuncColor(2);
ROOT . gStyle . SetFuncStyle(1);
ROOT . gStyle . SetFuncWidth(1);

#For the date:
ROOT . gStyle . SetOptDate(0);
# ROOT . gStyle . SetDateX(Float_t x = 0.01);
# ROOT . gStyle . SetDateY(Float_t y = 0.01);

# For the statistics box:
ROOT . gStyle . SetOptFile(0);
ROOT . gStyle . SetOptStat(0); # To display the mean and RMS: SetOptStat("mr");
ROOT . gStyle . SetStatColor(0); # kWhite
ROOT . gStyle . SetStatFont(42);
#ROOT . gStyle . SetStatFontSize(0.025);
ROOT . gStyle . SetStatFontSize(0.04);
ROOT . gStyle . SetStatTextColor(1);
ROOT . gStyle . SetStatFormat("6.4g");
ROOT . gStyle . SetStatBorderSize(1);
ROOT . gStyle . SetStatH(0.1);
ROOT . gStyle . SetStatW(0.15);
# ROOT . gStyle . SetStatStyle(Style_t style = 1001);
# ROOT . gStyle . SetStatX(Float_t x = 0);
# ROOT . gStyle . SetStatY(Float_t y = 0);

# Margins:
ROOT . gStyle . SetPadTopMargin(0.07);
ROOT . gStyle . SetPadBottomMargin(0.13);
ROOT . gStyle . SetPadLeftMargin(0.16);
#ROOT . gStyle . SetPadRightMargin(0.12);
ROOT . gStyle . SetPadRightMargin(0.03);

# For the Global title:

ROOT . gStyle . SetOptTitle(0);
ROOT . gStyle . SetTitleFont(42);
ROOT . gStyle . SetTitleColor(1);
ROOT . gStyle . SetTitleTextColor(1);
ROOT . gStyle . SetTitleFillColor(10);
ROOT . gStyle . SetTitleFontSize(0.05);
# ROOT . gStyle . SetTitleH(0); # Set the height of the title box
# ROOT . gStyle . SetTitleW(0); # Set the width of the title box
# ROOT . gStyle . SetTitleX(0); # Set the position of the title box
# ROOT . gStyle . SetTitleY(0.985); # Set the position of the title box
# ROOT . gStyle . SetTitleStyle(Style_t style = 1001);
# ROOT . gStyle . SetTitleBorderSize(2);

# For the axis titles:

ROOT . gStyle . SetTitleColor(1, "XYZ");
ROOT . gStyle . SetTitleFont(42, "XYZ");
ROOT . gStyle . SetTitleSize(0.06, "XYZ");
# ROOT . gStyle . SetTitleXSize(Float_t size = 0.02); # Another way to set the size?
# ROOT . gStyle . SetTitleYSize(Float_t size = 0.02);
ROOT . gStyle . SetTitleXOffset(0.9);
ROOT . gStyle . SetTitleYOffset(1.25);
# ROOT . gStyle . SetTitleOffset(1.1, "Y"); # Another way to set the Offset

# For the axis labels:

ROOT . gStyle . SetLabelColor(1, "XYZ");
ROOT . gStyle . SetLabelFont(42, "XYZ");
ROOT . gStyle . SetLabelOffset(0.007, "XYZ");
ROOT . gStyle . SetLabelSize(0.05, "XYZ");

# For the axis:

ROOT . gStyle . SetAxisColor(1, "XYZ");
ROOT . gStyle . SetStripDecimals(1); # kTRUE
ROOT . gStyle . SetTickLength(0.03, "XYZ");
ROOT . gStyle . SetNdivisions(510, "XYZ");
ROOT . gStyle . SetPadTickX(1); # To get tick marks on the opposite side of the frame
ROOT . gStyle . SetPadTickY(1);

# Change for log plots:
ROOT . gStyle . SetOptLogx(0);
ROOT . gStyle . SetOptLogy(0);
ROOT . gStyle . SetOptLogz(0);

# Postscript options:
ROOT . gStyle . SetPaperSize(20.,20.);
# ROOT . gStyle . SetLineScalePS(Float_t scale = 3);
# ROOT . gStyle . SetLineStyleString(Int_t i, const char* text);
# ROOT . gStyle . SetHeaderPS(const char* header);
# ROOT . gStyle . SetTitlePS(const char* pstitle);

# ROOT . gStyle . SetBarOffset(Float_t baroff = 0.5);
# ROOT . gStyle . SetBarWidth(Float_t barwidth = 0.5);
# ROOT . gStyle . SetPaintTextFormat(const char* format = "g");
# ROOT . gStyle . SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
# ROOT . gStyle . SetTimeOffset(Double_t toffset);
# ROOT . gStyle . SetHistMinimumZero(kTRUE);


Loading