Index: trunk/DataCheck/Processing/FillNumEvts.sh
===================================================================
--- trunk/DataCheck/Processing/FillNumEvts.sh	(revision 17082)
+++ trunk/DataCheck/Processing/FillNumEvts.sh	(revision 17088)
@@ -7,27 +7,22 @@
 date >> $logfile
 
-# get current hour
-hour=`date +%k`
-if [ $hour -le 7 ] || [ $hour -ge 19 ]
+# this script doesn't need variable $doupdate
+# filling is done by macro. therefore update is always done
+
+# get dates
+if [ "$certaindate" != "" ]
 then
-   dates=( `date +%Y/%m/%d --date="-12hour"` )
+   getdates $certaindate
 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"` \
-           )
+   # get all night
+   #getdates "all"
+   # get last 6 nights
+   getdates 6
 fi
 
-#dates=( `find -L $auxdata -mindepth 3 -type d | sort -r | grep -v bad | sed "s/\${auxdata_for_sed}//g" | sed -e 's/^\///'` ) #all available dates in /loc_data/zipraw
-
-#dates=( "2013/04/17" )
 
 printprocesslog "INFO processing the following night(s): "${dates[@]}
 echo  `date`": processing the following night(s): "${dates[@]} >> $logfile 2>&1
 
-#echo ${dates[@]}
-
-mars=/home/fact/SW.automatic.processing/Mars.svn.2013.04.29
 cd $mars
 
@@ -37,27 +32,50 @@
    runnumber=`echo $date | sed -e 's/\///g'`
    
-   # data which are not processed in LP
-   if [ $runnumber -lt 20121212 ]
+   # process only data which are available
+   if [ $runnumber -lt $firstnight ]
    then
       continue
    fi
    
-   echo "run numevts.C for night "$runnumber" (run-wise processing) " >> $logfile 2>&1
-   printprocesslog "run numevts.C for night "$runnumber" (run-wise processing) "
-   printprocesslog "root -q -b -l fact/processing/numevents.C+\("\"$runnumber"\"\,"\"$anapath"\"\,"\"$resulttable1"\"\,kFALSE\,kFALSE\)"
-   check1=`root -q -b -l fact/processing/numevents.C+\("\"$runnumber"\"\,"\"$anapath"\"\,"\"$resulttable1"\"\,kFALSE\,kFALSE\) | tee $logfile | intgrep`
+   # fill run-wise processing
+   if [ -d $anapath/ganymed_run/$date ]
+   then 
+      echo "run numevts.C for night "$runnumber" (run-wise processing) for table "$resulttable1 >> $logfile 2>&1
+      printprocesslog "INFO run numevts.C for night "$runnumber" (run-wise processing) for table "$resulttable1
+      printprocesslog "DEBUG root -q -b -l fact/processing/numevents.C+\("\"$runnumber"\"\,"\"$anapath"\"\,"\"$resulttable1"\"\,kFALSE\,kFALSE\)"
+      check1=`root -q -b -l fact/processing/numevents.C+\("\"$runnumber"\"\,"\"$anapath"\"\,"\"$resulttable1"\"\,kFALSE\,kFALSE\) | tee $logfile | intgrep`
+      
+      case $check1 in
+         1)   printprocesslog "INFO filling numevts.C was successfully for night "$runnumber" and table "$resulttable1" (check1=$check1)"
+              ;;
+         0)   printprocesslog "WARN connection to DB failed in numevts.C (check1=$check1)"
+              ;;
+         *)   printprocesslog "ERROR numevts.C failed for night "$runnumber" and table "$resulttable1" (check1=$check1)"
+              ;;
+      esac
+   fi
+   
+   query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$runnumber" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey "
+   sources=( `sendquery` )
+   # fill night-wise processing
+   for source in ${sources[@]}
+   do
+      if [ -d $anapath/ganymed_night/$source/$date ]
+      then 
+         echo "run numevts.C for night "$runnumber" and source "$source" (night-wise processing) " >> $logfile 2>&1
+         printprocesslog "INFO run numevents.C for night "$runnumber" and source "$source" (night-wise processing) "
+         printprocesslog "DEBUG root -q -b -l fact/processing/numevents.C+\("\"$runnumber"\"\,"\"$anapath"\"\,"\"$resulttable2"\"\,kFALSE\,kTRUE\,$source\)"
 
-   case $check1 in
-      1)   printprocesslog "INFO filling numevts.C was successfully (check1=$check1)"
-           ;;
-      0)   printprocesslog "WARN connection to DB failed in numevts.C (check1=$check1)"
-           ;;
-      *)   printprocesslog "ERROR numevts.C failed (check1=$check1)"
-           ;;
-   esac
-
-   #echo "run numevts.C for night "$runnumber" (night-wise processing) "
-   #root -q -b -l fact/processing/numevts.C\("\"$runnumber"\"\,"\"$inpath"\"\,"\"$resulttable2"\"\,kFALSE\,kTRUE\)
-
+         check1=`root -q -b -l fact/processing/numevents.C+\("\"$runnumber"\"\,"\"$anapath"\"\,"\"$resulttable2"\"\,kFALSE\,kTRUE\,$source\) | tee $logfile | intgrep`
+         case $check1 in
+            1)   printprocesslog "INFO filling numevts.C was successfully for night "$runnumber" and table "$resulttable2" (check1=$check1)"
+                 ;;
+            0)   printprocesslog "WARN connection to DB failed in numevts.C (check1=$check1)"
+                 ;;
+            *)   printprocesslog "ERROR numevts.C failed for night "$runnumber" and table "$resulttable2" (check1=$check1)"
+                 ;;
+         esac
+      fi
+   done
 done
 
