source: trunk/DataCheck/QuickLook/Step3.sh@ 19332

Last change on this file since 19332 was 18072, checked in by Daniela Dorner, 10 years ago
removed rsync as /daq is mounted on gate
  • Property svn:executable set to *
File size: 12.3 KB
Line 
1#!/bin/bash
2#
3source `dirname $0`/../Sourcefile.sh
4printprocesslog "INFO starting $0 $1"
5
6export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
7
8cd $mars
9
10if ! [ "$1" = "run" ] && ! [ "$1" = "night" ]
11then
12 #echo "wrong option "$1" (only min and nights valid)."
13 echo "wrong option "$1" (only run and night valid)."
14 finish
15fi
16
17if [ "$1" = "run" ]
18then
19 tablename=$resulttable1
20 timebins=( 5 10 20 30 40 60 90 120 180 240 300 360 )
21 timename="min"
22fi
23
24if [ "$1" = "night" ]
25then
26 tablename=$resulttable2
27 timebins=( 1 2 3 4 5 6 7 8 9 10 )
28 timename="night"
29fi
30
31# possibility to give table name as second option
32if [ "$2" != "" ]
33then
34 tablename=$2
35else
36 printprocesslog "INFO no second option given -> using table resulttable1 or resulttable2 for producing plots. "
37fi
38
39
40# get dates
41if [ "$certaindate" != "" ]
42then
43 checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'`
44 if [ "$checkstring" = "" ]
45 then
46 echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)"
47 finish
48 fi
49 getdates $certaindate
50else
51 # get all night
52 #getdates "all"
53 # get last 6 nights if hour between 7 and 19h, else only current night
54 getdates 6 7 19
55fi
56
57#echo ${dates[@]}
58for date in ${dates[@]}
59do
60 date2=`echo $date | sed -e 's/\///g'`
61 if [ $date2 -le $firstnight ]
62 then
63 continue
64 fi
65 query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$date2" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey "
66 sources=( `sendquery` )
67 printprocesslog "INFO process "$date" -> sources: "${sources[@]}
68 for source in ${sources[@]}
69 do
70 #echo $source
71 printprocesslog "INFO processing files for source "$source
72 outpath=$anapath/lightcurves/$date
73 makedir $outpath >/dev/null
74
75 for timebin in ${timebins[@]}
76 do
77 # doing the plots for one night
78 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".log"
79 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".root"
80 #echo $outfile
81 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2
82
83 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
84
85 case $check1 in
86 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)"
87 if ! ./showplot -b --save-as-png $outfile >/dev/null
88 then
89 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
90 fi
91 ;;
92 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2", but nothing to plot (check1=$check1)"
93 ;;
94 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)"
95 ;;
96 esac
97
98
99 # doing the plots for last week
100 lastweek=`date +%Y%m%d --date="$date -1 week"`
101 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.log"
102 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.root"
103 #echo $outfile
104 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last week ("$lastweek")"
105
106 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
107
108 case $check1 in
109 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)"
110 #./showplot -b --save-as-png $outfile
111 if ! ./showplot -b --save-as-png $outfile >/dev/null
112 then
113 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
114 fi
115 ;;
116 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week, but nothing to plot (check1=$check1)"
117 ;;
118 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)"
119 ;;
120 esac
121
122 # doing the plots for last month
123 lastmonth=`date +%Y%m%d --date="$date -28 day"`
124 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_month.log"
125 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_month.root"
126 #echo $outfile
127 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last month ("$lastmonth")"
128
129 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastmonth\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
130
131 case $check1 in
132 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last month (check1=$check1)"
133 #./showplot -b --save-as-png $outfile
134 if ! ./showplot -b --save-as-png $outfile >/dev/null
135 then
136 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
137 fi
138 ;;
139 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last month, but nothing to plot (check1=$check1)"
140 ;;
141 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last month (check1=$check1)"
142 ;;
143 esac
144
145 # doing the plots for all nights
146 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.log"
147 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.root"
148 #echo $outfile
149 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" all nights"
150
151 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
152
153 case $check1 in
154 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)"
155 #./showplot -b --save-as-png $outfile
156 if ! ./showplot -b --save-as-png $outfile >/dev/null
157 then
158 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
159 fi
160 ;;
161 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" all nights, but nothing to plot (check1=$check1)"
162 ;;
163 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)"
164 ;;
165 esac
166 done
167
168
169 # doing nightly plots
170
171 # doing the plots for one night
172 logfile=$outpath"/lightcurve"$source"_1night_"$date2".log"
173 outfile=$outpath"/lightcurve"$source"_1night_"$date2".root"
174 #echo $outfile
175 printprocesslog "INFO starting lightcurve.C+ for source "$source" 1 night for night "$date2
176
177 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
178
179 case $check1 in
180 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" (check1=$check1)"
181 if ! ./showplot -b --save-as-png $outfile >/dev/null
182 then
183 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
184 fi
185 ;;
186 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2", but nothing to plot (check1=$check1)"
187 ;;
188 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" (check1=$check1)"
189 ;;
190 esac
191
192
193 # doing the plots for last week
194 lastweek=`date +%Y%m%d --date="$date -1 week"`
195 logfile=$outpath"/lightcurve"$source"_1night_week.log"
196 outfile=$outpath"/lightcurve"$source"_1night_week.root"
197 #echo $outfile
198 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last week ("$lastweek")"
199
200 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
201
202 case $check1 in
203 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)"
204 #./showplot -b --save-as-png $outfile
205 if ! ./showplot -b --save-as-png $outfile >/dev/null
206 then
207 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
208 fi
209 ;;
210 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week, but nothing to plot (check1=$check1)"
211 ;;
212 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)"
213 ;;
214 esac
215
216 # doing the plots for last month
217 lastmonth=`date +%Y%m%d --date="$date -28 day"`
218 logfile=$outpath"/lightcurve"$source"_1night_month.log"
219 outfile=$outpath"/lightcurve"$source"_1night_month.root"
220 #echo $outfile
221 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last month ("$lastmonth")"
222
223 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastmonth\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
224
225 case $check1 in
226 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last month (check1=$check1)"
227 #./showplot -b --save-as-png $outfile
228 if ! ./showplot -b --save-as-png $outfile >/dev/null
229 then
230 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
231 fi
232 ;;
233 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last month, but nothing to plot (check1=$check1)"
234 ;;
235 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last month (check1=$check1)"
236 ;;
237 esac
238
239 # doing the plots for all nights
240 logfile=$outpath"/lightcurve"$source"_1night_all.log"
241 outfile=$outpath"/lightcurve"$source"_1night_all.root"
242 #echo $outfile
243 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" all nights"
244
245 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
246
247 case $check1 in
248 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)"
249 #./showplot -b --save-as-png $outfile
250 if ! ./showplot -b --save-as-png $outfile >/dev/null
251 then
252 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
253 fi
254 ;;
255 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" all nights, but nothing to plot (check1=$check1)"
256 ;;
257 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)"
258 ;;
259 esac
260
261 done
262done
263
264
265finish
266
Note: See TracBrowser for help on using the repository browser.