#!/bin/bash # source `dirname $0`/../Sourcefile.sh printprocesslog "INFO starting $0 $1" export LD_LIBRARY_PATH=./:$LD_LIBRARY_PATH cd $mars if ! [ "$1" = "run" ] && ! [ "$1" = "night" ] then #echo "wrong option "$1" (only min and nights valid)." echo "wrong option "$1" (only run and night valid)." finish fi if [ "$1" = "run" ] then tablename=$resulttable1 timebins=( 5 10 20 30 40 60 90 120 180 240 300 360 ) timename="min" fi if [ "$1" = "night" ] then tablename=$resulttable2 timebins=( 1 2 3 4 5 6 7 8 9 10 ) timename="night" fi # possibility to give table name as second option if [ "$2" != "" ] then tablename=$2 else printprocesslog "INFO no second option given -> using table resulttable1 or resulttable2 for producing plots. " fi # get dates if [ "$certaindate" != "" ] then checkstring=`echo $certaindate | grep -E -o '^20[0-9][0-9]\/[01][0-9]\/[0-3][0-9]$'` if [ "$checkstring" = "" ] then echo "Please give the variable certaindate in the correct format (YYYY/MM/DD)" finish fi getdates $certaindate else # get all night #getdates "all" # get last 6 nights if hour between 7 and 19h, else only current night getdates 6 7 19 fi #echo ${dates[@]} for date in ${dates[@]} do date2=`echo $date | sed -e 's/\///g'` if [ $date2 -le $firstnight ] then continue fi query="SELECT fSourceKEY FROM RunInfo WHERE fNight="$date2" AND fSourceKey > 0 AND fRunTypeKEY=1 GROUP BY fSourceKey " sources=( `sendquery` ) printprocesslog "INFO process "$date" -> sources: "${sources[@]} for source in ${sources[@]} do #echo $source printprocesslog "INFO processing files for source "$source outpath=$anapath/lightcurves/$date makedir $outpath >/dev/null for timebin in ${timebins[@]} do # doing the plots for one night logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".log" outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_"$date2".root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)" if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2", but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" (check1=$check1)" ;; esac # doing the plots for last week lastweek=`date +%Y%m%d --date="$date -1 week"` logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.log" outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_week.root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last week ("$lastweek")" check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)" #./showplot -b --save-as-png $outfile if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last week, but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last week (check1=$check1)" ;; esac # doing the plots for last month lastmonth=`date +%Y%m%d --date="$date -28 day"` logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_month.log" outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_month.root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" last month ("$lastmonth")" check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastmonth\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last month (check1=$check1)" #./showplot -b --save-as-png $outfile if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" last month, but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" last month (check1=$check1)" ;; esac # doing the plots for all nights logfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.log" outfile=$outpath"/lightcurve"$source"_"$timebin$timename"_all.root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin "$timebin" "$timename" night "$date2" all nights" check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,$timebin\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)" #./showplot -b --save-as-png $outfile if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin "$timebin" "$timename" night "$date2" all nights, but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin "$timebin" "$timename" night "$date2" all nights (check1=$check1)" ;; esac done # doing nightly plots # doing the plots for one night logfile=$outpath"/lightcurve"$source"_1night_"$date2".log" outfile=$outpath"/lightcurve"$source"_1night_"$date2".root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" 1 night for night "$date2 check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$date2\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" (check1=$check1)" if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2", but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" (check1=$check1)" ;; esac # doing the plots for last week lastweek=`date +%Y%m%d --date="$date -1 week"` logfile=$outpath"/lightcurve"$source"_1night_week.log" outfile=$outpath"/lightcurve"$source"_1night_week.root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last week ("$lastweek")" check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastweek\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)" #./showplot -b --save-as-png $outfile if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last week, but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last week (check1=$check1)" ;; esac # doing the plots for last month lastmonth=`date +%Y%m%d --date="$date -28 day"` logfile=$outpath"/lightcurve"$source"_1night_month.log" outfile=$outpath"/lightcurve"$source"_1night_month.root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" last month ("$lastmonth")" check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$lastmonth\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last month (check1=$check1)" #./showplot -b --save-as-png $outfile if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" last month, but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" last month (check1=$check1)" ;; esac # doing the plots for all nights logfile=$outpath"/lightcurve"$source"_1night_all.log" outfile=$outpath"/lightcurve"$source"_1night_all.root" #echo $outfile printprocesslog "INFO starting lightcurve.C+ for source "$source" timebin 1 night for night "$date2" all nights" check1=`root -q -b fact/analysis/lightcurve.C+\($source\,$firstnight\\,$date2\,-1\,"\"$tablename"\"\,"\"$outfile\""\,kFALSE\) | tee $logfile | intgrep` case $check1 in 0) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)" #./showplot -b --save-as-png $outfile if ! ./showplot -b --save-as-png $outfile >/dev/null then printprocesslog "WARN showplot -b --save-as-png "$outfile" failed." fi ;; 1) printprocesslog "INFO lightcurve.C was successful for source "$source" timebin 1 night for night "$date2" all nights, but nothing to plot (check1=$check1)" ;; *) printprocesslog "ERROR lightcurve.C failed for source "$source" timebin 1 night for night "$date2" all nights (check1=$check1)" ;; esac done done finish