Changeset 8626 for trunk/MagicSoft/Mars/scripts/preparemc
- Timestamp:
- 06/29/07 15:33:20 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/scripts/preparemc
r8227 r8626 1 1 #!/bin/sh 2 #3 2 # ======================================================================== 4 3 # … … 20 19 # Author(s): Daniela Dorner 05/2006 <mailto:dorner@astro.uni-wuerzburg.de> 21 20 # 22 # Copyright: MAGIC Software Development, 2000-200 621 # Copyright: MAGIC Software Development, 2000-2007 23 22 # 24 23 # … … 33 32 # 34 33 # variables, that have to be set by the user: 35 # - dirdirectory, where the mc sequence and dataset files are stored34 # - path directory, where the mc sequence and dataset files are stored 36 35 # be careful: don't move the sequence files afterwards, as the 37 36 # paths are stored in the datasetfiles 38 # - mars directory, where your Mars version is stored39 # only needed, if you want to create a rf-root-file for the40 # energy estimation41 37 # - zdmin minimum zenith distance 42 38 # - zdmax maximum zenith distance … … 48 44 # - numruns num of runs, that are in the sequence file, which are used 49 45 # 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\""\) 51 51 # 52 # Remark: You have to run the script in your Mars directory. 52 53 # 53 54 ############################################################################## 54 55 55 56 57 path=/home/dorner/final_analysis 58 mcoutpath=$path/mc 59 macrospath=$path/macros 60 mcdataset=$mcoutpath/mcdataset.txt 61 mcdataset2=$mcoutpath/mcdataset2.txt 56 62 57 #to be set by the user 58 dir=/home/dorner/crabspectrum 59 mars=/home/dorner/mars.cvs 60 zdmin=5 63 zdmin=17 61 64 zdmax=35 62 65 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" 66 modes=( "02" ) # nowobble 67 numruns=3 68 68 69 # be careful with $date, when path changes 70 mcpath=/magic/montecarlo 69 71 70 # begin of script71 datasetdir=$dir/datasets72 sequencedir=$dir/sequences73 setupdir=$dir/setup74 mcdir=/magic/montecarlo75 mcrawdir=$mcdir/rawfiles76 mcstardir=$mcdir/star77 mcdataset=$datasetdir/mcdataset-test-train.txt78 mcdataset2=$datasetdir/mcdataset-for-sponde.txt79 80 # make directories81 mkdir -pv $dir82 mkdir -v $sequencedir83 mkdir -v $datasetdir84 85 #calculation of the zbin86 72 zbinmin=`echo "scale=2 ; 100*(1 - c($zdmin*3.14/180))+1" | bc -l` 87 73 zbinmax=`echo "scale=2 ; 100*(1 - c($zdmax*3.14/180))+1" | bc -l` 74 88 75 zbinmin=`echo $zbinmin | cut -d. -f1` 89 76 zbinmax=`echo $zbinmax | cut -d. -f1` 90 echo "zd: min: $zbinmin max: $zbinmax" 91 echo "numruns: $numruns" 77 78 echo "zd: min: $zdmin max: $zdmax" 79 echo "zbin: min: $zbinmin max: $zbinmax" 80 echo "$numruns runs are classified as test the rest as train" 92 81 93 82 j=0 94 for mode in $ {modes[@]}83 for mode in $modes 95 84 do 96 echo "mode: "$mode97 85 for (( i=$zbinmin ; i < $zbinmax ; i++ )) 98 86 do 99 87 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" " "`) 105 90 if [ "$runs" = "" ] 106 91 then … … 108 93 continue 109 94 fi 95 echo "found ${#runs[@]} Gamma MC files in path "$path 110 96 97 runsforfirst="" 111 98 firstrun=${runs[0]} 112 99 secondrun=${runs[${numruns}]} … … 119 106 unset runs[$k] 120 107 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'` 124 109 125 trainsequfile=$ sequencedir/sequence$firstrunno.txt110 trainsequfile=$mcoutpath/sequence$firstrunno.txt 126 111 trainsequences[$j]=$firstrunno 127 112 echo " writing train-sequfile "$trainsequfile … … 133 118 echo "DatRuns: $firstrun$runsforfirst" >> $trainsequfile 134 119 echo "" >> $trainsequfile 120 echo "MonteCarlo: Yes" >> $trainsequfile 121 echo "" >> $trainsequfile 135 122 136 testsequfile=$ sequencedir/sequence$secondrunno.txt123 testsequfile=$mcoutpath/sequence$secondrunno.txt 137 124 testsequences[$j]=$secondrunno 138 echo "writing test-sequfile "$testsequfile125 # echo "writing test-sequfile "$testsequfile 139 126 echo "Sequence: $secondrun" > $testsequfile 140 127 echo "Night: $date" >> $testsequfile … … 144 131 echo "DatRuns: ${runs[@]}" >> $testsequfile 145 132 echo "" >> $testsequfile 133 echo "MonteCarlo: Yes" >> $testsequfile 134 echo "" >> $testsequfile 146 135 147 136 j=$j+1 … … 149 138 done 150 139 151 152 140 echo "# test sequences: ${#testsequences[@]}" 153 141 echo "# train sequences: ${#trainsequences[@]}" 154 155 echo "writing dataset files $mcdataset and $mcdataset2"156 142 157 143 echo "AnalysisNumber: 1 " > $mcdataset … … 173 159 numtrain=${trainsequences[$i]} 174 160 notrain=`echo $numtrain | cut -c 0-4` 175 echo "Sequence$numtrain.File: $ sequencedir/sequence$numtrain.txt" >> $mcdataset176 echo "Sequence$numtrain.Dir: $mc stardir/$notrain/$numtrain" >> $mcdataset177 echo "Sequence$numtrain.File: $ sequencedir/sequence$numtrain.txt" >> $mcdataset2178 echo "Sequence$numtrain.Dir: $mc stardir/$notrain/$numtrain" >> $mcdataset2161 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 179 165 180 166 numtest=${testsequences[$i]} 181 167 notest=`echo $numtest | cut -c 0-4` 182 echo "Sequence$numtest.File: $ sequencedir/sequence$numtest.txt" >> $mcdataset183 echo "Sequence$numtest.Dir: $mc stardir/$notrain/$numtrain" >> $mcdataset184 echo "Sequence$numtest.File: $ sequencedir/sequence$numtest.txt" >> $mcdataset2185 echo "Sequence$numtest.Dir: $mc stardir/$notrain/$numtrain" >> $mcdataset2168 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 186 172 done 187 173 188 174 189 if [ "$trainenergy" == "yes" ] 190 then 191 echo "creating rf-root-file for energy-estimation..." 192 cd $mars 193 logfile=$setupdir/trainenergy.log 175 logfile=$mcoutpath/trainenergy.log 176 rffile=$mcoutpath/rf-energy.root 194 177 195 root -q -b $mars/datacenter/macros/trainenergy.C+\("\"$mcdataset\""\,"\"$setupdir/\""\) | tee $logfile 196 fi 178 echo "mcdataset: $mcdataset" 179 echo "rffile: $rffile" 180 echo "macrospath: $macrospath" 181 root -q -b $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) | tee $logfile 182
Note:
See TracChangeset
for help on using the changeset viewer.