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

Last change on this file since 20031 was 20031, checked in by tbretz, 4 years ago
Included telescope id and the create query to the raw data extraction.
File size: 2.4 KB
Line 
1#!/bin/bash
2
3
4# Specify the telescope for which to run the script. Replace '1'
5# by $1 if the telesocpe number is supplied as an option to the script
6TELESCOPE=1
7
8# The data is expected to be found in /data/raw and data/callisto
9DATA="/data"
10CALLISTO=callisto
11# output is written to data/star
12STAR=star
13# Directory to Mars environment (usually Mars/build)
14MARS=~/Mars/build
15# Relative path to macros
16MACROS=../hawc
17
18# Get all runs that can (and should) be calibrated
19# Pipe the output to mysql and read the
20# mysql output line-by-libe
21echo \
22"\
23SELECT
24 NIGHT, RUNID
25FROM
26 Calibration
27WHERE
28 Telescope=${TELESCOPE}
29ORDER BY
30 NIGHT, RUNID\
31"\
32 | mysql \
33 --defaults-file=/home/tbretz/data/.password.cnf \
34 --user=iceactwrite \
35 --host=ihp-pc45.ethz.ch \
36 --database=iceactdata \
37 --skip-column-names \
38 --batch --raw \
39 --compress \
40 | \
41while IFS= read -r LINE
42do
43 # Get NIGHT and RUNID of all files
44 NIGHT=`echo "$LINE" | awk -F"\t" '{print $1}'`
45 RUNID=`echo "$LINE" | awk -F"\t" '{print $2}'`
46
47 # Split into year, month, day
48 YEAR=`echo ${NIGHT} | cut -c1-4`
49 MONTH=`echo ${NIGHT} | cut -c5-6`
50 DAY=`echo ${NIGHT} | cut -c7-8`
51
52 # Formatting of the file paths and names
53 DATPATH="${YEAR}/${MONTH}/${DAY}"
54
55 PREFIX=`printf ${NIGHT}_%03d ${RUNID}`
56
57 DATNAME=`printf ${PREFIX}_Y.root ${RUNID}`
58
59 OUT=${DATA}/${STAR}/${DATPATH}
60 IN=${DATA}/${CALLISTO}/${DATPATH}
61
62 echo ""
63 echo ${DATNAME}
64 echo ${IN} " => " ${OUT}
65
66 # Check if not yet successfully processed but sucessfully calibrated
67 if [[ -f "${IN}/.${PREFIX}.success" && ! -f "${IN}/.${PREFIX}.running" && ! -f "${OUT}/.${PREFIX}.success" ]]
68 then
69
70 cd ${MARS}
71
72 mkdir -p ${OUT}
73
74 # Flag that a process is running
75 rm -f ${OUT}/.${PREFIX}.done
76 rm -f ${OUT}/.${PREFIX}.success
77
78 touch ${OUT}/.${PREFIX}.running
79
80 # Execute image parameter calculation and write log-file
81 root -b -q -l ${MACROS}/star.C'("'${IN}/${DATNAME}'","'${OUT}'")' \
82 2>&1 | tee ${OUT}/${PREFIX}.log
83
84 # Remember exit status of callisto
85 RC=${PIPESTATUS[0]}
86
87 echo RC=${RC} | tee -a ${OUT}/${PREFIX}.log
88 echo ${RC} > ${OUT}/.${PREFIX}.done
89
90 # Flag that processing is finished
91 rm -f ${OUT}/.${PREFIX}.running
92
93 # If processing was successfull write coresponding flag
94 if [ "${RC}" == "0" ]
95 then
96 touch ${OUT}/.${PREFIX}.success
97 fi
98
99 cd -
100
101 else
102 echo Skipped.
103 fi
104
105done
Note: See TracBrowser for help on using the repository browser.