-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompare-mocanlo-runs.sh
More file actions
executable file
·105 lines (85 loc) · 2.54 KB
/
compare-mocanlo-runs.sh
File metadata and controls
executable file
·105 lines (85 loc) · 2.54 KB
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
#!/bin/bash
set -euo pipefail
switch=0
lhs=()
rhs=()
while [[ $# -gt 0 ]]; do
case $1 in
--with)
switch=1
shift
;;
--*)
echo >&1 "error: unkown switch: '$1'"
exit 1
;;
*)
if [[ ${switch} -eq 0 ]]; then
lhs+=( "$1" )
else
rhs+=( "$1" )
fi
shift
;;
esac
done
function create_result_table() {
for dir in "$@"; do
awk 'NR == 26 { print $5, $7 }' "${dir}"/result/scale_factor_1/cross_section.dat
done
}
function matrix_elements() {
for dir in "$@"; do
xs_file="${dir}"/result/scale_factor_1/cross_section.dat
int_type=$(grep "Integration type" "${xs_file}" | awk '{ print $4 }')
case "${int_type}" in
born | virt | idip)
section=partonic_process
;;
real)
section=real_process
;;
*)
echo >&1 "error: unknown integration type: '${int_type}'"
exit 1
;;
esac
pp_file="${dir}"/data/init/user_input/user_input_partonic_process.dat
incoming=$(awk "/begin ${section}/,/end ${section}/" "${pp_file}" | grep incoming | \
awk '{ for (i = 3; i <= NF; ++i) { printf "%s ", $i }; printf "->" }')
awk "/begin ${section}/,/end ${section}/" "${pp_file}" | grep outgoing | \
awk "{ printf \"%s \", \"${incoming}\"; for (i = 3; i <= NF; ++i) { printf \"%s \", \$i }; printf \"(${dir})\\n\" }"
done
}
readarray -t mes < <(matrix_elements "${lhs[@]}")
echo "LHS = ${mes[0]}"
for me in "${mes[@]:1}"; do
echo " + ${me}"
done
readarray -t mes < <(matrix_elements "${rhs[@]}")
echo "RHS = ${mes[0]}"
for me in "${mes[@]:1}"; do
echo " + ${me}"
done
echo "---"
echo
create_result_table "${lhs[@]}" > lhs
create_result_table "${rhs[@]}" > rhs
Rscript - <<'EOF'
options(scipen=-2)
lhs <- read.table('lhs')
rhs <- read.table('rhs')
lhs_sum <- sum(lhs$V1)
lhs_unc <- sqrt(sum(lhs$V2^2))
rhs_sum <- sum(rhs$V1)
rhs_unc <- sqrt(sum(rhs$V2^2))
pull <- (rhs_sum-lhs_sum)/sqrt(rhs_unc^2+lhs_unc^2)
rel_diff <- (rhs_sum/lhs_sum-1)*100
cat("LHS [fb] : ", lhs_sum, "\n", sep = "")
cat("LHS unc. [fb] : ", lhs_unc, "\n", sep = "")
cat("RHS [fb] : ", rhs_sum, "\n", sep = "")
cat("RHS unc. [fb] : ", rhs_unc, "\n", sep = "")
cat("pull [σ] : ", pull, "\n", sep = "")
cat("rel. diff. [%] : ", rel_diff, "\n", sep = "")
EOF
rm lhs rhs