Ignore:
Timestamp:
06/29/07 15:33:20 (18 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/scripts/preparemc

    r8227 r8626  
    11#!/bin/sh
    2 #
    32# ========================================================================
    43#
     
    2019#   Author(s): Daniela Dorner  05/2006 <mailto:dorner@astro.uni-wuerzburg.de>
    2120#
    22 #   Copyright: MAGIC Software Development, 2000-2006
     21#   Copyright: MAGIC Software Development, 2000-2007
    2322#
    2423#
     
    3332#
    3433# variables, that have to be set by the user:
    35 # - dir          directory, where the mc sequence and dataset files are stored
     34# - path         directory, where the mc sequence and dataset files are stored
    3635#                 be careful: don't move the sequence files afterwards, as the
    3736#                 paths are stored in the datasetfiles
    38 # - mars         directory, where your Mars version is stored
    39 #                 only needed, if you want to create a rf-root-file for the
    40 #                 energy estimation
    4137# - zdmin        minimum zenith distance
    4238# - zdmax        maximum zenith distance
     
    4844# - numruns      num of runs, that are in the sequence file, which are used
    4945#                 for training (SequencesOn in $mcdataset)
    50 # - trainenergy  if set to 'yes', the rf for energy estimation is trained
     46#
     47# Remark: For the training of the RF for the energy estimation you need the
     48# macro trainengery.C in the path $path/macros in a modified version, i.e. the
     49# inputfile (mcdataset) and the outputfile (rf-root file) are given as
     50# options: $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\)
    5151#
     52# Remark: You have to run the script in your Mars directory.
    5253#
    5354##############################################################################
    5455
    5556
     57path=/home/dorner/final_analysis
     58mcoutpath=$path/mc
     59macrospath=$path/macros
     60mcdataset=$mcoutpath/mcdataset.txt
     61mcdataset2=$mcoutpath/mcdataset2.txt
    5662
    57 #to be set by the user
    58 dir=/home/dorner/crabspectrum
    59 mars=/home/dorner/mars.cvs
    60 zdmin=5
     63zdmin=17
    6164zdmax=35
    6265psf=14
    63 modes=( "02" "04" ) # e.g. nowobble
    64 numruns=5
    65 # set here if you want to train a rf-engery-estimator
    66 #trainenergy=
    67 trainenergy="yes"
     66modes=( "02" ) # nowobble
     67numruns=3
    6868
     69# be careful with $date, when path changes
     70mcpath=/magic/montecarlo
    6971
    70 # begin of script
    71 datasetdir=$dir/datasets
    72 sequencedir=$dir/sequences
    73 setupdir=$dir/setup
    74 mcdir=/magic/montecarlo
    75 mcrawdir=$mcdir/rawfiles
    76 mcstardir=$mcdir/star
    77 mcdataset=$datasetdir/mcdataset-test-train.txt
    78 mcdataset2=$datasetdir/mcdataset-for-sponde.txt
    79 
    80 # make directories
    81 mkdir -pv $dir
    82 mkdir -v $sequencedir
    83 mkdir -v $datasetdir
    84 
    85 #calculation of the zbin
    8672zbinmin=`echo "scale=2 ; 100*(1 - c($zdmin*3.14/180))+1" | bc -l`
    8773zbinmax=`echo "scale=2 ; 100*(1 - c($zdmax*3.14/180))+1" | bc -l`
     74
    8875zbinmin=`echo $zbinmin | cut -d. -f1`
    8976zbinmax=`echo $zbinmax | cut -d. -f1`
    90 echo "zd: min: $zbinmin max: $zbinmax"
    91 echo "numruns: $numruns"
     77
     78echo "zd:   min: $zdmin max: $zdmax"
     79echo "zbin: min: $zbinmin max: $zbinmax"
     80echo "$numruns runs are classified as test the rest as train"
    9281
    9382j=0
    94 for mode in ${modes[@]}
     83for mode in $modes
    9584do
    96    echo "mode: "$mode
    9785   for (( i=$zbinmin ; i < $zbinmax ; i++ ))
    9886   do
    9987      zbin=`printf %02d $i`
    100       echo "zbin: $zbin"
    101       path=$mcrawdir/19$zbin/$mode/$psf
    102       runsforfirst=
    103 
    104       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" " "`)
     88      path=$mcpath/rawfiles/19$zbin/$mode/$psf
     89      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" " "`)
    10590      if [ "$runs" = "" ]
    10691      then
     
    10893         continue
    10994      fi
     95      echo "found ${#runs[@]} Gamma MC files in path "$path
    11096
     97      runsforfirst=""
    11198      firstrun=${runs[0]}
    11299      secondrun=${runs[${numruns}]}
     
    119106         unset runs[$k]
    120107      done
    121       mcrawdir2=`echo $mcrawdir | sed -e 's/\//\\\\\//g'`
    122       date=`echo $path | sed -e "s/$mcrawdir2\///" -e 's/\//-/g'`
    123 #      date=`echo $path | cut -c 22-31 | sed -e 's/\//-/g'`
     108      date=`echo $path | cut -d/ -f5-7 | sed -e 's/\//-/g'`
    124109     
    125       trainsequfile=$sequencedir/sequence$firstrunno.txt
     110      trainsequfile=$mcoutpath/sequence$firstrunno.txt
    126111      trainsequences[$j]=$firstrunno
    127112      echo "  writing train-sequfile "$trainsequfile
     
    133118      echo "DatRuns:         $firstrun$runsforfirst" >> $trainsequfile
    134119      echo "" >> $trainsequfile
     120      echo "MonteCarlo: Yes" >> $trainsequfile
     121      echo "" >> $trainsequfile
    135122
    136       testsequfile=$sequencedir/sequence$secondrunno.txt
     123      testsequfile=$mcoutpath/sequence$secondrunno.txt
    137124      testsequences[$j]=$secondrunno
    138       echo "  writing test-sequfile "$testsequfile
     125#      echo "writing test-sequfile "$testsequfile
    139126      echo "Sequence:        $secondrun" > $testsequfile
    140127      echo "Night:           $date" >> $testsequfile
     
    144131      echo "DatRuns:         ${runs[@]}" >> $testsequfile
    145132      echo "" >> $testsequfile
     133      echo "MonteCarlo: Yes" >> $testsequfile
     134      echo "" >> $testsequfile
    146135     
    147136      j=$j+1
     
    149138done
    150139
    151 
    152140echo "# test sequences: ${#testsequences[@]}"
    153141echo "# train sequences: ${#trainsequences[@]}"
    154 
    155 echo "writing dataset files $mcdataset and $mcdataset2"
    156142
    157143echo "AnalysisNumber: 1 " > $mcdataset
     
    173159   numtrain=${trainsequences[$i]}
    174160   notrain=`echo $numtrain | cut -c 0-4`
    175    echo "Sequence$numtrain.File: $sequencedir/sequence$numtrain.txt" >> $mcdataset
    176    echo "Sequence$numtrain.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset
    177    echo "Sequence$numtrain.File: $sequencedir/sequence$numtrain.txt" >> $mcdataset2
    178    echo "Sequence$numtrain.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset2
     161   echo "Sequence$numtrain.File: $mcoutpath/sequence$numtrain.txt" >> $mcdataset
     162   echo "Sequence$numtrain.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset
     163   echo "Sequence$numtrain.File: $mcoutpath/sequence$numtrain.txt" >> $mcdataset2
     164   echo "Sequence$numtrain.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset2
    179165
    180166   numtest=${testsequences[$i]}
    181167   notest=`echo $numtest | cut -c 0-4`
    182    echo "Sequence$numtest.File: $sequencedir/sequence$numtest.txt" >> $mcdataset
    183    echo "Sequence$numtest.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset
    184    echo "Sequence$numtest.File: $sequencedir/sequence$numtest.txt" >> $mcdataset2
    185    echo "Sequence$numtest.Dir:  $mcstardir/$notrain/$numtrain" >> $mcdataset2
     168   echo "Sequence$numtest.File: $mcoutpath/sequence$numtest.txt" >> $mcdataset
     169   echo "Sequence$numtest.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset
     170   echo "Sequence$numtest.File: $mcoutpath/sequence$numtest.txt" >> $mcdataset2
     171   echo "Sequence$numtest.Dir:  $mcpath/star/$notrain/$numtrain" >> $mcdataset2
    186172done
    187173
    188174
    189 if [ "$trainenergy" == "yes" ]
    190 then
    191    echo "creating rf-root-file for energy-estimation..."
    192    cd $mars
    193    logfile=$setupdir/trainenergy.log
     175logfile=$mcoutpath/trainenergy.log
     176rffile=$mcoutpath/rf-energy.root
    194177
    195    root -q -b $mars/datacenter/macros/trainenergy.C+\("\"$mcdataset\""\,"\"$setupdir/\""\) | tee $logfile
    196 fi
     178echo "mcdataset: $mcdataset"
     179echo "rffile: $rffile"
     180echo "macrospath: $macrospath"
     181root -q -b $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) | tee $logfile
     182
Note: See TracChangeset for help on using the changeset viewer.