Jpp  19.1.0
the software that should make you happy
JTimesliceReprocessor.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 version=1.0
6 script=${0##*/}
7 
8 # ------------------------------------------------------------------------------------------
9 #
10 # Script to jointly run JRandomTimesliceWriter and JTimesliceProcessor.
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 1
22 set_variable WORKDIR ./
23 set_variable PIPE $WORKDIR/pipe.dat
24 set_variable OUTPUT_FILE $WORKDIR/timeslice.root
25 set_variable DETECTOR $JPP_DATA/km3net_reference.detx
26 set_variable TRIGGER $JPP_DATA/trigger_parameters_arca.txt
27 set_variable PMT_FILE $JPP_DATA/PMT_parameters.txt
28 set_variable: BACKGROUND_HZ RANDOMEVENT_BACKGROUND_HZ ${BACKGROUND_HZ:-0 600 60 6 0.6}
29 set_variable: NUMBER_OF_SLICES RANDOMEVENT_SLICES 10
30 set_variable: RECYCLING RANDOMEVENT_RECYCLING "0 0"
31 set_variable DAQ_TIMESLICE JDAQTimesliceL0
32 set_variable: SEED RANDOMEVENT_SEED 0
33 
34 if do_usage $*; then
35  usage "$script [detector file [pipe [output file [trigger file [PMT parameters file]]]]]"
36 fi
37 
38 case $# in
39  5) set_variable PMT_FILE $5;&
40  4) set_variable TRIGGER $4;&
41  3) set_variable OUTPUT_FILE $3;&
42  2) set_variable PIPE $2;&
43  1) set_variable DETECTOR $1;;
44 esac
45 
46 print_variable DETECTOR TRIGGER OUTPUT_FILE BACKGROUND_HZ PMT_FILE
47 check_input_file $DETECTOR $TRIGGER $PMT_FILE
48 check_output_file $OUTPUT_FILE
49 
50 rm -f $PIPE
51 mkfifo $PIPE
52 
53 if [[ -p $PIPE ]]; then
54 
55  timer_start
56 
57  ( JRandomTimesliceWriter \
58  -a ${DETECTOR} \
59  -o ${PIPE} \
60  -n ${NUMBER_OF_SLICES} \
61  -P ${PMT_FILE} \
62  -d ${DEBUG} \
63  -S ${SEED} \
64  -B "$BACKGROUND_HZ" \
65  -N "$RECYCLING" \
66  --! && for (( i = 0; $i != 10; ++i )); do; echo 'EOF' > $PIPE; usleep 100000; done && rm -f $PIPE ) &
67 
68  JTimesliceReprocessor \
69  -a ${DETECTOR} \
70  -f ${PIPE} \
71  -@ ${TRIGGER} \
72  -C ${DAQ_TIMESLICE} \
73  -o ${OUTPUT_FILE} \
74  -d ${DEBUG} \
75  --!
76 
77  rm -f $PIPE
78 
79  timer_stop
80  timer_print
81 
82  JPrintTree \
83  -f ${OUTPUT_FILE}
84 
85 else
86 
87  fatal "Error opening $PIPE."
88 fi
89