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

Last change on this file since 19007 was 18806, checked in by Daniela Dorner, 8 years ago
improve logging (log of numevts.C was overwriting log of ganymed.C)
  • Property svn:executable set to *
File size: 4.9 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][.][0-9]+([E][\-][0-9][0-9])?' | sed -e 's/[E]+*/\\*10\\^/'`
29 tstop=`echo " $tstopi + $tstopf " | bc -l`
30 #tstop=${tstopi}${tstopf}
31else
32 printprocesslog "WARN "$rawfile" not found."
33fi
34if [ "$tstop" == "" ]
35then
36 printprocesslog "WARN tstop empty "$rawfile
37fi
38if ! ls $drivefile >/dev/null 2>&1
39then
40 printprocesslog "WARN "$drivefile" missing."
41fi
42if ls $drivefile >/dev/null 2>&1 && ! [ "$tstop" == "" ]
43then
44 printprocesslog "INFO getting coordinates from "$drivefile" for time range "$tstart" "$tstop
45 #echo "${factpath}/fitsdump ${drivefile} -c Ra_src Dec_src -r --filter='Time<'${tstop} 2>/dev/null"
46 coordinates=( `${factpath}/fitsdump ${drivefile} -c Ra_src Dec_src -r --filter='Time<'${tstop} 2>/dev/null | tail -1 2>&1` )
47 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
48 then
49 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile" @ time "$tstop
50 echo "WARN couldn't get coordinates ("${coordinates[@]}") from "$drivefile" @ time "$tstop
51 finish
52 fi
53 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
54 then
55 printprocesslog "WARN coordinates "${coordinates[@]}" @ time "$tstop
56 echo "WARN coordinates "${coordinates[@]}" @ time "$tstop
57 finish
58 fi
59else
60 night=`echo $date | sed -e 's/\///g'`
61 runid=`basename $starfile | cut -d_ -f2`
62 printprocesslog "INFO getting coordinates from DB."
63 query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$night" AND fRunID="$runid
64 sourcekey=`sendquery`
65 if [ "$sourcekey" == "" ]
66 then
67 printprocesslog "WARN sourcekey empty for "$night"_"$runid" - coordinates"${coordinates[@]}
68 finish
69 fi
70 query="SELECT Round(fRightAscension,6), Round(fDeclination,6) from Source WHERE fSourceKey="$sourcekey
71 coordinates=( `sendquery` )
72 if [ "${coordinates[0]}" == "" ] || [ "${coordinates[1]}" == "" ]
73 then
74 printprocesslog "WARN couldn't get coordinates ("${coordinates[@]}") for "$night"_"$runid" from DB."
75 finish
76 fi
77 if [ "${coordinates[0]}" == "0" ] || [ "${coordinates[1]}" == "0" ]
78 then
79 printprocesslog "WARN coordinates "${coordinates[@]}" for "$night"_"$runid
80 finish
81 fi
82fi
83ra=${coordinates[0]}
84dec=${coordinates[1]}
85
86
87outpath=`dirname $starfile | sed -e 's/star/ganymed_run/'`
88makedir $outpath
89
90output=$outpath/`basename $starfile | cut -d_ -f1-2`
91logfile=$output"-ganymed.log"
92ganymedfile=$output"-analysis.root"
93
94cd $mars
95
96# run ganymed
97printprocesslog "INFO starting ganymed.C for starfile "$starfile
98
99printprocesslog "DEBUG root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep"
100check1=`root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep`
101
102case $check1 in
103 0) printprocesslog "INFO ganymed.C was successful for starfile "$starfile" ra "$ra" dec "$dec" (check1=$check1)"
104
105 echo "run numevts.C for "$ganymedfile" for table "$resulttable1 >> $logfile 2>&1
106 printprocesslog "INFO run numevts.C for "$ganyemdfile" for table "$resulttable1
107 printprocesslog "DEBUG root -q -b -l fact/processing/numevents.C+\("\"$ganymedfile"\"\,"\"$starfile"\"\,"\"$resulttable1"\"\,kFALSE\)"
108 check1=`root -q -b -l fact/processing/numevents.C+\("\"$ganymedfile"\"\,"\"$starfile"\"\,"\"$resulttable1"\"\,kFALSE\) | tee -a $logfile | intgrep`
109 case $check1 in
110 1) printprocesslog "INFO filling numevts.C was successfully for "$ganymedfile" and table "$resulttable1" (check1=$check1)"
111 # check result for alerts (on daq only)
112 if [ "$HOSTNAME" = "daq" ]
113 then
114 `dirname $0`/FlareAlerts.sh
115 fi
116 ;;
117 0) printprocesslog "WARN connection to DB failed in numevts.C (check1=$check1)"
118 ;;
119 *) printprocesslog "ERROR numevts.C failed for "$ganymedfile" and table "$resulttable1" (check1=$check1)"
120 ;;
121 esac
122 ;;
123 *) printprocesslog "ERROR ganymed.C failed for starfile "$starfile" ra "$ra" dec "$dec" (check1=$check1)"
124 ;;
125esac
126
127finish
128
Note: See TracBrowser for help on using the repository browser.