source: trunk/Mars/datacenter/scripts/findnotseqruns@ 13591

Last change on this file since 13591 was 8482, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.2 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 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"
33function 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
62while [ "$1" ]
63do
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
106done
107
108alias mymysql='mysql -u MAGIC --password=d99swMT! --host=vela MyMagic -s -e'
109
110if [ "$dat" = "" ] && [ "$cal" = "" ] && [ "$ped" = "" ] && ! [ "$all" = "yes" ]
111then
112 echo "You have to select at least one of the options -a -c -d -p "
113 usage
114fi
115
116if [ "$all" = "yes" ]
117then
118 cal=
119 dat=
120 ped=
121fi
122
123query="SELECT fRunNumber FROM RunData "
124if ! [ "$source" = "" ]
125then
126 query=$query" LEFT JOIN Source ON Source.fSourceKEY=RunData.fSourceKEY "
127fi
128query=$query" WHERE fSequenceFirst='0' "
129
130cond=""
131if ! [ "$source" = "" ]
132then
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)"
142fi
143if ! [ "$run" = "" ]
144then
145 cond=$cond" AND RunData.fRunNumber > $run "
146fi
147if ! [ "$runmin" = "" ] && ! [ "$runmax" = "" ]
148then
149 cond=$cond" AND RunData.fRunNumber BETWEEN $runmin AND $runmax "
150fi
151if [ "$cal" = "yes" ] && [ "$dat" = "yes" ]
152then
153 cond=$cond" AND (fRunTypeKEY=4 OR fRunTypeKEY=2) "
154fi
155if [ "$cal" = "yes" ] && [ "$ped" = "yes" ]
156then
157 cond=$cond" AND (fRunTypeKEY=4 OR fRunTypeKEY=3) "
158fi
159if [ "$dat" = "yes" ] && [ "$ped" = "yes" ]
160then
161 cond=$cond" AND (fRunTypeKEY=2 OR fRunTypeKEY=3)"
162fi
163if [ "$cal" = "yes" ]
164then
165 cond=$cond" AND fRunTypeKEY=4 "
166fi
167if [ "$dat" = "yes" ]
168then
169 cond=$cond" AND fRunTypeKEY=2 "
170fi
171if [ "$ped" = "yes" ]
172then
173 cond=$cond" AND fRunTypeKEY=3 "
174fi
175if [ "$notexcl" = "yes" ]
176then
177 cond=$cond" AND fExcludedFDAKEY=1 "
178fi
179query=$query$cond
180
181runs=(`mymysql " $query "`)
182echo "found ${#runs[@]} not sequenced runs "
183if [ ${#runs[@]} -eq 0 ]
184then
185 exit
186fi
187if [ ${#runs[@]} -gt 1000 ]
188then
189 echo "> 1000 runs found, please restrict the range with the options --runmin and --runmax "
190 exit
191fi
192runs2=`echo ${runs[@]} | sed -e 's/ /,/g'`
193query="SELECT fSourceKEY FROM RunData WHERE fRunNumber IN ($runs2) GROUP BY fSourceKEY"
194sources=`mymysql " $query "`
195sources2=`echo $sources | sed -e 's/ /,/g'`
196query="SELECT fSourceName FROM Source WHERE fSourceKEY IN ($sources2)"
197sourcenames=`mymysql " $query "`
198
199for sourcename in $sourcenames
200do
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
214done
215
216#nail -s 'found warnings in '$oldprocesslog $erradrs
217
218#printprocesslog "INFO finished $0"
219
Note: See TracBrowser for help on using the repository browser.