File indexing completed on 2025-08-06 08:21:02
0001
0002 input_file=${1:-runList.txt}
0003 echo "About to submit jobs for runs in: $input_file"
0004 read -p "Continue? [y/N]: " confirm
0005 if [[ $confirm != [yY] ]]; then
0006 echo "Aborting."
0007 exit 1
0008 fi
0009 mkdir -p dstLists
0010
0011 export TargetDir="$PWD"/condorout
0012
0013
0014
0015
0016 if [ -d ${TargetDir} ]; then
0017 if [ -n "$(ls -A ${TargetDir}/OutDir*)" ]; then
0018 rm -rf ${TargetDir}/OutDir*
0019 fi
0020 else
0021 mkdir ${TargetDir}
0022 fi
0023
0024 i=0
0025 while read dir; do
0026 li=$(printf "%04d" $i)
0027
0028 rm inputdata.txt
0029 rm dst_cal*
0030 dstName="dstLists/dst_calofitting_run2pp-000${dir}.list"
0031
0032
0033 if [ -f ${dstName} ]; then
0034 cp ${dstName} inputdata.txt
0035 else
0036 echo "did not find ${dstName} getting from DB"
0037 CreateDstList.pl --build ana468 --cdb 2024p012_v001 --run ${dir} DST_CALOFITTING_run2pp
0038 cp dst_calo* inputdata.txt
0039 cp dst_calo* dstLists/.
0040 fi
0041
0042 if [ ! -s inputdata.txt ]; then
0043 echo "inputdata.txt is empty, skipping to next iteration."
0044 continue
0045 fi
0046
0047 j=50
0048
0049 tot_files=$( cat inputdata.txt | wc -l )
0050 echo "total files: $tot_files"
0051 rem=$(( $tot_files%$j ))
0052 files_per_job=$(( $tot_files/$j ))
0053 njob=$j
0054 if [ $rem -ne 0 ]; then
0055 files_per_job=$(( $files_per_job+1 ))
0056 fi
0057 rem2=$(( $tot_files%$files_per_job ))
0058 njob=$(( $tot_files/$files_per_job ))
0059 if [ $rem2 -ne 0 ]; then
0060 njob=$(( ($tot_files/$files_per_job)+1 ))
0061 fi
0062
0063
0064
0065 mkdir -p ${TargetDir}/OutDir$i
0066 export WorkDir="${TargetDir}/OutDir$i"
0067 echo "WorkDir:" ${WorkDir}
0068
0069 cat > ${WorkDir}/ff.sub <<EOF
0070 +JobFlavour = "workday"
0071 Universe = vanilla
0072 Notification = Never
0073 Priority = +12
0074 concurrency_limits =CONCURRENCY_LIMIT_DEFAULT:20
0075
0076 EOF
0077
0078 pushd ${WorkDir}
0079
0080 cp "$PWD"/../../../Fun4All_HCal.C .
0081 cp "$PWD"/../../inputdata.txt .
0082 touch DONE.txt
0083
0084 for((q=0;q<$njob;q++)); do
0085 start_file=$(( $q*$files_per_job+1 ))
0086 end_file=$(( $start_file+$files_per_job-1 ))
0087
0088
0089 sed -n $start_file\,${end_file}p inputdata.txt > ${WorkDir}/inputdata_$q.txt
0090
0091 cp "$PWD"/../../CondorRun.sh CondorRunJob${li}_$q.sh
0092 sed -i "10 a cp ${WorkDir}/inputdata_$q.txt inputdata.txt" CondorRunJob${li}_$q.sh
0093 sed -i "s/inputdata.txt/inputdata_$q.txt/g" CondorRunJob${li}_$q.sh
0094
0095
0096
0097 cat >> ${WorkDir}/ff.sub <<EOF
0098 Executable = ${WorkDir}/CondorRunJob${li}_$q.sh
0099 Output = ${WorkDir}/condor_${li}_$q.out
0100 Error = ${WorkDir}/condor_${li}_$q.errr
0101 Log = /tmp/condor_${li}_$q.log
0102 Queue
0103
0104 EOF
0105
0106 i=$((i+1))
0107 done
0108
0109 echo "submitting some condor jobs"
0110 condor_submit ff.sub
0111 popd
0112
0113 done < "$input_file"
0114
0115
0116
0117 file_directory="${TargetDir}/OutDir*/DONE.root"
0118
0119 while [ $(find condorout/OutDir* -name "DONE.txt" -print0 | xargs -0 cat | wc -l) -lt $((i)) ]; do
0120 current_file_count=$(find condorout/OutDir* -name "DONE.txt" -print0 | xargs -0 cat | wc -l)
0121 echo "Waiting for $((i)) files, currently $current_file_count"
0122 sleep 30
0123 done
0124
0125