Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:08

0001 #!/bin/tcsh
0002 
0003 echo  "Job started at "
0004 \date;
0005 
0006 if ($#argv < 2) then
0007     echo "************** Argument Error: at least 2 arg. required **************"
0008     echo "*   Usage:                                                           *"
0009     echo "*     ./PVValidationSubmitter.csh <TagFile.dat> <taskname> <options> *"
0010     echo "*                                                                    *"
0011     echo "*   Options:                                                         *"
0012     echo "*   --dryRun             do not submit the job to lxbatch            *"
0013     echo "**********************************************************************"
0014     exit 1
0015 endif
0016 
0017 set inputsource=$1
0018 set taskname=$2
0019 set options=$3
0020 
0021 echo "Submitting validation for file $inputsource with $options in task $taskname"
0022 
0023 source /afs/cern.ch/cms/caf/setup.csh
0024 
0025 setenv CMSSW_DIR ${CMSSW_BASE}/src/Alignment/OfflineValidation/test/
0026 setenv LXBATCH_DIR `pwd`
0027 
0028 cd $CMSSW_DIR
0029 eval `scramv1 runtime -csh`
0030 cd $LXBATCH_DIR
0031 
0032 cp ${inputsource} .
0033 
0034 set jobname=`more ${inputsource} | grep jobname | awk '{print $2}'`
0035 set isda=`more ${inputsource} | grep isda | awk '{print $2}'`
0036 set ismc=`more ${inputsource} | grep ismc | awk '{print $2}'`
0037 set runcontrol=`more ${inputsource} | grep runcontrol | awk '{print $2}'`
0038 set runnumber=`more ${inputsource} | grep runnumber | awk '{print $2}'` 
0039 set applybows=`more ${inputsource} | grep applybows | awk '{print $2}'`
0040 set applycorrs=`more ${inputsource} | grep applycorrs | awk '{print $2}'`
0041 set filesource=`more ${inputsource} | grep filesource | awk '{print $2}'`
0042 set datasetpath=`more ${inputsource} | grep datasetpath | awk '{print $2}'`
0043 set maxevents=`more ${inputsource} | grep maxevents | awk '{print $2}'`
0044 set globaltag=`more ${inputsource} | grep globaltag | awk '{print $2}'`
0045 set allFromGT=`more ${inputsource} | grep allFromGT | awk '{print $2}'`
0046 set alignobj=`more ${inputsource} | grep alignobj | awk '{print $2}'`
0047 set taggeom=`more ${inputsource} | grep taggeom | awk '{print $2}'`
0048 set apeobj=`more ${inputsource} | grep apeobj | awk '{print $2}'`
0049 set tagape=`more ${inputsource} | grep tagape | awk '{print $2}'`
0050 set bowsobj=`more ${inputsource} | grep bowsobj | awk '{print $2}'`
0051 set tagbows=`more ${inputsource} | grep tagbows | awk '{print $2}'`
0052 set tracktype=`more ${inputsource} | grep tracktype | awk '{print $2}'`
0053 set vertextype=`more ${inputsource} | grep vertextype | awk '{print $2}'`
0054 set lumilist=`more ${inputsource} | grep lumilist | awk '{print $2}'`
0055 set ptcut=`more ${inputsource} | grep ptcut | awk '{print $2}'`
0056 set outfile=`more ${inputsource} | grep outfile | awk '{print $2}'`
0057 
0058 if(${ismc} == "") then 
0059     set ${ismc} = "False"
0060 endif
0061 
0062 cp ${CMSSW_DIR}/PVValidation_TEMPL_cfg.py .
0063 cat PVValidation_TEMPL_cfg.py | sed "s?ISDATEMPLATE?${isda}?g" | sed "s?ISMCTEMPLATE?${ismc}?g" | sed "s?RUNCONTROLTEMPLATE?${runcontrol}?g"  | sed "s?RUNBOUNDARYTEMPLATE?${runnumber}?g" | sed "s?APPLYBOWSTEMPLATE?${applybows}?g" | sed "s?EXTRACONDTEMPLATE?${applycorrs}?g" | sed "s?FILESOURCETEMPLATE?${filesource}?g" | sed "s?USEFILELISTTEMPLATE?False?g" | sed "s?DATASETTEMPLATE?${datasetpath}?g" | sed "s?MAXEVENTSTEMPLATE?${maxevents}?g" | sed "s?GLOBALTAGTEMPLATE?${globaltag}?g"  | sed "s?ALLFROMGTTEMPLATE?${allFromGT}?g" | sed "s?ALIGNOBJTEMPLATE?${alignobj}?g" | sed "s?GEOMTAGTEMPLATE?${taggeom}?g" | sed "s?APEOBJTEMPLATE?${apeobj}?g" | sed "s?ERRORTAGTEMPLATE?${tagape}?g" | sed "s?TRACKTYPETEMPLATE?${tracktype}?g" | sed "s?OUTFILETEMPLATE?${outfile}?g" | sed "s?VERTEXTYPETEMPLATE?${vertextype}?g" | sed "s?LUMILISTTEMPLATE?${lumilist}?g" | sed "s?PTCUTTEMPLATE?${ptcut}?g" >! ${jobname}_cfg
0064 if(${applybows} == "True") then
0065     cat ${jobname}_cfg | sed "s?BOWSOBJECTTEMPLATE?${bowsobj}?g" | sed "s?BOWSTAGTEMPLATE?${tagbows}?g"  >! ${jobname}_cfg.py
0066     rm ${jobname}_cfg
0067 else 
0068     mv ${jobname}_cfg ${jobname}_cfg.py
0069 endif 
0070 
0071 cp ${CMSSW_DIR}/PVValidation_TEMPL.lsf .
0072 cat PVValidation_TEMPL.lsf | sed  "s?JOBNAMETEMPLATE?${jobname}?g" | sed "s?OUTFILETEMPLATE?${outfile}?g" >! ${jobname}.lsf
0073 
0074 if (! -d  ${CMSSW_DIR}/submittedCfg) then
0075     mkdir ${CMSSW_DIR}/submittedCfg
0076     cp ${jobname}_cfg.py  ${CMSSW_DIR}/submittedCfg/
0077     cp ${jobname}.lsf     ${CMSSW_DIR}/submittedCfg/
0078 else
0079     echo "${CMSSW_DIR}/submittedCfg already exists"
0080     cp ${jobname}_cfg.py  ${CMSSW_DIR}/submittedCfg/
0081     cp ${jobname}.lsf     ${CMSSW_DIR}/submittedCfg/
0082 endif
0083 
0084 if(${options} != "--dryRun") then
0085  echo "cmsRun ${jobname}_cfg.py"
0086  cmsRun ${jobname}_cfg.py >& ${jobname}.out;
0087 
0088  echo "Content of working directory is: "
0089  \ls -lrt
0090 
0091  set reply=`eos find -d /store/caf/user/$USER/Alignment/PVValidation/${taskname}`
0092  set word=`echo $reply |awk '{split($0,a," "); print a[1]}'`
0093 
0094  if(${word} == "") then
0095  echo "Creating folder $taskname"
0096     eos mkdir /store/caf/user/$USER/Alignment/PVValidation/${taskname} 
0097  else 
0098     echo "Sorry /store/caf/user/$USER/Alignment/PVValidation/${taskname} already exists!"
0099  endif
0100 
0101  if (! -d  ${CMSSW_DIR}/test/PVValResults) then
0102      mkdir ${CMSSW_DIR}/PVValResults
0103      eos cp -f ${outfile} /store/caf/user/$USER/Alignment/PVValidation/${taskname}
0104      cp ${jobname}.out ${CMSSW_DIR}/PVValResults 
0105  else     
0106      eos cp -f ${outfile} /store/caf/user/$USER/Alignment/PVValidation/${taskname}
0107      cp ${jobname}.out ${CMSSW_DIR}/PVValResults 
0108  endif
0109 endif
0110 
0111 echo  "Job ended at "
0112 \date;
0113 
0114 exit 0