2023-04-04 14:47:44 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ -z $SOLARISANADIR ]; then
|
|
|
|
echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh."
|
|
|
|
echo "better add \"source <path_to_SOLARIS.sh>\" into .bashrc"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -ne 3 ] || [ $1 == "-help" ]; then
|
|
|
|
echo "$ Process_EventBuilder [RunNum] [EventBuild] [timeWin]"
|
|
|
|
echo " RunNum = run number"
|
|
|
|
echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace"
|
|
|
|
echo " timeWin = number of tick for an event "
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
fi;
|
|
|
|
|
2023-03-31 16:08:06 -04:00
|
|
|
RUN=$1
|
|
|
|
EventBld=$2
|
2023-04-04 14:47:44 -04:00
|
|
|
timeWin=$3
|
|
|
|
|
|
|
|
source ${SOLARISANADIR}/armory/Process_BasicConfig
|
|
|
|
source ${SOLARISANADIR}/working/expName.sh
|
|
|
|
|
|
|
|
runNum=${RUN#0} #remove zero
|
|
|
|
RUN=$(printf '%03d' $runNum) ##add back the zero
|
2023-03-31 16:08:06 -04:00
|
|
|
|
2023-04-04 14:47:44 -04:00
|
|
|
rawDataPath=$SOLARISANADIR/data_raw
|
|
|
|
rootDataPath=$SOLARISANADIR/root_data
|
2023-03-31 16:08:06 -04:00
|
|
|
|
2023-04-04 14:47:44 -04:00
|
|
|
rawDataPattern="$rawDataPath/${expName}_${RUN}_*.sol"
|
|
|
|
rootDataName="$rootDataPath/run$RUN.root"
|
2023-03-31 16:08:06 -04:00
|
|
|
|
|
|
|
dir=$(pwd)
|
|
|
|
cd ${SOLARISANADIR}/armory
|
|
|
|
make
|
|
|
|
cd ${dir}
|
|
|
|
|
|
|
|
#==== check raw data exist
|
|
|
|
isRawDataExist=`ls -1 ${rawDataPattern}* 2>/dev/null | wc -l`
|
|
|
|
|
|
|
|
if [ ! $isRawDataExist -gt 0 ]; then
|
2023-04-04 14:47:44 -04:00
|
|
|
echo -e "${LRED}################# Run Data $rawDataPattern not exist. Abort. ${NC}"
|
2023-03-31 16:08:06 -04:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "${CYAN} ============== list of files ${NC}"
|
|
|
|
\du -h ${rawDataPattern}*
|
|
|
|
|
|
|
|
totSize=$(\du -hc ${rawDataPattern}* | tail -n 1 | awk '{print $1}')
|
|
|
|
echo -e "${CYAN} ============== total file size : ${totSize}${NC}"
|
|
|
|
|
|
|
|
|
|
|
|
#==== check raw data timeStamp
|
|
|
|
if [ ${Arch} == "Linux" ]; then
|
|
|
|
rawDataTime=`stat -c "%Z" ${rawDataPattern}* | sort -rn | head -1`
|
|
|
|
else
|
2023-04-04 14:47:44 -04:00
|
|
|
rawDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rawDataPattern | sort -rn | head -1`
|
2023-03-31 16:08:06 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
#==== check if root data exist
|
|
|
|
isRootDataExist=`ls -1 $rootDataName 2>/dev/null | wc -l`
|
|
|
|
|
2023-04-04 14:47:44 -04:00
|
|
|
#==== if root data exist, check timeStamp
|
2023-03-31 16:08:06 -04:00
|
|
|
if [ ${isRootDataExist} -gt 0 ]; then
|
|
|
|
if [ ${Arch} == "Linux" ]; then
|
|
|
|
rootDataTime=`stat -c "%Z" $rootDataName | sort -rn | head -1`
|
|
|
|
else
|
|
|
|
rootDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rootDataName | sort -rn | head -1`
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
rootDataTime=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ${EventBld} -eq 0 ]; then
|
|
|
|
|
|
|
|
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building Skipped by user. ${NC}"
|
|
|
|
|
|
|
|
elif [ ${EventBld} -ge 1 ]; then
|
|
|
|
|
|
|
|
if [ ${rawDataTime} -ge ${rootDataTime} ]; then
|
|
|
|
|
|
|
|
echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building $(date) ${NC}"
|
|
|
|
if [ ${EventBld} -eq 1 ]; then
|
2023-04-04 14:47:44 -04:00
|
|
|
EventBuilder $rootDataName ${timeWin} 0 $rawDataPattern
|
2023-03-31 16:08:06 -04:00
|
|
|
elif [ ${EventBld} -eq 2 ]; then
|
2023-04-04 14:47:44 -04:00
|
|
|
EventBuilder $rootDataName ${timeWin} 1 $rawDataPattern
|
2023-03-31 16:08:06 -04:00
|
|
|
fi
|
|
|
|
echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}"
|
|
|
|
|
|
|
|
else
|
2023-04-04 14:47:44 -04:00
|
|
|
echo -e "${GREEN} root data are newer than raw data. No need to merged again.${NC}"
|
2023-03-31 16:08:06 -04:00
|
|
|
echo -e "${GREEN}You can Force merging using option -${EventBld}, ${ORANGE} see ./process_run.sh -help${NC}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo -e "${LRED}>>>>>>>>>>>>>>> Force Event Building $(date) ${NC}"
|
|
|
|
if [ ${EventBld} -eq -1 ]; then
|
2023-04-04 14:47:44 -04:00
|
|
|
EventBuilder $rootDataName ${timeWin} 0 $rawDataPattern
|
2023-03-31 16:08:06 -04:00
|
|
|
elif [ ${EventBld} -eq -2 ]; then
|
2023-04-04 14:47:44 -04:00
|
|
|
EventBuilder $rootDataName ${timeWin} 1 $rawDataPattern
|
2023-03-31 16:08:06 -04:00
|
|
|
fi
|
|
|
|
echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}"
|
|
|
|
|
|
|
|
fi
|