XIAEventBuilder/process_run

96 lines
2.4 KiB
Plaintext
Raw Normal View History

2021-12-15 18:44:12 -05:00
#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)
2021-12-16 10:30:38 -05:00
DATA_DIR=fsu_run_2021
2021-12-15 18:44:12 -05:00
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`
2021-12-15 18:44:12 -05:00
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
2021-12-16 10:30:38 -05:00
$DIR/$DATA_DIR/pxi-time-order $a
2021-12-15 18:44:12 -05:00
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"
2021-12-16 10:30:38 -05:00
$DATA_DIR/pxi-time-order $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 | wc -l`
if [ ${isRootExist} -gt 0 ]; then
echo "found $rootFile"
rootDateTime=`stat -c "%Z" $rootFile | sort -rn | head -1`
if [ ${toDateTime} -ge ${rootDateTime} ]; then
2021-12-16 10:30:38 -05:00
$DATA_DIR/pixie2root $a.to
2021-12-15 18:44:12 -05:00
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