Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:14

0001 <?php
0002 
0003 require_once 'common.php';
0004 require_once 'db_functions.php';
0005 
0006 $tasks = get_task_array();
0007 
0008 $loc      = $_GET['loc'];
0009 $taskcode = $_GET['taskcode'];
0010 $run      = $_GET['run'];
0011 $iov_id   = $_GET['iov_id'];
0012 
0013 $conn = connect($_GET['loc']);
0014 
0015 ?>
0016 
0017 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
0018 <html>
0019 <head>
0020 <?php
0021 echo "<title>bad channels list - run ".$run." @ ".$loc."</title>";
0022 echo get_stylelinks();
0023 ?>
0024 
0025 </head>
0026 <body>
0027 
0028 <?php
0029 
0030 // Tables to output for each task code
0031 $tables['CI'][0] = "MON_CRYSTAL_CONSISTENCY_DAT";
0032 $tables['CI'][1] = "MON_TT_CONSISTENCY_DAT";
0033 $tables['CI'][2] = "MON_MEM_CH_CONSISTENCY_DAT";
0034 $tables['CI'][3] = "MON_MEM_TT_CONSISTENCY_DAT";
0035   
0036 $tables['PO'][0] = "MON_PEDESTALS_ONLINE_DAT";
0037 $tables['PD'][0] = "MON_PEDESTALS_DAT";
0038 $tables['PD'][1] = "MON_PN_PED_DAT";
0039   
0040 $tables['TP'][0] = "MON_TEST_PULSE_DAT";
0041 $tables['TP'][1] = "MON_PN_MGPA_DAT";
0042   
0043 $tables['LS'][0] = "MON_LASER_RED_DAT";
0044 $tables['LS'][1] = "MON_PN_RED_DAT";
0045 $tables['LS'][2] = "MON_LASER_BLUE_DAT";
0046 $tables['LS'][3] = "MON_PN_BLUE_DAT";
0047 $tables['LS'][4] = "MON_LASER_GREEN_DAT";
0048 $tables['LS'][5] = "MON_PN_GREEN_DAT";
0049 $tables['LS'][6] = "MON_LASER_IRED_DAT";
0050 $tables['LS'][7] = "MON_PN_IRED_DAT";
0051   
0052 // Page Title
0053 echo "<center>";
0054 echo "<h1>List of bad channels - run ".$run." @ ".$loc."</h1>";
0055 echo "</center>";
0056 echo "<hr/>";
0057 echo "<h2>".$tasks[$taskcode]."</h2>";
0058 echo "<hr/>";
0059   
0060 if ( $taskcode == 'CS' || $taskcode == 'BC' || $taskcode == 'BH' || $taskcode == 'TT' ) {
0061   echo "<h3>No bad channel lists are produced by this task</h3>";
0062   echo "<hr/>";
0063   exit;
0064 }
0065   
0066 foreach ($tables[$taskcode] as $table) {
0067   $data = fetch_mon_dataset_data($table, $iov_id, " task_status = :ts", array(':ts' => "0"));
0068   $headers = fetch_mon_dataset_headers($table);
0069   $headers = reorder_columns($table, $headers);
0070   $nrows = count($data['RUN']);
0071   $ncols = count($headers);
0072     
0073   // Table Title
0074   echo "<h4>$table<h4>";
0075     
0076   if ($nrows == 0) {
0077     echo "<h5>No bad channels in $table</h5>";
0078     echo "<hr/>";
0079     continue;
0080   }
0081     
0082   // Header row
0083   echo "<table class='bads'>";
0084   echo "<tr>";
0085   foreach($headers as $code => $head) {
0086     echo "<th>$head</th>";
0087     if ($head == 'crystal_number') {
0088       add_xtal_headers();
0089     }
0090   }
0091   echo "</tr>";
0092     
0093   // Data rows
0094   for ($i = 0; $i < $nrows; $i++) {
0095     if ($i % 2 == 0) { echo "<tr>"; }
0096     else { echo "<tr class='bads'>"; }
0097       
0098     foreach($headers as $code => $head) {
0099       $field = $data[$code][$i];
0100       // Useing a regexp to find floats
0101       // Somehow is_float() doesn't work for Oracle formatted floats...
0102       if (preg_match("/\d+E[\+\-]\d+/", $field)) {
0103   $field = sprintf("%6.1f", $field);
0104       }
0105       echo "<td>".$field."</td>";
0106       if ($head == 'crystal_number') {
0107   add_xtal_columns($field);
0108       }
0109     }
0110     echo "</tr>";
0111   }
0112     
0113   echo "</table>";
0114   echo "<hr/>";
0115 }
0116 
0117 
0118 function add_xtal_headers() {
0119   echo "<th>eta</th><th>phi</th><th>tower</th><th>strip</th><th>crystal in strip</th>";
0120 }
0121 
0122 function add_xtal_columns($xtal) {
0123   $eta = 1 + floor(($xtal -1)/20);
0124   $phi = 1 + ($xtal -1)%20;
0125   $tower = 1 + 4*floor(($eta -1)/5) + floor(($phi -1)/5);
0126 
0127   $nxtal = 1;
0128   $strip = 1;
0129 
0130   if ( ($tower > 12 && $tower < 21 ) || ($tower > 28 && $tower < 37) ||
0131        ($tower > 44 && $tower < 53 ) || ($tower > 60 && $tower < 69) ) {
0132     $cryInTower = (($eta -1)%5)*5;
0133     if ( (($eta -1)%5)%2 == 0 ) {
0134       $cryInTower += ($phi -1)%5;
0135     } else{
0136       $cryInTower += 5 - 1 - ($phi -1)%5;
0137     }
0138   } else {
0139     $cryInTower = (5 - 1 - ($eta -1)%5)*5;
0140     if ( (($eta-1)%5)%2 == 0 ) {
0141       $cryInTower += 5 - 1 - ($phi -1)%5;
0142     } else{
0143       $cryInTower += ($phi -1)%5;
0144     }
0145   }
0146 
0147   $nxtal = $cryInTower%5 + 1;
0148   $strip = floor($cryInTower/5) + 1;
0149 
0150   echo "<td>$eta</td><td>$phi</td><td>$tower</td><td>$strip</td><td>$nxtal</td>";
0151 }
0152 
0153 function reorder_columns($table, $col_headers) {
0154   $order = array_keys($col_headers);
0155 
0156   // Preferred column order based on table name
0157   if ($table == 'MON_PEDESTALS_DAT') {
0158     $order = array('RUN', 'ID1', 'ID2', 
0159        'PED_MEAN_G12', 'PED_RMS_G12', 
0160        'PED_MEAN_G6', 'PED_RMS_G6', 
0161        'PED_MEAN_G1', 'PED_RMS_G1',
0162        'TASK_STATUS');
0163   }
0164   
0165   $new_headers = array();
0166   foreach ($order as $code) {
0167     $new_headers[$code] = $col_headers[$code];
0168   }
0169 
0170   return ($new_headers);
0171 }
0172 
0173 ?>
0174 
0175 </body>
0176 </html>