source: trunk/DataCheck/QuickLook/RunGanymed.sh@ 18342

Last change on this file since 18342 was 18316, checked in by Daniela Dorner, 9 years ago
added exit in case no starfile is given
  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6
7# get and check variables
8if ! [ "$1" = "" ]
9then
10 starfile=$1
11fi
12
13if [ "$starfile" = "" ]
14then
15 echo "ERROR variable starfile empty."
16 printprocesslog "ERROR variable starfile empty."
17 finish
18fi
19
20# getting coordinates from raw and drive or DB
21date=`echo $starfile | grep -o -E '20[0-9][0-9]/[0-3][0-9]/[0-3][0-9]'`
22drivefile=$auxdata"/"$date"/"`basename $starfile | cut -d_ -f1`".DRIVE_CONTROL_SOURCE_POSITION.fits"
23rawfile=$rawdata"/"$date"/"`basename $starfile | sed -e 's/_I.root/.fits.fz/'`
24if [ -e $rawfile ]
25then
26 printprocesslog "INFO processing "$rawfile
27 tstopi=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep TSTOPI | grep -E -o '[0-9]+'`
28 tstopf=`$factpath/fitsdump -h $rawfile 2>/dev/null | grep TSTOPF | grep -E -o '[.][0-9]+'`
29 tstop=${tstopi}${tstopf}
30else
31 printprocesslog "WARN "$rawfile" not found."
32fi
33if [ "$tstop" == "" ]
34then
35 printprocesslog "WARN tstop empty "$rawfile
36fi
37if ! ls $drivefile >/dev/null 2>&1
38then
39 printprocesslog "WARN "$drivefile" missing."
40fi
41if ls $drivefile >/dev/null 2>&1 && ! [ "$tstop" == "" ]
42then
43 printprocesslog "INFO getting coordinates from "$drivefile
44 coordinates=( `${factpath}/fitsdump ${drivefile} -c Ra_src Dec_src -r --filter='Time<'${tstop} 2>/dev/null | tail -1 2>&1` )
45 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
46 then
47 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
48 echo "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile
49 finish
50 fi
51 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
52 then
53 printprocesslog "WARN coordinates "${coordinates[@]}
54 echo "WARN coordinates "${coordinates[@]}
55 finish
56 fi
57else
58 night=`echo $date | sed -e 's/\///g'`
59 runid=`basename $starfile | cut -d_ -f2`
60 printprocesslog "INFO getting coordinates from DB."
61 query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$night" AND fRunID="$runid
62 sourcekey=`sendquery`
63 if [ "$sourcekey" == "" ]
64 then
65 printprocesslog "WARN sourcekey empty for "$night"_"$runid" - coordinates"${coordinates[@]}
66 finish
67 fi
68 query="SELECT Round(fRightAscension,6), Round(fDeclination,6) from Source WHERE fSourceKey="$sourcekey
69 coordinates=( `sendquery` )
70 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
71 then
72 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") for "$night"_"$runid" from DB."
73 finish
74 fi
75 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
76 then
77 printprocesslog "WARN coordinates "${coordinates[@]}" for "$night"_"$runid
78 finish
79 fi
80fi
81ra=${coordinates[0]}
82dec=${coordinates[1]}
83
84
85outpath=`dirname $starfile | sed -e 's/star/ganymed_run/'`
86makedir $outpath
87
88output=$outpath/`basename $starfile | cut -d_ -f1-2`
89logfile=$output"-ganymed.log"
90ganymedfile=$output"-analysis.root"
91
92cd $mars
93
94# run ganymed
95printprocesslog "INFO starting ganymed.C for starfile "$starfile
96
97printprocesslog "DEBUG root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep"
98check1=`root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep`
99
100case $check1 in
101 0) printprocesslog "INFO ganymed.C was successful for starfile "$starfile" ra "$ra" dec "$dec" (check1=$check1)"
102
103 echo "run numevts.C for "$ganymedfile" for table "$resulttable1 >> $logfile 2>&1
104 printprocesslog "INFO run numevts.C for "$ganyemdfile" for table "$resulttable1
105 printprocesslog "DEBUG root -q -b -l fact/processing/numevents.C+\("\"$ganymedfile"\"\,"\"$starfile"\"\,"\"$resulttable1"\"\,kFALSE\)"
106 check1=`root -q -b -l fact/processing/numevents.C+\("\"$ganymedfile"\"\,"\"$starfile"\"\,"\"$resulttable1"\"\,kFALSE\) | tee $logfile | intgrep`
107 case $check1 in
108 1) printprocesslog "INFO filling numevts.C was successfully for "$ganymedfile" and table "$resulttable1" (check1=$check1)"
109 ;;
110 0) printprocesslog "WARN connection to DB failed in numevts.C (check1=$check1)"
111 ;;
112 *) printprocesslog "ERROR numevts.C failed for "$ganymedfile" and table "$resulttable1" (check1=$check1)"
113 ;;
114 esac
115 ;;
116 *) printprocesslog "ERROR ganymed.C failed for starfile "$starfile" ra "$ra" dec "$dec" (check1=$check1)"
117 ;;
118esac
119
120finish
121
Note: See TracBrowser for help on using the repository browser.