source: trunk/Mars/hawc/processing/run-root2sql.sh@ 20032

Last change on this file since 20032 was 20031, checked in by tbretz, 4 years ago
Included telescope id and the create query to the raw data extraction.
File size: 1.8 KB
Line 
1#/bin/bash
2
3# Specify the telescope for which to run the script. Replace '1'
4# by $1 if the telesocpe number is supplied as an option to the script
5TELESCOPE=1
6
7# Path where the data is stored... can be callisto or star
8BASEIN=/data/callisto
9# This is Y for calibrated data and I for image parameters
10SUFFIX=Y
11# The table to insert the data into (and create if not exists)
12TABLE=Callisto
13# Path to the executable
14ROOT2SQL=~/FACT++/build/root2sql
15# Resource file to use (should match the input files)
16RESOURCE=root2sql-callisto.rc
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_new
27ORDER BY
28 NIGHT, RUNID\
29
30"\
31 | mysql \
32 --defaults-file=~/.password.cnf \
33 --user=hawcwrite \
34 --host=ihp-pc45.ethz.ch \
35 --database=hawcdata \
36 --skip-column-names \
37 --batch --raw \
38 --compress \
39 | \
40while IFS= read -r LINE
41do
42
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 # Format file and path names
53 DIR="${BASEIN}/${YEAR}/${MONTH}/${DAY}"
54
55 PREFIX=`printf ${NIGHT}_%03d ${RUNID}`
56
57 echo ""
58 echo ${DIR}/${PREFIX}
59
60 # Check if processing was successfull
61 if [ -f ${DIR}/.${PREFIX}.success ]
62 then
63
64 ${ROOT2SQL} ${DIR}/${PREFIX}_${SUFFIX}Y.root \
65 -C ${RESOURCE} \
66 --table=${TABLE} \
67 --const.Telescope=${TELESCOPE} \
68 --const.NIGHT=${NIGHT} \
69 --const.RUNID=${RUNID} \
70 2>&1 | tee ${DIR}/${PREFIX}-root2sql.log
71
72 echo RC=${PIPESTATUS[0]} >> ${DIR}/${PREFIX}-root2sql.log
73 else
74 echo Skipped.
75 fi
76
77done
Note: See TracBrowser for help on using the repository browser.