From 1da39d036db5d5c6551439469b0caed9df73265f Mon Sep 17 00:00:00 2001 From: Silke Nelson Date: Mon, 5 May 2025 23:26:51 -0700 Subject: [PATCH 01/13] print message&makepeds command when takepeds is done, but before the elog post; add timedrun for pedestals runs in RIXS --- scripts/takepeds | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/takepeds b/scripts/takepeds index 57e7bdd8..6e7f5fa8 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,9 @@ 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 ' + echo 'Now posting to the elog: ' elogMessage="DARK" source pcds_conda PYCMD=LogBookPost @@ -54,7 +61,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 From 78e2d9136be0104ac5554b5544551a1551da4436 Mon Sep 17 00:00:00 2001 From: Silke Nelson Date: Mon, 5 May 2025 23:28:01 -0700 Subject: [PATCH 02/13] if passing experiment name, use exp-name to determine hutch if needed. Add option to see if this is an LCLS1 or LCLS2 experiment --- scripts/get_info.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/get_info.py b/scripts/get_info.py index 6c37850e..a95790dd 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') @@ -114,6 +115,10 @@ or path.find('xtod') + hostname.find('xtod') >= -1): hutch = 'LFE' # because we have so many names for the same subnet. foundHutch = True + if not foundHutch: + if args.setExp: + hutch = args.setExp[:3].upper() + foundHutch = True if not foundHutch: # then ask.....outside of python print('unknown_hutch') @@ -203,6 +208,25 @@ 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") + + print('get exp:') + print(ws_url + "/lgbk/" + exp + "/ws" + + "/file_counts_by_extension") + 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) From c5f890548172b600a323130dd86bf7a4d08651c3 Mon Sep 17 00:00:00 2001 From: Silke Nelson Date: Mon, 5 May 2025 23:28:47 -0700 Subject: [PATCH 03/13] use experiment data file names to determine the DAQ used (workf ro MFX that has runs using either DAQ) --- scripts/makepeds | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/makepeds b/scripts/makepeds index a368f40c..cbf10e88 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 --exp $EXP) +if [ $DAQ == 'LCLS2' ]; then echo "This is a LCLS-II experiment" MAKEPEDSEXE=makepeds_psana2 else From 4b60688e4447f78bab09d89f8ca56828c5456915 Mon Sep 17 00:00:00 2001 From: Silke Nelson Date: Mon, 5 May 2025 23:31:08 -0700 Subject: [PATCH 04/13] fix a couple small bugs, add axis makepeds (still in progress), add check to interactive jungfrau running, deal with multi-segment detectors (may change soon) --- scripts/makepeds_psana2 | 70 +++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index 4871e724..c3abd42a 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:' @@ -430,6 +431,8 @@ if [ "$DEPLOY" == 1 ]; then fi HAVE_EPIX100=$(grep -c epix100 /tmp/detnames_"$EXP"_"$CREATE_TIME") +#REMOVE BEFORE COMMIT +HAVE_EPIX100=0 if [[ $HAVE_EPIX100 -ge 1 ]]; then DETNAMES=$(grep epix100 /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $1}' | paste -d " " -s) DETTYPES=$(grep epix100 /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $2}' | paste -d " " -s) @@ -479,6 +482,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 +648,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 +661,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 16 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,10 +686,15 @@ 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 + if [ "$NSEG" -eq 32 ]; then + break + fi done else echo "$CMD" - $CMD + #PLEASE CHANGE BEFOER COMMITTING + #$CMD fi done ALLJOBIDS=("${JOBIDS[@]}") @@ -687,6 +727,12 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then fi if [ "$DEPLOY" == 1 ]; then + if [[ $RUNLOCAL == 1 ]]; then + read -r -p "Did all jobs success and 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 +744,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 From 1198a800a9e2e68e55e7c5017471d5445c5397be Mon Sep 17 00:00:00 2001 From: silkenelson Date: Mon, 5 May 2025 23:41:14 -0700 Subject: [PATCH 05/13] Update scripts/makepeds_psana2 Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/makepeds_psana2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index c3abd42a..99da174a 100755 --- a/scripts/makepeds_psana2 +++ b/scripts/makepeds_psana2 @@ -431,8 +431,6 @@ if [ "$DEPLOY" == 1 ]; then fi HAVE_EPIX100=$(grep -c epix100 /tmp/detnames_"$EXP"_"$CREATE_TIME") -#REMOVE BEFORE COMMIT -HAVE_EPIX100=0 if [[ $HAVE_EPIX100 -ge 1 ]]; then DETNAMES=$(grep epix100 /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $1}' | paste -d " " -s) DETTYPES=$(grep epix100 /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $2}' | paste -d " " -s) From 28b273797d0582656ff50baa58c3f284e732e5f3 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Mon, 5 May 2025 23:41:50 -0700 Subject: [PATCH 06/13] Update scripts/makepeds Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/makepeds | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/makepeds b/scripts/makepeds index cbf10e88..6427c42c 100755 --- a/scripts/makepeds +++ b/scripts/makepeds @@ -194,8 +194,8 @@ else HUTCH=${EXP:0:3} fi -DAQ=$(get_info --daq --exp $EXP) -if [ $DAQ == 'LCLS2' ]; then +DAQ=$(get_info --daq --setExp $EXP) +if [[ $DAQ == 'LCLS2' ]]; then echo "This is a LCLS-II experiment" MAKEPEDSEXE=makepeds_psana2 else From 53d5b43832023205290178829b23585ad9bddb30 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 00:02:07 -0700 Subject: [PATCH 07/13] Update scripts/get_info.py Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/get_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/get_info.py b/scripts/get_info.py index a95790dd..ed26ad33 100644 --- a/scripts/get_info.py +++ b/scripts/get_info.py @@ -119,9 +119,9 @@ if args.setExp: hutch = args.setExp[:3].upper() foundHutch = True - if not foundHutch: - # then ask.....outside of python - print('unknown_hutch') + else: + # then ask.....outside of python + print('unknown_hutch') sys.exit() if args.getHutch: print(hutch.upper()) From 449a5f445c828d6594411706ce37cf54fece0c7c Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 00:05:12 -0700 Subject: [PATCH 08/13] Update scripts/takepeds Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/takepeds | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/takepeds b/scripts/takepeds index 6e7f5fa8..6960e916 100755 --- a/scripts/takepeds +++ b/scripts/takepeds @@ -52,7 +52,6 @@ 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 ' - echo 'Now posting to the elog: ' elogMessage="DARK" source pcds_conda PYCMD=LogBookPost From f3456293cf9c8dc2545f1a61789e36a596334777 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 08:25:56 -0700 Subject: [PATCH 09/13] Update scripts/makepeds_psana2 Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/makepeds_psana2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index 99da174a..ec676c5e 100755 --- a/scripts/makepeds_psana2 +++ b/scripts/makepeds_psana2 @@ -726,7 +726,7 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then if [ "$DEPLOY" == 1 ]; then if [[ $RUNLOCAL == 1 ]]; then - read -r -p "Did all jobs success and you want to deploy now (y/n)" + read -r -p "Did all jobs succeed and do you want to deploy now (y/n)" if [ "$REPLY" != "y" ];then exit 1 fi From b84a24606fe81a394ab3a6e23d3cffbe65cc4bb8 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 08:26:08 -0700 Subject: [PATCH 10/13] Update scripts/makepeds_psana2 Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/makepeds_psana2 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index ec676c5e..773ecebf 100755 --- a/scripts/makepeds_psana2 +++ b/scripts/makepeds_psana2 @@ -691,8 +691,7 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then done else echo "$CMD" - #PLEASE CHANGE BEFOER COMMITTING - #$CMD + $CMD fi done ALLJOBIDS=("${JOBIDS[@]}") From d7ec510e5451cca0c1606f8927a87ec4e4d1e141 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 08:26:33 -0700 Subject: [PATCH 11/13] Update scripts/get_info.py Remove debug prints Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/get_info.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/get_info.py b/scripts/get_info.py index ed26ad33..f94f06ec 100644 --- a/scripts/get_info.py +++ b/scripts/get_info.py @@ -216,9 +216,6 @@ {"instrument_name": hutch, "station": station}) exp = resp.json().get("value", {}).get("name") - print('get exp:') - print(ws_url + "/lgbk/" + exp + "/ws" - + "/file_counts_by_extension") r = requests.get(ws_url + "/lgbk/" + exp + "/ws" + "/file_counts_by_extension") r.raise_for_status() From def9d0ca20940e70bac45debf080bd604967e4f1 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 08:28:50 -0700 Subject: [PATCH 12/13] Update scripts/makepeds_psana2 Co-authored-by: KaushikMalapati <80156796+KaushikMalapati@users.noreply.github.com> --- scripts/makepeds_psana2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index 773ecebf..8c3adb1c 100755 --- a/scripts/makepeds_psana2 +++ b/scripts/makepeds_psana2 @@ -742,7 +742,7 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then JUNGFRAU="${DETNAMES[i]// /}" #for JUNGFRAU in $DETNAMES; do echo "****" - echo `which jungfrau_deploy_constants` + 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 From b8c4f6c3f2b94c2e0c6dea554b10ec191587ea28 Mon Sep 17 00:00:00 2001 From: silkenelson Date: Tue, 6 May 2025 08:34:03 -0700 Subject: [PATCH 13/13] Update makepeds_psana2 fixed & a little more comments. --- scripts/makepeds_psana2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/makepeds_psana2 b/scripts/makepeds_psana2 index 8c3adb1c..cc7ceb9e 100755 --- a/scripts/makepeds_psana2 +++ b/scripts/makepeds_psana2 @@ -660,7 +660,7 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then if [[ $RUNLOCAL != 1 ]]; then for ((segment=0; segment<$NSEG; segment++)); do CMDS=$CMD - #commenting this out as MFX currently only uses 4 of the 16 segments + #commenting this out as MFX currently only uses 4 of the 32 segments #if [ $NSEG -lt 99 ]; then # CMDS=$CMD' --idx '$segment #else @@ -684,7 +684,7 @@ 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 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