Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 8625)
+++ trunk/MagicSoft/Mars/Changelog	(revision 8626)
@@ -33,4 +33,13 @@
        builddatasets.php to menu.php (function InitFindOffData), so that
        the values are also available in sequinfo-aio.php
+   
+   * scripts/dospectrum:
+     - completely new version using condor dag
+   
+   * scripts/preparemc:
+     - new version
+     - adapted path
+     - giving mars not needed anymore
+     - adapted to 8 digit run numbers for MC
 
 
Index: trunk/MagicSoft/Mars/scripts/dospectrum
===================================================================
--- trunk/MagicSoft/Mars/scripts/dospectrum	(revision 8625)
+++ trunk/MagicSoft/Mars/scripts/dospectrum	(revision 8626)
@@ -1,4 +1,4 @@
 #!/bin/sh
-#
+# 
 # ========================================================================
 #
@@ -18,154 +18,216 @@
 #
 #
-#   Author(s): Daniela Dorner  05/2006 <mailto:dorner@astro.uni-wuerzburg.de>
-#
-#   Copyright: MAGIC Software Development, 2000-2006
+#   Author(s): Daniela Dorner  06/2007 <mailto:dorner@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2007
 #
 #
 # ========================================================================
 #
-#
-#
 ##############################################################################
 #
-# This script creates the ganymed.rc files with different parameter sets (the 
-# parameters 1 and 3 are changed in steps). Then the script runs ganymed and 
-# sponde for this different parameter sets. 
-#
-# variables, that have to be set by the user:
-#
-# - path          directory, where the files are stored 
-# - mars          directory, where your Mars version is stored
-# - dataset       dataset file, which shall be used (filename without path)
-#                  the file has to be stored in the dataset directory in the 
-#                  path
-# - par*step      step width for changing the parameter * 
-# - par*numminus  number of steps going to smaller values of the parameter * 
-# - par*num       number of steps for changing the parameter * 
-# - spondenum     number of sponde rc file (also of the root and log file)
-# - ganymednum    number of ganymed root file
-#
-# Please make sure, that you provide the following files:
-# - $path/setup/ganymed$ganymednum.rc
-# - $path/setup/sponde$spondenum.rc
-# - $path/datasets/mcdataset-for-sponde.txt (if you use the script preparemc, 
-#    this file is produced automatically)
-# - $path/datasets/$datasetfilename (you give the datasetfilename below, but 
-#    you have to make sure, that it is in the directory $path/datasets
-#
-# To re-run ganymed (e.g. with new Software-Version), you have to delete 
-# the ganymed*.root files or set a new ganymednum. 
-# 
+# This script is: 
+# - writing rc-files with different sets of cuts 
+#   the set of cuts can be steered with the variables 
+#   $par3step, $par3numminus, $par3num and
+#   $par1step, $par1numminus, $par1num
+#     par*step     step width for changing the parameter * 
+#                  (suggested value: 0.005)
+#     par*numminus number of steps going to smaller values of the parameter * 
+#                  (starting value in your ganymed.rc file) 
+#     par*num      number of steps for changing the parameter * 
+#     par3: Cut1.Param3 from the ganymed.rc file 
+#     par1: Cut1.Param1 from the ganymed.rc file 
+# - writing a condor dag file for spectrum study
+#   With submitting this dag file with condor_submit_dag to condor from your
+#   Mars directroy you are running ganymed and sponde for all different rc 
+#   files. The condor dag man is taking care of the order of the jobs, 
+#   i.e. that sponde is started just when ganymed has been finished.
+# 
+# To start several spondes please set the arrays $spondes.
+# It is also possible to start new spondes without rerunning 
+# ganymed and/or the other spondes. To do so, please set the 
+# variables $doganymed and $spondedones accordingly
+#
+# Remark: You have to submit the condor dag file from your Mars directory.
+# 
+# For more detailed information read the comments directly before
+# each variable.
+#
 ##############################################################################
-
-
-# to be set by the user
-path=/home/dorner/crabspectrum
-mars=/home/dorner/mars.cvs
-datasetfilename=datasetcrab2005-2.txt
-spondenum=0
-ganymednum=1
-# settings for parameter 3
+#
+
+#
+# instructions and setup of the script
+# please set the variables according to your analysis
+#
+
+# path for you analysis
+path=/home/dorner/final_analysis
+# path where your condor dagfile is stored and where you need
+# the files processds.submit and processsponde.submit
+condorpath=$path/condor
+# path to store your resourcefiles
+# you should have there the ganymed.rc, which you want to use 
+# and your sponde.rc files 
+rcpath=$path/resources
+ganymedrc=$rcpath/ganymed_onoff.rc
+# outpath for your spectrum results
+# a directory for each set of cuts will be created there and
+# the ganymed and sponde output will be stored in these directories
+specpath=/results/spectrumSet2
+# name of your dataset
+# it has to be stored as dataset$dataset.txt in the directory
+# $path/datasets
+dataset="20060002"
+# this is the name of the condor-dag file, which you have to submit 
+# with condor_submit_dag from your Mars directory
+dagfile=$condorpath/set2spectrum.dag3
+# here you define whether ganymed still has to be done
+# if yes, set the variable $doganymed to "yes"
+#doganymed="yes"
+doganymed="no"
+# sponde.rc files have to be in the directory $rcpath 
+# they need to have the naming sponde1.rc, sponde2.rc, sponde3.rc 
+# (numbers in the following array)
+# the sponde.root files will be named in the same way (sponde(num).root)
+spondes=( 1 2 )
+# in this array you define whether the sponde is already done
+spondedones=( "done" "" )
+
+# this is the mc dataset, which has been created with the script
+# preparemc
+mcdataset=$path/mc/mcdataset2.txt
+
+# values for par3
 par3step=0.005
 par3numminus=10
 par3num=13
-# settings for parameter 1
+# values for par1
 par1step=0.005
 par1numminus=1 
-par1num=7
-
-
-function printsetup()
-{
-   echo "you set the following parameters: "
-   echo " path:       $path "
-   echo " ganymedrc:  $ganymedrc"
-   echo " sponderc:   $sponderc"
-   echo " dataset:    $dataset"
-   echo " mcdataset:  $mcdataset"
-   echo " spondenum:  $spondenum"
-   echo " ganymednum: $ganymednum"
-   echo " par1:       -$par1numminus to $par1num in $par1step steps"
-   echo " par3:       -$par3numminus to $par3num in $par3step steps"
-}
-
-#general variables
-datasetpath=$path/datasets
-setuppath=$path/setup
-#resultpath=$path/ganyspec
-resultpath=$path/ganyspec`echo $datasetfilename | sed -e 's/[.]txt//'`
-dataset=$datasetpath/$datasetfilename
-mcdataset=$datasetpath/mcdataset-for-sponde.txt
-ganymedrc=$setuppath/ganymed$ganymednum.rc
-sponderc=$setuppath/sponde$spondenum.rc
-setuplog=$setuppath/setup`date +%F-%H-%M-%S`.log
-
-if ! ls $ganymedrc >/dev/null 2>&1
-then
-   echo "couldn't find $ganymedrc."
-   echo "please provide the file $ganymedrc and re-run the script"
-   exit
-fi
-
-if ! ls $sponderc >/dev/null 2>&1
-then
-   echo "couldn't find $sponderc."
-   echo "do you want to continue anyhow? (ganymed will be done)"
-   echo "please insert y, if you want continue"
-   echo "              n, if you want quit"
-
-   answer=`head -n 1`
-   case $answer in
-      y) echo "continue creating rc files and running ganymed"
-         ;;
-      n) echo "please provide the file $ganymedrc and re-run the script"
-         exit
-         ;;
-      *) echo "your answer is not clear -> exit"
-         exit
-         ;;
-   esac
-   
-fi
-
-#start of the script
-printsetup
-printsetup > $setuplog
-
-mkdir -pv $resultpath
-
-echo "generating the ganymed.rc files with different parameter sets"
-# generating the ganymed.rc files with different parameter sets
+par1num=7 
+
+#
+# end of setup
+# beginning of script
+# 
+
+# some checks
+# checking if the given files and paths are existing
+if ! [ -e $mcdataset ]
+then
+   echo "Your mc dataset file $mcdataset does not exist."
+   exit
+fi
+if ! [ -e $path$specpath ]
+then
+   echo "Your output path $path$specpath does not exist."
+   exit
+fi
+if ! [ -e $path/datasets/dataset$dataset.txt ]
+then
+   echo "Your dataset file $path/datasets/dataset$dataset.txt does not exist."
+   exit
+fi
+if ! [ -e $ganymedrc ]
+then
+   echo "Your ganymed rc file $ganymedrc does not exist."
+   exit
+fi
+for (( l=0 ; l < ${#spondes[@]} ; l++ ))
+do 
+   if ! [ -e $rcpath/sponde${spondes[$l]}.rc ]
+   then
+      echo "Your sponde rc file $rcpath/sponde${spondes[$l]}.rc does not exist."
+      exit
+   fi
+done
+
+# get the parameters
 par3=`cat $ganymedrc | grep 'Cut1.Param3' | cut -d: -f2`
 par1=`cat $ganymedrc | grep 'Cut1.Param1' | cut -d: -f2`
-
-echo "parameter: 3 $par3 ,  1 $par1"
-
+echo "parameters: "
+echo "  par3= $par3"
+echo "  par1= $par1"
+echo ""
+
+# calculate the parameters with which you start
 start3=`echo $par3 - \( $par3numminus*$par3step \) | bc `
 start1=`echo $par1 - \( $par1numminus*$par1step \) | bc `
-echo "start: 1: $start1 3: $start3"
-
+echo "start: "
+echo "  par1: $start1 "
+echo "  par3: $start3"
+echo ""
+
+
+# function to print the lines for ganymed to the dag file
+function printganydagentry()
+{
+   if [ "$doganymed" = "yes" ]
+   then
+      echo "JOB  gany$name $condorpath/processds.submit"
+   else
+      echo "JOB  gany$name $condorpath/processds.submit DONE"
+   fi
+   echo "VARS gany$name path=\"$path\""
+   echo "VARS gany$name out=\"$dir\""
+   echo "VARS gany$name ds=\"$dataset\""
+   echo "VARS gany$name num=\"$dataset\""
+   echo "VARS gany$name rc=\"$rcfile\""
+   echo ""
+}
+
+# function to print the lines for sponde to the dag file
+function printspecdagentry()
+{
+   sponderc=$rcpath/sponde$1.rc
+   if [ "$2" = "done" ]
+   then
+      echo "JOB  spec$1_$name $condorpath/processsponde.submit DONE"
+   else
+      echo "JOB  spec$1_$name $condorpath/processsponde.submit"
+   fi
+   echo "VARS spec$1_$name path=\"/home/dorner/final_analysis\""
+   echo "VARS spec$1_$name out=\"$outpath\""
+   echo "VARS spec$1_$name rc=\"$sponderc\""
+   echo "VARS spec$1_$name spondenum=\"$1\""
+   echo "VARS spec$1_$name mcds=\"$mcdataset\""
+   echo "VARS spec$1_$name num=\"$dataset\""
+   echo ""
+   echo "PARENT gany$name CHILD spec$1_$name "
+   echo ""
+}
+
+echo "writing dag file $dagfile for dataset $dataset"
+echo "# dag file for dataset $dataset" > $dagfile
+echo "" >> $dagfile
 val1=$start1
 val3=$start3
-
+count=0
 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
+      name=${val1}_${val3}
+      dir=$specpath/ganyspec$name
+      outpath=$path$dir
+      rcfile=$outpath/ganymed_${name}_onoff.rc
+      if ! [ -d $outpath ]
       then 
-         mkdir -pv $dir
+         mkdir -v $outpath
       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
+      cat $ganymedrc | sed -e s/"${par1}"/"   ${val1}"/ -e s/"${par3}"/"  ${val3}"/ > $rcfile
       val1=`echo $val1 + $par1step | bc`
+      echo " writing dag entry for set of cuts par1: $val1, par3: $val3"
+      echo "# ganymed and sponde for dataset $dataset with cuts $name" >> $dagfile
+      echo "" >> $dagfile
+      printganydagentry  >> $dagfile
+      for (( k=0 ; k < ${#spondes[@]} ; k++ ))
+      do 
+         printspecdagentry ${spondes[$k]} ${spondedones[$k]} >> $dagfile
+      done
+      echo "" >> $dagfile
+      count=`echo $count + 1 | bc`
    done
    val3=`echo $val3 + $par3step | bc`
@@ -173,62 +235,9 @@
 done
 
-
-# running ganymed and sponde for different parameter sets
-
-# function running ganymed and sponde for a set of cuts
-function dospec()
-{
-   cd $mars
-
-   name=$set/ganymed`printf %08d $ganymednum`
-   ganymedfile=$name.root
-   if ! ls $ganymedfile >/dev/null 2>&1
-   then 
-      cd $mars
-#      rc=`ls $set/ganymed_*onoff.rc`
-      ganymedlog=$name.log
-      echo "starting ganymed for set $set ..."
-      if ! condor_run ./ganymed -b -f --n=$ganymednum --log=$ganymedlog --out=$set --config=$set/`basename $ganymedrc` $dataset >/dev/null
-      then 
-         echo "condor is not working " 
-         return
-      fi
-   else
-      echo "ganymed for set $set already done => continue with sponde"
-   fi
-
-   if ! ls $sponderc >/dev/null 2>&1
-   then 
-      echo "ERROR: spondercfile $sponderc is missing"
-      return
-   fi
-   spondefile=$set/sponde$spondenum-g$ganymednum.root
-   spondelog=$set/sponde$spondenum-g$ganymednum.log
-   if ! ls $spondefile >/dev/null 2>&1
-   then
-      echo "starting sponde for set $set ..."
-      if ! condor_run ./sponde -b -f --log=$spondelog --config=$sponderc -f $ganymedfile $mcdataset $spondefile >/dev/null
-      then
-         echo "condor is not working " 
-         return
-      fi
-      echo "finished sponde for set $set ..."
-   else
-      echo "sponde $spondenum for set $set already done => please remove sponde files or give new spondenum"
-   fi
-}
-
-
-sets=`find $resultpath -type d`
-for set in ${sets[@]}
-do 
-#   echo "set: "$set
-   if [ "$set" == "$resultpath" ]
-   then
-      continue
-   fi
-   dospec &
-   sleep 3
-done
-
-
+echo ""
+echo "finished writing condor dag file "$dagfile
+echo "in total $count different sets of cuts are used"
+echo ""
+echo "you can submit it now with \"condor_submit_dag -f $dagfile\" from your Mars directory"
+echo ""
+
Index: trunk/MagicSoft/Mars/scripts/preparemc
===================================================================
--- trunk/MagicSoft/Mars/scripts/preparemc	(revision 8625)
+++ trunk/MagicSoft/Mars/scripts/preparemc	(revision 8626)
@@ -1,4 +1,3 @@
 #!/bin/sh
-#
 # ========================================================================
 #
@@ -20,5 +19,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
 #
 #
@@ -33,10 +32,7 @@
 #
 # variables, that have to be set by the user:
-# - dir          directory, where the mc sequence and dataset files are stored 
+# - 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
-# - mars         directory, where your Mars version is stored
-#                 only needed, if you want to create a rf-root-file for the 
-#                 energy estimation 
 # - zdmin        minimum zenith distance
 # - zdmax        maximum zenith distance
@@ -48,59 +44,48 @@
 # - numruns      num of runs, that are in the sequence file, which are used 
 #                 for training (SequencesOn in $mcdataset)
-# - trainenergy  if set to 'yes', the rf for energy estimation is trained
+# 
+# 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\""\) 
 #
+# Remark: You have to run the script in your Mars directory.
 # 
 ##############################################################################
 
 
+path=/home/dorner/final_analysis
+mcoutpath=$path/mc
+macrospath=$path/macros
+mcdataset=$mcoutpath/mcdataset.txt
+mcdataset2=$mcoutpath/mcdataset2.txt
 
-#to be set by the user 
-dir=/home/dorner/crabspectrum 
-mars=/home/dorner/mars.cvs 
-zdmin=5
+zdmin=17
 zdmax=35
 psf=14
-modes=( "02" "04" ) # e.g. nowobble
-numruns=5
-# set here if you want to train a rf-engery-estimator
-#trainenergy=
-trainenergy="yes"
+modes=( "02" ) # nowobble
+numruns=3
 
+# be careful with $date, when path changes
+mcpath=/magic/montecarlo 
 
-# begin of script
-datasetdir=$dir/datasets
-sequencedir=$dir/sequences
-setupdir=$dir/setup
-mcdir=/magic/montecarlo
-mcrawdir=$mcdir/rawfiles
-mcstardir=$mcdir/star
-mcdataset=$datasetdir/mcdataset-test-train.txt
-mcdataset2=$datasetdir/mcdataset-for-sponde.txt
-
-# make directories 
-mkdir -pv $dir
-mkdir -v $sequencedir
-mkdir -v $datasetdir
-
-#calculation of the zbin
 zbinmin=`echo "scale=2 ; 100*(1 - c($zdmin*3.14/180))+1" | bc -l`
 zbinmax=`echo "scale=2 ; 100*(1 - c($zdmax*3.14/180))+1" | bc -l`
+
 zbinmin=`echo $zbinmin | cut -d. -f1`
 zbinmax=`echo $zbinmax | cut -d. -f1`
-echo "zd: min: $zbinmin max: $zbinmax"
-echo "numruns: $numruns"
+
+echo "zd:   min: $zdmin max: $zdmax"
+echo "zbin: min: $zbinmin max: $zbinmax"
+echo "$numruns runs are classified as test the rest as train"
 
 j=0
-for mode in ${modes[@]}
+for mode in $modes
 do 
-   echo "mode: "$mode
    for (( i=$zbinmin ; i < $zbinmax ; i++ ))
    do 
       zbin=`printf %02d $i`
-      echo "zbin: $zbin"
-      path=$mcrawdir/19$zbin/$mode/$psf
-      runsforfirst=
-
-      runs=(`ls $path 2>/dev/null | grep Gamma | cut -d_ -f2 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' | tr "\n" " "`)
+      path=$mcpath/rawfiles/19$zbin/$mode/$psf
+      runs=(`ls $path | grep Gamma | cut -d_ -f2 | sed -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' -e 's/^0//g' | tr "\n" " "`)
       if [ "$runs" = "" ]
       then
@@ -108,5 +93,7 @@
          continue
       fi
+      echo "found ${#runs[@]} Gamma MC files in path "$path
 
+      runsforfirst=""
       firstrun=${runs[0]}
       secondrun=${runs[${numruns}]}
@@ -119,9 +106,7 @@
          unset runs[$k]
       done
-      mcrawdir2=`echo $mcrawdir | sed -e 's/\//\\\\\//g'` 
-      date=`echo $path | sed -e "s/$mcrawdir2\///" -e 's/\//-/g'` 
-#      date=`echo $path | cut -c 22-31 | sed -e 's/\//-/g'`
+      date=`echo $path | cut -d/ -f5-7 | sed -e 's/\//-/g'`
       
-      trainsequfile=$sequencedir/sequence$firstrunno.txt
+      trainsequfile=$mcoutpath/sequence$firstrunno.txt
       trainsequences[$j]=$firstrunno
       echo "  writing train-sequfile "$trainsequfile 
@@ -133,8 +118,10 @@
       echo "DatRuns:         $firstrun$runsforfirst" >> $trainsequfile
       echo "" >> $trainsequfile
+      echo "MonteCarlo: Yes" >> $trainsequfile
+      echo "" >> $trainsequfile
 
-      testsequfile=$sequencedir/sequence$secondrunno.txt
+      testsequfile=$mcoutpath/sequence$secondrunno.txt
       testsequences[$j]=$secondrunno
-      echo "  writing test-sequfile "$testsequfile 
+#      echo "writing test-sequfile "$testsequfile 
       echo "Sequence:        $secondrun" > $testsequfile
       echo "Night:           $date" >> $testsequfile
@@ -144,4 +131,6 @@
       echo "DatRuns:         ${runs[@]}" >> $testsequfile
       echo "" >> $testsequfile
+      echo "MonteCarlo: Yes" >> $testsequfile
+      echo "" >> $testsequfile
       
       j=$j+1
@@ -149,9 +138,6 @@
 done
 
-
 echo "# test sequences: ${#testsequences[@]}"
 echo "# train sequences: ${#trainsequences[@]}"
-
-echo "writing dataset files $mcdataset and $mcdataset2"
 
 echo "AnalysisNumber: 1 " > $mcdataset
@@ -173,24 +159,24 @@
    numtrain=${trainsequences[$i]}
    notrain=`echo $numtrain | cut -c 0-4`
-   echo "Sequence$numtrain.File: $sequencedir/sequence$numtrain.txt" >> $mcdataset
-   echo "Sequence$numtrain.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset
-   echo "Sequence$numtrain.File: $sequencedir/sequence$numtrain.txt" >> $mcdataset2
-   echo "Sequence$numtrain.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset2
+   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
 
    numtest=${testsequences[$i]}
    notest=`echo $numtest | cut -c 0-4`
-   echo "Sequence$numtest.File: $sequencedir/sequence$numtest.txt" >> $mcdataset
-   echo "Sequence$numtest.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset
-   echo "Sequence$numtest.File: $sequencedir/sequence$numtest.txt" >> $mcdataset2
-   echo "Sequence$numtest.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset2
+   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
 done
 
 
-if [ "$trainenergy" == "yes" ]
-then 
-   echo "creating rf-root-file for energy-estimation..."
-   cd $mars
-   logfile=$setupdir/trainenergy.log
+logfile=$mcoutpath/trainenergy.log
+rffile=$mcoutpath/rf-energy.root
 
-   root -q -b $mars/datacenter/macros/trainenergy.C+\("\"$mcdataset\""\,"\"$setupdir/\""\) | tee $logfile
-fi
+echo "mcdataset: $mcdataset"
+echo "rffile: $rffile"
+echo "macrospath: $macrospath"
+root -q -b $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) | tee $logfile
+
