8source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
11set_variable: NUISANCE ASTRONOMY_NUISANCE fixed fixed
12set_variable: FORMAT GRAPHICS_FORMAT gif
13set_variable+ BATCH GRAPHICS_BATCH -B
16 usage "$script <signal histogram> <background histogram> <number of tests> <probability>"\
17 "\nThe histograms correspond to \"<file name>:<histogram name>\"."
21 fatal "Wrong number of arguments."
24set_variable HS $argv[1]
25set_variable HB $argv[2]
26let "NUMBER_OF_TESTS = $argv[3]"
27let "PROBABILITY = $argv[4]"
29if (( $PROBABILITY <= 0.0 || $PROBABILITY >= 1.0 )); then
30 fatal "Invalid probability $PROBABILITY"
33if (( $NUMBER_OF_TESTS * $PROBABILITY <= 1.0 )); then
34 warning "Insufficient number of tests $NUMBER_OF_TESTS given probability $PROBABILITY."
41let "N = 0" # zero signal
43$JPP_DIR/examples/JAstronomy/JPseudoExperiment \
44 -o benchmark\[$N\].root \
51 -d $DEBUG --! >& benchmark.$N.log
55awk '/Minimal likelihood ratio:/ { print $(NF - 1) }' benchmark.$N.log | read LIKELIHOOD_RATIO
57printf "Minimal likelihood ratio: %9.5f\n" $LIKELIHOOD_RATIO
63 -f benchmark\[$N\].root:hl \
64 -x "$LIKELIHOOD_RATIO 1.0e99" \
67JPrintResult -f benchmark\[$N\].root:hl -F GetSumOfWeights | read Y0
68JPrintResult -f zoom\[$N\].root:hl -F GetSumOfWeights | read Y1
70printf "Check of probability: %12.3e %12.3e\n" $PROBABILITY $(($Y1 / $Y0))
75let "NUMBER_OF_TESTS = 100000"
82for (( ; 1 ; )); do # lower limit
84 $JPP_DIR/examples/JAstronomy/JPseudoExperiment \
89 -Q $LIKELIHOOD_RATIO \
90 -d $DEBUG >& benchmark.log
92 awk '/Maximal probability:/ { print $(NF - 1) }' benchmark.log | read PROBABILITY
94 printf "lower limit: %9.5f -> P = %9.5f\n" $XMIN $PROBABILITY
96 if (( $PROBABILITY > $QUANTILE )); then
104for (( ; 1 ; )); do # upper limit
106 $JPP_DIR/examples/JAstronomy/JPseudoExperiment \
109 -n $NUMBER_OF_TESTS \
111 -Q $LIKELIHOOD_RATIO \
112 -d $DEBUG >& benchmark.log
114 awk '/Maximal probability:/ { print $(NF - 1) }' benchmark.log | read PROBABILITY
116 printf "upper limit: %9.5f -> P = %9.5f\n" $XMAX $PROBABILITY
118 if (( $PROBABILITY < $QUANTILE )); then
126for (( ; $XMAX - $XMIN > $EPS; )); do
128 let "X = 0.5 * ($XMIN + $XMAX)"
130 $JPP_DIR/examples/JAstronomy/JPseudoExperiment \
133 -n $NUMBER_OF_TESTS \
135 -Q $LIKELIHOOD_RATIO \
136 -d $DEBUG >& benchmark.log
140 awk '/Maximal probability:/ { print $(NF - 1) }' benchmark.log | read PROBABILITY
142 printf "search: %9.5f <= %9.5f <= %9.5f -> P = %9.5f\n" $XMIN $X $XMAX $PROBABILITY
144 if (( $PROBABILITY < $QUANTILE )); then
151let "X = 0.5 * ($XMIN + $XMAX)"
153$JPP_DIR/examples/JAstronomy/JPseudoExperiment \
156 -n $NUMBER_OF_TESTS \
160 -d $DEBUG >& benchmark.log
162printf "signal: %9.5f\n" $X