XIAEventBuilder/process_run

107 lines
2.6 KiB
Plaintext
Raw Normal View History

2021-12-15 18:44:12 -05:00
#1/bin/bash
DIR=$(pwd)
DATA_DIR=fsu_run_2021
sortTime=$DIR/$DATA_DIR/pxi-time-order
2021-12-15 18:44:12 -05:00
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
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'
2021-12-16 10:30:38 -05:00
#cd $RunFolder
2021-12-15 18:44:12 -05:00
#ls -lhtr *.evt
2021-12-16 10:30:38 -05:00
cd $DATA_DIR/$RunFolder
2021-12-15 18:44:12 -05:00
fileList=$(ls *.evt)
numFile=$(ls -lhtr *.evt | wc -l)
count=0
2021-12-16 10:30:38 -05:00
cd $DIR
2021-12-15 18:44:12 -05:00
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
2021-12-16 10:30:38 -05:00
evtDateTime=`stat -c "%Z" $DATA_DIR/$RunFolder/$a | sort -rn | head -1`
istoExist=`ls -1 $a.to 2> /dev/null | wc -l`
2021-12-15 18:44:12 -05:00
if [ ${istoExist} -gt 0 ]; then
echo "--- found $a.to"
2021-12-15 18:44:12 -05:00
toDateTime=`stat -c "%Z" $a.to | sort -rn | head -1`
if [ ${evtDateTime} -ge ${toDateTime} ]; then
$sortTime $DATA_DIR/$RunFolder/$a
2021-12-15 18:44:12 -05:00
else
echo "$a.to is generated after $a. skip."
fi
else
echo "cannot find $a.to, sort"
$sortTime $DATA_DIR/$RunFolder/$a
2021-12-15 18:44:12 -05:00
fi
elif [ $TimeSort -eq 0 ]; then
echo "skipped time sort by user."
else
echo "force Time sort"
$sortTime $DATA_DIR/$RunFolder/$a
2021-12-15 18:44:12 -05:00
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 2> /dev/null | wc -l`
2021-12-15 18:44:12 -05:00
if [ ${isRootExist} -gt 0 ]; then
echo "--- found $rootFile"
2021-12-15 18:44:12 -05:00
rootDateTime=`stat -c "%Z" $rootFile | sort -rn | head -1`
if [ ${toDateTime} -ge ${rootDateTime} ]; then
$DIR/pixie2root $a.to
2021-12-15 18:44:12 -05:00
else
echo "$rootFile is generated after $a.to skip."
fi
else
echo "cannot find $rootFile, build events"
$DIR/pixie2root $a.to
2021-12-15 18:44:12 -05:00
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)
2021-12-15 18:44:12 -05:00
cd $DIR