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