Jpp  17.1.0
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 $WORKDIR/monitor_${RUN}.root \
70  -b `get_option $2` \
71  -d $DEBUG
72 
73  JMergeCalibrateK40 \
74  -f $WORKDIR/monitor_${RUN}.root \
75  -o $WORKDIR/merge_${RUN}.root \
76  -d $DEBUG
77 
78  JConvertDetectorFormat \
79  -a $1 \
80  -o $WORKDIR/detector_${RUN}.datx
81 
82  JFitK40 \
83  -a $WORKDIR/detector_${RUN}.datx \
84  -f $WORKDIR/merge_${RUN}.root \
85  -o $WORKDIR/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 "$WORKDIR/TDC_${2}_${RUN}.txt"
108 
109  JCalibrateK40 \
110  -a $1 \
111  -f $3 \
112  -C $DAQ_TIMESLICE \
113  -o $WORKDIR/monitor_${RUN}.root \
114  -b `get_option $3` \
115  -d $DEBUG
116 
117  JMergeCalibrateK40 \
118  -f $WORKDIR/monitor_${RUN}.root \
119  -o $WORKDIR/merge_${RUN}.root \
120  -d $DEBUG
121 
122  JConvertDetectorFormat \
123  -a $1 \
124  -o $WORKDIR/detector_${RUN}.datx
125 
126  JFitK40 \
127  -a $WORKDIR/detector_${RUN}.datx \
128  -f $WORKDIR/merge_${RUN}.root \
129  -o $WORKDIR/fit_${RUN}.root \ $MODEL \
130  -A \
131  -w \
132  -! $WORKDIR/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 calibrate $DETECTOR ${INPUT_FILES[1]}
157 
158 hybrid $WORKDIR/detector_${RUNS[1]}.datx ${RUNS[1]} ${INPUT_FILES[2]}
159 
160 hybrid $WORKDIR/detector_${RUNS[2]}.datx ${RUNS[2]} ${INPUT_FILES[3]}
161 
&set_variable DAQ_TIMESLICE
Definition: JLegolas.sh:32
data_type w[N+1][M+1]
Definition: JPolint.hh:757
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
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
JFitK40_t< TF2 > JFitK40
Type definition for backward compatibility.
Definition: JFitK40.hh:807
o $QUALITY_ROOT d $DEBUG!JPlot1D f
Definition: JDataQuality.sh:66
exit
Definition: JPizza.sh:36
data_type r[M+1]
Definition: JPolint.hh:758
then fatal Wrong number of arguments fi JConvertDetectorFormat a o
then echo
static const double C
Physics constants.
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 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
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
then JCalibrateToT a
Definition: JTuneHV.sh:116
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
*fatal Wrong number of arguments esac eval JPrintDetector a $DETECTOR O IDENTIFIER RUNS
then display $WORKDIR
Definition: plot-Domino.sh:128
set_variable DETECTOR
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 $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
esac done
Definition: JAddHDE.sh:21
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62