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

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