| 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/SW.automatic.processing/Mars.svn.2013.04.29
|
|---|
| 12 | cd $mars
|
|---|
| 13 |
|
|---|
| 14 | if ! [ "$1" = "run" ] && ! [ "$1" = "night" ]
|
|---|
| 15 | then
|
|---|
| 16 | #echo "wrong option "$1" (only min and nights valid)."
|
|---|
| 17 | echo "wrong option "$1" (only run and night valid)."
|
|---|
| 18 | finish
|
|---|
| 19 | fi
|
|---|
| 20 |
|
|---|
| 21 | if [ "$1" = "run" ]
|
|---|
| 22 | then
|
|---|
| 23 | tablenam=$resulttable1
|
|---|
| 24 | fi
|
|---|
| 25 |
|
|---|
| 26 | if [ "$1" = "night" ]
|
|---|
| 27 | then
|
|---|
| 28 | tablenam=$resulttable2
|
|---|
| 29 | fi
|
|---|
| 30 |
|
|---|
| 31 | # get current hour
|
|---|
| 32 | hour=`date +%k`
|
|---|
| 33 | if [ $hour -le 7 ] || [ $hour -ge 19 ]
|
|---|
| 34 | then
|
|---|
| 35 | dates=( `date +%Y/%m/%d --date="-12hour"` )
|
|---|
| 36 | else
|
|---|
| 37 | # get last 3, 6 or 9 nights
|
|---|
| 38 | dates=( `date +%Y/%m/%d --date="-12hour"` `date +%Y/%m/%d --date="-36hour"` `date +%Y/%m/%d --date="-60hour"` \
|
|---|
| 39 | # `date +%Y/%m/%d --date="-84hour"` `date +%Y/%m/%d --date="-108hour"` `date +%Y/%m/%d --date="-132hour"` \
|
|---|
| 40 | # `date +%Y/%m/%d --date="-156hour"` `date +%Y/%m/%d --date="-180hour"` `date +%Y/%m/%d --date="-204hour"` \
|
|---|
| 41 | )
|
|---|
| 42 | fi
|
|---|
| 43 | #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
|
|---|
| 44 |
|
|---|
| 45 | #dates=( "2013/04/19" )
|
|---|
| 46 |
|
|---|
| 47 | # source info on daq in /loc_data/analysis/sources.txt
|
|---|
| 48 | # (dump of DB scheduling.sources)
|
|---|
| 49 |
|
|---|
| 50 | timebins=( 5 10 20 30 40 60 90 120 180 240 300 360 )
|
|---|
| 51 |
|
|---|
| 52 | #echo ${dates[@]}
|
|---|
| 53 | for date in ${dates[@]}
|
|---|
| 54 | do
|
|---|
| 55 | date2=`echo $date | sed -e 's/\///g'`
|
|---|
| 56 | if [ $date2 -le $firstnight ]
|
|---|
| 57 | then
|
|---|
| 58 | continue
|
|---|
| 59 | fi
|
|---|
| 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"min_"$date2".log"
|
|---|
| 74 | outfile=$outpath"/lightcurve"$source"_"$timebin"min_"$date2".root"
|
|---|
| 75 | #echo $outfile
|
|---|
| 76 | printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" night "$date2
|
|---|
| 77 |
|
|---|
| 78 | check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,$timebin\,"\"$resulttable1"\"\,"\"$outfile\""\) | tee $logfile | intgrep`
|
|---|
| 79 |
|
|---|
| 80 | case $check1 in
|
|---|
| 81 | 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" 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" 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 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 | 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" night "$date2" last week, but nothing to plot (check1=$check1)"
|
|---|
| 112 | ;;
|
|---|
| 113 | *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" night "$date2" last week (check1=$check1)"
|
|---|
| 114 | ;;
|
|---|
| 115 | esac
|
|---|
| 116 |
|
|---|
| 117 | # doing the plots for all nights
|
|---|
| 118 | logfile=$outpath"/lightcurve"$source"_"$timebin"min_all.log"
|
|---|
| 119 | outfile=$outpath"/lightcurve"$source"_"$timebin"min_all.root"
|
|---|
| 120 | #echo $outfile
|
|---|
| 121 | printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" night "$date2" all nights"
|
|---|
| 122 |
|
|---|
| 123 | check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,$timebin\,"\"$resulttable1"\"\,"\"$outfile\""\) | tee $logfile | intgrep`
|
|---|
| 124 |
|
|---|
| 125 | case $check1 in
|
|---|
| 126 | 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" 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" night "$date2" all nights, but nothing to plot (check1=$check1)"
|
|---|
| 134 | ;;
|
|---|
| 135 | *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" night "$date2" all nights (check1=$check1)"
|
|---|
| 136 | ;;
|
|---|
| 137 | esac
|
|---|
| 138 | done
|
|---|
| 139 | done
|
|---|
| 140 | printprocesslog "INFO rsync output of source "$source" to gate."
|
|---|
| 141 | #rsync -av $anapath/lightcurves/ gate:/home/factwww/lightcurves
|
|---|
| 142 | rsync -a $anapath/lightcurves/ gate:/home/factwww/lightcurves
|
|---|
| 143 | done
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | finish
|
|---|
| 147 |
|
|---|