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 | # - sourcefile directory, where your Mars version is stored
|
---|
42 | # only needed, if you want to create a rf-root-file for the
|
---|
43 | # energy estimation
|
---|
44 | # be careful, you also have to set the mars path in sourcefile
|
---|
45 | # - zdmin minimum zenith distance
|
---|
46 | # - zdmax maximum zenith distance
|
---|
47 | # - psf psf
|
---|
48 | # at the moment mc with psf 14 and 20 is available
|
---|
49 | # - modes observation mode
|
---|
50 | # the explanation for the modes can be found in
|
---|
51 | # /montecarlo/rawfiles/README.txt
|
---|
52 | # - numruns num of runs, that are in the sequence file, which are used for
|
---|
53 | # training (SequencesOn in $mcdataset)
|
---|
54 | #
|
---|
55 | # If you want to create a rf-root-file for the energy estimation, you have to
|
---|
56 | # comment out the 'exit' before the last lines of the script.
|
---|
57 | #
|
---|
58 | ##############################################################################
|
---|
59 |
|
---|
60 | #function to create directory
|
---|
61 | function makedir()
|
---|
62 | {
|
---|
63 | if [ ! -d $@ ]
|
---|
64 | then
|
---|
65 | mkdir -pv $@
|
---|
66 | if [ ! -d $@ ]
|
---|
67 | then
|
---|
68 | echo "could not make dir "$@
|
---|
69 | exit
|
---|
70 | fi
|
---|
71 | fi
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 |
|
---|
76 | #to be set by the user
|
---|
77 | dir=/home/operator/mc
|
---|
78 | mars=/home/operator/Mars.cvs
|
---|
79 | sourcefile=$mars/datacenter/scripts/sourcefile
|
---|
80 | zdmin=9
|
---|
81 | zdmax=51
|
---|
82 | psf=14
|
---|
83 | modes=( "02" "04" ) # e.g. nowobble
|
---|
84 | numruns=5
|
---|
85 |
|
---|
86 |
|
---|
87 | makedir $dir
|
---|
88 |
|
---|
89 | #needed if not set in .bashrc or when script is e.g. executed in cronjob
|
---|
90 | export ROOTSYS=/opt/root_v4.04.02g
|
---|
91 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib
|
---|
92 | export PATH=$PATH:$ROOTSYS/bin
|
---|
93 |
|
---|
94 | mcdir=/montecarlo/rawfiles
|
---|
95 | mcdataset=$dir/mcdataset-test-train.txt
|
---|
96 | mcdataset2=$dir/mcdataset-for-ganymed.txt
|
---|
97 |
|
---|
98 | #calculation of the zbin
|
---|
99 | zbinmin=`echo "scale=2 ; 100*(1 - c($zdmin*3.14/180))+1" | bc -l`
|
---|
100 | zbinmax=`echo "scale=2 ; 100*(1 - c($zdmax*3.14/180))+1" | bc -l`
|
---|
101 | zbinmin=`echo $zbinmin | cut -d. -f1`
|
---|
102 | zbinmax=`echo $zbinmax | cut -d. -f1`
|
---|
103 | echo "zd: min: $zbinmin max: $zbinmax"
|
---|
104 | echo "numruns: $numruns"
|
---|
105 |
|
---|
106 | j=0
|
---|
107 | for mode in ${modes[@]}
|
---|
108 | do
|
---|
109 | echo "mode: "$mode
|
---|
110 | for (( i=$zbinmin ; i < $zbinmax ; i++ ))
|
---|
111 | do
|
---|
112 | zbin=`printf %02d $i`
|
---|
113 | echo "zbin: $zbin"
|
---|
114 | path=$mcdir/19$zbin/$mode/$psf
|
---|
115 | runsforfirst=
|
---|
116 |
|
---|
117 | 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" " "`)
|
---|
118 | if [ "$runs" = "" ]
|
---|
119 | then
|
---|
120 | echo " no runs found for zbin $i "
|
---|
121 | continue
|
---|
122 | fi
|
---|
123 |
|
---|
124 | firstrun=${runs[0]}
|
---|
125 | secondrun=${runs[${numruns}]}
|
---|
126 | firstrunno=`printf %08d $firstrun`
|
---|
127 | secondrunno=`printf %08d $secondrun`
|
---|
128 | unset runs[0]
|
---|
129 | for (( k=1 ; k < $numruns ; k++ ))
|
---|
130 | do
|
---|
131 | runsforfirst=$runsforfirst" ${runs[$k]}"
|
---|
132 | unset runs[$k]
|
---|
133 | done
|
---|
134 | date=`echo $path | cut -c 22-31 | sed -e 's/\//-/g'`
|
---|
135 |
|
---|
136 | trainsequfile=$dir/sequence$firstrunno.txt
|
---|
137 | trainsequences[$j]=$firstrunno
|
---|
138 | echo " writing train-sequfile "$trainsequfile
|
---|
139 | echo "Sequence: $firstrun" > $trainsequfile
|
---|
140 | echo "Night: $date" >> $trainsequfile
|
---|
141 | echo "" >> $trainsequfile
|
---|
142 | echo "CalRuns: 1" >> $trainsequfile
|
---|
143 | echo "PedRuns: 2" >> $trainsequfile
|
---|
144 | echo "DatRuns: $firstrun$runsforfirst" >> $trainsequfile
|
---|
145 | echo "" >> $trainsequfile
|
---|
146 |
|
---|
147 | testsequfile=$dir/sequence$secondrunno.txt
|
---|
148 | testsequences[$j]=$secondrunno
|
---|
149 | echo " writing test-sequfile "$testsequfile
|
---|
150 | echo "Sequence: $secondrun" > $testsequfile
|
---|
151 | echo "Night: $date" >> $testsequfile
|
---|
152 | echo "" >> $testsequfile
|
---|
153 | echo "CalRuns: 1" >> $testsequfile
|
---|
154 | echo "PedRuns: 2" >> $testsequfile
|
---|
155 | echo "DatRuns: ${runs[@]}" >> $testsequfile
|
---|
156 | echo "" >> $testsequfile
|
---|
157 |
|
---|
158 | j=$j+1
|
---|
159 | done
|
---|
160 | done
|
---|
161 |
|
---|
162 | echo "# test sequences: ${#testsequences[@]}"
|
---|
163 | echo "# train sequences: ${#trainsequences[@]}"
|
---|
164 |
|
---|
165 | echo "writing dataset files $mcdataset and $mcdataset2"
|
---|
166 |
|
---|
167 | echo "AnalysisNumber: 1 " > $mcdataset
|
---|
168 | echo "" >> $mcdataset
|
---|
169 | echo "SequencesOn: ${trainsequences[@]}" >> $mcdataset
|
---|
170 | echo "" >> $mcdataset
|
---|
171 | echo "SequencesOff: ${testsequences[@]}" >> $mcdataset
|
---|
172 | echo "" >> $mcdataset
|
---|
173 | echo "" >> $mcdataset
|
---|
174 |
|
---|
175 | echo "AnalysisNumber: 1 " > $mcdataset2
|
---|
176 | echo "" >> $mcdataset2
|
---|
177 | echo "SequencesOn: ${testsequences[@]}" >> $mcdataset2
|
---|
178 | echo "" >> $mcdataset2
|
---|
179 | echo "" >> $mcdataset2
|
---|
180 |
|
---|
181 | for (( i=0 ; i < ${#testsequences[@]} ; i++ ))
|
---|
182 | do
|
---|
183 | numtrain=${trainsequences[$i]}
|
---|
184 | notrain=`echo $numtrain | cut -c 0-4`
|
---|
185 | echo "Sequence$numtrain.File: $dir/sequence$numtrain.txt" >> $mcdataset
|
---|
186 | echo "Sequence$numtrain.Dir: /montecarlo/star/$notrain/$numtrain" >> $mcdataset
|
---|
187 | echo "Sequence$numtrain.File: $dir/sequence$numtrain.txt" >> $mcdataset2
|
---|
188 | echo "Sequence$numtrain.Dir: /montecarlo/star/$notrain/$numtrain" >> $mcdataset2
|
---|
189 |
|
---|
190 | numtest=${testsequences[$i]}
|
---|
191 | notest=`echo $numtest | cut -c 0-4`
|
---|
192 | echo "Sequence$numtest.File: $dir/sequence$numtest.txt" >> $mcdataset
|
---|
193 | echo "Sequence$numtest.Dir: /montecarlo/star/$notrain/$numtrain" >> $mcdataset
|
---|
194 | echo "Sequence$numtest.File: $dir/sequence$numtest.txt" >> $mcdataset2
|
---|
195 | echo "Sequence$numtest.Dir: /montecarlo/star/$notrain/$numtrain" >> $mcdataset2
|
---|
196 | done
|
---|
197 |
|
---|
198 | # put # before the 'exit' to create rf-root-file for energy-estimation
|
---|
199 | exit
|
---|
200 |
|
---|
201 | echo "creating rf-root-file for energy-estimation..."
|
---|
202 | source $sourcefile
|
---|
203 | cd $mars
|
---|
204 | logfile=$dir/trainenergy.log
|
---|
205 |
|
---|
206 | root -q -b $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$dir/\""\) | tee $logfile
|
---|
207 |
|
---|