| | 1139 | Another way to write the same query is |
| | 1140 | {{{#!spoiler |
| | 1141 | {{{#!sql |
| | 1142 | WITH |
| | 1143 | Table0 AS |
| | 1144 | ( |
| | 1145 | SELECT -- 0 |
| | 1146 | Weight, |
| | 1147 | Size, |
| | 1148 | NumUsedPixels, |
| | 1149 | NumIslands, |
| | 1150 | Leakage1, |
| | 1151 | MeanX, |
| | 1152 | MeanY, |
| | 1153 | CosDelta, |
| | 1154 | SinDelta, |
| | 1155 | M3Long, |
| | 1156 | SlopeLong, |
| | 1157 | Width/Length AS WdivL, |
| | 1158 | PI()*Width*Length AS Area, |
| | 1159 | cosa*X - sina*Y AS PX, |
| | 1160 | cosa*Y + sina*X AS PY |
| | 1161 | FROM RunInfo |
| | 1162 | LEFT JOIN Images USING (FileId) |
| | 1163 | LEFT JOIN Position USING (FileId, EvtNumber) |
| | 1164 | CROSS JOIN Wobble |
| | 1165 | WHERE |
| | 1166 | fSourceKey=5 |
| | 1167 | AND |
| | 1168 | fRunTypeKey=1 |
| | 1169 | AND |
| | 1170 | FileId BETWEEN 131101000 AND 131107000 |
| | 1171 | AND |
| | 1172 | fZenithDistanceMax<35 |
| | 1173 | AND |
| | 1174 | fR750Cor>0.9e0*fR750Ref |
| | 1175 | AND |
| | 1176 | NumUsedPixels>5.5 |
| | 1177 | AND |
| | 1178 | NumIslands<3.5 |
| | 1179 | AND |
| | 1180 | Leakage1<0.1 |
| | 1181 | ), |
| | 1182 | |
| | 1183 | Table1 AS |
| | 1184 | ( |
| | 1185 | SELECT |
| | 1186 | Weight, CosDelta, SinDelta, M3Long, SlopeLong, Leakage1, WdivL, |
| | 1187 | MeanX - PX/1.02e0 AS DX, |
| | 1188 | MeanY - PY/1.02e0 AS DY |
| | 1189 | FROM |
| | 1190 | Table0 |
| | 1191 | WHERE |
| | 1192 | Area < LOG10(Size)*898e0-1535e0 |
| | 1193 | ), |
| | 1194 | |
| | 1195 | Table2 AS |
| | 1196 | ( |
| | 1197 | SELECT |
| | 1198 | Weight, CosDelta, SinDelta, DX, DY, M3Long, SlopeLong, Leakage1, WdivL, |
| | 1199 | SQRT(DX*DX + DY*DY) AS Norm |
| | 1200 | FROM |
| | 1201 | Table1 |
| | 1202 | ), |
| | 1203 | |
| | 1204 | Table3 AS |
| | 1205 | ( |
| | 1206 | SELECT |
| | 1207 | Weight, M3Long, SlopeLong, Leakage1, WdivL, Norm, |
| | 1208 | LEAST(GREATEST((CosDelta*DY - SinDelta*DX)/Norm, -1), 1) AS LX, |
| | 1209 | SIGN(CosDelta*DX + SinDelta*DY) AS Sign |
| | 1210 | FROM |
| | 1211 | Table2 |
| | 1212 | ), |
| | 1213 | |
| | 1214 | Table5 AS |
| | 1215 | ( |
| | 1216 | SELECT |
| | 1217 | Weight, Leakage1, WdivL, LX, |
| | 1218 | Norm *0.0117193246260285378e0 AS Dist, |
| | 1219 | M3Long *Sign*0.0117193246260285378e0 AS M3L, |
| | 1220 | SlopeLong*Sign/0.0117193246260285378e0 AS Slope |
| | 1221 | FROM |
| | 1222 | Table3 |
| | 1223 | ), |
| | 1224 | |
| | 1225 | Table6 AS |
| | 1226 | ( |
| | 1227 | SELECT |
| | 1228 | Weight, WdivL, Dist, LX, M3L, Slope, |
| | 1229 | 1.39252e0 + 0.154247e0*Slope + 1.67972e0*(1-1/(1+4.86232e0*Leakage1)) AS Xi |
| | 1230 | FROM |
| | 1231 | Table5 |
| | 1232 | ), |
| | 1233 | |
| | 1234 | Table7 AS |
| | 1235 | ( |
| | 1236 | SELECT |
| | 1237 | Weight, Dist, LX, |
| | 1238 | IF (M3L<-0.07 || (Dist-0.5e0)*7.2e0-Slope<0, -Xi, Xi) * (1-WdivL) AS Disp |
| | 1239 | FROM |
| | 1240 | Table6 |
| | 1241 | ), |
| | 1242 | |
| | 1243 | Table8 AS |
| | 1244 | ( |
| | 1245 | SELECT |
| | 1246 | Weight, |
| | 1247 | (Disp*Disp + Dist*Dist - 2*Disp*Dist*SQRT(1-LX*LX)) AS ThetaSq |
| | 1248 | FROM |
| | 1249 | Table7 |
| | 1250 | ), |
| | 1251 | |
| | 1252 | Table9 AS |
| | 1253 | ( |
| | 1254 | SELECT -- 9 |
| | 1255 | COUNT(IF(Weight>0, 1, NULL)) AS `Signal`, |
| | 1256 | COUNT(IF(Weight<0, 1, NULL))/5 AS `Background` |
| | 1257 | FROM |
| | 1258 | Table8 |
| | 1259 | WHERE |
| | 1260 | ThetaSq<0.024 |
| | 1261 | ) |
| | 1262 | |
| | 1263 | SELECT |
| | 1264 | *, |
| | 1265 | `Signal` - `Background` AS `Excess`, |
| | 1266 | LiMa(`Signal`, `Background`) AS `Significance` |
| | 1267 | FROM |
| | 1268 | Table9 |
| | 1269 | |
| | 1270 | }}} |
| | 1271 | |
| | 1272 | }}} |
| | 1273 | |