Index: trunk/DataCheck/QuickLook/Step3.sh
===================================================================
--- trunk/DataCheck/QuickLook/Step3.sh	(revision 15400)
+++ trunk/DataCheck/QuickLook/Step3.sh	(revision 15401)
@@ -32,12 +32,19 @@
 fi
 
-# get last 3, 6 or 9 nights
-dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
-#        `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
-#        `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
-        )
-#dates=( `find -L $ziprawdata -mindepth 3 -type d | sort -r | sed "s/\${ziprawdata_for_sed}//g" | sed -e 's/^\///'` ) #all available dates in /loc_data/zipraw
+# get current hour
+hour=`date +%k`
+if [ $hour -le 7 ] || [ $hour -ge 19 ]
+then
+   dates=( `date +%Y/%m/%d --date="-12hour"` )
+else
+   # get last 3, 6 or 9 nights
+   dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
+   #        `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
+   #        `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
+           )
+fi
+dates=( `find -L $auxdata -mindepth 3 -type d | sort -r | sed "s/\${auxdata_for_sed}//g" | sed -e 's/^\///'` ) #all available dates in /loc_data/zipraw
 
-dates=( "2013/04/19" )
+#dates=( "2013/04/19" )
 
 # source info on daq in /loc_data/analysis/sources.txt 
@@ -46,4 +53,5 @@
 timebins=( 5 10 20 30 40 60 90 120 180 240 300 360 )
 
+echo ${dates[@]}
 for date in ${dates[@]}
 do 
@@ -51,4 +59,5 @@
    query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$date2" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey "
    sources=( `sendquery` )
+   echo "process "$date" -> sources: "${sources[@]}
    for source in ${sources[@]}
    do 
@@ -75,4 +84,24 @@
                  ;;
             *)   printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" night "$date2" (check1=$check1)"
+                 ;;
+         esac
+
+         
+         # doing the plots for last week 
+         lastweek=`date +%Y%m%d --date="$date -1 week"`
+         logfile=$outpath"/lightcurve"$source"_"$timebin"min_week.log"
+         outfile=$outpath"/lightcurve"$source"_"$timebin"min_week.root"
+         echo $outfile
+         printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" night "$date2" last week ("$lastweek")"
+      
+	 check1=`root -q -b $mars2/fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,$timebin\,"\"$resulttable1"\"\,"\"$outfile\""\) | tee $logfile | intgrep`
+      
+         case $check1 in
+            0)   printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" last week (check1=$check1)"
+                 ./showplot -b --save-as-png $outfile
+                 ;;
+            1)   printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" last week, but nothing to plot (check1=$check1)"
+                 ;;
+            *)   printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" night "$date2" last week (check1=$check1)"
                  ;;
          esac
