| 1 | #!/bin/sh
|
|---|
| 2 | #
|
|---|
| 3 | # ========================================================================
|
|---|
| 4 | #
|
|---|
| 5 | # *
|
|---|
| 6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 7 | # * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 9 | # * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 10 | # *
|
|---|
| 11 | # * Permission to use, copy, modify and distribute this software and its
|
|---|
| 12 | # * documentation for any purpose is hereby granted without fee,
|
|---|
| 13 | # * provided that the above copyright notice appear in all copies and
|
|---|
| 14 | # * that both that copyright notice and this permission notice appear
|
|---|
| 15 | # * in supporting documentation. It is provided "as is" without express
|
|---|
| 16 | # * or implied warranty.
|
|---|
| 17 | # *
|
|---|
| 18 | #
|
|---|
| 19 | #
|
|---|
| 20 | # Author(s): Daniela Dorner 05/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2006
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | #
|
|---|
| 28 | #
|
|---|
| 29 | ##############################################################################
|
|---|
| 30 | #
|
|---|
| 31 | # This script creates mc sequences and datasets for a psf, observation mode
|
|---|
| 32 | # and zenith range chosen by the user.
|
|---|
| 33 | #
|
|---|
| 34 | # variables, that have to be set by the user:
|
|---|
| 35 | # - dir directory, where the mc sequence and dataset files are stored
|
|---|
| 36 | # be careful: don't move the sequence files afterwards, as the
|
|---|
| 37 | # 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
|
|---|
| 41 | # - zdmin minimum zenith distance
|
|---|
| 42 | # - zdmax maximum zenith distance
|
|---|
| 43 | # - psf psf
|
|---|
| 44 | # at the moment mc with psf 14 and 20 is available
|
|---|
| 45 | # - modes observation mode
|
|---|
| 46 | # the explanation for the modes can be found in
|
|---|
| 47 | # /montecarlo/rawfiles/README.txt
|
|---|
| 48 | # - numruns num of runs, that are in the sequence file, which are used
|
|---|
| 49 | # for training (SequencesOn in $mcdataset)
|
|---|
| 50 | # - trainenergy if set to 'yes', the rf for energy estimation is trained
|
|---|
| 51 | #
|
|---|
| 52 | #
|
|---|
| 53 | ##############################################################################
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 | #to be set by the user
|
|---|
| 58 | dir=/home/dorner/crabspectrum
|
|---|
| 59 | mars=/home/dorner/mars.cvs
|
|---|
| 60 | zdmin=5
|
|---|
| 61 | zdmax=35
|
|---|
| 62 | psf=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"
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 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
|
|---|
| 86 | zbinmin=`echo "scale=2 ; 100*(1 - c($zdmin*3.14/180))+1" | bc -l`
|
|---|
| 87 | zbinmax=`echo "scale=2 ; 100*(1 - c($zdmax*3.14/180))+1" | bc -l`
|
|---|
| 88 | zbinmin=`echo $zbinmin | cut -d. -f1`
|
|---|
| 89 | zbinmax=`echo $zbinmax | cut -d. -f1`
|
|---|
| 90 | echo "zd: min: $zbinmin max: $zbinmax"
|
|---|
| 91 | echo "numruns: $numruns"
|
|---|
| 92 |
|
|---|
| 93 | j=0
|
|---|
| 94 | for mode in ${modes[@]}
|
|---|
| 95 | do
|
|---|
| 96 | echo "mode: "$mode
|
|---|
| 97 | for (( i=$zbinmin ; i < $zbinmax ; i++ ))
|
|---|
| 98 | do
|
|---|
| 99 | 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" " "`)
|
|---|
| 105 | if [ "$runs" = "" ]
|
|---|
| 106 | then
|
|---|
| 107 | echo " no runs found for zbin $i "
|
|---|
| 108 | continue
|
|---|
| 109 | fi
|
|---|
| 110 |
|
|---|
| 111 | firstrun=${runs[0]}
|
|---|
| 112 | secondrun=${runs[${numruns}]}
|
|---|
| 113 | firstrunno=`printf %08d $firstrun`
|
|---|
| 114 | secondrunno=`printf %08d $secondrun`
|
|---|
| 115 | unset runs[0]
|
|---|
| 116 | for (( k=1 ; k < $numruns ; k++ ))
|
|---|
| 117 | do
|
|---|
| 118 | runsforfirst=$runsforfirst" ${runs[$k]}"
|
|---|
| 119 | unset runs[$k]
|
|---|
| 120 | 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'`
|
|---|
| 124 |
|
|---|
| 125 | trainsequfile=$sequencedir/sequence$firstrunno.txt
|
|---|
| 126 | trainsequences[$j]=$firstrunno
|
|---|
| 127 | echo " writing train-sequfile "$trainsequfile
|
|---|
| 128 | echo "Sequence: $firstrun" > $trainsequfile
|
|---|
| 129 | echo "Night: $date" >> $trainsequfile
|
|---|
| 130 | echo "" >> $trainsequfile
|
|---|
| 131 | echo "CalRuns: 1" >> $trainsequfile
|
|---|
| 132 | echo "PedRuns: 2" >> $trainsequfile
|
|---|
| 133 | echo "DatRuns: $firstrun$runsforfirst" >> $trainsequfile
|
|---|
| 134 | echo "" >> $trainsequfile
|
|---|
| 135 |
|
|---|
| 136 | testsequfile=$sequencedir/sequence$secondrunno.txt
|
|---|
| 137 | testsequences[$j]=$secondrunno
|
|---|
| 138 | echo " writing test-sequfile "$testsequfile
|
|---|
| 139 | echo "Sequence: $secondrun" > $testsequfile
|
|---|
| 140 | echo "Night: $date" >> $testsequfile
|
|---|
| 141 | echo "" >> $testsequfile
|
|---|
| 142 | echo "CalRuns: 1" >> $testsequfile
|
|---|
| 143 | echo "PedRuns: 2" >> $testsequfile
|
|---|
| 144 | echo "DatRuns: ${runs[@]}" >> $testsequfile
|
|---|
| 145 | echo "" >> $testsequfile
|
|---|
| 146 |
|
|---|
| 147 | j=$j+1
|
|---|
| 148 | done
|
|---|
| 149 | done
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 | echo "# test sequences: ${#testsequences[@]}"
|
|---|
| 153 | echo "# train sequences: ${#trainsequences[@]}"
|
|---|
| 154 |
|
|---|
| 155 | echo "writing dataset files $mcdataset and $mcdataset2"
|
|---|
| 156 |
|
|---|
| 157 | echo "AnalysisNumber: 1 " > $mcdataset
|
|---|
| 158 | echo "" >> $mcdataset
|
|---|
| 159 | echo "SequencesOn: ${trainsequences[@]}" >> $mcdataset
|
|---|
| 160 | echo "" >> $mcdataset
|
|---|
| 161 | echo "SequencesOff: ${testsequences[@]}" >> $mcdataset
|
|---|
| 162 | echo "" >> $mcdataset
|
|---|
| 163 | echo "" >> $mcdataset
|
|---|
| 164 |
|
|---|
| 165 | echo "AnalysisNumber: 1 " > $mcdataset2
|
|---|
| 166 | echo "" >> $mcdataset2
|
|---|
| 167 | echo "SequencesOn: ${testsequences[@]}" >> $mcdataset2
|
|---|
| 168 | echo "" >> $mcdataset2
|
|---|
| 169 | echo "" >> $mcdataset2
|
|---|
| 170 |
|
|---|
| 171 | for (( i=0 ; i < ${#testsequences[@]} ; i++ ))
|
|---|
| 172 | do
|
|---|
| 173 | numtrain=${trainsequences[$i]}
|
|---|
| 174 | 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
|
|---|
| 179 |
|
|---|
| 180 | numtest=${testsequences[$i]}
|
|---|
| 181 | 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
|
|---|
| 186 | done
|
|---|
| 187 |
|
|---|
| 188 |
|
|---|
| 189 | if [ "$trainenergy" == "yes" ]
|
|---|
| 190 | then
|
|---|
| 191 | echo "creating rf-root-file for energy-estimation..."
|
|---|
| 192 | cd $mars
|
|---|
| 193 | logfile=$setupdir/trainenergy.log
|
|---|
| 194 |
|
|---|
| 195 | root -q -b $mars/datacenter/macros/trainenergy.C+\("\"$mcdataset\""\,"\"$setupdir/\""\) | tee $logfile
|
|---|
| 196 | fi
|
|---|