Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:40

0001 #!/bin/bash
0002 
0003 if [ $# -lt 3 ]
0004 then
0005      echo "Error, usage is:"
0006      echo "SplitAndRun.sh N K Q (WD)"
0007      echo "Where"
0008      echo "  - N  is the total number of events"
0009      echo "  - K  is the number of events per job"
0010      echo "  - Q  is the name of the queue where the jobs will be submitted"
0011      echo "  - WD is the dir where \"cmsenv\" is done"
0012      echo "       (optional, default is \"pwd\")"
0013      exit
0014 fi
0015 
0016 N=$1
0017 K=$2
0018 Q=$3
0019 WDir=`pwd`
0020 if [ $# -eq 4 ]
0021 then
0022     WDir=$4
0023 fi
0024 
0025 let "NJOBS=$N/$K"
0026 if [ $NJOBS -eq 0 ]
0027 then
0028     echo "Error: N($N) < K($K). Total events must be >= number of events per job"
0029 fi
0030 
0031 DirName="`pwd`/StatErrors_`\date +%y%m%d"_"%H%M%S`"
0032 if [ ! -d $DirName ]
0033 then
0034     mkdir $DirName
0035 fi
0036 
0037 echo "Creating and submitting $NJOBS new jobs to queue $Q"
0038 
0039 for i in `seq $NJOBS`
0040 do
0041     echo "Creating and submitting job $i..."
0042     let "skip=$K*($i-1)"
0043     #mkdir -p Job_$i
0044     cat TreeSplitter_cfg.py | sed s/SUBSAMPLEFIRSTEVENT/${skip}/g | sed s/SUBSAMPLEMAXEVENTS/$K/g | sed s/MAXEVENTS/$N/g > ${DirName}/TreeSplitter_${i}_cfg.py
0045     cat singleJob.lsf | sed s?TEMPLATECMSDIR?${WDir}?g | sed s?TEMPLATEOUTDIR?${DirName}?g | sed s?JOBINDEX?${i}?g > ${DirName}/singleJob_${i}.lsf
0046     cd ${DirName}
0047     chmod +x singleJob_${i}.lsf
0048     bsub -o tmp_${i}.log -q ${Q} singleJob_${i}.lsf
0049     cd -
0050 done