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 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2007
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | # This script checks from the DB which new starfiles have been produced
|
---|
28 | # and sends it to the person in charge for building datasets
|
---|
29 | #
|
---|
30 |
|
---|
31 | #source `dirname $0`/sourcefile
|
---|
32 | #printprocesslog "INFO starting $0"
|
---|
33 | function usage()
|
---|
34 | {
|
---|
35 | echo "Usage: $0 [options]"
|
---|
36 | echo "options:"
|
---|
37 | echo -n " -a "
|
---|
38 | echo " all runs are considered "
|
---|
39 | echo -n " -c "
|
---|
40 | echo " only calibration runs are considered "
|
---|
41 | echo -n " -d "
|
---|
42 | echo " only data runs are considered "
|
---|
43 | echo -n " -p "
|
---|
44 | echo " only pedestal runs are considered "
|
---|
45 | echo -n " --notexcl "
|
---|
46 | echo " only not excluded runs are considered "
|
---|
47 | echo -n " --printruns "
|
---|
48 | echo " print all runs "
|
---|
49 | echo -n " --run run# "
|
---|
50 | echo " runs > run# are considered "
|
---|
51 | echo -n " --runmin run# "
|
---|
52 | echo " runs > run# are considered (use together with --runmax)"
|
---|
53 | echo -n " --runmax run# "
|
---|
54 | echo " runs < run# are considered (use together with --runmin)"
|
---|
55 | echo -n " --source source "
|
---|
56 | echo " only runs of which the sourcename contains 'source' are considered"
|
---|
57 | echo ""
|
---|
58 | exit
|
---|
59 | }
|
---|
60 |
|
---|
61 |
|
---|
62 | while [ "$1" ]
|
---|
63 | do
|
---|
64 | case $1 in
|
---|
65 | --run) shift
|
---|
66 | run=$1
|
---|
67 | echo "Only runs starting from run # $run are considered"
|
---|
68 | ;;
|
---|
69 | --runmin) shift
|
---|
70 | runmin=$1
|
---|
71 | echo "Only runs with run # > $runmin are considered"
|
---|
72 | ;;
|
---|
73 | --runmax) shift
|
---|
74 | runmax=$1
|
---|
75 | echo "Only runs with run # < $runmax are considered"
|
---|
76 | ;;
|
---|
77 | --source) shift
|
---|
78 | source=$1
|
---|
79 | echo "Only runs of which the sourcename contains $source are considered"
|
---|
80 | ;;
|
---|
81 | --notexcl) notexcl="yes"
|
---|
82 | echo "Only not excluded runs are considered"
|
---|
83 | ;;
|
---|
84 | --printruns) printruns="yes"
|
---|
85 | ;;
|
---|
86 | -a) all="yes"
|
---|
87 | echo "All runs are considered"
|
---|
88 | ;;
|
---|
89 | -c) cal="yes"
|
---|
90 | echo "Only calibration runs are considered"
|
---|
91 | ;;
|
---|
92 | -d) dat="yes"
|
---|
93 | echo "Only data runs are considered"
|
---|
94 | ;;
|
---|
95 | -p) ped="yes"
|
---|
96 | echo "Only ped runs are considered"
|
---|
97 | ;;
|
---|
98 | -h) usage
|
---|
99 | ;;
|
---|
100 | *) echo "unknown option $1 "
|
---|
101 | usage
|
---|
102 | exit
|
---|
103 | ;;
|
---|
104 | esac
|
---|
105 | shift
|
---|
106 | done
|
---|
107 |
|
---|
108 | alias mymysql='mysql -u MAGIC --password=d99swMT! --host=vela MyMagic -s -e'
|
---|
109 |
|
---|
110 | if [ "$dat" = "" ] && [ "$cal" = "" ] && [ "$ped" = "" ] && ! [ "$all" = "yes" ]
|
---|
111 | then
|
---|
112 | echo "You have to select at least one of the options -a -c -d -p "
|
---|
113 | usage
|
---|
114 | fi
|
---|
115 |
|
---|
116 | if [ "$all" = "yes" ]
|
---|
117 | then
|
---|
118 | cal=
|
---|
119 | dat=
|
---|
120 | ped=
|
---|
121 | fi
|
---|
122 |
|
---|
123 | query="SELECT fRunNumber FROM RunData "
|
---|
124 | if ! [ "$source" = "" ]
|
---|
125 | then
|
---|
126 | query=$query" LEFT JOIN Source ON Source.fSourceKEY=RunData.fSourceKEY "
|
---|
127 | fi
|
---|
128 | query=$query" WHERE fSequenceFirst='0' "
|
---|
129 |
|
---|
130 | cond=""
|
---|
131 | if ! [ "$source" = "" ]
|
---|
132 | then
|
---|
133 | subquery="SELECT fSourceKEY FROM Source WHERE fSourceName LIKE '%$source%'"
|
---|
134 | sourcekeys=`mymysql "$subquery"`
|
---|
135 | if [ "$sourcekeys" = "" ]
|
---|
136 | then
|
---|
137 | echo "No source found containing $source"
|
---|
138 | exit
|
---|
139 | fi
|
---|
140 | sourcekeys2=`echo $sourcekeys | sed -e 's/ /,/g'`
|
---|
141 | cond=$cond" AND Source.fSourceKEY IN ($sourcekeys2)"
|
---|
142 | fi
|
---|
143 | if ! [ "$run" = "" ]
|
---|
144 | then
|
---|
145 | cond=$cond" AND RunData.fRunNumber > $run "
|
---|
146 | fi
|
---|
147 | if ! [ "$runmin" = "" ] && ! [ "$runmax" = "" ]
|
---|
148 | then
|
---|
149 | cond=$cond" AND RunData.fRunNumber BETWEEN $runmin AND $runmax "
|
---|
150 | fi
|
---|
151 | if [ "$cal" = "yes" ] && [ "$dat" = "yes" ]
|
---|
152 | then
|
---|
153 | cond=$cond" AND (fRunTypeKEY=4 OR fRunTypeKEY=2) "
|
---|
154 | fi
|
---|
155 | if [ "$cal" = "yes" ] && [ "$ped" = "yes" ]
|
---|
156 | then
|
---|
157 | cond=$cond" AND (fRunTypeKEY=4 OR fRunTypeKEY=3) "
|
---|
158 | fi
|
---|
159 | if [ "$dat" = "yes" ] && [ "$ped" = "yes" ]
|
---|
160 | then
|
---|
161 | cond=$cond" AND (fRunTypeKEY=2 OR fRunTypeKEY=3)"
|
---|
162 | fi
|
---|
163 | if [ "$cal" = "yes" ]
|
---|
164 | then
|
---|
165 | cond=$cond" AND fRunTypeKEY=4 "
|
---|
166 | fi
|
---|
167 | if [ "$dat" = "yes" ]
|
---|
168 | then
|
---|
169 | cond=$cond" AND fRunTypeKEY=2 "
|
---|
170 | fi
|
---|
171 | if [ "$ped" = "yes" ]
|
---|
172 | then
|
---|
173 | cond=$cond" AND fRunTypeKEY=3 "
|
---|
174 | fi
|
---|
175 | if [ "$notexcl" = "yes" ]
|
---|
176 | then
|
---|
177 | cond=$cond" AND fExcludedFDAKEY=1 "
|
---|
178 | fi
|
---|
179 | query=$query$cond
|
---|
180 |
|
---|
181 | runs=(`mymysql " $query "`)
|
---|
182 | echo "found ${#runs[@]} not sequenced runs "
|
---|
183 | if [ ${#runs[@]} -eq 0 ]
|
---|
184 | then
|
---|
185 | exit
|
---|
186 | fi
|
---|
187 | if [ ${#runs[@]} -gt 1000 ]
|
---|
188 | then
|
---|
189 | echo "> 1000 runs found, please restrict the range with the options --runmin and --runmax "
|
---|
190 | exit
|
---|
191 | fi
|
---|
192 | runs2=`echo ${runs[@]} | sed -e 's/ /,/g'`
|
---|
193 | query="SELECT fSourceKEY FROM RunData WHERE fRunNumber IN ($runs2) GROUP BY fSourceKEY"
|
---|
194 | sources=`mymysql " $query "`
|
---|
195 | sources2=`echo $sources | sed -e 's/ /,/g'`
|
---|
196 | query="SELECT fSourceName FROM Source WHERE fSourceKEY IN ($sources2)"
|
---|
197 | sourcenames=`mymysql " $query "`
|
---|
198 |
|
---|
199 | for sourcename in $sourcenames
|
---|
200 | do
|
---|
201 | query="SELECT fRunNumber FROM RunData "
|
---|
202 | query=$query" LEFT JOIN Source ON Source.fSourceKEY=RunData.fSourceKEY "
|
---|
203 | query=$query"WHERE fSourceName='$sourcename' AND fSequenceFirst='0' "
|
---|
204 | query=$query$cond
|
---|
205 | runspersource=(`mymysql " $query "`)
|
---|
206 | if [ "$printruns" = "yes" ]
|
---|
207 | then
|
---|
208 | runsps=`echo ${runspersource[@]} | sed -e 's/ /,/g'`
|
---|
209 | printf "for %12s the following runs are not sequenced: %s \n" $sourcename $runsps
|
---|
210 | else
|
---|
211 | printf "for %12s the %04d runs are not sequenced \n" $sourcename ${#runspersource[@]}
|
---|
212 | fi
|
---|
213 |
|
---|
214 | done
|
---|
215 |
|
---|
216 | #nail -s 'found warnings in '$oldprocesslog $erradrs
|
---|
217 |
|
---|
218 | #printprocesslog "INFO finished $0"
|
---|
219 |
|
---|