| 435 | |
| 436 | Similarly to the analysis of Data, another query summarizes the !MonteCarlo Analysis. |
| 437 | |
| 438 | {{{#!Spoiler |
| 439 | {{{#!sql |
| 440 | WITH Table0 AS |
| 441 | ( |
| 442 | SELECT |
| 443 | Weight, |
| 444 | INTERVAL(Zd, %6:theta) AS `.theta`, |
| 445 | INTERVAL(LogEnergyEst, %7:energyest) AS `.energyest`, |
| 446 | INTERVAL(log10(Energy), %8:energysim) AS `.energysim`, |
| 447 | (%9:spectrum)/pow(Energy, SpectralIndex) AS SpectralWeight, |
| 448 | LogEnergyEst - log10(Energy) AS Residual |
| 449 | FROM |
| 450 | Excess |
| 451 | ), |
| 452 | Table1 AS |
| 453 | ( |
| 454 | SELECT |
| 455 | `.energyest`, |
| 456 | `.energysim`, |
| 457 | |
| 458 | -- Signal, Background, Excess |
| 459 | SUM( IF(Weight>0, ZdWeight*SpectralWeight, 0)) OVER EnergyEst AS `SignalW`, |
| 460 | SUM( IF(Weight<0, ZdWeight*SpectralWeight, 0)) OVER EnergyEst AS `BackgroundW`, |
| 461 | SUM( IF(Weight>0, POW(ErrZdWeight*SpectralWeight,2), 0)) OVER EnergyEst AS `SignalW2`, |
| 462 | SUM( IF(Weight<0, POW(ErrZdWeight*SpectralWeight,2), 0)) OVER EnergyEst AS `BackgroundW2`, |
| 463 | COUNT(IF(Weight>0, 1, NULL)) OVER EnergyEst AS `SignalN`, |
| 464 | COUNT(IF(Weight<0, 1, NULL)) OVER EnergyEst AS `BackgroundN`, |
| 465 | -- SUM( IF(Table9.Weight>0, ThetaHist.Weight*spectrum/Energy, 0)) OVER EnergyEst AS `SignalW`, |
| 466 | -- SUM( IF(Table9.Weight<0, ThetaHist.Weight*spectrum/Energy, 0)) OVER EnergyEst AS `BackgroundW`, |
| 467 | -- SUM( IF(Table9.Weight>0, POW(ThetaHist.Weight*spectrum/Energy,2), 0)) OVER EnergyEst AS `SignalW2`, |
| 468 | -- SUM( IF(Table9.Weight<0, POW(ThetaHist.Weight*spectrum/Energy,2), 0)) OVER EnergyEst AS `BackgroundW2`, |
| 469 | |
| 470 | -- Threshold |
| 471 | SUM( Weight * ZdWeight*SpectralWeight ) OVER EnergySim AS `ThresholdW`, |
| 472 | SUM(POW(Weight * ErrZdWeight*SpectralWeight,2)) OVER EnergySim AS `ThresholdW2`, |
| 473 | SUM( Weight ) OVER EnergySim AS `ThresholdN`, |
| 474 | -- SUM( Table9.Weight/Energy * ThetaHist.Weight*spectrum ) OVER EnergySim AS `ThresholdW`, |
| 475 | -- SUM( POW(Table9.Weight/Energy * ThetaHist.Weight*spectrum,2) ) OVER EnergySim AS `ThresholdW2`, |
| 476 | -- SUM( Table9.Weight/Energy ) OVER EnergySim AS `ThresholdN` |
| 477 | |
| 478 | -- Estimators |
| 479 | SUM(IF(Weight>0, ZdWeight*SpectralWeight, 0)) OVER EnergySim AS SimW, |
| 480 | SUM(IF(Weight>0, Residual* ZdWeight*SpectralWeight, 0)) OVER EnergyEst AS EstSum, |
| 481 | SUM(IF(Weight>0, Residual* ZdWeight*SpectralWeight, 0)) OVER EnergySim AS SimSum, |
| 482 | SUM(IF(Weight>0, POW(Residual,2)*ZdWeight*SpectralWeight, 0)) OVER EnergyEst AS EstSum2, |
| 483 | SUM(IF(Weight>0, POW(Residual,2)*ZdWeight*SpectralWeight, 0)) OVER EnergySim AS SimSum2, |
| 484 | |
| 485 | -- Migration |
| 486 | SUM(Weight * ZdWeight*SpectralWeight) OVER Migration AS `MigrationW`, |
| 487 | SUM(Weight ) OVER Migration AS `MigrationN` |
| 488 | FROM |
| 489 | Table0 |
| 490 | INNER JOIN |
| 491 | ThetaHist USING(`.theta`) |
| 492 | WINDOW |
| 493 | EnergyEst AS (PARTITION BY `.energyest`), |
| 494 | EnergySim AS (PARTITION BY `.energysim`), |
| 495 | Migration AS (PARTITION BY `.energysim`,`.energyest`) |
| 496 | ) |
| 497 | SELECT DISTINCT |
| 498 | *, |
| 499 | `SignalW` - `BackgroundW`/5 AS `ExcessW`, |
| 500 | `SignalN` - `BackgroundN`/5 AS `ExcessN`, |
| 501 | ExcErr(`SignalW2`, `BackgroundW2`/5) AS `ErrExcessW`, |
| 502 | ExcErr(`SignalN`, `BackgroundN` /5) AS `ErrExcessN`, |
| 503 | IF(SignalW=0, 0, EstSum / SignalW) AS BiasEst, |
| 504 | IF(SimW =0, 0, SimSum / SimW) AS BiasSim, |
| 505 | IF(SignalW=0, 0, SQRT(EstSum2/SignalW - POW(EstSum/SignalW, 2))) AS ResolutionEst, |
| 506 | IF(SimW =0, 0, SQRT(SimSum2/SimW - POW(SimSum/SimW, 2))) AS ResolutionSim |
| 507 | FROM |
| 508 | Table1 |
| 509 | }}} |
| 510 | }}} |
| 511 | |
| 512 | The placeholders `%6:theta`, `%7:energyest` and `%8:energysim` are the binnings (as used previously) for the zenith angle and the logarithm (base 10) of the estimated and true energy. `%9:spectrum` is the (unknown) 'true' source spectrum, for example `POW(Energy, -2.4)`. |