diff --git a/scripts/get_info.py b/scripts/get_info.py index 6c37850e..f94f06ec 100644 --- a/scripts/get_info.py +++ b/scripts/get_info.py @@ -12,6 +12,7 @@ parser.add_argument("--exp", help="get experiment name", action='store_true') parser.add_argument("--live", help="ongoing?", action='store_true') parser.add_argument("--ended", help="ended", action='store_true') +parser.add_argument("--daq", help="get DAQ type", action='store_true') parser.add_argument("--hutch", help="get experiment for hutch xxx") parser.add_argument("--station", help="optional station for hutch with two daqs, e.g. cxi and mfx") parser.add_argument("--getHutch", help="get hutch (uppercase)", action='store_true') @@ -115,8 +116,12 @@ hutch = 'LFE' # because we have so many names for the same subnet. foundHutch = True if not foundHutch: - # then ask.....outside of python - print('unknown_hutch') + if args.setExp: + hutch = args.setExp[:3].upper() + foundHutch = True + else: + # then ask.....outside of python + print('unknown_hutch') sys.exit() if args.getHutch: print(hutch.upper()) @@ -203,6 +208,22 @@ logger.exception("No runs?") print('No runs taken yet') +if args.daq: + if args.setExp: + exp = args.setExp + else: + resp = requests.get(ws_url + "/lgbk/ws/activeexperiment_for_instrument_station", + {"instrument_name": hutch, "station": station}) + exp = resp.json().get("value", {}).get("name") + + r = requests.get(ws_url + "/lgbk/" + exp + "/ws" + + "/file_counts_by_extension") + r.raise_for_status() + if "xtc2" in r.json()["value"]: + print('LCLS2') + else: + print('LCLS1') + if args.files_for_run or args.nfiles_for_run: if args.files_for_run: run = int(args.files_for_run) diff --git a/scripts/makepeds b/scripts/makepeds index a368f40c..6427c42c 100755 --- a/scripts/makepeds +++ b/scripts/makepeds @@ -194,8 +194,8 @@ else HUTCH=${EXP:0:3} fi -LCLS2_HUTCHES="rix, tmo, txi, ued, mfx" -if echo "$LCLS2_HUTCHES" | grep -iw "$HUTCH" > /dev/null; then +DAQ=$(get_info --daq --setExp $EXP) +if [[ $DAQ == 'LCLS2' ]]; then echo "This is a LCLS-II experiment" MAKEPEDSEXE=makepeds_psana2 else diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index 4871e724..cc7ceb9e 100755 --- a/scripts/makepeds_psana2 +++ b/scripts/makepeds_psana2 @@ -410,10 +410,11 @@ ls -ltr "$XTCDIR"/*r"$RUNSTR"*s*xtc* echo Check detectors: detnames -r exp="${EXP}",run="${RUN}",dir="${XTCDIR}" > /tmp/detnames_"$EXP"_"$CREATE_TIME" -if $?; then +if [ $? -ne 0 ]; then echo 'detnames failed' exit 8 fi + #running local echo "-----------------------" echo 'XTC files contain:' @@ -479,6 +480,30 @@ if [[ $HAVE_ARCHON -ge 1 ]]; then done fi +HAVE_AXIS_SVLS=$(grep -c axis_svls /tmp/detnames_"$EXP"_"$CREATE_TIME") +if [[ $HAVE_AXIS_SVLS -ge 1 ]]; then + DETNAMES=$(grep axis_svls /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $1}' | paste -d " " -s) + DETTYPES=$(grep axis_svls /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $2}' | paste -d " " -s) + for i in "${!DETNAMES[@]}"; do + LOCARG=$ARG' -o '$CALIBDIR + if [[ -v VALSTR ]]; then + LOCARG=$LOCARG' -t '$VALSTR + fi + if [[ -v NRECS1 ]]; then + LOCARG=$LOCARG' --nrecs1 '$NRECS1 + fi + + MYDET="${DETNAMES[i]// /}" + MYDETTYPE="${DETTYPES[i]// /}" + if [ "$MYDETTYPE" = 'pv' ]; then + echo 'now calibrate...'$MYDET + CMD="det_dark_proc -d $MYDET -k exp=$EXP,run=$RUN,dir=$XTCDIR -L INFO $LOCARG" + echo "$CMD" + $CMD + fi + done +fi + #### # epixquad for UED #### @@ -621,6 +646,12 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then NSEG=99 if [[ $JUNGFRAU =~ "16M" ]]; then NSEG=32; + elif [[ $JUNGFRAU =~ "4M" ]]; then + NSEG=8; + elif [[ $JUNGFRAU =~ "1M" ]]; then + NSEG=2; + elif [[ $EXP =~ "mfx" ]]; then #note that this is a hotfix! + NSEG=32; fi for calibcycle in {0..2}; do nextcycle=$(( calibcycle + 1 )) @@ -628,11 +659,13 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then echo "---------------JUNGFRAU PEDESTALS FOR CYCLE $calibcycle --------------------" if [[ $RUNLOCAL != 1 ]]; then for ((segment=0; segment<$NSEG; segment++)); do - if [ $NSEG -lt 99 ]; then - CMDS=$CMD' --idx '$segment - else - CMDS=$CMD - fi + CMDS=$CMD + #commenting this out as MFX currently only uses 4 of the 32 segments + #if [ $NSEG -lt 99 ]; then + # CMDS=$CMD' --idx '$segment + #else + # CMDS=$CMD + #fi tmpScript=$(mktemp -p $WORKDIR jungfrau_pedestals_tmpXXXXX.sh) #trap "rm -f $tmpScript" EXIT chmod u+x "$tmpScript" @@ -651,6 +684,10 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then if [ "$NSEG" -eq 99 ]; then break fi + #this here is while we don't have a 32 segment jungfrau available - this belong w/ the --idx section + if [ "$NSEG" -eq 32 ]; then + break + fi done else echo "$CMD" @@ -687,6 +724,12 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then fi if [ "$DEPLOY" == 1 ]; then + if [[ $RUNLOCAL == 1 ]]; then + read -r -p "Did all jobs succeed and do you want to deploy now (y/n)" + if [ "$REPLY" != "y" ];then + exit 1 + fi + fi echo "---------------JUNGFRAU PEDESTALS CALCULATED NOW DEPLOY --------------------" if [ $NFAILEDJOBS -gt 0 ]; then read -r -p "$NFAILEDJOBS of the calibration tasks failed, do you want to continue anyways (y/n)?" @@ -698,15 +741,21 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then for i in "${!DETNAMES[@]}"; do JUNGFRAU="${DETNAMES[i]// /}" #for JUNGFRAU in $DETNAMES; do - CMD="jungfrau_deploy_constants -D -d $JUNGFRAU -k exp=$EXP,run=$RUN,dir=$XTCDIR -L INFO -o $CALIBDIR -p psrnx -N1" + echo "****" + echo $(which jungfrau_deploy_constants) + echo "****" + CMD="jungfrau_deploy_constants -D -d $JUNGFRAU -k exp=$EXP,run=$RUN,dir=$XTCDIR -L INFO -o $CALIBDIR -p psrnx" if [ -v "$VALSTR" ]; then echo 'setting validity....'"$VALSTR" CMD=$CMD' -t '$VALSTR fi + if [ $NSEG -lt 99 ]; then + CMD=$CMD' -N '$NSEG + fi echo "$CMD" if ! $CMD; then echo 'deployment failed' - return 1 + exit 1 fi done diff --git a/scripts/takepeds b/scripts/takepeds index 57e7bdd8..6960e916 100755 --- a/scripts/takepeds +++ b/scripts/takepeds @@ -34,6 +34,10 @@ if [[ "$(daqutils isdaqmgr)" = "true" || ${HUTCH} =~ 'ued' ]]; then elif [[ ${HUTCH} =~ 'mfx' ]]; then source $SIT_ENV_DIR/setup_env.sh jungfrau_pedestal_scan --record 1 --hutch ${HUTCH} -p 0 -g 1 -v -t 10000 -C drp-srcf-cmp014 + elif [[ ${HUTCH} =~ 'rix' ]]; then + echo "Running LCLS2 RIX specific pedestal acquisition..." + source /cds/group/pcds/dist/pds/rix/scripts/setup_env.sh + timed_run --duration="60" --config="/cds/group/pcds/dist/pds/rix/scripts/rix.py" --record fi else echo "This is an LCLS-I experiment" @@ -46,6 +50,8 @@ else fi if [ $? -eq 0 ]; then + echo 'Finished taking the pedestals, now posting to the elog' + echo 'Please call: makepeds -q milano -r '`get_lastRun`' -u ' elogMessage="DARK" source pcds_conda PYCMD=LogBookPost @@ -54,7 +60,6 @@ if [ $? -eq 0 ]; then echo $PYCMD -i "${HUTCH^^}" -u `whoami` -e "$EXP" -t DARK -r $RUN -m "$elogMessage" $PYCMD -i "${HUTCH^^}" -u `whoami` -p pcds -e "$EXP" -t DARK -r $RUN -m "$elogMessage"& - echo 'Please call: makepeds -q milano -r '`get_lastRun`' -u ' else echo 'takepeds failed, make sure the DAQ is setup appropriately!' fi