Changeset 18906


Ignore:
Timestamp:
09/14/17 23:22:39 (7 years ago)
Author:
Daniela Dorner
Message:
fixed two bugs, added filling of informaion in DB
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/QuickLook/FlareAlerts.sh

    r18859 r18906  
    33
    44# missing:
    5 # implement DB-entries for being called
     5# finalize DB-entries for being called
    66# prepare directly template for email
    7 # use current value for CU in triggers
    8 # add note for values > 70 evts/h for X-ray triggers
     7# add x-ray trigger as trigger type or
     8#    add note for values > 70 evts/h for X-ray triggers
    99#
    1010# add more information:
     
    6767ontime="IF(ISNULL(fEffectiveOn), fOnTimeAfterCuts, TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)"
    6868threshold="IF (ISNULL(fThresholdMinSet), fThresholdMedian, fThresholdMinSet)"
    69 cu="20.0"
     69#cu="20.0"
     70cu="CUQLA(fNight)"
    7071corr="1"
    7172# missing: corrected excessrates
    72 # missing: time-dependent CU
    7373
    7474
     
    359359         1)   #echo "std trigger: criteria ( $exc >= $exclimit && $sig >= $siglimit && $higher )"
    360360              trigger=`echo " $exc >= $exclimit && $sig >= $siglimit && $higher " | bc -l`
     361              limits=$exclimit"_"$siglimit
    361362              ;;
    362363         2)   #echo "magic 501: criteria ( $exc >= $exclimit && $sig >= $siglimit && $higher )"
    363364              trigger=`echo " $exc >= $exclimit && $sig >= $siglimit && $higher " | bc -l`
     365              limits=$exclimit"_"$siglimit
    364366              ;;
    365367         3)   #echo "magic fast rise/decay"
    366368              #trigger=`echo " $slope >= $slopelimit && $slopeprev >= $slopelimit && $slope60 >= $slopelimit && $sig >= $siglimit " | bc -l`
    367369              trigger=`echo " ( ( $slope >= $slopelimit && $slopeprev >= $slopelimit && $slope60 >= $slopelimit ) || ( - $slope >= $slopelimit && - $slopeprev >= $slopelimit && - $slope60 >= $slopelimit  ) ) && $sig >= $siglimit " | bc -l`
     370              limits=$slopelimit"_"$siglimit
    368371              ;;
    369          4)   #echo "std trigger: criteria ( $exc >= $exclimit && $sig >= $siglimit && $higher )"
     372         5)   #echo "std trigger: criteria ( $exc >= $exclimit && $sig >= $siglimit && $higher )"
    370373              trigger=`echo " $exc >= $exclimit && $sig >= $siglimit && $higher " | bc -l`
     374              limits=$exclimit"_"$siglimit
    371375              ;;
    372376         *)   echo $triggertype" not yet implemented" >> $logfile
     
    389393            # or check value if it's increasing?
    390394            # missing: get information from previous trigger + interpret
    391             triggerfile=$flarealertspath"/"$night"-"$exclimit"_"$siglimit"-source"$sourcekey".trigger"$triggertype
     395            triggerfile=$flarealertspath"/"$night"-"$limits"-source"$sourcekey".trigger"$triggertype
    392396         else
    393397            # smaller binning: check if trigger is identical
    394             triggerfile=$flarealertspath"/"$night"_"`printf %03d $runid`"-"$exclimit"_"$siglimit"-source"$sourcekey".trigger"$triggertype
    395             donetriggerfile=$triggerfile".done"
    396             #ls $donetriggerfile
    397             # write new file only if old files do not agree
    398             if [ "$donetriggerfile" != "" ] && [ -e $donetriggerfile ]
     398            triggerfile=$flarealertspath"/"$night"_"`printf %03d $runid`"-"$limits"-source"$sourcekey".trigger"$triggertype
     399         fi
     400         donetriggerfile=$triggerfile".done"
     401         #ls $donetriggerfile
     402
     403         # check if nightly flux increased
     404         if [ "$bin" = "" ]
     405         then
     406            trigger2=1
     407            changedfiles=( `ls $donetriggerfile"-changed-"* 2>/dev/null` )
     408            if [ ${#changedfiles[@]} -gt 0 ]
     409            then
     410               oldnightlyexc=`grep "corr. cu:      [0-9].[0-9] " ${changedfiles[@]} | grep -o -E ' [0-9].[0-9] ' | sort | tail -1`
     411               trigger2=`echo " $exc > $oldnightlyexc " | bc -l`
     412               echo "trigger2: "$trigger2" (exc: "$exc", oldexc: "$oldnightlyexc")"
     413               echo "trigger2: "$trigger2" (exc: "$exc", oldexc: "$oldnightlyexc")" >> $logfile
     414            fi
     415         fi
     416         
     417         # write new file only if old files do not agree
     418         if [ -e $donetriggerfile ]
     419         then
     420            diff $donetriggerfile $triggerfile >/dev/null
     421            checkstatus=`echo $?`
     422            if [ $checkstatus -eq 0 ]
    399423            then
    400                diff $donetriggerfile $triggerfile >/dev/null
    401                checkstatus=`echo $?`
    402                if [ $checkstatus -eq 0 ]
    403                then
    404                   echo "  alert already done "$donetriggerfile >> $logfile
    405                   i=`echo $i +1 | bc -l`
    406                   continue
    407                fi
     424               echo "  alert already done "$donetriggerfile >> $logfile
     425               i=`echo $i +1 | bc -l`
     426               continue
    408427            fi
    409             if [ -e $triggerfile ]
    410             then
    411                mv $triggerfile $donetriggerfile
    412             fi
    413          fi
     428         fi
     429         if [ -e $triggerfile ]
     430         then
     431            mv $triggerfile $donetriggerfile
     432         fi
     433         
    414434         #echo $night"_"$runid" "$sourcekey" -> "$triggerfile
    415435         echo "  writing "$triggerfile >> $logfile
     
    418438         echo "-------------- " >> $triggerfile
    419439         echo "  type: "$triggertype >> $triggerfile
    420          echo "  excess limit: "$exclimit" evts/h" >> $triggerfile
     440         echo "  excess limit: "$exclimit" CU" >> $triggerfile
    421441         echo "  significance limit: "$siglimit" sigma" >> $triggerfile
    422442         if [ "$bin" = "" ]   
     
    468488         fi
    469489         
    470          if [ "$donetriggerfile" != "" ] && [ -e $donetriggerfile ]
     490         if [ -e $donetriggerfile ]
    471491         then
    472492            diff $donetriggerfile $triggerfile >/dev/null
     
    482502         
    483503         # send email only of $donetriggerfile doesn't exists
    484          if ! [ -e $donetriggerfile ]
     504         if ! [ -e $donetriggerfile ] 
    485505         then
     506            query="INSERT FlareAlerts.FlareTriggers SET fTriggerInserted=Now(), fNight="$night", fRunID="$runid", fTriggerType="$triggertype
     507            if [ "$bin" = "" ]
     508            then
     509               query=$query", fBinning=NULL"
     510            else
     511               query=$query", fBinning="$bin
     512            fi
     513            echo $query
     514            sendquery >> $logfile
     515           
    486516            # AMON case: create VOEvent-File
    487             if [ $triggertype -eq 4 ]
     517            if [ $triggertype -eq 5 ]
    488518            then
    489519               voeventfile=$voeventpath"/"`basename $triggerfile`".xml"
     
    495525               print_voevent_file > $voeventfile
    496526               # in amon-case no email needs to be sent
    497                continue
     527            else
     528               if [ "$bin" = "" ] && [ $trigger2 -eq 0 ]
     529               then
     530                  continue
     531               fi
     532               echo "sending["$triggertype"] "$triggerfile
     533               echo "sending["$triggertype"] "$triggerfile >> $logfile
     534               cat $triggerfile | mail -s 'test flare alert ' -b $emailfrom -r $emailfrom $emailto
     535               #cat $triggerfile | mail -s "test flare alert for $sourcename " $emailto
     536               # that's also the cases for making a call
     537               # fill DB for shifthelper
    498538            fi
    499 
    500             cat $triggerfile | mail -s 'test flare alert ' -b $emailfrom -r $emailfrom $emailto
    501          fi
    502          
    503          #cat $triggerfile | mail -s "test flare alert for $sourcename " $emailto
    504          # that's also the cases for making a call
    505          
     539         fi
    506540      fi
    507541
     
    570604   printprocesslog "INFO Evaluation for $sourcename ... "
    571605   echo "Evaluation for $sourcename ... " >> $logfile
    572    echo " average fluxes: "$avgfluxmonth"+-"$errormonth" "$avgfluxyear"+-"$erroryear" "$avgflux"+-"$error >> $logfile
     606   echo " average fluxes: "$avgfluxmonth"+-"$errormonth" evts/h (last month) "$avgfluxyear"+-"$erroryear" evts/h (last year) "$avgflux"+-"$error" evts/h (all)" >> $logfile
    573607   
    574608   # missing: get limits from DB (structure needs to be defined)
     
    649683   fi
    650684   
     685   # X-ray ToO
     686   triggertype=4
     687   # to be added
     688   
    651689   # AMON - automatic triggers using VOEvent files
    652    triggertype=4
     690   triggertype=5
    653691   printprocesslog "INFO checking for [Trigger to AMON]" >> $logfile
    654692   echo "[Trigger to AMON]" >> $logfile
Note: See TracChangeset for help on using the changeset viewer.