Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:13

0001 #!/bin/sh
0002 
0003 # L1Trigger O2O - set IOVs
0004 
0005 
0006 nflag=0
0007 oflag=""
0008 fflag=""
0009 xflag=""
0010 while getopts 'nofxh' OPTION
0011   do
0012   case $OPTION in
0013       n) nflag=1
0014           ;;
0015       o) oflag="-o"
0016           ;;
0017       f) fflag="-f"
0018           ;;
0019       x) xflag="-x"
0020           ;;
0021       h) echo "Usage: [-n] runnum L1_KEY"
0022           echo "  -n: no RS"
0023           echo "  -o: overwrite RS keys"
0024           echo "  -f: force IOV update"
0025           echo "  -x: write to DB instead of local file"
0026           exit
0027           ;;
0028   esac
0029 done
0030 shift $(($OPTIND - 1))
0031 
0032 # arguments
0033 run=$1
0034 l1Key=$2
0035 
0036 release=CMSSW_7_4_2
0037 workdir=/nfshome0/l1emulator/run2/o2o/v7/
0038 version=015
0039 
0040 logfile=${workdir}/o2o-setIOV-${version}.log
0041 summaryfile=${workdir}/o2o-summary
0042 lockfile=o2o-setIOV.lock
0043 
0044 
0045 echo "`date` : o2o-setIOV-l1Key.sh $run $l1Key" | tee -a ${logfile}
0046 echo "`uptime`" | tee -a ${logfile}
0047 START=$(date +%s)
0048 
0049 if [ $# -lt 2 ]
0050     then
0051     echo "Wrong number of arguments.  Usage: $0 [-n] runnum L1_KEY" | tee -a ${logfile}
0052     exit 127
0053 fi
0054 
0055 # setup CMSSW
0056 source /data/cmssw/cmsset_default.sh
0057 cd ${workdir}/${release}
0058 cmsenv
0059 cd ../o2o/
0060 SCRIPTS=${workdir}/${release}/src/CondTools/L1TriggerExt/scripts
0061 
0062 # Check for semaphore file
0063 if [ -f ${lockfile} ]
0064     then
0065     echo "$0 already running.  Aborting process."  | tee -a ${logfile}
0066     echo "$0 already running.  Aborting process."  1>&2
0067     tail -4 ${logfile} >> ${summaryfile}
0068     exit 50
0069 else
0070     touch $lockfile
0071 fi
0072 
0073 # Delete semaphore and exit if any signal is trapped
0074 # KILL signal (9) is not trapped even though it is listed below.
0075 trap "rm -f ${lockfile}; mv tmp.log tmp.log.terminated; exit" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
0076 
0077 # run script; args are run key
0078 rm -f tmp.log
0079 echo "`date`" >& tmp.log
0080 
0081 # Check if o2o-tscKey.sh is running.  If so, wait 15 seconds to prevent simultaneous writing ot ORCON.
0082 if [ -f o2o-tscKey.lock ]
0083     then
0084     echo "o2o-tscKey.sh currently running.  Wait 15 seconds...." >> tmp.log 2>&1
0085     sleep 15
0086     echo "Resuming process." >> tmp.log 2>&1
0087 fi
0088 
0089 
0090 o2ocode2=0
0091 
0092 if [ ${nflag} -eq 0 ]
0093     then
0094     echo "`date` : setting RS keys and IOVs" >> tmp.log 2>&1
0095     ${SCRIPTS}/runL1-O2O-rs-keysFromL1Key.sh ${xflag} ${oflag} ${fflag} ${run} ${l1Key} >> tmp.log 2>&1
0096     o2ocode2=$?
0097 fi
0098 
0099 echo "`date` : setting TSC IOVs" >> tmp.log 2>&1
0100 tscKey=`$CMSSW_BASE/src/CondTools/L1Trigger/scripts/getKeys.sh -t ${l1Key}`
0101 echo "`date` : parsed tscKey = ${tscKey}" >> tmp.log 2>&1
0102 $SCRIPTS/runL1-O2O-iov.sh ${xflag} ${oflag} ${fflag} ${run} ${tscKey} >> tmp.log 2>&1
0103 o2ocode1=$?
0104 
0105 tail -2 ${logfile} >> ${summaryfile}
0106 
0107 # Filter CORAL debug output into different file, which gets deleted if no errors
0108 grep -E "CORAL.*Info|CORAL.*Debug" tmp.log >& coraldebug-${run}.log
0109 grep -Ev "CORAL.*Info|CORAL.*Debug" tmp.log | tee -a ${logfile}
0110 #cat tmp.log | tee -a /nfshome0/popcondev/L1Job/o2o-setIOV-${version}.log
0111 
0112 # log TSC key and RS keys
0113 echo "runNumber=${run} tscKey=${tscKey}" >> ./keylogs/tsckeys.txt
0114 
0115 if [ ${nflag} -eq 0 ]
0116 then
0117     grep KEYLOG tmp.log | sed 's/KEYLOG //' >> ./keylogs/rskeys.txt
0118 fi
0119 
0120 rm -f tmp.log
0121 
0122 echo "cmsRun status (TSC) ${o2ocode1}" | tee -a ${logfile} 
0123 echo "cmsRun status (RS) ${o2ocode2}" | tee -a ${logfile}
0124 o2ocode=`echo ${o2ocode1} + ${o2ocode2} | bc`
0125 
0126 if [ ${o2ocode} -eq 0 ]
0127 then
0128     echo "L1-O2O-INFO: o2o-setIOV-l1Key-slc5.sh successful"
0129     rm -f coraldebug-${run}.log
0130 else
0131     if [ ${o2ocode1} -eq 90 -o ${o2ocode2} -eq 90 ]
0132         then
0133         echo "L1-O2O-ERROR: problem with Oracle databases."
0134         echo "L1-O2O-ERROR: problem with Oracle databases." 1>&2
0135     else
0136         echo "L1-O2O-ERROR: o2o-setIOV-l1Key-slc5.sh failed!"
0137         echo "L1-O2O-ERROR: o2o-setIOV-l1Key-slc5.sh failed!" 1>&2
0138     fi
0139 fi
0140 
0141 echo "`date` : o2o-setIOV-l1Key-slc5.sh finished : ${run} ${l1Key}" | tee -a ${logfile}
0142 
0143 END=$(date +%s)
0144 DIFF=$(( $END - $START ))
0145 if [ ${DIFF} -gt 60 ]
0146     then
0147     echo "O2O SLOW: `date`, ${DIFF} seconds for ${run} ${l1Key}" | tee -a ${logfile}
0148 else
0149     echo "Time elapsed: ${DIFF} seconds" | tee -a ${logfile}
0150 fi
0151 echo "" | tee -a ${logfile}
0152 
0153 tail -6 ${logfile} >> ${summaryfile}
0154 
0155 # Delete semaphore file
0156 rm -f ${lockfile}
0157 
0158 exit ${o2ocode}