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

Last change on this file since 20029 was 20028, checked in by tbretz, 4 years ago
Changed execution bit.
File size: 2.2 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# output is written to data/star
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
20FROM
21 Calibration_new
22ORDER BY
23 NIGHT, RUNID\
24"\
25 | mysql \
26 --defaults-file=/home/tbretz/data/.password.cnf \
27 --user=iceactwrite \
28 --host=ihp-pc45.ethz.ch \
29 --database=iceactdata \
30 --skip-column-names \
31 --batch --raw \
32 --compress \
33 | \
34while IFS= read -r LINE
35do
36 # Get NIGHT and RUNID of all files
37 NIGHT=`echo "$LINE" | awk -F"\t" '{print $1}'`
38 RUNID=`echo "$LINE" | awk -F"\t" '{print $2}'`
39
40 # Split into year, month, day
41 YEAR=`echo ${NIGHT} | cut -c1-4`
42 MONTH=`echo ${NIGHT} | cut -c5-6`
43 DAY=`echo ${NIGHT} | cut -c7-8`
44
45 # Formatting of the file paths and names
46 DATPATH="${YEAR}/${MONTH}/${DAY}"
47
48 PREFIX=`printf ${NIGHT}_%03d ${RUNID}`
49
50 DATNAME=`printf ${PREFIX}_Y.root ${RUNID}`
51
52 OUT=${DATA}/${STAR}/${DATPATH}
53 IN=${DATA}/${CALLISTO}/${DATPATH}
54
55 echo ""
56 echo ${DATNAME}
57 echo ${IN} " => " ${OUT}
58
59 # Check if not yet successfully processed but sucessfully calibrated
60 if [[ -f "${IN}/.${PREFIX}.success" && ! -f "${IN}/.${PREFIX}.running" && ! -f "${OUT}/.${PREFIX}.success" ]]
61 then
62
63 cd ${MARS}
64
65 mkdir -p ${OUT}
66
67 # Flag that a process is running
68 rm -f ${OUT}/.${PREFIX}.done
69 rm -f ${OUT}/.${PREFIX}.success
70
71 touch ${OUT}/.${PREFIX}.running
72
73 # Execute image parameter calculation and write log-file
74 root -b -q -l ${MACROS}/star.C'("'${IN}/${DATNAME}'","'${OUT}'")' \
75 2>&1 | tee ${OUT}/${PREFIX}.log
76
77 # Remember exit status of callisto
78 RC=${PIPESTATUS[0]}
79
80 echo RC=${RC} | tee -a ${OUT}/${PREFIX}.log
81 echo ${RC} > ${OUT}/.${PREFIX}.done
82
83 # Flag that processing is finished
84 rm -f ${OUT}/.${PREFIX}.running
85
86 # If processing was successfull write coresponding flag
87 if [ "${RC}" == "0" ]
88 then
89 touch ${OUT}/.${PREFIX}.success
90 fi
91
92 cd -
93
94 else
95 echo Skipped.
96 fi
97
98done
Note: See TracBrowser for help on using the repository browser.