source: branches/trigger_burst_research/QuickLook/RunGanymed.sh@ 19875

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