97 lines
2.2 KiB
Bash
Executable File
97 lines
2.2 KiB
Bash
Executable File
|
|
nCore=15;
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: "
|
|
echo " ./convertRoot.sh [Start_RunNum] [Stop_RunNum]"
|
|
exit;
|
|
fi
|
|
|
|
runNum1=$1
|
|
runNum2=$2
|
|
|
|
overWrite=0
|
|
if [[ ${runNum1} -lt 0 ]]; then
|
|
overWrite=1
|
|
runNum1=$(( ${runNum1} * (-1) ))
|
|
fi
|
|
if [[ ${runNum2} -lt 0 ]]; then
|
|
overWrite=1
|
|
runNum2=$(( ${runNum2} * (-1) ))
|
|
fi
|
|
|
|
echo "is overWrite : ${overWrite} | ${runNum1} ${runNum2}"
|
|
|
|
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 [[ ${overWrite} -gt 0 ]]; then
|
|
echo ${fileName}
|
|
armory/EventBuilder ${outFileName} 1 250 ${fileName} > /dev/null &
|
|
else
|
|
if [[ -f ${outFileName} ]]; then
|
|
echo "${outFileName} exist. Skip."
|
|
else
|
|
echo ${fileName}
|
|
armory/EventBuilder ${outFileName} 1 250 ${fileName} > /dev/null &
|
|
fi
|
|
fi
|
|
((j += 1))
|
|
done
|
|
|
|
sleep 2
|
|
|
|
SegNum0=$((${nCore}*i))
|
|
SegNum1=$((${nCore}*i + j - 1 ))
|
|
|
|
while true; do
|
|
nthings=`ps aux | grep "armory/[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
|