File indexing completed on 2024-04-06 12:06:26
0001
0002 WebDir='/eos/cms/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring'
0003 WebSite='https://cms-conddb-dev.cern.ch/eosweb/hcal/HcalRemoteMonitoring'
0004 HistoDir='/eos/cms/store/group/dpg_hcal/comm_hcal/www/HcalRemoteMonitoring/CMT/histos'
0005 eos='/afs/cern.ch/project/eos/installation/0.3.15/bin/eos.select'
0006
0007
0008 if [[ "$1" == "" ]]; then
0009 echo "Usage:"
0010 echo " $0 file [comment] [-ignore-file] [-das-cache]"
0011 echo " file -- a file with run numbers"
0012 echo " comment -- add a comment line (instead of spaces use '_')"
0013 echo " -ignore-file -- skips production of run html pages. Produces"
0014 echo " only the global page. File name is not needed."
0015 echo " -das-cache -- whether to save DAS information locally for a reuse"
0016 echo
0017 echo "example: ./GLOBAL.sh Run_List.txt"
0018 exit 1
0019 fi
0020
0021 cmsenv 2>/dev/null
0022 if [ $? == 0 ] ; then
0023 eval `scramv1 runtime -sh`
0024 fi
0025 temp_var=`ls ${eos}`
0026 status="$?"
0027 echo "using eos command <${temp_var}>"
0028 if [ ! ${status} -eq 0 ] ; then
0029 echo "failed to find eos command"
0030
0031 fi
0032
0033
0034
0035 fileName=$1
0036 comment=$2
0037 if [ ${
0038 ignoreFile=0
0039 debug=0
0040 dasCache=0
0041 DAS_DIR="d-DAS-info"
0042
0043 for a in $@ ; do
0044 if [ "$a" == "-ignore-file" ] ; then
0045 echo " ** file will be ignored"
0046 fileName=""
0047 ignoreFile=1
0048 elif [ "$a" == "-das-cache" ] ; then
0049 echo " ** DAS cache ${DAS_DIR} enabled"
0050 dasCache=1
0051 if [ ! -d ${DAS_DIR} ] ; then mkdir ${DAS_DIR}; fi
0052 else
0053 temp_var=${a/-debug/}
0054 if [ ${
0055 debug=${temp_var}
0056 echo " ** debug detected (debug=${debug})"
0057 fi
0058 fi
0059 done
0060
0061
0062 runList=""
0063 if [ ${
0064 if [ -s ${fileName} ] ; then
0065 runList=`cat ${fileName}`
0066 else
0067 echo "<${fileName}> does not seem to be a valid file"
0068 exit 2
0069 fi
0070 else
0071 if [ ${ignoreFile} -eq 0 ] ; then
0072 echo " ! no file provided"
0073 fi
0074 echo " ! will produce only the global html page"
0075 fi
0076
0077
0078
0079
0080 runList=`echo "${runList}" | sed 'sk,k\ kg' | sed 'sk;k\ kg'`
0081 ok=1
0082 for r in ${runList} ; do
0083 if [ ! ${
0084 echo "run numbers are expected to be of length 6. Check <$r>"
0085 ok=0
0086 fi
0087 debug_loc=0
0088 if [ "$r" -eq "$r" ] 2>/dev/null ; then
0089 if [ ${debug_loc} -eq 1 ] ; then echo "run variable <$r> is a number (ok)"; fi
0090 else
0091 echo "error: run variable <$r> is not an integer number"
0092 ok=0
0093 fi
0094 done
0095
0096 echo "Tested `wc -w <<< "${runList}"` runs from file ${fileName}"
0097 if [ ${ok} -eq 0 ] ; then
0098 echo "errors in the file ${fileName} with run numbers"
0099 exit 3
0100 else
0101 if [ ${
0102 echo "run numbers in ${fileName} verified ok"
0103 fi
0104 fi
0105
0106 comment=`echo ${comment} | sed sk\_k\ kg`
0107 if [ ${
0108 echo "comment \"${comment}\" will be added to the pages"
0109 fi
0110
0111 if [ ${debug} -eq 3 ] ; then exit; fi
0112
0113
0114 echo
0115 echo
0116 echo
0117 echo 'Run numbers for processing'
0118 echo "${runList}"
0119 echo -e "list complete\n"
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 histoFiles=`${eos} ls $HistoDir | grep root | awk -F '_' '{print $2}' | awk -F '.' '{print $1}'`
0134
0135
0136
0137
0138 echo -e '\n\nRun numbers to be on EOS:'
0139
0140
0141 runListEOS=`echo $histoFiles `
0142
0143
0144 echo "${runListEOS}"
0145 echo -e "list complete\n"
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160 echo 'next message is Fine because of command rm index.html: '
0161 rm index.html
0162
0163 echo 'copy index.html and OLDindex.html '
0164 eos cp $WebDir/CMT/index.html index.html
0165 cp index.html OLDindex.html
0166
0167 echo ' delete last line of copied index_draft.html which close the table'
0168 cat index.html | head -n -1 > index_draft.html
0169
0170 echo 'extract run numbers:'
0171 k=0
0172 for i in ${runListEOS} ; do
0173 let "k = k + 1"
0174 done
0175 echo ' ================>>> k in old list = '$k
0176
0177
0178
0179 k=0
0180 echo ' ================>>> starting hardcoded k = '$k
0181
0182 for i in ${runListEOS} ; do
0183
0184
0185
0186
0187 runnumber=${i}
0188 let "k = k + 1"
0189
0190 if [[ "$runnumber" > 309999 ]] ; then
0191
0192
0193
0194
0195
0196
0197 echo
0198 echo
0199 echo 'k = '$k
0200 echo 'RUN number = '$runnumber
0201
0202
0203 dasInfo=${DAS_DIR}/das_${runnumber}.txt
0204 got=0
0205 if [ ${dasCache} -eq 1 ] ; then
0206 rm -f tmp
0207 if [ -s ${dasInfo} ] ; then
0208 cp ${dasInfo} tmp
0209 got=1
0210 else
0211 echo "no ${dasInfo} found. Will use das_client.py"
0212 fi
0213 fi
0214 if [ ${got} -eq 0 ] ; then
0215 ./das_client.py --query="run=${i} | grep run.beam_e,run.bfield,run.nlumis,run.lhcFill,run.delivered_lumi,run.duration,run.start_time,run.end_time" --limit=0 > tmp
0216 if [ ${dasCache} -eq 1 ] ; then cp tmp ${dasInfo}; fi
0217 fi
0218
0219
0220 date=`cat tmp | awk '{print $7" "$8}'`
0221 date_end=`cat tmp | awk '{print $9" "$10}'`
0222 E=`cat tmp | awk '{print $1}'`
0223 B=`cat tmp | awk '{print $2}'`
0224 nL=`cat tmp | awk '{print $3}'`
0225 Fill=`cat tmp | awk '{print $4}'`
0226 dLumi=`cat tmp | awk '{print $5}'`
0227 D=`cat tmp | awk '{print $6}'`
0228 rm tmp
0229
0230
0231
0232
0233
0234
0235
0236 fileinfo=`${eos} ls -l $HistoDir/Global_$i.root`
0237 Date_obr=`echo ${fileinfo} | awk '{print $6" "$7" "$8}'`
0238 echo "Date_obr=$Date_obr"
0239
0240
0241 type='Cosmic'
0242 commentariy=''
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 echo 'RUN Start Date = '$date
0256 echo 'RUN Duration = '$D
0257 echo 'RUN End Date = '$date_end
0258 echo 'RUN Energy = '$E
0259 echo 'RUN Magnet field = '$B
0260 echo 'RUN LS number = '$nL
0261 echo 'RUN LHC Fill = '$Fill
0262 echo 'RUN Delivered Luminosity = '$dLumi
0263 echo 'RUN Date processing = '$Date_obr
0264
0265
0266
0267 let "raw = (k % 2) + 2"
0268 echo '<tr>'>> index_draft.html
0269 echo '<td class="s1" align="center">'$k'</td>'>> index_draft.html
0270 echo '<td class="s'$raw'" align="center">'$runnumber'</td>'>> index_draft.html
0271
0272 echo '<td class="s'$raw'" align="center">'$nL'</td>'>> index_draft.html
0273 echo '<td class="s'$raw'" align="center">'$Fill'</td>'>> index_draft.html
0274 echo '<td class="s'$raw'" align="center">'$date'</td>'>> index_draft.html
0275 echo '<td class="s'$raw'" align="center">'$D'</td>'>> index_draft.html
0276 echo '<td class="s'$raw'" align="center">'$date_end'</td>'>> index_draft.html
0277 echo '<td class="s'$raw'" align="center"><a href="'$WebSite'/CMT/GLOBAL_'$runnumber'/LumiList.html">CMT_'$runnumber'</a></td>'>> index_draft.html
0278 echo '<td class="s'$raw'" align="center"><a href="'$WebSite'/GlobalRMT/GLOBAL_'$runnumber'/MAP.html">RMT_'$runnumber'</a></td>'>> index_draft.html
0279 echo '<td class="s'$raw'" align="center">'$B' T</td>'>> index_draft.html
0280 echo '<td class="s'$raw'" align="center">'$E' GeV</td>'>> index_draft.html
0281
0282 echo '<td class="s'$raw'" align="center">'$Date_obr' /nb</td>'>> index_draft.html
0283 if [ ${
0284
0285 temp_var=${runList/${runnumber}/}
0286 if [ ${
0287 echo "adding a commentary for this run"
0288 echo "<td class=\"s${raw}\" align=\"center\">${comment}</td>" >> index_draft.html
0289 fi
0290 fi
0291 echo '</tr>'>> index_draft.html
0292 prev=$i
0293
0294 fi
0295
0296 done
0297
0298
0299
0300 echo `cat footer.txt`>> index_draft.html
0301
0302
0303 status=0
0304 if [ ${debug} -gt 0 ] ; then
0305 echo "debug=${debug}. No upload to eos"
0306 status=-1
0307 else
0308
0309
0310
0311
0312 status="$?"
0313
0314 fi
0315
0316
0317
0318 if [ ${debug} -eq 0 ] ; then
0319 rm -f *.root
0320 rm -f _runlist_
0321 fi
0322
0323
0324 if [[ "${status}" == "0" ]]; then
0325 echo "Successfully uploaded!"
0326 else
0327 echo "ERROR: Uploading failed"
0328 exit 1
0329 fi
0330
0331 echo "index script done"