8source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
11set_variable: NUISANCE ASTRONOMY_NUISANCE fixed fixed
12set_variable: SNR ASTRONOMY_SNR 0.0
13set_variable: M_SIZE ASTRONOMY_M_SIZE 10000
14set_variable: FORMAT GRAPHICS_FORMAT gif
15set_variable+ BATCH GRAPHICS_BATCH -B
18 usage "$script <signal histogram> <background histogram> <number of tests> <probability>"\
19 "\nThe histograms correspond to \"<file name>:<histogram name>\"."
23 fatal "Wrong number of arguments."
26set_variable HS $argv[1]
27set_variable HB $argv[2]
28let "NUMBER_OF_TESTS = $argv[3]"
29let "PROBABILITY = $argv[4]"
31if (( $PROBABILITY <= 0.0 || $PROBABILITY >= 1.0 )); then
32 fatal "Invalid probability $PROBABILITY"
35if (( $NUMBER_OF_TESTS * $PROBABILITY <= 1.0 )); then
36 warning "Insufficient number of tests $NUMBER_OF_TESTS given probability $PROBABILITY."
41# H0 pseudo experiments
43let "N = 0" # zero signal
47echo -n "Running H0 pseudo experiments... "
49$JPP_DIR/examples/JAstronomy/JPseudoExperiment \
50 -o benchmark\[$H0\].root \
60 -d $DEBUG >& benchmark.$H0.log
65awk '/Minimal likelihood ratio:/ { print $(NF - 1) }' benchmark.$H0.log | read LIKELIHOOD_RATIO
67printf "Minimal likelihood ratio: %9.5f\n" $LIKELIHOOD_RATIO
70# H1 pseudo experiments
72let "NUMBER_OF_TESTS = 100000"
75$JPP_DIR/examples/JAstronomy/JPseudoExperiment \
81 -Q $LIKELIHOOD_RATIO \
86 -d $DEBUG >& benchmark.log
88awk '/Signal strength:/ { print $NF }' benchmark.log | read X
90printf "signal: %9.5f\n" $X
92printf "%1.1f" $X | read H1
94$JPP_DIR/examples/JAstronomy/JPseudoExperiment \
95 -o benchmark\[$H1\].root \
104 -d $DEBUG >& benchmark.log
114 typeset -A HYPOTHESES
116 HYPOTHESES[H0]=$PROBABILITY
117 HYPOTHESES[H1]=$QUANTILE
119 for KEY VALUE in ${(kv)HYPOTHESES}; do
122 -f benchmark\[${(P)KEY}\].root:hl \
123 -x "$LIKELIHOOD_RATIO 1.0e99" \
126 JPrintResult -f benchmark\[${(P)KEY}\].root:hl -F GetSumOfWeights | read Y0
127 JPrintResult -f zoom.root:hl -F GetSumOfWeights | read Y1
129 printf "Hypothesis %s - check probability: %10.3e == %10.3e\n" $KEY $VALUE $(($Y1 / $Y0))
138let "X1 = $LIKELIHOOD_RATIO"
139let "X2 = $LIKELIHOOD_RATIO"
141let "Y2 = $(JPrintResult -f benchmark\[$N\].root:hl -F GetMaximum)"
143JLine -p "$X1 $Y1 $X2 $Y2" -@ "style = 2" -o line.root
146 -f benchmark\[$H0\].root:hl \
147 -f benchmark\[$H1\].root:hl \
150 -> "likelihood ratio" \
151 -\^ "number of experiments" \
155 -o discovery.$FORMAT $BATCH