Jpp  18.4.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 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  -@ "LIVETIME_S = 10" \
77  -d $DEBUG
78 
79  JConvertDetectorFormat \
80  -a $1 \
81  -o $WORKDIR/detector_${RUN}.datx
82 
83  JFitK40 \
84  -a $WORKDIR/detector_${RUN}.datx \
85  -f $WORKDIR/merge_${RUN}.root \
86  -o $WORKDIR/fit_${RUN}.root \ $MODEL \
87  -A \
88  -w \
89  -d $DEBUG
90 }
91 
92 
93 #
94 # Hybrid calibration.
95 #
96 # \param 1 detector
97 # \param 2 reference run
98 # \param 3 input file
99 #
100 function hybrid()
101 {
102  JPrintDAQHeader -f $3 | read ID RUN FRAME_INDEX UTC
103 
104  JTDC \
105  -D $DETECTOR_ID \
106  -r "$2 $RUN" \
107  $DATABASE_OPTION \
108  -o "$WORKDIR/TDC_${2}_${RUN}.txt"
109 
110  JCalibrateK40 \
111  -a $1 \
112  -f $3 \
113  -C $DAQ_TIMESLICE \
114  -o $WORKDIR/monitor_${RUN}.root \
115  -b `get_option $3` \
116  -d $DEBUG --!
117 
118  JMergeCalibrateK40 \
119  -f $WORKDIR/monitor_${RUN}.root \
120  -o $WORKDIR/merge_${RUN}.root \
121  -@ "LIVETIME_S = 10" \
122  -d $DEBUG
123 
124  JConvertDetectorFormat \
125  -a $1 \
126  -o $WORKDIR/detector_${RUN}.datx
127 
128  JFitK40 \
129  -a $WORKDIR/detector_${RUN}.datx \
130  -f $WORKDIR/merge_${RUN}.root \
131  -o $WORKDIR/fit_${RUN}.root \ $MODEL \
132  -A \
133  -w \
134  -! $WORKDIR/TDC_${2}_${RUN}.txt \
135  -d $DEBUG
136 }
137 
138 
139 # Get run numbers
140 
141 eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
142 
143 RUNS=()
144 
145 for INPUT_FILE in $INPUT_FILES[*]; do
146 
147  JPrintDAQHeader -f $INPUT_FILE | read ID RUN FRAME_INDEX UTC
148 
149  if (( $ID != $DETECTOR_ID )); then
150  fatal "Detector identifier from $INPUT_FILE $ID != $DETECTOR_ID"
151  fi
152 
153  RUNS+=($RUN)
154 
155 done
156 
157 
158 calibrate $DETECTOR ${INPUT_FILES[1]}
159 
160 hybrid $WORKDIR/detector_${RUNS[1]}.datx ${RUNS[1]} ${INPUT_FILES[2]}
161 
162 hybrid $WORKDIR/detector_${RUNS[2]}.datx ${RUNS[2]} ${INPUT_FILES[3]}
163 
&set_variable DAQ_TIMESLICE
Definition: JLegolas.sh:32
data_type w[N+1][M+1]
Definition: JPolint.hh:867
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 Wrong number of arguments fi set_variable ARCHIVE $argv[1] set_variable DETECTOR_ID $argv[2] set_variable VERSION $argv[3] RUN
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
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:868
then
Definition: datalogs.sh:31
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable TRIPOD $argv[2] set_array INPUT_FILES $argv[3,-1] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O CAN JAcoustics sh $DETECTOR_ID
Definition: footprint.sh:38
then fatal Wrong number of arguments fi JConvertDetectorFormat a o
then fatal Missing detector file $DETECTOR fi eval JPrintDetector a $DETECTOR O IDENTIFIER RUNS
static const double C
Physics constants.
do set_variable STRING_TXT awk
then JCalibrateToT a
Definition: JTuneHV.sh:113
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
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:79
then ls $DIR $ID
Definition: getArchive.sh:85
fi set_variable FILENAME $WORKDIR
Definition: datalogs.sh:34
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47
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:48
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 eval ls $DIR $ID $TYPE _
Definition: getArchive.sh:104
set_variable DETECTOR
then echo
Definition: JQAQC.sh:90
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
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