Index: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 7426)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 7460)
@@ -20,9 +20,19 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script is launching the calibration of sequences. 
+# 
+# In the case of calibration only one sequence is processed. Despite of 
+# that the structure of the script is such, that also more sequences could
+# be processed. The restriction to one sequence has been made, as the 
+# calibration takes some time. There's one todo file per sequence. 
+# First the script searches for a todo file. Then the sequence from this 
+# todo file is calibrated and the merpp update is done. 
+# 
+# the callisto.rc files are stored in the setup directory
 #
 
@@ -32,4 +42,5 @@
 set -C
 
+# define callisto.rc files
 callistorcnew=$setuppath/callisto/callisto.rc
 callistorcmarapr05=$setuppath/callisto/callisto_MarApr05.rc
@@ -56,4 +67,5 @@
 cd $mars
 
+# get todo file
 echo "checking if other todo-files are there" >> $scriptlog 2>&1
 if  ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
@@ -73,26 +85,21 @@
    esac
 
-   if  ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
-   then
-      echo "other file(s) on disk " >> $scriptlog 2>&1
-      echo " -> choose one file and start calibrating" >> $scriptlog 2>&1
-   else
-      echo "getting list..." >> $scriptlog 2>&1
-      check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
-
-      case $check0 in
-          1)   echo "check0=$check0 -> everything ok -> run callisto" >> $scriptlog 2>&1;;
-          *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
-      esac
-   fi
+   echo "getting list..." >> $scriptlog 2>&1
+   check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
+
+   case $check0 in
+      1)   echo "check0=$check0 -> everything ok -> run callisto" >> $scriptlog 2>&1;;
+      *)   echo "check0=$check0 -> ERROR -> could not get todo list -> exit" >> $scriptlog 2>&1
+	   rm -v $lockpath/lock-getting-callisto-list.txt >> $scriptlog 2>&1
+	   date  >> $scriptlog 2>&1
+	   exit;;
+   esac
    rm -v $lockpath/lock-getting-callisto-list.txt >> $scriptlog 2>&1
 fi
 
-
+# choose todo file
 nr=bla
 echo "finding the right todo-file" >> $scriptlog 2>&1
 todofiles=`ls -r $listpath/ToDo-$table-$column-*`
-
-#echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
 
 for todofile in ${todofiles[@]}
@@ -122,6 +129,6 @@
 esac
 
+# get sequence(s) from todo file
 sequences=(`cat $todofile`)
-
 if [ "$sequences" = "" ]
 then 
@@ -133,6 +140,6 @@
 fi
 
+# run calibration for sequence(s)
 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
-
 for sequence in ${sequences[@]}
 do 
@@ -146,4 +153,5 @@
   echo "sequfile: "$sequfile >> $scriptlog 2>&1
   
+  # find callisto.rc file
   if [ -e $outpath/callisto.rc ]
   then
@@ -167,4 +175,6 @@
   case $check1 in
      0)   echo "check1=$check1 -> everything ok -> doing update..." >> $scriptlog 2>&1
+          # running merpp update if calibration worked
+          # finding files, which have to be updated
           echo "finding files to be updated" >> $scriptlog 2>&1
           calfiles=`find $outpath -name *_Y_* `
@@ -179,7 +189,10 @@
           makedir $merpplogpath >> $scriptlog 2>&1
           
+          # updated calibrated data files with the information from the cc and caco files
           for calfile in ${calfiles[@]}
           do 
              echo "calfile: "$calfile >> $scriptlog 2>&1
+             # find cc and caco file
+             # if file is missing continue with next sequence
              runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
              ccfile=`find /magic/subsystemdata/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
@@ -232,4 +245,5 @@
           done
           
+          # set status for calibration if merpp updates are also done
           echo "inserting the status for callisto for sequence $sequence into the db" >> $scriptlog 2>&1
           setstatuslogpath=$logpath/setstatus/callisto/$no
