Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:41:12

0001 #!/bin/bash
0002 
0003 WebDir='/eos/cms/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring'
0004 WebSite='https://cms-conddb.cern.ch/eosweb/hcal/HcalRemoteMonitoring'
0005 HistoDir='/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring/CMT/histos'
0006 eos='/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select'
0007 
0008 # print usage info
0009 if [[ "$1" == "" ]]; then
0010   echo "Usage:"
0011   echo "  $0 file [comment] [-ignore-file] [-das-cache]"
0012   echo "    file  -- a file with run numbers"
0013   echo "    comment  -- add a comment line (instead of spaces use '_')"
0014   echo "    -ignore-file   -- skips production of run html pages. Produces"
0015   echo "                      only the global page. File name is not needed."
0016   echo "    -das-cache   -- whether to save DAS information locally for a reuse"
0017   echo
0018   echo "example: ./GLOBAL.sh Run_List.txt"
0019   exit 1
0020 fi
0021 
0022 cmsenv 2>/dev/null
0023 if [ $? == 0 ] ; then
0024     eval `scramv1 runtime -sh`
0025 fi
0026 temp_var=`ls ${eos}`
0027 status="$?"
0028 echo "using eos command <${temp_var}>"
0029 if [ ! ${status} -eq 0 ] ; then
0030     echo "failed to find eos command"
0031     # exit 1
0032 fi
0033 
0034 
0035 # create log directory
0036 LOG_DIR="dir-Logs"
0037 if [ ! -d ${LOG_DIR} ] ; then mkdir ${LOG_DIR}; fi
0038 rm -f ${LOG_DIR}/*
0039 
0040 
0041 # Process arguments and set the flags
0042 fileName=$1
0043 comment=$2
0044 if [ ${#comment} -gt 0 ] && [ "${comment:0:1}" == "-" ] ; then comment=""; fi
0045 ignoreFile=0
0046 debug=0
0047 dasCache=0
0048 DAS_DIR="d-DAS-info"
0049 
0050 for a in $@ ; do
0051     if [ "$a" == "-ignore-file" ] ; then
0052         echo " ** file will be ignored"
0053         fileName=""
0054         ignoreFile=1
0055     elif [ "$a" == "-das-cache" ] ; then
0056         echo " ** DAS cache ${DAS_DIR} enabled"
0057         dasCache=1
0058         if [ ! -d ${DAS_DIR} ] ; then mkdir ${DAS_DIR}; fi
0059     else
0060         temp_var=${a/-debug/}
0061         if [ ${#a} -gt ${#temp_var} ] ; then
0062             debug=${temp_var}
0063             echo " ** debug detected (debug=${debug})"
0064         fi
0065     fi
0066 done
0067 
0068 # Obtain the runList from a file, if needed
0069 runList=""
0070 if [ ${#fileName} -gt 0 ] ; then
0071   if [ -s ${fileName} ] ; then
0072       runList=`cat ${fileName}`
0073   else
0074       echo "<${fileName}> does not seem to be a valid file"
0075       exit 2
0076   fi
0077 else
0078     if [ ${ignoreFile} -eq 0 ] ; then
0079         echo " ! no file provided"
0080     fi
0081     echo " ! will produce only the global html page"
0082 fi
0083 
0084 
0085 # Check the runList and correct the correctables
0086 # Replace ',' and ';' by empty spaces
0087 runList=`echo "${runList}" | sed 'sk,k\ kg' | sed 'sk;k\ kg'`
0088 ok=1
0089 for r in ${runList} ; do
0090     if [ ! ${#r} -eq 6 ] ; then
0091         echo "run numbers are expected to be of length 6. Check <$r>"
0092         ok=0
0093     fi
0094     debug_loc=0
0095     if [ "$r" -eq "$r" ] 2>/dev/null ; then
0096         if [ ${debug_loc} -eq 1 ] ; then echo "run variable <$r> is a number (ok)"; fi
0097     else
0098         echo "error: run variable <$r> is not an integer number"
0099         ok=0
0100     fi
0101 done
0102 
0103 echo "Tested `wc -w <<< "${runList}"` runs from file ${fileName}"
0104 if [ ${ok} -eq 0 ] ; then
0105     echo "errors in the file ${fileName} with run numbers"
0106     exit 3
0107 else
0108     if [ ${#fileName} -gt 0 ] ; then
0109         echo "run numbers in ${fileName} verified ok"
0110     fi
0111 fi
0112 
0113 comment=`echo ${comment} | sed sk\_k\ kg`
0114 if [ ${#comment} -gt 0 ] ; then
0115     echo "comment \"${comment}\" will be added to the pages"
0116 fi
0117 
0118 if [ ${debug} -eq 3 ] ; then exit; fi
0119 
0120 
0121 echo 
0122 echo 
0123 echo 
0124 echo 'Run numbers for processing'
0125 echo "${runList}"
0126 echo -e "list complete\n"
0127 
0128 #processing
0129 
0130 for i in ${runList} ; do
0131     runnumber=$i
0132 
0133     logFile="${LOG_DIR}/log_${runnumber}.out"
0134     rm -f ${logFile}
0135 
0136 # if [[ "$runnumber" > 233890 ]] ; then
0137     echo 
0138     echo 
0139     echo
0140     echo  "Run for processing $runnumber"
0141     echo  "always copy root file from /eos !!!"
0142     echo  "file=root://eoscms//cms/$HistoDir/Global_$runnumber.root"
0143 # always copy root file from /eos !!!
0144 ##    if [ ! -s Global_${runnumber}.root ] ; then
0145 ##      xrdcp root://eoscms//eos/cms/$HistoDir/Global_$runnumber.root Global_$runnumber.root
0146 #       xrdcp -f root://eoscms//eos/cms/$HistoDir/Global_$runnumber.root Global_$runnumber.root
0147 cp /eos/cms/$HistoDir/Global_$runnumber.root Global_$runnumber.root
0148 
0149         status="$?"
0150         if [ ! ${status} -eq 0 ] ; then
0151             echo "failed to get file Global_${runnumber}.root"
0152             exit 2
0153         fi
0154 ##    fi
0155     
0156 
0157 
0158     #GlobalRMT processing
0159     echo -e "\nRemoteMonitoringMAP_Global\n" >> ${logFile}
0160     ./../../macros/cmt/RemoteMonitoringMAP_Global.cc.exe Global_$runnumber.root Global_$runnumber.root 2>&1 | tee -a ${logFile}
0161     if [ ! $? -eq 0 ] ; then
0162         echo "MAP_Global processing failed"
0163         exit 2
0164     fi
0165 
0166 #    if [ ! -s HELP.html ] ; then
0167 #       echo "MAP_Global failure was not detected. HELP.html is missing"
0168 #       exit 2
0169 #    fi
0170 
0171     local_WebDir=dir-GlobalRMT-GLOBAL_${runnumber}
0172     rm -rf ${local_WebDir}
0173     if [ ! -d ${local_WebDir} ] ; then mkdir ${local_WebDir}; fi
0174     for j in $(ls -r *.html); do
0175         cat $j | sed 's#cms-cpt-software.web.cern.ch\/cms-cpt-software\/General\/Validation\/SVSuite#cms-conddb-dev.cern.ch\/eosweb\/hcal#g' \
0176                 > ${local_WebDir}/$j
0177     done
0178 
0179     cp *.png ${local_WebDir}
0180 #    cp HELP.html ${local_WebDir}
0181 
0182 
0183 
0184 #---------------111
0185 # first variant:
0186     mkdir $WebDir/GlobalRMT/GLOBAL_$runnumber
0187     cp *.png $WebDir/GlobalRMT/GLOBAL_$runnumber/.
0188     cp *.html $WebDir/GlobalRMT/GLOBAL_$runnumber/.
0189  echo "cp  png and html file done"
0190 
0191 
0192 #---------------222 wrong
0193 # more simple second variant:
0194 #scp -r ${local_WebDir} $WebDir/GlobalRMT/GLOBAL_$runnumber
0195 #echo "cp -r for dir with png and html file done"
0196 
0197 
0198 
0199 
0200     #files=`cd ${local_WebDir}; ls`
0201     ##echo "GlobalRMT files=${files}"
0202 
0203 #    if [ ${debug} -eq 0 ] ; then
0204 #       eos mkdir $WebDir/GlobalRMT/GLOBAL_$runnumber
0205 #       if [ ! $? -eq 0 ] ; then
0206 #           echo "GlobalRMT eos mkdir failed"
0207 #           exit 2
0208 #       fi
0209 #       for f in ${files} ; do
0210 #           echo "eoscp ${local_WebDir}/${f} $WebDir/GlobalRMT/GLOBAL_$runnumber/${f}"
0211 #           eoscp ${local_WebDir}/${f} $WebDir/GlobalRMT/GLOBAL_$runnumber/${f}
0212 #           if [ ! $? -eq 0 ] ; then
0213 #               echo "GlobalRMT eoscp failed for ${f}"
0214 #               exit 2
0215 #           fi
0216 #       done
0217 #    else
0218 #        # debuging
0219 #       echo "debugging: files are not copied to EOS"
0220 #    fi
0221 
0222     rm *.html
0223     rm *.png
0224     rm -rf dir-GlobalRMT-GLOBAL_*
0225 #    rm *.root
0226 #fi
0227 
0228 done
0229 
0230 if [ ${debug} -eq 2 ] ; then
0231     echo "debug=2 skipping web page creation"
0232     exit 2
0233 fi
0234 
0235 
0236 
0237 echo "GlobalRMT script done"