| 196 | {{{!#Spoiler |
| 197 | {{{!#sql |
| 198 | CREATE TEMPORARY TABLE ThetaHist |
| 199 | ( |
| 200 | `.theta` SMALLINT UNSIGNED NOT NULL, |
| 201 | lo DOUBLE NOT NULL COMMENT 'Lower edge of zenith distance bin in degree', |
| 202 | hi DOUBLE NOT NULL COMMENT 'Upper edge of zenith distance bin in degree', |
| 203 | CountN INT UNSIGNED NOT NULL, |
| 204 | OnTime FLOAT NOT NULL, |
| 205 | ZdWeight DOUBLE NOT NULL COMMENT 'tau(delta theta)', |
| 206 | ErrZdWeight DOUBLE NOT NULL COMMENT 'sigma(tau)', |
| 207 | PRIMARY KEY (`.theta`) USING HASH |
| 208 | ) ENGINE=Memory |
| 209 | AS |
| 210 | ( |
| 211 | WITH EventCount AS |
| 212 | ( |
| 213 | SELECT |
| 214 | INTERVAL(DEGREES(Theta), %0:bins) AS `.theta`, |
| 215 | COUNT(*) AS CountN |
| 216 | FROM |
| 217 | MonteCarloFiles |
| 218 | LEFT JOIN |
| 219 | factmc.OriginalMC USING(FileId) |
| 220 | GROUP BY |
| 221 | `.theta` |
| 222 | ) |
| 223 | SELECT |
| 224 | `.theta`, lo, hi, |
| 225 | CountN, |
| 226 | OnTime, |
| 227 | OnTime/CountN AS ZdWeight, |
| 228 | (OnTime/CountN)*SQRT(POW(1/300, 2) + 1/CountN) AS ErrZdWeight\ |
| 229 | FROM |
| 230 | ObservationTime |
| 231 | LEFT JOIN |
| 232 | EventCount USING(`.theta`) |
| 233 | LEFT JOIN |
| 234 | BinningTheta ON `.theta`=bin |
| 235 | ORDER BY |
| 236 | `.theta` |
| 237 | ) |
| 238 | }}} |
| 239 | }}} |
| 240 | |