Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 8485)
+++ trunk/MagicSoft/Mars/Changelog	(revision 8486)
@@ -23,4 +23,7 @@
    * datacenter/scripts/runcallisto:
      - bugfix (typo in getting date for finding cc and cacofile)
+
+   * scripts/merppupdate:
+     - added (script to merpp update already calibrated files) 
 
 
Index: trunk/MagicSoft/Mars/scripts/merppupdate
===================================================================
--- trunk/MagicSoft/Mars/scripts/merppupdate	(revision 8486)
+++ trunk/MagicSoft/Mars/scripts/merppupdate	(revision 8486)
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# ========================================================================
+#
+# *
+# * This file is part of MARS, the MAGIC Analysis and Reconstruction
+# * Software. It is distributed to you in the hope that it can be a useful
+# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+# * It is distributed WITHOUT ANY WARRANTY.
+# *
+# * Permission to use, copy, modify and distribute this software and its
+# * documentation for any purpose is hereby granted without fee,
+# * provided that the above copyright notice appear in all copies and
+# * that both that copyright notice and this permission notice appear
+# * in supporting documentation. It is provided "as is" without express
+# * or implied warranty.
+# *
+#
+#
+#   Author(s): Daniela Dorner  05/2007 <mailto:dorner@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2007
+#
+#
+# ========================================================================
+#
+#
+#
+##############################################################################
+#
+# This script can be used to do the merppupdate for already calibrated data.
+#
+# You have to set the path, where your calibrated files are stored.
+# 
+##############################################################################
+
+# to be set by the user: 
+# the directory, where the *_Y_*-files of your calibration are stored
+outpath=
+
+calfiles=`find $outpath -name 20_*_Y_*_E.root`
+
+echo "calfiles: "$calfiles
+
+for calfile in ${calfiles[@]}
+do 
+   echo "updating $calfile..."
+   
+   merpplogpath=$outpath"/merpplogs"
+   if [ ! -d $merpplogpath ]
+   then
+     mkdir -pv $merpplogpath 
+     if [ ! -d $merpplogpath ]
+     then
+        echo "could not make merpplogpath "$merpplogpath 
+        exit
+     fi
+   fi
+   
+   runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
+   date=`date --date \`basename $calfile | cut -d_ -f1\` +%Y/%m/%d`
+   ccfile=`find /magic/subsystemdata/cc/$date -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
+   cacofile=`find /magic/subsystemdata/caco/$date -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_*.txt`
+   echo "runno: "$runno 
+   echo "ccfile: "$ccfile 
+   if [ "$ccfile" = "" ]
+   then
+      echo "no ccfile found for run "$runno 
+      break
+   fi
+   if [ "$cacofile" = "" ]
+   then 
+      echo "cacofile with no $runno not found" >> $scriptlog 2>&1
+      echo "finding cacofile..." >> $scriptlog 2>&1
+      for (( i = 0; i <= 10; i++ ))
+      do 
+         newrun=`echo $runno - $i | bc`
+         cacofile=`find $cacopath -name *$newrun*`
+         if [ "$cacofile" = "" ]
+         then
+            if [ $i -eq 9 ]
+            then
+               echo "no cacofile found for runno $newrun in $cacopath" >> $scriptlog 2>&1
+               break 2
+            fi   
+            continue
+         else
+            break
+         fi
+      done
+   fi
+   echo "cacofile: "$cacofile 
+   ./merpp -u --log=$merpplogpath/merppccupdate$runno.log --runfile=$runno $ccfile $calfile 
+   echo "./merpp -u --log=$merpplogpath/merppccupdate$runno.log --runfile=$runno $ccfile $calfile "
+
+   ./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --auto-time $cacofile $calfile 
+   echo "./merpp -u --log=$merpplogpath/merppcacoupdate$runno.log --auto-time $cacofile $calfile "
+   
+done
+
