File indexing completed on 2025-10-16 08:23:42
0001
0002
0003
0004 if [[ $USER == "sphnxpro" ]]
0005 then
0006 source /opt/sphenix/core/bin/sphenix_setup.sh -n new
0007 TOPDIR=/sphenix/u/sphnxpro/chiu/new_2025/CALIBPRODUCTION/
0008
0009 tobedonedir=${TOPDIR}/SUBMITTED.$(date +"%Y%m%d%H%M")
0010
0011 SUBMITDIR=${tobedonedir}
0012 elif [[ $USER == "chiu" ]]
0013 then
0014 TOPDIR=/sphenix/user/chiu/sphenix_bbc/run2025/CALIBPRODUCTION/lists
0015 tobedonedir=${TOPDIR}/SUBMITTED.$(date +"%Y%m%d%H%M")
0016 SUBMITDIR=/sphenix/user/chiu/sphenix_bbc/run2025/CALIBPRODUCTION/
0017 fi
0018
0019 mkdir ${tobedonedir}
0020 cd ${tobedonedir}
0021
0022
0023
0024 tmp_runsfile=${TOPDIR}/allrunsraw.txt
0025 min_runnumber=66457
0026 max_runnumber=99999
0027 psql -U phnxrc -h sphnxdaqdbreplica.sdcc.bnl.gov -c "select runnumber,eventsinrun,ertimestamp-brtimestamp from run where runnumber>= $min_runnumber and runnumber <= $max_runnumber and runtype='physics' and eventsinrun >= 100000 and EXTRACT(EPOCH FROM (ertimestamp-brtimestamp)) > 300 order by runnumber" daq | tail -n +3 | grep '|' | sort -n -k1 > $tmp_runsfile
0028
0029 awk '{print $1}' $tmp_runsfile > ${TOPDIR}/all.runs
0030
0031 tobedonefile=tobedone.$(date +"%Y%m%d%H%M")
0032 fgrep -v -f ${TOPDIR}/submitted.runs ../all.runs | join - $tmp_runsfile | awk '{print $1}' > $tobedonefile
0033
0034
0035 tstamp_file=${TOPDIR}/.tstamp.new
0036 psql -c 'select NOW();' FileCatalog | awk 'NR==3' | sed 's/^ //' > ${tstamp_file}
0037
0038
0039 tmpfile=/tmp/get_files2calib.$$
0040 all_files=${TOPDIR}/ALL_FILES/all_files.$(date +"%Y%m%d%H%M")
0041
0042 pcmd="SELECT lfn FROM files WHERE time >= '$(tail -1 ${TOPDIR}/tstamp.history)';"
0043 echo psql -c \"$pcmd\" FileCatalog
0044 psql -c "$pcmd" FileCatalog > $tmpfile
0045 grep DST_TRIGGERED_EVENT_seb18_run3auau $tmpfile | sed 's/^ //' | sort > ${all_files}
0046
0047
0048 if [[ -s ${all_files} ]]
0049 then
0050 echo "New DSTs:"
0051 wc -l ${all_files}
0052 cp -p ${TOPDIR}/tstamp.history .
0053 cat ${tstamp_file} >> ${TOPDIR}/tstamp.history
0054 else
0055 echo "No new DSTs found"
0056 exit
0057 fi
0058
0059 fgrep -f ${tobedonefile} ${TOPDIR}/ALL_FILES/all_files.* | sed 's/^.*://' | sort | uniq > flist.tobedone
0060 ${TOPDIR}/splitbyrun.sh flist.tobedone
0061
0062
0063 cd ${SUBMITDIR}
0064 if [[ $USER == "sphnxpro" ]]
0065 then
0066 cp -p ${HOME}/chiu/offline/macros/calibrations/mbd/* .
0067 elif [[ $USER == "chiu" ]]
0068 then
0069 cp -p /sphenix/user/chiu/sphenix_bbc/offline/macros/calibrations/mbd/* .
0070 fi
0071
0072
0073 wc -l ?????.list | grep -v total | while read ndsts fname
0074 do
0075 if [[ $ndsts -lt 19 ]]
0076 then
0077
0078 echo $ndsts $fname >> SKIPPING
0079 else
0080 cd ${SUBMITDIR}
0081 echo ./submit.sh ./myrun.sh ${tobedonedir}/${fname}
0082 ./submit.sh ./myrun.sh ${tobedonedir}/${fname}
0083 cd ${tobedonedir}
0084 echo ${fname%.list} >> submit.runs
0085 fi
0086 done
0087
0088
0089 if [[ -f submit.runs ]]
0090 then
0091 cp -p ${TOPDIR}/submitted.runs .
0092 cat ${TOPDIR}/submitted.runs submit.runs | sort | uniq > /tmp/submit.$$
0093 cp -p /tmp/submit.$$ ${TOPDIR}/submitted.runs
0094 else
0095 echo No runs found
0096 fi
0097