Index: trunk/MagicSoft/Mars/datacenter/scripts/runcamera
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcamera	(revision 8526)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcamera	(revision 8526)
@@ -0,0 +1,138 @@
+#!/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 runs the reflector.
+#
+
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
+program=camera
+column=fCameraFileAvail
+detectordir=/home/msmeyer/MC/MagicSoft/Simulation/Detector
+
+set -C
+
+# printing input card to stdout
+function printinputcard()
+{
+   echo $cameraversion
+   echo "ct_num 1"
+   echo "ct_geom 1"
+   echo "qe_file 0 $detectordir/Data/qe-emi-coat.RFL.dat"
+   echo "input_file 0 "$mcpath"/reflector/"$date"/"$outfile
+   echo "data_file $outpath/"`echo $outfile | sed -e 's/rfl/dat/'`
+   echo "root_file $outpath/"`echo $outfile | sed -e 's/rfl/root/'`
+   echo "trigger_prop 3.0 0.25 1.0 2.0"
+   echo "trigger_single 0 4 4 2"
+   echo "nsb_on"
+   echo "nsb_mean 0.178 50"
+   echo "fadc_noise 1.3 2.4 1."
+   echo "sigma_xy_cm_spot "$spotsize
+   echo "mirror_fraction 0 0.73"
+   echo "seeds "$seeds
+   echo "nsb_directory $detectordir/StarLight/inner/"
+   echo "nsb_dir_outer $detectordir/StarLight/outer/"
+   echo "fadc_prop 1 7.8 5.0"
+   echo "fadc_outer 1 3.2 5.0"
+   echo "write_McTrig"
+   echo "write_McFadc"
+   echo "end_file"
+}
+
+
+scriptlog=$runlogpath/run$program-$datetime.log
+date >> $scriptlog 2>&1
+
+# get sequence # 
+gettodo >> $scriptlog 2>&1
+run=$process
+
+# lock sequ
+lockfile=$lockpath/lock-$table-$column-$sequence.txt
+checklock >> $scriptlog 2>&1
+
+echo "run $program for run $run..." >> $scriptlog 2>&1
+printprocesslog "INFO starting $program for run $run"
+
+primvar=$run
+setstatus "start" >> $scriptlog 2>&1
+
+echo "run $program for run $run "
+echo "create input card... "
+
+# get values for inputcard
+query="SELECT fMCRunNumber FROM MCRunData where fMCRunNumber="$run
+reflectorrunno=`sendquery`
+query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
+date=`sendquery`
+query="SELECT fParticleTypeName FROM MCCorsikaRunData "
+query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
+query=$query" LEFT JOIN MCRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCRunData.fCorsikaRunNumber "
+query=$query" WHERE fMCRunNumber="$run
+particle=`sendquery`
+outpath=$mcpath"/"$program"/"$date
+date2=`echo $date | sed -e 's/\///g'`
+outfile=$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
+query="SELECT fAdditionalSpotSize FROM MCRunData where fMCRunNumber="$run
+spotsize=`sendquery`
+query="SELECT fCameraSeed, fCameraSeed+1 FROM MCRunData where fMCRunNumber="$run
+seeds=`sendquery`
+
+echo "" >> $scriptlog 2>&1
+echo "INPUTCARD:" >> $scriptlog 2>&1
+echo "----------" >> $scriptlog 2>&1
+echo "" >> $scriptlog 2>&1
+echo "" >> $scriptlog 2>&1
+printinputcard >> $scriptlog 2>&1
+
+logfile=$outpath/$program"-"`printf %06d $run`".log"
+makedir $outpath >> $scriptlog 2>&1
+
+cd $detectordir/Camera
+
+echo "INPUTCARD:" >> $logfile 2>&1
+printinputcard >> $logfile 2>&1
+echo "" >> $logfile 2>&1
+echo "" >> $logfile 2>&1
+printinputcard | ./camera
+
+check1=$?
+
+case $check1 in
+   0)   echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
+        printprocesslog "INFO $program finished successfully for sequence $sequence"
+        ;;
+   *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+        printprocesslog "ERROR $program failed for sequence $sequence"
+        com=$Freflector
+        check=$check1
+        ;;
+esac
+
+setstatus "stop" >> $scriptlog 2>&1
+
+finish >> $scriptlog 2>&1
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/runcorsika
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runcorsika	(revision 8526)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runcorsika	(revision 8526)
@@ -0,0 +1,163 @@
+#!/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 runs corsika.
+# 
+
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
+program=corsika
+column=fCorsikaFileAvail
+
+set -C
+
+export FLUPRO='/home/operator/Corsika/Mmcs6500/fluka2006_3'
+
+# printing input card to stdout
+function printinputcard()
+{
+   echo "RUNNR "$corsikarunno
+   echo "PRMPAR "$primparticle
+   query="SELECT fEnergyMin, fEnergyMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+   echo "ERANGE "$erange
+   echo "EVTNR 1"
+   echo "NSHOW "$numevts
+   echo "ESLOPE "$slope
+   echo "THETAP "$zdrange
+   echo "PHIP "$azrange
+#   echo "VIEWCONE 0. 2.3"
+   echo "DIRECT "$outpath
+   echo "SEED "$seed1" 0 0 "
+   echo "SEED "$seed2" 0 0 "
+   echo "SEED "$seed3" 0 0 "
+   echo "OBSLEV 2200.E2"
+   echo "RADNKG 200.E2"
+   echo "MAGNET 29.5 23.0"
+   echo "ECUTS 0.3 0.3 0.02 0.02"
+   echo "MUADDI F"
+   echo "MUMULT T"
+   echo "LONGI T 10. T F"
+   echo "MAXPRT 0"
+   echo "ECTMAP 1.E4"
+   echo "STEPFC 0.1"
+   echo "DEBUG F 6 F 1000000"
+   echo "CWAVLG 290. 600."
+   echo "CSCAT 1 0. "$impact
+   echo "CERSIZ 1."
+   echo "CERFIL T"
+   echo "FIXCHI 280"
+   echo "DATBAS F"
+   echo "CERTEL 1"
+   echo " 0. 0. 0. 0. 0. 1800. 1700."
+   echo "USER operator"
+   echo "ATMOSPHERE 11 T"
+   echo "EXIT"
+}
+
+
+scriptlog=$runlogpath/run$program-$datetime.log
+date >> $scriptlog 2>&1
+
+# get sequence # 
+gettodo >> $scriptlog 2>&1
+run=$process
+# get corsika runno
+query="SELECT fCorsikaRunNumber FROM MCRunData where fMCRunNumber="$run
+corsikarunno=`sendquery`
+
+# lock sequ
+lockfile=$lockpath/lock-$table-$column-$corsikarunno.txt
+checklock >> $scriptlog 2>&1
+
+echo "run $program for run $run..." >> $scriptlog 2>&1
+printprocesslog "INFO starting $program for run $run"
+
+primvar=$run
+setstatus "start" >> $scriptlog 2>&1
+
+echo "run $program for run $run " >> $scriptlog 2>&1
+echo "create input card... " >> $scriptlog 2>&1
+
+# get values for inputcard
+query="SELECT fParticleTypeKEY FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+primparticle=`sendquery`
+query="SELECT fEnergyMin, fEnergyMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+erange=`sendquery`
+query="SELECT fNumEvents FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+numevts=`sendquery`
+query="SELECT fEnergySlope FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+slope=`sendquery`
+query="SELECT fZenithDistanceMin, fZenithDistanceMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+zdrange=`sendquery`
+query="SELECT fAzimuthMin, fAzimuthMax FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+azrange=`sendquery`
+query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+date=`sendquery`
+outpath=$mcpath"/"$program"/"$date
+query="SELECT fCorsikaSeed FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+seed1=`sendquery`
+query="SELECT fCorsikaSeed+1 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+seed2=`sendquery`
+query="SELECT fCorsikaSeed+2 FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+seed3=`sendquery`
+query="SELECT fImpactParameter FROM MCCorsikaRunData where fCorsikaRunNumber="$corsikarunno
+impact=`sendquery`
+
+echo "" >> $scriptlog 2>&1
+echo "INPUTCARD:" >> $scriptlog 2>&1
+echo "----------" >> $scriptlog 2>&1
+echo "" >> $scriptlog 2>&1
+echo "" >> $scriptlog 2>&1
+printinputcard >> $scriptlog 2>&1
+
+logfile=$outpath/$program"-"`printf %06d $corsikarunno`".log"
+makedir $outpath >> $scriptlog 2>&1
+
+cd /home/operator/Corsika/Mmcs6500/
+
+echo "INPUTCARD:" >> $logfile 2>&1
+printinputcard >> $logfile 2>&1
+echo "" >> $logfile 2>&1
+echo "" >> $logfile 2>&1
+printinputcard | ./cc6501p-linux >> $logfile 2>&1
+
+check1=$?
+
+case $check1 in
+   0)   echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
+        printprocesslog "INFO $program finished successfully for sequence $sequence"
+        ;;
+   *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+        printprocesslog "ERROR $program failed for sequence $sequence"
+        com=$Fcorsika
+        check=$check1
+        ;;
+esac
+
+setstatus "stop" >> $scriptlog 2>&1
+
+finish >> $scriptlog 2>&1
+
Index: trunk/MagicSoft/Mars/datacenter/scripts/runreflector
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/runreflector	(revision 8526)
+++ trunk/MagicSoft/Mars/datacenter/scripts/runreflector	(revision 8526)
@@ -0,0 +1,144 @@
+#!/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 runs the reflector.
+#
+
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
+program=reflector
+column=fReflectorFileAvail
+detectordir=/home/msmeyer/MC/MagicSoft/Simulation/Detector
+
+set -C
+
+# printing input card to stdout
+function printinputcard()
+{
+   echo $reflectorversion
+   echo "verbose_level 4"
+   echo "seeds "$seeds
+   echo "fixed_target 0. 0. "
+   echo "telescopes_layout 1 1"
+   echo "telescope_position 0.0 0.0"
+   if [ $wobble -eq 2 ]
+   then 
+      echo "wobble_mode 1"
+   else
+      echo "wobble_mode 0"
+   fi
+   echo "ct_file $detectordir/Data/magic.def"
+   echo "reflectivity_file $detectordir/Data/reflectivity.dat"
+   echo "axisdev_file $detectordir/Data/axisdev.dat"
+   echo "output_file "$outfile
+   echo "atm_model ATM_MagicWinter"
+   echo "cer_files "
+   echo $infile
+}
+
+
+scriptlog=$runlogpath/run$program-$datetime.log
+date >> $scriptlog 2>&1
+
+# get sequence # 
+gettodo >> $scriptlog 2>&1
+run=$process
+# get reflector runnumber
+query="SELECT fReflectorRunNumber FROM MCRunData where fMCRunNumber="$run
+reflectorrunno=`sendquery`
+
+# lock sequ
+lockfile=$lockpath/lock-$table-$column-$reflectorrunno.txt
+checklock >> $scriptlog 2>&1
+
+echo "run $program for run $run..." >> $scriptlog 2>&1
+printprocesslog "INFO starting $program for run $run"
+
+primvar=$run
+setstatus "start" >> $scriptlog 2>&1
+
+echo "run $program for run $run "
+echo "create input card... "
+
+# get values for inputcard
+query="SELECT fReflectorSeed, fReflectorSeed+1 FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
+seeds=`sendquery`
+query="SELECT fObservationModeKEY FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
+wobble=`sendquery`
+query="SELECT DATE_FORMAT(fRunStart, '%Y/%m/%d') FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
+date=`sendquery`
+query="SELECT fParticleTypeName FROM MCCorsikaRunData "
+query=$query" LEFT JOIN ParticleType ON MCCorsikaRunData.fParticleTypeKEY=ParticleType.fParticleTypeKEY "
+query=$query" LEFT JOIN MCReflectorRunData ON MCCorsikaRunData.fCorsikaRunNumber=MCReflectorRunData.fCorsikaRunNumber "
+query=$query" WHERE fReflectorRunNumber="$reflectorrunno
+particle=`sendquery`
+outpath=$mcpath"/"$program"/"$date
+date2=`echo $date | sed -e 's/\///g'`
+outfile=$outpath"/"$date2"_"`printf %06d $reflectorrunno`"_"$particle".rfl"
+query="SELECT fCorsikaRunNumber FROM MCReflectorRunData where fReflectorRunNumber="$reflectorrunno
+infile=$mcpath"/corsika/"$date"/cer"`printf %06d \`sendquery\``
+
+echo "" >> $scriptlog 2>&1
+echo "INPUTCARD:" >> $scriptlog 2>&1
+echo "----------" >> $scriptlog 2>&1
+echo "" >> $scriptlog 2>&1
+echo "" >> $scriptlog 2>&1
+printinputcard >> $scriptlog 2>&1
+
+makedir $outpath >> $scriptlog 2>&1
+if ls $outfile >/dev/null 2>&1
+then
+   rm -v $outfile
+fi
+logfile=$outpath/$program"-"`printf %06d $reflectorrunno`".log"
+
+cd $detectordir/ReflectorII
+
+echo "INPUTCARD:" >> $logfile 2>&1
+printinputcard >> $logfile 2>&1
+echo "" >> $logfile 2>&1
+echo "" >> $logfile 2>&1
+printinputcard | ./reflector
+
+check1=$?
+
+echo "the reflector returned: "$check1
+
+case $check1 in
+   22)   echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1
+         printprocesslog "INFO $program finished successfully for sequence $sequence"
+         ;;
+    *)   echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
+         printprocesslog "ERROR $program failed for sequence $sequence"
+         com=$Freflector
+         check=$check1
+         ;;
+esac
+
+setstatus "stop" >> $scriptlog 2>&1
+
+finish >> $scriptlog 2>&1
+
