1 | #!/bin/bash
|
---|
2 | #
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 |
|
---|
7 | # get and check variables
|
---|
8 | if ! [ "$1" = "" ]
|
---|
9 | then
|
---|
10 | starfile=$1
|
---|
11 | fi
|
---|
12 |
|
---|
13 | if [ "$starfile" = "" ]
|
---|
14 | then
|
---|
15 | echo "ERROR variable starfile empty."
|
---|
16 | printprocesslog "ERROR variable starfile empty."
|
---|
17 | finish
|
---|
18 | fi
|
---|
19 |
|
---|
20 | # getting coordinates from raw and drive or DB
|
---|
21 | date=`echo $starfile | grep -o -E '20[0-9][0-9]/[0-3][0-9]/[0-3][0-9]'`
|
---|
22 | drivefile=$auxdata"/"$date"/"`basename $starfile | cut -d_ -f1`".DRIVE_CONTROL_SOURCE_POSITION.fits"
|
---|
23 | rawfile=$rawdata"/"$date"/"`basename $starfile | sed -e 's/_I.root/.fits.fz/'`
|
---|
24 | if [ -e $rawfile ]
|
---|
25 | then
|
---|
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}
|
---|
31 | else
|
---|
32 | printprocesslog "WARN "$rawfile" not found."
|
---|
33 | fi
|
---|
34 | if [ "$tstop" == "" ]
|
---|
35 | then
|
---|
36 | printprocesslog "WARN tstop empty "$rawfile
|
---|
37 | fi
|
---|
38 | if ! ls $drivefile >/dev/null 2>&1
|
---|
39 | then
|
---|
40 | printprocesslog "WARN "$drivefile" missing."
|
---|
41 | fi
|
---|
42 | if ls $drivefile >/dev/null 2>&1 && ! [ "$tstop" == "" ]
|
---|
43 | then
|
---|
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
|
---|
59 | else
|
---|
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
|
---|
82 | fi
|
---|
83 | ra=${coordinates[0]}
|
---|
84 | dec=${coordinates[1]}
|
---|
85 |
|
---|
86 |
|
---|
87 | outpath=`dirname $starfile | sed -e 's/star/ganymed_run/'`
|
---|
88 | makedir $outpath
|
---|
89 |
|
---|
90 | output=$outpath/`basename $starfile | cut -d_ -f1-2`
|
---|
91 | logfile=$output"-ganymed.log"
|
---|
92 | ganymedfile=$output"-analysis.root"
|
---|
93 |
|
---|
94 | cd $mars
|
---|
95 |
|
---|
96 | # run ganymed
|
---|
97 | printprocesslog "INFO starting ganymed.C for starfile "$starfile
|
---|
98 |
|
---|
99 | printprocesslog "DEBUG root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep"
|
---|
100 | check1=`root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep`
|
---|
101 |
|
---|
102 | case $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 $logfile | intgrep`
|
---|
109 | case $check1 in
|
---|
110 | 1) printprocesslog "INFO filling numevts.C was successfully for "$ganymedfile" and table "$resulttable1" (check1=$check1)"
|
---|
111 | ;;
|
---|
112 | 0) printprocesslog "WARN connection to DB failed in numevts.C (check1=$check1)"
|
---|
113 | ;;
|
---|
114 | *) printprocesslog "ERROR numevts.C failed for "$ganymedfile" and table "$resulttable1" (check1=$check1)"
|
---|
115 | ;;
|
---|
116 | esac
|
---|
117 | ;;
|
---|
118 | *) printprocesslog "ERROR ganymed.C failed for starfile "$starfile" ra "$ra" dec "$dec" (check1=$check1)"
|
---|
119 | ;;
|
---|
120 | esac
|
---|
121 |
|
---|
122 | finish
|
---|
123 |
|
---|