File indexing completed on 2025-08-06 08:21:02
0001
0002
0003 export TargetDir="$PWD"/condorout
0004
0005
0006 export iter=4
0007
0008
0009 for((x=0;x<1;x++));
0010 do
0011
0012 if [ -d ${TargetDir} ]; then
0013 if [ -n "$(ls -A ${TargetDir}/OutDir*)" ]; then
0014 rm -rf ${TargetDir}/OutDir*
0015 fi
0016 else
0017 mkdir ${TargetDir}
0018 fi
0019
0020 i=0
0021
0022 while read dir; do
0023 li=$(printf "%04d" $i)
0024
0025 if [ ! -d dstLists ]; then
0026 mkdir dstLists
0027 fi
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_EMCal.C .
0081 cp "$PWD"/../../inputdata.txt .
0082 cp "$PWD"/../../local_calib_copy.root .
0083 touch DONE.txt
0084
0085 for((q=0;q<$njob;q++)); do
0086 start_file=$(( $q*$files_per_job+1 ))
0087 end_file=$(( $start_file+$files_per_job-1 ))
0088
0089
0090 sed -n $start_file\,${end_file}p inputdata.txt > ${WorkDir}/inputdata_$q.txt
0091
0092 cp "$PWD"/../../CondorRun.sh CondorRunJob${li}_$q.sh
0093
0094 sed -i "10 a cp ${WorkDir}/inputdata_$q.txt inputdata.txt" CondorRunJob${li}_$q.sh
0095 sed -i "s/inputdata.txt/inputdata_$q.txt/g" CondorRunJob${li}_$q.sh
0096 sed -i "s/iteration/$iter/g" CondorRunJob${li}_$q.sh
0097
0098
0099
0100
0101
0102 cat >> ${WorkDir}/ff.sub <<EOF
0103 Executable = ${WorkDir}/CondorRunJob${li}_$q.sh
0104 Output = ${WorkDir}/condor.out
0105 Error = ${WorkDir}/condor.err
0106 Log = /tmp/condor_${li}_$q.log
0107 Queue
0108
0109 EOF
0110
0111 i=$((i+1))
0112 done
0113
0114 echo "submitting some condor jobs"
0115 condor_submit ff.sub
0116 popd
0117
0118
0119 done < runList.txt
0120
0121
0122 file_directory="${TargetDir}/OutDir*/DONE.root"
0123
0124 while [ $(find condorout/OutDir* -name "DONE.txt" -print0 | xargs -0 cat | wc -l) -lt $((i)) ]; do
0125 current_file_count=$(find condorout/OutDir* -name "DONE.txt" -print0 | xargs -0 cat | wc -l)
0126 echo "Waiting for $((i)) files, currently $current_file_count"
0127 sleep 30
0128 done
0129
0130 sh hadd_condor.sh
0131 sleep 1200
0132
0133 export TargetHadd="$PWD"/combine_out
0134
0135 if [ ! -d ${TargetHadd} ]; then
0136 mkdir ${TargetHadd}
0137 fi
0138
0139 file_to_hadd="hadd_condor/OutDir*/out*.root"
0140
0141 hist_out=${TargetHadd}/out${iter}.root
0142
0143 rm $hist_out
0144
0145 hadd -k $hist_out $file_to_hadd
0146
0147
0148
0149 root -b "../doFitAndCalibUpdate.C(\"${hist_out}\",\"local_calib_copy.root\",$iter)"
0150
0151 iter=$((iter+1))
0152 done
0153