Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:19:43

0001 #!/usr/bin/env bash
0002 #
0003 # run_slewcal.sh <fname>
0004 # do slew calibrations
0005 # <fname> is the name of the DSTUNCALMBD root file with the waveforms
0006 
0007 # Check that user specifies a file
0008 if [[ $# -lt 1 ]]
0009 then
0010   echo "Usage: run_slewcal.sh <rootfname>"
0011   exit -1
0012 fi
0013 
0014 fname=$1    # DST_UNCALMBD filename
0015 
0016 nevt=0
0017 if [[ $# -gt 1 ]]
0018 then
0019   nevt=$2
0020   echo Processing $2 events
0021 fi
0022 
0023 rootf=$fname
0024 echo PATH=$PATH
0025 echo LD_LIBRARY_PATH=$LD_LIBRARY_PATH
0026 
0027 # first process up to 250K uncalibrated events
0028 mbd_uncalrootf=${fname%.root}.root
0029 
0030 # now run calibrations
0031 tcalib_events=0
0032 if [[ $nevt -ne 0 ]] && [[ $nevt -lt 100000 ]]
0033 then
0034   tcalib_events=${nevt}
0035 fi
0036 
0037 # if not interactive, run ROOT in batch mode
0038 if [ ! -z $PS1 ]
0039 then
0040   BATCH=-b
0041 fi
0042 
0043 subpass=1  # generate slew curves (slew calibrations may or may not be applied)
0044 echo root.exe $BATCH -q cal_mbd.C\(\"${mbd_uncalrootf}\",${subpass},${tcalib_events}\)
0045 root.exe $BATCH -q cal_mbd.C\(\"${mbd_uncalrootf}\",${subpass},${tcalib_events}\) 
0046 
0047 # after this, run recal_mbd_slew.C to generate the slewcorr calib file,
0048 run=${mbd_uncalrootf##*/}
0049 run=${run#*-}
0050 run=${run%.root}
0051 run=${run%-*}
0052 run=$((10#${run}))
0053 
0054 slewrootf=results/${run}/calmbdpass2.${subpass}_slew-${run}.root
0055 echo root.exe ${BATCH} -q recal_mbd_slew.C\(\"${slewrootf}\",${subpass}\) 
0056 root.exe ${BATCH} -q recal_mbd_slew.C\(\"${slewrootf}\",${subpass}\) 
0057 
0058 # cp the slewcorr file so that it is used in the subpass 2
0059 echo cp -p results/${run}/pass${subpass}_mbd_slewcorr.calib results/${run}/mbd_slewcorr.calib
0060 cp -p results/${run}/pass${subpass}_mbd_slewcorr.calib results/${run}/mbd_slewcorr.calib
0061 echo Updating mbd_slewcorr.calib using pass${subpass}_mbd_slewcorr.calib
0062 
0063 # then run addt0.C to get combined t0 calibs and cp it
0064 echo root.exe -b -q addt0.C\(\"results/${run}/mbd_tt_t0.calib\",\"results/${run}/pass${subpass}_mbd_tt_t0.calib\"\)
0065 root.exe -b -q addt0.C\(\"results/${run}/mbd_tt_t0.calib\",\"results/${run}/pass${subpass}_mbd_tt_t0.calib\"\)
0066 rm -f results/${run}/mbd_tt_t0.calib results/${run}/mbd_tq_t0.calib
0067 cp -p results/${run}/add_mbd_tt_t0.calib results/${run}/mbd_tt_t0.calib
0068 cp -p results/${run}/add_mbd_tq_t0.calib results/${run}/mbd_tq_t0.calib
0069 
0070 subpass=2  # do slew calibrations, applying any that exist
0071 echo root.exe $BATCH -q cal_mbd.C\(\"${mbd_uncalrootf}\",${subpass},${tcalib_events}\)
0072 root.exe $BATCH -q cal_mbd.C\(\"${mbd_uncalrootf}\",${subpass},${tcalib_events}\) 
0073 
0074 slewrootf=results/${run}/calmbdpass2.${subpass}_slew-${run}.root
0075 echo root.exe ${BATCH} -q recal_mbd_slew.C\(\"${slewrootf}\",${subpass}\) 
0076 root.exe ${BATCH} -q recal_mbd_slew.C\(\"${slewrootf}\",${subpass}\) 
0077 
0078 # then run addslew.C to get combined slewcorr.calib. need to add in original, since that was applied in dst_uncalmbd
0079 # then run addt0 to get combined t0 calibs