Back to home page

Project CMSSW displayed by LXR

 
 

    


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