Skip to content

Commit

Permalink
big updates in plotting for new AC fits
Browse files Browse the repository at this point in the history
  • Loading branch information
emanueledimarco committed Mar 14, 2023
1 parent c1a9756 commit 33a2710
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 47 deletions.
19 changes: 9 additions & 10 deletions Plots/cats.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"all":"All Categories",
"wall":"#splitline{All Categories}{S/(S+B) weighted}",
"VBFTag_0":"not populated cat",
"VBFTag_1":"ggH low purity",
"VBFTag_2":"not populated cat",
"VBFTag_3":"ggH high purity",
"VBFTag_4":"not populated cat",
"VBFTag_5":"qqH SM-like",
"VBFTag_6":"qqH BSM-like high purity",
"VBFTag_7":"qqH BSM-like med purity"
"all":"All Categories",
"wall":"#splitline{All Categories}{S/(S+B) weighted}",
"RECO_VBFTOPO_ACGGH_Tag0":"ggH low purity",
"RECO_VBFTOPO_ACGGH_Tag1":"ggH high purity",
"RECO_VBFTOPO_ACVBFSM_Tag0":"qqH SM-like",
"RECO_VBFTOPO_ACVBFBSM_Tag0":"qqH BSM-like high purity",
"RECO_VBFTOPO_ACVBFBSM_Tag1":"qqH BSM-like med purity",
"RECO_VBFTOPO_VHHAD_Tag0":"qqH VH Tag0",
"RECO_VBFTOPO_VHHAD_Tag1":"qqH VH Tag1",
}

5 changes: 5 additions & 0 deletions Plots/cats_latex.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"RECO_PTH_GT650_Tag0":"BSM high $\\ptgg$",
"RECO_VBFTOPO_VHHAD_Tag0":"qqH VH-like Tag0",
"RECO_VBFTOPO_VHHAD_Tag1":"qqH VH-like Tag1",
"RECO_VBFTOPO_ACGGH_Tag0":"qqH ggH-like Tag0",
"RECO_VBFTOPO_ACGGH_Tag1":"qqH ggH-like Tag1",
"RECO_VBFTOPO_ACVBFSM_Tag0":"qqH SM-like",
"RECO_VBFTOPO_ACVBFBSM_Tag0":"qqH BSM-like Tag0",
"RECO_VBFTOPO_ACVBFBSM_Tag1":"qqH BSM-like Tag1",
"RECO_VBFTOPO_JET3VETO_LOWMJJ_Tag0":"qqH low $\\mjj$ low $\\ptHjj$ Tag0",
"RECO_VBFTOPO_JET3VETO_LOWMJJ_Tag1":"qqH low $\\mjj$ low $\\ptHjj$ Tag1",
"RECO_VBFTOPO_JET3VETO_HIGHMJJ_Tag0":"qqH high $\\mjj$ low $\\ptHjj$ Tag0",
Expand Down
5 changes: 3 additions & 2 deletions Plots/makeToys.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_options():
setParam0Str = setParam0Str[:-1]
mh_bf = w.var("MH").getVal()

if opt.batch == 'IC':
if opt.batch in ['IC','Rome']:
# Create submission file
for itoy in range(0,opt.nToys):
fsub = open("./SplusBModels%s/toys/jobs/sub_toy_%g.sh"%(opt.ext,itoy),'w')
Expand Down Expand Up @@ -76,7 +76,8 @@ def get_options():
os.system("chmod 775 ./SplusBModels%s/toys/jobs/sub*.sh"%opt.ext)
if not opt.dryRun:
subs = glob.glob("./SplusBModels%s/toys/jobs/sub*"%opt.ext)
for fsub in subs: os.system("qsub -q hep.q -l h_rt=4:0:0 -l h_vmem=24G %s"%fsub)
subcmd = 'qsub -q hep.q -l h_rt=4:0:0 -l h_vmem=24G' if opt.batch == 'IC' else 'bsub -q %s'%opt.queue
for fsub in subs: os.system("%s %s"%(subcmd,fsub))
else: print " --> [DRY-RUN] jobs have not been submitted"

elif opt.batch == 'condor':
Expand Down
117 changes: 95 additions & 22 deletions Plots/makeYieldsTables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def leave():
print " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HGG YIELDS TABLES RUN II (END) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "
sys.exit(1)


# Define STXS stage 0 mapping to procs
stage0_ggh = od()
stage0_ggh["ggH"] = ['ggH_0J_PTH_0_10','ggZH_had_0J_PTH_0_10','ggH_0J_PTH_GT10','ggZH_had_0J_PTH_GT10','ggH_1J_PTH_0_60','ggZH_had_1J_PTH_0_60','ggH_1J_PTH_60_120','ggZH_had_1J_PTH_60_120','ggH_1J_PTH_120_200','ggZH_had_1J_PTH_120_200','ggH_GE2J_MJJ_0_350_PTH_0_60','ggZH_had_GE2J_MJJ_0_350_PTH_0_60','ggH_GE2J_MJJ_0_350_PTH_60_120','ggZH_had_GE2J_MJJ_0_350_PTH_60_120','ggH_GE2J_MJJ_0_350_PTH_120_200','ggZH_had_GE2J_MJJ_0_350_PTH_120_200','ggH_GE2J_MJJ_350_700_PTH_0_200_PTHJJ_0_25','ggH_GE2J_MJJ_350_700_PTH_0_200_PTHJJ_GT25','ggH_GE2J_MJJ_GT700_PTH_0_200_PTHJJ_0_25','ggH_GE2J_MJJ_GT700_PTH_0_200_PTHJJ_GT25','ggZH_had_GE2J_MJJ_350_700_PTH_0_200_PTHJJ_0_25','ggZH_had_GE2J_MJJ_350_700_PTH_0_200_PTHJJ_GT25','ggZH_had_GE2J_MJJ_GT700_PTH_0_200_PTHJJ_0_25','ggZH_had_GE2J_MJJ_GT700_PTH_0_200_PTHJJ_GT25','ggH_PTH_200_300','ggZH_had_PTH_200_300','ggH_PTH_300_450','ggH_PTH_450_650','ggH_PTH_GT650','ggZH_had_PTH_300_450','ggZH_had_PTH_450_650','ggZH_had_PTH_GT650']
Expand Down Expand Up @@ -53,11 +54,17 @@ def leave():
stage0_top["tHq"] = ['tHq']
stage0_top["tHW"] = ['tHW']

cp_vbf = od()
cp_vbf["ggH"] = ['ggH']
cp_vbf["qqH"] = ['qqH']
cp_vbf["ttH"] = ['ttH']
cp_vbf["vH"] = ['vH']
cp_ggh = od()
cp_ggh["ggH"] = ['ggH']

cp_qqh = od()
cp_qqh["qqH"] = ['qqH']

cp_top = od()
cp_top["ttH"] = ['ttH']

cp_vh = od()
cp_vh["vH"] = ['WMINUSH2HQQ','WPLUSH2HQQ','ZH_lep']

# ggH tags
target_procs_ggh = od()
Expand Down Expand Up @@ -152,13 +159,81 @@ def leave():
target_procs_qqh["RECO_VBFTOPO_VHHAD_Tag1"] = ['qqH_GE2J_MJJ_60_120','WH_had_GE2J_MJJ_60_120','ZH_had_GE2J_MJJ_60_120']

# qqH tags for anomalous couplings
target_procs_ggh_ac = od()
target_procs_ggh_ac["RECO_0J_PTH_0_10_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_0J_PTH_0_10_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_0J_PTH_0_10_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_0J_PTH_GT10_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_0J_PTH_GT10_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_0J_PTH_GT10_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_0_60_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_0_60_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_0_60_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_120_200_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_120_200_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_120_200_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_60_120_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_60_120_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_1J_PTH_60_120_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_0_60_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_0_60_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_0_60_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_120_200_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_120_200_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_120_200_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_60_120_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_60_120_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_GE2J_PTH_60_120_Tag2"] = ['ggH']
target_procs_ggh_ac["RECO_PTH_200_300_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_PTH_200_300_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_PTH_300_450_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_PTH_300_450_Tag1"] = ['ggH']
target_procs_ggh_ac["RECO_PTH_450_650_Tag0"] = ['ggH']
target_procs_ggh_ac["RECO_PTH_GT650_Tag0"] = ['ggH']

target_procs_top_ac = od()
target_procs_top_ac["RECO_THQ_LEP"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_0_60_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_0_60_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_0_60_Tag2"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_120_200_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_120_200_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_120_200_Tag2"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_120_200_Tag3"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_200_300_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_200_300_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_200_300_Tag2"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_60_120_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_60_120_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_60_120_Tag2"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_GT300_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_HAD_PTH_GT300_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_0_60_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_0_60_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_0_60_Tag2"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_120_200_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_120_200_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_200_300_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_60_120_Tag0"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_60_120_Tag1"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_60_120_Tag2"] = ['ttH']
target_procs_top_ac["RECO_TTH_LEP_PTH_GT300_Tag0"] = ['ttH']

target_procs_qqh_ac = od()
target_procs_qqh_ac["VBFTag_1"] = ['qqH']
target_procs_qqh_ac["VBFTag_3"] = ['qqH']
target_procs_qqh_ac["VBFTag_5"] = ['qqH']
target_procs_qqh_ac["VBFTag_6"] = ['qqH']
target_procs_qqh_ac["VBFTag_7"] = ['qqH']
target_procs_qqh_ac["RECO_VBFTOPO_ACGGH_Tag0"] = ['qqH']
target_procs_qqh_ac["RECO_VBFTOPO_ACGGH_Tag1"] = ['qqH']
target_procs_qqh_ac["RECO_VBFTOPO_ACVBFBSM_Tag0"] = ['qqH']
target_procs_qqh_ac["RECO_VBFTOPO_ACVBFBSM_Tag1"] = ['qqH']
target_procs_qqh_ac["RECO_VBFTOPO_ACVBFSM_Tag0"] = ['qqH']

target_procs_vh_ac = od()
target_procs_vh_ac["RECO_VBFTOPO_VHHAD_Tag0"] = ['vH']
target_procs_vh_ac["RECO_VBFTOPO_VHHAD_Tag1"] = ['vH']
target_procs_vh_ac["RECO_VH_MET_Tag0"] = ['vH']
target_procs_vh_ac["RECO_VH_MET_Tag1"] = ['vH']
target_procs_vh_ac["RECO_VH_MET_Tag2"] = ['vH']
target_procs_vh_ac["RECO_WH_LEP_PTV_0_75_Tag0"] = ['vH']
target_procs_vh_ac["RECO_WH_LEP_PTV_0_75_Tag1"] = ['vH']

def get_options():
parser = OptionParser()
Expand All @@ -181,20 +256,17 @@ def LoadTranslations(jsonfilename):
translateStage0 = {} if opt.translateStage0 is None else LoadTranslations(opt.translateStage0)

if opt.group == "ggh":
stage0 = stage0_ggh
target_procs = target_procs_ggh
stage0 = cp_ggh
target_procs = target_procs_ggh_ac
elif opt.group == "qqh":
stage0 = stage0_qqh
target_procs = target_procs_qqh
stage0 = cp_qqh
target_procs = target_procs_qqh_ac
elif opt.group == "vh":
stage0 = stage0_vh
target_procs = target_procs_vh
stage0 = cp_vh
target_procs = target_procs_vh_ac
elif opt.group == "top":
stage0 = stage0_top
target_procs = target_procs_top
elif opt.group == "qqh_ac":
stage0 = cp_vbf
target_procs = target_procs_qqh_ac
stage0 = cp_top
target_procs = target_procs_top_ac
else:
print " --> [ERROR] target group of categories %s does not exist"%opt.group
leave()
Expand All @@ -204,7 +276,7 @@ def LoadTranslations(jsonfilename):
print " --> [ERROR] Input directory with pickle files does not exist. Leaving"
leave()
yfiles = glob.glob("%s/*.pkl" % opt.inputPklDir)
data = pd.concat([pd.read_pickle(f) for f in yfiles])
data = pd.concat([pd.read_pickle(f) for f in yfiles],sort=False)
#with open( opt.inputPkl, "rb" ) as fin: data = pickle.load(fin)

# Load cat info dataframe
Expand Down Expand Up @@ -254,6 +326,7 @@ def LoadTranslations(jsonfilename):
# Make table
nColumns = 4+len(stage0.keys())
foutname = "Tables/yields_table_lite_%s%s.txt"%(opt.group,opt.ext)
if not os.path.isdir('Tables'): os.system("mkdir Tables")
fout = open(foutname,"w")
fout.write("\\begin{tabular}{%s}\n"%("l|"+("c"*(nColumns-1))))
#fout.write(" \\hline \\hline \n")
Expand Down
65 changes: 52 additions & 13 deletions Plots/run_sequence.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,55 @@
# prefit (all mu=1)
python makeSplusBModelPlot.py --inputWSFile ../Combine/Datacard_sm_mu_simple.root --cats VBFTag_1,VBFTag_3,VBFTag_5,VBFTag_6,VBFTag_7 --doZeroes --pdir plots/2022-08-31-fits --ext _test --translateCats cats.json --unblind
STEP=0
usage(){
echo "Script to run fits and plots of fit output."
echo "options:"

echo "-h|--help) "
echo "-s|--step) "
echo "-d|--dryRun) "
}
# options may be followed by one colon to indicate they have a required argument
if ! options=$(getopt -u -o s:hd -l help,step:,dryRun -- "$@")
then
# something went wrong, getopt will put out an error message for us
exit 1
fi
set -- $options
while [ $# -gt 0 ]
do
case $1 in
-h|--help) usage; exit 0;;
-s|--step) STEP=$2; shift ;;
-d|--dryRun) DR=$2; shift ;;
(--) shift; break;;
(-*) usage; echo "$0: error - unrecognized option $1" 1>&2; usage >> /dev/stderr; exit 1;;
(*) break;;
esac
shift
done

# postfit
python makeSplusBModelPlot.py --inputWSFile plots/2022-08-31-fits/sm_mu_simple/bestfit_syst_r_VBF.root --loadSnapshot MultiDimFit --cats VBFTag_1,VBFTag_3,VBFTag_5,VBFTag_6,VBFTag_7 --doZeroes --pdir plots/2022-08-31-fits --ext _test --translateCats cats.json --unblind
bestfit="../Combine/runFitsxsec_xsec_savedWS/higgsCombine_bestfit_syst_obs_xsec_r_ggH.MultiDimFit.mH125.root"
yields="../Datacard/yields_2023-03-02_xsec"

# get category weights
python getCatInfo.py --inputWSFile ../Combine/Datacard_sm_mu_simple.root --cats all --doBkgRenormalization --saveCatInfo --ext _allCats
if [[ $STEP == "spb" ]]; then
python makeSplusBModelPlot.py --inputWSFile $bestfit --loadSnapshot MultiDimFit --cats all --doZeroes --pdir . --ext _test --unblind
elif [[ $STEP == "catweights" ]]; then
python getCatInfo.py --inputWSFile $bestfit --cats all --doBkgRenormalization --saveCatInfo --ext _allCats
elif [[ $STEP == "bands" ]]; then
python makeToys.py --inputWSFile $bestfit --loadSnapshot MultiDimFit --nToys 500 --POIs r_ggH,r_VBF,r_top,r_VH --batch Rome --queue cmsan --ext _test_with_bands
elif [[ $STEP == "spb2-calc" ]]; then
# first time, with bands calculation
python makeSplusBModelPlot.py --inputWSFile $bestfit --loadSnapshot MultiDimFit --cats all --doZeroes --pdir . --ext _test_with_bands --unblind --doBands --saveToyYields --doSumCategories --doCatWeights --saveWeights
elif [[ $STEP == "spb2" ]]; then
# next times, when toys are merged
python makeSplusBModelPlot.py --inputWSFile $bestfit --loadSnapshot MultiDimFit --cats all --doZeroes --pdir . --ext _test_with_bands --unblind --doBands --loadToyYields SplusBModels_test_with_bands/toys/toyYields_CMS_hgg_mass.pkl --doSumCategories --doCatWeights --saveWeights
elif [[ $STEP == "tables" ]]; then
# make tables with yields
groups=("ggh" "qqh" "vh" "top")
for group in ${groups[*]}
do
python makeYieldsTables.py --inputPklDir $yields --loadCatInfo pkl/catInfo_allCats.pkl --group $group
done
else
echo "Step $STEP is not one among yields,datacard,links. Exiting."
fi

# make bands with toys
python makeToys.py --inputWSFile plots/2022-08-31-fits/sm_mu_simple/bestfit_syst_r_VBF.root --loadSnapshot MultiDimFit --nToys 500 --POIs r_ggH,r_VBF,r_top,r_VH --batch condor --queue workday --ext _test_with_bands
python makeSplusBModelPlot.py --inputWSFile plots/2022-08-31-fits/sm_mu_simple/bestfit_syst_r_VBF.root --loadSnapshot MultiDimFit --cats all --doZeroes --pdir plots/2022-08-31-fits --ext _test_with_bands --translateCats cats.json --unblind --doBands --saveToyYields --doSumCategories --doCatWeights --saveWeights # first time, with bands calculation
python makeSplusBModelPlot.py --inputWSFile plots/2022-08-31-fits/sm_mu_simple/bestfit_syst_r_VBF.root --loadSnapshot MultiDimFit --cats all --doZeroes --pdir plots/2022-08-31-fits --ext _test_with_bands --translateCats cats.json --unblind --doBands --loadToyYields SplusBModels_test_with_bands/toys/toyYields_CMS_hgg_mass.pkl --doSumCategories --doCatWeights --saveWeights

# make tables with yields
python makeYieldsTables.py --inputPklDir ../Datacard/yields_2022-09-01_xsec --loadCatInfo pkl/catInfo_allCats.pkl --group qqh_ac --translateCats cats.json

0 comments on commit 33a2710

Please sign in to comment.