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

Last change on this file since 17120 was 17110, checked in by Daniela Dorner, 11 years ago
usage of getdates function, cleanup
  • Property svn:executable set to *
File size: 9.5 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 #echo "date: "$date
60 query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$date2" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey "
61 sources=( `sendquery` )
62 printprocesslog "INFO process "$date" -> sources: "${sources[@]}
63 for source in ${sources[@]}
64 do
65 #echo $source
66 printprocesslog "INFO processing files for source "$source
67 outpath=$anapath/lightcurves/$date
68 makedir $outpath
69
70 for timebin in ${timebins[@]}
71 do
72 # doing the plots for one night
73 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".log"
74 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".root"
75 #echo $outfile
76 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2
77
78 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
79
80 case $check1 in
81 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)"
82 if ! ./showplot -b --save-as-png $outfile >/dev/null
83 then
84 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
85 fi
86 ;;
87 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2", but nothing to plot (check1=$check1)"
88 ;;
89 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)"
90 ;;
91 esac
92
93
94 # doing the plots for last week
95 lastweek=`date +%Y%m%d --date="$date -1 week"`
96 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.log"
97 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.root"
98 #echo $outfile
99 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last week ("$lastweek")"
100
101 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
102
103 case $check1 in
104 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)"
105 #./showplot -b --save-as-png $outfile
106 if ! ./showplot -b --save-as-png $outfile >/dev/null
107 then
108 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
109 fi
110 ;;
111 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week, but nothing to plot (check1=$check1)"
112 ;;
113 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)"
114 ;;
115 esac
116
117 # doing the plots for all nights
118 logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.log"
119 outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.root"
120 #echo $outfile
121 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" all nights"
122
123 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$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" all nights (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" all nights, but nothing to plot (check1=$check1)"
134 ;;
135 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)"
136 ;;
137 esac
138 done
139
140
141 # doing nightly plots
142
143 # doing the plots for one night
144 logfile=$outpath"/lightcurve"$source"_1night_"$date2".log"
145 outfile=$outpath"/lightcurve"$source"_1night_"$date2".root"
146 #echo $outfile
147 printprocesslog "INFO starting lightcurve.C+ for source "$source" 1 night for night "$date2
148
149 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
150
151 case $check1 in
152 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" (check1=$check1)"
153 if ! ./showplot -b --save-as-png $outfile >/dev/null
154 then
155 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
156 fi
157 ;;
158 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2", but nothing to plot (check1=$check1)"
159 ;;
160 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" (check1=$check1)"
161 ;;
162 esac
163
164
165 # doing the plots for last week
166 lastweek=`date +%Y%m%d --date="$date -1 week"`
167 logfile=$outpath"/lightcurve"$source"_1night_week.log"
168 outfile=$outpath"/lightcurve"$source"_1night_week.root"
169 #echo $outfile
170 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last week ("$lastweek")"
171
172 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep`
173
174 case $check1 in
175 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)"
176 #./showplot -b --save-as-png $outfile
177 if ! ./showplot -b --save-as-png $outfile >/dev/null
178 then
179 printprocesslog "WARN showplot -b --save-as-png "$outfile" failed."
180 fi
181 ;;
182 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week, but nothing to plot (check1=$check1)"
183 ;;
184 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)"
185 ;;
186 esac
187
188 # doing the plots for all nights
189 logfile=$outpath"/lightcurve"$source"_1night_all.log"
190 outfile=$outpath"/lightcurve"$source"_1night_all.root"
191 #echo $outfile
192 printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" all nights"
193
194 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$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" all nights (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" all nights, but nothing to plot (check1=$check1)"
205 ;;
206 *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)"
207 ;;
208 esac
209
210 done
211 printprocesslog "INFO rsync output of source "$source" to gate."
212 #rsync -av $anapath/lightcurves/ gate:/home/factwww/lightcurves
213 rsync -a $anapath/lightcurves/ gate:/home/factwww/lightcurves
214done
215
216
217finish
218
Note: See TracBrowser for help on using the repository browser.