1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | source `dirname $0`/../Sourcefile.sh
|
---|
4 | printprocesslog "INFO starting $0 $1"
|
---|
5 |
|
---|
6 | #root=/opt/root_svn/bin/thisroot.sh
|
---|
7 | #source $root
|
---|
8 | #factpath=/home/fact/FACT++.in-run-fad-loss
|
---|
9 | export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH
|
---|
10 |
|
---|
11 | mars=/home/fact/Mars
|
---|
12 | cd $mars
|
---|
13 | pwd
|
---|
14 | # use macro from different mars version until versions are sorted out
|
---|
15 | mars2=/home/fact/SW.automatic.processing/Mars.svn.2013.04.12
|
---|
16 |
|
---|
17 | if ! [ "$1" = "run" ] && ! [ "$1" = "night" ]
|
---|
18 | then
|
---|
19 | #echo "wrong option "$1" (only min and nights valid)."
|
---|
20 | echo "wrong option "$1" (only run and night valid)."
|
---|
21 | finish
|
---|
22 | fi
|
---|
23 |
|
---|
24 | if [ "$1" = "run" ]
|
---|
25 | then
|
---|
26 | tablenam=$resulttable1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | if [ "$1" = "night" ]
|
---|
30 | then
|
---|
31 | tablenam=$resulttable2
|
---|
32 | fi
|
---|
33 |
|
---|
34 | # get current hour
|
---|
35 | hour=`date +%k`
|
---|
36 | if [ $hour -le 7 ] || [ $hour -ge 19 ]
|
---|
37 | then
|
---|
38 | dates=( `date +%Y/%m/%d --date="-12hour"` )
|
---|
39 | else
|
---|
40 | # get last 3, 6 or 9 nights
|
---|
41 | dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
|
---|
42 | # `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
|
---|
43 | # `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
|
---|
44 | )
|
---|
45 | fi
|
---|
46 | #dates=( `find -L $auxdata -mindepth 3 -type d | sort -r | sed "s/\${auxdata_for_sed}//g" | sed -e 's/^\///'` ) #all available dates in /loc_data/zipraw
|
---|
47 |
|
---|
48 | #dates=( "2013/04/19" )
|
---|
49 |
|
---|
50 | # source info on daq in /loc_data/analysis/sources.txt
|
---|
51 | # (dump of DB scheduling.sources)
|
---|
52 |
|
---|
53 | timebins=( 5 10 20 30 40 60 90 120 180 240 300 360 )
|
---|
54 |
|
---|
55 | echo ${dates[@]}
|
---|
56 | for date in ${dates[@]}
|
---|
57 | do
|
---|
58 | date2=`echo $date | sed -e 's/\///g'`
|
---|
59 | if [ $date2 -le $firstnight ]
|
---|
60 | then
|
---|
61 | continue
|
---|
62 | fi
|
---|
63 | query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$date2" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey "
|
---|
64 | sources=( `sendquery` )
|
---|
65 | echo "process "$date" -> sources: "${sources[@]}
|
---|
66 | for source in ${sources[@]}
|
---|
67 | do
|
---|
68 | echo $source
|
---|
69 | printprocesslog "INFO processing files for source "$source
|
---|
70 | outpath=$anapath/lightcurves/$date
|
---|
71 | makedir $outpath
|
---|
72 |
|
---|
73 | for timebin in ${timebins[@]}
|
---|
74 | do
|
---|
75 | # doing the plots for one night
|
---|
76 | logfile=$outpath"/lightcurve"$source"_"$timebin"min_"$date2".log"
|
---|
77 | outfile=$outpath"/lightcurve"$source"_"$timebin"min_"$date2".root"
|
---|
78 | echo $outfile
|
---|
79 | printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" night "$date2
|
---|
80 |
|
---|
81 | check1=`root -q -b $mars2/fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,$timebin\,"\"$resulttable1"\"\,"\"$outfile\""\) | tee $logfile | intgrep`
|
---|
82 |
|
---|
83 | case $check1 in
|
---|
84 | 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" (check1=$check1)"
|
---|
85 | ./showplot -b --save-as-png $outfile
|
---|
86 | ;;
|
---|
87 | 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2", but nothing to plot (check1=$check1)"
|
---|
88 | ;;
|
---|
89 | *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" 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"min_week.log"
|
---|
97 | outfile=$outpath"/lightcurve"$source"_"$timebin"min_week.root"
|
---|
98 | echo $outfile
|
---|
99 | printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" night "$date2" last week ("$lastweek")"
|
---|
100 |
|
---|
101 | check1=`root -q -b $mars2/fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,$timebin\,"\"$resulttable1"\"\,"\"$outfile\""\) | tee $logfile | intgrep`
|
---|
102 |
|
---|
103 | case $check1 in
|
---|
104 | 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" last week (check1=$check1)"
|
---|
105 | ./showplot -b --save-as-png $outfile
|
---|
106 | ;;
|
---|
107 | 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" last week, but nothing to plot (check1=$check1)"
|
---|
108 | ;;
|
---|
109 | *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" night "$date2" last week (check1=$check1)"
|
---|
110 | ;;
|
---|
111 | esac
|
---|
112 |
|
---|
113 | # doing the plots for all nights
|
---|
114 | logfile=$outpath"/lightcurve"$source"_"$timebin"min_all.log"
|
---|
115 | outfile=$outpath"/lightcurve"$source"_"$timebin"min_all.root"
|
---|
116 | echo $outfile
|
---|
117 | printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" night "$date2" all nights"
|
---|
118 |
|
---|
119 | check1=`root -q -b $mars2/fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,$timebin\,"\"$resulttable1"\"\,"\"$outfile\""\) | tee $logfile | intgrep`
|
---|
120 |
|
---|
121 | case $check1 in
|
---|
122 | 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" all nights (check1=$check1)"
|
---|
123 | ./showplot -b --save-as-png $outfile
|
---|
124 | ;;
|
---|
125 | 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" night "$date2" all nights, but nothing to plot (check1=$check1)"
|
---|
126 | ;;
|
---|
127 | *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" night "$date2" all nights (check1=$check1)"
|
---|
128 | ;;
|
---|
129 | esac
|
---|
130 | done
|
---|
131 | done
|
---|
132 | printprocesslog "INFO rsync output of source "$source" to gate."
|
---|
133 | rsync -av $anapath/lightcurves/ gate:/home/factwww/lightcurves
|
---|
134 | done
|
---|
135 |
|
---|
136 |
|
---|
137 | finish
|
---|
138 |
|
---|