Ignore:
Timestamp:
12/15/19 18:04:36 (5 years ago)
Author:
tbretz
Message:
Fixed Error calculation for final spectrum, it is difficult to keep usage of the zenith angle consistent. To avoid strange features in the plots, the best is to use the telescope pointing for data and correlate it with the particle direction for simulations.
Location:
trunk/FACT++/spectrum
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/spectrum/analysis.sql

    r19893 r19907  
    1111   returned. (Note that you must not add a comma behind it)
    1212
    13    100| %100:columns
    14    101| %101:files:: table containing the `FileId`s to analyze.
    15    102| %102:runinfo:: table with the run info data
    16    103| %103:events:: table with the image parameters
    17    104| %104:positions:: table with the source positions in the camera
    18    105| %105:estimator:: estimator for log10 energy
     13   100| %100:files:: table containing the `FileId`s to analyze.
     14   101| %101:runinfo:: table with the run info data
     15   102| %102:events:: table with the image parameters
     16   103| %103:positions:: table with the source positions in the camera
     17   104| %105:zenith:: zenith angle in degrees
     18   105| %104:columns
     19   106| %105:estimator:: estimator for log10 energy
     20
     21   WARNING:
     22     Right now, we correlate the mean zenith angle of the data
     23     file with the particle direction in the simulation!
    1924
    2025*************************************************************************** */
     
    2328(
    2429   SELECT
    25       %100:columns  -- this could be removed if we can join events via the same columns (without CorsikaNumResuse)
     30      %105:columns  -- this could be removed if we can join events via the same columns (without CorsikaNumResuse)
     31      %104:zenith AS Theta,
    2632      Weight,
    2733      Size,
     
    4046      cosa*Y + sina*X   AS PY
    4147   FROM
    42       %101:files
     48      %100:files
    4349   LEFT JOIN
    44       %102:runinfo USING (FileId)
     50      %101:runinfo USING (FileId)
    4551   LEFT JOIN
    46       %103:events USING (FileId)  -- This could be replaced by a user uploaded temporary table
     52      %102:events USING (FileId)  -- This could be replaced by a user uploaded temporary table
    4753   LEFT JOIN
    48       %104:positions USING (FileId, EvtNumber)
     54      %103:positions USING (FileId, EvtNumber)
    4955   CROSS JOIN
    5056      Wobble
     
    6066(
    6167   SELECT
    62       %100:columns
    63       Weight,
     68      %105:columns
     69      Theta, Weight,
    6470      Size, CosDelta, SinDelta, M3Long, SlopeLong, Leakage1, WdivL,
    6571      MeanX - PX/1.02e0 AS DX,
     
    7480(
    7581   SELECT
    76       %100:columns
    77       Weight,
     82      %105:columns
     83      Theta, Weight,
    7884      Size, CosDelta, SinDelta, DX, DY, M3Long, SlopeLong, Leakage1, WdivL,
    7985      SQRT(DX*DX + DY*DY) AS Norm
     
    8591(
    8692   SELECT
    87       %100:columns
    88       Weight,
     93      %105:columns
     94      Theta, Weight,
    8995      Size, M3Long, SlopeLong, Leakage1, WdivL, Norm,
    9096      LEAST(GREATEST((CosDelta*DY - SinDelta*DX)/Norm, -1), 1) AS LX,
     
    97103(
    98104   SELECT
    99       %100:columns
    100       Weight,
     105      %105:columns
     106      Theta, Weight,
    101107      Size, Leakage1, WdivL, LX,
    102108      Norm          *0.0117193246260285378e0 AS Dist,
     
    110116(
    111117   SELECT
    112       %100:columns
    113       Weight,
     118      %105:columns
     119      Theta, Weight,
    114120      Size, WdivL, Dist, LX, M3L, Slope,
    115121      1.39252e0 + 0.154247e0*Slope + 1.67972e0*(1-1/(1+4.86232e0*Leakage1)) AS Xi
     
    121127(
    122128   SELECT
    123       %100:columns
    124       Weight,
     129      %105:columns
     130      Theta, Weight,
    125131      Size, Dist, LX,
    126132      IF (M3L<-0.07 OR (Dist-0.5e0)*7.2e0-Slope<0, -Xi, Xi) * (1-WdivL) AS Disp
     
    130136
    131137SELECT
    132    %100:columns
    133    Weight,
     138   %105:columns
     139   Theta, Weight,
    134140   (Disp*Disp + Dist*Dist - 2*Disp*Dist*SQRT(1-LX*LX)) AS ThetaSq,
    135    %105:estimator AS LogEnergyEst
     141   %106:estimator AS LogEnergyEst
    136142FROM
    137143   Table7
  • trunk/FACT++/spectrum/data.sql

    r19905 r19907  
    11SELECT
    2    INTERVAL(fZenithDistanceMean, %106:theta)  AS `.theta`,
    3    INTERVAL(LogEnergyEst, %107:sparse)  AS  `.sparse_est`,
     2   INTERVAL(Theta, %107:theta)  AS `.theta`,
     3   INTERVAL(LogEnergyEst, %108:sparse)  AS  `.sparse_est`,
    44
    55   -- Signal and Background counts
  • trunk/FACT++/spectrum/simulation.sql

    r19893 r19907  
    33   SELECT
    44      Weight, Energy, LogEnergyEst,
    5       INTERVAL(Zd, %106:theta)  AS `.theta`,
    6       INTERVAL(LogEnergyEst, %107:sparse)  AS `.sparse_est`,
    7       INTERVAL(LogEnergyEst, %108:dense)  AS `.dense_est`,
    8       INTERVAL(LOG10(Energy), %107:sparse)  AS `.sparse_sim`,
    9       INTERVAL(LOG10(Energy), %108:dense)  AS `.dense_sim`,
     5      INTERVAL(Theta, %107:theta)  AS `.theta`,
     6      INTERVAL(LogEnergyEst, %108:sparse)  AS `.sparse_est`,
     7      INTERVAL(LogEnergyEst, %109:dense)  AS `.dense_est`,
     8      INTERVAL(LOG10(Energy), %108:sparse)  AS `.sparse_sim`,
     9      INTERVAL(LOG10(Energy), %109:dense)  AS `.dense_sim`,
    1010
    11       (%109:spectrum)/POW(Energy, SpectralIndex) AS SpectralWeight,  -- FIXME: Is this correct for files with different Slopes?
     11      (%110:spectrum)/POW(Energy, SpectralIndex) AS SpectralWeight,  -- FIXME: Is this correct for files with different Slopes?
    1212      LogEnergyEst - log10(Energy) AS Residual
    1313   FROM
  • trunk/FACT++/spectrum/spectrum.sql

    r19904 r19907  
    7676Flux AS
    7777(
    78    SELECT -- Return final result
     78   SELECT -- Calculate Flux and Relative Errors
    7979      *,
    8080
    81       -- Differetial Spectrum
     81      -- Differential Spectrum
    8282
    8383      SimExcess/SimFluxW  AS  Efficiency,
    8484
    8585      Excess/SimExcess/Width/AreaTime  AS  ExcessRatio,
    86          1/SQRT(
     86         SQRT(
    8787             + POW(ErrExcess    / Excess,    2)
    8888             + POW(ErrSimExcess / SimExcess, 2)
    89          )  AS  SigmaExcessRatio,
     89         )  AS  RelErrExcessRatio,
    9090
    9191
    9292      Excess/SimExcess*SimFluxW/Width/AreaTime  AS  Flux,
    93          1/SQRT(
     93         SQRT(
    9494             + POW(ErrExcess    / Excess,    2)
    9595             + POW(ErrSimExcess / SimExcess, 2)
    9696             + POW(ErrSimFluxW  / SimFluxW,  2)
    97          )  AS  SigmaFlux,
     97         )  AS  RelErrFlux,
    9898
    9999      -- Integral Spectrum
     
    102102
    103103      ExcessI/SimExcessI/AreaTime  AS  ExcessRatioI,
    104          1/SQRT(
     104         SQRT(
    105105             + POW(ErrExcessI    / ExcessI,    2)
    106106             + POW(ErrSimExcessI / SimExcessI, 2)
    107          )  AS  SigmaExcessRatioI,
     107         )  AS  RelErrExcessRatioI,
    108108
    109109
    110110      ExcessI/SimExcessI*SimFluxI/AreaTime  AS  FluxI,
    111          1/SQRT(
     111         SQRT(
    112112             + POW(ErrExcessI    / ExcessI,    2)
    113113             + POW(ErrSimExcessI / SimExcessI, 2)
    114114             + POW(ErrSimFluxI   / SimFluxI,   2)
    115          )  AS  SigmaFluxI
     115         )  AS  RelErrFluxI
    116116
    117117   FROM
    118118      CombinedData
    119119),
    120 Spectrum AS
     120Errors AS
    121121(
    122    SELECT -- Return final result
     122   SELECT -- Calculate Inverse of Relative Errors (Sigma) and Absolute Errors
    123123      *,
    124124
    125       ExcessRatio /SigmaExcessRatio   AS  ErrExcessRatio,
    126       ExcessRatioI/SigmaExcessRatioI  AS  ErrExcessRatioI,
    127       ABS(Flux)   /SigmaFlux          AS  ErrFlux,
    128       ABS(FluxI)  /SigmaFluxI         AS  ErrFluxI
     125      IF(RelErrExcessRatio =0, NULL, 1/RelErrExcessRatio )  AS  SigmaExcessRatio,
     126      IF(RelErrExcessRatioI=0, NULL, 1/RelErrExcessRatioI)  AS  SigmaExcessRatioI,
     127      IF(RelErrFlux        =0, NULL, 1/RelErrFlux        )  AS  SigmaFlux,
     128      IF(RelErrFluxI       =0, NULL, 1/RelErrFluxI       )  AS  SigmaFluxI,
     129
     130      IF(Excess =0, ErrExcess /SimExcess   /AreaTime/Width, ExcessRatio *RelErrExcessRatio )  AS  ErrExcessRatio,
     131      IF(ExcessI=0, ErrExcessI/SimExcessI  /AreaTime,       ExcessRatioI*RelErrExcessRatioI)  AS  ErrExcessRatioI,
     132      IF(Excess =0, ErrExcess /Efficiency  /AreaTime/Width, ABS(Flux)   *RelErrFlux        )  AS  ErrFlux,
     133      IF(ExcessI=0, ErrExcessI/EfficiencyI /AreaTime,       ABS(FluxI)  *RelErrFluxI       )  AS  ErrFluxI
    129134   FROM
    130135      Flux
     
    133138   *,
    134139
    135    -- Integrated Spectrum
     140   -- Integrate Differential Spectrum
    136141
    137142   SUM(Flux*Width) OVER Integral AS IntegratedFlux,
     
    139144
    140145FROM
    141    Spectrum
     146   Errors
    142147WINDOW
    143148   Integral AS (ORDER BY %101:bin DESC)
  • trunk/FACT++/spectrum/summary-sim.sql

    r19902 r19907  
    3030      %102:bin
    3131),
    32 Triggered AS -- Summarizy triggered (ceres) data in bins
     32Triggered AS -- Summarize triggered (ceres) data in bins
    3333(
    3434   SELECT
Note: See TracChangeset for help on using the changeset viewer.