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

Last change on this file since 17903 was 17591, checked in by Daniela Dorner, 11 years ago
added plots for period of 1 month
  • Property svn:executable set to *
File size: 12.2 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 getdates $certaindate
44else
45 # get all night
46 #getdates "all"
47 # get last 6 nights if hour between 7 and 19h, else only current night
48 getdates 6 7 19
49fi
50
51#echo ${dates[@]}
52for date in ${dates[@]}
53do
54 date2=`echo $date | sed -e 's/\///g'`
55 if [ $date2 -le $firstnight ]
56 then
57 continue
58 fi
59 query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$date2" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey "
60 sources=( `sendquery` )
61 printprocesslog "INFO process "$date" -> sources: "${sources[@]}
62 for source in ${sources[@]}
63 do
64 #echo $source
65 printprocesslog "INFO processing files for source "$source
66 outpath=$anapath/lightcurves/$date
67 makedir $outpath
68
69 for timebin in ${timebins[@]}
70 do
71 # doing the plots for one night
72 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".log"
73 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".root"
74 #echo $outfile
75 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2
76
77 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
78
79 case $check1 in
80 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)"
81 if ! ./showplot -b --save-as-png $outfile >/dev/null
82 then
83 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
84 fi
85 ;;
86 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2", but nothing to plot (check1=$check1)"
87 ;;
88 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)"
89 ;;
90 esac
91
92
93 # doing the plots for last week
94 lastweek=`date +%Y%m%d --date="$date -1 week"`
95 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.log"
96 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.root"
97 #echo $outfile
98 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last week ("$lastweek")"
99
100 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
101
102 case $check1 in
103 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)"
104 #./showplot -b --save-as-png $outfile
105 if ! ./showplot -b --save-as-png $outfile >/dev/null
106 then
107 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
108 fi
109 ;;
110 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week, but nothing to plot (check1=$check1)"
111 ;;
112 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)"
113 ;;
114 esac
115
116 # doing the plots for last month
117 lastmonth=`date +%Y%m%d --date="$date -28 day"`
118 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_month.log"
119 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_month.root"
120 #echo $outfile
121 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last month ("$lastmonth")"
122
123 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastmonth\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
124
125 case $check1 in
126 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last month (check1=$check1)"
127 #./showplot -b --save-as-png $outfile
128 if ! ./showplot -b --save-as-png $outfile >/dev/null
129 then
130 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
131 fi
132 ;;
133 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last month, but nothing to plot (check1=$check1)"
134 ;;
135 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last month (check1=$check1)"
136 ;;
137 esac
138
139 # doing the plots for all nights
140 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.log"
141 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.root"
142 #echo $outfile
143 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" all nights"
144
145 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
146
147 case $check1 in
148 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)"
149 #./showplot -b --save-as-png $outfile
150 if ! ./showplot -b --save-as-png $outfile >/dev/null
151 then
152 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
153 fi
154 ;;
155 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" all nights, but nothing to plot (check1=$check1)"
156 ;;
157 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)"
158 ;;
159 esac
160 done
161
162
163 # doing nightly plots
164
165 # doing the plots for one night
166 logfile=$outpath"/lightcurve"$source"_1night_"$date2".log"
167 outfile=$outpath"/lightcurve"$source"_1night_"$date2".root"
168 #echo $outfile
169 printprocesslog "INFO starting lightcurve.C+ for source "$source" 1 night for night "$date2
170
171 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
172
173 case $check1 in
174 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" (check1=$check1)"
175 if ! ./showplot -b --save-as-png $outfile >/dev/null
176 then
177 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
178 fi
179 ;;
180 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2", but nothing to plot (check1=$check1)"
181 ;;
182 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" (check1=$check1)"
183 ;;
184 esac
185
186
187 # doing the plots for last week
188 lastweek=`date +%Y%m%d --date="$date -1 week"`
189 logfile=$outpath"/lightcurve"$source"_1night_week.log"
190 outfile=$outpath"/lightcurve"$source"_1night_week.root"
191 #echo $outfile
192 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last week ("$lastweek")"
193
194 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
195
196 case $check1 in
197 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)"
198 #./showplot -b --save-as-png $outfile
199 if ! ./showplot -b --save-as-png $outfile >/dev/null
200 then
201 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
202 fi
203 ;;
204 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week, but nothing to plot (check1=$check1)"
205 ;;
206 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)"
207 ;;
208 esac
209
210 # doing the plots for last month
211 lastmonth=`date +%Y%m%d --date="$date -28 day"`
212 logfile=$outpath"/lightcurve"$source"_1night_month.log"
213 outfile=$outpath"/lightcurve"$source"_1night_month.root"
214 #echo $outfile
215 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last month ("$lastmonth")"
216
217 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastmonth\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
218
219 case $check1 in
220 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last month (check1=$check1)"
221 #./showplot -b --save-as-png $outfile
222 if ! ./showplot -b --save-as-png $outfile >/dev/null
223 then
224 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
225 fi
226 ;;
227 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last month, but nothing to plot (check1=$check1)"
228 ;;
229 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last month (check1=$check1)"
230 ;;
231 esac
232
233 # doing the plots for all nights
234 logfile=$outpath"/lightcurve"$source"_1night_all.log"
235 outfile=$outpath"/lightcurve"$source"_1night_all.root"
236 #echo $outfile
237 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" all nights"
238
239 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
240
241 case $check1 in
242 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)"
243 #./showplot -b --save-as-png $outfile
244 if ! ./showplot -b --save-as-png $outfile >/dev/null
245 then
246 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
247 fi
248 ;;
249 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" all nights, but nothing to plot (check1=$check1)"
250 ;;
251 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)"
252 ;;
253 esac
254
255 done
256 printprocesslog "INFO rsync output of source "$source" to gate."
257 #rsync -av $anapath/lightcurves/ gate:/home/factwww/lightcurves
258 rsync -a $anapath/lightcurves/ gate:/home/factwww/lightcurves
259done
260
261
262finish
263
Note: See TracBrowser for help on using the repository browser.