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 - validate TSC key, and write it to ORCON called by cron job on l1-o2o.cms
0004 
0005 # Run as l1emulator on machine with frontier squids enabled.  Check with `rpm -qa | grep squid`.
0006 # Should have a line with STABLE, e.g. squid-2.7.STABLE7-frontiercmshlt2
0007 
0008 pflag=0
0009 while getopts 'ph' OPTION
0010   do
0011   case $OPTION in
0012       p) pflag=1
0013           ;;
0014       h) echo "Usage: [-p]"
0015           echo "  -p: centrally installed release, not on local machine"
0016           exit
0017           ;;
0018   esac
0019 done
0020 shift $(($OPTIND - 1))
0021 
0022 #==============================================================================
0023 # Environment
0024 #==============================================================================
0025 
0026 release=CMSSW_4_2_3_ONLINE
0027 # Emulator cannot run in online releases because of missing packages
0028 #emulatorRelease=CMSSW_3_11_0
0029 emulatorRelease=CMSSW_4_2_3
0030 version=011
0031 
0032 #==============================================================================
0033 # File containing TSC keys that have been tested and written (+ status)
0034 #==============================================================================
0035 
0036 # writtenFile=~zrwan/CMSSW_3_5_0/cronjob/writtenTscKeys.txt
0037 writtenFile=~popcondev/L1Job/${release}/validate-l1Key/writtenTscKeys.txt
0038 
0039 #==============================================================================
0040 # Summary file
0041 #==============================================================================
0042 
0043 #summaryFile=~zrwan/CMSSW_3_5_0/cronjob/o2o.summary
0044 summaryFile=/nfshome0/popcondev/L1Job/o2o.summary
0045 
0046 #==============================================================================
0047 # Log file
0048 #==============================================================================
0049 
0050 #logFile=~zrwan/CMSSW_3_5_0/cronjob/validate-l1Key-${version}.log
0051 logFile=/nfshome0/popcondev/L1Job/validate-l1Key-${version}.log
0052 
0053 #==============================================================================
0054 # Check for semaphore file
0055 #==============================================================================
0056 
0057 semaphoreFile=/nfshome0/popcondev/L1Job/${release}/validate-l1Key/validate-l1Key.lock
0058 
0059 if [ -f ${semaphoreFile} ]
0060     then
0061     echo "`date` : validate-l1Key.sh" >> ${logFile}
0062     echo "$0 already running.  Aborting process.  Check for hung jobs from previous call of validate-l1Key.sh."  | tee -a ${logFile}
0063     tail -3 ${logFile} >> /nfshome0/popcondev/L1Job/o2o.summary
0064     exit 50
0065 else
0066     touch ${semaphoreFile}
0067 fi
0068 
0069 # Delete semaphore and exit if any signal is trapped
0070 # KILL signal (9) is not trapped even though it is listed below.
0071 trap "rm -f ${semaphoreFile}; mv /nfshome0/popcondev/L1Job/${release}/validate-l1Key/temp.log /nfshome0/popcondev/L1Job/${release}/validate-l1Key/temp.log.save; mv /nfshome0/popcondev/L1Job/${emulatorRelease}/validate-l1Key/temp.log /nfshome0/popcondev/L1Job/${emulatorRelease}/validate-l1Key/temp.log.save; 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
0072 
0073 #==============================================================================
0074 # Set up environment
0075 #==============================================================================
0076 
0077 #cd ~zrwan/CMSSW_3_5_0/cronjob
0078 cd /nfshome0/popcondev/L1Job/${release}/validate-l1Key
0079 
0080 if [ ${pflag} -eq 0 ]
0081     then
0082     export SCRAM_ARCH=""
0083     export VO_CMS_SW_DIR=""
0084     source /opt/cmssw/cmsset_default.sh
0085 else
0086     source /nfshome0/cmssw2/scripts/setup.sh
0087     centralRel="-p"
0088 fi
0089 eval `scramv1 run -sh`
0090 
0091 #==============================================================================
0092 # Find next key to be tested and written
0093 #==============================================================================
0094 
0095 if [ ! -f ${writtenFile} ]
0096     then
0097     touch ${writtenFile}
0098 fi
0099 
0100 #for KEY in `~zrwan/CMSSW_3_5_0/cronjob/getValidTscKeys.sh`
0101 for KEY in `$CMSSW_BASE/src/CondTools/L1Trigger/scripts/getValidTscKeys.sh`
0102 do
0103   if [ -z "${tsc_key}" ]
0104       then
0105       last=`grep ${KEY} writtenTscKeys.txt`
0106       if [ -n "${last}" ]
0107           then
0108           status=`echo ${last} | cut -f 2 -d ' '`
0109           #  echo "Key ${KEY} already written and validated: status ${status}"
0110       else
0111           #  echo "Setting tsc_key ${KEY}"
0112           tsc_key=${KEY}
0113       fi
0114   fi
0115 done
0116 
0117 if [ -z "${tsc_key}" ]
0118     then
0119     # echo "No new keys to write and test." >> ${summaryFile}
0120     rm -f ${semaphoreFile}
0121     exit 0
0122 fi
0123 
0124 #==============================================================================
0125 # Start testing and writing new key
0126 #==============================================================================
0127 
0128 echo "`date` : validate-l1Key.sh" >> ${logFile}
0129 echo "tsc_key = ${tsc_key}" >> ${logFile}
0130 echo "O2O release ${release}$" >> ${logFile}
0131 
0132 #==============================================================================
0133 # 0. Write TSC payloads.  Decoupled from validation (for now) b/c of timing.
0134 #==============================================================================
0135 
0136 /nfshome0/l1emulator/o2o/o2o-tscKey-slc5.sh ${tsc_key}
0137 o2ocode3=$?
0138 
0139 if [ ${o2ocode3} -eq 0 ]
0140     then
0141     writeStatus="successful"
0142 else
0143     writeStatus="failed"
0144 fi
0145 
0146 #==============================================================================
0147 # 1. Copy conditions for a given TSC key from online database to a sqlite file
0148 #==============================================================================
0149 
0150 rm -f temp.log
0151 
0152 $CMSSW_BASE/src/CondTools/L1Trigger/scripts/getConditions.sh -n ${centralRel} ${tsc_key} >& temp.log
0153 o2ocode1=$?
0154 
0155 cat temp.log >> ${logFile}
0156 rm -f temp.log
0157 
0158 echo "getConditions status ${o2ocode1}" >> ${logFile}
0159 echo "" >> ${logFile}
0160 
0161 #==============================================================================
0162 # 2. Copy a raw data file from castor
0163 #==============================================================================
0164 
0165 # Assume Raw.root is under the current directory
0166 
0167 #==============================================================================
0168 # 3. Test with emulator
0169 #==============================================================================
0170 
0171 if [ ${o2ocode1} -eq 0 ]
0172     then
0173     echo "Running emulator job in ${emulatorRelease}" >> ${logFile}
0174     cd /nfshome0/popcondev/L1Job/${emulatorRelease}/validate-l1Key
0175     ln -sf /nfshome0/popcondev/L1Job/${release}/validate-l1Key/l1config.db .
0176     ln -sf /nfshome0/popcondev/L1Job/${release}/validate-l1Key/Raw.root .
0177 
0178     export SCRAM_ARCH=slc5_amd64_gcc434
0179     #export VO_CMS_SW_DIR=""
0180     source /nfshome0/cmssw2/scripts/setup.sh
0181 
0182     eval `scramv1 run -sh`
0183     ln -sf $CMSSW_BASE/src/CondTools/L1Trigger/test/validate-l1Key.py .
0184     cmsRun validate-l1Key.py >& temp.log
0185     o2ocode2=$?
0186 
0187     cat temp.log >> ${logFile}
0188     rm -f temp.log
0189 
0190     echo "emulator status ${o2ocode2}" >> ${logFile}
0191     echo "" >> ${logFile}
0192 fi
0193 
0194 #==============================================================================
0195 # 4. Clean up
0196 #==============================================================================
0197 
0198 #rm -f ~zrwan/CMSSW_3_5_0/cronjob/l1config.db
0199 rm -f /nfshome0/popcondev/L1Job/${release}/validate-l1Key/l1config.db
0200 
0201 o2ocode=`echo ${o2ocode1} + ${o2ocode2} | bc`
0202 
0203 echo "tsc_key = ${tsc_key}" >> ${logFile}
0204 echo "getConditions status ${o2ocode1}" >> ${logFile}
0205 echo "emulator status ${o2ocode2}" >> ${logFile}
0206 echo "exit code ${o2ocode}" >> ${logFile}
0207 if [ ${o2ocode} -eq 0 ]
0208     then
0209     echo "L1-O2O-INFO: successful" >> ${logFile}
0210     validationStatus="successful"
0211 else
0212     echo "L1-O2O-INFO: failed" >> ${logFile}
0213     validationStatus="failed"
0214 #    writeStatus="failed"
0215 fi
0216 echo "`date` : validate-l1Key.sh finished" >> ${logFile}
0217 
0218 tail -6 ${logFile} >> ${summaryFile}
0219 echo "" >> ${logFile}
0220 
0221 ##==============================================================================
0222 ## 5. If key is validated, call O2O payload-writing script
0223 ##==============================================================================
0224 #
0225 #if [ ${o2ocode} -eq 0 ]
0226 #    then
0227 #    /nfshome0/l1emulator/o2o/o2o-tscKey-slc5.sh ${tsc_key}
0228 #    o2ocode3=$?
0229 #
0230 #    if [ ${o2ocode3} -eq 0 ]
0231 #       then
0232 #       writeStatus="successful"
0233 #    else
0234 #       writeStatus="failed"
0235 #    fi
0236 
0237     o2ocode=`echo ${o2ocode} + ${o2ocode3} | bc`
0238 #fi
0239 
0240 echo "${tsc_key} ${validationStatus} ${writeStatus}" >> ${writtenFile}
0241 
0242 # Delete semaphore file
0243 rm -f ${semaphoreFile}
0244 
0245 exit ${o2ocode}