-
Notifications
You must be signed in to change notification settings - Fork 2
/
doDatacards_bias.sh
78 lines (69 loc) · 2.69 KB
/
doDatacards_bias.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
mass=$1
cards=""
function=$2
range=$3
background="_${function}_${range}"
dirName="PreselectedWithRegressionDeepCSV/MMRSelection_chi2/fit_bias/MMR_${mass}${background}"
dcardName="datacard_${mass}${background}.txt"
bgLogName="data_bkg.log"
Type="Split"
datacardtype="f_${function}"
data_file="w_background_${function}_${range}.root"
pdfLogName="pdf.log"
sigLogName="signal"${mass}"_sig.log"
sig_norm=`grep 'norm =' ${dirName}/${sigLogName}| awk '{print $3/50}'`
jec_norm=`grep 'JEC lnN' ${dirName}/${sigLogName} | awk '{print $3}'`
jer_norm=`grep 'JER lnN' ${dirName}/${sigLogName} | awk '{print $3}'`
btag_norm=`grep 'btag lnN' ${dirName}/${sigLogName} | awk '{print $3}'`
pdf_norm=`grep 'PDF lnN' ${dirName}/${pdfLogName} | awk '{print $3}'`
bkg_norm=`grep ' Background number of '${function}_${range}' = ' ${dirName}/${bgLogName} | awk '{print $6}'`
if [ $4 -eq 1 ];
then
case "$mass" in
550) bias=-0.1081;; 600) bias=0.1244;; 650) bias=0.1698;; 750) bias=-0.2380;; 800) bias=-0.1523;; 900) bias=-0.0907;; 1000) bias=0.0297;;
esac
else
case "$mass" in
550) bias=-0.0396;; 600) bias=0.095;; 650) bias=0.1535;; 750) bias=-0.1249;; 800) bias=-0.1706;; 900) bias=-0.1212;; 1000) bias=0.0359;;
esac
fi
echo "bias" ${bias}
echo sig_norm ${sig_norm}
echo JEC ${jec_norm}
echo JER ${jer_norm}
echo bTag ${btag_norm}
echo PDF ${pdf_norm}
echo bkg_norm ${bkg_norm}
#let's build a datacard!
cat > ${dirName}/${dcardName} <<EOF
imax 1 number of channels
jmax * number of backgrounds
kmax * number of systematic uncertainty sources
----------
shapes signal HbbHbb w_signal_${mass}.root HbbHbb:signal_fixed
shapes signal_bkg HbbHbb w_signal_${mass}.root HbbHbb:signal_bkg
shapes background HbbHbb $data_file HbbHbb:$datacardtype
shapes data_obs HbbHbb $data_file HbbHbb:data_obs$background
----------
## Observation
bin HbbHbb
observation -1
----------
bin HbbHbb HbbHbb HbbHbb
process signal background signal_bkg
process 0 1 2
rate ${sig_norm} ${bkg_norm} ${sig_norm}
lumi_13TeV lnN 1.026 - -
bTag lnN ${btag_norm} - -
JER lnN ${jer_norm} - -
JEC lnN ${jec_norm} - -
trigger lnN 1.10 - -
PDF lnN ${pdf_norm} - -
shapeBkg_signal_bkg_HbbHbb__norm param 0.0 ${bias}
EOF
#bkg_norm rateParam HbbHbb 1 ${bkg_norm}
#now add the systematics to the card
grep 'sg_' ${dirName}/${sigLogName} | grep ' param ' >> ${dirName}/${dcardName}
grep 'par_'${function}'_' ${dirName}/${bgLogName} | grep ' param ' >> ${dirName}/${dcardName}
cards+="${dirName}/${dcardName} "
echo $cards