#!/bin/bash function usage() { echo "Usage: ./kstudysim3.bash [-o ] " echo " where is the index of the subset" echo " of events to simulate in this job. The output" echo " is written to kstudysim_.hddm where" echo " is added to if it is given." exit 1 } nthreads=1 nevents=10000 datadir=/home/www/docs/halld/kstudy-4-2020 source setup.sh offset=0 process=none while [ $# -gt 0 ]; do if echo $1 | grep -q -- '-'; then if [ "$1" = "-o" ]; then offset=$2 shift; shift else usage fi else process=$1 break fi done if [ "$process" = "none" ]; then usage else process=`expr $process + $offset` fi random_sequence=`expr $process + 1` random_numbers=`awk '{if(NR=='$random_sequence'){print}}' randoms` echo Running process $process on `hostname -s` sed -i "s/^HADR.*/HADR 1/" control.in sed -i "s/^TRIG.*/TRIG $nevents/" control.in sed -i "s/^RNDM.*/RNDM $random_numbers/" control.in sed -i "s/^OUTF.*/OUTFILE 'kstudysim.hddm'/" control.in if [ $process -ge 300 -a $process -lt 400 ]; then skip=`expr \( $process - 300 \) \* 10000` sed -i "s/^cINFI.*/INFILE 'gen.hddm'/" control.in sed -i "s/^SKIP.*/SKIP $skip/" control.in rm -f gen.hddm && ln -s $datadir/pauligen.hddm gen.hddm elif [ $process -ge 700 -a $process -lt 800 ]; then skip=`expr \( $process - 700 \) \* 10000` sed -i "s/^cINFI.*/INFILE 'gen.hddm'/" control.in sed -i "s/^SKIP.*/SKIP $skip/" control.in rm -f gen.hddm && ln -s $datadir/nilangagen.hddm gen.hddm else sed -i "s/^INFI.*/cINFILE 'gen.hddm'/" control.in fi runno=`awk '/^RUN/{print $2}' control.in` hdgeant -xml=ccdb://GEOMETRY/main_HDDS.xml,run=$runno retcode=$? if [ $retcode = 0 ]; then mv kstudysim.hddm kstudysim3_$process.hddm else exit $retcode fi