Jpp 19.3.0
the software that should make you happy
Loading...
Searching...
No Matches
JMorphology+background.sh
Go to the documentation of this file.
1#!/bin/env zsh
2script=${0##*/}
3
4if [ -z $JPP_DIR ]; then
5 echo "Variable JPP_DIR undefined."
6 exit
7fi
8
9source $JPP_DIR/setenv.sh $JPP_DIR
10
11zmodload zsh/mathfunc
12
13set_variable DIR $JPP_DIR/examples/JAstronomy
14set_variable DEBUG 2
15set_variable LOCATION_DEG -39.77 -101.72
16set_variable NUMBER_OF_EVENTS 35
17set_variable NUMBER_OF_SIGMAS 2.0
18set_variable BACKGROUND 50000 # number of events per year
19set_variable OMEGA 2.0e-5 # solid angle
20set_variable: FORMAT GRAPHICS_FORMAT gif
21set_variable+ BATCH GRAPHICS_BATCH -B
22
23if do_usage $*; then
24 usage "$script"
25fi
26
27UTC=(2025-01-01T00:00:00Z 2035-01-01T00:00:00Z)
28
29MORPHOLOGY_DEG=0.0
30RESOLUTION_DEG=0.4
31
32let "R = (1.0 * $BACKGROUND) / (365.0 * 24.0 * 60.0 * 60.0) / (2.0 * $PI)"
33
34XMIN=-3.5
35XMAX=+3.5
36YMIN=-3.5
37YMAX=+3.5
38
39$DIR/JMorphology \
40 -@ "ct = -0.1 +1.0" \
41 -o source+background.root \
42 -U "$UTC[*]" \
43 -n $NUMBER_OF_EVENTS \
44 -r "Gauss $RESOLUTION_DEG" \
45 -x "200 $XMIN $XMAX" \
46 -y "200 $YMIN $YMAX" \
47 -M "Point $LOCATION_DEG" \
48 -B $R \
49 -O $OMEGA \
50 -d $DEBUG --!
51
52JPlot2D \
53 -f source+background.root:g1 \
54 -f source+background.root:g2 \
55 -> "#DeltaRA [deg]" \
56 -< "#DeltaDEC [deg]" \
57 -x "$XMIN $XMAX" \
58 -y "$YMIN $YMAX" \
59 -G XY \
60 -O COLZ \
61 -N "X 505" \
62 -N "Y 505" \
63 -S 0.4 \
64 -T "$NUMBER_OF_EVENTS" \
65 -o skymap+background.$FORMAT $BATCH
66
67JPrintRange1D -f source+background.root:h1 | read XMIN YMIN XMAX YMAX
68
69let "XS = cos($NUMBER_OF_SIGMAS * sqrt($RESOLUTION_DEG*$RESOLUTION_DEG + $MORPHOLOGY_DEG*$MORPHOLOGY_DEG) * $PI / 180.0)"
70
71JFit \
72 -f source+background.root:h1 \
73 -o fit.root \
74 -x "$XMIN $XS" \
75 -F "exp([0])" \
76 -@ "p0 = $((log($YMIN + 0.5)))" \
77 -O L \
78 -d $DEBUG
79
80JPrintFit -f fit.root:\.\* -@ p0 | read -A BUFFER
81
82printf "Fitted background %7.3f +/- %7.3f\n" $((exp($BUFFER[1]))) $((exp($BUFFER[1]) * $BUFFER[2]))
83
84JPlot1D \
85 -f fit.root:h1 \
86 -> "cos(#alpha)" \
87 -\^ "number of events" \
88 -N "X 505" \
89 -T "$NUMBER_OF_EVENTS" \
90 -o source+background.$FORMAT $BATCH
91
92rm -f fit.root >& /dev/null