Changeset 19036


Ignore:
Timestamp:
06/29/18 11:06:29 (6 years ago)
Author:
Daniela Dorner
Message:
some cleanup and comments added
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/Tools/get_data.sh

    r19035 r19036  
    7878function get_results()
    7979{
    80    # some basic query parts
    81 
    82    # data check based on artificial trigger rate
    83    #dch=" AND fR750Cor/fR750Ref >0.93 "
    84    dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
     80   # some query parts
     81
     82   # some numbers for flux calculation
     83   crabflux="3.37e-11"
     84   fluxprec=13
     85   crabflux="3.37"
     86   fluxprec=2
     87   
     88   # some names and definitions needed several times below
    8589   # ontime
    8690   ontime1=" TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn "
    8791   ontime2=" fOnTimeAfterCuts "
    8892   ontimeif=" IF(ISNULL(fEffectiveOn), "$ontime2", "$ontime1") "
    89    from=" FROM RunInfo LEFT JOIN "$table" USING (fNight, fRunID) "
    90    # time range and source
    91    where=" WHERE fSourceKey="$source" AND fNight BETWEEN "$nightmin" AND "$nightmax
    92    where=$where" AND NOT ISNULL(fNumExcEvts) "
    93    # some sanity checks
    94    where=$where" AND fRunTypeKey=1 "
    95    # zd cut
    96    where=$where" AND fZenithDistanceMax < "$zdmax
    97    # th cut
    98    where=$where" AND fThresholdMedian < "$thmax
    99    where=$where" "$dch
    100    
    101    #
     93   # zd and threshold
     94   zenith="fZenithDistance"
     95   thresh="IF(ISNULL(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)"
     96   # correction factor for excess rate (formula by TB)
     97   correvts=" fNumExcEvts*(pow(cos("$zenith"Mean*PI()/180),3)+14.8/21.9*pow(sin(2*"$zenith"Mean*PI()/180),5))/((1-0.00124/1.21*("$thresh"-500)*("$thresh">=500))) "
     98   # conversion to CU (determined by DD for QLA)
     99   # https://www.fact-project.org/logbook/showthread.php?tid=4927
    102100   cufactor=" Avg(CUQLA(fNight)) "
    103    crabflux="3.37e-11"
    104    fluxprec=13
    105    crabflux="3.37"
    106    fluxprec=2
    107    
     101   # some calculations
     102   excerr="ExcErr(Sum(fNumSigEvts), SUM(fNumBgEvts))"
     103   CU="SUM("$correvts"/CUQLA(fNight))/SUM("$ontimeif")*3600"
     104   CUerr=$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/CUQLA(fNight))/SUM(fNumExcEvts)"
     105   excerr2="ExcErr(SUM(o.sigevts),SUM(o.bgevts))"
     106   CU2="SUM(o.corevts/o.cu)/SUM(o.ot)*3600"
     107   CUerr2=$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cu)/(SUM(o.sigevts)-SUM(o.bgevts))"
     108   
     109   # columns to be selected
     110   # for night-binning
     111   ontime=" ROUND(SUM("$ontimeif")/60., 1) AS ontime"
     112   excrate=" ROUND(SUM(fNumExcEvts)/SUM("$ontimeif")*3600, 1) AS excrate"
     113   significance="ROUND(LiMa(Sum(fNumSigEvts), SUM(fNumBgEvts)), 1) AS significance"
     114   numexc="Sum(fNumExcEvts) AS numexc"
     115   numsig="Sum(fNumSigEvts) AS numsig"
     116   numbg="Sum(fNumBgEvts) AS numbg"
     117   excrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600, 1) AS excrateerr"
     118   correxcrate=" ROUND(SUM("$correvts")/SUM("$ontimeif")*3600, 1) AS correxcrate"
     119   correxcrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600*SUM("$correvts")/SUM(fNumExcEvts), 1) AS correxcrateerr"
     120   cu=" ROUND("$CU", 2) AS cu"
     121   cuerr=" ROUND("$CUerr", 2) AS cuerr"
     122   flux="ROUND("$CU" * "$crabflux", 2) AS flux"
     123   fluxerr="ROUND("$CUerr" * "$crabflux", 2) AS fluxerr"
     124   # for minute binning
     125   ontime2=" ROUND(SUM(o.ot)/60., 1) AS ontime"
     126   excrate2=" ROUND((SUM(o.sigevts)-SUM(o.bgevts))/SUM(o.ot)*3600, 1) AS excrate"
     127   significance2=" ROUND(LiMa(SUM(o.sigevts),SUM(o.bgevts)), 1) AS significance"
     128   numexc2="Sum(o.sigevts-o.bgevts) AS numexc"
     129   numsig2="Sum(o.sigevts) AS numsig"
     130   numbg2="Sum(o.bgevts) AS numbg"
     131   excrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600, 1) AS excrateerr"
     132   correxcrate2=" ROUND(SUM(o.corevts)/SUM(o.ot)*3600, 1) AS correxcrate"
     133   correxcrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600*SUM(o.corevts)/(SUM(o.sigevts)-SUM(o.bgevts)), 1) AS correxcrateerr"
     134   cu2=" ROUND("$CU2", 2) AS cu"
     135   cuerr2=" ROUND("$CUerr2", 2) AS cuerr"
     136   flux2="ROUND("$CU2" * "$crabflux", "$fluxprec") AS flux"
     137   fluxerr2="ROUND("$CUerr2" *"$crabflux", "$fluxprec") AS fluxerr"
     138
    108139   case $timeunit in
    109140      mjd)  delta="(Mjd(MAX(fRunStop))-Mjd(Min(fRunStart)))/2"
     
    141172            ;;
    142173   esac
    143    zenith="fZenithDistance"
    144    thresh="IF(ISNULL(fThresholdMinSet),fThresholdMedian,fThresholdMinSet)"
    145    # thomas correction factor
    146    correvts=" fNumExcEvts*(pow(cos("$zenith"Mean*PI()/180),3)+14.8/21.9*pow(sin(2*"$zenith"Mean*PI()/180),5))/((1-0.00124/1.21*("$thresh"-500)*("$thresh">=500))) "
    147    excerr="ExcErr(Sum(fNumSigEvts), SUM(fNumBgEvts))"
    148    CU="SUM("$correvts"/CUQLA(fNight))/SUM("$ontimeif")*3600"
    149    CUerr=$excerr"/SUM("$ontimeif")*3600*SUM("$correvts"/CUQLA(fNight))/SUM(fNumExcEvts)"
    150    excerr2="ExcErr(SUM(o.sigevts),SUM(o.bgevts))"
    151    CU2="SUM(o.corevts/o.cu)/SUM(o.ot)*3600"
    152    CUerr2=$excerr2"/SUM(o.ot)*3600*SUM(o.corevts/o.cu)/(SUM(o.sigevts)-SUM(o.bgevts))"
    153    
    154    ontime=" ROUND(SUM("$ontimeif")/60., 1) AS ontime"
    155    excrate=" ROUND(SUM(fNumExcEvts)/SUM("$ontimeif")*3600, 1) AS excrate"
    156    significance="ROUND(LiMa(Sum(fNumSigEvts), SUM(fNumBgEvts)), 1) AS significance"
    157    numexc="Sum(fNumExcEvts) AS numexc"
    158    numsig="Sum(fNumSigEvts) AS numsig"
    159    numbg="Sum(fNumBgEvts) AS numbg"
    160    excrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600, 1) AS excrateerr"
    161    correxcrate=" ROUND(SUM("$correvts")/SUM("$ontimeif")*3600, 1) AS correxcrate"
    162    # corerr = MMath::ErrorExc(excevtssum+bgevtssum, bgevtssum*5, 0.2)/ontimesum*3600.*corrate/excrate;
    163    correxcrateerr=" ROUND("$excerr"/SUM("$ontimeif")*3600*SUM("$correvts")/SUM(fNumExcEvts), 1) AS correxcrateerr"
    164    # correction on run basis
    165    cu=" ROUND("$CU", 2) AS cu"
    166    cuerr=" ROUND("$CUerr", 2) AS cuerr"
    167    flux="ROUND("$CU" * "$crabflux", 2) AS flux"
    168    fluxerr="ROUND("$CUerr" * "$crabflux", 2) AS fluxerr"
    169    
    170    ontime2=" ROUND(SUM(o.ot)/60., 1) AS ontime"
    171    excrate2=" ROUND((SUM(o.sigevts)-SUM(o.bgevts))/SUM(o.ot)*3600, 1) AS excrate"
    172    significance2=" ROUND(LiMa(SUM(o.sigevts),SUM(o.bgevts)), 1) AS significance"
    173    numexc2="Sum(o.sigevts-o.bgevts) AS numexc"
    174    numsig2="Sum(o.sigevts) AS numsig"
    175    numbg2="Sum(o.bgevts) AS numbg"
    176    excrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600, 1) AS excrateerr"
    177    correxcrate2=" ROUND(SUM(o.corevts)/SUM(o.ot)*3600, 1) AS correxcrate"
    178    correxcrateerr2=" ROUND("$excerr2"/SUM(o.ot)*3600*SUM(o.corevts)/(SUM(o.sigevts)-SUM(o.bgevts)), 1) AS correxcrateerr"
    179    cu2=" ROUND("$CU2", 2) AS cu"
    180    cuerr2=" ROUND("$CUerr2", 2) AS cuerr"
    181    flux2="ROUND("$CU2" * "$crabflux", "$fluxprec") AS flux"
    182    fluxerr2="ROUND("$CUerr2" *"$crabflux", "$fluxprec") AS fluxerr"
    183 
     174   
     175   # from and join of query
     176   from=" FROM RunInfo LEFT JOIN "$table" USING (fNight, fRunID) "
     177   
     178   # data check based on artificial trigger rate
     179   # details see https://www.fact-project.org/logbook/showthread.php?tid=5790
     180   #dch=" AND fR750Cor/fR750Ref >0.93 "
     181   dch=" AND fR750Cor/fR750Ref BETWEEN 0.93 AND 1.3 "
     182   
     183   # put together where-clause of query
     184   # time range and source
     185   where=" WHERE fSourceKey="$source" AND fNight BETWEEN "$nightmin" AND "$nightmax
     186   where=$where" AND NOT ISNULL(fNumExcEvts) "
     187   # some sanity checks
     188   where=$where" AND fRunTypeKey=1 "
     189   # zd cut
     190   where=$where" AND fZenithDistanceMax < "$zdmax
     191   # th cut
     192   where=$where" AND fThresholdMedian < "$thmax
     193   where=$where" "$dch
    184194   
    185195   if [ $bin -le 0 ]
     
    407417nightmin=20140714
    408418nightmax=20140805
    409 #get_results
     419get_results
     420
     421bin=30
     422name="Mrk501_2014_forMAGIC30"
     423get_results
     424
     425bin=0
     426name="P"
     427nightmin=20140501
     428nightmax=20140930
     429get_results
    410430
    411431bin=20
     
    414434name="Mrk501_test"
    415435get_results
    416 
    417 #bin=30
    418 #name="Mrk501_2014_forMAGIC30"
    419 #get_results
    420 
    421436
    422437
Note: See TracChangeset for help on using the changeset viewer.