| 274 | === Analysis Query === |
| 275 | |
| 276 | The analysis of Data and !MontaCarlo files must be done totally identical to produce reasonable results. Therefore, the exact same query (or code) should be used for the analysis of both. In this example, the query has to provide two columns, `Weight` and `LogEnergyEst` for all gamma-line events. The weight must be +1 for events in the on-region and -0.2 for an event in the off-region (corresponding to the number of five wobble positions). !LogEnergyEst must contain \(\log_{10}\) of the estimated energy for each event. Only events surviving background suppression and spatial (theta) cuts should be considered. |
| 277 | |
| 278 | {{{#!Spoiler |
| 279 | {{{#!sql |
| 280 | WITH Table0 AS |
| 281 | ( |
| 282 | SELECT |
| 283 | %0:columns -- this could be removed if we can join events via the same columns (without CorsikaNumResuse) |
| 284 | Weight, |
| 285 | Size, |
| 286 | NumUsedPixels, |
| 287 | NumIslands, |
| 288 | Leakage1, |
| 289 | MeanX, |
| 290 | MeanY, |
| 291 | CosDelta, |
| 292 | SinDelta, |
| 293 | M3Long, |
| 294 | SlopeLong, |
| 295 | Width/Length AS WdivL, |
| 296 | PI()*Width*Length AS Area, |
| 297 | cosa*X - sina*Y AS PX, |
| 298 | cosa*Y + sina*X AS PY |
| 299 | FROM |
| 300 | %1:files |
| 301 | LEFT JOIN |
| 302 | %2:runinfo USING (FileId) |
| 303 | LEFT JOIN |
| 304 | %3:events USING (FileId) -- This could be replaced by a user uploaded temporary table |
| 305 | LEFT JOIN |
| 306 | %4:positions USING (FileId, EvtNumber) |
| 307 | CROSS JOIN |
| 308 | Wobble |
| 309 | WHERE |
| 310 | NumUsedPixels>5.5 |
| 311 | AND |
| 312 | NumIslands<3.5 |
| 313 | AND |
| 314 | Leakage1<0.1 |
| 315 | ), |
| 316 | |
| 317 | Table1 AS |
| 318 | ( |
| 319 | SELECT |
| 320 | %0:columns |
| 321 | Weight, |
| 322 | Size, CosDelta, SinDelta, M3Long, SlopeLong, Leakage1, WdivL, |
| 323 | MeanX - PX/1.02e0 AS DX, |
| 324 | MeanY - PY/1.02e0 AS DY |
| 325 | FROM |
| 326 | Table0 |
| 327 | WHERE |
| 328 | Area < LOG10(Size)*898e0 - 1535e0 |
| 329 | ), |
| 330 | |
| 331 | Table2 AS |
| 332 | ( |
| 333 | SELECT |
| 334 | %0:columns |
| 335 | Weight, |
| 336 | Size, CosDelta, SinDelta, DX, DY, M3Long, SlopeLong, Leakage1, WdivL, |
| 337 | SQRT(DX*DX + DY*DY) AS Norm |
| 338 | FROM |
| 339 | Table1 |
| 340 | ), |
| 341 | |
| 342 | Table3 AS |
| 343 | ( |
| 344 | SELECT |
| 345 | %0:columns |
| 346 | Weight, |
| 347 | Size, M3Long, SlopeLong, Leakage1, WdivL, Norm, |
| 348 | LEAST(GREATEST((CosDelta*DY - SinDelta*DX)/Norm, -1), 1) AS LX, |
| 349 | SIGN(CosDelta*DX + SinDelta*DY) AS Sign |
| 350 | FROM |
| 351 | Table2 |
| 352 | ), |
| 353 | |
| 354 | Table5 AS |
| 355 | ( |
| 356 | SELECT |
| 357 | %0:columns |
| 358 | Weight, |
| 359 | Size, Leakage1, WdivL, LX, |
| 360 | Norm *0.0117193246260285378e0 AS Dist, |
| 361 | M3Long *Sign*0.0117193246260285378e0 AS M3L, |
| 362 | SlopeLong*Sign/0.0117193246260285378e0 AS Slope |
| 363 | FROM |
| 364 | Table3 |
| 365 | ), |
| 366 | |
| 367 | Table6 AS |
| 368 | ( |
| 369 | SELECT |
| 370 | %0:columns |
| 371 | Weight, |
| 372 | Size, WdivL, Dist, LX, M3L, Slope, |
| 373 | 1.39252e0 + 0.154247e0*Slope + 1.67972e0*(1-1/(1+4.86232e0*Leakage1)) AS Xi |
| 374 | FROM |
| 375 | Table5 |
| 376 | ), |
| 377 | |
| 378 | Table7 AS |
| 379 | ( |
| 380 | SELECT |
| 381 | %0:columns |
| 382 | Weight, |
| 383 | Size, Dist, LX, |
| 384 | IF (M3L<-0.07 OR (Dist-0.5e0)*7.2e0-Slope<0, -Xi, Xi) * (1-WdivL) AS Disp |
| 385 | FROM |
| 386 | Table6 |
| 387 | ) |
| 388 | |
| 389 | SELECT |
| 390 | %0:columns |
| 391 | Weight, |
| 392 | (Disp*Disp + Dist*Dist - 2*Disp*Dist*SQRT(1-LX*LX)) AS ThetaSq, |
| 393 | %5:estimator AS LogEnergyEst |
| 394 | FROM |
| 395 | Table7 |
| 396 | HAVING |
| 397 | ThetaSq<0.024 |
| 398 | }}} |
| 399 | }}} |
| 400 | |
| 401 | The placeholder `%0:column` is currently used to request !MonteCarlo true values (such as Energy) in addition to the anaylsis values only for the analysis of simulated data. The must be no comma behind! In additon, `%1:files` is a placeholder for the table containing the `FileId`s to analyze, `%2:runinfo` for the table with the run info data, `%3:events` for the table with the image parameters and `%4:positions` for the table with the source positions in the camera. |