1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # The data is expected to be found in /data/raw and data/callisto
|
---|
4 | DATA="/data"
|
---|
5 | CALLISTO=callisto
|
---|
6 | # The .success file in /data/star will be resetted
|
---|
7 | STAR=star
|
---|
8 | # Directory to Mars environment (usually Mars/build)
|
---|
9 | MARS=~/Mars/build
|
---|
10 | # Relative path to macros
|
---|
11 | MACROS=../hawc/processing
|
---|
12 |
|
---|
13 | DATNIGHT=$1
|
---|
14 | DATRUNID=$2
|
---|
15 |
|
---|
16 | # Split both into year, month, day
|
---|
17 | DATYEAR=`echo ${DATNIGHT} | cut -c1-4`
|
---|
18 | DATMONTH=`echo ${DATNIGHT} | cut -c5-6`
|
---|
19 | DATDAY=`echo ${DATNIGHT} | cut -c7-8`
|
---|
20 |
|
---|
21 | DRSYEAR=`echo ${DRSNIGHT} | cut -c1-4`
|
---|
22 | DRSMONTH=`echo ${DRSNIGHT} | cut -c5-6`
|
---|
23 | DRSDAY=`echo ${DRSNIGHT} | cut -c7-8`
|
---|
24 |
|
---|
25 | # Formatting of the file paths and names
|
---|
26 | DATPATH="${DATYEAR}/${DATMONTH}/${DATDAY}"
|
---|
27 | DRSPATH="${DRSYEAR}/${DRSMONTH}/${DRSDAY}"
|
---|
28 |
|
---|
29 | PREFIX=`printf ${DATNIGHT}_%03d ${DATRUNID}`
|
---|
30 |
|
---|
31 | DATNAME=`printf ${DATNIGHT}_%03d.fits.fz ${DATRUNID}`
|
---|
32 | DRSNAME=`printf ${DRSNIGHT}_%03d.drs.fits ${DRSRUNID}`
|
---|
33 |
|
---|
34 | COUT=${DATA}/${CALLISTO}/${DATPATH}
|
---|
35 | SOUT=${DATA}/${STAR}/${DATPATH}
|
---|
36 |
|
---|
37 | echo ""
|
---|
38 | echo DAT=${DATNAME} [${DATPATH}]
|
---|
39 | echo DRS=${DRSNAME} [${DRSPATH}]
|
---|
40 |
|
---|
41 | # Check if not yet successfully processed
|
---|
42 | # Removing this file can be used to trigger a re-processing
|
---|
43 | # the next time this script is executed
|
---|
44 | if [ ! -f "${OUT}/.${PREFIX}.success" ]
|
---|
45 | then
|
---|
46 |
|
---|
47 | cd ${MARS}
|
---|
48 |
|
---|
49 | mkdir -p ${OUT}
|
---|
50 |
|
---|
51 | # Trigger reprocessing of the process-fils in the star directory
|
---|
52 | rm -f "${DATA}/${STAR}/${DATPATH}/.${PREFIX}.*"
|
---|
53 |
|
---|
54 | # Flag that a process is running
|
---|
55 | rm ${OUT}/.${PREFIX}.done
|
---|
56 | rm ${OUT}/.${PREFIX}.success
|
---|
57 |
|
---|
58 | touch ${OUT}/.${PREFIX}.running
|
---|
59 |
|
---|
60 | # Execute the calibration and write output to log-file
|
---|
61 | root -b -q -l ${MACROS}/callisto.C'("'${DATA}/raw/${DATPATH}/${DATNAME}'","'${DATA}/raw/${DRSPATH}/${DRSNAME}'","'${OUT}'")' \
|
---|
62 | 2>&1 | tee ${OUT}/${PREFIX}.log
|
---|
63 |
|
---|
64 | RC=${PIPESTATUS[0]}
|
---|
65 |
|
---|
66 | # Remember exit status of callisto
|
---|
67 | echo RC=${RC} | tee -a ${OUT}/${PREFIX}.log
|
---|
68 | echo ${RC} > ${OUT}/.${PREFIX}.done
|
---|
69 |
|
---|
70 | # Processing is finished
|
---|
71 | rm -f ${OUT}/.${PREFIX}.running
|
---|
72 |
|
---|
73 | # If processing was successfull write corresponding flag
|
---|
74 | if [ "${RC}" == "0" ]
|
---|
75 | then
|
---|
76 | touch ${OUT}/.${PREFIX}.success
|
---|
77 | fi
|
---|
78 |
|
---|
79 | cd -
|
---|
80 |
|
---|
81 | else
|
---|
82 | echo Skipped.
|
---|
83 | fi
|
---|
84 |
|
---|
85 | done
|
---|