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 06/2007 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2007
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | ##############################################################################
|
---|
28 | #
|
---|
29 | # This script is:
|
---|
30 | # - writing rc-files with different sets of cuts
|
---|
31 | # the set of cuts can be steered with the variables
|
---|
32 | # $par3step, $par3numminus, $par3num and
|
---|
33 | # $par1step, $par1numminus, $par1num
|
---|
34 | # par*step step width for changing the parameter *
|
---|
35 | # (suggested value: 0.005)
|
---|
36 | # par*numminus number of steps going to smaller values of the parameter *
|
---|
37 | # (starting value in your ganymed.rc file)
|
---|
38 | # par*num number of steps for changing the parameter *
|
---|
39 | # par3: Cut1.Param3 from the ganymed.rc file
|
---|
40 | # par1: Cut1.Param1 from the ganymed.rc file
|
---|
41 | # - writing a condor dag file for spectrum study
|
---|
42 | # With submitting this dag file with condor_submit_dag to condor from your
|
---|
43 | # Mars directroy you are running ganymed and sponde for all different rc
|
---|
44 | # files. The condor dag man is taking care of the order of the jobs,
|
---|
45 | # i.e. that sponde is started just when ganymed has been finished.
|
---|
46 | #
|
---|
47 | # To start several spondes please set the arrays $spondes.
|
---|
48 | # It is also possible to start new spondes without rerunning
|
---|
49 | # ganymed and/or the other spondes. To do so, please set the
|
---|
50 | # variables $doganymed and $spondedones accordingly
|
---|
51 | #
|
---|
52 | # Remark: You have to submit the condor dag file from your Mars directory.
|
---|
53 | #
|
---|
54 | # For more detailed information read the comments directly before
|
---|
55 | # each variable.
|
---|
56 | #
|
---|
57 | ##############################################################################
|
---|
58 | #
|
---|
59 |
|
---|
60 | #
|
---|
61 | # instructions and setup of the script
|
---|
62 | # please set the variables according to your analysis
|
---|
63 | #
|
---|
64 |
|
---|
65 | # path for you analysis
|
---|
66 | path=/home/dorner/final_analysis
|
---|
67 | # path where your condor dagfile is stored and where you need
|
---|
68 | # the files processds.submit and processsponde.submit
|
---|
69 | condorpath=$path/condor
|
---|
70 | # path to store your resourcefiles
|
---|
71 | # you should have there the ganymed.rc, which you want to use
|
---|
72 | # and your sponde.rc files
|
---|
73 | rcpath=$path/resources
|
---|
74 | ganymedrc=$rcpath/ganymed_onoff.rc
|
---|
75 | # outpath for your spectrum results
|
---|
76 | # a directory for each set of cuts will be created there and
|
---|
77 | # the ganymed and sponde output will be stored in these directories
|
---|
78 | specpath=/results/spectrumSet2
|
---|
79 | # name of your dataset
|
---|
80 | # it has to be stored as dataset$dataset.txt in the directory
|
---|
81 | # $path/datasets
|
---|
82 | dataset="20060002"
|
---|
83 | # this is the name of the condor-dag file, which you have to submit
|
---|
84 | # with condor_submit_dag from your Mars directory
|
---|
85 | dagfile=$condorpath/set2spectrum.dag3
|
---|
86 | # here you define whether ganymed still has to be done
|
---|
87 | # if yes, set the variable $doganymed to "yes"
|
---|
88 | #doganymed="yes"
|
---|
89 | doganymed="no"
|
---|
90 | # sponde.rc files have to be in the directory $rcpath
|
---|
91 | # they need to have the naming sponde1.rc, sponde2.rc, sponde3.rc
|
---|
92 | # (numbers in the following array)
|
---|
93 | # the sponde.root files will be named in the same way (sponde(num).root)
|
---|
94 | spondes=( 1 2 )
|
---|
95 | # in this array you define whether the sponde is already done
|
---|
96 | spondedones=( "done" "" )
|
---|
97 |
|
---|
98 | # this is the mc dataset, which has been created with the script
|
---|
99 | # preparemc
|
---|
100 | mcdataset=$path/mc/mcdataset2.txt
|
---|
101 |
|
---|
102 | # values for par3
|
---|
103 | par3step=0.005
|
---|
104 | par3numminus=10
|
---|
105 | par3num=13
|
---|
106 | # values for par1
|
---|
107 | par1step=0.005
|
---|
108 | par1numminus=1
|
---|
109 | par1num=7
|
---|
110 |
|
---|
111 | #
|
---|
112 | # end of setup
|
---|
113 | # beginning of script
|
---|
114 | #
|
---|
115 |
|
---|
116 | # some checks
|
---|
117 | # checking if the given files and paths are existing
|
---|
118 | if ! [ -e $mcdataset ]
|
---|
119 | then
|
---|
120 | echo "Your mc dataset file $mcdataset does not exist."
|
---|
121 | exit
|
---|
122 | fi
|
---|
123 | if ! [ -e $path$specpath ]
|
---|
124 | then
|
---|
125 | echo "Your output path $path$specpath does not exist."
|
---|
126 | exit
|
---|
127 | fi
|
---|
128 | if ! [ -e $path/datasets/dataset$dataset.txt ]
|
---|
129 | then
|
---|
130 | echo "Your dataset file $path/datasets/dataset$dataset.txt does not exist."
|
---|
131 | exit
|
---|
132 | fi
|
---|
133 | if ! [ -e $ganymedrc ]
|
---|
134 | then
|
---|
135 | echo "Your ganymed rc file $ganymedrc does not exist."
|
---|
136 | exit
|
---|
137 | fi
|
---|
138 | for (( l=0 ; l < ${#spondes[@]} ; l++ ))
|
---|
139 | do
|
---|
140 | if ! [ -e $rcpath/sponde${spondes[$l]}.rc ]
|
---|
141 | then
|
---|
142 | echo "Your sponde rc file $rcpath/sponde${spondes[$l]}.rc does not exist."
|
---|
143 | exit
|
---|
144 | fi
|
---|
145 | done
|
---|
146 |
|
---|
147 | # get the parameters
|
---|
148 | par3=`cat $ganymedrc | grep 'Cut1.Param3' | cut -d: -f2`
|
---|
149 | par1=`cat $ganymedrc | grep 'Cut1.Param1' | cut -d: -f2`
|
---|
150 | echo "parameters: "
|
---|
151 | echo " par3= $par3"
|
---|
152 | echo " par1= $par1"
|
---|
153 | echo ""
|
---|
154 |
|
---|
155 | # calculate the parameters with which you start
|
---|
156 | start3=`echo $par3 - \( $par3numminus*$par3step \) | bc `
|
---|
157 | start1=`echo $par1 - \( $par1numminus*$par1step \) | bc `
|
---|
158 | echo "start: "
|
---|
159 | echo " par1: $start1 "
|
---|
160 | echo " par3: $start3"
|
---|
161 | echo ""
|
---|
162 |
|
---|
163 |
|
---|
164 | # function to print the lines for ganymed to the dag file
|
---|
165 | function printganydagentry()
|
---|
166 | {
|
---|
167 | if [ "$doganymed" = "yes" ]
|
---|
168 | then
|
---|
169 | echo "JOB gany$name $condorpath/processds.submit"
|
---|
170 | else
|
---|
171 | echo "JOB gany$name $condorpath/processds.submit DONE"
|
---|
172 | fi
|
---|
173 | echo "VARS gany$name path=\"$path\""
|
---|
174 | echo "VARS gany$name out=\"$dir\""
|
---|
175 | echo "VARS gany$name ds=\"$dataset\""
|
---|
176 | echo "VARS gany$name num=\"$dataset\""
|
---|
177 | echo "VARS gany$name rc=\"$rcfile\""
|
---|
178 | echo ""
|
---|
179 | }
|
---|
180 |
|
---|
181 | # function to print the lines for sponde to the dag file
|
---|
182 | function printspecdagentry()
|
---|
183 | {
|
---|
184 | sponderc=$rcpath/sponde$1.rc
|
---|
185 | if [ "$2" = "done" ]
|
---|
186 | then
|
---|
187 | echo "JOB spec$1_$name $condorpath/processsponde.submit DONE"
|
---|
188 | else
|
---|
189 | echo "JOB spec$1_$name $condorpath/processsponde.submit"
|
---|
190 | fi
|
---|
191 | echo "VARS spec$1_$name path=\"/home/dorner/final_analysis\""
|
---|
192 | echo "VARS spec$1_$name out=\"$outpath\""
|
---|
193 | echo "VARS spec$1_$name rc=\"$sponderc\""
|
---|
194 | echo "VARS spec$1_$name spondenum=\"$1\""
|
---|
195 | echo "VARS spec$1_$name mcds=\"$mcdataset\""
|
---|
196 | echo "VARS spec$1_$name num=\"$dataset\""
|
---|
197 | echo ""
|
---|
198 | echo "PARENT gany$name CHILD spec$1_$name "
|
---|
199 | echo ""
|
---|
200 | }
|
---|
201 |
|
---|
202 | echo "writing dag file $dagfile for dataset $dataset"
|
---|
203 | echo "# dag file for dataset $dataset" > $dagfile
|
---|
204 | echo "" >> $dagfile
|
---|
205 | val1=$start1
|
---|
206 | val3=$start3
|
---|
207 | count=0
|
---|
208 | for (( i=0 ; i < $par3num ; i++ ))
|
---|
209 | do
|
---|
210 | for (( j=0 ; j < $par1num ; j++ ))
|
---|
211 | do
|
---|
212 | name=${val1}_${val3}
|
---|
213 | dir=$specpath/ganyspec$name
|
---|
214 | outpath=$path$dir
|
---|
215 | rcfile=$outpath/ganymed_${name}_onoff.rc
|
---|
216 | if ! [ -d $outpath ]
|
---|
217 | then
|
---|
218 | mkdir -v $outpath
|
---|
219 | fi
|
---|
220 | cat $ganymedrc | sed -e s/"${par1}"/" ${val1}"/ -e s/"${par3}"/" ${val3}"/ > $rcfile
|
---|
221 | val1=`echo $val1 + $par1step | bc`
|
---|
222 | echo " writing dag entry for set of cuts par1: $val1, par3: $val3"
|
---|
223 | echo "# ganymed and sponde for dataset $dataset with cuts $name" >> $dagfile
|
---|
224 | echo "" >> $dagfile
|
---|
225 | printganydagentry >> $dagfile
|
---|
226 | for (( k=0 ; k < ${#spondes[@]} ; k++ ))
|
---|
227 | do
|
---|
228 | printspecdagentry ${spondes[$k]} ${spondedones[$k]} >> $dagfile
|
---|
229 | done
|
---|
230 | echo "" >> $dagfile
|
---|
231 | count=`echo $count + 1 | bc`
|
---|
232 | done
|
---|
233 | val3=`echo $val3 + $par3step | bc`
|
---|
234 | val1=$start1
|
---|
235 | done
|
---|
236 |
|
---|
237 | echo ""
|
---|
238 | echo "finished writing condor dag file "$dagfile
|
---|
239 | echo "in total $count different sets of cuts are used"
|
---|
240 | echo ""
|
---|
241 | echo "you can submit it now with \"condor_submit_dag -f $dagfile\" from your Mars directory"
|
---|
242 | echo ""
|
---|
243 |
|
---|