-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine.sh
executable file
·149 lines (120 loc) · 4.63 KB
/
combine.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
set -Eeuo pipefail
# set -x
usage () {
printf -- "Usage:\n\t-l\tMinimiser type\n\t-a\tMinimiser algorithm\n\t-s\tMinimiser strategy\n\t-t\tToys\n\t-S\tSeed\n"
}
t2w () {
text2workspace.py "${@}"
}
combine () {
combineTool.py --cminDefaultMinimizerStrategy="${strategy}" --cminDefaultMinimizerType="${minlib}" --cminDefaultMinimizerAlgo="${algo}" --expectSignal=1.0 --toys "${toys}" --mass 120 --seed "${seed}" "${@}"
}
significance () {
combine -M Significance -d ${era}/datacards/datacard_"${1}".root --bruteForce --setBruteForceTypeAndAlgo $minlib,$algo --uncapped 1 --name "_${1}" --plot out/${era}/loglikelihood_"${1}".png
}
signal () {
combine -M FitDiagnostics -d ${era}/datacards/datacard_"${1}".root --robustFit=1 --setRobustFitAlgo=$minlib,$algo --setRobustFitStrategy=$strategy --rMin -15 --out out/${era} --name "_${1}" --plots --saveShapes --saveWithUncertainties # --ignoreCovWarning
}
shapes () {
PostFitShapesFromWorkspace -w ${era}/datacards/datacard_"${1}".root -o out/${era}/shapes_"${1}".root -m 120 --postfit --print --covariance --sampling -f out/${era}/fitDiagnostics_"${1}".root:fit_s > logs/postfitshapes_"${1}".log
}
impacts () {
combine -M Impacts -d ${era}/datacards/datacard_"${1}".root --rMin -5 --doInitialFit --robustFit=1 --setRobustFitAlgo=$minlib,$algo --setRobustFitStrategy=$strategy --name "${1}" > logs/impacts_"${1}".log 2>&1
rename "${seed}." '' higgsCombine_initialFit_"${1}"*
combine -M Impacts -d ${era}/datacards/datacard_"${1}".root --rMin -5 --doFits --parallel $(nproc) --robustFit=1 --setRobustFitAlgo=$minlib,$algo --setRobustFitStrategy=$strategy --name "${1}" >> logs/impacts_"${1}".log 2>&1
rename "${seed}." '' higgsCombine_paramFit_"${1}"*
combine -M Impacts -d ${era}/datacards/datacard_"${1}".root --rMin -5 --robustFit=1 --setRobustFitAlgo=$minlib,$algo --setRobustFitStrategy=$strategy -o out/${era}/impacts_"${1}".json --name "${1}" >> logs/impacts_"${1}".log 2>&1
# Before making the plot remove all nuisance parameters from statistical
# uncertainties
python stat_remover.py out/${era}/impacts_"${1}".json
plotImpacts.py -i out/${era}/impacts_"${1}".json -o out/${era}/impacts_"${1}" --translate ${era}/json/thesis.json --per-page 50 --label-size 0.03
}
# Defaults
minlib="Minuit2"
algo="Migrad"
strategy=1
toys=-1
seed=777
era=2017
while getopts "l:a:e:s:S:t:h" OPTION; do
case "${OPTION}" in
l)
minlib="${OPTARG}"
;;
a)
algo="${OPTARG}"
;;
e)
era="${OPTARG}"
;;
s)
strategy="${OPTARG}"
;;
S)
seed="${OPTARG}"
;;
t)
toys="${OPTARG}"
;;
h)
usage
exit 0
;;
?)
usage
exit 1
;;
esac
done
shift "$((${OPTIND} -2))"
printf "\e[1m!===SETUP===!\e[0m\n"
mkdir -p logs out/${era}
rm -f higgsCombine* out/${era}/* ${era}/datacards/datacard*.root ${era}/datacards/datacard_combined.txt logs/*.log
printf "\e[1m!== Creating workspaces ==!\e[0m\n"
# Create workspaces
t2w ${era}/datacards/datacard_ee.txt > logs/text2workspace_datacard_ee.log
t2w ${era}/datacards/datacard_mumu.txt > logs/text2workspace_datacard_mumu.log
printf "\e[1m!== Combining Datacards ==!\e[0m\n"
# Combine datacards
pushd ${era}/datacards/
combineCards.py MVA_ee=datacard_ee.txt MVA_mumu=datacard_mumu.txt > datacard_combined.txt
popd
t2w ${era}/datacards/datacard_combined.txt > logs/text2workspace_datacard.log
printf "\n"
printf "\e[1m!===CALCULATING SIGNIFICANCES===!\e[0m\n"
printf "\e[1m!== ee SIGNIFICANCE==!\e[0m\n"
significance ee
printf "\n\e[1m!== μμ SIGNIFICANCE==!\e[0m\n"
significance mumu
printf "\n\e[1m!== COMBINED SIGNIFICANCE==!\e[0m\n"
significance combined
printf "\n"
printf "\e[1m!===CALCULATING SIGNAL STRENGTHS===!\e[0m\n"
printf "\e[1m!== ee SIGNAL STRENGTH==!\e[0m\n"
signal ee
printf "\n\e[1m!== μμ SIGNAL STRENGTH==!\e[0m\n"
signal mumu
printf "\n\e[1m!== COMBINED SIGNAL STRENGTH==!\e[0m\n"
signal combined
if [ "${toys}" -gt 1 ]
then
exit 0;
fi
printf "\n\e[1m!===CREATING POST-FIT SHAPES===!\e[0m\n"
printf "\e[1m!== ee ==!\e[0m\n"
shapes ee
printf "\e[1m!== μμ ==!\e[0m\n"
shapes mumu
printf "\e[1m!== COMBINED ==!\e[0m\n"
shapes combined
printf "\n"
printf "\e[1m!===CREATING POST-FIT IMPACT PLOTS===!\e[0m\n"
printf "\e[1m!== ee ==!\e[0m\n"
impacts ee
printf "\n\e[1m!== μμ ==!\e[0m\n"
impacts mumu
printf "\n\e[1m!== COMBINED ==!\e[0m\n"
impacts combined
# printf "\e[1m!===CREATING STACKPLOTS===!\e[0m\n"
# ./stackplots.py out/${era}/shapes_combined.root out/${era}/