Index: trunk/MagicSoft/Mars/scripts/preparemc
===================================================================
--- trunk/MagicSoft/Mars/scripts/preparemc	(revision 8626)
+++ trunk/MagicSoft/Mars/scripts/preparemc	(revision 8637)
@@ -32,21 +32,21 @@
 #
 # variables, that have to be set by the user:
-# - path         directory, where the mc sequence and dataset files are stored 
-#                 be careful: don't move the sequence files afterwards, as the 
-#                 paths are stored in the datasetfiles
-# - zdmin        minimum zenith distance
-# - zdmax        maximum zenith distance
-# - psf          psf 
-#                 at the moment mc with psf 14 and 20 is available
-# - modes        observation mode
-#                 the explanation for the modes can be found in 
-#                  /montecarlo/rawfiles/README.txt
-# - numruns      num of runs, that are in the sequence file, which are used 
-#                 for training (SequencesOn in $mcdataset)
+# - path     directory, where the mc sequence and dataset files are stored 
+#              be careful: don't move the sequence files afterwards, as the 
+#              paths are stored in the datasetfiles
+# - zdmin    minimum zenith distance
+# - zdmax    maximum zenith distance
+# - psf      psf (at the moment mc with psf 14 and 20 is available)
+# - modes    observation mode
+#              the explanation for the modes can be found in 
+#              /magic/montecarlo/rawfiles/README.txt
+# - numruns  number  of runs, that are in the sequence file, which are used 
+#            for training (SequencesOn in $mcdataset)
 # 
 # Remark: For the training of the RF for the energy estimation you need the 
-# macro trainengery.C in the path $path/macros in a modified version, i.e. the
-# inputfile (mcdataset) and the outputfile (rf-root file) are given as
-# options: $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) 
+#         macro trainengery.C in the path $path/macros in a modified version, 
+#         i.e. the inputfile (mcdataset) and the outputfile (rf-root file) 
+#         are given as options: 
+#         $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) 
 #
 # Remark: You have to run the script in your Mars directory.
@@ -54,16 +54,46 @@
 ##############################################################################
 
-
+# to be set by the user
 path=/home/dorner/final_analysis
+# path where your mc sequence and dataset files are stored
 mcoutpath=$path/mc
+# path where you have your modified version of trainenergy.C
 macrospath=$path/macros
-mcdataset=$mcoutpath/mcdataset.txt
-mcdataset2=$mcoutpath/mcdataset2.txt
-
+
+# zenith range of your data
 zdmin=17
-zdmax=35
+zdmax=36
+# point spread function of your data
 psf=14
-modes=( "02" ) # nowobble
-numruns=3
+# observation mode of your data
+#  for explanations see /magic/montecarlo/rawfiles/README.txt
+modes=( "02" ) 
+# number of runs which are in the sequence files used for training
+# please adjust this number such, that you use about 30000 Events for training
+numruns=1
+
+
+
+
+# some checks
+# checking if the given files and paths are existing
+if ! [ -e $mcoutpath ]
+then
+   echo "Your outpath for the mc $mcoutpathdoes not exist."
+   exit
+fi
+if ! [ -e $macrospath ]
+then
+   echo "Your macros path $macrospath does not exist."
+   exit
+fi
+if ! [ -e $macrospath/trainenergy.C ]
+then
+   echo "Your trainenergy.C does not exist in path $macrospath."
+   exit
+fi
+
+mcdatasettrain=$mcoutpath/mcdataset-for-training.txt
+mcdatasetsponde=$mcoutpath/mcdataset-for-sponde.txt
 
 # be careful with $date, when path changes
@@ -90,5 +120,5 @@
       if [ "$runs" = "" ]
       then
-         echo "  no runs found for zbin $i "
+         echo "  No runs for zbin $i found. Please try to find some MC with zbin $i!"
          continue
       fi
@@ -110,5 +140,5 @@
       trainsequfile=$mcoutpath/sequence$firstrunno.txt
       trainsequences[$j]=$firstrunno
-      echo "  writing train-sequfile "$trainsequfile 
+#      echo "  writing train-sequfile "$trainsequfile 
       echo "Sequence:        $firstrun" > $trainsequfile
       echo "Night:           $date" >> $trainsequfile
@@ -141,17 +171,17 @@
 echo "# train sequences: ${#trainsequences[@]}"
 
-echo "AnalysisNumber: 1 " > $mcdataset
-echo "" >> $mcdataset
-echo "SequencesOn: ${trainsequences[@]}" >> $mcdataset
-echo "" >> $mcdataset
-echo "SequencesOff: ${testsequences[@]}" >> $mcdataset
-echo "" >> $mcdataset
-echo "" >> $mcdataset
-
-echo "AnalysisNumber: 1 " > $mcdataset2
-echo "" >> $mcdataset2
-echo "SequencesOn: ${testsequences[@]}" >> $mcdataset2
-echo "" >> $mcdataset2
-echo "" >> $mcdataset2
+echo "AnalysisNumber: 1 " > $mcdatasettrain
+echo "" >> $mcdatasettrain
+echo "SequencesOn: ${trainsequences[@]}" >> $mcdatasettrain
+echo "" >> $mcdatasettrain
+echo "SequencesOff: ${testsequences[@]}" >> $mcdatasettrain
+echo "" >> $mcdatasettrain
+echo "" >> $mcdatasettrain
+
+echo "AnalysisNumber: 1 " > $mcdatasetsponde
+echo "" >> $mcdatasetsponde
+echo "SequencesOn: ${testsequences[@]}" >> $mcdatasetsponde
+echo "" >> $mcdatasetsponde
+echo "" >> $mcdatasetsponde
 
 for (( i=0 ; i < ${#testsequences[@]} ; i++ ))
@@ -159,24 +189,26 @@
    numtrain=${trainsequences[$i]}
    notrain=`echo $numtrain | cut -c 0-4`
-   echo "Sequence$numtrain.File: $mcoutpath/sequence$numtrain.txt" >> $mcdataset
-   echo "Sequence$numtrain.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset
-   echo "Sequence$numtrain.File: $mcoutpath/sequence$numtrain.txt" >> $mcdataset2
-   echo "Sequence$numtrain.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset2
+   echo "Sequence$numtrain.File: $mcoutpath/sequence$numtrain.txt" >> $mcdatasettrain
+   echo "Sequence$numtrain.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdatasettrain
 
    numtest=${testsequences[$i]}
    notest=`echo $numtest | cut -c 0-4`
-   echo "Sequence$numtest.File: $mcoutpath/sequence$numtest.txt" >> $mcdataset
-   echo "Sequence$numtest.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset
-   echo "Sequence$numtest.File: $mcoutpath/sequence$numtest.txt" >> $mcdataset2
-   echo "Sequence$numtest.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset2
+   echo "Sequence$numtest.File: $mcoutpath/sequence$numtest.txt" >> $mcdatasettrain
+   echo "Sequence$numtest.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdatasettrain
+   echo "Sequence$numtest.File: $mcoutpath/sequence$numtest.txt" >> $mcdatasetsponde
+   echo "Sequence$numtest.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdatasetsponde
 done
 
 
+# train the rf for energy estimation
 logfile=$mcoutpath/trainenergy.log
 rffile=$mcoutpath/rf-energy.root
 
-echo "mcdataset: $mcdataset"
-echo "rffile: $rffile"
-echo "macrospath: $macrospath"
-root -q -b $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) | tee $logfile
-
+echo "Your mcdataset for training: $mcdatasettrain"
+echo "Your rffile: $rffile"
+echo ""
+echo "Training the RF..."
+root -q -b $macrospath/trainenergy.C+\("\"$mcdatasettrain\""\,"\"$rffile\""\) | tee $logfile
+
+echo "" 
+echo "Please use rf-file $rffile in your sponde.rc, in case you want to use the RF energy estimator there. "
