Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JEditTuneHV.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3# \author bjung
4#
5version=1.0
6script=${0##*/}
7
8# ------------------------------------------------------------------------------------------------
9#
10# Utility script for finding PMT supply voltages corresponding to the nominal gain setting.
11#
12# ------------------------------------------------------------------------------------------------
13
14
15if [ -z $JPP_DIR ]; then
16 echo "Variable JPP_DIR undefined."
17 exit
18fi
19
20
21source $JPP_DIR/setenv.sh $JPP_DIR
22
23set_variable: DEBUG CALIBRATION_DEBUG 2
24set_variable: WORKDIR CALIBRATION_WORKDIR ${TMPDIR:-/tmp}
25
26set_variable: DETID EDITTUNEHV_DETID -1
27set_variable: RUNID EDITTUNEHV_RUNID -1
28set_variable: OUTPUT_FILE EDITTUNEHV_OUTPUT_FILE "HVtuningEdit.json"
29
30
31if do_usage $*; then
32 usage "$script <input file> <output files> [detector identifier] [run number] [PMT set]\n\n" \
33 "Note: The operation performed depends on the input parameters.\n" \
34 " Possible operations are to update according to:\n" \
35 " - the high-voltage settings corresponding to a specific DAQ run\n" \
36 " if both detector ID and run number are specified.\n" \
37 " - the vendor high-voltage settings\n" \
38 " if the detector ID is specified, but the run number is left unspecified.\n" \
39 " - manually specifiable values\n" \
40 " if both detector ID and run number are left unspecified.\n\n" \
41 " A set of PMTs on which the operation should be performed can be optionally\n" \
42 " specified via the command line."
43fi
44
45case $# in
46 2) set_variable OUTPUT_FILE $2;
47 set_variable INPUT_FILE $1;;
48 *) set_variable INPUT_FILE $1
49 set_variable OUTPUT_FILE $2
50
51 set_array IDENTIFIERS ""
52 set_array PMTSET ""
53
54 for ARGUMENT in ${argv[3,-1]}; do
55 if [[ ${ARGUMENT} =~ ^-?[0-9]+$ ]]; then
56 set_array IDENTIFIERS ${IDENTIFIERS[@]} ${ARGUMENT}
57 else
58 set_array PMTSET ${PMTSET[@]} ${ARGUMENT}
59 fi
60 done
61
62 if (( ${#IDENTIFIERS} > 0 )); then
63 set_variable DETID ${IDENTIFIERS[1]}
64 fi
65
66 if (( ${#IDENTIFIERS} > 1 )); then
67 set_variable RUNID ${IDENTIFIERS[2]}
68 fi
69 ;;
70esac
71
72let "TIMER = $(date +%s)"
73
74
75# Retrieve cookie
76JCookie.sh
77
78set_variable COOKIE $(cat ~/.km3netdb_cookie)
79set_variable LOGIN ${${COOKIE#*_}%%_*}
80set_variable LOCATIONID $(getLocationID -L ${LOGIN})
81
82
83if (( ${DETID} > 0 )); then
84
85 if (( ${RUNID} > 0 )); then
86
87 set_variable DETOID $( getDetector -D ${DETID} -- )
88
89 JAsciiDB \
90 -q pmt_hv_run_settings \
91 -@ "detoid = ${DETOID}" \
92 -@ "run = ${RUNID}" -- > ${WORKDIR}/HVfile.txt
93
94 set_array HVTABLE 2 ${WORKDIR}/HVfile.txt
95
96 else
97
98 JAsciiDB \
99 -q vendorhv \
100 -@ "detid = ${DETID}" -- > ${WORKDIR}/HVfile.txt
101
102 set_array HVTABLE 1 ${WORKDIR}/HVfile.txt
103 fi
104fi
105
106
107if (( 1 )); then
108
109 let "TIMER = $(date +%s) - $TIMER"
110
111 JEditTuneHV \
112 -f ${INPUT_FILE} \
113 -o ${OUTPUT_FILE} \
114 ${HVTABLE:+-b "${HVTABLE[*]}"} \
115 ${PMTSET:+-P "${PMTSET[*]}"} \
116 -# "login = ${LOGIN}" \
117 -# "locationID = ${LOCATIONID}" \
118 -# "elapsedTime = ${TIMER}" \
119 -d ${DEBUG} --!
120fi
121