Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:29:13

0001 #!/bin/bash
0002 
0003 USAGE="Usage: `basename $0` NrOfEvents MinimumEnergy MaximumEnergy Tag"
0004 
0005 case $# in
0006 4)
0007         MAXEVENTS=$1
0008         MINIMUM_ENERGY=$2
0009         MAXIMUM_ENERGY=$3
0010         TAG=$4
0011         ;;
0012 *)
0013         echo $USAGE; exit 1;
0014         ;;
0015 esac
0016 
0017 # directory where the job is run or submitted
0018 if [ "${LS_SUBCWD+set}" = set ]; then
0019    LK_WKDIR="${LS_SUBCWD}" # directory where you submit in case of bsub
0020    WWDIR="${WORKDIR}"
0021 else
0022    LK_WKDIR=`pwd`          # directory where you run locally otherwise
0023    WWDIR=`pwd`
0024 fi
0025 
0026 #
0027 TEMPLATE_CFG="${LK_WKDIR}/template_pion_cfg.py"
0028 OUTPUT="output_${MAXEVENTS}_${MINIMUM_ENERGY}_${MAXIMUM_ENERGY}_${TAG}"
0029 CFGFILE=${WWDIR}/${OUTPUT}_cfg.py
0030 NTUPLEFILE=${WWDIR}/${OUTPUT}.eventNtuple.root
0031 POOLOUTPUTFILE=${WWDIR}/${OUTPUT}.pool.root
0032 LOGFILE=${WWDIR}/${OUTPUT}.log
0033 #
0034 CASTOR_DIR="/castor/cern.ch/user/h/hvanhaev/CMSSW_3_3_0_pre2/pions"
0035 rfdir $CASTOR_DIR/${OUTPUT}.eventNtuple.root 2>/dev/null
0036 return_val=$?
0037 if [ $return_val -eq 0 ]; then
0038   echo "castor file $CASTOR_DIR/${OUTPUT}.eventNtuple.root exists, delete it first. Stopping here!"
0039   exit 1;
0040 fi
0041 #
0042 if [ -e $CFGFILE ]; then
0043    echo "The cfg file $CFGFILE already exists. Stopping here!"
0044    exit 1;
0045 fi
0046 
0047 #
0048 #
0049 DIR_WHERE_TO_EVAL="/afs/cern.ch/user/h/hvanhaev/scratch0/CMSSW_3_3_0_pre2/src"
0050 
0051 # random numbers
0052 RAND_sourceSeed=`head -c4 /dev/urandom | od -N3 -tu4 | sed -ne '1s/.* //p'`
0053 RAND_VtxSmeared=`head -c4 /dev/urandom | od -N3 -tu4 | sed -ne '1s/.* //p'`
0054 RAND_g4SimHits=`head -c3 /dev/urandom  | od -N1 -tu4 | sed -ne '1s/.* //p'`
0055 RAND_mix=`head -c4 /dev/urandom        | od -N2 -tu4 | sed -ne '1s/.* //p'`
0056 RAND_generator=`head -c4 /dev/urandom  | od -N3 -tu4 | sed -ne '1s/.* //p'`
0057 
0058 cat $TEMPLATE_CFG | perl -p -e "s@MAXEVENTS@$MAXEVENTS@" | perl -p -e "s@POOLOUTPUTFILE@$POOLOUTPUTFILE@"  | perl -p -e "s@RAND_VtxSmeared@$RAND_VtxSmeared@" | perl -p -e "s@RAND_generator@$RAND_generator@"| perl -p -e "s@RAND_g4SimHits@$RAND_g4SimHits@" | perl -p -e "s@RAND_mix@$RAND_mix@" | perl -p -e "s@RAND_sourceSeed@$RAND_sourceSeed@" | perl -p -e "s@NTUPLEFILE@$NTUPLEFILE@" | perl -p -e "s@MAXIMUM_ENERGY@$MAXIMUM_ENERGY@" | perl -p -e "s@MINIMUM_ENERGY@$MINIMUM_ENERGY@"   > $CFGFILE
0059 
0060 cd $DIR_WHERE_TO_EVAL; eval `scramv1 runtime -sh`; cd -;
0061 cmsRun $CFGFILE > $LOGFILE 2>&1
0062 return_val=$?
0063 if [ $return_val -eq 0 ]; then
0064   rfcp $CFGFILE $CASTOR_DIR/
0065   rfcp $POOLOUTPUTFILE $CASTOR_DIR/
0066   rfcp $NTUPLEFILE $CASTOR_DIR/
0067 fi
0068