File indexing completed on 2024-04-06 12:23:16
0001 <?php
0002
0003
0004
0005
0006
0007
0008
0009 require_once 'common.php';
0010 require_once 'db_functions.php';
0011
0012 $conn = connect($_GET['loc']);
0013
0014 function input_errors() {
0015 $error = "";
0016 foreach (array('run', 'datatype', 'iov_id', 'exists_str') as $input) {
0017 if (!isset($input)) { $error .= "<h1>ERROR: Missing input parameter '$input'</h1>"; }
0018 }
0019 }
0020
0021 function get_plottypes() {
0022 return array('histo_all' => 'Histogram (All Channels)',
0023 'histo_grp' => 'Histogram (Group Channels)',
0024 'graph_all' => 'Graph (All Channels)',
0025 'graph_grp' => 'Graph (Group Channels)',
0026 'map_all' => 'Map (All Channels)');
0027 }
0028
0029 function draw_plotselect_form() {
0030 echo "<div class='plot'>";
0031 echo "<form name='plotmap' action='plot.php'>";
0032 echo "Variable: ";
0033 draw_plotselect();
0034 echo "<input type='submit' name='' value='Plot' />";
0035
0036 foreach (array('run', 'loc', 'datatype', 'iov_id', 'exists_str') as $name) {
0037 $value = $_GET[$name];
0038 echo "<input type='hidden' name='$name' value='$value' />";
0039 }
0040 echo "</form>";
0041 echo "</div>";
0042 }
0043
0044 function draw_plotselect() {
0045 global $fieldlists;
0046 $run = $_GET['run'];
0047 $datatype = $_GET['datatype'];
0048 $iov_id = $_GET['iov_id'];
0049 $exists_str = $_GET['exists_str'];
0050
0051
0052 $exists = array_flip(split(',', $exists_str));
0053 $available = array_intersect_key($fieldlists[$datatype], $exists);
0054
0055 if (count($available)) {
0056 echo "<select class='plotselect' name='tablefield'>";
0057 foreach ($available as $table => $tflist) {
0058 foreach ($tflist as $tf) {
0059 list($table, $field) = split('\.', $tf);
0060 $plotparams = db_fetch_plot_params($table, $field);
0061 if ($plotparams) {
0062 $fielddesc = $plotparams['LABEL'];
0063 } else {
0064 $fielddesc = $tf;
0065 }
0066 if (isset($_GET['tablefield']) &&
0067 $_GET['tablefield'] == $tf) {
0068 $selected = "selected='selected'";
0069 } else { $selected = ""; }
0070 echo "<option value='$tf' $selected>$fielddesc</option>";
0071 }
0072 }
0073 echo "</select>";
0074 echo "<select name='plottype'>";
0075 foreach (get_plottypes() as $value => $label) {
0076 if (isset($_GET['plottype']) &&
0077 $_GET['plottype'] == $value) {
0078 $selected = "selected='selected'";
0079 } else { $selected = ""; }
0080 echo "<option value='$value' $selected>$label</option>";
0081 }
0082 echo "</select>";
0083 } else {
0084 echo "No Data Available";
0085 }
0086 }
0087
0088 function draw_plot() {
0089 if ( !isset($_GET['tablefield']) ||
0090 !isset($_GET['iov_id'] ) ||
0091 !isset($_GET['run']) ||
0092 !isset($_GET['plottype']) ) { return 0; }
0093
0094 echo "<div class='plot'>";
0095
0096 list($table, $field) = split('\.', $_GET['tablefield']);
0097 $iov_id = $_GET['iov_id'];
0098 $run = $_GET['run'];
0099 $plottype = $_GET['plottype'];
0100
0101 $name = "../ecalconddb/plotcache/run$run.$table.$field.$iov_id.$plottype";
0102
0103 $names = array();
0104 if ($img_files = glob($name.'*.png')) {
0105 foreach ($img_files as $img) {
0106 array_push($names, preg_replace('/\.png/', '', $img));
0107 }
0108 } elseif ( $names = db_make_rootplot($table, $field, $iov_id, $plottype, $name) ) {
0109 } else {
0110 echo "<h1>ERROR</h1>";
0111 $error_msg = get_rootplot_error();
0112 echo "<p>", $error_msg, "</p>";
0113 }
0114
0115 if ($names == 0) {
0116 echo "Names is zero.";
0117 }
0118
0119
0120 foreach ($names as $name) {
0121 $img = $name.'.png';
0122 $root = 'download.php?file='.$name.'.root';
0123 echo "<a href='$root' type='application/octet-stream'><img src=\"$img\" alt=\"$img\"/><br />Click to download ROOT file</a>";
0124 echo " Cached on ". date("Y-m-d H:i:s", filemtime($img)). "<br />";
0125 }
0126
0127 echo "</div>";
0128 }
0129
0130
0131 $run = $_GET['run'];
0132 $datatype = $_GET['datatype'];
0133 $iov_id = $_GET['iov_id'];
0134 $exists = $_GET['exists_str'];
0135
0136 $datatypes = get_datatype_array();
0137 $fieldlists = array();
0138 foreach ($datatypes as $name => $prefix) {
0139 if (isset($_GET[$prefix])) { $ndisplay++; }
0140 $fieldlists[$prefix] = fetch_field_array(strtoupper($prefix));
0141 }
0142
0143 $dataname = array_search($datatype, $datatypes);
0144 $title = "$dataname plot for run $run";
0145
0146
0147
0148 ?>
0149 <!DOCTYPE html
0150 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
0151 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0152 <html>
0153 <head>
0154 <title><?php echo $title ?></title>
0155 <?php echo get_stylelinks(); ?>
0156 </head>
0157
0158 <body>
0159
0160 <?php
0161 if ($errors = input_errors()) {
0162 echo $errors;
0163 } else {
0164 echo "<h1>$title</h1>";
0165 draw_plotselect_form();
0166 draw_plot();
0167 }
0168 ?>
0169
0170 </body>
0171 </html>