-
Notifications
You must be signed in to change notification settings - Fork 5
/
buildDatacards.sh
executable file
·80 lines (72 loc) · 2.93 KB
/
buildDatacards.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
#!/bin/bash
postfix=(
`cat inputs_to_process.txt`
)
mass=$1
echo "0.12+${mass}*0.07*0.001" | bc -l
btagSys=$(bc <<< "scale=3;1+0.12+${mass}*0.07*0.001")
echo $btagSys
antibtagSys=$(bc <<< "scale=3;1/${btagSys}")
echo $antibtagSys
cards=""
for name in ${postfix[@]}
do
echo building datacard for $name
dirName="info_${mass}_${name}"
dcardName="datacard_${mass}_${name}.txt"
bgLogName="data_${name}_bkg.log"
sig_norm=`grep 'norm =' ${dirName}/index.html | awk '{print $3}'`
bkg_norm=`grep ' Background number of events = ' ${dirName}/${bgLogName} | awk '{print $6}'`
#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 Vg w_signal_${mass}.root Vg:signal_fixed_${name}
shapes background Vg w_background_GaussExp.root Vg:bg_${name}
shapes data_obs Vg w_data.root Vg:data_obs
----------
## Observation
bin Vg
observation -1
----------
bin Vg Vg
process signal background
process 0 1
rate ${sig_norm} 1
cms_lumi_13TeV lnN 1.027 -
cms_btag_sf_13TeV lnN ${btagSys} -
cms_btag_sf_13TeV lnN ${antibtagSys} -
cms_JES_13TeV lnN 1.02 -
cms_phoHLT_13TeV lnN 1.02 -
cms_pho_sf_13TeV lnN 1.05 -
cms_pileup_13TeV lnN 1.01 -
cms_xzg_pdf_13TeV lnN 1.02 -
cms_xzg_scale_13TeV lnN 1.05 -
EOF
#now add the systematics to the card
#grep 'signal_' ${dirName}/index.html | awk '{print $1 " " $2 " " $3 " " $4}' >> ${dirName}/${dcardName}
#grep 'bias_term_' ${dirName}/${bgLogName} | grep ' param ' >> ${dirName}/${dcardName}
#grep 'bg_' ${dirName}/${bgLogName} | grep 'param' >> ${dirName}/${dcardName}
if [[ $dcardName == *"anti"* ]]
then
if [[ ${mass} -gt 3300 ]]
then
grep 'bias_term_' ${dirName}/${bgLogName} | grep ' param ' >> ${dirName}/${dcardName}
fi
sed -i 's/WHATKIND/Anti/' ${dirName}/${dcardName}
sed -i '/cms_btag_sf_13TeV.*'${btagSys}'.*/d' ${dirName}/${dcardName}
#grep 'bg_' ${dirName}/${bgLogName} | grep ' param ' >> ${dirName}/${dcardName}
else
if [[ ${mass} -gt 3800 ]]
then
grep 'bias_term_' ${dirName}/${bgLogName} | grep ' param ' >> ${dirName}/${dcardName}
fi
sed -i 's/WHATKIND//' ${dirName}/${dcardName}
sed -i '/cms_btag_sf_13TeV.*'${antibtagSys}'.*/d' ${dirName}/${dcardName}
#grep 'bg_' ${dirName}/${bgLogName} | grep 'param' >> ${dirName}/${dcardName}
fi
cards+="${dirName}/${dcardName} "
done
combineCards.py -S $cards > datacard_qqg_${mass}_combined.txt