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 | fi
|
---|
18 |
|
---|
19 | # getting coordinates from raw and drive
|
---|
20 | date=`echo $starfile | grep -o -E '20[0-9][0-9]/[0-3][0-9]/[0-2][0-9]'`
|
---|
21 | drivefile=$auxdata"/"$date"/"`basename $starfile | cut -d_ -f1`".DRIVE_CONTROL_SOURCE_POSITION.fits"
|
---|
22 | rawfile=$rawdata"/"$date"/"`basename $starfile | sed -e 's/_I.root/.fits.fz/'`
|
---|
23 | if [ -e $rawfile ]
|
---|
24 | then
|
---|
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}
|
---|
29 | fi
|
---|
30 | if ls $drivefile >/dev/null 2>&1 && ! [ "$tstop" == "" ]
|
---|
31 | then
|
---|
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
|
---|
46 | else
|
---|
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
|
---|
70 | fi
|
---|
71 | ra=${coordinates[0]}
|
---|
72 | dec=${coordinates[1]}
|
---|
73 |
|
---|
74 |
|
---|
75 | outpath=`dirname $starfile | sed -e 's/star/ganymed_run/'`
|
---|
76 | makedir $outpath
|
---|
77 |
|
---|
78 | output=$outpath/`basename $starfile | cut -dI -f1`
|
---|
79 | logfile=$output"-ganymed.log"
|
---|
80 | ganymedfile=$output"-analysis.root"
|
---|
81 |
|
---|
82 | cd $mars
|
---|
83 |
|
---|
84 | # run ganymed
|
---|
85 | printprocesslog "INFO starting ganymed.C for starfile "$starfile
|
---|
86 |
|
---|
87 | printprocesslog "DEBUG root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep"
|
---|
88 | check1=`root -q -b fact/analysis/ganymed.C\($ra\,$dec\,"\"$starfile\""\,"\"$output\""\) | tee $logfile | intgrep`
|
---|
89 |
|
---|
90 | case $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 | ;;
|
---|
108 | esac
|
---|
109 |
|
---|
110 | finish
|
---|
111 |
|
---|