Jpp  master_rocky
the software that should make you happy
JDynamics.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 if [ -z $JPP_DIR ]; then
5  echo "Variable JPP_DIR undefined."
6  exit
7 fi
8 
9 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
10 
11 set_variable: DEBUG DYNAMICS_DEBUG 2
12 set_variable: WORKDIR DYNAMICS_WORKDIR ./
13 set_variable: PERIOD DYNAMICS_PERIOD 100 # range of runs per output file
14 set_variable: MARGIN DYNAMICS_MARGIN 5 # overlap of runs at edges between output files
15 set_variable RANGE 1-99999999
16 
17 if do_usage $*; then
18  usage "$script <archive> <detector identifier|detector file> <version> [run-run]"\
19  "\nAuxiliary script to process dynamical positions and orientations data."\
20  "\nThe static and dynamic data are stored in the archive with the given version."
21 fi
22 
23 case $# in
24  4) set_variable RANGE $argv[4];&
25  3) set_variable VERSION $argv[3];
26  set_variable DETECTOR $argv[2];
27  set_variable ARCHIVE $argv[1];;
28  *) fatal "Wrong number of arguments."
29 esac
30 
31 JCookie.sh
32 
33 CHECK_EXIT_CODE
34 
35 if [[ -f $DETECTOR ]]; then
36  eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
37 else
38  set_variable DETECTOR_ID `getDetector -D $DETECTOR -O int`
39  set_variable DETECTOR detector.datx
40 fi
41 
42 if [[ ! -f $DETECTOR ]]; then
43  fatal "Missing file $DETECTOR"\
44  "\nYou may want to execute archive-get-calibration.sh beforehand."
45 fi
46 
47 JAcoustics.sh $DETECTOR_ID
48 
49 CHECK_EXIT_CODE
50 
51 archive-put-calibration.sh $ARCHIVE $VERSION ./
52 
53 CHECK_EXIT_CODE
54 
55 RUNS=(`JRuns -D $DETECTOR_ID -F RUN -@ "RUN >= ${RANGE%%-*}" -@ "RUN <= ${RANGE##*-}" | sort -g`)
56 
57 for (( L = 1; $L <= ${#RUNS}; L += $PERIOD )); do
58 
59  let "R = $L + $PERIOD - 1"
60 
61  if (( $R > ${#RUNS} )); then
62  let "R = ${#RUNS}"
63  fi
64 
65  let "LS = $L - $MARGIN"
66  let "RS = $R + $MARGIN"
67 
68  if (( $LS < 1 )); then
69  let "LS = 1"
70  fi
71  if (( $RS > ${#RUNS} )); then
72  let "RS = ${#RUNS}"
73  fi
74 
75  echo "\n\nProcessing runs $RUNS[$L]-$RUNS[$R]\n"
76 
77 
78  set_variable TYPE positions
79  set_variable OUTPUT_FILE katoomba_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUNS[$L]}.root
80 
81  INPUT_FILES=()
82 
83  for (( i = $LS; $i <= $RS; i += 1 )); do
84 
85  set_variable INPUT_FILE KM3NeT_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUNS[$i]}_event.root
86 
87  if [[ ! -f $INPUT_FILE ]]; then
88  JAcousticsEventBuilder.sh $DETECTOR $RUNS[$i]
89  fi
90 
91  if [[ -f $INPUT_FILE ]]; then
92  INPUT_FILES+=($INPUT_FILE)
93  fi
94  done
95 
96  if [[ ! -f $OUTPUT_FILE ]]; then
97 
98  if (( ${#INPUT_FILES} != 0 )); then
99 
100  set_variable ACOUSTICS_STRIP
101 
102  JKatoomba.sh $DETECTOR $INPUT_FILES[*] $OUTPUT_FILE
103 
104  putFile.sh $OUTPUT_FILE $ARCHIVE $DETECTOR_ID $RUNS[$L] $RUNS[$R] $TYPE $VERSION
105 
106  else
107  error "No input files for $OUTPUT_FILE"
108  fi
109  fi
110 
111 
112  set_variable TYPE orientations
113  set_variable OUTPUT_FILE ballarat_${(l:8::0::0:)DETECTOR_ID}_${(l:8::0::0:)RUNS[$L]}.root
114 
115  if [[ ! -f $OUTPUT_FILE ]]; then
116 
117  JBallarat.sh $DETECTOR $RUNS[$LS,$RS] $OUTPUT_FILE
118 
119  putFile.sh $OUTPUT_FILE $ARCHIVE $DETECTOR_ID $RUNS[$L] $RUNS[$R] $TYPE $VERSION
120  fi
121 done
122