L rich copyped

From Hall A Wiki
Jump to: navigation, search

copyped.sh:

#!/bin/bash
#
# Copy pedestals files from replay dir to
# pedestal daq dir and to a backup dir
#
 
indir=/adaqfs/home/adaq/transversity/rich/leftreplay
 
infile1=rich_ped_bottom.dat
infile2=rich_ped_top.dat
 
logfile=save/log.txt
 
lrun=`lastrun | grep latest | awk -F "_" '{print $2}' | awk -F "." '{print $1}'` 
echo "... coping ped files ..."
 
for ifile in ${infile1} ${infile2}; do
 
    inpath=${indir}/${ifile}
 
    dmon=`ls -l ${inpath} | awk '{print $6}'`
    dday=`ls -l ${inpath} | awk '{print $7}'`
    drun=`awk 'NR==1 {print $13}' ${inpath}`
    dsgg=`awk 'NR==1 {print $16}' ${inpath}`
    dsig=`echo "scale=2; ${dsgg}/1." | bc -l`
 
    odir=save/${dmon}${dday}_${lrun}_${dsig}
 
    mkdir -p ${odir}
    cp ${inpath} ${odir}/${ifile}
 
    cp ${inpath} ./${ifile}
 
#    sleep 1
 
    dada=`date +"%Y/%m/%d %T"`
 
    len=`wc -l ./${ifile} | awk '{print $1}'`
 
#    echo "File: $ifile copied from $indir to ./ and $odir"
    echo "[ $dada | ${lrun} ] new $ifile ($odir)" >>$logfile
    echo "File ${ifile} copied, actual length = ${len} [must be 9601]"
done
 
echo "you can now start a production run ... ! remind the prescales ! ..."