Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:19

0001 #!/bin/bash
0002 
0003 function DoO2O(){
0004     echo -n "$runString  --  "
0005     if grep -q "$runString" $storeFile ; then
0006         echo O2O transfer already performed or not necessary
0007     else
0008       # O2O not done, let's check if it is necessary
0009         if tail -n1 $storeFile | grep -qe "`echo $runString | cut -d":" -f 2-`" ; then
0010             echo Fed and partition not changed since last IOV was opened. O2O Not necessary
0011             echo "$runString -- Not Necessary" >> $storeFile
0012         elif [ 0`tail -n1 $storeFile | awk '{print $1}'` -gt $oldRunNb ]; then
0013             echo RunNumber $oldRunNb violates append mode. last uploaded run is `tail -n1 $storeFile | awk '{print $1}'`
0014             echo -e "\n Please, to include this run, start the o2o with a new offline tag name in file $basePath/`basename $0`\nCurrent tag is $Tag"
0015             echo -e "\n--- Run skipped ----\n"
0016             return
0017         else
0018             echo Performing O2O...
0019             #echo pedmode $pedmode oldrunNb $oldRunNb oldpedmode $oldPedmode
0020             cp template_sistripo2o_multipartition.cfg $log/tmp.cfg
0021             counter=0
0022             echo $runString | sed -e "s@:Part:@\n@g" | awk '{ if(NR>1) print $0 }'| while read line;
0023             do
0024               vec=($line)
0025               partition=${vec[0]}             
0026               #echo "----------------"
0027               #echo ${vec[@]}
0028               #echo partition $partition
0029               #echo "----------------"
0030 
0031               let counter++
0032               
0033               cat  $log/tmp.cfg | sed -e "s#insert_onlineDB#$onlineDB#g" -e "s@insert_Run@$oldRunNb@g" -e "s@insert_ConfigDbPartition_$counter@$partition@g"  -e "s@insert_authPath@$authPath@" -e "s@insert_tag@$Tag@" -e "s@insert_connect_string@$connectString@" -e "s@#DO${oldPedmode}@@" -e "s@#thePart${counter}@@" -e "s@insert_logdb@$logdb@"> $log/tmp1.cfg
0034               mv $log/tmp1.cfg $log/tmp.cfg
0035             done
0036             cp $log/tmp.cfg $log/siStripO2O_$oldRunNb.cfg
0037             rm $log/tmp.cfg 
0038 
0039             if cmsRun $log/siStripO2O_$oldRunNb.cfg > $log/siStripO2O_$oldRunNb.log ; then
0040                 if [ "$oldPedmode" == "PEDESTAL" ]; then 
0041                     echo "$runString -- CabPed">> $storeFile
0042                 else
0043                     echo "$runString -- CabOnly">> $storeFile
0044                 fi
0045             else
0046                 echo ERROR in O2O performing. EXIT!
0047                 echo check log file `pwd`/$log/siStripO2O_$oldRunNb.log
0048                 doExit="true"
0049             fi
0050         fi
0051     fi
0052 }
0053 
0054 ##################################################
0055 ######## MAIN
0056 #####################################
0057 
0058 
0059 cd `dirname $0`
0060 basePath=`pwd`
0061 
0062 [ -e "LockFile" ] && echo -e "\n Lock File already exists. \nProbably a process is already running. \nOtherwise, please remove the lockFile from $basePath/LockFile" && exit
0063 LOCKFILE=`pwd`/LockFile
0064 ERRORLOCKFILE="/tmp/o2o-error-`date +%Y%m%d%H%M`"
0065 touch $LOCKFILE
0066 touch $ERRORLOCKFILE 
0067 trap "rm -f $LOCKFILE" EXIT
0068 
0069 source /nfshome0/cmssw2/scripts/setup.sh
0070 cd /raid/cmssw/Development/O2O/CMSSW_2_0_8/src/
0071 eval `scramv1 runtime -sh`
0072 cd $basePath
0073 
0074 preTag=TKCC_20X
0075 postTag=v3_hlt
0076 Tag=${preTag}_${postTag}
0077 authPath=/nfshome0/xiezhen/conddb/
0078 #authPath=/afs/cern.ch/cms/DB/conddb
0079 onlineDB="cms_trk_tkcc/tkcc2008@cms_omds_lb"
0080 connectString="oracle://cms_orcon_prod/CMS_COND_20X_STRIP"
0081 #connectString="oracle://cms_orcoff_int2r/CMS_COND_STRIP"
0082 #connectString="sqlite_file:dbfile.db"
0083 #logdb="sqlite_file:log.db"
0084 #logdb="oracle://omds/CMS_POP_CON"
0085 logdb="oracle://cms_orcon_prod/CMS_COND_21X_POPCONLOG"
0086 storeFile="/raid/cmssw/Development/O2O/store/doneRuns_${preTag}_${postTag}"
0087 doExit="false"
0088 
0089 touch $storeFile
0090 
0091 log=log_at_P5_$Tag
0092 #rm -rf $log
0093 mkdir $log
0094 
0095 export TNS_ADMIN=/nfshome0/xiezhen/conddb 
0096 
0097 #sqlplus -S -M "HTML ON " $onlineDB < OMDSQuery.sql
0098 
0099 oldRunNb=-1
0100 oldPedmode=blablabla
0101 runString=""
0102 
0103 sqlplus -S -M "HTML ON " $onlineDB < OMDSQuery_multipartition.sql | awk 'BEGIN{newline=0; stringa=""} $0~/<*th.*>/{newline=0} $0~/<tr>/{newline=1;if(stringa!="") print stringa; stringa=""} $0~/<\/tr>/{newline=0;} $0!~/<?td.*>/{if(newline && $0!="<tr>"){stringa=sprintf("%s %s",stringa,$0)}} END{print "99999999999999 LATENCY"}' | sort -n| while read line;
0104 do
0105 vec=($line)
0106 
0107 echo -e "----------------\n${vec[@]}\n----------------"
0108 #echo $runNb $partition $fecV $fedV $cabV
0109 
0110 runNb=${vec[0]}
0111 mode=${vec[1]}
0112 partition=${vec[2]}
0113 fecV=${vec[3]}
0114 fedV=${vec[4]}
0115 cabV=${vec[5]}
0116 dcuV=${vec[6]}
0117 
0118 if [ "$mode" == "LATENCY" ] || [ "$mode" == "PHYSIC" ]; then
0119     runVer=":Part: $partition $cabV $fedV $dcuV"
0120     pedmode="PEDESTAL"
0121 else
0122     continue
0123     runVer=":Part: $partition $cabV XXX $dcuV"
0124     pedmode="blablabla"
0125 fi
0126 
0127 if [ "$oldRunNb" != "$runNb" ]; then
0128     if [ "$oldRunNb" != "-1" ]; then
0129      #No other equal partitions
0130         #echo "------------------------>" doO2O for $runString 
0131         DoO2O
0132     fi
0133     runString="$runNb $mode"
0134     oldRunNb=$runNb
0135     oldPedmode=$pedmode
0136 fi
0137 runString="$runString $runVer"
0138 
0139 
0140 [[ "$doExit" != "false" ]] && break
0141 
0142 
0143 echo ""
0144 
0145 done
0146 
0147 echo ""
0148 
0149 rm -f $LOCKFILE
0150 rm -f $ERRORLOCKFILE