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

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