#!/bin/ksh # -------------------------------------------------------------------- # extractDetector: # patchy step to extract the Detector data file # # -------------------------------------------------------------------- cmd=`basename $0` usage="usage: $cmd [-hn] CarFile DetectorFile" # version='pro' allopt=$@ while getopts hn xopt ; do case $xopt in n) version='dev' ;; h) # help message: echo $cmd script extracts a "detector file" from the ".car" file echo given as the first argument. echo 'It is possible to force the search for the DEV version ' echo 'explicitely by specifying the "n" option switch. ' echo echo 'The detector file is written in the working directory where' echo 'the script is executed and its name is given' echo ' by the second argument with the ".dat" extension.' echo echo 'The "CarFile" argument should be the file name only, ' echo 'excluding the directory path.' echo echo Switches \(optional\): echo -h prints this help message echo -n use the "dev" path for CAR file search \(default: pro \) echo --------------------------------------------------------------- echo $usage exit 9;; \?) echo unknown option $xopt; echo $usage; exit 9;; esac done shift `expr $OPTIND - 1 ` if [ $# -le 1 ]; then echo file argument missing echo $usage exit 9 fi OPSYS=${OPSYS:=`uname`} # carfile=`basename $1 .car` detfile=`basename $2 .dat` # USER=${USER:=`whoami`} log=`date`" $USER $cmd $allopt" echo $log echo " operating system: " $OPSYS # # cdir=`pwd` wdir="/afs/cern.ch/user/d/diracww/public/offline/ariane/${version}" cd ${wdir} echo "working directory: " $wdir # cd ${wdir}/car if [ -f ${detfile}.dat.bak ]; then rm ${detfile}.dat.bak ; fi if [ -f ${detfile}.dat ]; then mv ${detfile}.dat ${detfile}.dat.bak ; fi # #------------------------------------------------------------------- # Run patchy nypatchy <<! - - tty tty - - ${detfile} - - - - .go +exe. +use,p= TitlesData. +pam,12,t=attach,t=cards. $carfile +quit ! # move the detector file to the current directory cd ${cdir} echo "The file ${detfile}.dat will be located in the $cdir diractory" if [ -f ${detfile}.dat.bak ]; then rm ${detfile}.dat.bak ; fi if [ -f ${detfile}.dat ]; then mv ${detfile}.dat ${detfile}.dat.bak ; fi mv ${wdir}/car/${detfile}.dat $cdir #