source: trunk/Mars/hawc/processing/run-callisto.sh@ 20029

Last change on this file since 20029 was 20028, checked in by tbretz, 4 years ago
Changed execution bit.
File size: 2.8 KB
Line 
1#!/bin/bash
2
3# The data is expected to be found in /data/raw and data/callisto
4DATA="/data"
5CALLISTO=callisto
6# The .success file in /data/star will be resetted
7STAR=star
8# Directory to Mars environment (usually Mars/build)
9MARS=~/Mars/build
10# Relative path to macros
11MACROS=../hawc
12
13# Get all runs that can (and should) be calibrated
14# Pipe the output to mysql and read the
15# mysql output line-by-libe
16echo \
17"\
18SELECT
19 NIGHT, RUNID, DrsNight, DrsRunID
20FROM
21 Calibration
22ORDER BY
23 NIGHT, RUNID\
24"\
25 | mysql \
26 --defaults-file=~/.password.cnf \
27 --user=hawcwrite \
28 --host=ihp-pc45.ethz.ch \
29 --database=hawcdata \
30 --skip-column-names \
31 --batch --raw \
32 --compress \
33 | \
34while IFS= read -r LINE
35do
36
37 # Extract night/runid for data file and calibration file
38 DATNIGHT=`echo "$LINE" | awk -F"\t" '{print $1}'`
39 DATRUNID=`echo "$LINE" | awk -F"\t" '{print $2}'`
40 DRSNIGHT=`echo "$LINE" | awk -F"\t" '{print $3}'`
41 DRSRUNID=`echo "$LINE" | awk -F"\t" '{print $4}'`
42
43 # Split both into year, month, day
44 DATYEAR=`echo ${DATNIGHT} | cut -c1-4`
45 DATMONTH=`echo ${DATNIGHT} | cut -c5-6`
46 DATDAY=`echo ${DATNIGHT} | cut -c7-8`
47
48 DRSYEAR=`echo ${DRSNIGHT} | cut -c1-4`
49 DRSMONTH=`echo ${DRSNIGHT} | cut -c5-6`
50 DRSDAY=`echo ${DRSNIGHT} | cut -c7-8`
51
52 # Formatting of the file paths and names
53 DATPATH="${DATYEAR}/${DATMONTH}/${DATDAY}"
54 DRSPATH="${DRSYEAR}/${DRSMONTH}/${DRSDAY}"
55
56 PREFIX=`printf ${DATNIGHT}_%03d ${DATRUNID}`
57
58 DATNAME=`printf ${DATNIGHT}_%03d.fits.fz ${DATRUNID}`
59 DRSNAME=`printf ${DRSNIGHT}_%03d.drs.fits ${DRSRUNID}`
60
61 OUT=${DATA}/${CALLISTO}/${DATPATH}
62
63 echo ""
64 echo DAT=${DATNAME} [${DATPATH}]
65 echo DRS=${DRSNAME} [${DRSPATH}]
66
67 # Check if not yet successfully processed
68 # Removing this file can be used to trigger a re-processing
69 # the next time this script is executed
70 if [ ! -f "${OUT}/.${PREFIX}.success" ]
71 then
72
73 cd ${MARS}
74
75 mkdir -p ${OUT}
76
77 # Trigger reprocessing of the process-fils in the star directory
78 rm -f "${DATA}/${STAR}/${DATPATH}/.${PREFIX}.*"
79
80 # Flag that a process is running
81 rm ${OUT}/.${PREFIX}.done
82 rm ${OUT}/.${PREFIX}.success
83
84 touch ${OUT}/.${PREFIX}.running
85
86 # Execute the calibration and write output to log-file
87 root -b -q -l ${MACROS}/callisto.C'("'${DATA}/raw/${DATPATH}/${DATNAME}'","'${DATA}/raw/${DRSPATH}/${DRSNAME}'","'${OUT}'")' \
88 2>&1 | tee ${OUT}/${PREFIX}.log
89
90 RC=${PIPESTATUS[0]}
91
92 # Remember exit status of callisto
93 echo RC=${RC} | tee -a ${OUT}/${PREFIX}.log
94 echo ${RC} > ${OUT}/.${PREFIX}.done
95
96 # Processing is finished
97 rm -f ${OUT}/.${PREFIX}.running
98
99 # If processing was successfull write corresponding flag
100 if [ "${RC}" == "0" ]
101 then
102 touch ${OUT}/.${PREFIX}.success
103 fi
104
105 cd -
106
107 else
108 echo Skipped.
109 fi
110
111done
Note: See TracBrowser for help on using the repository browser.