95 lines
2.3 KiB
Plaintext
95 lines
2.3 KiB
Plaintext
|
#1/bin/bash
|
||
|
|
||
|
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
||
|
echo "$./process_run [Run Folder] [Time Sort] [EventBuild] [Analysis]"
|
||
|
echo " Run Folder = the name of run folder"
|
||
|
echo " Time Sort = 1/0/-1 || 1 = sort, 0 = not sort, -1 = force sort "
|
||
|
echo " EventBuild = 1/0/-1 || "
|
||
|
echo " Analysis = 1/0/-1 || "
|
||
|
echo ""
|
||
|
exit 1
|
||
|
fi;
|
||
|
|
||
|
RunFolder=$1
|
||
|
|
||
|
TimeSort=1
|
||
|
if [ $# -gt 1 ]; then TimeSort=$2; fi
|
||
|
EventBuild=1
|
||
|
if [ $# -gt 2 ]; then EventBuild=$3; fi
|
||
|
|
||
|
DIR=$(pwd)
|
||
|
|
||
|
|
||
|
RED='\033[1;31m'
|
||
|
YELLOW='\033[1;33m'
|
||
|
ORANGE='\033[0;33m'
|
||
|
GREEN='\033[1;32m'
|
||
|
BLUE='\033[0;34m'
|
||
|
Cyan='\033[0;36m'
|
||
|
NC='\033[0m'
|
||
|
|
||
|
cd $RunFolder
|
||
|
#ls -lhtr *.evt
|
||
|
fileList=$(ls *.evt)
|
||
|
numFile=$(ls -lhtr *.evt | wc -l)
|
||
|
count=0
|
||
|
|
||
|
for a in $fileList
|
||
|
do
|
||
|
count=$((${count}+1))
|
||
|
echo -e "$YELLOW>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ["$count"/"$numFile"]"
|
||
|
echo -e $a
|
||
|
echo -e "------------------------------------------$NC"
|
||
|
|
||
|
#............ check if *.to file exist, if yes, check timestamp, if timestamp is eariler, sort time
|
||
|
|
||
|
if [ $TimeSort -eq 1 ]; then
|
||
|
evtDateTime=`stat -c "%Z" $a | sort -rn | head -1`
|
||
|
istoExist=`ls -1 $a.to | wc -l`
|
||
|
if [ ${istoExist} -gt 0 ]; then
|
||
|
echo "found $a.to"
|
||
|
toDateTime=`stat -c "%Z" $a.to | sort -rn | head -1`
|
||
|
if [ ${evtDateTime} -ge ${toDateTime} ]; then
|
||
|
$DIR/pxi-time-order $a
|
||
|
else
|
||
|
echo "$a.to is generated after $a. skip."
|
||
|
fi
|
||
|
fi
|
||
|
elif [ $TimeSort -eq 0 ]; then
|
||
|
echo "skipped time sort by user."
|
||
|
else
|
||
|
echo "force Time sort"
|
||
|
$DIR/pxi-time-order $a
|
||
|
fi
|
||
|
|
||
|
|
||
|
#............ check if *.root file exist, if yes, check timestamp, if timestamp is eariler, built
|
||
|
|
||
|
if [ $EventBuild -eq 1 ]; then
|
||
|
len=`echo $a | wc -c`
|
||
|
len=$(($len-5))
|
||
|
rootFile=${a:0:$len}".root"
|
||
|
isRootExist=`ls -1 $rootFile | wc -l`
|
||
|
if [ ${isRootExist} -gt 0 ]; then
|
||
|
echo "found $rootFile"
|
||
|
rootDateTime=`stat -c "%Z" $rootFile | sort -rn | head -1`
|
||
|
if [ ${toDateTime} -ge ${rootDateTime} ]; then
|
||
|
$DIR/pixie2root $a.to
|
||
|
else
|
||
|
echo "$rootFile is generated after $a.to skip."
|
||
|
fi
|
||
|
fi
|
||
|
elif [ $TimeSort -eq 0 ]; then
|
||
|
echo "skipped event build by user."
|
||
|
else
|
||
|
echo "force event build"
|
||
|
$DIR/pixie2root $a.to
|
||
|
fi
|
||
|
|
||
|
done
|
||
|
|
||
|
fileList=$(ls *.root)
|
||
|
|
||
|
|
||
|
cd $DIR
|