Index: trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C
===================================================================
--- trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/macros/findcacofiles.C	(revision 8482)
@@ -28,6 +28,6 @@
 // ===============
 //
-// Macro to get from the database the number of the runs, for which no caco
-// file is available.
+// Macro to find caco files for runs which don't have a dedicated caco file.
+// Called by the script filesondisk
 //
 // Sometimes the DAQ aborts a run and starts itself a new one. In this cases
@@ -37,12 +37,12 @@
 // 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.
-// This is done by a script.
-// findcacofiles.C produces the input for this script. It queries from the
-// database, for which runs no caco file with the same runnumber is available
-// and writes the runnumbers into an txt file.
+// 
+// findcacofiles.C searches in the database for runs which don't have a
+// dedicated caco file, and searches for each of these runs, if one of the 10
+// previous runs has a dedicated caco file. In case one is found, it is
+// inserted into the database.
 //
 // Usage:
-//   .x findcacofiles.C+("date", "logpath")
-// date and logpath are needed only for the output file
+//   .x findcacofiles.C+
 //
 // Make sure, that database and password are corretly set in a resource
@@ -60,5 +60,5 @@
 #include <TSystem.h>
 
-#include <MSQLServer.h>
+#include "MSQLMagic.h"
 #include <TSQLRow.h>
 #include <TSQLResult.h>
@@ -67,9 +67,9 @@
 
 
-int findcacofiles(TString date, TString logpath)
+int findcacofiles()
 {
     TEnv env("sql.rc");
 
-    MSQLServer serv(env);
+    MSQLMagic serv(env);
     if (!serv.IsConnected())
     {
@@ -83,9 +83,13 @@
     cout << endl;
 
-    //get runnumbers from database
-    TString query="SELECT RunProcessStatus.fRunNumber FROM RunProcessStatus ";
-    query+=" LEFT JOIN RunData on RunData.fRunNumber=RunProcessStatus.fRunNumber ";
-    query+=" WHERE IsNull(fCaCoFileFound) and fExcludedFDAKEY=1 ";
-    query+=" and RunProcessStatus.fRunNumber > 10000 and not IsNull(fCCFileAvail)";
+    //get runnumbers and dates from database
+    TString query="SELECT RunProcessStatus.fRunNumber, ";
+    query+=" DATE_FORMAT(ADDDATE(if(fRunStart='0000-00-00 00:00:00', fRunStop, fRunStart), INTERVAL +13 HOUR), '%Y/%m/%d') ";
+    query+=" FROM RunProcessStatus ";
+    query+=" LEFT JOIN RunData ON RunData.fRunNumber=RunProcessStatus.fRunNumber ";
+    query+=" LEFT JOIN Source ON RunData.fSourceKEY=Source.fSourceKEY ";
+    query+=" WHERE IsNull(fCaCoFileFound) AND fExcludedFDAKEY=1 ";
+    query+=" AND RunProcessStatus.fRunNumber > 10000 AND NOT IsNull(fCCFileAvail)";
+    query+=" AND fTest='no'";
 
     TSQLResult *res = serv.Query(query);
@@ -96,17 +100,53 @@
     }
 
-    //create output file
-    TString filename(Form("%s/findcacofiles-%s.txt", logpath.Data(), date.Data()));
-    ofstream fout(filename, ios::app);
-    if (!fout)
-    {
-        cout << "ERROR - Cannot open file " << filename << endl;
-        return 0;
-    }
-
-    //write runnumbers into output file
+    Int_t counter=0;
+    Int_t counter2=0;
     TSQLRow *row=0;
     while ((row = res->Next()))
-        fout << (*row)[0] << endl;
+    {
+        //search nearest previous available CaCoFile
+        Int_t run=atoi((*row)[0]);
+        if (TString((*row)[1]).IsNull())
+        {
+            cout << "For run " << (*row)[0] << " fRunStart and fRunStop are 0000-00-00 00:00:00. No CaCoFile can be determined. " << endl;
+            continue;
+        }
+        cout << "CaCoFile missing for run " << (*row)[0] << " with date " << (*row)[1] << endl;
+
+        query ="SELECT MAX(fCaCoFileFound) FROM RunProcessStatus ";
+        query+=" LEFT JOIN RunData ON RunData.fRunNumber=RunProcessStatus.fRunNumber ";
+        query+=Form("WHERE DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%%Y/%%m/%%d')='%s' ",
+                    (*row)[1]);
+        query+=Form("AND RunData.fRunNumber IN (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
+                    run, run-1, run-2, run-3, run-4, run-5,
+                    run-6, run-7, run-8, run-9, run-10);
+
+        TSQLResult *res2 = serv.Query(query);
+        if (!res2)
+        {
+            cout << "Error." << endl;
+            return 0;
+        }
+        TSQLRow *row2=0;
+        row2 = res2->Next();
+        if ((*row2)[0])
+        {
+            cout << "Found CaCoFile at run " << (*row2)[0] << endl;
+            TString vals=Form("fCaCoFileAvail=Now(), fCaCoFileFound=%s", (*row2)[0]);
+            TString where=Form("fRunNumber=%d", run);
+
+            //insert found runnumber
+            if (!serv.Update("RunProcessStatus", vals,where))
+                return 0;
+            counter2+=1;
+        }
+        else
+            cout << " No caco file found for run " << run << endl;
+
+        delete res2;
+        counter+=1;
+    }
+    cout << endl << counter << " missing caco files. " << endl;
+    cout << counter2 << " caco files found and inserted. " << endl;
 
     delete res;
Index: trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/buildsequenceentries	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -32,5 +32,5 @@
 # macro buildsequenceentries.C
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -69,10 +69,9 @@
    printprocesslog "INFO build sequence entries for $date"
    year2=`echo $date | cut -c 1-4`
-   var1=$year2
-   var2=$date
    buildsequentriespath=$logpath/$program/$year2
    makedir  $buildsequentriespath >> $scriptlog 2>&1
    buildsequentrieslog=$buildsequentriespath/buildsequenceentries-$date.log
 
+   primvar=$date
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -32,5 +32,5 @@
 # checked by using the macro checkfilesavail.C 
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -68,6 +68,4 @@
    no=`printf %08d $sequence | cut -c 0-4`
    no2=`printf %08d $sequence`
-   var1=$no
-   var2=$no2
    checkfileavailpath=$logpath/$program/$no
    makedir $checkfileavailpath  >> $scriptlog 2>&1 
@@ -76,4 +74,5 @@
    sequencefile=$sequpath/$no/sequence$no2.txt
 
+   primvar=$no2
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/checklogs
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checklogs	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checklogs	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/checkstardone
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -33,5 +33,5 @@
 # the macro checkstardone.C 
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -68,6 +68,4 @@
    no=`printf %08d $dataset | cut -c 0-5`
    no2=`printf %08d $dataset`
-   var1=$no
-   var2=$dataset
    datasetfile=$datasetpath/$no/dataset`printf %08d $dataset`.txt
    
@@ -84,4 +82,5 @@
    makedir $outpath  >> $scriptlog 2>&1 
    
+   primvar=$dataset
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/checktransfer
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checktransfer	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checktransfer	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  09/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -99,5 +99,5 @@
 
 #find all dates in transfer-directory
-dates=`find $transdir/*/ -type d | grep -o --regexp=20[0-9][0-9]_[0-1][0-9]_[0-3][0-9]` >> $scriptlog 2>&1
+dates=`find $transdir/*/ -type d | grep -o --regexp=20[0-9][0-9]_[0-1][0-9]_[0-3][0-9] | sort | uniq` >> $scriptlog 2>&1
 if ! [ "$dates" = "" ]
 then 
@@ -220,5 +220,4 @@
 do
    printprocesslog "INFO process "$opticalfile
-#   echo $opticalfile
    file=`basename $opticalfile`
    year=`echo $file | cut -c 0-4`
@@ -226,8 +225,6 @@
    makedir $opticallogpath >> $scriptlog 2>&1
    opticallogfile=$opticallogpath/filloptical-$file.log
-#   echo "logfile: "$opticallogfile
   
    checkfilloptical=`root -q -b $macrospath/filloptical.C+\("\"$opticalfile\""\,kFALSE\) | tee $opticallogfile | intgrep`
-#   checkfilloptical=`root -q -b $macrospath/filloptical.C+\("\"$opticalfile\""\) | tee $opticallogfile | intgrep`
             
    case $checkfilloptical in
@@ -266,5 +263,10 @@
 
 #getting new catalogfiles 
-catfiles=`find $subsystempath/cc/ -name $magfav -newer $catalog | sort`
+for (( i=0 ; i < 31 ; i++ ))
+do
+   date=`date --date "-${i}day" +%Y/%m/%d`
+   path=$subsystempath/cc/$date
+   catfiles=$catfiles" "`find $path -name $magfav -newer $catalog`
+done
 
 for catfile in ${catfiles[@]}
Index: trunk/MagicSoft/Mars/datacenter/scripts/correcttime
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/correcttime	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/correcttime	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -31,5 +31,5 @@
 # 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
+# the function setstatus.
 #
 # This script was needed for the data between 06/2004 and 02/2005 (including
@@ -69,8 +69,6 @@
    printprocesslog "INFO run correct_raw_time for run $run"
    no=`printf %08d $run | cut -c 1-5`
-   var1=$no
-   var2=$run
    echo "getting path for run $run ... " >> $scriptlog 2>&1
-   infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[D,C,P,S]_*`
+   infile=`find $datapath/rawfiles-wrong-timing/ -name *${run}_[DCPS]_*`
    echo "infile:"$infile >> $scriptlog 2>&1
    outfile=`echo $infile | sed -e 's/-wrong-timing//g'`
@@ -86,4 +84,5 @@
    check1=0
    echo "run $program..." >> $scriptlog 2>&1
+   primvar=$run
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dodatacheck	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -36,5 +36,5 @@
 #    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
+# the function setstatus.
 #
 
@@ -63,12 +63,12 @@
 no=`printf %08d $run | cut -c 0-2`
 no2=`printf %08d $run`
-var1=$date
-var2=$no2
-rawfile=`find /magic/data/rawfiles/ -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[D,P,C,S]_*_E.raw.gz`
+query="SELECT DATE_FORMAT(ADDDATE(fRunStart, INTERVAL +13 HOUR), '%Y/%m/%d') FROM RunData where fRunNumber="$run
+date=`sendquery`
+rawfile=`find /magic/data/rawfiles/$date -name *${run}_[D,P,C,S]_*_E.raw -o -name *${run}_[DPCS]_*_E.raw.gz`
 echo "rawfile: "$rawfile >> $scriptlog 2>&1
-date=`echo $rawfile | cut -c 22-31`
 # for sinope the date is needed in the format YYYY-MM-DD
 date2=`echo $date | sed -e 's/\//-/g'`
 
+primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
 
@@ -113,13 +113,13 @@
    
    case $check2 in 
-       0)   echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
-            ;;
-       *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
-            printprocesslog "ERROR sinope $sin failed for $rawfile"
-            com=$Fsinope
-#            comadd=
-            check=$check2
-            setstatus "stop" >> $scriptlog 2>&1
-            continue 2;;
+      0)   echo " check2=$check2 -> everything ok -> go on with $program..." >> $scriptlog 2>&1
+           ;;
+      *)   echo " check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+           printprocesslog "ERROR sinope $sin failed for $rawfile"
+           com=$Fsinope
+#           comadd=
+           check=$check2
+           setstatus "stop" >> $scriptlog 2>&1
+           continue 2;;
    esac
    check2=1
@@ -182,6 +182,4 @@
 starttime="NULL"
 failedtime="NULL"
-var1=$date
-var2=$no2
 setstatus "stop" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/doexclusions
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/doexclusions	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/doexclusions	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -32,5 +32,5 @@
 # macro doexclusions.C
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -69,10 +69,9 @@
    printprocesslog "INFO do exclusions for $date"
    year2=`echo $date | cut -c 1-4`
-   var1=$year2
-   var2=$date
    doexclusionspath=$logpath/$program/$year2
    makedir $doexclusionspath >> $scriptlog 2>&1
    doexclusionslog=$doexclusionspath/doexclusions-$date.log
 
+   primvar=$date
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/doqualityplots
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/doqualityplots	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/doqualityplots	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -54,11 +54,11 @@
 
 case $check0 in 
-    1)   echo " check0=$check0 -> everything ok -> move files" >> $scriptlog 2>&1
-         printprocesslog "INFO plots successfully produced"
-         ;;
-    *)   echo " check0=$check0 -> ERROR -> couldn't create plots -> exit" >> $scriptlog 2>&1
-         printprocesslog "ERROR producing plots failed"
-         finish >> $scriptlog 2>&1
-         ;;
+   1)   echo " check0=$check0 -> everything ok -> move files" >> $scriptlog 2>&1
+        printprocesslog "INFO plots successfully produced"
+        ;;
+   *)   echo " check0=$check0 -> ERROR -> couldn't create plots -> exit" >> $scriptlog 2>&1
+        printprocesslog "ERROR producing plots failed"
+        finish >> $scriptlog 2>&1
+        ;;
 esac
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/dowebplots
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/dowebplots	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/dowebplots	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -44,9 +44,9 @@
 do
    case $opts in
-     p)  type=$OPTARG
-         echo "got programname: $type"  >> $scriptlog 2>&1
-         ;;
-     ?)  echo "usage: $(basename $0) -p programname"  >> $scriptlog 2>&1
-         ;;
+      p)  type=$OPTARG
+          echo "got programname: $type"  >> $scriptlog 2>&1
+          ;;
+      ?)  echo "usage: $(basename $0) -p programname"  >> $scriptlog 2>&1
+          ;;
    esac
 done
Index: trunk/MagicSoft/Mars/datacenter/scripts/filesondisk
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/filesondisk	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -33,5 +33,5 @@
 #   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 
+#   cases the camera control 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 
@@ -40,5 +40,5 @@
 #   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
+#   using the macro findcacofiles.C 
 # - rawfiles
 # The update in the database is done using the macro resetallruns.C
@@ -66,4 +66,8 @@
 printprocesslog "INFO checking ccfiles"
 filename=$filesondisklogpath/ccfilesondisk-$datetime.txt
+if ls $filename >/dev/null 2>&1 
+then
+   rm -v $filename >> $scriptlog 2>&1 
+fi
 column=fCCFileAvail
 find $subsystempath/cc/ -name '*_S.rep' | cut -d_ -f2  > $filename
@@ -85,7 +89,12 @@
 
 
+
 echo "checking disk for cacofiles..."  >> $scriptlog 2>&1 
 printprocesslog "INFO checking cacofiles"
 filename=$filesondisklogpath/cacofilesondisk-$datetime.txt
+if ls $filename >/dev/null 2>&1 
+then
+   rm -v $filename >> $scriptlog 2>&1 
+fi
 column=fCaCoFileAvail
 find $subsystempath/caco/ -name '*.txt' | cut -d_ -f8 | grep [0-9] > $filename
@@ -107,7 +116,7 @@
 
 date=`date +%F`
-echo "checking missing cacofiles..." >> $scriptlog 2>&1 
+echo "finding missing cacofiles..." >> $scriptlog 2>&1 
 printprocesslog "INFO checking missing cacofiles"
-check1=`root -q -b $macrospath/findcacofiles.C+\("\"$date\""\,"\"$filesondisklogpath\""\) | tee $filesondisklogpath/findcacofiles-$datetime.log | intgrep`
+check1=`root -q -b $macrospath/findcacofiles.C+ | tee $filesondisklogpath/findcacofiles-$datetime.log | intgrep`
 
 case $check1 in 
@@ -123,54 +132,4 @@
 esac
 
-printprocesslog "INFO finding missing cacofiles"
-missingcacoruns=(`cat $filesondisklogpath/findcacofiles-$date.txt`)
-for missingcacorun in ${missingcacoruns[@]}
-do 
-   runno=$missingcacorun
-   echo "missing cacofile for run "$runno >> $scriptlog 2>&1 
-   echo "-> finding cacofile" >> $scriptlog 2>&1 
-   ccfile=`find $subsystempath/cc/ -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep -and ! -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*[1-9]${runno}_[P,D,C,S]_*_S.rep` 2>/dev/null
-   echo " ccfile: "$ccfile  >> $scriptlog 2>&1 
-   if [ "$ccfile" = "" ]
-   then
-      echo " no ccfile found for run "$runno >> $scriptlog 2>&1 
-      continue
-   fi
-   for (( i = 0; i <= 10; i++ ))
-   do 
-      newrun=`echo $runno - $i | bc`
-      path=`dirname $ccfile`
-      path=`echo $path | sed -e 's/cc/caco/'`
-      cacofile=`find $path -name *$newrun* 2>/dev/null`
-      if [ "$cacofile" = "" ]
-      then
-         continue
-      else
-         printprocesslog "INFO inserting cacofile for run $missingcacorun"
-         echo " inserting cacofile $file for run $missingcacorun..." >> $scriptlog 2>&1 
-         check2=`root -q -b $macrospath/insertcacofile.C+\("\"$runno\""\,"\"$newrun\""\) | tee $filesondisklogpath/insertcacofile-$missingcacorun.log | intgrep`
-
-         case $check2 in
-            1)   echo " check2=$check2 -> everything ok -> insert is done" >> $scriptlog 2>&1 
-                 printprocesslog "INFO inserted $missingcacorun successfully"
-                 ;;
-            0)   echo " check1=$check1 -> no connection to db -> continue..." >> $scriptlog 2>&1 
-                 printprocesslog "WARN connection to DB failed"
-                 ;;
-            *)   echo " check2=$check2 -> ERROR -> something went wrong while inserting run "$missingcacorun >> $scriptlog 2>&1 
-                 printprocesslog "ERROR insertcacofile.C failed for run $missingcacorun"
-                 ;;
-         esac
-         break
-      fi
-   done
-   if [ "$cacofile" = "" ]
-   then 
-      echo " no cacofile found for run "$runno >> $scriptlog 2>&1 
-      printprocesslog "WARN no cacofile found for run $runno"
-   else
-      echo " cacofile: "$cacofile >> $scriptlog 2>&1 
-   fi
-done
 
 
@@ -178,4 +137,8 @@
 printprocesslog "INFO checking rawfiles"
 filename=$filesondisklogpath/rawfilesondisk-$datetime.txt
+if ls $filename >/dev/null 2>&1 
+then
+   rm -v $filename >> $scriptlog 2>&1 
+fi
 column=fRawFileAvail
 find $datapath/rawfiles -name '*.raw' -o -name '*.gz' | cut -d_ -f2 > $filename
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillcallisto	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -33,5 +33,5 @@
 # fillcalib.C and fillsignal.C 
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -70,6 +70,4 @@
    no=`printf %08d $sequence | cut -c 0-4`
    no2=`printf %08d $sequence`
-   var1=$no
-   var2=$no2
    path="$datapath/callisto/$no/$no2"
    signalfile=$path/signal$no2.root
@@ -81,4 +79,5 @@
 
    echo "run $program for sequence $sequence" >> $scriptlog 2>&1
+   primvar=$no2
    setstatus "start" >> $scriptlog 2>&1
    echo "run fillcalib..." >> $scriptlog 2>&1
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillganymed
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillganymed	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillganymed	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -32,5 +32,5 @@
 # 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
+# the function setstatus.
 #
 
@@ -70,6 +70,4 @@
    no=`printf %08d $dataset | cut -c 0-5`
    no2=`printf %08d $dataset`
-   var1=$no
-   var2=$no2
    path="$datapath/ganymed/$no/$no2"
    ganymedfile=$path/ganymed$no2.root
@@ -79,4 +77,5 @@
 
    echo "run $program for dataset $dataset" >> $scriptlog 2>&1
+   primvar=$no2
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/fillstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/fillstar	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -32,5 +32,5 @@
 # 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
+# the function setstatus.
 #
 
@@ -70,6 +70,4 @@
    no=`printf %08d $sequence | cut -c 0-4`
    no2=`printf %08d $sequence`
-   var1=$no
-   var2=$no2
    path="$datapath/star/$no/$no2"
    starfile=$path/star$no2.root
@@ -79,4 +77,5 @@
 
    echo "run $program for sequence $sequence" >> $scriptlog 2>&1
+   primvar=$no2
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/findnewstars
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/findnewstars	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/findnewstars	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/findnotseqruns
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/findnotseqruns	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/findnotseqruns	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/insertdatasets	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/insertsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/insertsequences	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/insertsequences	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/jobmanager
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/jobmanager	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  05/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -142,5 +142,11 @@
          echo "condor is not working -> sleeping $errorsleeptime" >> $jmscriptlog 2>&1
          printprocesslog "WARN submitting ${scripts[$i]} to condor failed"
+         if [ $errorsleeptime -lt $sleeptimelimit ]
+         then 
+            errorsleeptime=`echo " $errorsleeptime + $errorsleeptimedefault " | bc`
+         fi
          sleep $errorsleeptime
+      else
+         errorsleeptime=$errorsleeptimedefault
       fi
       date >> $jmscriptlog 2>&1
Index: trunk/MagicSoft/Mars/datacenter/scripts/linkmc
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/linkmc	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/linkmc	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -149,9 +149,9 @@
    for (( i=1 ; i <= 12 ; i++ )) 
    do 
-       if [ "${modes[$i]}" == "$testmode" ]
-       then 
-          totalmode=$i
-          break
-       fi
+      if [ "${modes[$i]}" == "$testmode" ]
+      then 
+         totalmode=$i
+         break
+      fi
    done
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/makecallistolinks	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/mcsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/mcsequences	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/movingsubsystemfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/movingsubsystemfiles	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/movingsubsystemfiles	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -45,13 +45,13 @@
 for subsysfile in ${subsysfiles[@]}
 do 
-  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'`
-  newdir=`dirname $newsubsysfile`
-  if [ ! -d $newdir ]
-  then
-    echo "make dir "$newdir
-    mkdir -p $newdir
-  fi
+   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'`
+   newdir=`dirname $newsubsysfile`
+   if [ ! -d $newdir ]
+   then
+      echo "make dir "$newdir
+      mkdir -p $newdir
+   fi
 
-  mv -v $subsysfile $newsubsysfile
+   mv -v $subsysfile $newsubsysfile
 done
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/processmcsequences	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  12/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/rmlocks
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/rmlocks	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/rmlocks	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/runcallisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcallisto	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -51,5 +51,5 @@
 sequence=$process
 
-# lock sequ
+# lock sequ for cal
 lockfile=$lockpath/lock-$table-$column-$sequence.txt
 checklock >> $scriptlog 2>&1
@@ -62,6 +62,4 @@
 no=`printf %08d $sequence | cut -c 0-4`
 no2=`printf %08d $sequence`
-var1=$no
-var2=$no2
 outpath="$datapath/$program/$no/$no2"
 makedir $outpath >> $scriptlog 2>&1
@@ -80,11 +78,22 @@
    if [ $sequence -gt 200000 ]
    then
-   	ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
+      ln -vs $callistorcmux $outpath/callisto.rc >> $scriptlog 2>&1
    else
-   	ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
+      ln -vs $callistorcnew $outpath/callisto.rc >> $scriptlog 2>&1
    fi
    callistorcseq=$outpath/callisto.rc
 fi
 
+# lock sequ for zipping
+lockfile=$lockpath/calzip$sequence.txt
+# if lockfile is already existing, 1 is returned
+if ! checklock return 1 >> $scriptlog 2>&1
+then
+   # reset lockfile name
+   lockfile=$lockpath/lock-$table-$column-$sequence.txt
+   finish >> $scriptlog 2>&1
+fi
+
+primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
 
@@ -92,4 +101,8 @@
 ./callisto -b -q -v4 -f --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath --config=$callistorcseq $sequfile  2>> $scriptlog > /dev/null
 check1=$?
+
+# remove lockfile for zip and reset lockfile name
+rm -v $lockfile >> $scriptlog 2>&1
+lockfile=$lockpath/lock-$table-$column-$sequence.txt
 
 case $check1 in
@@ -117,9 +130,11 @@
            # find cc and caco file
            # if file is missing continue with next sequence
+           date=`date --date \`basename $calfile | cut -d_ -f1 +%Y/%m/%d\``
+           ccpath=$subsystempath/cc/$date
+           cacopath=$subsystempath/caco/$date
            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 -and ! -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*[1-9]${runno}_[P,D,C,S]_*_S.rep`
+           ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
            source=`echo $ccfile | cut -d_ -f4`
-           cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_${source}.txt -and ! -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*[1-9]${runno}_${source}.txt`
-#            cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
+           cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
            if [ "$ccfile" = "" ]
            then
@@ -138,13 +153,10 @@
               do 
                  newrun=`echo $runno - $i | bc`
-                 path=`dirname $ccfile`
-                 path=`echo $path | sed -e 's/cc/caco/'`
-                 echo "path: "$path >> $scriptlog 2>&1
-                 cacofile=`find $path -name *$newrun*`
+                 cacofile=`find $cacopath -name *$newrun*`
                  if [ "$cacofile" = "" ]
                  then
                     if [ $i -eq 9 ]
                     then
-                       echo "no cacofile found" >> $scriptlog 2>&1
+                       echo "no cacofile found for runno $newrun in $cacopath" >> $scriptlog 2>&1
                        printprocesslog "ERROR cacofile $cacofile not found for $calfile"
                        com=$Fnocacofile
@@ -164,13 +176,13 @@
            check2=$?
            case $check2 in
-                   0)   echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
-                        printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
-                        ;;
-        	   *)   echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
-                        printprocesslog "ERROR merppccupdate with file $ccfile failed for $calfile"
-                        com=$Fmerppcc
-                        comadd=$runno
-                        check=$check2
-                        break ;;
+              0)   echo " check2=$check2 -> everything ok, merppccupdate worked -> continue" >> $scriptlog 2>&1
+                   printprocesslog "INFO merppupdated $calfile sucessfully with $ccfile"
+                   ;;
+              *)   echo " check2=$check2 -> ERROR -> merppccupdate failed" >> $scriptlog 2>&1
+                   printprocesslog "ERROR merppccupdate with file $ccfile failed for $calfile"
+                   com=$Fmerppcc
+                   comadd=$runno
+                   check=$check2
+                   break ;;
            esac
            echo "./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --html=$merpplogpath/merppcacoupdate$runno.html --auto-time $cacofile $calfile 2>> $scriptlog> /dev/null" >> $scriptlog 2>&1
@@ -178,13 +190,13 @@
            check3=$?
            case $check3 in
-                   0)   echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
-                        printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
-                        ;;
-        	   *)   echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
-                        printprocesslog "ERROR merppcacoupdate with file $cacofile failed for $calfile"
-                        com=$Fmerppcaco
-                        comadd=$runno
-                        check=$check3
-                        break ;;
+              0)   echo " check3=$check3 -> everything ok, merppcacoupdate worked -> continue" >> $scriptlog 2>&1
+                   printprocesslog "INFO merppupdated $calfile sucessfully with $cacofile"
+                   ;;
+              *)   echo " check3=$check3 -> ERROR -> merppcacoupdate failed" >> $scriptlog 2>&1
+                   printprocesslog "ERROR merppcacoupdate with file $cacofile failed for $calfile"
+                   com=$Fmerppcaco
+                   comadd=$runno
+                   check=$check3
+                   break ;;
            esac
         done
Index: trunk/MagicSoft/Mars/datacenter/scripts/runganymed
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runganymed	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runganymed	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -61,6 +61,4 @@
 no=`printf %08d $dataset | cut -c 0-5`
 no2=`printf %08d $dataset`
-var1=$no
-var2=$no2
 outpath="$datapath/$program/$no/$no2"
 makedir $outpath >> $scriptlog 2>&1
@@ -75,4 +73,5 @@
 fi
 
+primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/runstar
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runstar	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runstar	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -61,6 +61,4 @@
 no=`printf %08d $sequence | cut -c 0-4`
 no2=`printf %08d $sequence`
-var1=$no
-var2=$no2
 outpath="$datapath/$program/$no/$no2"
 inpath=`echo $outpath | sed -e 's/star/callisto/'`
@@ -69,4 +67,5 @@
 sequfile="$sequpath/$no/sequence$no2.txt"
 
+primvar=$no2
 setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/scriptlauncher	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -37,27 +37,30 @@
 scriptlog=$runlogpath/scriptlauncher`date +%F`.log
 
-echo `date`": starting $0 $@"  >> $scriptlog 2>&1
+echo `date`": starting $0 $@" >> $scriptlog 2>&1
 
 path=`dirname $0`
 date=`date +%Y-%m-%d`
 
-for i in $@
+scripts=( `echo $@ | sed -e 's/allatthesametime//'` )
+num=${#scripts[@]}
+echo "$num scripts have to be launched" >> $scriptlog 2>&1
+i=0
+
+while [ $i -lt $num ]
 do 
-   if [ "$i" = "allatthesametime" ]
-   then 
-      continue
-   fi
-   echo " launching $i..." >> $scriptlog 2>&1
-   pid=`/usr/local/bin/condor_submit -a path=$path -a prog=$i -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2`
+   echo " launching ${scripts[$i]}..." >> $scriptlog 2>&1
+   pid=`/usr/local/bin/condor_submit -a path=$path -a prog=${scripts[$i]} -a date=$date -a dir=$runlogpath $path/run.condor 2>> $errorlog | grep 'submitted to cluster' | cut -dr -f2`
    if [ "$pid" = "" ]
    then 
       echo `date`" WARN condor is not working " >> $errorlog 2>&1
-      printprocesslog "WARN submitting $i to condor failed"
+      printprocesslog "WARN submitting ${scripts[$i]} to condor failed"
+      continue
    fi
    if ! echo $@ | grep "allatthesametime" >/dev/null 2>$errorlog
    then
-      echo "  waiting for $i to be done..." >> $scriptlog 2>&1
+      echo "  waiting for ${scripts[$i]} to be done..." >> $scriptlog 2>&1
       /usr/local/bin/condor_wait $runlogpath/condor-$date.log $pid >/dev/null 2>$errorlog
    fi
+   i=`expr $i + 1`
 done
 echo `date`": all done/submitted." >> $scriptlog 2>&1
Index: trunk/MagicSoft/Mars/datacenter/scripts/setup
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/setup	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/setup	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -63,5 +63,5 @@
 sleeptime=30 #30
 sleeptimelimit=360 #360
-errorsleeptime=60 #60
+errorsleeptimedefault=60 #60
 max=18 #maximum number of processes
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/sourcefile
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/sourcefile	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  05/2005 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -47,13 +47,13 @@
    if [ ! -d $@ ]
    then
-     mkdir -pv $@ 
-     if [ ! -d $@ ]
-     then 
-        echo "could not make dir "$@
-        rm -v $todofile
-        rm -v $lockfile
-        date
-        exit
-     fi
+      mkdir -pv $@ 
+      if [ ! -d $@ ]
+      then 
+         echo "could not make dir "$@
+         rm -v $todofile
+         rm -v $lockfile
+         date
+         exit
+      fi
    fi
 }
@@ -133,5 +133,5 @@
 function finish()
 {
-   if ls $todofile >/dev/null 2>&1
+   if ! [ "$todofile" = "" ] && ls $todofile >/dev/null 2>&1
    then 
       rm -v $todofile
@@ -160,33 +160,11 @@
    checklock0=$?
    case $checklock0 in
-       0)   echo " checklock0=$checklock0 -> continue " ;;
-       1)   echo " checklock0=$checklock0 -> file $lockfile exists -> exit"
-            date
-            exit;;
-       *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
+      0)   echo " checklock0=$checklock0 -> continue " ;;
+      1)   echo " checklock0=$checklock0 -> file $lockfile exists"
+           date
+           $@
+           exit;;
+      *)   echo " checklock0=$checklock0 -> something went completely wrong" ;;
    esac
-}
-
-# function calling the macro, which is producing the todo-list
-function getdolistroot()
-{
-   datetime=`date +%F-%H-%M-%S`
-   year=`date +%Y`
-   date=NULL
-
-   getstatuslogpath=$logpath/getstatus/$program/$year
-   getstatuslog=$getstatuslogpath/getstatus-$table-$column-$datetime.log
-   makedir $getstatuslogpath
-
-   # get todo list
-   echo "getting todo list..."
-   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, got todo list -> run $program";;
-      *)   echo " check0=$check0 -> ERROR -> could not get todo list -> exit"
-           finish ;;
-   esac
-
 }
 
@@ -222,26 +200,26 @@
                ;;
        stop)   case $check in
-                 ok)  echo "setstatus stop - ok"
-                      statustime="Now()"
-                      ;;
-                 no)  echo "setstatus stop - nothing new"
-                      check="ok"
-                      ;;
-                  *)  echo "setstatus stop - failed"
-                      starttime=noreset
-                      if [ "$check" == "" ]
-                      then
-                         returncode=1
-                      else
-                         returncode=$check
-                      fi
-                      failedcode=$com
-                      if ! [ "$comadd" = "" ]
-                      then
-                         failedcodeadd=$comadd
-                      fi
-                      failedtime="Now()"
-                      check="ok"
-                      ;;
+                  ok)  echo "setstatus stop - ok"
+                       statustime="Now()"
+                       ;;
+                  no)  echo "setstatus stop - nothing new"
+                       check="ok"
+                       ;;
+                   *)  echo "setstatus stop - failed"
+                       starttime=noreset
+                       if [ "$check" == "" ]
+                       then
+                          returncode=1
+                       else
+                          returncode=$check
+                       fi
+                       failedcode=$com
+                       if ! [ "$comadd" = "" ]
+                       then
+                          failedcodeadd=$comadd
+                       fi
+                       failedtime="Now()"
+                       check="ok"
+                       ;;
                esac
                ;;
@@ -250,24 +228,4 @@
                finish
                ;;
-   esac
-}
-
-# function calling the macro to set the status, after a process has finished
-function setstatusroot()
-{
-   # set status values
-   resetstatusvalues
-   evalstatus $@
-
-#   printstatusvalues
-   # set status
-   setstatuslogpath=$logpath/setstatus/$program/$var1
-   makedir $setstatuslogpath
-   setstatuslog=$setstatuslogpath/setstatus-$@-$program-$var2.log
-   checkstatus=`root -q -b $macrospath/setstatus.C+\("\"$var2\""\,"\"$table\""\,"\"$column\""\,"\"$statustime\""\,"\"$returncode\""\,"\"$failedcode\""\,"\"$failedcodeadd\""\,"\"$starttime\""\,"\"$failedtime\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
-   case $checkstatus in
-      1)   echo " checkstatus=$checkstatus -> everything ok, status has been set";;
-      *)   echo " checkstatus=$checkstatus -> ERROR -> step could not be set -> exit"
-           finish ;;
    esac
 }
@@ -417,6 +375,6 @@
    if [ "$reset" = "no" ]
    then
-      echo "YOU CAN'T RESET $column for $var2!!!"
-      printprocesslog "ERROR you can't reset $column for $var2"
+      echo "YOU CAN'T RESET $column for $primvar!!!"
+      printprocesslog "ERROR you can't reset $column for $primvar"
       finish
    fi
@@ -434,5 +392,5 @@
    fi
    query=$query", fFailedTime=$failedtime, fFailedCode=$failedcode, fFailedCodeAdd=$failedcodeadd, fReturnCode=$returncode "
-   query=$query" where $primary='$var2'"
+   query=$query" where $primary='$primvar'"
    echo " QUERY: "$query
    if ! mysql -s -u $us --password=$pw --host=vela $db -e " $query "
@@ -445,2 +403,19 @@
 }
 
+# function to send a mysql query
+function sendquery()
+{
+   getdbsetup
+   if ! val=`mysql -s -u $us --password=$pw --host=vela $db -e " $query "`
+   then
+      printprocesslog "ERROR could not query db (program: $program, function sendquery)"
+      return 1
+   fi
+   if [ "$val" = "NULL" ]
+   then
+      val=
+   fi
+   echo $val
+   return 0
+}
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/webupdate-callisto
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/webupdate-callisto	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/webupdate-callisto	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/webupdate-ganymed
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/webupdate-ganymed	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/webupdate-ganymed	(revision 8482)
@@ -18,7 +18,7 @@
 #
 #
-#   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
+#   Author(s): Daniela Dorner  08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/webupdate-sinope
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/webupdate-sinope	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/webupdate-sinope	(revision 8482)
@@ -18,7 +18,7 @@
 #
 #
-#   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
+#   Author(s): Daniela Dorner  08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/webupdate-star
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/webupdate-star	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/webupdate-star	(revision 8482)
@@ -18,7 +18,7 @@
 #
 #
-#   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
+#   Author(s): Daniela Dorner  08/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
Index: trunk/MagicSoft/Mars/datacenter/scripts/writedatasetfiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/writedatasetfiles	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/writedatasetfiles	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -33,5 +33,5 @@
 # the macro checkstardone.C 
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -68,6 +68,4 @@
    no=`printf %08d $dataset | cut -c 0-5`
    no2=`printf %08d $dataset`
-   var1=$no
-   var2=$dataset
    datasetpathcpl=$datasetpath/$no
    makedir $datasetpathcpl >> $scriptlog 2>&1 
@@ -75,4 +73,7 @@
    makedir $writedatasetfilelogpath >> $scriptlog 2>&1 
    logfile=$writedatasetfilelogpath/$program-$no2.log
+
+   primvar=$dataset
+   setstatus "start" >> $scriptlog 2>&1
    
    check1=`root -q -b $macrospath/writedatasetfile.C+\($dataset\,\""$datasetpathcpl\""\) | tee $logfile | intgrep`
Index: trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/writesequencefiles	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -32,5 +32,5 @@
 # the macro writesequencefile.C
 # If this was successful, the status is inserted into the database using 
-# the macro setstatus.C
+# the function setstatus.
 #
 
@@ -70,6 +70,4 @@
    no=`printf %08d $sequence | cut -c 0-4`
    no2=`printf %08d $sequence`
-   var1=$no
-   var2=$no2
    sequencepath=$sequpath/$no
    makedir $sequencepath >> $scriptlog 2>&1
@@ -80,4 +78,5 @@
 
    echo "write sequencefile for sequence $sequence" >> $scriptlog 2>&1
+   primvar=$no2
    setstatus "start" >> $scriptlog 2>&1
 
Index: trunk/MagicSoft/Mars/datacenter/scripts/zipscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/zipscript	(revision 8481)
+++ trunk/MagicSoft/Mars/datacenter/scripts/zipscript	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  09/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -30,5 +30,7 @@
 source `dirname $0`/sourcefile
 printprocesslog "INFO starting $0"
-program=zipscript
+# to give the possibility to run several zipscripts at the same time, 
+# $1 is added
+program=zipscript$1
 
 set -C
@@ -52,109 +54,54 @@
 
 for file in ${files[@]}
-do 
+do
+   echo "processing file $file..." >> $scriptlog 2>&1 
+   runno=`basename $file | cut -d_ -f2`
+   query="SELECT fSequenceFirst FROM RunData WHERE fRunNumber="$runno
+   echo " sending query: $query" >> $scriptlog 2>&1 
+   if ! seq=`sendquery`
+   then
+      echo "querying seq for run $runno from the db did not work -> continue" >> $scriptlog 2>&1
+      printprocesslog "WARN query $seq for run $runno from the db did not work"
+      continue
+   fi
+   if [ "$seq" == "" ] 
+   then
+      echo "no seq found for run $runno -> locking only run..." >> $scriptlog 2>&1
+      seq=$runno
+   fi
+   echo "locking sequence $seq..."  >> $scriptlog 2>&1 
+   lockfile=$lockpath/calzip$seq.txt
+   checklock continue >> $scriptlog 2>&1
+   query="UPDATE SequenceProcessStatus set fNotZipping=NULL WHERE fSequenceFirst=$seq"
+   echo " sending query: $query" >> $scriptlog 2>&1 
+   if ! sendquery 
+   then
+      echo "locking $seq for callisto in db did not work ..." >> $scriptlog 2>&1
+      printprocesslog "WARN locking $seq for callisto in db did not work"
+      rm -v $lockfile >> $scriptlog 2>&1
+      continue
+   fi
    echo "zipping $file ..." >> $scriptlog 2>&1
-#   if ssh pegasus nice -n 19 gzip -1f $file >> $scriptlog 2>&1
-   if ssh phoenix nice -n 19 gzip -1f $file >> $scriptlog 2>&1
-
+   if ssh -x phoenix nice -n 19 gzip -1f $file >> $scriptlog 2>&1
    then 
-      chmod a-w $file >> $scriptlog 2>&1
+      gzfile=$file".gz"
+      chmod a-w $gzfile >> $scriptlog 2>&1
+   else
+      printprocesslog "WARN zipping $file did not work"
    fi
+   echo "unlocking sequence $seq..."  >> $scriptlog 2>&1 
+   query="UPDATE SequenceProcessStatus set fNotZipping=Now() WHERE fSequenceFirst=$seq"
+   echo " sending query: $query" >> $scriptlog 2>&1 
+   if ! sendquery 
+   then
+      echo "unlocking $seq for callisto in db did not work ..." >> $scriptlog 2>&1
+      printprocesslog "ERROR unlocking $seq for callisto in db did not work"
+      rm -v $lockfile >> $scriptlog 2>&1
+      continue
+   fi
+   rm -v $lockfile >> $scriptlog 2>&1
 done
 
+lockfile=$lockpath/lock-$program.txt
 finish >> $scriptlog 2>&1
 
-
-
-# old code for running script locally
-
-#rawdatapath=$datapath/rawfiles
-##h:     0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-#pnos=( 2 2 2 2 2 2 2 2 2 2  2  2  2  2  2  2  2  2  2  2  2  2  2  2 )
-#sl1=30 #sleeping time before new directory
-#sl2=60 #sleeping time before new process check
-#
-#dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort`
-##dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort -r`
-#
-#for dir in ${dirs[@]}
-#do
-#   cont=`echo $dir | cut -d/ -f7`
-#   if [ "$cont" == "" ]
-#   then
-#      continue
-#   fi
-#
-#   if ! ls $dir/*.raw >/dev/null 2>&1
-#   then
-#      echo "no unzipped rawfiles in $dir left"
-#      continue
-#   fi
-#
-#   echo "sleeping $sl1..."
-#   sleep $sl1
-#
-#   h=`date +%k`
-#   count=`ps aux | grep gzip | grep -v grep | wc -l`
-#   echo "count: $count - h: $h - pno: ${pnos[$h]}"
-#   while [ "$count" -ge "${pnos[$h]}" ]
-#   do
-#      echo "sleeping $sl2..."
-#      sleep $sl2
-#      h=`date +%k`
-#      count=`ps aux | grep gzip | grep -v grep | wc -l`
-#      echo "count: $count - h: $h - pno: ${pnos[$h]}"
-#   done
-#   echo $dir
-#   du -hs $dir
-#   echo "gzip -1f $dir/*.raw &"
-#   gzip -1f $dir/*.raw &
-#done
-#
-
-
-# old code for running script with condor
-
-#rawdatapath=$datapath/rawfiles
-##h:     0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
-#pnos=( 2 2 2 2 2 2 2 2 2 2  2  2  2  2  2  2  2  2  2  2  2  2  2  2 )
-#sl1=30 #sleeping time before new directory
-#sl2=60 #sleeping time before new process check
-#
-#dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort`
-##dirs=`find $rawdatapath -type d | grep -v timecorrlogs | sort -r`
-#
-#for dir in ${dirs[@]}
-#do
-#   cont=`echo $dir | cut -d/ -f7`
-#   if [ "$cont" == "" ]
-#   then
-#      continue
-#   fi
-#
-#   if ! ls $dir/*.raw >/dev/null 2>&1
-#   then
-#      echo "no unzipped rawfiles in $dir left"
-#      continue
-#   fi
-#
-#   echo "sleeping $sl1..."
-#   sleep $sl1
-#
-#   h=`date +%k`
-#   count=`grep gzip .condor_run.* | wc -l`
-#   echo "count: $count - h: $h - pno: ${pnos[$h]}"
-#   while [ "$count" -ge "${pnos[$h]}" ]
-#   do
-#      echo "sleeping $sl2..."
-#      sleep $sl2
-#      h=`date +%k`
-#      count=`grep gzip .condor_run.* | wc -l`
-#      echo "count: $count - h: $h - pno: ${pnos[$h]}"
-#   done
-#   echo $dir
-#   du -hs $dir
-#   condor_run gzip -1f $dir/*.raw &
-#
-#done
-#
-
Index: trunk/MagicSoft/Mars/scripts/dospectrum
===================================================================
--- trunk/MagicSoft/Mars/scripts/dospectrum	(revision 8481)
+++ trunk/MagicSoft/Mars/scripts/dospectrum	(revision 8482)
@@ -151,24 +151,24 @@
 for (( i=0 ; i < $par3num ; i++ ))
 do 
-  for (( j=0 ; j < $par1num ; j++ ))
-  do 
-#     echo "i: $i - j: $j ------- par1: $val1 and par3: $val3"
-     dir=$resultpath/set${val1}_${val3}
-     if ! ls $dir >/dev/null 2>&1
-     then 
-        mkdir -pv $dir
-     fi
-#     rcfile=$dir/ganymed_${val1}_${val3}_onoff.rc
-     rcfile=$dir/`basename $ganymedrc` 
-     if ! ls $rcfile >/dev/null 2>&1
-     then 
-        cat $ganymedrc | sed -e s/"${par1}"/"   ${val1}"/ -e s/"${par3}"/"  ${val3}"/ > $rcfile
-     else
-        echo "rcfile $rcfile already exists"
-     fi
-     val1=`echo $val1 + $par1step | bc`
-  done
-  val3=`echo $val3 + $par3step | bc`
-  val1=$start1
+   for (( j=0 ; j < $par1num ; j++ ))
+   do 
+#      echo "i: $i - j: $j ------- par1: $val1 and par3: $val3"
+      dir=$resultpath/set${val1}_${val3}
+      if ! ls $dir >/dev/null 2>&1
+      then 
+         mkdir -pv $dir
+      fi
+#      rcfile=$dir/ganymed_${val1}_${val3}_onoff.rc
+      rcfile=$dir/`basename $ganymedrc` 
+      if ! ls $rcfile >/dev/null 2>&1
+      then 
+         cat $ganymedrc | sed -e s/"${par1}"/"   ${val1}"/ -e s/"${par3}"/"  ${val3}"/ > $rcfile
+      else
+         echo "rcfile $rcfile already exists"
+      fi
+      val1=`echo $val1 + $par1step | bc`
+   done
+   val3=`echo $val3 + $par3step | bc`
+   val1=$start1
 done
 
Index: trunk/MagicSoft/Mars/scripts/makemovie
===================================================================
--- trunk/MagicSoft/Mars/scripts/makemovie	(revision 8481)
+++ trunk/MagicSoft/Mars/scripts/makemovie	(revision 8482)
@@ -25,8 +25,17 @@
 # ========================================================================
 #
-#
-#
 ##############################################################################
 #
+# This script runs callisto with the -movie option and the corresponding 
+# rc files for a given sequence. 
+# The following movies are produced:
+# - movieSequenceNumber[mc]-withoutcut.mpg (all events)
+# - movieSequenceNumber[mc]-qualcut.mpg    (events after quality cuts)
+# - movieSequenceNumber[mc]-areacut.mpg    (events after area cut)
+# - movieSequenceNumber[mc]-thetacut.mpg   (events after theta^2 cut)
+# 
+# If no outpath is given, the movies are stored in the directory movies.
+# 
+# The script has to be executed in the Mars directory. 
 # 
 ##############################################################################
@@ -43,9 +52,4 @@
 NumEvents=500
 Threshold=3
-
-#MFEvtNumber.FileName: ganymed00001218.root
-#MFEvtNumber.Selector: ThetaSquared.fVal<0.04 && DataType.fVal>0.5
-#MMovieWrite.Filename: movie-00071431-off-all.mpg
-
 
 function usage()
@@ -83,26 +87,26 @@
 do 
    case $1 in 
-           --sequ)  shift
-                    sequence=$1
-                    ;;
-            --out)  shift
-                    outpath=$1
-                    ;;
-  --target-length)  shift
-                    TargetLength=$1
-                    ;;
-     --num-events)  shift
-                    NumEvents=$1
-                    ;;
-          -wobble)  wobble='yes'
-                    ;;
-              -mc)  mc='mc'
-                    ;;
-               -h)  usage
-                    ;;
-      *)      echo "unknown option $1 "
-              usage
-              exit
-              ;;
+               --sequ)  shift
+                        sequence=$1
+                        ;;
+                --out)  shift
+                        outpath=$1
+                        ;;
+      --target-length)  shift
+                        TargetLength=$1
+                        ;;
+         --num-events)  shift
+                        NumEvents=$1
+                        ;;
+              -wobble)  wobble='yes'
+                        ;;
+                  -mc)  mc='mc'
+                        ;;
+                   -h)  usage
+                        ;;
+                *)      echo "unknown option $1 "
+                        usage
+                        exit
+                        ;;
    esac
    shift
@@ -239,7 +243,7 @@
 for (( i=1 ; i < 4 ; i++ )) 
 do
-  command="./callisto $opts --config=$outpath2/callisto_$n8$mc-${names[$i]}.rc "
-  echo "submitting: "$command 
-  condor_run $command &
+   command="./callisto $opts --config=$outpath2/callisto_$n8$mc-${names[$i]}.rc "
+   echo "submitting: "$command 
+   condor_run $command &
 done
 
Index: trunk/MagicSoft/Mars/scripts/processsequence
===================================================================
--- trunk/MagicSoft/Mars/scripts/processsequence	(revision 8481)
+++ trunk/MagicSoft/Mars/scripts/processsequence	(revision 8482)
@@ -20,5 +20,5 @@
 #   Author(s): Daniela Dorner  10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
@@ -80,5 +80,5 @@
           echo ""
           ;;
-     [1-9]|[0-9][0-9]|1[0-1][0-9]|12[0-7])
+      [1-9]|[0-9][0-9]|1[0-1][0-9]|12[0-7])
           echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
           if [ "$program" == "callisto" ]
@@ -229,7 +229,11 @@
       mkdir -pv $merpplogpath
 
+      date=`date --date \`basename $calfile | cut -d_ -f1 +%Y/%m/%d\``
+      ccpath=$subsystempath/cc/$date
+      cacopath=$subsystempath/caco/$date
       runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
-      ccfile=`find /magic/subsystemdata/cc/ -name 20[0-2][0-9][0,1][0-9][0-3][0-9]_*${runno}_[P,D,C,S]_*_S.rep`
-      cacofile=`find /magic/subsystemdata/caco/ -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_*.txt`
+      ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
+      source=`echo $ccfile | cut -d_ -f4`
+      cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
       echo "runno: "$runno
       echo "ccfile: "$ccfile
@@ -247,9 +251,5 @@
          do
             newrun=`echo $runno - $i | bc`
-     #      echo "$missingcacorun + $i = $newrun"
-            path=`dirname $ccfile`
-            path=`echo $path | sed -e 's/cc/caco/'`
-            echo "path: "$path
-            cacofile=`find $path -name *$newrun*`
+            cacofile=`find $cacopath -name *$newrun*`
             if [ "$cacofile" = "" ]
             then
Index: trunk/MagicSoft/Mars/steps.rc
===================================================================
--- trunk/MagicSoft/Mars/steps.rc	(revision 8481)
+++ trunk/MagicSoft/Mars/steps.rc	(revision 8482)
@@ -140,5 +140,5 @@
 #SequenceProcessStatus.fCallisto: 
 SequenceProcessStatus.fCallisto.Default: no
-SequenceProcessStatus.fCallisto.Needs: SequenceProcessStatus.fSequenceFileWritten SequenceProcessStatus.fAllFilesAvail
+SequenceProcessStatus.fCallisto.Needs: SequenceProcessStatus.fSequenceFileWritten SequenceProcessStatus.fAllFilesAvail SequenceProcessStatus.fNotZipping
 SequenceProcessStatus.fCallisto.Influences: SequenceProcessStatus.fFillCallisto SequenceProcessStatus.fStar SequenceProcessStatus.fFillStar
 SequenceProcessStatus.fCallisto.Reset: yes
