Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-19 23:59:14

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='/eos/cms/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring/CMT/histos'
0006 
0007 
0008 cmsenv 2>/dev/null
0009 if [ $? == 0 ] ; then
0010     eval `scramv1 runtime -sh`
0011 fi
0012 
0013 
0014 # Process arguments and set the flags
0015 fileName=$1
0016 
0017 # Obtain the runList from a file, if needed
0018 runList=""
0019 if [ ${#fileName} -gt 0 ] ; then
0020   if [ -s ${fileName} ] ; then
0021       runList=`cat ${fileName}`
0022   else
0023       echo "<${fileName}> does not seem to be a valid file"
0024       exit 2
0025   fi
0026 else
0027     if [ ${ignoreFile} -eq 0 ] ; then
0028         echo " ! no file provided"
0029     fi
0030     echo " ! will produce only the global html page"
0031 fi
0032 
0033 
0034 # Check the runList and correct the correctables
0035 # Replace ',' and ';' by empty spaces
0036 runList=`echo "${runList}" | sed 'sk,k\ kg' | sed 'sk;k\ kg'`
0037 ok=1
0038 for r in ${runList} ; do
0039     if [ ! ${#r} -eq 6 ] ; then
0040         echo "run numbers are expected to be of length 6. Check <$r>"
0041         ok=0
0042     fi
0043     debug_loc=0
0044     if [ "$r" -eq "$r" ] 2>/dev/null ; then
0045         if [ ${debug_loc} -eq 1 ] ; then echo "run variable <$r> is a number (ok)"; fi
0046     else
0047         echo "error: run variable <$r> is not an integer number"
0048         ok=0
0049     fi
0050 done
0051 
0052 echo "Tested `wc -w <<< "${runList}"` runs from file ${fileName}"
0053 if [ ${ok} -eq 0 ] ; then
0054     echo "errors in the file ${fileName} with run numbers"
0055     exit 3
0056 else
0057     if [ ${#fileName} -gt 0 ] ; then
0058         echo "run numbers in ${fileName} verified ok"
0059     fi
0060 fi
0061 
0062 echo 
0063 echo 
0064 echo 'Numbers of NEW runs for processing'
0065 echo "${runList}"
0066 echo -e "runList complete\n"
0067 
0068 echo -e '\n\nRun numbers:'
0069 runListEOS=`echo $runList | tee _runlist_`
0070 echo "${runListEOS}"
0071 echo -e "Full runList for EOS complete\n"
0072 
0073 
0074 # copy index.html from EOS:
0075 echo 'next message is Fine: '
0076 rm index.html
0077 eoscp $WebDir/CMT/index.html index.html
0078 cp index.html OLDindex.html
0079 
0080 # delete last line of copied index_draft.html which close the table
0081 cat index.html | head -n -1 > index_draft.html
0082 
0083 #extract run numbers for correct continuation
0084 #k=0
0085 #for i in ${runListEOSall} ; do
0086 #let "k = k + 1"
0087 #done
0088 
0089 k=4
0090 
0091 
0092 ########################################## type by hands number of new runs k=k-number:
0093 #let "k = k - 1"
0094 echo ' ================>>>    k in old list = '$k
0095 
0096 for i in ${runListEOS} ; do
0097  
0098 #runnumber=$(echo $i | sed -e 's/[^0-9]*//g')
0099 #runnumber=$(echo $i | awk -F 'run' '{print $2}'| awk -F '.' '{print $1}')
0100 runnumber=${i}
0101 #if [[ "$runnumber" > 243400 ]] ; then
0102 let "k = k + 1"
0103 echo
0104 echo ' ================>>> new k in loop = '$k
0105 echo
0106 echo
0107 echo 'RUN number = '$runnumber
0108 
0109 # extract the date of file
0110 dasInfo=${DAS_DIR}/das_${runnumber}.txt
0111 got=0
0112 if [ ${dasCache} == "1" ] ; then
0113     rm -f tmp
0114     if [ -s ${dasInfo} ] ; then
0115         cp ${dasInfo} tmp
0116         got=1
0117     else
0118         echo "no ${dasInfo} found. Will use dasgoclient"
0119     fi
0120 fi
0121 
0122 if [ ${got} -eq 0 ] ; then
0123 #dasgoclient  --query="file dataset=/HcalNZS/Run2018D-v1/RAW  run=${i} | grep file.size, file.nevents, file.modification_time "  > tmp
0124 dasgoclient  --query="file dataset=/Cosmics/Commissioning2021-v1/RAW  run=${i} | grep file.size, file.nevents, file.modification_time "  > tmp
0125 fi
0126 
0127 
0128 timetmp=`cat tmp | head -n 1  | awk '{print $3}'`
0129 ############################################################################################################
0130 type='Cosmics'
0131 timetmp2=`date -d @${timetmp} +%Y-%m-%d:%H-%M-%S`
0132 sizetmp=`cat tmp | head -n 1  | awk '{print $1}'`
0133 neventstmp=`cat tmp | head -n 1  | awk '{print $2}'`
0134 #commentariy='CRUZET2021'
0135 commentariy='CRAFT2021'
0136 #cat runs_info
0137 echo 'RUN Type = '$type
0138 echo ${sizetmp} ${neventstmp} ${timetmp2}
0139 echo 'RUN Comment = '$commentariy
0140 
0141 
0142 
0143 #adding entry to list of file index_draft.html
0144 let "raw = (k % 2) + 2"
0145 echo '<tr>'>> index_draft.html
0146 echo '<td class="s1" align="center">'$k'</td>'>> index_draft.html
0147 echo '<td class="s'$raw'" align="center">'$runnumber'</td>'>> index_draft.html
0148 echo '<td class="s'$raw'" align="center">'$type'</td>'>> index_draft.html
0149 echo '<td class="s'$raw'" align="center">'$timetmp2'</td>'>> index_draft.html
0150 echo '<td class="s'$raw'" align="center">'$sizetmp'</td>'>> index_draft.html
0151 echo '<td class="s'$raw'" align="center">'$neventstmp'</td>'>> index_draft.html
0152 echo '<td class="s'$raw'" align="center"><a href="'$WebSite'/CMT/GLOBAL_'$runnumber'/LumiList.html">CMT_'$runnumber'</a></td>'>> index_draft.html
0153 echo '<td class="s'$raw'" align="center"><a href="'$WebSite'/GlobalRMT/GLOBAL_'$runnumber'/MAP.html">RMT_'$runnumber'</a></td>'>> index_draft.html
0154 echo '<td class="s'$raw'" align="center">'$commentariy'</td>'>> index_draft.html
0155 
0156 
0157 rm tmp
0158 
0159 ############################################################################################################   record index_draft.html
0160 
0161 if [ ${#comment} -gt 0 ] ; then
0162     #echo "runList=${runList}, check ${runnumber}"
0163     temp_var=${runList/${runnumber}/}
0164     if [ ${#temp_var} -lt ${#runList} ] ; then
0165         echo "adding a commentary for this run"
0166         echo "<td class=\"s${raw}\" align=\"center\">${comment}</td>" >> index_draft.html
0167     fi
0168 fi
0169 echo '</tr>'>> index_draft.html
0170 prev=$i
0171 
0172 #fi
0173 done
0174 
0175 
0176 # print footer to index.html 
0177 echo `cat footer.txt`>> index_draft.html
0178 
0179 
0180 status=0
0181 if [ ${debug} == "1" ] ; then
0182     echo "debug=${debug}. No upload to eos"
0183     status=-1
0184 else
0185 ###    echo "Commented by me:  eoscp index_draft.html $WebDir/CMT/index.html No upload to eos"
0186 #  eoscp OLDindex.html $WebDir/CMT/OLDindex.html
0187 #  eoscp index_draft.html $WebDir/CMT/index.html
0188     status="$?"
0189 # rm index_draft.html
0190 fi
0191 
0192 # delete temp files
0193 
0194 if [ ${debug} == "0" ] ; then
0195 #    rm -f *.root
0196     rm -f _runlist_
0197     rm -f _runlistEOSall_
0198 fi
0199 
0200 # check eos-upload exit code
0201 if [[ "${status}" == "0" ]]; then
0202   echo "Successfully uploaded!"
0203 else
0204   echo "ERROR: Uploading failed"
0205   exit 1
0206 fi
0207 
0208 echo "index script done"