Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:22

0001 #!/usr/bin/env bash
0002 #
0003 # usage:
0004 #  calmbd.sh <prdf or dst or list> <nevts>
0005 
0006 infile=$1
0007 echo "input file " $infile
0008 
0009 nevt=0
0010 if [[ $# -gt 1 ]] 
0011 then
0012   nevts=$2
0013   echo $nevts
0014 fi
0015 
0016 # get run number
0017 run=""
0018 if [[ "$infile" =~ prdf$ || "$infile" =~ root$ ]]
0019 then
0020   run=${infile##*/}
0021   run=${run%-*}
0022   run=${run#*-}
0023   run=${run#000}
0024 elif [[ "$infile" =~ list$ ]]
0025 then
0026   run=${infile##*/}
0027   run=${run%.list}
0028   nevt=2000000
0029 fi
0030 
0031 echo processing run $run
0032 
0033 # make calibration directory and fill it
0034 caldir=${PWD}/results/${run}
0035 echo mkdir -p ${caldir}
0036 mkdir -p ${caldir}
0037 
0038 # link pass0 calibs
0039 # use existing PASS0DIR, otherwise default to
0040 if [ -z "$PASS0DIR" ]
0041 then
0042   export PASS0DIR=/sphenix/user/chiu/sphenix_bbc/CDB/PASS0/
0043   echo "Setting PASS0DIR to $PASS0DIR"
0044 fi
0045 
0046 ln -sf ${PASS0DIR}/mbd_shape.calib ${caldir}/
0047 ln -sf ${PASS0DIR}/mbd_sherr.calib ${caldir}/
0048 ln -sf ${PASS0DIR}/mbd_timecorr.calib ${caldir}/
0049 ln -sf ${PASS0DIR}/mbd_slewcorr.calib ${caldir}/
0050 
0051 # do the pass1 calibrations (only 20K events)
0052 echo run_mbdcalpass.sh $infile 1
0053 run_mbdcalpass.sh $infile 1
0054 
0055 # process waveforms, output a DST_UNCALMBD
0056 # here time is in ns and charge in adc
0057 echo run_mbdcalpass.sh $infile 2 $nevts
0058 run_mbdcalpass.sh $infile 2 $nevts
0059 
0060 # do pass 2.0 (t0 offsets)
0061 rootfname=""
0062 if [[ "$infile" =~ prdf$ ]]
0063 then
0064   rootfname=${infile%.prdf}.root
0065   rootfname=DST_UNCALMBD-${rootfname#*-}
0066 elif [[ "$infile" =~ root$ ]]
0067 then
0068   rootfname=$(echo $infile | sed 's/DST_TRIGGERED_EVENT_run2pp_new_2024p001/DST_UNCALMBD/' | sed 's:^.*/::')
0069 elif [[ "$infile" =~ list$ ]]
0070 then
0071   rootfname=$(printf "DST_UNCALMBD-%08d-0000.root" $run)
0072 fi
0073 
0074 echo run_tcal.sh $rootfname
0075 run_tcal.sh $rootfname
0076 ln -sf ${PASS0DIR}/mbd_tt_t0.calib ${caldir}/
0077 ln -sf ${PASS0DIR}/mbd_tq_t0.calib ${caldir}/
0078 
0079 # do pass 2.3 (mip fits)
0080 echo run_qcal.sh $rootfname
0081 run_qcal.sh $rootfname
0082