1 | #/bin/bash
|
---|
2 |
|
---|
3 | # Path where the data is stored... can be callisto or star
|
---|
4 | BASEIN=/data/callisto
|
---|
5 | # This is Y for calibrated data and I for image parameters
|
---|
6 | SUFFIX=Y
|
---|
7 | # The table to insert the data into (and create if not exists)
|
---|
8 | TABLE=Callisto
|
---|
9 | # Path to the executable
|
---|
10 | ROOT2SQL=~/FACT++/build/root2sql
|
---|
11 | # Resource file to use (should match the input files)
|
---|
12 | RESOURCE=root2sql-callisto.rc
|
---|
13 |
|
---|
14 | # Get all runs that can (and should) be calibrated
|
---|
15 | # Pipe the output to mysql and read the
|
---|
16 | # mysql output line-by-libe
|
---|
17 | echo \
|
---|
18 | "\
|
---|
19 | SELECT
|
---|
20 | NIGHT, RUNID
|
---|
21 | FROM
|
---|
22 | Calibration_new
|
---|
23 | ORDER BY
|
---|
24 | NIGHT, RUNID\
|
---|
25 |
|
---|
26 | "\
|
---|
27 | | mysql \
|
---|
28 | --defaults-file=~/.password.cnf \
|
---|
29 | --user=hawcwrite \
|
---|
30 | --host=ihp-pc45.ethz.ch \
|
---|
31 | --database=hawcdata \
|
---|
32 | --skip-column-names \
|
---|
33 | --batch --raw \
|
---|
34 | --compress \
|
---|
35 | | \
|
---|
36 | while IFS= read -r LINE
|
---|
37 | do
|
---|
38 |
|
---|
39 | # Get NIGHT and RUNID of all files
|
---|
40 | NIGHT=`echo "$LINE" | awk -F"\t" '{print $1}'`
|
---|
41 | RUNID=`echo "$LINE" | awk -F"\t" '{print $2}'`
|
---|
42 |
|
---|
43 | # Split into year, month, day
|
---|
44 | YEAR=`echo ${NIGHT} | cut -c1-4`
|
---|
45 | MONTH=`echo ${NIGHT} | cut -c5-6`
|
---|
46 | DAY=`echo ${NIGHT} | cut -c7-8`
|
---|
47 |
|
---|
48 | # Format file and path names
|
---|
49 | DIR="${BASEIN}/${YEAR}/${MONTH}/${DAY}"
|
---|
50 |
|
---|
51 | PREFIX=`printf ${NIGHT}_%03d ${RUNID}`
|
---|
52 |
|
---|
53 | echo ""
|
---|
54 | echo ${DIR}/${PREFIX}
|
---|
55 |
|
---|
56 | # Check if processing was successfull
|
---|
57 | if [ -f ${DIR}/.${PREFIX}.success ]
|
---|
58 | then
|
---|
59 |
|
---|
60 | ${ROOT2SQL} ${DIR}/${PREFIX}_${SUFFIX}Y.root \
|
---|
61 | -C ${RESOURCE} \
|
---|
62 | --table=${TABLE} \
|
---|
63 | --const.NIGHT=${NIGHT} \
|
---|
64 | --const.RUNID=${RUNID} \
|
---|
65 | 2>&1 | tee ${DIR}/${PREFIX}-root2sql.log
|
---|
66 |
|
---|
67 | echo RC=${PIPESTATUS[0]} >> ${DIR}/${PREFIX}-root2sql.log
|
---|
68 | else
|
---|
69 | echo Skipped.
|
---|
70 | fi
|
---|
71 |
|
---|
72 | done |
---|