81 lines
1.8 KiB
Bash
Executable File
81 lines
1.8 KiB
Bash
Executable File
|
|
nCore=10;
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: "
|
|
echo " ./convertRoot.sh [Start_RunNum] [Stop_RunNum]"
|
|
exit;
|
|
fi
|
|
|
|
runNum1=$1
|
|
|
|
runNum2=$2
|
|
|
|
for (( runNum=${runNum1}; runNum <=${runNum2}; runNum++)); do
|
|
|
|
nFile=$(ls -1 rawdata/run${runNum}/run*evt | wc -l)
|
|
files=$(ls -1 rawdata/run${runNum}/run*evt)
|
|
|
|
nLoop=$((${nFile}/nCore+1))
|
|
|
|
echo "===== number of files in run-${runNum} = ${nFile}"
|
|
echo " number of loops = ${nLoop}"
|
|
echo "================================================="
|
|
|
|
i=0
|
|
while [[ $i -lt ${nLoop} ]]; do
|
|
|
|
j=0
|
|
while [[ $j -lt ${nCore} ]]; do
|
|
SegNum=$((${nCore}*i+j))
|
|
|
|
if [[ ${SegNum} -ge ${nFile} ]]; then break; fi
|
|
|
|
#patching the prefix ZERO
|
|
if [ $runNum -lt 10 ]; then
|
|
runPrefix="000"
|
|
elif [ $runNum -lt 100 ]; then
|
|
runPrefix="00"
|
|
elif [ $runNum -lt 1000 ]; then
|
|
runPrefix="0"
|
|
fi
|
|
|
|
#patching the prefix ZERO for segment
|
|
if [ $SegNum -lt 10 ]; then
|
|
segPrefix="0"
|
|
else
|
|
segPrefix=""
|
|
fi
|
|
|
|
fileName=rawdata/run${runNum}/run-${runPrefix}${runNum}-${segPrefix}${SegNum}.evt
|
|
outFileName=root_data/run-${runPrefix}${runNum}-${segPrefix}${SegNum}.root
|
|
if [[ -f ${outFileName} ]]; then
|
|
echo "${outFileName} exist. Skip."
|
|
else
|
|
echo ${fileName}
|
|
armory/EventBuilder ${outFileName} 1 250 ${fileName} > /dev/null &
|
|
fi
|
|
((j += 1))
|
|
done
|
|
|
|
sleep 2
|
|
|
|
SegNum0=$((${nCore}*i))
|
|
SegNum1=$((${nCore}*i + j ))
|
|
|
|
while true; do
|
|
nthings=`ps aux | grep "[E]ventBuilder"| wc -l`
|
|
echo $(date)" || "$nthings" EventBuilder are running. $runNum, ${SegNum0}-${SegNum1}"
|
|
|
|
if [[ $nthings > 0 ]]; then
|
|
sleep 10;
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
((i += 1))
|
|
done
|
|
|
|
done
|