Jpp
JSirene.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 # utility script for Sirene Monte Carlo.
6 script=${0##*/}
7 
8 # ------------------------------------------------------------------------------------------
9 #
10 # Example script to run JSirene.
11 #
12 # ------------------------------------------------------------------------------------------
13 
14 if [ -z $JPP_DIR ]; then
15  echo "Variable JPP_DIR undefined."
16  exit
17 fi
18 
19 source $JPP_DIR/setenv.sh $JPP_DIR
20 
21 set_variable DEBUG ${SIRENE_DEBUG:-1}
22 set_variable WORKDIR ./
23 set_variable CDF $JPP_DATA/I%p.dat
24 set_variable INPUT_FILE $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz
25 set_variable OUTPUT_FILE $WORKDIR/sirene.root
26 set_variable DETECTOR $JPP_DATA/km3net_reference.detx
27 set_variable KEEP ${SIRENE_KEEP+-k}
28 set_variable SEED ${SIRENE_SEED:-0}
29 set_variable FACTOR ${SIRENE_FACTOR:-1.0}
30 
31 if ( do_usage $* ); then
32  usage "$script [detector file [input file [output file [CDF file descriptor]]]]"\
33  "\nNote that if more than one input file is specified, all other arguments must be provided."
34 fi
35 
36 case $# in
37  4) set_variable CDF $4;&
38  3) set_variable OUTPUT_FILE $3;&
39  2) set_variable INPUT_FILE $2;&
40  1) set_variable DETECTOR $1;;
41  0) ;;
42  *) set_variable DETECTOR $1
43  set_variable INPUT_FILE $argv[2,-3]
44  set_variable OUTPUT_FILE $argv[-2]
45  set_variable CDF $argv[-1];;
46 esac
47 
48 # Sanity checks
49 
50 print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF
51 
52 for TYPE in 1 2 5 6 13 14; do
53  if [[ ! -f ${CDF/\%/${TYPE}} ]]; then
54  error "Missing CDF files."
55  error "Run: JMakePDF.sh"
56  JMakePDF.sh -h
57  exit
58  fi
59 done
60 
61 if [[ ! -f $DETECTOR ]]; then
62  error "Missing detector file."
63  error "Run: JDetector.sh"
64  JDetector.sh -h
65  exit
66 fi
67 
68 check_input_file $DETECTOR $INPUT_FILE
69 check_output_file $OUTPUT_FILE
70 
71 timer_start
72 
73 JSirene \
74  -F $CDF \
75  -a $DETECTOR \
76  -f $INPUT_FILE \
77  -o $OUTPUT_FILE \
78  -@ "Tmax_ns=2.0;" \
79  -U $FACTOR \
80  $KEEP \
81  -S $SEED \
82  -d $DEBUG --!
83 
84 timer_stop
85 timer_print
86 
87 JPrintMeta \
88  -f $OUTPUT_FILE
89 
90 JPrintSirene \
91  -f $OUTPUT_FILE
92 
93 JPrintTree \
94  -f $OUTPUT_FILE