Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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=2
0090 
0091 ########################################## type by hands number of new runs k=k-number:
0092 #let "k = k - 1"
0093 echo ' ================>>>    k in old list = '$k
0094 
0095 for i in ${runListEOS} ; do
0096  
0097 #runnumber=$(echo $i | sed -e 's/[^0-9]*//g')
0098 #runnumber=$(echo $i | awk -F 'run' '{print $2}'| awk -F '.' '{print $1}')
0099 runnumber=${i}
0100 #if [[ "$runnumber" > 243400 ]] ; then
0101 let "k = k + 1"
0102 echo
0103 echo ' ================>>> new k in loop = '$k
0104 echo
0105 echo
0106 echo 'RUN number = '$runnumber
0107 
0108 # extract the date of file
0109 dasInfo=${DAS_DIR}/das_${runnumber}.txt
0110 got=0
0111 if [ ${dasCache} -eq 1 ] ; then
0112     rm -f tmp
0113     if [ -s ${dasInfo} ] ; then
0114         cp ${dasInfo} tmp
0115         got=1
0116     else
0117         echo "no ${dasInfo} found. Will use dasgoclient"
0118     fi
0119 fi
0120 
0121 if [ ${got} -eq 0 ] ; then
0122 #dasgoclient  --query="file dataset=/HcalNZS/Run2018D-v1/RAW  run=${i} | grep file.size, file.nevents, file.modification_time "  > tmp
0123 dasgoclient  --query="file dataset=/HIHcalNZS/HIRun2018A-v1/RAW  run=${i} | grep file.size, file.nevents, file.modification_time "  > tmp
0124 fi
0125 
0126 
0127 timetmp=`cat tmp | head -n 1  | awk '{print $3}'`
0128 ############################################################################################################
0129 type='ZeroBias'
0130 timetmp2=`date -d @${timetmp} +%Y-%m-%d:%H-%M-%S`
0131 sizetmp=`cat tmp | head -n 1  | awk '{print $1}'`
0132 neventstmp=`cat tmp | head -n 1  | awk '{print $2}'`
0133 commentariy='era HI test'
0134 #cat runs_info
0135 echo 'RUN Type = '$type
0136 echo ${sizetmp} ${neventstmp} ${timetmp2}
0137 echo 'RUN Comment = '$commentariy
0138 
0139 
0140 
0141 #adding entry to list of file index_draft.html
0142 let "raw = (k % 2) + 2"
0143 echo '<tr>'>> index_draft.html
0144 echo '<td class="s1" align="center">'$k'</td>'>> index_draft.html
0145 echo '<td class="s'$raw'" align="center">'$runnumber'</td>'>> index_draft.html
0146 echo '<td class="s'$raw'" align="center">'$type'</td>'>> index_draft.html
0147 echo '<td class="s'$raw'" align="center">'$timetmp2'</td>'>> index_draft.html
0148 echo '<td class="s'$raw'" align="center">'$sizetmp'</td>'>> index_draft.html
0149 echo '<td class="s'$raw'" align="center">'$neventstmp'</td>'>> index_draft.html
0150 echo '<td class="s'$raw'" align="center"><a href="'$WebSite'/CMT/GLOBAL_'$runnumber'/LumiList.html">CMT_'$runnumber'</a></td>'>> index_draft.html
0151 echo '<td class="s'$raw'" align="center"><a href="'$WebSite'/GlobalRMT/GLOBAL_'$runnumber'/MAP.html">RMT_'$runnumber'</a></td>'>> index_draft.html
0152 echo '<td class="s'$raw'" align="center">'$commentariy'</td>'>> index_draft.html
0153 
0154 
0155 rm tmp
0156 
0157 ############################################################################################################   record index_draft.html
0158 
0159 if [ ${#comment} -gt 0 ] ; then
0160     #echo "runList=${runList}, check ${runnumber}"
0161     temp_var=${runList/${runnumber}/}
0162     if [ ${#temp_var} -lt ${#runList} ] ; then
0163         echo "adding a commentary for this run"
0164         echo "<td class=\"s${raw}\" align=\"center\">${comment}</td>" >> index_draft.html
0165     fi
0166 fi
0167 echo '</tr>'>> index_draft.html
0168 prev=$i
0169 
0170 #fi
0171 done
0172 
0173 
0174 # print footer to index.html 
0175 echo `cat footer.txt`>> index_draft.html
0176 
0177 
0178 status=0
0179 if [ ${debug} -gt 0 ] ; then
0180     echo "debug=${debug}. No upload to eos"
0181     status=-1
0182 else
0183 ###    echo "Commented by me:  eoscp index_draft.html $WebDir/CMT/index.html No upload to eos"
0184 #  eoscp OLDindex.html $WebDir/CMT/OLDindex.html
0185 #  eoscp index_draft.html $WebDir/CMT/index.html
0186     status="$?"
0187 # rm index_draft.html
0188 fi
0189 
0190 # delete temp files
0191 
0192 if [ ${debug} -eq 0 ] ; then
0193 #    rm -f *.root
0194     rm -f _runlist_
0195     rm -f _runlistEOSall_
0196 fi
0197 
0198 # check eos-upload exit code
0199 if [[ "${status}" == "0" ]]; then
0200   echo "Successfully uploaded!"
0201 else
0202   echo "ERROR: Uploading failed"
0203   exit 1
0204 fi
0205 
0206 echo "index script done"