Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:27

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/GlobalPSM/histos'
0006 eos='/afs/cern.ch/project/eos/installation/0.3.15/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         status="$?"
0148         if [ ! ${status} -eq 0 ] ; then
0149             echo "failed to get file Global_${runnumber}.root"
0150             exit 2
0151         fi
0152 ##    fi
0153     
0154     #GlobalPSM processing
0155     echo -e "\nRemoteMonitoringPSM\n" >> ${logFile}
0156 #    ./../../macros/psm/RemoteMonitoringPSM.cc.exe Global_$runnumber.root 2>&1 | tee -a ${logFile}
0157     ./../../macros/psm/RemoteMonitoringPSM.cc.exe Global_$runnumber.root Global_$runnumber.root Global 2>&1 | tee -a ${logFile}
0158 
0159     if [ ! $? -eq 0 ] ; then
0160         echo "PSM processing failed"
0161         exit 2
0162     fi
0163 
0164 ##    if [ ! -s HELP.html ] ; then
0165 ##      echo "GLOBAL failure was not detected. HELP.html is missing"
0166 ##      exit 2
0167 ##    fi
0168 
0169 
0170     local_WebDir=dir-GlobalPSM-GLOBAL_${runnumber}
0171     rm -rf ${local_WebDir}
0172     if [ ! -d ${local_WebDir} ] ; then mkdir ${local_WebDir}; fi
0173     for j in $(ls -r *.html); do
0174         cat $j | sed 's#cms-cpt-software.web.cern.ch\/cms-cpt-software\/General\/Validation\/SVSuite#cms-conddb.cern.ch\/eosweb\/hcal#g' \
0175             > ${local_WebDir}/$j
0176     done
0177     cp *.png ${local_WebDir}
0178 ##    cp HELP.html ${local_WebDir}
0179 
0180 
0181 
0182 #-----------------------------------------------------------------------------------------copying:
0183 
0184 
0185 #---------------111
0186 # first variant:
0187     mkdir $WebDir/GlobalPSM/GLOBAL_$runnumber
0188     cp *.png $WebDir/GlobalPSM/GLOBAL_$runnumber/.
0189     cp *.html $WebDir/GlobalPSM/GLOBAL_$runnumber/.
0190  echo "cp  png and html file done"
0191 
0192 
0193 #---------------222 wrong, create dir GLOBAL_$runnumber and inside, the dir local_WebDir
0194 # more simple second variant:
0195 #scp -r ${local_WebDir} $WebDir/GlobalPSM/GLOBAL_$runnumber
0196 #echo "cp -r for dir with png and html file done"
0197 
0198 
0199 #---------------old
0200 # instead old variant:
0201 
0202 #    files=`cd ${local_WebDir}; ls`
0203     ###echo "GlobalPSM files=${files}"
0204 #    if [ ${debug} -eq 0 ] ; then
0205 #       eos mkdir -p $WebDir/GlobalPSM/GLOBAL_$runnumber
0206 #       if [ ! $? -eq 0 ] ; then
0207 #           echo "GlobalPSM eos mkdir failed"
0208 #           exit 2
0209 #       fi
0210 #       for f in ${files} ; do
0211 #           echo "eoscp ${local_WebDir}/${f} $WebDir/GlobalPSM/GLOBAL_$runnumber/${f}"
0212 #           eos cp ${local_WebDir}/${f} $WebDir/GlobalPSM/GLOBAL_$runnumber/${f}
0213 #           if [ ! $? -eq 0 ] ; then
0214 #               echo "GlobalPSM eoscp failed for ${f}"
0215 ####            exit 2
0216 #           fi
0217 #       done
0218 #    else
0219         ## debuging
0220 #       echo "debugging: files are not copied to EOS"
0221 #    fi
0222 #
0223 #---------------
0224 #
0225 #   removing:
0226 #
0227 #
0228 #
0229     rm *.html
0230     rm *.png 
0231 #    rm -rf dir-GlobalPSM-GLOBAL_*
0232 #    rm *.root
0233 #
0234 
0235 #---------------
0236 
0237 #fi
0238 
0239 done
0240 
0241 if [ ${debug} -eq 2 ] ; then
0242     echo "debug=2 skipping web page creation"
0243     exit 2
0244 fi
0245 #---------------
0246 
0247 
0248 
0249 echo "GlobalPSM script done"
0250 #---------------