Jpp  18.0.0-rc.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRecalibrateK40.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 # ------------------------------------------------------------------------------------------
5 #
6 # Script to run K40 time calibration following HV tuning.
7 #
8 # ------------------------------------------------------------------------------------------
9 
10 if [ -z $JPP_DIR ]; then
11  echo "Variable JPP_DIR undefined."
12  exit
13 fi
14 
15 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16 
17 set_variable: DEBUG CALIBRATION_DEBUG 1
18 set_variable: WORKDIR CALIBRATION_WORKDIR `pwd`
19 set_variable: DAQ_TIMESLICE CALIBRATION_TIMESLICE JDAQTimesliceL1
20 set_variable+ DATABASE_OPTION CALIBRATION_USEPMTID -U
21 set_variable+ MODEL CALIBRATION_MODEL -D
22 
23 if do_usage $*; then
24  usage "$script <detector file> <input file> <input file> <input file>"\
25  "\nThe 1st and 3rd input file should correspond to a data taking run in which the HV settings are complete (e.g. \"vendor\" or \"tuned\")."\
26  "\nThe 2nd input file should correspond to a run with so-called hybrid HV settings."\
27  "\nIn this, half of the PMTs should have the same HV settings as either the 1st or 3rd input file."
28 fi
29 
30 if (( $# == 4 )); then
32  set_array INPUT_FILES $argv[2,-1]
33 else
34  fatal "Wrong number of arguments."
35 fi
36 
37 JCookie.sh
38 
39 #
40 # Get background option for given input file.
41 #
42 # \param 1 input file
43 # \return option
44 #
45 function get_option()
46 {
47  if (( `JPrintTree -f $1 | awk '/JDAQSummaryslice/ { print $3 } '` > 0 )); then
48  echo rates
49  else
50  echo counts
51  fi
52 }
53 
54 
55 #
56 # Standard calibration.
57 #
58 # \param 1 detector
59 # \param 2 input file
60 #
61 function calibrate()
62 {
63  JPrintDAQHeader -f $2 | read ID RUN FRAME_INDEX UTC
64 
65  JCalibrateK40 \
66  -a $1 \
67  -f $2 \
68  -C $DAQ_TIMESLICE \
69  -o $ODIR/monitor_${RUN}.root \
70  -b `get_option $2` \
71  -d $DEBUG
72 
73  JMergeCalibrateK40 \
74  -f $ODIR/monitor_${RUN}.root \
75  -o $ODIR/merge_${RUN}.root \
76  -d $DEBUG
77 
78  JConvertDetectorFormat \
79  -a $1 \
80  -o $ODIR/detector_${RUN}.datx
81 
82  JFitK40 \
83  -a $ODIR/detector_${RUN}.datx \
84  -f $ODIR/merge_${RUN}.root \
85  -o $ODIR/fit_${RUN}.root \ $MODEL \
86  -A \
87  -w \
88  -d $DEBUG
89 }
90 
91 
92 #
93 # Hybrid calibration.
94 #
95 # \param 1 detector
96 # \param 2 reference run
97 # \param 3 input file
98 #
99 function hybrid()
100 {
101  JPrintDAQHeader -f $3 | read ID RUN FRAME_INDEX UTC
102 
103  JTDC \
104  -D $DETECTOR_ID \
105  -r "$2 $RUN" \
106  $DATABASE_OPTION \
107  -o "$ODIR/TDC_${2}_${RUN}.txt"
108 
109  JCalibrateK40 \
110  -a $1 \
111  -f $3 \
112  -C $DAQ_TIMESLICE \
113  -o $ODIR/monitor_${RUN}.root \
114  -b `get_option $3` \
115  -d $DEBUG
116 
117  JMergeCalibrateK40 \
118  -f $ODIR/monitor_${RUN}.root \
119  -o $ODIR/merge_${RUN}.root \
120  -d $DEBUG
121 
122  JConvertDetectorFormat \
123  -a $1 \
124  -o $ODIR/detector_${RUN}.datx
125 
126  JFitK40 \
127  -a $ODIR/detector_${RUN}.datx \
128  -f $ODIR/merge_${RUN}.root \
129  -o $ODIR/fit_${RUN}.root \ $MODEL \
130  -A \
131  -w \
132  -! $ODIR/TDC_${2}_${RUN}.txt \
133  -d $DEBUG
134 }
135 
136 
137 # Get run numbers
138 
139 eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
140 
141 RUNS=()
142 
143 for INPUT_FILE in $INPUT_FILES[*]; do
144 
145  JPrintDAQHeader -f $INPUT_FILE | read ID RUN FRAME_INDEX UTC
146 
147  if (( $ID != $DETECTOR_ID )); then
148  fatal "Detector identifier from $INPUT_FILE $ID != $DETECTOR_ID"
149  fi
150 
151  RUNS+=($RUN)
152 
153 done
154 
155 
156 # Process string-by-string
157 
158 eval `JPrintDetector -a $DETECTOR -O SUMMARY`
159 
160 for STRING in $STRINGS[*]; do
161 
162  echo "Processing string $STRING"
163 
165  mkdir -p $ODIR
166 
167  JEditDetector -a $DETECTOR -k $STRING -o $ODIR/detector.datx
168 
169  calibrate $ODIR/detector.datx ${INPUT_FILES[1]} >& $ODIR/calibrate.log
170 
171  hybrid $ODIR/detector_${RUNS[1]}.datx ${RUNS[1]} ${INPUT_FILES[2]} >& $ODIR/hybrid_${RUNS[1]}.log
172 
173  hybrid $ODIR/detector_${RUNS[2]}.datx ${RUNS[2]} ${INPUT_FILES[3]} >& $ODIR/hybrid_${RUNS[2]}.log
174 done
175 
176 for (( i = 1; $i <= 3; ++i )); do
177  JMergeDetector "-a $WORKDIR/"${^STRINGS}"/detector_${RUNS[${i}]}.datx" -o $WORKDIR/detector_${RUNS[${i}]}.datx
178 done
179 
180 
181 # cleanup
182 
183 #rm -rf "$WORKDIR/"${^STRINGS}
184 
&set_variable DAQ_TIMESLICE
Definition: JLegolas.sh:32
data_type w[N+1][M+1]
Definition: JPolint.hh:778
then usage $script< detector identifier >< startdate\"YYYY-MM-DDHH:MM:SS\"><finaldate\"YYYY-MM-DDHH:MM:SS\"><QA/QCfile> fi case set_variable QAQC_TXT $argv[4]
Definition: JDataMonitor.sh:24
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
set_array RUNS
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
clean eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY set_variable STRING
JFitK40_t< TF2 > JFitK40
Type definition for backward compatibility.
Definition: JFitK40.hh:807
o $QUALITY_ROOT d $DEBUG!CHECK_EXIT_CODE JPlot1D f
Definition: JDataQuality.sh:76
exit
Definition: JPizza.sh:36
data_type r[M+1]
Definition: JPolint.hh:779
then fatal Wrong number of arguments fi JConvertDetectorFormat a o
do JCanberra a $DETECTOR f $INPUT_FILE o $WORKDIR canberra[${EMITTER}\] root T $WORKDIR tripod txt V $WORKDIR sound_velocity txt M $WORKDIR mechanics txt H $WORKDIR hydrophone txt E $EMITTER $DISABLE d $DEBUG!done kill_child_processes_at_exit attach getModule a $DETECTOR typeset Z STRING typeset Z FLOOR for STRING in $STRINGS[*]
Definition: JCanberra.sh:68
static const double C
Physics constants.
then fatal Invalid string $STRING
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:21
do set_variable STRING_TXT awk
then JCalibrateToT a
Definition: JTuneHV.sh:116
then rm i $OUTPUT_FILE fi let RUN
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR set_variable DEBUG set_variable WORKDIR if do_usage *then usage for INPUT_FILE in $INPUT_FILES[*]
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DEBUG set_variable WORKDIR
Definition: JLegolas.sh:20
* usage
then JFileTuna f $INPUT_FILE
Definition: file-Tuna.sh:66
set_variable INPUT_FILE
do sput $STRING $FLOOR sget MODULE INPUT_FILES
Definition: JCanberra.sh:77
set_array INPUT_FILES argv[2,$((START_INDEX_STRING-1))] set_array STRINGS
then ls $DIR $ID
Definition: getArchive.sh:85
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
then set_variable MODULE getModule a $DETECTOR L $STRING $FLOOR JEditDetector a $DETECTOR M $MODULE add $X o $DETECTOR else echo No update of detector $DETECTOR
then display $WORKDIR
Definition: plot-Domino.sh:128
then eval ls $DIR $ID $TYPE _
Definition: getArchive.sh:104
set_variable DETECTOR
do set_variable DETECTOR_TXT $WORKDIR detector
then echo
Definition: JQAQC.sh:90
static JNullStream null
Null I/O stream.
Definition: JNullStream.hh:51
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
script
Definition: JAcoustics.sh:2
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
esac done
Definition: JAddHDE.sh:21
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
do alias $i