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