source: branches/Mars_IncreaseNsb/scripts/dospectrum@ 19344

Last change on this file since 19344 was 8648, checked in by Daniela Dorner, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 8.1 KB
Line 
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 ganymed and/or
49# the other spondes. To do so, please set the variables $doganymed and
50# $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
66path=/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# standard condor path in your Mars directory
71condorpath=condor
72# path to store your resourcefiles
73# you should have there the ganymed.rc, which you want to use
74# and your sponde.rc files
75rcpath=$path/resources
76ganymedrc=$rcpath/ganymed_wobble_set5_final.rc
77# outpath for your spectrum results
78# a directory for each set of cuts will be created there and
79# the ganymed and sponde output will be stored in these directories
80specpath=$path/results/spectrumSet5
81# name of your dataset
82# it has to be stored as dataset$dataset.txt in the directory
83# $path/datasets
84dataset="20070001"
85# this is the name of the condor-dag file, which you have to submit
86# with condor_submit_dag from your Mars directory
87dagfile=$condorpath/spectrumSet5.dag
88# here you define whether ganymed still has to be done
89# if yes, set the variable $doganymed to "yes"
90#doganymed="yes"
91doganymed="no"
92# sponde.rc files have to be in the directory $rcpath
93# they need to have the naming sponde1.rc, sponde2.rc, sponde3.rc
94# (numbers in the following array)
95# the sponde.root files will be named in the same way (sponde(num).root)
96spondes=( 1 2 3 4 12 13 14 15 )
97# in this array you define whether the sponde is already done
98spondedones=( "done" "" "" "" "" "" "" "" )
99
100# this is the mc dataset, which has been created with the script
101# preparemc, make sure to use the correct path
102mcdataset=$path/mc/mcdataset-for-sponde.txt
103
104# values for par3
105par3step=0.01
106par3numminus=9
107par3num=11
108# values for par1
109par1step=0.005
110par1numminus=1
111par1num=7
112
113#
114# end of setup
115#-----------------------------------------------------------------------------
116# beginning of script
117#
118
119# some checks
120# checking if the given files and paths are existing
121if ! [ -e $mcdataset ]
122then
123 echo "Your mc dataset file $mcdataset does not exist."
124 exit
125fi
126if ! [ -e $specpath ]
127then
128 echo "Your output path $specpath does not exist."
129 exit
130fi
131if ! [ -e $path/datasets/dataset$dataset.txt ]
132then
133 echo "Your dataset file $path/datasets/dataset$dataset.txt does not exist."
134 exit
135fi
136if ! [ -e $ganymedrc ]
137then
138 echo "Your ganymed rc file $ganymedrc does not exist."
139 exit
140fi
141for (( l=0 ; l < ${#spondes[@]} ; l++ ))
142do
143 if ! [ -e $rcpath/sponde${spondes[$l]}.rc ]
144 then
145 echo "Your sponde rc file $rcpath/sponde${spondes[$l]}.rc does not exist."
146 exit
147 fi
148done
149
150# get the parameters
151par3=`cat $ganymedrc | grep 'Cut1.Param3' | cut -d: -f2`
152par1=`cat $ganymedrc | grep 'Cut1.Param1' | cut -d: -f2`
153echo "parameters: "
154echo " par3= $par3"
155echo " par1= $par1"
156echo ""
157
158# calculate the parameters with which you start
159start3=`echo $par3 - \( $par3numminus*$par3step \) | bc `
160start1=`echo $par1 - \( $par1numminus*$par1step \) | bc `
161echo "start: "
162echo " par1: $start1 "
163echo " par3: $start3"
164echo ""
165
166
167# function to print the lines for ganymed to the dag file
168function printganydagentry()
169{
170 if [ "$doganymed" = "yes" ]
171 then
172 echo "JOB ds"$dataset"gany"$name" "$condorpath"/processds.submit"
173 else
174 echo "JOB ds"$dataset"gany"$name" "$condorpath"/processds.submit DONE"
175 fi
176 echo "VARS ds"$dataset"gany"$name" path=\"$path\""
177 echo "VARS ds"$dataset"gany"$name" out=\"$outpath\""
178 echo "VARS ds"$dataset"gany"$name" ds=\"$dataset\""
179 echo "VARS ds"$dataset"gany"$name" num=\"$dataset\""
180 echo "VARS ds"$dataset"gany"$name" rc=\"$rcfile\""
181 echo ""
182}
183
184# function to print the lines for sponde to the dag file
185function printspecdagentry()
186{
187 sponderc=$rcpath/sponde_wobble$1.rc
188 if [ "$2" = "done" ]
189 then
190 echo "JOB ds"$dataset"spec"$1"_"$name" "$condorpath"/processsponde.submit DONE"
191 else
192 echo "JOB ds"$dataset"spec"$1"_"$name" "$condorpath"/processsponde.submit"
193 fi
194 echo "VARS ds"$dataset"spec"$1"_"$name" path=\""$path"\""
195 echo "VARS ds"$dataset"spec"$1"_"$name" out=\""$outpath"\""
196 echo "VARS ds"$dataset"spec"$1"_"$name" rc=\""$sponderc"\""
197 echo "VARS ds"$dataset"spec"$1"_"$name" spondenum=\""$1"\""
198 echo "VARS ds"$dataset"spec"$1"_"$name" mcds=\""$mcdataset"\""
199 echo "VARS ds"$dataset"spec"$1"_"$name" num=\""$dataset"\""
200 echo ""
201 echo "PARENT ds"$dataset"gany"$name" CHILD ds"$dataset"spec"$1"_"$name
202 echo ""
203}
204
205echo "writing dag file $dagfile for dataset $dataset"
206echo "# dag file for dataset $dataset" > $dagfile
207echo "" >> $dagfile
208val1=$start1
209val3=$start3
210count=0
211for (( i=0 ; i < $par3num ; i++ ))
212do
213 for (( j=0 ; j < $par1num ; j++ ))
214 do
215 name=${val1}_${val3}
216 outpath=$specpath/ganyspec$name
217 rcfile=$outpath/ganymed_${name}_onoff.rc
218 if ! [ -d $outpath ]
219 then
220 mkdir -v $outpath
221 fi
222 cat $ganymedrc | sed -e s/"${par1}"/" ${val1}"/ -e s/"${par3}"/" ${val3}"/ > $rcfile
223 val1=`echo $val1 + $par1step | bc`
224 echo " writing dag entry for set of cuts par1: $val1, par3: $val3"
225 echo "# ganymed and sponde for dataset $dataset with cuts $name" >> $dagfile
226 echo "" >> $dagfile
227 printganydagentry >> $dagfile
228 for (( k=0 ; k < ${#spondes[@]} ; k++ ))
229 do
230 printspecdagentry ${spondes[$k]} ${spondedones[$k]} >> $dagfile
231 done
232 echo "" >> $dagfile
233 count=`echo $count + 1 | bc`
234 done
235 val3=`echo $val3 + $par3step | bc`
236 val1=$start1
237done
238
239echo ""
240echo "finished writing condor dag file "$dagfile
241echo "in total $count different sets of cuts are used"
242echo ""
243echo "you can submit it now with \"condor_submit_dag -f -maxidle 7 $dagfile\" from your Mars directory"
244echo ""
245
Note: See TracBrowser for help on using the repository browser.