Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 8230)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 8231)
@@ -31,4 +31,8 @@
      - added (script to produce ganymed.rc files with different sets of
        cuts and to run ganymed and sponde for these sets)
+   
+   * scripts/processsequence:
+     - added function checkreturncode
+     - improved logging in case of an error
    
    * datacenter/macros/buildsequenceentries.C
Index: /trunk/MagicSoft/Mars/scripts/processsequence
===================================================================
--- /trunk/MagicSoft/Mars/scripts/processsequence	(revision 8230)
+++ /trunk/MagicSoft/Mars/scripts/processsequence	(revision 8231)
@@ -66,10 +66,34 @@
    echo ""
    echo "Remarks: "
-   echo    " - you can set the variables (or part of it) also in the script "
+   echo    " - you can set the needed variables also in the script "
    echo    " - you have to set the outpath and either the sequence number or the sequence file"
    echo    "    (if both is set, the sequence given by the sequencefile is processed)"
+   echo    " - you have to execute the script from your mars directory"
    echo "" 
    exit
 }
+
+function checkreturncode()
+{
+   case $check in 
+      0)  echo "$program finished sucessfully"
+          echo ""
+          ;;
+     [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" ]
+          then 
+             echo -n " - for more details see http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
+          fi
+          echo " you executed the following command: "$command
+          exit
+          ;;
+      *)  echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
+          echo -n " $program returned a signal > 127 ($check)"
+          echo " you executed the following command: "$command
+          exit;;
+   esac
+}
+
 
 interactive="yes"
@@ -80,7 +104,4 @@
            --sequ)  shift
                     sequence=$1
-                    ;;
-           --mars)  shift
-                    mars=$1
                     ;;
             --out)  shift
@@ -136,9 +157,9 @@
    echo " sequence: "$sequence
    echo " sequfile: "$sequfile
-   if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
-   then 
+#   if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
+#   then 
       calpath=$outpath"/callisto/$n8"
       echo " path where calibration files are stored : "$calpath
-   fi
+#   fi
    if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
    then 
@@ -148,9 +169,9 @@
 else
    echo " sequfile: "$sequfile
-   if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
-   then 
+#   if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
+#   then 
       calpath=$outpath"/callisto"
       echo " path where calibration files are stored : "$calpath
-   fi
+#   fi
    if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
    then 
@@ -185,17 +206,12 @@
    mkdir -pv $calpath
 
-   echo "run callisto..."
-   echo "./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile "
-   ./callisto -b -q -f --log=$calpath/callisto$sequence.log --out=$calpath $sequfile 
+   program=callisto
+   echo "run $program..."
+   logfile=$calpath/$program$sequence.log
+   command="./$program -b -q -f --log=$logfile --out=$calpath $sequfile "
+   echo $command 
+   $command
    check=$?
-   case $check in 
-      0)  echo "callisto finished sucessfully"
-          echo "";;
-      *)  echo -n "ERROR: callisto returned $check - please check "
-          echo -n "http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
-          echo " for more details"
-          exit;;
-   esac
-
+   checkreturncode
 
    calfiles=`find $calpath -name [2][0][0-2][0-9][0,1][0-9][0-3][0-9]_*_Y_*.root`
@@ -214,6 +230,6 @@
 
       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`
-      cacofile=`find /magic/subsystemdata/caco/ -name dc_[2][0][0-2][0-9]_[0,1][0-9]_[0-3][0-9]_*${runno}_*.txt`
+      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`
       echo "runno: "$runno
       echo "ccfile: "$ccfile
@@ -245,26 +261,21 @@
          done
       fi
+
+      program=merppccupdate
+      logfile=$merpplogpath/$program$runno.log
+      command="./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
+      echo $command
+      $command
+      check=$?
+      checkreturncode
       
-      logfile=$merpplogpath/merppccupdate$runno.log
-      echo "./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
-      ./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile
+      program=merppcacoupdate
+      logfile=$merpplogpath/$program$runno.log
+      command="./merpp -u --log=$logfile --auto-time $cacofile $calfile"
+      echo $command
+      $command
       check=$?
-      case $check in
-         0)  ;;
-         *)  echo "ERROR: merppccupdate returned $check "
-             echo "please check the logfile $logfile "
-             exit;;
-      esac
-
-      logfile=$merpplogpath/merppcacoupdate$runno.log
-      echo "./merpp -u --log=$logfile --auto-time $cacofile $calfile "
-      ./merpp -u --log=$logfile --auto-time $cacofile $calfile
-      check=$?
-      case $check in
-         0)  ;;
-         *)  echo "ERROR: merppcacoupdate returned $check "
-             echo "please check the logfile $logfile "
-             exit;;
-      esac
+      checkreturncode
+      
    done
    echo "merppupdate is finished"
@@ -276,25 +287,20 @@
    mkdir -pv $starpath
 
-   echo "run star..."
-   logfile=$starpath/star$sequence.log
+   program=star
+   echo "run $program..."
+   logfile=$starpath/$program$sequence.log
    if ! ls $calpath
    then 
-      echo "couldn't find $calpath => taking standard inpath for star"
-      echo "./star -b -q -f --log=$logfile --out=$starpath $sequfile "
-      ./star -b -q -f --log=$logfile --out=$starpath $sequfile
+      echo "couldn't find $calpath => taking standard inpath for $program"
+      command="./$program -b -q -f --log=$logfile --out=$starpath $sequfile"
+      echo $command
+      $command
    else
-      echo "./star -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile "
-      ./star -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile
+      command="./$program -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile"
+      echo $command
+      $command
    fi
    check=$?
-   case $check in 
-      0)  echo "star finished sucessfully"
-          echo "";;
-      *)  echo "ERROR: star returned $check - please check "
-          echo "please check the logfile $logfile "
-          exit;;
-   esac
-
-   echo "star is finished "
-fi
-
+   checkreturncode
+fi
+
