2021-12-15 18:44:12 -05:00
|
|
|
#1/bin/bash
|
|
|
|
|
2021-12-16 15:24:18 -05:00
|
|
|
DIR=$(pwd)
|
2022-01-06 16:52:59 -05:00
|
|
|
DATA_DIR=data
|
2021-12-16 15:24:18 -05:00
|
|
|
|
2022-01-06 19:29:26 -05:00
|
|
|
TIMEWINDOW=100
|
|
|
|
|
2021-12-15 18:44:12 -05:00
|
|
|
if [ $# -eq 0 ] || [ $1 == "-help" ]; then
|
2022-01-06 19:58:39 -05:00
|
|
|
echo "$./process_run [Run Folder] [Merge] [BuildEvents] [Analysis]"
|
2021-12-15 18:44:12 -05:00
|
|
|
echo " Run Folder = the name of run folder"
|
2022-01-06 16:52:59 -05:00
|
|
|
echo " Merge = 1/0/-1 || 1 = merge, 0 = not merge, -1 = force merge "
|
2022-01-06 19:58:39 -05:00
|
|
|
echo " BuildEvents = 1/0/-1 || "
|
2021-12-15 18:44:12 -05:00
|
|
|
echo " Analysis = 1/0/-1 || "
|
|
|
|
echo ""
|
2022-01-06 19:58:39 -05:00
|
|
|
|
|
|
|
ls -l --color $DATA_DIR/
|
2021-12-15 18:44:12 -05:00
|
|
|
exit 1
|
|
|
|
fi;
|
|
|
|
|
|
|
|
RunFolder=$1
|
|
|
|
|
2022-01-06 16:52:59 -05:00
|
|
|
isMerge=1
|
|
|
|
if [ $# -gt 1 ]; then isMerge=$2; fi
|
|
|
|
isBuildEvents=1
|
|
|
|
if [ $# -gt 2 ]; then isBuildEvents=$3; fi
|
2022-01-06 18:00:36 -05:00
|
|
|
isAnalysis=1
|
|
|
|
if [ $# -gt 3 ]; then isAnalysis=$4; fi
|
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'
|
|
|
|
|
2022-01-06 18:00:36 -05:00
|
|
|
if [ -f $DATA_DIR/$RunFolder/*.evt ]; then
|
|
|
|
echo -e "found evt files."
|
|
|
|
else
|
2022-01-06 19:58:39 -05:00
|
|
|
echo -e "cannot found any evt files in $DATA_DIR/$RunFolder/. Abort."
|
2022-01-06 18:00:36 -05:00
|
|
|
exit
|
|
|
|
fi
|
2021-12-16 15:24:18 -05:00
|
|
|
|
2022-01-06 16:52:59 -05:00
|
|
|
echo -e "$RED>>> `date` >>>>>>>>>>>>>>>>>>>>>>> Merge evt files to ${RunFolder}_raw.root $NC"
|
2021-12-15 18:44:12 -05:00
|
|
|
|
2022-01-06 16:52:59 -05:00
|
|
|
if [ $isMerge -eq 1 ]; then
|
|
|
|
# check is ${RunFolder}"_raw.root" exist
|
|
|
|
if [ -f ${RunFolder}_raw.root ]; then #_raw.root exist
|
|
|
|
#check evt DateTime
|
|
|
|
evtDateTime=`stat -c "%Z" $DATA_DIR/$RunFolder/*.evt | sort -rn | head -1`
|
|
|
|
rawRootDateTime=`stat -c "%Z" ${RunFolder}"_raw.root" | sort -rn | head -1`
|
|
|
|
if [ $evtDateTime -gt $rawRootDateTime ]; then #if evt file is newer
|
|
|
|
./armory/MergeEVT ${RunFolder}"_raw.root" `ls ${DATA_DIR}/${RunFolder}/*.evt`
|
2021-12-16 15:24:18 -05:00
|
|
|
else
|
2022-01-06 16:52:59 -05:00
|
|
|
echo "there is no newer evt files"
|
2021-12-15 18:44:12 -05:00
|
|
|
fi
|
2022-01-06 16:52:59 -05:00
|
|
|
|
2021-12-15 18:44:12 -05:00
|
|
|
else
|
2022-01-06 16:52:59 -05:00
|
|
|
|
|
|
|
./armory/MergeEVT ${RunFolder}"_raw.root" `ls ${DATA_DIR}/${RunFolder}/*.evt`
|
|
|
|
|
2021-12-15 18:44:12 -05:00
|
|
|
fi
|
2022-01-06 16:52:59 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $isMerge -eq 0 ]; then
|
|
|
|
echo -e "$YELLOW skipped by user $NC"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $isMerge -eq -1 ]; then
|
|
|
|
echo -e "$YELLOW forced by user $NC"
|
|
|
|
./armory/MergeEVT ${RunFolder}"_raw.root" `ls ${DATA_DIR}/${RunFolder}/*.evt`
|
|
|
|
fi
|
|
|
|
echo -e "$RED>>> `date` >>>>>>>>>>>>>>>>>>>>>>> Merge finished$NC"
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "$RED>>> `date` >>>>>>>>>>>>>>>>>>>>>>> Build Events$NC"
|
|
|
|
if [ ${isBuildEvents} -eq 1 ]; then
|
|
|
|
|
|
|
|
if [ -f ${RunFolder}.root ]; then # root exist
|
|
|
|
rawRootDateTime=`stat -c "%Z" ${RunFolder}"_raw.root" | sort -rn | head -1`
|
|
|
|
rootDateTime=`stat -c "%Z" ${RunFolder}".root" | sort -rn | head -1`
|
|
|
|
|
|
|
|
if [ ${rawRootDateTime} -gt ${rootDateTime} ]; then
|
2022-01-06 19:29:26 -05:00
|
|
|
./armory/EventBuilder ${RunFolder}"_raw.root" $TIMEWINDOW
|
2021-12-16 15:24:18 -05:00
|
|
|
else
|
2022-01-06 16:52:59 -05:00
|
|
|
echo -e "${RunFolder}.root is up-to-date."
|
|
|
|
fi
|
2021-12-15 18:44:12 -05:00
|
|
|
else
|
2022-01-06 19:29:26 -05:00
|
|
|
./armory/EventBuilder ${RunFolder}"_raw.root" $TIMEWINDOW
|
2022-01-06 16:52:59 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${isBuildEvents} -eq 0 ]; then
|
|
|
|
echo -e "$YELLOW skipped by user $NC"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ${isBuildEvents} -eq -1 ]; then
|
|
|
|
echo -e "$YELLOW forced by user $NC"
|
2022-01-06 19:29:26 -05:00
|
|
|
./armory/EventBuilder ${RunFolder}"_raw.root" $TIMEWINDOW
|
2022-01-06 16:52:59 -05:00
|
|
|
fi
|
|
|
|
echo -e "$RED>>> `date` >>>>>>>>>>>>>>>>>>>>>>> Build Events finsihed.$NC"
|
|
|
|
|
|
|
|
|
|
|
|
echo -e "$RED>>> `date` >>>>>>>>>>>>>>>>>>>>>>> Analysis $NC"
|
2022-01-06 18:00:36 -05:00
|
|
|
if [ ${isAnalysis} -eq 1 ]; then
|
|
|
|
root -l "process_run.c(\"${RunFolder}.root\")"
|
|
|
|
fi
|
2022-01-06 16:52:59 -05:00
|
|
|
|
2022-01-06 19:58:39 -05:00
|
|
|
if [ ${isAnalysis} -eq 0 ]; then
|
|
|
|
echo -e "$YELLOW skipped by user $NC"
|
|
|
|
fi
|
|
|
|
|
2022-01-06 18:00:36 -05:00
|
|
|
if [ ${isAnalysis} -eq -1 ]; then
|
|
|
|
echo -e "$YELLOW forced by user $NC"
|
|
|
|
root -l "process_run.c(\"${RunFolder}.root\")"
|
|
|
|
fi
|
2022-01-06 16:52:59 -05:00
|
|
|
|