Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:58

0001 #!/bin/bash
0002 
0003 pkgdir="$CMSSW_BASE/src/Alignment/HIPAlignmentAlgorithm/"
0004 curdir=$(pwd)
0005 
0006 hpname=$1
0007 niter=$2
0008 linkhp=$3
0009 
0010 commoncfg="$curdir/$4"
0011 aligncfg="$curdir/$5"
0012 trkselcfg="$curdir/$6"
0013 
0014 lstfile="$curdir/$7"
0015 iovfile="$curdir/$8"
0016 
0017 kinitial=$KRB5CCNAME
0018 kcachein=${kinitial#FILE:}
0019 #kticket="`pwd`/screen_kerberost_cache"
0020 kticket="${kcachein}_copy"
0021 
0022 echo "Copy Kerberos ticket for screen session to $kticket"
0023 cp $kcachein $kticket
0024 export KRB5CCNAME=$kticket
0025 
0026 #kinit #-l 25h -r 5d  # Ticket for 25 hours renewable for 5 days 
0027 #echo "Obtaining AFS token"
0028 #aklog
0029 
0030 krenew -b -t -K 60
0031 
0032 extraopts=""
0033 if [[ "$9" != "" ]];then
0034   extraopts="$9"
0035 fi
0036 
0037 extraopts=${extraopts//\"} # Needed to drop \" if present
0038 echo "Extra arguments: $extraopts"
0039 
0040 proceed=1
0041 if [ ! -d $trkselcfg ];then
0042   echo "$trkselcfg does not exist or is not a directory!"
0043   let proceed=0
0044 fi
0045 if [ ! -f $commoncfg ];then
0046   echo "$commoncfg does not exist or is not a file!"
0047   let proceed=0
0048 fi
0049 if [ ! -f $aligncfg ];then
0050   echo "$aligncfg does not exist or is not a file!"
0051   let proceed=0
0052 fi
0053 if [ ! -f $lstfile ];then
0054   echo "$lstfile does not exist or is not a file!"
0055   let proceed=0
0056 fi
0057 if [ ! -f $iovfile ];then
0058   echo "$iovfile does not exist or is not a file!"
0059   let proceed=0
0060 fi
0061 
0062 outdir="$curdir/../Jobs/$hpname"
0063 emailList=$(git config user.email)
0064 if [ $proceed -eq 1 ];then
0065   uinput=""
0066   if [ -d $outdir ];then
0067     while [[ "$uinput" == "" ]];do
0068       echo "$outdir exists. Rewrite? (y/n)"
0069       read uinput
0070     done
0071     if [[ "$uinput" == "y" ]];then
0072       rm -rf $outdir
0073     fi
0074   fi
0075   mkdir -p $outdir
0076   (
0077     cd $pkgdir
0078     eval `scramv1 runtime -sh`
0079     krenew -t -K 10 -- batchHippy.py --niter=$niter --outdir=$outdir --lstfile=$lstfile --iovfile=$iovfile --trkselcfg=$trkselcfg --commoncfg=$commoncfg --aligncfg=$aligncfg --sendto="$emailList" $extraopts
0080     krenew -t -H 60
0081   )
0082 fi
0083 
0084 dbname="alignments_iter$niter.db"
0085 fname="$outdir/$dbname"
0086 
0087 if [ ! -f $fname ];then
0088   if ! [ -z $emailList ]; then
0089     mail -s $hpname $emailList <<< "$hpname/$dbname is not done."
0090   fi
0091 else
0092   if [[ "$hpname" == *"Monitor"* ]];then
0093     if ! [ -z $emailList ]; then
0094       mail -s $hpname $emailList <<< "$hpname/$dbname is done. Monitor jobs cannot be linked."
0095     fi
0096   else
0097     (
0098       cd $outdir
0099       cp $dbname "alignments_iter$(echo $niter + 1 | bc).db"
0100       sqlite3 alignments_iter$(echo $niter + 1 | bc).db 'update iov set since=1'
0101       mkdir -p /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HipPy/alignments/$linkhp
0102       for a in *.db; do
0103         ln -s $(readlink -f $a) /afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN2/HipPy/alignments/$linkhp/
0104       done
0105     )
0106 
0107     if ! [ -z $emailList ]; then
0108       mail -s $hpname $emailList <<< "$hpname/$dbname is done. Linking to $linkhp"
0109     fi
0110 
0111   fi
0112 fi
0113 
0114 kdestroy -c $kticket