nCore=10; if [ $# -eq 0 ]; then echo "Usage: " echo " ./convertPixie.sh [RUNNUM]" exit; fi runNum=$1 ls -lh rawdata/run${runNum}/run*evt 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=pixie_evt/pixie-${runPrefix}${runNum}-${segPrefix}${SegNum}.evt if [[ -f ${outFileName} ]]; then echo "${outFileName} exist. Skip." else echo ${fileName} ./nscl2pixie_haha ${fileName} ${outFileName} & fi ((j += 1)) done sleep 1 while true; do nthings=`ps aux | grep "[n]scl2pixie_haha"| wc -l` echo $(date)" || "$nthings" nscl2pixie_haha are running." if [[ $nthings > 0 ]]; then sleep 10; else break fi done ((i += 1)) done #Pixiefiles=$(ls -1 evt_data/pixie-0${run}*.evt) #for a in ${Pixiefiles} #do # echo ${a} # echo ${a:15:7} # ./armory/MergeEVT root_data/run-${a:15:7}_raw.root ${a} #done