Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:16

0001 <?php
0002 /* 
0003  * common.php
0004  * 
0005  * Common variables and functions for the application (basically a config
0006  * script)
0007  */
0008 
0009 function get_conn_params($location) {
0010   if ($location && $location == 'P5_MT' ) {
0011     return array('user' => "cms_ecal",
0012          'pass' => "_change_me_",
0013          'sid'  => "omds");
0014   } elseif ( $location && $location == 'P5_Co' ) {
0015     return array('user' => "cms_ecal_cond",
0016                'pass' => "_change_me_",
0017                'sid'  => "omds");
0018   } else {
0019     return array('user' => "cond01",
0020          'pass' => "_change_me_",
0021          'sid'  => "ecalh4db");
0022   }
0023 }
0024 
0025 function get_dqm_url($location, $runtype, $run) {
0026   if ($location && $location == 'H4B') {
0027     if ( $run < 18581 ) {
0028       $url = "http://pctorino1.cern.ch/html/";
0029     } else {
0030       $url = "http://pctorino1.cern.ch/html.new/";
0031     }
0032   } elseif ($location && $location == 'H2') {
0033     if ($runtype == 'BEAM') {
0034       $url = "http://cmshcal04.cern.ch/html/";
0035     } else {
0036       $url = "http://pctorino2.cern.ch/html/";
0037     }
0038   } elseif ($location && $location == 'P5_MT') {
0039     $url = "http://lxcms201.cern.ch/mtcc/";
0040   } elseif ($location && $location == 'P5_Co') {
0041     $url = "http://ecalod-dqm01/html/";
0042   } else {
0043     $url = "http://lxcms201.cern.ch/html/";
0044   }
0045   return $url.str_pad($run, 9, '0', STR_PAD_LEFT);
0046 }
0047 
0048 function get_dqm_url2($location, $runtype, $run) {
0049   if ($location && $location == 'H4B') {
0050     $url = "http://pctorino1.cern.ch/logfile.php?run=" . $run;
0051   } elseif ($location && $location == 'H2') {
0052     if ($runtype == 'BEAM') {
0053       $url = "http://cmshcal04.cern.ch/logfile.php?run=" . $run;
0054     } else {
0055       $url = "http://pctorino2.cern.ch/logfile.php?run=" . $run;
0056       $url = $url . "&runtype=" . $runtype;
0057     }
0058   } elseif ($location && $location == 'P5_MT') {
0059     $url = "log file for run ". $run . "is not available";
0060   } elseif ($location && $location == 'P5_Co') {
0061     $url = "http://ecalod-dqm01/logfile.php?run=" . $run;
0062     $url = $url . "&runtype=" . $runtype;
0063   } else if ($location && $location == 'H4') {
0064     $url = "http://lxcms201.cern.ch/logfile.php?run=" . $run;
0065     $url = $url . "&runtype=" . $runtype;
0066   }
0067   return $url;
0068 }
0069 
0070 function get_rootplot_path() {
0071   
0072 }
0073 
0074 function get_cache_dir() {
0075 
0076 }
0077 
0078 function get_datatype_array() {
0079   return array('Beam' => 'BEAM',
0080          'Monitoring' => 'MON',
0081          'DCU' => 'DCU',
0082          'Laser' => 'LMF',
0083          'DCS' => 'DCS');
0084 }
0085 
0086 function get_rootplot_handle($args) {
0087   putenv('ROOTSYS=/afs/cern.ch/cms/external/lcg/external/root/5.12.00/slc3_ia32_gcc323/root');
0088   putenv('LD_LIBRARY_PATH=/afs/cern.ch/cms/external/lcg/external/root/5.12.00/slc3_ia32_gcc323/root/lib:/afs/cern.ch/cms/sw/slc3_ia32_gcc323/external/boost/1.33.1/lib:$LD_LIBRARY_PATH');
0089   putenv('ROOTPLOT=CMSSW_0_8_0/bin/slc3_ia32_gcc323/cmsecal_rootplot');
0090 
0091   @system('rm rootplot_error.log');
0092   $handle = popen("\$ROOTPLOT $args > rootplot_error.log 2>&1", "w") or die('Failed to open rootplot program');
0093 
0094   if (! $handle ) {
0095     return 0;
0096   }
0097 
0098   flush();
0099   fflush($handle);
0100   if (get_rootplot_error()) {
0101     pclose($handle);
0102     return 0;
0103   }
0104 
0105   return $handle;
0106 }
0107 
0108 function get_rootplot_error() {
0109   $error_file = @fopen('rootplot_error.log', 'r');
0110   if (! $error_file) { 
0111     return 0;
0112   }
0113 
0114   $error_msg = "";
0115   while ($line = fgets($error_file)) {
0116     $error_msg .= $line;
0117   }
0118   fclose($error_file);
0119   return $error_msg;
0120 }
0121 
0122 function get_task_array() {
0123   return array('CI' => 'Channel Integrity Task',
0124          'CS' => 'Cosmic Task',
0125          'LS' => 'Laser Task',
0126          'PD' => 'Pedestal Task',
0127          'PO' => 'Pedestals Online Task',
0128          'TP' => 'Test Pulse Task',
0129          'BC' => 'Beam Calo Task',
0130                'BH' => 'Beam Hodo Task',
0131                'TT' => 'Trigger Tower Task');
0132 }
0133 
0134 function get_task_outcome($list_bits, $outcome_bits) {
0135   if (!$list_bits && !$outcome_bits) { return false; }
0136   $tasks = get_task_array();
0137   
0138   $result = array();
0139   foreach(array_keys($tasks) as $i => $taskcode) {
0140     if ($list_bits & (1 << $i)) {
0141       $result[$taskcode] = $outcome_bits & (1 << $i);
0142     }
0143   }
0144   return $result;
0145 }
0146 
0147 function get_stylelinks( $compact = 0 ) {
0148 
0149   if( $compact == '1' ) {
0150     return "
0151 <link rel='stylesheet' type='text/css' href='ecalconddb-compact.css'/>
0152 <!--[if IE]>
0153 <link rel='stylesheet' type='text/css' href='fixie.css'/>
0154 <![endif]-->
0155 ";
0156   }
0157   else {
0158     return "
0159 <link rel='stylesheet' type='text/css' href='ecalconddb.css'/>
0160 <!--[if IE]>
0161 <link rel='stylesheet' type='text/css' href='fixie.css'/>
0162 <![endif]-->
0163 ";
0164   }
0165 }
0166 
0167 ?>
0168