| 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 the ganymed.rc files with different parameter sets (the
|
|---|
| 32 | # parameters 1 and 3 are changed in steps). Then the script runs ganymed and
|
|---|
| 33 | # sponde for this different parameter sets.
|
|---|
| 34 | #
|
|---|
| 35 | # variables, that have to be set by the user:
|
|---|
| 36 | #
|
|---|
| 37 | # - path directory, where the files are stored
|
|---|
| 38 | # - mars directory, where your Mars version is stored
|
|---|
| 39 | # - dataset dataset file, which shall be used (filename without path)
|
|---|
| 40 | # the file has to be stored in the dataset directory in the
|
|---|
| 41 | # path
|
|---|
| 42 | # - par*step step width for changing the parameter *
|
|---|
| 43 | # - par*numminus number of steps going to smaller values of the parameter *
|
|---|
| 44 | # - par*num number of steps for changing the parameter *
|
|---|
| 45 | # - spondenum number of sponde rc file (also of the root and log file)
|
|---|
| 46 | # - ganymednum number of ganymed root file
|
|---|
| 47 | #
|
|---|
| 48 | # Please make sure, that you provide the following files:
|
|---|
| 49 | # - $path/setup/ganymed$ganymednum.rc
|
|---|
| 50 | # - $path/setup/sponde$spondenum.rc
|
|---|
| 51 | # - $path/datasets/mcdataset-for-sponde.txt (if you use the script preparemc,
|
|---|
| 52 | # this file is produced automatically)
|
|---|
| 53 | # - $path/datasets/$datasetfilename (you give the datasetfilename below, but
|
|---|
| 54 | # you have to make sure, that it is in the directory $path/datasets
|
|---|
| 55 | #
|
|---|
| 56 | # To re-run ganymed (e.g. with new Software-Version), you have to delete
|
|---|
| 57 | # the ganymed*.root files or set a new ganymednum.
|
|---|
| 58 | #
|
|---|
| 59 | ##############################################################################
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | # to be set by the user
|
|---|
| 63 | path=/home/dorner/crabspectrum
|
|---|
| 64 | mars=/home/dorner/mars.cvs
|
|---|
| 65 | datasetfilename=datasetcrab2005-2.txt
|
|---|
| 66 | spondenum=0
|
|---|
| 67 | ganymednum=1
|
|---|
| 68 | # settings for parameter 3
|
|---|
| 69 | par3step=0.005
|
|---|
| 70 | par3numminus=10
|
|---|
| 71 | par3num=13
|
|---|
| 72 | # settings for parameter 1
|
|---|
| 73 | par1step=0.005
|
|---|
| 74 | par1numminus=1
|
|---|
| 75 | par1num=7
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 | function printsetup()
|
|---|
| 79 | {
|
|---|
| 80 | echo "you set the following parameters: "
|
|---|
| 81 | echo " path: $path "
|
|---|
| 82 | echo " ganymedrc: $ganymedrc"
|
|---|
| 83 | echo " sponderc: $sponderc"
|
|---|
| 84 | echo " dataset: $dataset"
|
|---|
| 85 | echo " mcdataset: $mcdataset"
|
|---|
| 86 | echo " spondenum: $spondenum"
|
|---|
| 87 | echo " ganymednum: $ganymednum"
|
|---|
| 88 | echo " par1: -$par1numminus to $par1num in $par1step steps"
|
|---|
| 89 | echo " par3: -$par3numminus to $par3num in $par3step steps"
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | #general variables
|
|---|
| 93 | datasetpath=$path/datasets
|
|---|
| 94 | setuppath=$path/setup
|
|---|
| 95 | #resultpath=$path/ganyspec
|
|---|
| 96 | resultpath=$path/ganyspec`echo $datasetfilename | sed -e 's/[.]txt//'`
|
|---|
| 97 | dataset=$datasetpath/$datasetfilename
|
|---|
| 98 | mcdataset=$datasetpath/mcdataset-for-sponde.txt
|
|---|
| 99 | ganymedrc=$setuppath/ganymed$ganymednum.rc
|
|---|
| 100 | sponderc=$setuppath/sponde$spondenum.rc
|
|---|
| 101 | setuplog=$setuppath/setup`date +%F-%H-%M-%S`.log
|
|---|
| 102 |
|
|---|
| 103 | if ! ls $ganymedrc >/dev/null 2>&1
|
|---|
| 104 | then
|
|---|
| 105 | echo "couldn't find $ganymedrc."
|
|---|
| 106 | echo "please provide the file $ganymedrc and re-run the script"
|
|---|
| 107 | exit
|
|---|
| 108 | fi
|
|---|
| 109 |
|
|---|
| 110 | if ! ls $sponderc >/dev/null 2>&1
|
|---|
| 111 | then
|
|---|
| 112 | echo "couldn't find $sponderc."
|
|---|
| 113 | echo "do you want to continue anyhow? (ganymed will be done)"
|
|---|
| 114 | echo "please insert y, if you want continue"
|
|---|
| 115 | echo " n, if you want quit"
|
|---|
| 116 |
|
|---|
| 117 | answer=`head -n 1`
|
|---|
| 118 | case $answer in
|
|---|
| 119 | y) echo "continue creating rc files and running ganymed"
|
|---|
| 120 | ;;
|
|---|
| 121 | n) echo "please provide the file $ganymedrc and re-run the script"
|
|---|
| 122 | exit
|
|---|
| 123 | ;;
|
|---|
| 124 | *) echo "your answer is not clear -> exit"
|
|---|
| 125 | exit
|
|---|
| 126 | ;;
|
|---|
| 127 | esac
|
|---|
| 128 |
|
|---|
| 129 | fi
|
|---|
| 130 |
|
|---|
| 131 | #start of the script
|
|---|
| 132 | printsetup
|
|---|
| 133 | printsetup > $setuplog
|
|---|
| 134 |
|
|---|
| 135 | mkdir -pv $resultpath
|
|---|
| 136 |
|
|---|
| 137 | echo "generating the ganymed.rc files with different parameter sets"
|
|---|
| 138 | # generating the ganymed.rc files with different parameter sets
|
|---|
| 139 | par3=`cat $ganymedrc | grep 'Cut1.Param3' | cut -d: -f2`
|
|---|
| 140 | par1=`cat $ganymedrc | grep 'Cut1.Param1' | cut -d: -f2`
|
|---|
| 141 |
|
|---|
| 142 | echo "parameter: 3 $par3 , 1 $par1"
|
|---|
| 143 |
|
|---|
| 144 | start3=`echo $par3 - \( $par3numminus*$par3step \) | bc `
|
|---|
| 145 | start1=`echo $par1 - \( $par1numminus*$par1step \) | bc `
|
|---|
| 146 | echo "start: 1: $start1 3: $start3"
|
|---|
| 147 |
|
|---|
| 148 | val1=$start1
|
|---|
| 149 | val3=$start3
|
|---|
| 150 |
|
|---|
| 151 | for (( i=0 ; i < $par3num ; i++ ))
|
|---|
| 152 | do
|
|---|
| 153 | for (( j=0 ; j < $par1num ; j++ ))
|
|---|
| 154 | do
|
|---|
| 155 | # echo "i: $i - j: $j ------- par1: $val1 and par3: $val3"
|
|---|
| 156 | dir=$resultpath/set${val1}_${val3}
|
|---|
| 157 | if ! ls $dir >/dev/null 2>&1
|
|---|
| 158 | then
|
|---|
| 159 | mkdir -pv $dir
|
|---|
| 160 | fi
|
|---|
| 161 | # rcfile=$dir/ganymed_${val1}_${val3}_onoff.rc
|
|---|
| 162 | rcfile=$dir/`basename $ganymedrc`
|
|---|
| 163 | if ! ls $rcfile >/dev/null 2>&1
|
|---|
| 164 | then
|
|---|
| 165 | cat $ganymedrc | sed -e s/"${par1}"/" ${val1}"/ -e s/"${par3}"/" ${val3}"/ > $rcfile
|
|---|
| 166 | else
|
|---|
| 167 | echo "rcfile $rcfile already exists"
|
|---|
| 168 | fi
|
|---|
| 169 | val1=`echo $val1 + $par1step | bc`
|
|---|
| 170 | done
|
|---|
| 171 | val3=`echo $val3 + $par3step | bc`
|
|---|
| 172 | val1=$start1
|
|---|
| 173 | done
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 | # running ganymed and sponde for different parameter sets
|
|---|
| 177 |
|
|---|
| 178 | # function running ganymed and sponde for a set of cuts
|
|---|
| 179 | function dospec()
|
|---|
| 180 | {
|
|---|
| 181 | cd $mars
|
|---|
| 182 |
|
|---|
| 183 | name=$set/ganymed`printf %08d $ganymednum`
|
|---|
| 184 | ganymedfile=$name.root
|
|---|
| 185 | if ! ls $ganymedfile >/dev/null 2>&1
|
|---|
| 186 | then
|
|---|
| 187 | cd $mars
|
|---|
| 188 | # rc=`ls $set/ganymed_*onoff.rc`
|
|---|
| 189 | ganymedlog=$name.log
|
|---|
| 190 | echo "starting ganymed for set $set ..."
|
|---|
| 191 | if ! condor_run ./ganymed -b -f --n=$ganymednum --log=$ganymedlog --out=$set --config=$set/`basename $ganymedrc` $dataset >/dev/null
|
|---|
| 192 | then
|
|---|
| 193 | echo "condor is not working "
|
|---|
| 194 | return
|
|---|
| 195 | fi
|
|---|
| 196 | else
|
|---|
| 197 | echo "ganymed for set $set already done => continue with sponde"
|
|---|
| 198 | fi
|
|---|
| 199 |
|
|---|
| 200 | if ! ls $sponderc >/dev/null 2>&1
|
|---|
| 201 | then
|
|---|
| 202 | echo "ERROR: spondercfile $sponderc is missing"
|
|---|
| 203 | return
|
|---|
| 204 | fi
|
|---|
| 205 | spondefile=$set/sponde$spondenum-g$ganymednum.root
|
|---|
| 206 | spondelog=$set/sponde$spondenum-g$ganymednum.log
|
|---|
| 207 | if ! ls $spondefile >/dev/null 2>&1
|
|---|
| 208 | then
|
|---|
| 209 | echo "starting sponde for set $set ..."
|
|---|
| 210 | if ! condor_run ./sponde -b -f --log=$spondelog --config=$sponderc -f $ganymedfile $mcdataset $spondefile >/dev/null
|
|---|
| 211 | then
|
|---|
| 212 | echo "condor is not working "
|
|---|
| 213 | return
|
|---|
| 214 | fi
|
|---|
| 215 | echo "finished sponde for set $set ..."
|
|---|
| 216 | else
|
|---|
| 217 | echo "sponde $spondenum for set $set already done => please remove sponde files or give new spondenum"
|
|---|
| 218 | fi
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 | sets=`find $resultpath -type d`
|
|---|
| 223 | for set in ${sets[@]}
|
|---|
| 224 | do
|
|---|
| 225 | # echo "set: "$set
|
|---|
| 226 | if [ "$set" == "$resultpath" ]
|
|---|
| 227 | then
|
|---|
| 228 | continue
|
|---|
| 229 | fi
|
|---|
| 230 | dospec &
|
|---|
| 231 | sleep 3
|
|---|
| 232 | done
|
|---|
| 233 |
|
|---|
| 234 |
|
|---|