Index: trunk/DataCheck/Processing/FillAuxData.sh
===================================================================
--- trunk/DataCheck/Processing/FillAuxData.sh	(revision 15297)
+++ trunk/DataCheck/Processing/FillAuxData.sh	(revision 15298)
@@ -90,5 +90,4 @@
 #        `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
         )
-dates=( "2012/03/25" "2012/03/26" "2012/03/27" "2012/03/28" "2012/03/29" "2012/03/30" "2012/04/10" "2012/04/09" "2012/04/08" "2012/04/06" "2012/04/05" "2012/04/03"  )
 #dates=( `find $ziprawdata -mindepth 3 -type d | sort | sed "s/\${ziprawdata_for_sed}//g" | sed -e 's/^\///'` ) #all available dates in /loc_data/zipraw
 printprocesslog "INFO processing the following night(s): "${dates[@]}
@@ -131,4 +130,16 @@
       then 
          printprocesslog "WARN for $trackingfile fverify returned "$tracknumerrors" error(s)."
+      fi
+   fi
+   
+   sourceposfile=$auxdir/$runnumber.DRIVE_CONTROL_SOURCE_POSITION.fits
+   if ! [ -e $sourceposfile ]
+   then 
+      printprocesslog "WARN "$sourceposfile" not found."
+   else
+      sourceposnumerrors=`fverify $sourceposfile 2>/dev/null | grep -o '[0-9][ ]error(s)'  | grep -E -o '[0-9]'`
+      if [ $sourceposnumerrors -gt 0 ]
+      then 
+         printprocesslog "WARN for $sourceposfile fverify returned "$sourceposnumerrors" error(s)."
       fi
    fi
@@ -228,6 +239,32 @@
       #fi
 
+      # get information from source_pos file
+      if [ -e $sourceposfile ] && [ $sourceposnumerrors -eq 0 ]
+      then 
+         #sourcename=`${factpath}/fitsdump ${sourceposfile} -c Time -c Name --filter='[1]<'${tstop}  2>/dev/null | tail -1 2>&1 | grep -o -E "['][a-zA-Z0-9\ ]+[']" | sed -e "s/'//g"`
+         sourcename=`/home/fact/FACT++.dbg/fitsdump ${sourceposfile} -c Time -c Name --filter='[1]<'${tstop}  2>/dev/null | tail -1 2>&1 | grep -o -E "['][a-zA-Z0-9\ ]+[']" | sed -e "s/'//g"`
+         #echo "/home/fact/FACT++.dbg/fitsdump ${sourceposfile} -c Time -c Name --filter='[1]<'${tstop}  2>/dev/null | tail -1 2>&1 "
+         #echo $sourcename
+         if [ "$sourcename" == "" ]
+         then
+            printprocesslog "INFO couldn't get sourcename ("$sourcename") from "$sourceposfile" for "$runnumber"_"$filenum
+         else 
+            query="SELECT fSourceKey FROM Source WHERE fSourceName='"$sourcename"'"
+            sourcekey=`sendquery`
+            if [ "$sourcename" == "" ]
+            then
+               printprocesslog "WARN couldn't get sourcekey for source "$sourcename" from DB for "$runnumber"_"$filenum
+            fi 
+            #echo $sourcekey
+         fi
+      fi
+      
       # build query to update runinfo in DB
       query="UPDATE RunInfo SET "
+      # fill source key only if available
+      if ! [ "$sourcekey" = "" ]
+      then
+         query=$query" fSourceKey="$sourcekey", "
+      fi
       
       # get information from tracking
@@ -364,4 +401,5 @@
       # add where condition
       query=$query" WHERE fNight="$runnumber" AND fRunID="$filenum
+      #echo $query
 
       # send query to DB
