source: trunk/www/dch/db_explorer.php@ 18956

Last change on this file since 18956 was 18883, checked in by Daniela Dorner, 7 years ago
added (tool by Thomas to plot DB content)
File size: 48.6 KB
Line 
1<?php
2
3 include("db.php");
4
5 // ini_set("display_errors", "On");
6 // ini_set("mysql.trace_mode", "On");
7
8
9if (isset($_GET['db']))
10 $database = $_GET['db'];
11
12$error_con = "";
13
14$db = new mysqli($host, $user, $pw, $database);
15if ($db->connect_error)
16{
17 header("HTTP/1.0 500 Internal server error");
18 $error_con = $db->connect_error;
19 //die("mysqli_connect: ".$db->connect_errno." ".$db->connect_error);
20}
21
22if (isset($_GET["short"]) && !$db->connect_error)
23{
24 $query = "SELECT URL from ShortURL.ShortURL WHERE `Key`=(".base62_decode($_GET["short"]).")";
25 if ($result = $db->query($query))
26 {
27 $uri = $_SERVER['REQUEST_URI'];
28 $pos = strpos($uri, '?');
29 $uri = $pos===FALSE ? $uri : substr($uri, 0, $pos);
30
31 $row = $result->fetch_assoc();
32 $result->free();
33
34 $url = $row['URL'];
35
36 $tiny = $_SERVER['HTTP_HOST'].$uri.'?'.$url;
37
38 if (isset($_GET["print"]) &&
39 strstr($url, "?print")==FALSE &&
40 strstr($url, "&print")==FALSE)
41 $tiny .= "&print";
42
43 header('Location: //'.$tiny);
44 die("");
45 }
46}
47
48$hidden = isset($_GET["print"]) ? "*{visibility:hidden;}.print{position:fixed;left:0;top:0;}.print *{visibility:visible;}" : "";
49$begin = isset($_GET["b"]) ? $_GET["b"] : "";
50$end = isset($_GET["e"]) ? $_GET["e"] : "";
51$source = isset($_GET["s"]) ? intval($_GET["s"]) : 0;
52$group = isset($_GET["g"]) ? intval($_GET["g"]) : 1;
53$table = isset($_GET["t"]) ? $_GET["t"] : "LP";
54$cut = isset($_GET["cut"]) ? trim($_GET["cut"]) : "";
55$having = isset($_GET["hav"]) ? trim($_GET["hav"]) : "";
56$vmin = isset($_GET["min"]) ? "minValue:".intval($_GET["min"])."," : "";
57$vmax = isset($_GET["max"]) ? "maxValue:".intval($_GET["max"])."," : "";
58$width = isset($_GET["w"]) ? floatval($_GET["w"]) : 1;
59$sql_x = isset($_GET["x"]) ? trim($_GET["x"]) : "";
60$sql_y = isset($_GET["y"]) ? trim($_GET["y"]) : "";
61$sql_err= isset($_GET["err"]) ? trim($_GET["err"]) : "";
62$rate = isset($_GET["r"]) ? intval($_GET["r"]) : 6;
63$offset = isset($_GET["o"]) ? floatval($_GET["o"]) : 0;
64$nohist = isset($_GET["no-hist"]) ? 1 : 0;
65$noerr = isset($_GET["no-errors"]) ? 1 : 0;
66$ontime = isset($_GET["on"]) ? floatval($_GET["on"]) : -1;
67//$clean = isset($_GET["clean"]) ? "AND fEffectiveOn>0.015" : "";
68
69if (!empty($sql_x))
70 $group = 42;
71
72if ($width<=0)
73 $width = 1;
74
75if (empty($offset))
76 $offset = 0;
77
78/*
79$join = isset($_GET["join"]) ? "LEFT JOIN ".$_GET["join"]." USING(fNight,fRunID)" : "";
80
81if (isset($_GET["x"]))
82 $group = 42;
83
84if (isset($_GET["y"]))
85 $rate = 44;
86
87// Backward compatibility
88if (isset($_GET["avg"]))
89{
90 $y = $_GET["avg"];
91 $rate = 42;
92}
93
94if (isset($_GET["sum"]))
95{
96 $y = $_GET["sum"];
97 $rate = 43;
98}
99
100if (isset($_GET["hist"]))
101{
102 $x = $_GET["hist"];
103 $rate = 45;
104 $group = 42;
105}
106
107*/
108
109$good = "";
110if (isset($_GET["good"]))
111{
112 $g = $_GET["good"];
113
114 if ($g&0x1) $good .= " AND fNumThreshold750/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5))/TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))/fEffectiveOn>3.7 ";
115 if ($g&0x2) $good .= " AND ((fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/((-2381.1+2766.3*LOG10(fThresholdMinSet)-1049.9*POW(LOG10(fThresholdMinSet),2)+131.05*POW(LOG10(fThresholdMinSet),3))/21.15)/(COS(fZenithDistanceMean*PI()/180)+0.179*POW(SIN(1.89*fZenithDistanceMean*PI()/180),5)))/(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)>16.2 ";
116 if ($g&0x4) $good .= " AND (fNumEvtsAfterQualCuts/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5))/((8598.9- 13181*log10(fThresholdMinSet)+7567.4*pow(log10(fThresholdMinSet),2)-1925.2*pow(log10(fThresholdMinSet),3)+183*pow(log10(fThresholdMinSet),4))/9.2 ))/(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)>6.7 ";
117 if ($g&0x8) $good .= " AND (fNumEvtsAfterBgCuts/(1.41*POW(fZenithDistanceMean*PI()/180,2)+0.975)/(-7.53e-12*POW(10, LOG10(fThresholdMinSet)*3.69)+1.035) )/(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)>0.6 ";
118}
119
120$sqlbegin = !empty($begin) ? "AND (DATE(fNight)>='".$begin."')" : "";
121$sqlend = !empty($end) ? "AND (DATE(fNight)<='".$end."')" : "";
122$sqlcut = !empty($cut) ? "AND (".$cut.") " : "";
123$sqlhaving = !empty($having)? "AND (".$having.") " : "";
124
125// --------------------------------------------------------------------
126
127$query2 = <<<EOT
128
129SELECT
130 COLUMN_NAME
131FROM
132 INFORMATION_SCHEMA.COLUMNS
133WHERE
134 TABLE_SCHEMA='$database' AND
135 TABLE_NAME in ('RunInfo','AnalysisResultsRun$table')
136GROUP BY
137 COLUMN_NAME
138ORDER BY
139 COLUMN_NAME
140
141EOT;
142
143$error2 = "";
144$columns = "";
145
146$result2 = $db->connect_error ? FALSE : $db->query($query2);
147if ($result2)
148{
149 while ($row = $result2->fetch_assoc())
150 $columns .= '"'.$row['COLUMN_NAME'].'",'."\n";
151 $result2->free();
152}
153else
154{
155 $error2 .= $db->error;
156}
157
158// --------------------------------------------------------------------
159
160$query1 = <<<EOT
161
162SELECT
163 fSourceKEY AS k,
164 fSourceName AS name,
165 fRightAscension AS ra
166FROM Source
167WHERE fSourceTypeKey=1
168ORDER BY k
169
170EOT;
171
172$error1 = "";
173
174$sources = array();
175$sourceoptions = "";
176
177$result1 = $db->connect_error ? FALSE : $db->query($query1);
178if ($result1)
179{
180 while ($row = $result1->fetch_assoc())
181 {
182 $sources[$row['k']] = $row;
183 $sourceoptions .= "<option value='".$row['k']."'>".$row['name']."</option>\n";
184 }
185 $result1->free();
186}
187else
188{
189 $error1 .= $db->error;
190}
191
192$sourcename = $source==0 ? "All" : $sources[$source]['name'];
193$ra = $source==0 ? 0 : $sources[$source]['ra'];
194$sqlsource = $source==0 ? "" : "AND fSourceKey=".$source;
195
196// --------------------------------------------------------------------
197
198$unitx = "";
199
200switch ($group)
201{
202case 1:
203 $selectx="fPeriod";
204 $titlex="Period";
205 $axistype="number";
206 $mintime=60;
207 break;
208case 2:
209 //$selectx="FROM_UNIXTIME(UNIX_TIMESTAMP(fRunStart)+(UNIX_TIMESTAMP(fRunStop)-UNIX_TIMESTAMP(fRunStart))/2)";
210 $selectx="STR_TO_DATE(fNight, '%Y%m%d')";
211 $titlex="Night";
212 $axistype="date";
213 $mintime=20;
214 break;
215case 3:
216 $selectx="YEAR(fNight)";//"SUBSTR(fNight,1,4)";
217 $titlex="Year";
218 $axistype="date";
219 $mintime=60;
220 break;
221case 4:
222 $selectx="ADDDATE(DATE(CONCAT(YEAR(ADDDATE(DATE(fNight), INTERVAL - (".$ra."/24.*365+80) DAY)), '-01-01')), INTERVAL + (".$ra."/24.*365+80+365/2) DAY)"; // FIXME shift back to get the center!
223 //$selectx="ADDDATE(DATE(YEAR(ADDDATE(DATE(fNight), INTERVAL - (".$ra."/24.*365+80) DAY))), INTERVAL + (".$ra."/24.*365+80) DAY)";
224 $titlex="Season";
225 $axistype="date";
226 $mintime=60;
227 break;
228case 5:
229 $selectx="FROM_UNIXTIME((UNIX_TIMESTAMP(fRunStop)+UNIX_TIMESTAMP(fRunStart))/2)";
230 $titlex="Time";
231 $axistype="date";
232 $mintime=0.5;
233 break;
234case 6:
235 $bin = isset($width) ? $width : 5;
236 $selectx="FLOOR(fZenithDistanceMean/".$bin.")*".$bin."+".$bin."/2";
237 $titlex="Zd [deg]";
238 $axistype="number";
239 $mintime=0.5;
240 break;
241case 7:
242 $bin = isset($width) ? $width : 50;
243 $selectx="FLOOR(fThresholdMinSet/".$bin.")*".$bin."+".$bin."/2";
244 $titlex="Threshold";
245 $axistype="number";
246 $mintime=0.5;
247 break;
248case 8:
249 $bin = isset($width) ? $width : 5;
250 $selectx="FLOOR(fCurrentsMedMean/".$bin.")*".$bin."+".$bin."/2";
251 $titlex="Current [\u00B5A/pix]"; // \u00B5 = &micro;
252 $axistype="number";
253 $mintime=0.5;
254 break;
255case 9:
256 $selectx="MONTH(fNight)";//"SUBSTR(fNight,1,4)";
257 $titlex="Month";
258 $axistype="date";
259 $mintime=60;
260 break;
261case 42:
262 $bin = isset($width) ? $width : 1;
263 $selectx="FLOOR(((".$sql_x.")-".$offset.")/".$bin.")*".$bin."+".$bin."/2+".$offset;
264 $titlex=addslashes($sql_x)." / ".$bin;
265 $axistype="number";
266 $mintime=0.5;
267 break;
268
269default:
270 $selectx="fPeriod";
271 $titlex="Period";
272 $axistype="number";
273 $mintime=60;
274 break;
275}
276
277if ($ontime>=0)
278 $mintime = $ontime;
279
280// --------------------------------------------------------------------
281
282$isnull = "";
283$unity = "[Hz]";
284$selecterr="1";
285
286$vminval = 0;
287$errors = 0;
288$histogram = 0;
289
290switch ($rate)
291{
292case 1:
293 $selecty="AVG(fTriggerRateMedian)";
294 $isnull="AND NOT ISNULL(fTriggerRateMedian)";
295 $titley="Average TriggerRate";
296 break;
297case 21:
298 $selecty="SUM(fNumPhysicsTrigger)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
299 $isnull="AND NOT ISNULL(fNumPhysicsTrigger)";
300 $titley="PhysicsTriggerRate";
301 break;
302case 22:
303 //$selecty="(SUM(fNumPhysicsTrigger)-SUM(fNum27Sec))/SUM(fOnTime)";
304 $selecty="SUM(fNumPhysicsTrigger*1.0-fNum27Sec*1.0)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
305 $isnull="AND NOT ISNULL(fNumPhysicsTrigger) AND NOT ISNULL(fNum27Sec)";
306 $titley="PhysicsTrigger-27Sec";
307 break;
308case 2:
309 $selecty="SUM(fNumEvtsAfterCleaning)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
310 $isnull="AND NOT ISNULL(fNumEvtsAfterCleaning)";
311 $titley="Rate after Cleaning";
312 break;
313case 23:
314 $selecty="SUM(fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
315 $isnull="AND NOT ISNULL(fNumEvtsAfterCleaning) AND NOT ISNULL(fNum27Sec)";
316 $titley="Rate after Cleaning-27Sec";
317 break;
318case 20:
319 //$selecty="SUM((fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/(1-(22.3-6)/22.5/0.4*(LOG10(fThresholdMinSet)-2.5))/(cos(fZenithDistanceMean*PI()/180)+0.18*pow(sin(2*fZenithDistanceMean*PI()/180),3)))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
320 $selecty="SUM((fNumEvtsAfterCleaning*1.0-fNum27Sec*1.0)/((-2381.1+2766.3*LOG10(fThresholdMinSet)-1049.9*POW(LOG10(fThresholdMinSet),2)+131.05*POW(LOG10(fThresholdMinSet),3))/21.15)/(COS(fZenithDistanceMean*PI()/180)+0.179*POW(SIN(1.89*fZenithDistanceMean*PI()/180),5)))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
321 $isnull="AND NOT ISNULL(fNumEvtsAfterCleaning) AND LOG10(fThresholdMinSet)<2.8 AND NOT ISNULL(fZenithDistanceMean) AND fThresholdMinSet>0 ";
322 $titley="Rate after cleaning (Zd/TH/27s corrected)";
323 break;
324case 3:
325 $selecty="SUM(fNumEvtsAfterQualCuts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
326 $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts)";
327 $titley="Rate after Quality Cuts";
328 break;
329case 4:
330 $selecty="SUM(fNumEvtsAfterBgCuts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
331 $isnull="AND NOT ISNULL(fNumEvtsAfterBgCuts)";
332 $titley="Rate after Background Cuts";
333 break;
334case 24:
335 $selecty="SUM(fNumEvtsAfterBgCuts/(1.41*POW(fZenithDistanceMean*PI()/180,2)+0.975)/(-7.53e-12*POW(10, LOG10(fThresholdMinSet)*3.69)+1.035) )/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
336 $isnull="AND NOT ISNULL(fNumEvtsAfterBgCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)";
337 $titley="BgRate (corrected)";
338 break;
339case 28:
340 $selecty="SUM(fNumExcEvts/((1.41*POW(fZenithDistanceMean*PI()/180,2)+0.975)/(-7.53e-12*POW(10, LOG10(fThresholdMinSet)*3.69)+1.035) ))/SUM(fNumExcEvts)";
341 $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)";
342 $titley="Ratio Corrected(fNumEvtsAfterBgCuts) Exc / Exc";
343 break;
344case 25:
345 $selecty="SUM(fNumEvtsAfterQualCuts/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5))/((8598.9- 13181*log10(fThresholdMinSet)+7567.4*pow(log10(fThresholdMinSet),2)-1925.2*pow(log10(fThresholdMinSet),3)+183*pow(log10(fThresholdMinSet),4))/9.2 ))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
346 $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)";
347 $titley="QualCutRate (corrected)";
348 break;
349case 29:
350 $selecty="SUM(fNumExcEvts/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5))/((8598.9- 13181*log10(fThresholdMinSet)+7567.4*pow(log10(fThresholdMinSet),2)-1925.2*pow(log10(fThresholdMinSet),3)+183*pow(log10(fThresholdMinSet),4))/9.2 ))/SUM(fNumExcEvts)";
351 $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)";
352 $titley="Ratio Corrected(fNumEvtsAfterQualCuts) Exc / Exc";
353 break;
354case 30:
355 $selecty="SUM(fNumExcEvts/(pow(cos(fZenithDistanceMean*PI()/180),3)+14.8/21.9*pow(sin(2*fZenithDistanceMean*PI()/180),5))/(1-0.00124/1.21*(fThresholdMinSet-500)*(fThresholdMinSet>=500)))/SUM(fNumExcEvts)";
356 $isnull="AND NOT ISNULL(fNumEvtsAfterQualCuts) AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fThresholdMinSet)";
357 $titley="Ratio Corrected(fNumExcEvts) Exc / Exc";
358 break;
359case 17:
360 $selecty="SUM(fNumSigEvts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
361 $isnull="AND NOT ISNULL(fNumSigEvts)";
362 $titley="Signal events";
363 break;
364case 5:
365 $selecty="SUM(fNumBgEvts)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
366 $isnull="AND NOT ISNULL(fNumBgEvts)";
367 $titley="Background events";
368 break;
369case 6:
370 $selecty="SUM(fNumExcEvts)*3600/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
371 $selecterr="EXCERR(SUM(fNumSigEvts), SUM(fNumBgEvts))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)*3600";
372 $isnull="AND NOT ISNULL(fNumExcEvts)";
373 $titley="Excess events";
374 $unity="[1/h]";
375 $errors = $noerr ? 0 : 1;
376 break;
377case 7:
378 $selecty="SUM(fNum27Sec)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
379 $isnull="AND NOT ISNULL(fNum27Sec)";
380 $titley="27sec Rate";
381 break;
382case 8:
383 $selecty="SUM(fNumThreshold500)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
384 $isnull="AND NOT ISNULL(fNumThreshold500)";
385 $titley="Threshold 500 Rate";
386 break;
387case 9:
388 $selecty="SUM(fNumThreshold750)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
389 $isnull="AND NOT ISNULL(fNumThreshold750)";
390 $titley="Threshold 750 Rate";
391 break;
392case 10:
393 $selecty="SUM(fNumThreshold1000)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
394 $isnull="AND NOT ISNULL(fNumThreshold1000)";
395 $titley="Threshold 1000 Rate";
396 break;
397case 11:
398 $selecty="SUM(fNumThreshold1250)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
399 $isnull="AND NOT ISNULL(fNumThreshold1250)";
400 $titley="Threshold 1250 Rate";
401 break;
402case 12:
403 $selecty="SUM(fNumThreshold2500)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
404 $isnull="AND NOT ISNULL(fNumThreshold2500)";
405 $titley="Threshold 2500 Rate";
406 break;
407case 13:
408 $selecty="SUM(fNumThreshold5000)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
409 $isnull="AND NOT ISNULL(fNumThreshold5000)";
410 $titley="Threshold 5000 Rate";
411 break;
412case 14:
413 $selecty="SUM(fNumThreshold10000)/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
414 $isnull="AND NOT ISNULL(fNumThreshold10000)";
415 $titley="Threshold 10000 Rate";
416 break;
417case 15:
418 $selecty="AVG(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn-fOnTime)";
419 $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00'";
420 $titley="Ontime difference";
421 $sqlhaving.="AND y>0";
422 $unity="[s]";
423 break;
424case 26:
425 $selecty="AVG(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn-fOnTimeAfterCuts)";
426 $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fOnTimeAfterCuts) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00'";
427 $titley="Calculated ontime minus ontime after cuts";
428 $unity="[s]";
429 break;
430case 27:
431 $selecty="AVG(fOnTime-fOnTimeAfterCuts)";
432 $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fOnTimeAfterCuts) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00'";
433 $titley="Average difference between ontime and ontime after cuts";
434 $unity="[s]";
435 break;
436case 18:
437 $selecty="AVG(fEffectiveOn)";
438 $isnull="AND NOT ISNULL(fEffectiveOn)";
439 $titley="Average (On time / elapsed time)";
440 $unity="";
441 $vminval=0.8;
442 break;
443case 19:
444 $selecty="SUM(fOnTime)/SUM(fOnTime/fEffectiveOn)";
445 $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fEffectiveOn)";
446 $titley="SUM(On time) / SUM(Elapsed time)";
447 $unity="";
448 $vminval=0.8;
449 break;
450case 16:
451 $selecty="SUM(fNumThreshold750/(cos(fZenithDistanceMean*PI()/180)+0.179*pow(sin(1.89*fZenithDistanceMean*PI()/180),5)))/SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))*fEffectiveOn)";
452 $isnull="AND NOT ISNULL(fOnTime) AND NOT ISNULL(fRunStop) AND NOT ISNULL(fRunStart) AND NOT fRunStop='0000-00-00 00:00:00' AND NOT fRunStart='0000-00-00 00:00:00' AND NOT ISNULL(fZenithDistanceMean) AND NOT ISNULL(fNumThreshold750)";
453 $titley="Threshold 750 Rate (Zd corrected)";
454 break;
455case 42:
456 $selecty="AVG(".$sql_y.")";
457 $isnull="AND NOT ISNULL(".$sql_y.")";
458 $titley="Average ".$sql_y;
459 $unity="";
460 //$vmin ="";
461 $histogram = 1;//$nohist ? 0 : 1;
462 break;
463case 43:
464 $selecty="SUM(".$sql_y.")";
465 $isnull="AND NOT ISNULL(".$sql_y.")";
466 $titley="Sum of ".$sql_y;
467 $unity="";
468 //$vmin ="";
469 $histogram = 1;//$nohist ? 0 : 1;
470 break;
471case 44:
472 $selecty=$sql_y;
473 $titley=$sql_y;
474 $unity="";
475 //$vmin ="";
476 $histogram = 1;//$nohist ? 0 : 1;
477 break;
478case 45:
479 $selecty="COUNT(".(empty($sql_y)?"*":$sql_y).")";
480 $titley="Counts";
481 $unity="";
482 //$vmin ="";
483 $histogram = 1;//$nohist ? 0 : 1;
484 break;
485case 46:
486 $selecty="LOG10(COUNT(".(empty($sql_y)?"*":$sql_y)."))";
487 $titley="log10(Counts)";
488 $unity="";
489 //$vmin ="";
490 $histogram = 1;//$nohist ? 0 : 1;
491 break;
492default:
493 $selecty="AVG(fTriggerRateMedian)";
494 $isnull="AND NOT ISNULL(fNumExcEvts) AND NOT ISNULL(fNumBgEvts) AND NOT ISNULL(fNumSigEvts)";
495 $titley="TriggerRate";
496 break;
497}
498
499// --------------------------------------------------------------------
500/*
501SELECT
502 o.night,
503 MIN(o.start),
504 MAX(o.stop),
505 SUM(o.sigevts),
506 SUM(o.bgevts),
507 ROUND(SUM(o.ot)/60.,1)
508FROM
509(
510 SELECT
511 fNight,
512 fRunID,
513 fOnTimeAfterCuts AS ot,
514 fRunStart AS start,
515 fRunStop AS stop,
516 fNumSigEvts AS sigevts,
517 fNumBgEvts AS bgevts,
518 if (
519 @night=fNight AND FLOOR((@os+fOnTimeAfterCuts)/20./60.)<1,
520 @bl,
521 @bl := @bl + 1
522 ) as block,
523 if (
524 @night=fNight AND FLOOR((@os+fOnTimeAfterCuts)/20./60.)<1,
525 @os := @os + fOnTimeAfterCuts,
526 @os := fOnTimeAfterCuts
527 ) as os,
528 @os/20./60. AS a,
529 FLOOR(@os/20./60.) AS b,
530 @night := fNight AS night
531 FROM RunInfo
532 LEFT JOIN AnalysisResultsRunLP USING(fNight,fRunID)
533 CROSS JOIN
534 (
535 SELECT
536 @night := 0,
537 @os := 0,
538 @bl := 0
539 ) PARAMS
540 WHERE
541 fNight BETWEEN 20130414 AND 20130415
542 AND fRunTypeKey=1
543 AND fSourceKey=1
544) o
545
546GROUP BY block
547*/
548
549// --------------------------------------------------------------------
550
551$query0 = <<<EOT
552
553SELECT
554 ($selectx) AS x,
555 ($selecty) AS y,
556 (SUM(fOnTimeAfterCuts)/60) AS ontime,
557 ($selecterr) AS e,
558 (LIMA(SUM(fNumSigEvts), SUM(fNumBgEvts))) AS s,
559 (MIN(fRunStart)) as start,
560 (MAX(fRunStop)) as stop,
561 (MIN(fZenithDistanceMin)) as zdmin,
562 (MAX(fZenithDistanceMax)) as zdmax,
563 (MIN(fAzimuthMin)) as azmin,
564 (MAX(fAzimuthMax)) as azmax,
565 (MIN(fThresholdMinSet)) as thmin,
566 (MAX(fThresholdMInSet)) as thmax
567FROM RunInfo
568LEFT JOIN AnalysisResultsRun$table USING(fNight,fRunID)
569WHERE
570 fRunTypeKey=1 $sqlsource
571 $sqlbegin $sqlend
572 $isnull
573 $good
574 $sqlcut
575GROUP BY x
576HAVING
577 (ontime>$mintime)
578 $sqlhaving
579
580EOT;
581/*
582# SUM(fNumExcEvts)/SUM(fOnTimeAfterCuts)*3600 AS y,
583 AND NOT ISNULL(fNumSigEvts)
584 AND NOT ISNULL(fNumExcEvts)
585 AND NOT ISNULL(fNumBgEvts)
586*/
587
588$var0 = "";
589$error0 = "";
590$data = "<table id='list'>\n <tr><th>X</th><th>Y</th><th>E</th><th>OnTime</th><th>Start</th><th>Stop</th><th>Zdmin</th><th>Zdmax</th><th>Azmin</th><th>Azmax</th><th>THmin</th><th>THmax</th></tr>\n";
591
592$timeStart = microtime(true);
593$result0 = $db->connect_error ? FALSE : $db->query($query0);
594$timeMeasured = number_format((microtime(true)-$timeStart)*1000, 2, ".", "");
595if ($result0)
596{
597 while ($row = $result0->fetch_assoc())
598 {
599 $data .= " <tr><td>".$row['x']."</td><td>".$row['y']."</td><td>".$row['e']."</td><td>".$row['ontime']."</td><td>".$row['start']."</td><td>".$row['stop']."</td><td>".$row['zdmin']."</td><td>".$row['zdmax']."</td><td>".$row['azmin']."</td><td>".$row['azmax']."</td><td>".$row['thmin']."</td><td>".$row['thmax']."</td></tr>\n";
600
601 switch ($group)
602 {
603 case 3: // Year
604 $x = "new Date('".$row['x']."-07-01')";
605 $xtext = $titlex." ".$row['x'];
606 break;
607 case 9: // Month
608 $x = "new Date('2000-".$row['x']."-15')";
609 $xtext = $titlex." ".$row['x'];
610 break;
611 case 2: // Night
612 case 4: // Season
613 case 5: // Run
614 $x = "new Date('".$row['x']."')";
615 $xtext = $titlex." ".$row['x'];
616 break;
617 default:
618 $x = $row['x'];
619 $xtext = $titlex." ".$row['x']." ".$unitx;
620 }
621
622 $y = $row['y'];
623 $ymin = $row['y']-$row['e'];
624 $ymax = $row['y']+$row['e'];
625 $s = round($row['s'], 2);
626 $sr = round($row['s']/sqrt($row['ontime']/60), 1);
627 $t = round($row['ontime'], 2);
628 $time = $t>60 ? round($row['ontime']/60,2).' h' : round($row['ontime'],1).' min';
629 $start= $row['start'];
630 $stop = $row['stop'];
631 $zdmin= $row['zdmin'];
632 $zdmax= $row['zdmax'];
633 $azmin= $row['azmin'];
634 $azmax= $row['azmax'];
635 $thmin= $row['thmin'];
636 $thmax= $row['thmax'];
637
638 // <entry>
639 $var0 .= "[";
640 $var0 .= $x.",";
641 $var0 .= $y.",";
642
643 if ($histogram==1 && !$nohist)
644 $var0 .= $y.",0,0,";
645
646 if ($errors==1)
647 {
648 $var0 .= $y.",";
649 $var0 .= $ymin.",";
650 $var0 .= $ymax.",";
651 }
652
653 // <tooltip>
654 $var0 .= "'<p>".addslashes($xtext);
655
656 if ($errors==1)
657 {
658 $var0 .= "<p>".round($y,1)." &plusmn ".round($row['e'],1);
659 $var0 .= "<p>".$s." &sigma;";
660 $var0 .= "<p>".$sr." &sigma;/&radic;h";
661 }
662 else
663 $var0 .= "<p>".round($y,3);
664
665 $var0 .= "<p>".$time;
666 $var0 .= "<p>".$start." &ndash; ".$stop;
667 $var0 .= "<p>Zd=[".$zdmin.";".$zdmax."] Az=[".$azmin.";".$azmax."]";
668 $var0 .= "<p>TH=[".$thmin.";".$thmax."]";
669 $var0 .= "'";
670 // </tooltip>
671
672 $var0 .= "],\n";
673 // </entry>
674 }
675
676 $result0->free();
677}
678else
679{
680 $error0 .= $db->error;
681}
682
683// --------------------------------------------------------------------
684
685if (!isset($_GET['list']) && !isset($_GET['list-only']))
686 $data="";
687else
688 $data.="</table>\n<hr>\n";
689
690$querycol0 = colorize($query0);
691$querycol1 = colorize($query1);
692$errorcol_con = !empty($error_con) ? colorize($error_con) : "";
693$errorcol2 = !empty($error2) ? colorize($error2) ."\n\n".$querycol2 : "";
694$errorcol1 = !empty($error1) ? colorize($error1) ."\n\n".$querycol1 : "";
695$errorcol0 = !empty($error0) ? colorize($error0) ."\n\n".$querycol0 : "";
696$has_error = empty($error_con) && empty($error0) && empty($error1) && empty($error2) ? 0 : 1;
697
698$intervalStyle = $histogram==1 && !$nohist ? 'boxes' : 'bars';
699$pointSize = $histogram==1 && !$nohist ? 'pointSize:0,' : '';
700$boxWidth = $histogram==1 && !$nohist ? 1.6 : 0;
701
702// boxWidth: Could be used as x error bar for equidistant points
703
704
705$uri = $_SERVER['REQUEST_URI'];
706$pos = strpos($uri, '?');
707$arg = $pos===FALSE ? "" : substr($uri, $pos+1);
708$uri = $pos===FALSE ? $uri : substr($uri, 0, $pos);
709$min = isset($_GET["min"]) ? intval($_GET["min"]) : "";
710$max = isset($_GET["max"]) ? intval($_GET["max"]) : "";
711$listonly = isset($_GET["list-only"]) ? 1 : 0;
712
713$hiddenBeg = isset($_GET['bx']) ? $_GET['bx'] : "";
714$hiddenEnd = isset($_GET['ex']) ? $_GET['ex'] : "";
715
716$hiddenInput ="";
717if (isset($_GET["t"]))
718 $hiddenInput .= "<input type='hidden' name='t' value='".$_GET["t"]."'>\n";
719if (isset($_GET["db"]))
720 $hiddenInput .= "<input type='hidden' name='db' value='".$_GET["db"]."'>\n";
721if (isset($_GET["good"]))
722 $hiddenInput .= "<input type='hidden' name='good' value='".$_GET["good"]."'>\n";
723
724
725// --------------------------------------------------------------------
726/*
727$curl = curl_init();
728curl_setopt($curl, CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$uri);
729curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
730curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
731$tinyurl = curl_exec($curl);
732curl_close($curl);
733*/
734
735// --------------------------------------------------------------------
736
737/*
738[9:51:32 PM] Lamouette: mysql> explain ShortURL;
739+----------+------------------+------+-----+-------------------+-----------------------------+
740| Field | Type | Null | Key | Default | Extra |
741+----------+------------------+------+-----+-------------------+-----------------------------+
742| Key | int(10) unsigned | NO | PRI | NULL | auto_increment |
743| URL | varchar(1024) | NO | | NULL | |
744| UserName | varchar(50) | NO | | NULL | |
745| LastUpd | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
746+----------+------------------+------+-----+-------------------+-----------------------------+
7474 rows in set (0.00 sec)
748*/
749
750/*
751*/
752
753
754$tinyurl = "";
755if ($has_error==0 && strlen($arg)>16 && empty($print) && !$db->connect_error)
756{
757 $query2 = "INSERT INTO ShortURL.ShortURL (URL) VALUES ('".$arg."') ON DUPLICATE KEY UPDATE `Key`=LAST_INSERT_ID(`Key`) ";
758 if ($result2 = $db->query($query2))
759 {
760 $tiny = $_SERVER['HTTP_HOST'].$uri."?short=".base62_encode($db->insert_id);
761 $tinyurl = "<tt style='padding:2px;background:#eef;'>Short URL: <A HREF=//".$tiny.">".$tiny."</A></tt>";
762 }
763}
764
765// --------------------------------------------------------------------
766
767echo <<<EOT
768
769<!DOCTYPE HTML>
770<html lang="en">
771<head>
772<meta charset="utf-8">
773<title>Database Explorer</title>
774<script src="https://code.jquery.com/jquery-2.2.1.min.js" integrity="sha256-gvQgAFzTH6trSrAWoH1iPo9Xc96QxSZ3feW6kem+O00=" crossorigin="anonymous"></script>
775<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=" crossorigin="anonymous"></script>
776
777<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
778
779<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
780<script type="text/javascript">
781 if ($listonly==0)
782 {
783 google.charts.load('current', {packages: ['corechart']});
784 google.charts.setOnLoadCallback(drawAxisTickColors);
785 }
786
787 $(function() {
788
789 $(document).tooltip();
790
791 var availableTags = [
792 "ABS(",
793 "ACOS(",
794 "ADDDATE(",
795 "ADDTIME(",
796 "AND ",
797 "ASIN(",
798 "ATAN(",
799 "ATAN2(",
800 "AVG(",
801 "CEIL(",
802 "CONCAT(",
803 "COS(",
804 "COUNT(",
805 "DATE(",
806 "DAY(",
807 "DEGREES(",
808 "EXCERR(",
809 "EXP(",
810 "FLOOR(",
811 "FROM_UNIXTIME(",
812 "INTERVAL ",
813 "ISNULL(",
814 "LIMA(",
815 "LN(",
816 "LOG(",
817 "LOG10(",
818 "LOG2(",
819 "MAX(",
820 "MIN(",
821 "MINUTE(",
822 "MONTH(",
823 "OR ",
824 "PI()",
825 "POW(",
826 "RADIANS(",
827 "RAND(",
828 "ROUND(",
829 "SIGN(",
830 "SIN(",
831 "SUM(",
832 "SQRT(",
833 "TAN(",
834 "TIME_TO_SEC(",
835 "TIMEDIFF(",
836 "TRUNCATE(",
837 "UNIX_TIMESTAMP(",
838 "YEAR(",
839$columns
840];
841
842 function acSource( request, response )
843 {
844 //var pos = $($(this)).get(0).selectionStart;
845 var pos = this.element[0].selectionStart;
846 var t = request.term.substr(0, pos);
847 var l = t.match(/\w*$/);
848 response( $.ui.autocomplete.filter(availableTags, String(l)));
849 }
850 function acSelect ( event, ui )
851 {
852 // $(this)[0] === this
853 // "this" was $($(this)).get(0)
854 var pos = this.selectionStart;
855 var idx = this.value.substr(0, pos).match(/\w*$/).index;
856 this.value = this.value.substr(0, idx)+ui.item.value+this.value.substr(pos);
857 this.selectionStart = idx+ui.item.value.length;
858 this.selectionEnd = idx+ui.item.value.length;
859 return false;
860 }
861 function acFocus(event, ui) { event.preventDefault(); return false; }
862
863
864 $( "#input_x" ).autocomplete( {source: acSource, minLength:1, select: acSelect, focus: acFocus });
865 $( "#input_y" ).autocomplete( {source: acSource, minLength:1, select: acSelect, focus: acFocus });
866 $( "#input_err").autocomplete({source: acSource, minLength:1, select: acSelect, focus: acFocus });
867 $( "#sql_cut" ).autocomplete( {source: acSource, minLength:1, select: acSelect, focus: acFocus });
868 $( "#having" ).autocomplete( {source: acSource, minLength:1, select: acSelect, focus: acFocus });
869
870 $( "#button_submit" ).button();
871 $( "#button_submit" ).button({
872 icons: {
873 primary: "ui-icon-image"
874 },
875 text: true
876 });
877
878 $("#input_x").prop('disabled', $group!=42);
879
880 $( "#select_x" ).selectmenu({
881 change: function( event, data ) {
882 console.log(JSON.stringify(data));
883 $("#input_x").prop('disabled', data.item.value!=42);
884 $("#width").spinner(data.item.value!=42 && data.item.value!=7 && data.item.value!=8 ? "disable" : "enable");
885 $("#offset").spinner(data.item.value!=42 && data.item.value!=7 && data.item.value!=8 ? "disable" : "enable");
886 $("#nohist").prop('disabled', data.item.value<42);
887 }
888 });
889
890 $( "#select_y" ).selectmenu({
891 change: function( event, data ) {
892 console.log(JSON.stringify(data));
893 $("#input_y").prop('disabled', data.item.value<42);
894 $("#input_err").prop('disabled', data.item.value<42);
895 //$("#noerr").prop('disabled', data.item.value<42);
896 }
897 });
898
899 $( "#source" ).selectmenu();
900
901 $("#input_y").prop('disabled', $rate<42);
902 $("#input_err").prop('disabled', $rate<42);
903
904 $('#select_x').val($group).selectmenu("refresh");
905 $('#select_y').val($rate).selectmenu("refresh");
906 $('#source').val($source).selectmenu("refresh");
907 $('#sql_cut').val("$cut");
908 $('#input_x').val("$sql_x");
909 $('#input_y').val("$sql_y");
910 $('#input_err').val("$sql_err");
911 $('#having').val("$having");
912
913 $( "#date_beg" ).datepicker();
914 $( "#date_end" ).datepicker();
915
916 var date_opt =
917 {
918 dateFormat: 'yy-mm-dd',
919 minDate: '2011-10-10',
920 maxDate: '+1',
921 showButtonPanel: true,
922 showOtherMonths: true,
923 selectOtherMonths: true,
924 changeYear: true,
925 autoSize: true,
926 /*inline: true,*/
927 }
928
929 $( "#width" ).val($width);
930 $( "#offset" ).val($offset);
931 $('#min').val($min);
932 $('#max').val($max);
933 $('#ontime').val($mintime);
934
935 $( "#width" ).spinner();
936 $( "#offset" ).spinner();
937 $( '#min' ).spinner();
938 $( '#max' ).spinner();
939 $( '#ontime' ).spinner();
940
941 $("#offset").spinner($group!=42 && $group!=6 && $group!=7 && $group!=8 ? "disable" : "enable");
942 $("#width").spinner( $group!=42 && $group!=6 && $group!=7 && $group!=8 ? "disable" : "enable");
943 $("#width").spinner('option', { min: 0} );
944
945 $('#min').spinner("$min"=="" ? "disable" : "enable");
946 $('#max').spinner("$max"=="" ? "disable" : "enable");
947 $('#ontime').spinner("$ontime"=="-1" ? "disable" : "enable");
948
949 $( "#enable_min" ).prop('checked', "$min"!="");
950 $( "#enable_max" ).prop('checked', "$max"!="");
951 $( "#enable_ontime" ).prop('checked', "$ontime"!="-1");
952
953 if ($has_error)
954 {
955 $( "#shorturl" ).hide();
956 $( "#chart_area" ).hide();
957 $( "#error" ).show();
958 }
959
960 $( "#date_beg" ).datepicker('option', 'disabled', "$begin"=="");
961 $( "#date_end" ).datepicker('option', 'disabled', "$end"=="");
962
963 $( "#date_beg" ).datepicker('option', date_opt);
964 $( "#date_end" ).datepicker('option', date_opt);
965
966 $( "#date_beg" ).datepicker("setDate", "$begin"=="" ? "2011-10-10" : "$begin");
967 $( "#date_end" ).datepicker("setDate", "$end"=="" ? "+1d" : "$end");
968
969 $( "#enable_beg" ).prop('checked', "$begin"!="");
970 $( "#enable_end" ).prop('checked', "$end"!="");
971
972 $( "#date_beg" ).datepicker('option', 'altField', '#hidden_beg');
973 $( "#date_end" ).datepicker('option', 'altField', '#hidden_end');
974
975 $( "#nohist" ).prop('checked', $nohist==1);
976 $( "#noerr" ).prop('checked', $noerr==1);
977
978 $( "#enable_beg" ).change(function(event,data) { $("#date_beg").datepicker('option', 'disabled', !$(this).prop('checked') ); } );
979 $( "#enable_end" ).change(function(event,data) { $("#date_end").datepicker('option', 'disabled', !$(this).prop('checked') ); } );
980 $( "#enable_min" ).change(function(event,data) { $("#min").spinner('option', 'disabled', !$(this).prop('checked') ); } );
981 $( "#enable_max" ).change(function(event,data) { $("#max").spinner('option', 'disabled', !$(this).prop('checked') ); } );
982 $( "#enable_ontime" ).change(function(event,data) { $("#ontime").spinner('option', 'disabled', !$(this).prop('checked') ); } );
983
984 $( "#nohist" ).prop('disabled', !$histogram);
985 //$( "#noerr" ).prop('disabled', $histogram);
986
987 if ($listonly==1)
988 $( "#chart_area" ).hide();
989 });
990
991/*
992alert(
993(new Date("2012-10-10"))+"\\n"+ // 2h +0200
994(new Date(2012,10-1,10))+"\\n"+ // 0h +0200
995(new Date("2012-10-10 03:00:00"))+"\\n"+ // 3h +0200
996(new Date("2012-10-10 03:00:00 UTC"))+"\\n"+ // 5h +0200
997(new Date("2012-10-10 03:00:00 +0000"))+"\\n"+ // 5h +0200
998(new Date(2012,10-1,10,3,0,0)) // 3h +0200
999);
1000*/
1001
1002 function drawAxisTickColors()
1003 {
1004 var data = new google.visualization.DataTable();
1005 try
1006 {
1007 data.addColumn('$axistype', 'x');
1008 data.addColumn('number', 'excessrate');
1009 if ($errors==1 || ($histogram==1 && $nohist==0))
1010 {
1011 data.addColumn({id:'val', type:'number', role:'interval'});
1012 data.addColumn({id:'min', type:'number', role:'interval'});
1013 data.addColumn({id:'max', type:'number', role:'interval'});
1014 }
1015 data.addColumn({id:'tooltip', type:'string', role:'tooltip', p:{html:true}});
1016 data.addRows([
1017$var0
1018]);
1019 }
1020 catch (e)
1021 {
1022 $( "#error" ).html(e);
1023 $( "#shorturl" ).hide();
1024 $( "#chart_area" ).hide();
1025 $( "#error" ).show();
1026 return;
1027 }
1028
1029 var options = {
1030 tooltip: {isHtml: true},
1031 lineWidth: 0,
1032 title: "$titley vs $titlex [$sourcename]",
1033 height: 400,
1034 width:'90%',
1035 hAxis: {
1036 title: '$titlex $unitx',
1037 gridlines: {
1038 //count: "-1",
1039 units: {
1040 months: { format: [ "MMM" ] },
1041 minutes: { format: [ "HH:mm" ] },
1042 hours: { format: [ "MM/dd HH:mm" ] }, // MM/dd HH:mm
1043 days: { format: [ "MM/dd" ] } // yyyy/MM/dd
1044 },
1045 },
1046 minorGridlines: {
1047 units: {
1048 hours: { format: [ "HH" ] },
1049 //days: { format: [ "dd" ] },
1050 }
1051 },
1052 },
1053 vAxis: {
1054 title: '$titley $unity',
1055 $vmin
1056 $vmax
1057 //chartArea: {left:60,top:40,bottom:40,width:'90%'},
1058 },
1059 legend: 'none',
1060 $pointSize
1061 intervals: {
1062 // Normal error bars
1063 style: '$intervalStyle',
1064 barWidth: 0.5,
1065 lineWidth: 1,
1066 boxWidth: $boxWidth,
1067 },
1068 interval: {
1069 val: {
1070 style: 'boxes',
1071 fillOpacity: 0.5,
1072 color: '#BBB'
1073 },
1074 },
1075 explorer: {
1076 keepInBound:true,
1077 actions:['dragToZoom','rightClickToReset'],
1078 maxZoomIn: 0.000001,
1079 },
1080 };
1081
1082 var chart0 = new google.visualization.ScatterChart(document.getElementById('chart_div'));
1083 chart0.draw(data, options);
1084 document.getElementById('print_chart').innerHTML = '<a href="' + chart0.getImageURI() + '">Print</a>';
1085
1086 console.log("Google.chart.ready");
1087 }
1088</script>
1089<style>
1090 $hidden
1091
1092/* Configration of jQuery UI */
1093span.ui-selectmenu-text { padding: 0 5px 0 5px !important; }
1094.hasDatepicker { padding: 0 5px 0 5px !important; }
1095.ui-widget { font-size:16px;}
1096span.ui-button-text { padding-top: 3px !important; padding-bottom: 3px !important; }
1097// span.ui-button-text { text-color: black !important; }
1098
1099/* Configuration for debug table */
1100table { color: #333; font-family: Helvetica, Arial, sans-serif; width: 640px; border-collapse: collapse; border-spacing: 0; }
1101td, th { border: 2px solid white; transition: all 0.3s; white-space: nowrap; padding: 3px; }
1102#list th { background: #DFDFDF; font-weight: bold; }
1103#list td { background: #FAFAFA; text-align: center; }
1104#list tr:nth-child(even) td { background: #F1F1F1; }
1105#list tr:nth-child(odd) td { background: #FEFEFE; }
1106#list tr td:hover { background: #666; color: #FFF; }
1107
1108/* Configuration for tooltip */
1109div.google-visualization-tooltip { font-family: Sans; font-size: 12px; }
1110div.google-visualization-tooltip p { margin-top: 0px; margin: 0.5ex 1ex 0.5ex 1ex; }
1111div.google-visualization-tooltip p:nth-child(1) { color: blue; font-weight: bold; font-style: italic; }
1112div.google-visualization-tooltip p:nth-child(2) { font-weight: bold; }
1113div.google-visualization-tooltip p:last-child { font-style: italic; }
1114
1115</style>
1116</head>
1117
1118<body>
1119
1120<div class="ui-widget">
1121<form action="#">
1122
1123 <fieldset>
1124 <label for="enbale_beg">From</label>
1125 <input type="checkbox" id="enable_beg" title="Enable a lower date limit">
1126 <input type="text" name="b" id="date_beg">
1127 <!--<input type="hidden" name="bx" id="hidden_beg">-->
1128
1129 <label for="enbale_end">To</label>
1130 <input type="checkbox" id="enable_end" title="Enable an upper date limit">
1131 <input type="text" name="e" id="date_end">
1132 <!--<input type="hidden" name="ex" id="hidden_end">-->
1133
1134 <label for="width" title="Width of the range in which data is grouped together">Bin width:</label>
1135 <input id="width" name="w" style="width:4em">
1136
1137 <label for="offset" title="Normally binning starts at 0. This allows an artificial shift of the bins.">Bin shift:</label>
1138 <input id="offset" name="o" style="width:5em">
1139
1140 <label for="nohist">Nohist:</label>
1141 <input type="checkbox" id="nohist" name ="no-hist" title="Disable display as histogram">
1142
1143 <label for="noerr">Noerr:</label>
1144 <input type="checkbox" id="noerr" name="no-errors" title="Disable error bars">
1145
1146 <p style="margin-top: 16px">
1147
1148 <label for="select_x">Select x</label>
1149 <select name="g" id="select_x">
1150 <optgroup label="User defined">
1151 <option value="42">User defined</option>
1152 </optgroup>
1153 <optgroup label="By time">
1154 <option value="5">Run</option>
1155 <option value="2">Night</option>
1156 <option value="1">Period</option>
1157 <option value="4">Season</option>
1158 <option value="9">Month</option>
1159 <option value="3">Year</option>
1160 </optgroup>
1161 <optgroup label="Pre defined">
1162 <option value="6">Zenith angle</option>
1163 <option value="7">Threshold</option>
1164 <option value="8">Current</option>
1165 </optgroup>
1166 </select>
1167
1168 <label for="select_y">Select y</label>
1169 <select name="r" id="select_y">
1170 <optgroup label="User defined">
1171 <option value="44">User defined</option>
1172 </optgroup>
1173 <optgroup label="Pre defined">
1174 <option value="45">Counts</option>
1175 <option value="46">log10(Counts)</option>
1176 <option value="43">Sum</option>
1177 <option value="42">Average</option>
1178 </optgroup>
1179 <optgroup label="Analysis event rates [Effective on time]">
1180 <option value="5">Background rate</option>
1181 <option value="17">Signal rate</option>
1182 <option value="6">Excess rate</option>
1183 </optgroup>
1184 <optgroup label="Raw event rates [Effective on time]">
1185 <option value="21">Physics trigger</option>
1186 <option value="22">Physics trigger minus 27s events</option>
1187 <option value="2">Events after cleaning</option>
1188 <option value="23">Events after cleaning minus 27s events</option>
1189 <option value="3">Events after quality cuts</option>
1190 <option value="4">Events after background cuts</option>
1191 <option value="6">Excess events</option>
1192 </optgroup>
1193
1194 <optgroup label="Corrected [Zd/TH] event rates [Eff. on time]">
1195 <option value="20">Events after cleaning minus 27s events</option>
1196 <option value="24">Events after background cuts</option>
1197 <option value="25">Events after quality cuts</option>
1198 <option value="16">Artifical trigger TH750</option>
1199 </optgroup>
1200
1201 <optgroup label="Artificial trigger rates [Effective on time]">
1202 <option value="7">27s events</option>
1203 <option value="8">TH500</option>
1204 <option value="9">TH750</option>
1205 <option value="10">TH1000</option>
1206 <option value="11">TH1250</option>
1207 <option value="12">TH2500</option>
1208 <option value="13">TH5000</option>
1209 <option value="14">TH10000</option>
1210 </optgroup>
1211
1212 <optgroup label="On time comparison">
1213 <option value="15">Avg difference Eff. on time minus Stop-Start time</option>
1214 <option value="26">Avg difference Eff. on time minus OnTimeAfterCuts</option>
1215 <option value="27">Avg Stop-Start time minus OnTimeAfterCuts</option>
1216 <option value="18">Avg FTM effective on time</option>
1217 <option value="19">Sum FTM on time divided by Sum FTM elapsed time</option>
1218 </optgroup>
1219
1220 <optgroup label="Others">
1221 <option value="28">Excess rate correction factor (fNumEvtsAfterBgCuts / PRELIMINARY)</option>
1222 <option value="29">Excess rate correction factor (fNumEvtsAfterQualCuts / PRELIMINARY)</option>
1223 <option value="30">Excess rate correction factor (fNumExcEvts / PRELIMINARY)</option>
1224 </optgroup>
1225 </select>
1226
1227 <label for="source">Source</label>
1228 <select name="s" id="source">
1229 <optgroup label="All data">
1230 <option value="0">All data</option>
1231 </optgroup>
1232 <optgroup label="Sources">
1233$sourceoptions
1234 </optgroup>
1235 </select>
1236
1237 <table style='width:100%'>
1238 <tr>
1239 <td align="right" width="1%">
1240 <label for="input_x">X: </label>
1241 </td>
1242 <td>
1243 <!--<input id="input_x" name="x" style="width:100%">-->
1244 <textarea id="input_x" name="x" style="width:100%" rows="1" maxlength="10000" wrap="soft"></textarea>
1245 </td>
1246 </tr>
1247 <tr>
1248 <td align="right" width="1%">
1249 <label for="input_y">Y: </label>
1250 </td>
1251 <td>
1252 <!--<input id="input_y" name="y" style="width:100%">-->
1253 <textarea id="input_y" name="y" style="width:100%" rows="1" maxlength="10000" wrap="soft"></textarea>
1254 </td>
1255 </tr>
1256<!-- <tr>
1257 <td align="right" width="1%">
1258 <label for="input_err">E: </label>
1259 </td>
1260 <td>
1261 <textarea id="input_err" name="err" style="width:100%" rows="1" maxlength="10000" wrap="soft"></textarea>
1262 </td>
1263 </tr>
1264--> <tr>
1265 <td align="right" width="1%">
1266 <label for="sql_cut">Cut: </label>
1267 </td>
1268 <td>
1269 <!--<input id="sql_cut" name="cut" style="width:100%">-->
1270 <textarea id="sql_cut" name="cut" style="width:100%" rows="1" maxlength="10000" wrap="soft"></textarea>
1271 </td>
1272 </tr>
1273 <tr>
1274 <td align="right" width="1%">
1275 <label for="having">Hav: </label>
1276 </td>
1277 <td>
1278 <textarea id="having" name="hav" style="width:100%" rows="1" maxlength="10000" wrap="soft"></textarea>
1279 </td>
1280 </tr>
1281 </table>
1282
1283 <br>
1284
1285 <button id="button_submit">Plot!</button>
1286 <!--<button id="button_tinyurl">Tiny URL</button>-->
1287
1288 <label for="min" title="Minimum y-axis value (only if outside of the data range)">Min:</label>
1289 <input type="checkbox" id="enable_min">
1290 <input id="min" name="min" style="width:4em">
1291
1292 <label for="max" title="Maximum y-axis value (only if outside of the data range)">Max:</label>
1293 <input type="checkbox" id="enable_max">
1294 <input id="max" name="max" style="width:4em">
1295
1296 <label for="ontime" title="To avoid outliers, this can be used to limit the ontime for which a bin is displayed [min]">On-time limit:</label>
1297 <input type="checkbox" id="enable_ontime">
1298 <input id="ontime" name="on" style="width:3em"> min
1299
1300 $hiddenInput
1301
1302 </fieldset>
1303</form>
1304</div>
1305
1306<hr>
1307
1308<div class="ui-state-error ui-corner-all" id="error" style="padding: 5px;display:none;">
1309 <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
1310 <strong>SQL Error:</strong>
1311 <pre>
1312$errorcol_con$errorcol1$errorcol0
1313 </pre>
1314 </p>
1315</div>
1316
1317<div id="chart_area" style='position:relative'>
1318<div id='chart_div' class="print" style="height:400px;width:99%;margin-left:0.5%;"></div>
1319<div id='print_chart' style='position:absolute;top:10px;right:40px;'></div>
1320</div>
1321
1322<div id="shorturl" align="right">
1323$tinyurl
1324</div>
1325
1326<hr>
1327
1328<input type="button" onclick="$('#spoiler0').toggle(300);" value="Legend"/>
1329<div id="spoiler0" style="display:none">
1330<dl>
1331 <dt>&r = 1</dt><dd>trigger rate</dd>
1332 <dt>&r = 2</dt><dd>rate after cleaning</dd>
1333 <dt>&r = 3</dt><dd>rate after quality cuts</dd>
1334 <dt>&r = 4</dt><dd>rate after background cuts</dd>
1335 <dt>&r = 5</dt><dd>background rate (fOnTimeAfterCuts)</dd>
1336 <dt>&r = 6</dt><dd>excess rate</dd>
1337 <dt>&r = 7</dt><dd>27 second events</dd>
1338 <dt>&r = 8</dt><dd>threshold 500</dd>
1339 <dt>&r = 9</dt><dd>threshold 750</dd>
1340 <dt>&r = 10</dt><dd>threshold 1000</dd>
1341 <dt>&r = 11</dt><dd>threshold 1250</dd>
1342 <dt>&r = 12</dt><dd>threshod 2500</dd>
1343 <dt>&r = 13</dt><dd>threshold 5000</dd>
1344 <dt>&r = 14</dt><dd>threshold 10000</dd>
1345 <dt>&r = 15</dt><dd>Average of calculated EffOnTime and FTM OnTime</dd>
1346 <dt>&r = 16</dt><dd>Zenith angle corrected R750</dd>
1347 <dt>&r = 17</dt><dd>Event rate after background cuts (Total caclulated ontime)</dd>
1348 <dt>&r = 18</dt><dd>Average of FTM effective on time</dd>
1349 <dt>&r = 19</dt><dd>Sum of FTM OnTime divided by sum of FTM Elapsed time</dd>
1350 <dt>&r = 20</dt><dd>Rate after cleaning corrected for 27sec events run-wise corrected for zenith angle and threshold</dd>
1351 <dt>&r = 21</dt><dd>Physics trigger rate</dd>
1352 <dt>&r = 22</dt><dd>Physics trigger rate corrected for 27sec events</dd>
1353 <dt>&r = 23</dt><dd>Rate after cleaning corrected for 27sec events</dd>
1354 <dt>&r = 24</dt><dd>Rate after background cuts runwise corrected for zenith angle and threshold</dd>
1355 <dt>&r = 25</dz><dd>Rate after quallity cuts runwise corrected for zenith angle and threshold</dd>
1356 <dt>&r = 42</dz><dd>Plot average of &y=... (profile histogram with &y as weights)</dd>
1357 <dt>&r = 43</dz><dd>Plot sum of &y=... (histogram with &y as weights)</dd>
1358 <dt>&r = 44</dz><dd>Plot user defined variable &y=...</dd>
1359 <dt>&r = 45</dz><dd>Plot a histogram (counts) [&y=... can be used to specify what is counted != NULL, if omitted COUNT(*)]</dd>
1360 <dt>&r = 46</dz><dd>Plot a histogram (log10(counts)) [&y=... can be used to specify what is counted != NULL, if omitted COUNT(*)]</dd>
1361 <P>
1362 <dt>&g = 1</dt><dd>Binning in moon periods</dd>
1363 <dt>&g = 2</dt><dd>Nightly binning</dd>
1364 <dt>&g = 3</dt><dd>Yearly binning</dd>
1365 <dt>&g = 4</dt><dd>Season binning (lower culmination to lower culmination)</dd>
1366 <dt>&g = 5</dt><dd>Run wise display (might be slow!)</dd>
1367 <dt>&g = 6</dt><dd>Binning in fZenithDistanceMean [default bin-width: 5]</dd>
1368 <dt>&g = 7</dt><dd>Binning in ThresholdMinSet [default bin-width: 50]</dd>
1369 <dt>&g = 42</dt><dd>Use &x=... for x-axis binning [default bin-width: 1]</dd>
1370 <P>
1371 <dt>&b=...</dt><dd>Restrict data range (begin) [eg. &b=2011-10-01]</dd>
1372 <dt>&e=...</dt><dd>Restrict data range (end) [eg. &e=2011-10-01]</dd>
1373 <dt>&print</dt><dd>Show the plot only [&print] </dd>
1374 <dt>&s=...</dt><dd>Restrict to given source id [eg. &s=5] </dd>
1375 <dt>&t=...</dt><dd>Choose table with analysis results (ISDC, LP:default) [eg. &t=ISDC] </dd>
1376 <dt>&cut=...</dt><dd>Additional where statement to be added with AND [eg. &cut=fZenithDistance&lt;35]</dd>
1377 <dt>&min=...</dt><dd>y-axis minimum [eg. &min=0]</dd>
1378 <dt>&max=...</dt><dd>y-axis maximum [eg. &max=0]</dd>
1379 <dt>&no-errors</dt><dd>suppress error bars [eg. &no-errors]</dd>
1380 <dt>&no-hist</dt><dd>do not show histogram as bars [eg. &no-hist]</dd>
1381 <dt>&x=...</dt><dd>A x-axis binned in ... [forces &g=42, eg. &x=fZenithDistance]</dd>
1382 <dt>&w=...</dt><dd>Bin width for &g=6/7/42 [eg. &w=2]</dd>
1383 <dt>&y=...</dt><dd>x-axis variable, to be used with &r=42/43/44[/45] [eg. &y=fOnTime]</dd>
1384 <dt>&avg=...</dt><dd>short for &y=... [forces &r=42, eg. &y=fOnTime]</dd>
1385 <dt>&sum=...</dt><dd>short for &y=... [forces &r=43, eg. &y=fOnTime]</dd>
1386 <dt>&hist=...</dt><dd>short for &x=... [forces &r=45, eg. &y=fOnTime]</dd>
1387</dl>
1388</div>
1389
1390<hr>
1391
1392<input type="button" onclick="$('#spoiler1').toggle(300);" value="SQL Query"/>
1393<div id="spoiler1" style="display:none">
1394<pre>
1395Database = $database
1396<hr>
1397$querycol1
1398
1399<hr>
1400$querycol0
1401
1402<tt><font color="blue"><b>Roundtrip query time:</B></font> $timeMeasured ms</tt>
1403</pre>
1404</div>
1405
1406<hr>
1407
1408$data
1409
1410</body>
1411</html>
1412EOT;
1413
1414?>
Note: See TracBrowser for help on using the repository browser.