Skip to content

Commit f836202

Browse files
authored
Merge pull request #281 from silkenelson/feature/MFX_is_LCLS2
Several changes to expand the capabilities of takepeds/makepeds for LCLS2
2 parents c05992e + b8c4f6c commit f836202

File tree

4 files changed

+88
-13
lines changed

4 files changed

+88
-13
lines changed

scripts/get_info.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
parser.add_argument("--exp", help="get experiment name", action='store_true')
1313
parser.add_argument("--live", help="ongoing?", action='store_true')
1414
parser.add_argument("--ended", help="ended", action='store_true')
15+
parser.add_argument("--daq", help="get DAQ type", action='store_true')
1516
parser.add_argument("--hutch", help="get experiment for hutch xxx")
1617
parser.add_argument("--station", help="optional station for hutch with two daqs, e.g. cxi and mfx")
1718
parser.add_argument("--getHutch", help="get hutch (uppercase)", action='store_true')
@@ -115,8 +116,12 @@
115116
hutch = 'LFE' # because we have so many names for the same subnet.
116117
foundHutch = True
117118
if not foundHutch:
118-
# then ask.....outside of python
119-
print('unknown_hutch')
119+
if args.setExp:
120+
hutch = args.setExp[:3].upper()
121+
foundHutch = True
122+
else:
123+
# then ask.....outside of python
124+
print('unknown_hutch')
120125
sys.exit()
121126
if args.getHutch:
122127
print(hutch.upper())
@@ -203,6 +208,22 @@
203208
logger.exception("No runs?")
204209
print('No runs taken yet')
205210

211+
if args.daq:
212+
if args.setExp:
213+
exp = args.setExp
214+
else:
215+
resp = requests.get(ws_url + "/lgbk/ws/activeexperiment_for_instrument_station",
216+
{"instrument_name": hutch, "station": station})
217+
exp = resp.json().get("value", {}).get("name")
218+
219+
r = requests.get(ws_url + "/lgbk/" + exp + "/ws"
220+
+ "/file_counts_by_extension")
221+
r.raise_for_status()
222+
if "xtc2" in r.json()["value"]:
223+
print('LCLS2')
224+
else:
225+
print('LCLS1')
226+
206227
if args.files_for_run or args.nfiles_for_run:
207228
if args.files_for_run:
208229
run = int(args.files_for_run)

scripts/makepeds

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ else
194194
HUTCH=${EXP:0:3}
195195
fi
196196

197-
LCLS2_HUTCHES="rix, tmo, txi, ued, mfx"
198-
if echo "$LCLS2_HUTCHES" | grep -iw "$HUTCH" > /dev/null; then
197+
DAQ=$(get_info --daq --setExp $EXP)
198+
if [[ $DAQ == 'LCLS2' ]]; then
199199
echo "This is a LCLS-II experiment"
200200
MAKEPEDSEXE=makepeds_psana2
201201
else

scripts/makepeds_psana2

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,11 @@ ls -ltr "$XTCDIR"/*r"$RUNSTR"*s*xtc*
410410
echo Check detectors:
411411

412412
detnames -r exp="${EXP}",run="${RUN}",dir="${XTCDIR}" > /tmp/detnames_"$EXP"_"$CREATE_TIME"
413-
if $?; then
413+
if [ $? -ne 0 ]; then
414414
echo 'detnames failed'
415415
exit 8
416416
fi
417+
417418
#running local
418419
echo "-----------------------"
419420
echo 'XTC files contain:'
@@ -479,6 +480,30 @@ if [[ $HAVE_ARCHON -ge 1 ]]; then
479480
done
480481
fi
481482

483+
HAVE_AXIS_SVLS=$(grep -c axis_svls /tmp/detnames_"$EXP"_"$CREATE_TIME")
484+
if [[ $HAVE_AXIS_SVLS -ge 1 ]]; then
485+
DETNAMES=$(grep axis_svls /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $1}' | paste -d " " -s)
486+
DETTYPES=$(grep axis_svls /tmp/detnames_"$EXP"_"$CREATE_TIME" | grep raw | awk 'BEGIN { FS = "|"}; {print $2}' | paste -d " " -s)
487+
for i in "${!DETNAMES[@]}"; do
488+
LOCARG=$ARG' -o '$CALIBDIR
489+
if [[ -v VALSTR ]]; then
490+
LOCARG=$LOCARG' -t '$VALSTR
491+
fi
492+
if [[ -v NRECS1 ]]; then
493+
LOCARG=$LOCARG' --nrecs1 '$NRECS1
494+
fi
495+
496+
MYDET="${DETNAMES[i]// /}"
497+
MYDETTYPE="${DETTYPES[i]// /}"
498+
if [ "$MYDETTYPE" = 'pv' ]; then
499+
echo 'now calibrate...'$MYDET
500+
CMD="det_dark_proc -d $MYDET -k exp=$EXP,run=$RUN,dir=$XTCDIR -L INFO $LOCARG"
501+
echo "$CMD"
502+
$CMD
503+
fi
504+
done
505+
fi
506+
482507
####
483508
# epixquad for UED
484509
####
@@ -621,18 +646,26 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then
621646
NSEG=99
622647
if [[ $JUNGFRAU =~ "16M" ]]; then
623648
NSEG=32;
649+
elif [[ $JUNGFRAU =~ "4M" ]]; then
650+
NSEG=8;
651+
elif [[ $JUNGFRAU =~ "1M" ]]; then
652+
NSEG=2;
653+
elif [[ $EXP =~ "mfx" ]]; then #note that this is a hotfix!
654+
NSEG=32;
624655
fi
625656
for calibcycle in {0..2}; do
626657
nextcycle=$(( calibcycle + 1 ))
627658
CMD="jungfrau_dark_proc $LOCARG -d $JUNGFRAU -k exp=$EXP,run=$RUN,dir=$XTCDIR --stepnum $calibcycle --stepmax $nextcycle -L INFO"
628659
echo "---------------JUNGFRAU PEDESTALS FOR CYCLE $calibcycle --------------------"
629660
if [[ $RUNLOCAL != 1 ]]; then
630661
for ((segment=0; segment<$NSEG; segment++)); do
631-
if [ $NSEG -lt 99 ]; then
632-
CMDS=$CMD' --idx '$segment
633-
else
634-
CMDS=$CMD
635-
fi
662+
CMDS=$CMD
663+
#commenting this out as MFX currently only uses 4 of the 32 segments
664+
#if [ $NSEG -lt 99 ]; then
665+
# CMDS=$CMD' --idx '$segment
666+
#else
667+
# CMDS=$CMD
668+
#fi
636669
tmpScript=$(mktemp -p $WORKDIR jungfrau_pedestals_tmpXXXXX.sh)
637670
#trap "rm -f $tmpScript" EXIT
638671
chmod u+x "$tmpScript"
@@ -651,6 +684,10 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then
651684
if [ "$NSEG" -eq 99 ]; then
652685
break
653686
fi
687+
#this here is while we don't have a 32 segment jungfrau available - this belong w/ the --idx section
688+
if [ "$NSEG" -eq 32 ]; then
689+
break
690+
fi
654691
done
655692
else
656693
echo "$CMD"
@@ -687,6 +724,12 @@ if [[ $HAVE_JUNGFRAU -ge 1 ]]; then
687724
fi
688725

689726
if [ "$DEPLOY" == 1 ]; then
727+
if [[ $RUNLOCAL == 1 ]]; then
728+
read -r -p "Did all jobs succeed and do you want to deploy now (y/n)"
729+
if [ "$REPLY" != "y" ];then
730+
exit 1
731+
fi
732+
fi
690733
echo "---------------JUNGFRAU PEDESTALS CALCULATED NOW DEPLOY --------------------"
691734
if [ $NFAILEDJOBS -gt 0 ]; then
692735
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
698741
for i in "${!DETNAMES[@]}"; do
699742
JUNGFRAU="${DETNAMES[i]// /}"
700743
#for JUNGFRAU in $DETNAMES; do
701-
CMD="jungfrau_deploy_constants -D -d $JUNGFRAU -k exp=$EXP,run=$RUN,dir=$XTCDIR -L INFO -o $CALIBDIR -p psrnx -N1"
744+
echo "****"
745+
echo $(which jungfrau_deploy_constants)
746+
echo "****"
747+
CMD="jungfrau_deploy_constants -D -d $JUNGFRAU -k exp=$EXP,run=$RUN,dir=$XTCDIR -L INFO -o $CALIBDIR -p psrnx"
702748
if [ -v "$VALSTR" ]; then
703749
echo 'setting validity....'"$VALSTR"
704750
CMD=$CMD' -t '$VALSTR
705751
fi
752+
if [ $NSEG -lt 99 ]; then
753+
CMD=$CMD' -N '$NSEG
754+
fi
706755
echo "$CMD"
707756
if ! $CMD; then
708757
echo 'deployment failed'
709-
return 1
758+
exit 1
710759
fi
711760
done
712761

scripts/takepeds

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ if [[ "$(daqutils isdaqmgr)" = "true" || ${HUTCH} =~ 'ued' ]]; then
3434
elif [[ ${HUTCH} =~ 'mfx' ]]; then
3535
source $SIT_ENV_DIR/setup_env.sh
3636
jungfrau_pedestal_scan --record 1 --hutch ${HUTCH} -p 0 -g 1 -v -t 10000 -C drp-srcf-cmp014
37+
elif [[ ${HUTCH} =~ 'rix' ]]; then
38+
echo "Running LCLS2 RIX specific pedestal acquisition..."
39+
source /cds/group/pcds/dist/pds/rix/scripts/setup_env.sh
40+
timed_run --duration="60" --config="/cds/group/pcds/dist/pds/rix/scripts/rix.py" --record
3741
fi
3842
else
3943
echo "This is an LCLS-I experiment"
@@ -46,6 +50,8 @@ else
4650
fi
4751

4852
if [ $? -eq 0 ]; then
53+
echo 'Finished taking the pedestals, now posting to the elog'
54+
echo 'Please call: makepeds -q milano -r '`get_lastRun`' -u <userID>'
4955
elogMessage="DARK"
5056
source pcds_conda
5157
PYCMD=LogBookPost
@@ -54,7 +60,6 @@ if [ $? -eq 0 ]; then
5460
echo $PYCMD -i "${HUTCH^^}" -u `whoami` -e "$EXP" -t DARK -r $RUN -m "$elogMessage"
5561
$PYCMD -i "${HUTCH^^}" -u `whoami` -p pcds -e "$EXP" -t DARK -r $RUN -m "$elogMessage"&
5662

57-
echo 'Please call: makepeds -q milano -r '`get_lastRun`' -u <userID>'
5863
else
5964
echo 'takepeds failed, make sure the DAQ is setup appropriately!'
6065
fi

0 commit comments

Comments
 (0)