Пример #1
0
function draw_plotselect()
{
    global $fieldlists;
    $run = $_GET['run'];
    $datatype = $_GET['datatype'];
    $iov_id = $_GET['iov_id'];
    $exists_str = $_GET['exists_str'];
    $exists = array_flip(split(',', $exists_str));
    $available = array_intersect_key($fieldlists[$datatype], $exists);
    if (count($available)) {
        echo "<select class='plotselect' name='tablefield'>";
        foreach ($available as $table => $tflist) {
            foreach ($tflist as $tf) {
                list($table, $field) = split('\\.', $tf);
                $plotparams = db_fetch_plot_params($table, $field);
                if ($plotparams) {
                    $fielddesc = $plotparams['LABEL'];
                } else {
                    $fielddesc = $tf;
                }
                if (isset($_GET['tablefield']) && $_GET['tablefield'] == $tf) {
                    $selected = "selected='selected'";
                } else {
                    $selected = "";
                }
                echo "<option value='{$tf}' {$selected}>{$fielddesc}</option>";
            }
        }
        echo "</select>";
        echo "<select name='plottype'>";
        foreach (get_plottypes() as $value => $label) {
            if (isset($_GET['plottype']) && $_GET['plottype'] == $value) {
                $selected = "selected='selected'";
            } else {
                $selected = "";
            }
            echo "<option value='{$value}' {$selected}>{$label}</option>";
        }
        echo "</select>";
    } else {
        echo "No Data Available";
    }
}
Пример #2
0
function db_make_rootplot($table, $field, $iov_id, $plottype, $name)
{
    global $conn;
    $plot_params = db_fetch_plot_params($table, $field);
    $fmt = "png";
    $title = $plot_params['FIELD_CONTENT'];
    $chan_name = $plot_params['LOGIC_ID_NAME'];
    $map_name = $plot_params['MAP_BY_LOGIC_ID_NAME'];
    if ($plottype == 'histo_all') {
        $type = 'TH1F';
        $grp = 0;
        $sql = "select {$field} from {$table} where iov_id = :iov_id";
        $xtitle = $plot_params['LABEL'];
        $ytitle = "";
    } elseif ($plottype == 'histo_grp') {
        $type = 'TH1F';
        $grp = 1;
        $sql = "select vd.id1name, cv.id1, d.{$field} from {$table} d, channelview cv, viewdescription vd\n             where d.iov_id = :iov_id \n               and d.logic_id = cv.logic_id\n               and cv.name = cv.maps_to\n               and cv.name = vd.name\n             order by cv.id1, cv.id2, cv.id3";
        $xtitle = $plot_params['LABEL'];
        $ytitle = "";
    } elseif ($plottype == 'graph_all') {
        $type = 'TGraph';
        $grp = 0;
        $sql = "select rownum, {$field}\n              from (select d.{$field} from {$table} d, channelview cv\n                     where d.iov_id = :iov_id \n                       and d.logic_id = cv.logic_id\n                       and cv.name = cv.maps_to\n                     order by cv.id1, cv.id2, cv.id3)";
        $xtitle = $plot_params['LOGIC_ID_EXPLANATION'];
        $ytitle = $plot_params['LABEL'];
    } elseif ($plottype == 'graph_grp') {
        $type = 'TGraph';
        $grp = 1;
        $sql = "select id1name, id1, rownum, {$field}\n              from (select vd.id1name, cv.id1, d.{$field} from {$table} d, channelview cv, viewdescription vd\n                     where d.iov_id = :iov_id \n                       and d.logic_id = cv.logic_id\n                       and cv.name = cv.maps_to\n                       and cv.name = vd.name\n                     order by cv.id1, cv.id2, cv.id3)";
        $xtitle = $plot_params['LOGIC_ID_EXPLANATION'];
        $ytitle = $plot_params['LABEL'];
    } elseif ($plottype == 'map_all') {
        //    if (!$map_name) { echo "No map_name.";  return 0; } // Cannot map without an _index type mapping
        $type = 'Map';
        $grp = 1;
        $sql = "select id1name, id1, rownum, {$field}\n              from (select vd.id1name, cv.id1, d.{$field} from {$table} d, channelview cv, viewdescription vd\n                     where d.iov_id = :iov_id \n                       and d.logic_id = cv.logic_id\n                       and cv.name = 'EB_crystal_number'\n                       and cv.name = vd.name\n                     order by cv.id1, cv.id2, cv.id3)";
        $xtitle = "";
        $ytitle = "";
    } else {
        die("Unknown plottype");
    }
    $stmt = oci_parse($conn, $sql);
    oci_bind_by_name($stmt, ':iov_id', $iov_id);
    oci_execute($stmt);
    $n = 0;
    $names = array();
    $rptitle = $title;
    $rpname = $name;
    while ($row = oci_fetch_row($stmt)) {
        // Augment titles and file names if there is grouping
        if ($grp) {
            $grp_name = array_shift($row);
            $curr_grp = array_shift($row);
        }
        // If the group is over add finish the last plot
        if ($n != 0 && $grp && $last_grp != $curr_grp) {
            array_push($names, $rpname);
            pclose($rootplot);
        }
        // Open a rootplot handle if it is the first row or the group changed
        if ($n == 0 || $grp && $last_grp != $curr_grp) {
            if ($grp) {
                $rptitle = $title . " ({$grp_name} {$curr_grp})";
                $rpname = $name . ".{$grp_name}{$curr_grp}";
            }
            $histo_min = $plot_params['HISTO_MIN'];
            $histo_max = $plot_params['HISTO_MAX'];
            $rootplot = get_rootplot_handle("-T \"{$rptitle}\" -X \"{$xtitle}\" -Y \"{$ytitle}\" {$type} {$fmt} {$rpname} {$histo_min} {$histo_max}");
            if (!$rootplot || get_rootplot_error()) {
                return 0;
            }
        }
        // Write a row of data to the rootplot handle
        $dataline = join(' ', $row) . "\n";
        fwrite($rootplot, $dataline);
        // Increment
        $n++;
        if ($grp) {
            $last_grp = $curr_grp;
        }
    }
    // Close the last plot
    array_push($names, $rpname);
    pclose($rootplot);
    if ($n == 0) {
        echo "N is zero";
    }
    if (get_rootplot_error() || $n == 0) {
        return 0;
    }
    return $names;
}