forked from KIT-CMS/MSSMvsSMRun2Legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_model-indep_with-ml-cats_limits_per_channel.sh
executable file
·206 lines (181 loc) · 8.44 KB
/
run_model-indep_with-ml-cats_limits_per_channel.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# based on https://github.com/KIT-CMS/MSSMvsSMRun2Legacy/tree/ntuple_processor
ulimit -s unlimited
TAG=$1
MODE=$2
CHANNEL=$3
ERA=$4
if [[ $TAG == "auto" ]]; then
TAG="${CHANNEL}_${ERA}_ind"
fi
if [[ $ERA == "2016" ]]; then
LUMI="36.3 fb^{-1} (2016, 13 TeV)"
elif [[ $ERA == "2017" ]]; then
LUMI="41.5 fb^{-1} (2017, 13 TeV)"
elif [[ $ERA == "2018" ]]; then
LUMI="59.7 fb^{-1} (2018, 13 TeV)"
fi
defaultdir=analysis/$TAG
analysis="bsm-model-indep"
sub_analysis="hSM-in-bg"
categorization="with-sm-ml"
sm_like_hists="bsm"
[[ ! -d ${defaultdir} ]] && mkdir -p ${defaultdir}
[[ ! -d ${defaultdir}/logs ]] && mkdir -p ${defaultdir}/logs
[[ ! -d ${defaultdir}/limits/condor ]] && mkdir -p ${defaultdir}/limits/condor
[[ ! -d ${defaultdir}/limits_ind/condor ]] && mkdir -p ${defaultdir}/limits_ind/condor
defaultdir=$(readlink -f analysis/$TAG)
datacarddir=${defaultdir}/datacards_${analysis}
taskname="${analysis}_${TAG}_1"
taskname2="${analysis}_${TAG}_2"
if [[ $MODE == "initial" ]]; then
############
# morphing
############
morph_parallel.py --output ${defaultdir}/datacards \
--analysis ${analysis} \
--sub-analysis ${sub_analysis} \
--categorization ${categorization} \
--sm-like-hists ${sm_like_hists} \
--eras 2016,2017,2018 \
--category-list ${CMSSW_BASE}/src/CombineHarvester/MSSMvsSMRun2Legacy/input/by_channel/sm_neuralnet_categories_$CHANNEL.txt \
--variable nnscore \
--sm-gg-fractions ${CMSSW_BASE}/src/CombineHarvester/MSSMvsSMRun2Legacy/data/higgs_pt_reweighting_fullRun2_v2.root \
--sm \
--parallel 10 2>&1 | tee -a ${defaultdir}/logs/morph_sm_log.txt
morph_parallel.py --output ${defaultdir}/datacards \
--analysis ${analysis} \
--sub-analysis ${sub_analysis} \
--categorization ${categorization} \
--sm-like-hists ${sm_like_hists} \
--eras 2016,2017,2018 \
--category-list ${CMSSW_BASE}/src/CombineHarvester/MSSMvsSMRun2Legacy/input/by_channel/mssm_signal_categories_$CHANNEL.txt \
--variable mt_tot_puppi \
--sm-gg-fractions ${CMSSW_BASE}/src/CombineHarvester/MSSMvsSMRun2Legacy/data/higgs_pt_reweighting_fullRun2_v2.root \
--parallel 10 2>&1 | tee -a ${defaultdir}/logs/morph_mssm_log.txt
############
# combining outputs
############
mkdir -p ${datacarddir}/combined/cmb/
rsync -av --progress ${datacarddir}/201?/htt_*/* ${datacarddir}/combined/cmb/ 2>&1 | tee -a ${defaultdir}/logs/copy_datacards.txt
mkdir -p ${datacarddir}/${ERA}/cmb/
rsync -av --progress ${datacarddir}/${ERA}/htt_*/* ${datacarddir}/${ERA}/cmb/ 2>&1 | tee -a ${defaultdir}/logs/copy_datacards_${ERA}.txt
mkdir -p ${datacarddir}/${ERA}/${CHANNEL}/
rsync -av --progress ${datacarddir}/${ERA}/htt_${CHANNEL}*/* ${datacarddir}/${ERA}/${CHANNEL}/
rsync -av --progress ${datacarddir}/${ERA}/htt_${CHANNEL}* ${datacarddir}/${ERA}/${CHANNEL}/
rsync -av --progress ${datacarddir}/${ERA}/restore_binning ${datacarddir}/${ERA}/${CHANNEL}/restore_binning
elif [[ $MODE == "ws" ]]; then
############
# workspace creation
############
combineTool.py -M T2W -o "ws.root" \
-P HiggsAnalysis.CombinedLimit.PhysicsModel:multiSignalModel \
--PO '"map=^.*/ggh_(i|t|b).?$:r_ggH[0,0,200]"' \
--PO '"map=^.*/bbh$:r_bbH[0,0,200]"' \
-i ${datacarddir}/${ERA}/${CHANNEL} \
-m 110 --parallel 4 | tee -a ${defaultdir}/logs/workspace_independent_${ERA}_${CHANNEL}.txt
# # Extract prefit shapes.
# prefit_postfit_shapes_parallel.py --datacard_pattern "output_mssm/201?/htt_*/combined.txt.cmb" \
# --workspace_name ws.root \
# --freeze_arguments "--freeze $FREEZE" \
# --output_name prefit_shapes_${FREEZE}.root
# --parallel $CORES
# hadd -f prefit_shapes_${FREEZE}.root output_mssm/201?/htt_*/prefit_shapes_${FREEZE}.root
############
# job setup creation
############
cd ${defaultdir}/limits_ind/condor
combineTool.py -m "60,80,100,120,125,130,140,160,180,200,250,300,350,400,450,500,600,700,800,900,1000,1200,1400,1600,1800,2000,2300,2600,2900,3200,3500" \
-M AsymptoticLimits \
--rAbsAcc 0 \
--rRelAcc 0.0005 \
--boundlist ${CMSSW_BASE}/src/CombineHarvester/MSSMvsSMRun2Legacy/input/mssm_boundaries.json \
--setParameters r_ggH=0,r_bbH=0 \
--redefineSignalPOIs r_bbH \
-d ${datacarddir}/${ERA}/${CHANNEL}/ws.root \
--there -n ".bbH" \
--job-mode condor \
--dry-run \
--task-name bbH_full_${ERA}_${CHANNEL} \
--X-rtd MINIMIZER_analytic \
--cminDefaultMinimizerStrategy 0 \
--cminDefaultMinimizerTolerance 0.01 \
-v 1 | tee -a ${defaultdir}/logs/job_setup_modelind_bbh_${ERA}_${CHANNEL}.txt
combineTool.py -m "60,80,100,120,125,130,140,160,180,200,250,300,350,400,450,500,600,700,800,900,1000,1200,1400,1600,1800,2000,2300,2600,2900,3200,3500" \
-M AsymptoticLimits \
--rAbsAcc 0 \
--rRelAcc 0.0005 \
--boundlist ${CMSSW_BASE}/src/CombineHarvester/MSSMvsSMRun2Legacy/input/mssm_boundaries.json \
--setParameters r_ggH=0,r_bbH=0 \
--redefineSignalPOIs r_ggH \
-d ${datacarddir}/${ERA}/${CHANNEL}/ws.root \
--there -n ".ggH" \
--job-mode condor \
--dry-run \
--task-name ggH_full_${ERA}_${CHANNEL} \
--X-rtd MINIMIZER_analytic \
--cminDefaultMinimizerStrategy 0 \
--cminDefaultMinimizerTolerance 0.01 \
-v 1 | tee -a ${defaultdir}/logs/job_setup_modelind_ggh_${ERA}_${CHANNEL}.txt
elif [[ $MODE == "submit" ]]; then
############
# job submission
############
cd ${defaultdir}/limits_ind/condor
condor_submit condor_bbH_full_${ERA}_${CHANNEL}.sub
condor_submit condor_ggH_full_${ERA}_${CHANNEL}.sub
elif [[ $MODE == "submit-local" ]]; then
############
# job submission
############
cp scripts/run_limits_locally.py ${defaultdir}/limits_ind/condor
cd ${defaultdir}/limits_ind/condor
python run_limits_locally.py --cores 27 --njobs 27 --taskname condor_bbH_full_${ERA}_${CHANNEL}.sh | tee -a ${defaultdir}/logs/fit_bbh_${ERA}_${CHANNEL}.txt
python run_limits_locally.py --cores 27 --njobs 27 --taskname condor_ggH_full_${ERA}_${CHANNEL}.sh | tee -a ${defaultdir}/logs/fit_ggh_${ERA}_${CHANNEL}.txt
elif [[ $MODE == "collect" ]]; then
for p in gg bb
do
combineTool.py -M CollectLimits ${datacarddir}/${ERA}/${CHANNEL}/higgsCombine.${p}H*.root \
--use-dirs \
-o ${datacarddir}/${ERA}/${CHANNEL}/mssm_${p}H_${ERA}_${CHANNEL}.json
done
elif [[ $MODE == "plot" ]]; then
for p in gg bb
do
plotMSSMLimits.py --cms-sub "Preliminary" \
--title-right="${CHANNEL} - ${LUMI}" \
--process "${p}#phi" \
--y-axis-min 0.0001 \
--y-axis-max 1000.0 \
--show exp,obs ${datacarddir}/${ERA}/${CHANNEL}/mssm_${p}H_${ERA}_${CHANNEL}_${CHANNEL}.json \
--output mssm_model-independent_${p}H_${ERA}_${CHANNEL} \
--logx \
--logy
mv mssm_model-independent_${p}H_${ERA}_${CHANNEL}.{png,pdf} ${defaultdir}/limits_ind
done
elif [[ $MODE == "prefit" ]]; then
FREEZE="MH=450,r_ggH=0.002,r_bbH=0.002"
prefit_postfit_shapes_parallel.py --datacard_pattern "analysis/mt_16_debug_independent/datacards_mssm/$ERA/$CHANNEL/combined.txt.cmb" \
--workspace_name ws.root \
--freeze_arguments "--freeze $FREEZE" \
--output_name prefit_shapes_${FREEZE}.root \
--parallel 1
hadd -f prefit_shapes_${FREEZE}.root output_mssm/201?/htt_*/prefit_shapes_${FREEZE}.root
elif [[ $MODE == "impacts" ]]; then
combineTool.py -M Impacts -d ${datacarddir}/${ERA}/${CHANNEL}/ws.root \
-m 125 \
--X-rtd MINIMIZER_analytic --cminDefaultMinimizerStrategy 0 \
--doInitialFit --robustFit 1 \
-t -1 --setParameters r_ggH=0,r_bbH=0 \
--parallel 16
combineTool.py -M Impacts -d ${datacarddir}/${ERA}/${CHANNEL}/ws.root \
-m 125 \
--X-rtd MINIMIZER_analytic --cminDefaultMinimizerStrategy 0 \
--robustFit 1 --doFits \
-t -1 --setParameters r_ggH=0,r_bbH=0 \
--parallel 16
combineTool.py -M Impacts \
-d ${datacarddir}/${ERA}/${CHANNEL}/ws.root \
-m 125 \
-o ${ERA}_${CHANNEL}_impacts.json
plotImpacts.py -i ${ERA}_${CHANNEL}_impacts.json -o ${ERA}_${CHANNEL}_impacts
fi