Index: trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/checkstardone.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/createdataset.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/createdataset.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/createdataset.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 06/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/doexclusions.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/filldotraw.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/filldotrbk.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/filldotrbk.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/filldotrbk.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/filldotrun.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Thomas Bretz, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillganymed.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Thomas Bretz, 08/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillsignal.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 04/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/fillsinope.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillsinope.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillsinope.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 04/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/fillstar.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/fillstar.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/fillstar.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
@@ -32,5 +32,5 @@
 //
 // Sometimes the DAQ aborts a run and starts itself a new one. In this cases
-// there's the camera controll doesn't start a new file, as the command to
+// the camera controll doesn't start a new file, as the command to
 // start a new run was not sent by the central control. So the caco
 // information is stored in the previous caco file, which has a different
Index: trunk/MagicSoft/Mars/datacenter/macros/getdolist.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/getdolist.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/getdolist.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/insertcacofile.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/insertcacofile.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/insertcacofile.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
@@ -32,5 +32,5 @@
 //
 // Sometimes the DAQ aborts a run and starts itself a new one. In this cases
-// there's the camera controll doesn't start a new file, as the command to
+// the camera controll doesn't start a new file, as the command to
 // start a new run was not sent by the central control. So the caco
 // information is stored in the previous caco file, which has a different
Index: trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/insertdataset.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/insertdate.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/insertdate.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/insertdate.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/insertsequence.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/insertsequence.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/insertsequence.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/plotdb.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/plotdb.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/plotdb.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/resetcolumn.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/resetcolumn.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/resetcolumn.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/setstatus.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/setstatus.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/setstatus.C	(revision 7460)
@@ -18,5 +18,5 @@
 !   Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2005
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/macros/writesequencefile.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/writesequencefile.C	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/macros/writesequencefile.C	(revision 7460)
@@ -19,5 +19,5 @@
 !   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 !
-!   Copyright: MAGIC Software Development, 2000-2004
+!   Copyright: MAGIC Software Development, 2000-2006
 !
 !
Index: trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 7460)
@@ -20,9 +20,18 @@
 #   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 launches the building of sequences for all days for which 
+# this step is needed. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then the sequences are built for each date in the todolist using the 
+# macro buildsequenceentries.C
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -52,4 +61,5 @@
 makedir $getstatuslogpath >> $scriptlog 2>&1
 
+# check if script is already running
 date > $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1 
 checklock0=$?
@@ -57,5 +67,5 @@
     0)   echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
     1)   echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
-         echo "-> getting list for buildsequenceentries is running -> exit" >> $scriptlog 2>&1
+         echo "-> buildsequenceentries is running -> exit" >> $scriptlog 2>&1
          date  >> $scriptlog 2>&1
          exit;;
@@ -63,15 +73,19 @@
 esac
 
-
-echo "getting list..." >> $scriptlog 2>&1
+# get todo list
+echo "getting todo list..." >> $scriptlog 2>&1
 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatus.log | grep int | sed -e 's/(int)//'`
 
 case $check0 in 
-   1)   echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1;;
-   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+   1)   echo "check0=$check0 -> everything ok, got todo list -> build sequence entries" >> $scriptlog 2>&1;;
+   *)   echo "check0=$check0 -> ERROR -> could not get todo list -> exit" >> $scriptlog 2>&1
+	rm -v $todofile >> $scriptlog 2>&1
+	rm -v $lockpath/lock-buildsequenceentries.txt >> $scriptlog 2>&1
+   	date  >> $scriptlog 2>&1
+	exit;;
 esac
 
+# retrieve dates from todofile
 dates=(`cat $todofile`)
-
 if [ "$dates" = "" ]
 then 
@@ -84,5 +98,4 @@
 
 echo "dates: "${dates[@]} >> $scriptlog 2>&1
-
 for date in ${dates[@]}
 do 
@@ -95,5 +108,5 @@
 
    case $check1 in
-      1)   echo "check1=$check1 -> everything ok -> setting status..." >> $scriptlog 2>&1
+      1)   echo "check1=$check1 -> everything ok -> setting status for $date..." >> $scriptlog 2>&1
            setstatuslogpath=$logpath/setstatus/buildsequenceentries/$year2
            makedir $setstatuslogpath >> $scriptlog 2>&1
@@ -102,8 +115,8 @@
            case $check2 in
    	      1)   echo "check2=$check2 -> everything ok, status has been set" >> $scriptlog 2>&1;;
-   	      *)   echo "check2=$check2 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
+   	      *)   echo "check2=$check2 -> ERROR -> step could not be set for $date" >> $scriptlog 2>&1;;
            esac
    	   ;;
-      *)   echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+      *)   echo "check1=$check1 -> ERROR - buildsequenceentries.C failed for $date -> step has to be repeated" >> $scriptlog 2>&1;;
    esac
 done
Index: trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail	(revision 7460)
@@ -20,9 +20,18 @@
 #   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 launches the checking of the availability of the files for 
+# the sequences. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each sequence the availability of the files (raw, cc, caco) is 
+# checked by using the macro checkfilesavail.C 
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -51,10 +60,17 @@
 cd $mars
 
-if [ -e $todofile ]
-then 
-   echo "checkfilesforsequenceavail is already running -> exit" >> $scriptlog 2>&1
-   exit
-fi
+# check if script is already running
+date > $lockpath/lock-checkfileavail.txt >> $scriptlog 2>&1 
+checklock0=$?
+case $checklock0 in 
+    0)   echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
+    1)   echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
+         echo "-> checkfileavail is running -> exit" >> $scriptlog 2>&1
+         date  >> $scriptlog 2>&1
+         exit;;
+    *)   echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
+esac
 
+# get todo list
 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)//'`
@@ -62,14 +78,18 @@
 case $check0 in 
    1)   echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1 ;;
-   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
+   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+	rm -v $todofile >> $scriptlog 2>&1
+	rm -v $lockpath/lock-checkfileavail.txt >> $scriptlog 2>&1
+   	date  >> $scriptlog 2>&1
+	exit;;
 esac
 
+# retrieve sequences from todofile
 sequences=(`cat $todofile`)
-
 if [ "$sequences" = "" ]
 then 
    echo "nothing to do -> exit"  >> $scriptlog 2>&1
    rm -v $todofile >> $scriptlog 2>&1
-   rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+   rm -v $lockpath/lock-checkfileavail.txt >> $scriptlog 2>&1
    date  >> $scriptlog 2>&1
    exit
@@ -77,5 +97,4 @@
 
 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
-
 for sequence in ${sequences[@]}
 do 
@@ -107,5 +126,5 @@
 
 rm -v $todofile  >> $scriptlog 2>&1 
-rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+rm -v $lockpath/lock-checkfileavail.txt >> $scriptlog 2>&1
 
 date  >> $scriptlog 2>&1
Index: trunk/MagicSoft/Mars/datacenter/scripts/checkstardone
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(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 launches the checking of the availability of the files for 
+# the datasets. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each dataset the sequences are extracted from the datasetfile 
+# and for each sequence the availability of the star files checked by using 
+# the macro checkstardone.C 
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -42,5 +52,4 @@
 scriptlogpath=$logpath/run/checkstardone/`date +%Y/%m/%d`
 makedir $scriptlogpath
-
 scriptlog=$scriptlogpath/checkstardone-$datetime.log
 
@@ -51,11 +60,17 @@
 cd $mars
 
+# check if script is already running
+date > $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1 
+checklock0=$?
+case $checklock0 in 
+    0)   echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
+    1)   echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
+         echo "-> checkstardone is running -> exit" >> $scriptlog 2>&1
+         date  >> $scriptlog 2>&1
+         exit;;
+    *)   echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
+esac
 
-if [ -e $todofile ]
-then 
-   echo "checkstardone is already running -> exit" >> $scriptlog 2>&1
-   exit
-fi
-
+# get todo list
 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)//'`
@@ -63,14 +78,17 @@
 case $check0 in 
    1)   echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1 ;;
-   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
+   *)   echo "check0=$check0 -> ERROR -> could not get list -> exit" >> $scriptlog 2>&1
+        rm -v $todofile >> $scriptlog 2>&1
+   	rm -v $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1
+   	date  >> $scriptlog 2>&1
+	exit;;
 esac
 
 datasets=(`cat $todofile`)
-
 if [ "$datasets" = "" ]
 then 
    echo "nothing to do -> exit"  >> $scriptlog 2>&1
    rm -v $todofile >> $scriptlog 2>&1
-   rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+   rm -v $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1
    date  >> $scriptlog 2>&1
    exit
@@ -78,5 +96,4 @@
 
 echo "datasets: "${datasets[@]} #>> $scriptlog 2>&1
-
 for dataset in ${datasets[@]}
 do 
@@ -123,5 +140,5 @@
 
 rm -v $todofile  >> $scriptlog 2>&1 
-rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+rm -v $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1
 
 date  >> $scriptlog 2>&1
Index: trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 7460)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
@@ -27,11 +27,10 @@
 #
 # This script handles the subsystem logfiles, which are copied every
-# day automatically from pc15 in La Palma to /data/MAGIC/transfer/ in
-# Wuerzburg
+# day automatically from /local/ on pc15 in La Palma to 
+# /home/lapalma/transfer/ on coma in the datacenter in Wuerzburg
 # The structure in this directory is: subsystem/date/logfile.*
 # The logfiles are from CC (*.rep, CC*.dbg, CC*.rbk, CC*.rep, CC*.run,
-# CC*.run.html) and Cosy (cosy*.log, cosy*.rep, tpoint*.txt/starg*.txt) 
-# AMC (AMC*.log, AMC*.info, AMC*.lut) and CaCo (dc*.txt) are not copied
-# every day automatically
+# CC*.run.html), Cosy (cosy*.log, cosy*.rep, tpoint*.txt/starg*.txt) 
+# AMC (AMC*.log, AMC*.info, AMC*.lut) and CaCo (dc*.txt) 
 #
 # the script performs the following steps:
@@ -40,9 +39,10 @@
 # using the macros filldotrbk.C and filldotrun.C
 # - copying all logfiles to the correct directory:
-# /Period*/subsystem/date/file.*
-# (the period for each date is obtained by the macro getperiod.C) 
-# - filling the sequences for the standard analysis into the database
-# (for each day of which a file was copied) 
-# 
+# /subsystemdata/subsystem/YYYY/MM/DD/file.*
+# - building the sequences for the standard analysis in the database
+#   (for each day of which a file was copied) 
+# - if a new catalogfile has been copied, it is installed as standard in the
+#   setup directory /magic/datacenter/setup and the new lines are sent to 
+#   the adresses specified in the script
 # 
 # -- to make sure that no file is copied twice there's a textfile
@@ -66,5 +66,4 @@
 transdir=/home/lapalma/transfer
 char=28
-#extern=MAGIC@virgo:/data/MAGIC/transfer
 datetime=`date +%F-%H-%M-%S`
 
@@ -76,4 +75,5 @@
 date >> $scriptlog 2>&1
 
+# check if the script is already running
 date > $lockpath/lock-copyscript.txt >> $scriptlog 2>&1 
 checklock0=$?
@@ -87,12 +87,9 @@
 esac
 
-# rsync new dc with virgo
-#rsync -av $extern/ $transdir  >> $scriptlog 2>&1 
-
 cd $transdir
 
 #check the checksums, write output into file
 md5sum -c .checksums | tee $transdir/.check  >> $scriptlog 2>&1 
-#md5sum -c $transdir/checksums-test >| $transdir/.check 
+
 if ! test -e $transdir/.check
 then
@@ -113,5 +110,4 @@
 #dates=`ls $transdir/*/ -1 | grep --regexp=20[0-9][0-9]_*[0-1][0-9]_*[0-3][0-9] | grep -v '.tgz'`
 dates=`ls $transdir/*/ -1 | grep --regexp=20[0-9][0-9]_[0-1][0-9]_[0-3][0-9] | grep -v '.tgz'` >> $scriptlog 2>&1
-
 if [ "$dates" = "" ]
 then 
@@ -123,5 +119,4 @@
 
 echo "dates found: "$dates  >> $scriptlog 2>&1 
-
 #loop over dates 
 for date in ${dates[@]}
@@ -138,5 +133,4 @@
    
    date2=`echo $date | sed -e 's/_/\//g'`
-#   echo "date2=$date2"
    copylogpath=$logpath/copyscript/$date2
    echo "copylogpath: "$copylogpath >> $scriptlog 2>&1
@@ -148,5 +142,4 @@
       echo "file: "$file  >> $scriptlog 2>&1 
       filename=`basename $file`
-#      echo "filename: "$filename
                         
       #check for each file whether it has to be processed
@@ -179,6 +172,5 @@
                1) echo "checkfillrun=$checkfillrun -> everything ok " >> $scriptlog 2>&1 
                   echo "-> insert date in SequenceBuildStatus for $date" >> $scriptlog 2>&1 
-#                  date3=`echo $date | sed -e 's/_/-/g'`
-#                  echo "date3=$date3"
+
                   checkinsertdate=`root -q -b $macrospath/insertdate.C+\("\"$date\""\) | tee $copylogpath/insertdate-$date-log.txt   | grep int | sed -e 's/(int)//'`
                   case $checkinsertdate in
@@ -224,7 +216,4 @@
 
 rm -v $transdir/.check >> $scriptlog 2>&1 
-
-#rsync -av $transdir/ $extern >> $scriptlog 2>&1 
-#rsync -av --delete $transdir/ $extern >> $scriptlog 2>&1 
 
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/correcttime
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/correcttime	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/correcttime	(revision 7460)
@@ -20,9 +20,20 @@
 #   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 runs the timing correction for all run, that need the timing
+# correction
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each run the timing correction is done 
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
+#
+# This script was needed for the data between 06/2004 and 02/2005 (including
+# this months). 
 #
 
@@ -56,6 +67,6 @@
 esac
 
+# retrieving runs from todo file
 runs=(`cat $listpath/ToDo-$table-$column.txt`)
-
 if [ "$runs" = "" ]
 then 
@@ -66,5 +77,4 @@
 
 echo "runs: "${runs[@]}
-
 for run in ${runs[@]}
 do 
@@ -80,5 +90,5 @@
   timecorrpath=$outpath"/timecorrlogs"
   echo "timecorrpath: "$timecorrpath
-  make dir $timecorrpath 
+  makedir $timecorrpath 
   
   check1=0
Index: trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 7460)
@@ -20,9 +20,22 @@
 #   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 launches the datacheck for all runs, which are not yet 
+# checked
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each run the following steps are done: 
+#  - filldotraw.C
+#  - sinope (once for data and once for calibration events)
+#  - fillsinope
+#  - reset ExclusionsDone, so that the result from the datacheck can be 
+#    taken into account when doexclusions is running the next time
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -46,5 +59,4 @@
 scriptlogpath=$logpath/run/dodatacheck/`date +%Y/%m`
 makedir $scriptlogpath
-
 scriptlog=$scriptlogpath/dodatacheck-$datetime.log
 
@@ -53,9 +65,10 @@
 makedir $getstatuslogpath >> $scriptlog 2>&1
 
+# check if there are already todo files
 echo "checking if other todo-files are there" >> $scriptlog 2>&1
 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
+   echo " -> choose one file and start datacheck " >> $scriptlog 2>&1
 else
    date > $lockpath/lock-getting-dodatacheck-list.txt >> $scriptlog 2>&1 
@@ -70,21 +83,16 @@
    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 datacheck" >> $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 -> do datacheck" >> $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 -> do datacheck" >> $scriptlog 2>&1;;
+      *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+   esac
    rm -v $lockpath/lock-getting-dodatacheck-list.txt >> $scriptlog 2>&1
 fi
 
 
+# finding a todo file
 nr=bla
 echo "finding the right todo-file" >> $scriptlog 2>&1
@@ -92,5 +100,4 @@
 
 echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
-
 for todofile in ${todofiles[@]}
 do 
@@ -120,6 +127,6 @@
 
 
+# get run(s) from todo file
 runs=(`cat $todofile`)
-
 if [ "$runs" = "" ]
 then 
@@ -131,6 +138,6 @@
 fi
 
+# processing run(s)
 echo "runs: "${runs[@]} >> $scriptlog 2>&1
-
 for run in ${runs[@]}
 do 
@@ -143,7 +150,9 @@
    date=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw | cut -c 22-31`
    echo "date: "$date >> $scriptlog 2>&1
+   # for sinope the date is needed in the format YYYY-MM-DD
    date2=`echo $date | sed -e 's/\//-/g'`
    echo "date2: "$date2 >> $scriptlog 2>&1
 
+   # running filldotraw
    filldotrawpath=$logpath/filldotraw/$date
    makedir $filldotrawpath >> $scriptlog 2>&1
@@ -160,4 +169,5 @@
    esac
    
+   # running sinope 
    sinopepath=$datapath/sinope/$date
    makedir $sinopepath >> $scriptlog 2>&1
@@ -183,4 +193,5 @@
    done
    
+   # running fillsinope
    fillsinopepath=$logpath/fillsinope/$date
    makedir $fillsinopepath >> $scriptlog 2>&1
@@ -191,5 +202,5 @@
 
    case $check3 in 
-       1)   echo "check3=$check3 -> everything ok -> set exclusions..." >> $scriptlog 2>&1
+       1)   echo "check3=$check3 -> everything ok -> set status..." >> $scriptlog 2>&1
             ;;
        *)   echo "check3=$check3 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
@@ -197,5 +208,6 @@
    esac
 
-   echo "resetting the status for fExclusions done for date $date2" >> $scriptlog 2>&1
+   # resetting the status for exclusions
+   echo "resetting the status for fExclusionsDone for date $date2" >> $scriptlog 2>&1
    resetlogpath=$logpath/resetexclusions/$date
    echo "resetlogpath: $resetlogpath" >> $scriptlog 2>&1
@@ -212,4 +224,5 @@
    esac
 
+   # set status
    echo "inserting the status for the datacheck for run $run into the db" >> $scriptlog 2>&1
    setstatuslogpath=$logpath/setstatus/datacheck/$date
Index: trunk/MagicSoft/Mars/datacenter/scripts/doexclusions
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/doexclusions	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/doexclusions	(revision 7460)
@@ -20,9 +20,18 @@
 #   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 launches the excluding of runs for all days for which 
+# this step is needed. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then the run are excluded for each date in the todolist using the 
+# macro doexclusions.C
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -46,5 +55,4 @@
 scriptlogpath=$logpath/run/doexclusions/`date +%Y/%m`
 makedir $scriptlogpath
-
 scriptlog=$scriptlogpath/doexclusions-$datetime.log
 
@@ -53,4 +61,5 @@
 makedir $getstatuslogpath >> $scriptlog 2>&1
 
+# check if the script is already running
 date > $lockpath/lock-doexclusions.txt >> $scriptlog 2>&1 
 checklock0=$?
@@ -64,5 +73,5 @@
 esac
 
-
+# get the todo list
 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)//'`
@@ -70,9 +79,12 @@
 case $check0 in 
    1)   echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1;;
-   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+   *)   echo "check0=$check0 -> ERROR -> could not get todo list -> exit" >> $scriptlog 2>&1
+	rm -v $todofile >> $scriptlog 2>&1
+   	rm -v $lockpath/lock-doexclusions.txt >> $scriptlog 2>&1
+	date  >> $scriptlog 2>&1
+	exit;;
 esac
 
 dates=(`cat $todofile`)
-
 if [ "$dates" = "" ]
 then 
@@ -84,6 +96,6 @@
 fi
 
+# do exclusions for each date in the todo file
 echo "dates: "${dates[@]} >> $scriptlog 2>&1
-
 for date in ${dates[@]}
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/doqualityplots
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/doqualityplots	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/doqualityplots	(revision 7460)
@@ -20,9 +20,15 @@
 #   Author(s): Daniela Dorner  08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script produces the qualityplots in the web by executing the macro 
+# plotdb.C 
+# 
+# After checking, if the script is already running, the plots are produced 
+# (ps and root file). Then they are moved to the webdirectory and there png 
+# files are produced from the ps file. 
 #
 
@@ -43,4 +49,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 lockfile=$lockpath/lock-doqualityplots.txt
 date > $lockfile >> $scriptlog 2>&1 
@@ -55,5 +62,5 @@
 esac
 
-
+# producing the plots with the values from the database 
 echo "producing plots: " >> $scriptlog 2>&1
 check0=`root -q -b $macrospath/plotdb.C+\(\) | tee -a $scriptlog | grep int | sed -e 's/.*(int)//'`
@@ -66,5 +73,5 @@
 esac
 
-
+# making files available in the web
 webpath=/www/htdocs/datacenter/datacheck
 name=plotdb
@@ -74,5 +81,5 @@
 mv -v $name.{root,ps} $webpath  >> $scriptlog 2>&1
 
-echo "moving files: " >> $scriptlog 2>&1
+echo "producing png files: " >> $scriptlog 2>&1
 pstoimg -antialias -flip r270 -density 100 -type png -multipage $psfile >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/dowebplots
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dowebplots	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dowebplots	(revision 7460)
@@ -20,9 +20,14 @@
 #   Author(s): Daniela Dorner  08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script produces the plots from all root-files in the web directory
+# 
+# After checking, if the script is already running, the plots are produced:
+# With the programm showplot a ps-file is written, from which the png 
+# files are produced. 
 #
 
@@ -44,4 +49,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 lockfile=$lockpath/lock-dowebplots.txt
 date > $lockfile >> $scriptlog 2>&1 
@@ -69,5 +75,4 @@
    exit
 fi
-
 
 #produce plots for each rootfile
@@ -115,6 +120,6 @@
 #make sure, that old plots of files, that are already removed from disk, 
 #  are deleted also in the webdirectory
-#this has to be done, as ps and png files are excluded from rsync, 
-#as rsync is done with --delete option (script /home/operator/condor/webupdate
+#this has to be done, as ps and png files are excluded from rsync, and 
+#as rsync is done with --delete option (script /home/operator/condor/webupdate)
 
 #find all directories with plots
Index: trunk/MagicSoft/Mars/datacenter/scripts/filesondisk
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 7460)
@@ -20,10 +20,28 @@
 #   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 checks which files are on disk and updates the database 
+# accordingly. It is not yet running automatically. 
+# 
+# It is checking the:
+# - ccfiles
+# - cacofiles 
+#   this includes also the search for missing cacofiles:
+#   Sometimes the DAQ aborts a run and starts itself a new one. In this 
+#   cases the camera controll doesn't start a new file, as the command to 
+#   start a new run was not sent by the central control. So the caco 
+#   information is stored in the previous caco file, which has a 
+#   different runnumber. To be able to merpp the information into the 
+#   calibrated data file, the runnumber of the file containing the 
+#   information has to be found.
+#   In this script the search and inserting into the database is done 
+#   using the macros findcacofiles.C and insertcacofile.C
+# - rawfiles
+# The update in the database is done using the macro resetallruns.C
+# 
 
 user=`whoami`
@@ -39,10 +57,7 @@
 
 echo "checking disk for ccfiles..." 
-
 filename=$filesondisklogpath/ccfilesondisk-$date.txt
 column=fCCFileAvail
-
 find $subsystemdir/cc/ -name '*_S.rep' | cut -d_ -f2  > $filename
-
 
 echo "resetting runs..."
@@ -55,12 +70,8 @@
 
 
-
 echo "checking disk for cacofiles..." 
-
 filename=$filesondisklogpath/cacofilesondisk-$date.txt
 column=fCaCoFileAvail
-
 find $subsystemdir/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
-
 
 echo "resetting runs..."
@@ -71,6 +82,4 @@
    *)   echo "check0=$check0 -> ERROR -> something went wrong while resetting";;
 esac
-
-
 
 echo "checking missing cacofiles..."
@@ -83,5 +92,4 @@
 
 missingcacoruns=(`cat $filesondisklogpath/findcacofiles-$date.txt`)
-
 for missingcacorun in ${missingcacoruns[@]}
 do 
@@ -121,10 +129,7 @@
 
 
-
 echo "checking disk for rawfiles..." 
-
 filename=$filesondisklogpath/rawfilesondisk-$date.txt
 column=fRawFileAvail
-
 find $datapath -name '*.raw' | cut -d_ -f2 > $filename
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto	(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 launches the filling of the results from the calibration for 
+# all sequences of which the results are not yet in the database.
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each sequence in the todo list the calibration results are 
+# filled into the table Calibration in the database using the macros 
+# fillcalib.C and fillsignal.C 
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -44,5 +54,4 @@
 scriptlogpath=$logpath/run/fillcallisto/`date +%Y/%m/%d`
 makedir $scriptlogpath
-
 scriptlog=$scriptlogpath/runfillcallisto-$datetime.log
 
@@ -53,4 +62,5 @@
 cd $mars
 
+# check if the script is already running
 date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
 checklock0=$?
@@ -64,4 +74,5 @@
 esac
 
+# get todo file
 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)//'`
@@ -69,9 +80,12 @@
 case $check0 in 
     1)   echo "check0=$check0 -> everything ok -> run fillcallisto" >> $scriptlog 2>&1;;
-    *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+    *)   echo "check0=$check0 -> ERROR -> could not get list -> exit" >> $scriptlog 2>&1
+         rm -v $todofile >> $scriptlog 2>&1
+         rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+    	 date  >> $scriptlog 2>&1
+         exit;;
 esac
 
 sequences=(`cat $todofile`)
-
 if [ "$sequences" = "" ]
 then 
@@ -83,6 +97,6 @@
 fi
 
+# fill information into the database for all sequences in the todo file
 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
-
 for sequence in ${sequences[@]}
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillganymed
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillganymed	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillganymed	(revision 7460)
@@ -20,9 +20,18 @@
 #   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 launches the filling of the results of ganymed into the db 
+# for all datasets of which the results are not yet in the database.
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each dataset in the todo list the ganymed results are filled 
+# into the table Ganymed in the database using the macro fillganymed.C
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -52,4 +61,5 @@
 cd $mars
 
+# check if script is already running
 date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
 checklock0=$?
@@ -63,4 +73,5 @@
 esac
 
+# get todo list
 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)//'`
@@ -68,9 +79,13 @@
 case $check0 in 
     1)   echo "check0=$check0 -> everything ok -> run fillganymed" >> $scriptlog 2>&1;;
-    *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+    *)   echo "check0=$check0 -> ERROR -> could not get list -> exit" >> $scriptlog 2>&1
+         rm -v $todofile >> $scriptlog 2>&1
+         rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+    	 date  >> $scriptlog 2>&1
+         exit;;
 esac
 
+# retrieve datasets from todo file
 datasets=(`cat $todofile`)
-
 if [ "$datasets" = "" ]
 then 
@@ -82,6 +97,6 @@
 fi
 
+# run fillganymed for datasets
 echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
-
 for dataset in ${datasets[@]}
 do 
@@ -110,5 +125,5 @@
            esac
    	  ;;
-      *)   echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+      *)  echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
    esac
 done
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 7460)
@@ -20,9 +20,18 @@
 #   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 launches the filling of the results of star into the db 
+# for all sequences of which the results are not yet in the database.
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each sequence in the todo list the star results are filled 
+# into the table Star in the database using the macro fillstar.C
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -52,4 +61,5 @@
 cd $mars
 
+# check if the script is already running
 date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
 checklock0=$?
@@ -63,4 +73,5 @@
 esac
 
+# get todo list
 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)//'`
@@ -68,9 +79,13 @@
 case $check0 in 
     1)   echo "check0=$check0 -> everything ok -> run fillstar" >> $scriptlog 2>&1;;
-    *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+    *)   echo "check0=$check0 -> ERROR -> could not get list -> exit" >> $scriptlog 2>&1
+         rm -v $todofile >> $scriptlog 2>&1
+         rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+    	 date  >> $scriptlog 2>&1
+         exit;;
 esac
 
+# retrieve sequences from todo file
 sequences=(`cat $todofile`)
-
 if [ "$sequences" = "" ]
 then 
@@ -82,6 +97,6 @@
 fi
 
+# run fillstar for sequences
 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
-
 for sequence in ${sequences[@]}
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 7460)
@@ -20,9 +20,14 @@
 #   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 launches the inserting of the datasets into the db.
+#
+# Extract information (dataset number, source name, comment, observation 
+# mode) from dataset file and insert it into the database in the table 
+# DataSets using the macro insertdataset.C
 #
 
@@ -55,14 +60,19 @@
 esac
 
-
+# get all datasetfiles
 datasetfiles=(`ls $datasetpath/*/*`)
 echo "datasetfiles: "${datasetfiles[@]}  >> $scriptlog 2>&1 
 echo "" >> $scriptlog 2>&1 
 
+# extract information from dataset file and insert it into db with the macro insertdataset.C
 for datasetfile in ${datasetfiles[@]}
 do 
+   # get datasetnumber from filename
    no=`echo $datasetfile | cut -d/ -f5 | cut -c8-99 | cut -d. -f1`
+   # get datasetnumber from file and get it with 8 digits
    no2=`grep 'AnalysisNumber:' $datasetfile | sed -e 's/AnalysisNumber://g' | sed -e 's/ //g'`
    no3=`printf %08d $no2`
+   # compare the two datasetnumber 
+   # continue only if number is the same
    if [ "$no" = "$no3" ]
    then 
@@ -73,4 +83,5 @@
       continue
    fi
+   # get source name, comment and observation mode from dataset file
    source=`grep 'SourceName:' $datasetfile | sed -e 's/SourceName://g' | sed -e 's/ //g' | sed -e 's/#//g'` >> $scriptlog 2>&1 
    comment=`grep 'Comment:' $datasetfile | sed -e 's/Comment://g'` >> $scriptlog 2>&1 
@@ -94,4 +105,5 @@
    insertdatasetlog=$insertdatasetpath/insertdataset-$no3.log
 
+   # insert information into db
    check0=`root -q -b $macrospath/insertdataset.C+\("\"$no2\""\,"\"$source\""\,"\"$wobble\""\,"\"$comment\""\,kFALSE\) | tee $insertdatasetlog | grep int | sed -e 's/(int)//'`
    case $check0 in 
Index: trunk/MagicSoft/Mars/datacenter/scripts/insertsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/insertsequences	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/insertsequences	(revision 7460)
@@ -20,10 +20,16 @@
 #   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 launches the inserting of sequences into the db.
+# It is not used in the automatic processing of data, but only for 
+# inserting of manual written sequences. 
 #
+# Find manual written sequence files and insert information into the 
+# database using the macro insertsequence.C 
+# 
 
 user=`whoami`
@@ -44,4 +50,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 date > $lockpath/lock-insertsequences.txt >> $scriptlog 2>&1 
 checklock0=$?
@@ -55,9 +62,10 @@
 esac
 
-
+# finding manual written sequence files (marked by the comment '#manually changed')
 sequencefiles=(`grep -R '#manually changed' $sequpath/ | cut -c 1-42`)
 echo "sequencefiles: "${sequencefiles[@]}  >> $scriptlog 2>&1 
 echo "" >> $scriptlog 2>&1 
 
+# process sequencefiles: insert information into the database
 for sequencefile in ${sequencefiles[@]}
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/linkmc
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/linkmc	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/linkmc	(revision 7460)
@@ -20,9 +20,24 @@
 #   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script is linking the montecarlo files from the original structure
+# to a structure from which the files can be processed more easily with the
+# automatic analysis. 
+# This script is not yet running automatically. 
+#
+# original structure:
+# /montecarlo/camera/
+#
+# new structure: 
+# /montecarlo/rawfiles/YYYY/MM/DD/file.root
+# more explanation concerning the file structure can be found in the file
+# /montecarlo/rawfiles/README.txt
+#
+# First the data files are linked and then in each new directory also the 
+# pedestal and calibration file is linked. 
 #
 
@@ -38,4 +53,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 lockfile=$lockpath/lock-mclinks.txt
 date > $lockfile >> $scriptlog 2>&1 
@@ -50,5 +66,4 @@
 esac
 
-
 mccampath=/montecarlo/camera
 mcpath=/montecarlo/rawfiles
@@ -57,4 +72,5 @@
 readme=$mcpath/README.txt #file in which the information about the modes is redirected to have always an updated explanation
 
+# check if file with next runnumber is available
 if ! ls $next >> $scriptlog 2>&1
 then
@@ -64,12 +80,12 @@
 fi
 
-date >| $readme 2>&1
-
-
+
+# observation modes 
 modes=("" "Gammawobble+" "Gammanowobble0" "GammawobbleHE+" "GammanowobbleHE0" "Gammawobble0" "GammawobbleHE0" "Gammadiffuse0" "Protonnowobble0" )
-
 #be carful: 
 # w- not yet foreseen in this script
 
+# print information and explanation of structure into README.txt 
+date >| $readme 2>&1
 echo "" >> $readme 2>&1
 echo "Explanation for the structure in which the mc files are linked" >> $readme 2>&1
@@ -218,5 +234,4 @@
 done
 
-
 rm -v $lockfile >> $scriptlog 2>&1
 
@@ -225,3 +240,2 @@
 date  >> $scriptlog 2>&1
 
-
Index: trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks	(revision 7460)
@@ -20,9 +20,15 @@
 #   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 links a special callisto.rc for data, for which the 
+# calibration with the standard callisto.rc failes. 
+# 
+# The sequences with failing calibration are searched by searching for the 
+# reason of failure in the callisto.log Then the special callisto.rc is 
+# linked to the directory of the sequence. 
 #
 
@@ -41,4 +47,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 lockfile=$lockpath/lock-making-callisto-links.txt
 date > $lockfile >> $scriptlog 2>&1 
@@ -53,10 +60,12 @@
 esac
 
-
+# reason why calibration with standard callisto.rc fails
 reason="Pulse is too much to the right, cannot go beyond logain limits!"
 echo "reason: "$reason >> $scriptlog 2>&1
 
+# find files containing reason 
 files=`find $datapath/callisto -name callisto*.log`
 
+# make links for callisto.rc for which the callisto.log contains reason
 for file in $files
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/mcsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 7460)
@@ -20,10 +20,17 @@
 #   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
-#
+# This script is an intermediate solution to process the montecarlo files.
+# As soon as the montecarlo database is running, this script shall be 
+# exchanged. 
+# 
+# The script is building one sequence per directory. As the files are 
+# structured by condition, the files in one directory and such in one 
+# sequence have the same observation mode, psf, zbin, ... 
+# 
 
 user=`whoami`
@@ -38,4 +45,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 lockfile=$lockpath/lock-mcsequences.txt
 date > $lockfile >> $scriptlog 2>&1 
@@ -54,6 +62,6 @@
 mcsequpath=/montecarlo/sequences
 
+# find montecarlo directories, build one sequence per directory and write sequence file
 dirs=`find $mcpath -type d`
-
 for dir in ${dirs[@]}
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/movingrawfiles	(revision 7460)
@@ -20,24 +20,30 @@
 #   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 moving the rawfiles from the directory 
+# /magic/datacenter/fromtape/rawdata to the structure 
+# /magic/data/rawfiles/YYYY/MM/DD
+# 
 
 umask 0002
 
+# change permission for files 
+# perhaps needed as the tapes are read by the user tape 
 ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/rawdata/*
 # output for chmod with -v or -c (only changes)
+# for files transferes via internet perhaps also needed for user lapalma
 
+# find rawfiles
 rawfiles=`find /magic/datacenter/fromtape/rawdata/ -name '*.*'`
-
 for rawfile in $rawfiles
 do 
-#  echo "file: "$rawfile
+# workaround for rawfiles with wrong timing
 #  newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles-wrong-timing/g' -e 's/_/\//1' -e 's/_/\//1'`
   newrawfile=`echo $rawfile | sed -e 's/center\/fromtape\/rawdata/\/rawfiles/g' -e 's/_/\//1' -e 's/_/\//1'`
-#  echo "new file: "$newrawfile
   newdir=`dirname $newrawfile`
-#  echo "newdir: "$newdir
   if [ ! -d $newdir ]
   then
@@ -47,5 +53,4 @@
 
   mv -v $rawfile $newrawfile
-
 done
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/movingsubsystemfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/movingsubsystemfiles	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/movingsubsystemfiles	(revision 7460)
@@ -20,13 +20,21 @@
 #   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 moving the subsystemfiles from the directory 
+# /magic/datacenter/fromtape to the structure 
+# /magic/subsystemdata/subsystem/YYYY/MM/DD
+# 
 
 umask 0002
 
+# change permission for files 
+# perhaps needed as the tapes are read by the user tape 
 ssh tape@dc07 chmod -R g+w /magic/datacenter/fromtape/{ccdata,cacodata,amc,daqlog}/* 
 
+# find subsystem files
 subsysfiles=`find /magic/datacenter/fromtape/ccdata/ -name '*.*'`
 subsysfiles=("${subsysfiles[@]}" `find /magic/datacenter/fromtape/daqlog/ -name '*.*'`)
@@ -34,11 +42,9 @@
 subsysfiles=("${subsysfiles[@]}" `find /magic/datacenter/fromtape/amc/ -name '*.*'`)
 
+# moving subsystem files
 for subsysfile in ${subsysfiles[@]}
 do 
-#  echo "file: "$subsysfile
   newsubsysfile=`echo $subsysfile | sed -e 's/datacenter\/fromtape/subsystemdata/g' -e 's/daqlog/daq__/g' -e 's/ccdata/cc/g' -e 's/cacodata/caco/g' -e 's/_/\//1' -e 's/_/\//1' -e 's/\/\///g'`
-#  echo "new file: "$newsubsysfile
   newdir=`dirname $newsubsysfile`
-#  echo "newdir: "$newdir
   if [ ! -d $newdir ]
   then
@@ -48,5 +54,4 @@
 
   mv -v $subsysfile $newsubsysfile
-
 done
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences	(revision 7460)
@@ -20,9 +20,14 @@
 #   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script is an intermediate solution to process the montecarlo files.
+# As soon as the montecarlo database is running, this script shall be 
+# exchanged. 
+# 
+# The script is processing the montecarlo sequences: callisto and star
 #
 
@@ -38,4 +43,5 @@
 date >> $scriptlog 2>&1
 
+# check if script is already running
 lockfile=$lockpath/lock-processmcsequences.txt
 date > $lockfile >> $scriptlog 2>&1 
@@ -50,5 +56,4 @@
 esac
 
-
 mcpath=/montecarlo/rawfiles
 mccalpath=/montecarlo/callisto
@@ -57,8 +62,8 @@
 callistorc=$setuppath/callisto/callisto.rc
 
-sequfiles=`find $mcsequpath -type f`
-
 cd $mars
 
+# find montecarlo sequence files
+sequfiles=`find $mcsequpath -type f`
 for sequfile in ${sequfiles[@]}
 do 
@@ -69,9 +74,10 @@
    makedir $caloutpath >> $scriptlog 2>&1
    
+   # continue with next sequence, if sequence is already processed 
+   #  or processing  of sequence is just running
    if ls $caloutpath/.done >> $scriptlog 2>&1
    then 
       continue
    fi
-   
    if ls $caloutpath/.doing >> $scriptlog 2>&1
    then 
@@ -79,8 +85,8 @@
    fi
    
+   # lock file
    touch $caloutpath/.doing
-   
    echo "processing sequ $sequfile" >> $scriptlog 2>&1
-   
+   # find callisto.rc file
    if [ -e $caloutpath/callisto.rc ]
    then
@@ -92,9 +98,9 @@
       callistorcseq=$caloutpath/callisto.rc
    fi
-   
+   # calibrate data
    echo "./callisto -mc -f -b -q --ind=$mcpath/$date --log=$caloutpath/callisto$sequno.log --html=$caloutpath/callisto$sequno.html --out=$caloutpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null" >> $scriptlog 2>&1
    ./callisto -mc -f -b -q --ind=$mcpath/$date --log=$caloutpath/callisto$sequno.log --html=$caloutpath/callisto$sequno.html --out=$caloutpath --config=$callistorcseq $sequfile 2>> $scriptlog > /dev/null
    check1=$?
-  
+   # if calibration worked -> run star for sequence
    case $check1 in
       0)   echo "check1=$check1 -> everything ok..." >> $scriptlog 2>&1
@@ -103,4 +109,5 @@
            imgoutpath=$mccalpath/$no/$sequno
            makedir $imgoutpath >> $scriptlog 2>&1
+           
            ./star -b -q -v4 -f -mc --log=$imgoutpath/star$sequno.log --html=$imgoutpath/star$sequno.html --ind=$caloutpath --out=$imgoutpath $sequfile  2>> $scriptlog> /dev/null
            check2=$?
@@ -118,5 +125,4 @@
 done
 
-
 rm -v $lockfile >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/rmlocks
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/rmlocks	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/rmlocks	(revision 7460)
@@ -20,9 +20,19 @@
 #   Author(s): Daniela Dorner  08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script is removing lock files which are older than 12 hours. 
+# 
+# Each process in the automatic analysis is writing a lock file. As these 
+# processes are launched with condor, they are stopped after 12 hours, if 
+# they are still running. In this case the lock files are not removed. 
+# 
+# By comparing the date of the lock file and the current date, the 
+# running time of a process is determined and if it is bigger than 12 
+# hours (which means that the process has been already kill by condor) the 
+# lock file is removed
 #
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 7459)
+++ 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
Index: trunk/MagicSoft/Mars/datacenter/scripts/runganymed
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runganymed	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runganymed	(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 ganymed for datasets.
+# 
+# In the case of ganymed only one dataset is processed. Despite of 
+# that the structure of the script is such, that also more datasets could
+# be processed. The restriction to one dataset has been made, as ganymed 
+# takes some time. There's one todo file per dataset. 
+# First the script searches for a todo file. Then ganymed is run for the 
+# dataset from this todo file. 
+#
+# the ganymed.rc files are stored in the setup directory
 #
 
@@ -45,5 +55,4 @@
 scriptlogpath=$logpath/run/ganymed/`date +%Y/%m/%d`
 makedir $scriptlogpath
-
 scriptlog=$scriptlogpath/runganymed-$datetime.log
 
@@ -54,4 +63,5 @@
 cd $mars
 
+# check if getting of list is already running
 date > $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
 checklock0=$?
@@ -65,4 +75,5 @@
 esac
 
+# finding todo file
 echo "checking if other todo-files are there" >> $scriptlog 2>&1
 if  ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
@@ -82,9 +93,8 @@
 rm -v $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
 
+# choosing todo file
 nr=bla
 echo "finding the right todo-file" >> $scriptlog 2>&1
 todofiles=`ls $listpath/ToDo-$table-$column-*`
-
-#echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
 
 for todofile in ${todofiles[@]}
@@ -114,7 +124,6 @@
 esac
 
-
+# retrieve dataset from todo file
 datasets=(`cat $todofile`)
-
 if [ "$datasets" = "" ]
 then 
@@ -126,6 +135,6 @@
 fi
 
+# run ganymed for dataset
 echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
-
 for dataset in ${datasets[@]}
 do 
@@ -138,4 +147,5 @@
   datasetfile="$datasetpath/$no/dataset$no2.txt"
   echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
+  # get observation mode to choose ganymed.rc file
   wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1 
   wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1 
Index: trunk/MagicSoft/Mars/datacenter/scripts/runstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runstar	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runstar	(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 star for sequence.
+# 
+# In the case of star 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 star
+# takes some time. There's one todo file per sequence. 
+# First the script searches for a todo file. Then star is run for the 
+# sequence from this todo file. 
+#
+# the star.rc files are taken from the mars directory
 #
 
@@ -53,4 +63,5 @@
 cd $mars
 
+# check if getting of list is already running
 date > $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
 checklock0=$?
@@ -64,4 +75,5 @@
 esac
 
+# finding todo file
 echo "checking if other todo-files are there" >> $scriptlog 2>&1
 if  ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
@@ -81,9 +93,8 @@
 rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
 
+# choosing todo file
 nr=bla
 echo "finding the right todo-file" >> $scriptlog 2>&1
 todofiles=`ls $listpath/ToDo-$table-$column-*`
-
-#echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
 
 for todofile in ${todofiles[@]}
@@ -114,6 +125,6 @@
 
 
+# retrieve sequence from todo file
 sequences=(`cat $todofile`)
-
 if [ "$sequences" = "" ]
 then 
@@ -125,6 +136,6 @@
 fi
 
+# run star for sequence
 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
-
 for sequence in ${sequences[@]}
 do 
Index: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 7460)
@@ -20,9 +20,11 @@
 #   Author(s): Daniela Dorner  05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This a resource file for the scripts, in which the standard paths and 
+# functions, which are needed more often are stored. 
 #
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles	(revision 7459)
+++ trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles	(revision 7460)
@@ -20,9 +20,18 @@
 #   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 launches the writing of the sequence files for all sequences
+# for which this step is needed. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then the sequence file is written for each sequence in the todolist using
+# the macro writesequencefile.C
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -52,4 +61,5 @@
 cd $mars
 
+# check if script is already running
 date > $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
 checklock0=$?
@@ -63,4 +73,5 @@
 esac
 
+# get todo list
 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)//'`
@@ -68,9 +79,13 @@
 case $check0 in 
     1)   echo "check0=$check0 -> everything ok -> run writesequencefiles" >> $scriptlog 2>&1;;
-    *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
+    *)   echo "check0=$check0 -> ERROR -> could not get todo list -> exit" >> $scriptlog 2>&1
+         rm -v $todofile >> $scriptlog 2>&1
+         rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+         date  >> $scriptlog 2>&1
+         exit;;
 esac
 
+# get sequences from todo file
 sequences=(`cat $todofile`)
-
 if [ "$sequences" = "" ]
 then 
@@ -82,6 +97,6 @@
 fi
 
+# write sequence file for all sequences in todo file
 echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
-
 for sequence in ${sequences[@]}
 do 
