Index: trunk/DataCheck/CheckRawData.sh
===================================================================
--- trunk/DataCheck/CheckRawData.sh	(revision 12622)
+++ trunk/DataCheck/CheckRawData.sh	(revision 12623)
@@ -30,5 +30,5 @@
 # get last 3 nights
 dates=( `date +%Y/%m/%d` `date +%Y/%m/%d --date="-1day"` `date +%Y/%m/%d --date="-2day"` `date +%Y/%m/%d --date="-3day"` )
-dates=( `date +%Y/%m/%d --date="-2day"` )
+dates=( `date +%Y/%m/%d --date="-3day"` )
 
 # do rsync for rawfiles of these dates
@@ -129,5 +129,5 @@
       query5="SELECT fRunNumber FROM RunInfo WHERE fRunNumber="$runnumber" AND fFileNumber="$filenumberfromfileorig
       query5=$query5" AND NOT ISNULL(fMd5sumRaw) AND NOT ISNULL(fMd5sumRawZip)"
-      echo "Q5:"$query5 >> $logfile 2>&1 2>&1
+      echo "Q5:"$query5 >> $logfile 2>&1 
       result5=`/usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query5"`
 
@@ -143,9 +143,13 @@
          if [ "$skipmd5sum" == "no" ] || [ "$result5" == "" ] 
          then 
-            echo "calculation md5sum for raw..." >> $logfile 2>&1
-            md5sum=`md5sum $file | cut -d' ' -f1`
             zipfile=`echo $file | sed -e 's/raw/zipraw/' -e 's/fits/fits.gz/'`
-            echo "calculation md5sum for zipraw..." >> $logfile 2>&1
-            md5sumzip=`md5sum $zipfile | cut -d' ' -f1`
+            # only do the md5sum if the zipfile is already available
+            if ls $zipfile >/dev/null >> $logfile 2>&1 
+            then 
+               echo "calculation md5sum for raw..." >> $logfile 2>&1
+               md5sum=`md5sum $file | cut -d' ' -f1`
+               echo "calculation md5sum for zipraw..." >> $logfile 2>&1
+               md5sumzip=`md5sum $zipfile | cut -d' ' -f1`
+            fi
          fi
       fi
@@ -159,13 +163,31 @@
       roi=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep NROI | grep -v NROITM | grep -E -o '[0-9]{1,4}'`
       numevents=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep Events | grep -E -o '[0-9]+'`
-      runstart=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep TSTART | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
-      runstop=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep TSTOP | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
+      # in newest data start time is in DATE-OBS
+      # in older data start time is in TSTART
+      # in the beginning TSTART was empty
+      runstart=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep DATE-OBS | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
+      runstart2=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep TSTART | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
       if [ "$runstart" == ""  ]
       then
-         runstart=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep DATE | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
-      fi
+         if [ "$runstart2" == ""  ]
+         then
+            runstart=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep DATE | grep -v 'DATE-' | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
+         else
+            runstart=$runstart2
+         fi
+      fi
+      # in newest data start time is in DATE-END
+      # in older data start time is in TSTOP
+      # in the beginning TSTOP was empty
+      runstop=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep DATE-END | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
+      runstop2=`/home/fact/FACT++/fitsdump -h -t Events $file  2>/dev/null | grep TSTOP | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9]T[0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{6}'`
       if [ "$runstop" == ""  ]
       then
-         runstop=`stat $file  2>/dev/null | grep Modify | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9][ ][0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{9}'`
+         if [ "$runstop2" == ""  ]
+         then
+            runstop=`stat $file  2>/dev/null | grep Modify | grep -E -o '20[1-9][0-9][\-][01][0-9][\-][0-3][0-9][ ][0-2][0-9]:[0-6][0-9]:[0-6][0-9][.][0-9]{9}'`
+         else
+            runstop=$runstop2
+         fi
       fi
 
@@ -207,5 +229,5 @@
       query4=$query4" "$querystop
       echo "Q4:"$query4 >> $logfile 2>&1
-      if ! /usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query4"
+      if ! /usr/bin/mysql -u operator --host=fact01.fact.local --password=$password FactData -e "$query4" >> $logfile 2>&1
       then
          echo "insert/update of "$numfromfile" to mysql" >> $logfile 2>&1
