1 | #!/bin/sh
|
---|
2 | # ========================================================================
|
---|
3 | #
|
---|
4 | # *
|
---|
5 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
6 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
7 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
8 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
9 | # *
|
---|
10 | # * Permission to use, copy, modify and distribute this software and its
|
---|
11 | # * documentation for any purpose is hereby granted without fee,
|
---|
12 | # * provided that the above copyright notice appear in all copies and
|
---|
13 | # * that both that copyright notice and this permission notice appear
|
---|
14 | # * in supporting documentation. It is provided "as is" without express
|
---|
15 | # * or implied warranty.
|
---|
16 | # *
|
---|
17 | #
|
---|
18 | #
|
---|
19 | # Author(s): Daniela Dorner 05/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
20 | #
|
---|
21 | # Copyright: MAGIC Software Development, 2000-2007
|
---|
22 | #
|
---|
23 | #
|
---|
24 | # ========================================================================
|
---|
25 | #
|
---|
26 | #
|
---|
27 | #
|
---|
28 | ##############################################################################
|
---|
29 | #
|
---|
30 | # This script creates mc sequences and datasets for a psf, observation mode
|
---|
31 | # and zenith range chosen by the user.
|
---|
32 | #
|
---|
33 | # variables, that have to be set by the user:
|
---|
34 | # - path directory, where the mc sequence and dataset files are stored
|
---|
35 | # be careful: don't move the sequence files afterwards, as the
|
---|
36 | # paths are stored in the datasetfiles
|
---|
37 | # - zdmin minimum zenith distance
|
---|
38 | # - zdmax maximum zenith distance
|
---|
39 | # - psf psf
|
---|
40 | # at the moment mc with psf 14 and 20 is available
|
---|
41 | # - modes observation mode
|
---|
42 | # the explanation for the modes can be found in
|
---|
43 | # /montecarlo/rawfiles/README.txt
|
---|
44 | # - numruns num of runs, that are in the sequence file, which are used
|
---|
45 | # for training (SequencesOn in $mcdataset)
|
---|
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 | #
|
---|
52 | # Remark: You have to run the script in your Mars directory.
|
---|
53 | #
|
---|
54 | ##############################################################################
|
---|
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
|
---|
62 |
|
---|
63 | zdmin=17
|
---|
64 | zdmax=35
|
---|
65 | psf=14
|
---|
66 | modes=( "02" ) # nowobble
|
---|
67 | numruns=3
|
---|
68 |
|
---|
69 | # be careful with $date, when path changes
|
---|
70 | mcpath=/magic/montecarlo
|
---|
71 |
|
---|
72 | zbinmin=`echo "scale=2 ; 100*(1 - c($zdmin*3.14/180))+1" | bc -l`
|
---|
73 | zbinmax=`echo "scale=2 ; 100*(1 - c($zdmax*3.14/180))+1" | bc -l`
|
---|
74 |
|
---|
75 | zbinmin=`echo $zbinmin | cut -d. -f1`
|
---|
76 | zbinmax=`echo $zbinmax | cut -d. -f1`
|
---|
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"
|
---|
81 |
|
---|
82 | j=0
|
---|
83 | for mode in $modes
|
---|
84 | do
|
---|
85 | for (( i=$zbinmin ; i < $zbinmax ; i++ ))
|
---|
86 | do
|
---|
87 | zbin=`printf %02d $i`
|
---|
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" " "`)
|
---|
90 | if [ "$runs" = "" ]
|
---|
91 | then
|
---|
92 | echo " no runs found for zbin $i "
|
---|
93 | continue
|
---|
94 | fi
|
---|
95 | echo "found ${#runs[@]} Gamma MC files in path "$path
|
---|
96 |
|
---|
97 | runsforfirst=""
|
---|
98 | firstrun=${runs[0]}
|
---|
99 | secondrun=${runs[${numruns}]}
|
---|
100 | firstrunno=`printf %08d $firstrun`
|
---|
101 | secondrunno=`printf %08d $secondrun`
|
---|
102 | unset runs[0]
|
---|
103 | for (( k=1 ; k < $numruns ; k++ ))
|
---|
104 | do
|
---|
105 | runsforfirst=$runsforfirst" ${runs[$k]}"
|
---|
106 | unset runs[$k]
|
---|
107 | done
|
---|
108 | date=`echo $path | cut -d/ -f5-7 | sed -e 's/\//-/g'`
|
---|
109 |
|
---|
110 | trainsequfile=$mcoutpath/sequence$firstrunno.txt
|
---|
111 | trainsequences[$j]=$firstrunno
|
---|
112 | echo " writing train-sequfile "$trainsequfile
|
---|
113 | echo "Sequence: $firstrun" > $trainsequfile
|
---|
114 | echo "Night: $date" >> $trainsequfile
|
---|
115 | echo "" >> $trainsequfile
|
---|
116 | echo "CalRuns: 1" >> $trainsequfile
|
---|
117 | echo "PedRuns: 2" >> $trainsequfile
|
---|
118 | echo "DatRuns: $firstrun$runsforfirst" >> $trainsequfile
|
---|
119 | echo "" >> $trainsequfile
|
---|
120 | echo "MonteCarlo: Yes" >> $trainsequfile
|
---|
121 | echo "" >> $trainsequfile
|
---|
122 |
|
---|
123 | testsequfile=$mcoutpath/sequence$secondrunno.txt
|
---|
124 | testsequences[$j]=$secondrunno
|
---|
125 | # echo "writing test-sequfile "$testsequfile
|
---|
126 | echo "Sequence: $secondrun" > $testsequfile
|
---|
127 | echo "Night: $date" >> $testsequfile
|
---|
128 | echo "" >> $testsequfile
|
---|
129 | echo "CalRuns: 1" >> $testsequfile
|
---|
130 | echo "PedRuns: 2" >> $testsequfile
|
---|
131 | echo "DatRuns: ${runs[@]}" >> $testsequfile
|
---|
132 | echo "" >> $testsequfile
|
---|
133 | echo "MonteCarlo: Yes" >> $testsequfile
|
---|
134 | echo "" >> $testsequfile
|
---|
135 |
|
---|
136 | j=$j+1
|
---|
137 | done
|
---|
138 | done
|
---|
139 |
|
---|
140 | echo "# test sequences: ${#testsequences[@]}"
|
---|
141 | echo "# train sequences: ${#trainsequences[@]}"
|
---|
142 |
|
---|
143 | echo "AnalysisNumber: 1 " > $mcdataset
|
---|
144 | echo "" >> $mcdataset
|
---|
145 | echo "SequencesOn: ${trainsequences[@]}" >> $mcdataset
|
---|
146 | echo "" >> $mcdataset
|
---|
147 | echo "SequencesOff: ${testsequences[@]}" >> $mcdataset
|
---|
148 | echo "" >> $mcdataset
|
---|
149 | echo "" >> $mcdataset
|
---|
150 |
|
---|
151 | echo "AnalysisNumber: 1 " > $mcdataset2
|
---|
152 | echo "" >> $mcdataset2
|
---|
153 | echo "SequencesOn: ${testsequences[@]}" >> $mcdataset2
|
---|
154 | echo "" >> $mcdataset2
|
---|
155 | echo "" >> $mcdataset2
|
---|
156 |
|
---|
157 | for (( i=0 ; i < ${#testsequences[@]} ; i++ ))
|
---|
158 | do
|
---|
159 | numtrain=${trainsequences[$i]}
|
---|
160 | notrain=`echo $numtrain | cut -c 0-4`
|
---|
161 | 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
|
---|
165 |
|
---|
166 | numtest=${testsequences[$i]}
|
---|
167 | notest=`echo $numtest | cut -c 0-4`
|
---|
168 | 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
|
---|
172 | done
|
---|
173 |
|
---|
174 |
|
---|
175 | logfile=$mcoutpath/trainenergy.log
|
---|
176 | rffile=$mcoutpath/rf-energy.root
|
---|
177 |
|
---|
178 | echo "mcdataset: $mcdataset"
|
---|
179 | echo "rffile: $rffile"
|
---|
180 | echo "macrospath: $macrospath"
|
---|
181 | root -q -b $macrospath/trainenergy.C+\("\"$mcdataset\""\,"\"$rffile\""\) | tee $logfile
|
---|
182 |
|
---|