| 413 | |
| 414 | == Day-by-day light-curve == |
| 415 | |
| 416 | {{{#!sql |
| 417 | WITH Table8 AS |
| 418 | ( |
| 419 | WITH Table7 AS |
| 420 | ( |
| 421 | WITH Table6 AS |
| 422 | ( |
| 423 | WITH Table5 AS |
| 424 | ( |
| 425 | WITH Table4 AS |
| 426 | ( |
| 427 | WITH Table3 AS |
| 428 | ( |
| 429 | WITH Table2 AS |
| 430 | ( |
| 431 | WITH Table1 AS |
| 432 | ( |
| 433 | WITH Table0 AS |
| 434 | ( |
| 435 | SELECT -- 0 |
| 436 | FileId, |
| 437 | Weight, |
| 438 | Size, |
| 439 | NumUsedPixels, |
| 440 | NumIslands, |
| 441 | Leakage1, |
| 442 | MeanX, |
| 443 | MeanY, |
| 444 | CosDelta, |
| 445 | SinDelta, |
| 446 | M3Long, |
| 447 | SlopeLong, |
| 448 | Width/Length AS WdivL, |
| 449 | PI()*Width*Length AS Area, |
| 450 | cosa*X - sina*Y AS PX, |
| 451 | cosa*Y + sina*X AS PY |
| 452 | FROM RunInfo |
| 453 | LEFT JOIN Events USING (FileId) |
| 454 | LEFT JOIN Position USING (FileId, EvtNumber) |
| 455 | CROSS JOIN Wobble |
| 456 | WHERE |
| 457 | fSourceKey=5 |
| 458 | AND |
| 459 | fRunTypeKey=1 |
| 460 | AND |
| 461 | fR750Cor>0.9e0*fR750Ref |
| 462 | AND |
| 463 | NumUsedPixels>5.5 |
| 464 | AND |
| 465 | NumIslands<3.5 |
| 466 | AND |
| 467 | Leakage1<0.1 |
| 468 | |
| 469 | ) -- AS Table0 |
| 470 | |
| 471 | SELECT -- 1 |
| 472 | FileId, Weight, CosDelta, SinDelta, M3Long, SlopeLong, Leakage1, WdivL, |
| 473 | MeanX - PX*1.02e0 AS DX, |
| 474 | MeanY - PY*1.02e0 AS DY |
| 475 | FROM |
| 476 | Table0 |
| 477 | WHERE |
| 478 | Area < LOG10(Size)*898-1535 |
| 479 | |
| 480 | ) -- AS Table1 |
| 481 | |
| 482 | SELECT -- 2 |
| 483 | FileId, Weight, CosDelta, SinDelta, DX, DY, M3Long, SlopeLong, Leakage1, WdivL, |
| 484 | SQRT(DX*DX + DY*DY) AS Norm |
| 485 | FROM |
| 486 | Table1 |
| 487 | |
| 488 | ) -- AS Table2 |
| 489 | |
| 490 | SELECT -- 3 |
| 491 | FileId, Weight, M3Long, SlopeLong, Leakage1, WdivL, Norm, |
| 492 | LEAST(GREATEST((CosDelta*DY - SinDelta*DX)/Norm, -1), 1) AS LX, |
| 493 | SIGN(CosDelta*DX + SinDelta*DY) AS Sign |
| 494 | FROM |
| 495 | Table2 |
| 496 | |
| 497 | ) -- AS Table3 |
| 498 | |
| 499 | SELECT -- 4 |
| 500 | FileId, Weight, Leakage1, WdivL, LX, |
| 501 | Norm *0.0117193246260285378e0 AS Dist, |
| 502 | M3Long *Sign*0.0117193246260285378e0 AS M3L, |
| 503 | SlopeLong*Sign/0.0117193246260285378e0 AS Slope |
| 504 | FROM |
| 505 | Table3 |
| 506 | |
| 507 | ) -- AS Table4 |
| 508 | |
| 509 | SELECT -- 5 |
| 510 | FileId, Weight, WdivL, Dist, LX, M3L, Slope, |
| 511 | -- 1.39252e0 + 0.154247e0*Slope + 1.67972e0*(1-1/(1+4.86232e0*Leakage1)) AS Xi |
| 512 | 1.34e0 + 0.0755e0*Slope + 1.67972e0*(1-1/(1+4.86232e0*Leakage1)) AS Xi |
| 513 | FROM |
| 514 | Table4 |
| 515 | |
| 516 | ) -- AS Table5 |
| 517 | |
| 518 | SELECT -- 6 |
| 519 | FileId, Weight, Dist, LX, |
| 520 | IF (M3L<-0.07 || (Dist-0.5e0)*7.2e0-Slope<0, -Xi, Xi) * (1-WdivL) AS Disp |
| 521 | FROM |
| 522 | Table5 |
| 523 | |
| 524 | ) -- AS Table6 |
| 525 | |
| 526 | SELECT -- 7 |
| 527 | FileId, Weight, -- cos(alpha) = sqrt(1-lx^2) |
| 528 | (Disp*Disp + Dist*Dist - 2*Disp*Dist*SQRT(1-LX*LX)) AS ThetaSq |
| 529 | FROM |
| 530 | Table6 |
| 531 | |
| 532 | ) -- AS Table8 |
| 533 | |
| 534 | SELECT -- 9 |
| 535 | FileId, |
| 536 | COUNT(*) AS `Count`, |
| 537 | COUNT(IF(Weight>0, 1, NULL)) AS `Signal`, |
| 538 | COUNT(IF(Weight<0, 1, NULL))/5 AS `Background` |
| 539 | FROM |
| 540 | Table7 |
| 541 | WHERE |
| 542 | ThetaSq<0.024336 |
| 543 | GROUP BY |
| 544 | FileId |
| 545 | |
| 546 | ) -- AS Table8 |
| 547 | |
| 548 | SELECT -- 9 |
| 549 | FileId, |
| 550 | 20000000+FLOOR(FileId/1000) AS fNight, |
| 551 | FileId%1000 AS fRunID, |
| 552 | `Count` AS fNumRuns, |
| 553 | `Signal` AS fNumSigEvts, |
| 554 | `Background` AS fNumBgEvts, |
| 555 | `Signal` - `Background` AS fNumExcEvts |
| 556 | FROM |
| 557 | Table8 |
| 558 | }}} |
| 559 | |
| 560 | Note that this query can easily run 30min or more! |