Jpp  15.0.0-rc.2
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 
38 #
39 # Get background option for given input file.
40 #
41 # \param 1 input file
42 # \return option
43 #
44 function get_option()
45 {
46  if (( `JPrintTree -f $1 | awk '/JDAQSummaryslice/ { print $3 } '` > 0 )); then
47  echo rates
48  else
49  echo counts
50  fi
51 }
52 
53 
54 #
55 # Standard calibration.
56 #
57 # \param 1 detector
58 # \param 2 input file
59 #
60 function calibrate()
61 {
62  JPrintDAQHeader -f $2 | read ID RUN FRAME_INDEX UTC
63 
64  JCalibrateK40 \
65  -a $1 \
66  -f $2 \
67  -C $DAQ_TIMESLICE \
68  -o $WORKDIR/monitor_${RUN}.root \
69  -b `get_option $2` \
70  -d $DEBUG
71 
72  JMergeCalibrateK40 \
73  -f $WORKDIR/monitor_${RUN}.root \
74  -o $WORKDIR/merge_${RUN}.root \
75  -d $DEBUG
76 
77  JConvertDetectorFormat \
78  -a $1 \
79  -o $WORKDIR/detector_${RUN}.datx
80 
81  JFitK40 \
82  -a $WORKDIR/detector_${RUN}.datx \
83  -f $WORKDIR/merge_${RUN}.root \
84  -o $WORKDIR/fit_${RUN}.root \ $MODEL \
85  -A \
86  -w \
87  -d $DEBUG
88 }
89 
90 
91 #
92 # Hybrid calibration.
93 #
94 # \param 1 detector
95 # \param 2 reference run
96 # \param 3 input file
97 #
98 function hybrid()
99 {
100  JPrintDAQHeader -f $3 | read ID RUN FRAME_INDEX UTC
101 
102  JTDC \
103  -D $DETECTOR_ID \
104  -r "$2 $RUN" \
105  $DATABASE_OPTION \
106  -o "$WORKDIR/TDC_${2}_${RUN}.txt"
107 
108  JCalibrateK40 \
109  -a $1 \
110  -f $3 \
111  -C $DAQ_TIMESLICE \
112  -o $WORKDIR/monitor_${RUN}.root \
113  -b `get_option $3` \
114  -d $DEBUG
115 
116  JMergeCalibrateK40 \
117  -f $WORKDIR/monitor_${RUN}.root \
118  -o $WORKDIR/merge_${RUN}.root \
119  -d $DEBUG
120 
121  JConvertDetectorFormat \
122  -a $1 \
123  -o $WORKDIR/detector_${RUN}.datx
124 
125  JFitK40 \
126  -a $WORKDIR/detector_${RUN}.datx \
127  -f $WORKDIR/merge_${RUN}.root \
128  -o $WORKDIR/fit_${RUN}.root \ $MODEL \
129  -A \
130  -w \
131  -! $WORKDIR/TDC_${2}_${RUN}.txt \
132  -d $DEBUG
133 }
134 
135 
136 # Get run numbers
137 
138 eval `JPrintDetector -a $DETECTOR -O IDENTIFIER`
139 
140 RUNS=()
141 
142 for INPUT_FILE in $INPUT_FILES[*]; do
143 
144  JPrintDAQHeader -f $INPUT_FILE | read ID RUN FRAME_INDEX UTC
145 
146  if (( $ID != $DETECTOR_ID )); then
147  fatal "Detector identifier from $INPUT_FILE $ID != $DETECTOR_ID"
148  fi
149 
150  RUNS+=($RUN)
151 
152 done
153 
154 
155 calibrate $DETECTOR ${INPUT_FILES[1]}
156 
157 hybrid $WORKDIR/detector_${RUNS[1]}.datx ${RUNS[1]} ${INPUT_FILES[2]}
158 
159 hybrid $WORKDIR/detector_${RUNS[2]}.datx ${RUNS[2]} ${INPUT_FILES[3]}
160 
then usage $script< detector file >< detectorfile > nIf the range of floors is the first detector file is aligned to the second before the comparison fi case set_variable RANGE $argv[3]
&set_variable DAQ_TIMESLICE
Definition: JLegolas.sh:32
data_type w[N+1][M+1]
Definition: JPolint.hh:741
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[*]
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
then JMuonPostfit f
JFitK40_t< TF2 > JFitK40
Type definition for backward compatibility.
Definition: JFitK40.hh:807
then usage $script< detector file >< inputfile > nUtility script to create PDF and CDF of transition time distribution fi case set_variable WORKDIR
Definition: JLegolas.sh:31
set_variable INPUT_FILE
exit
Definition: JPizza.sh:36
data_type r[M+1]
Definition: JPolint.hh:742
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:20
then rm i $OUTPUT_FILE fi let RUN
do $DIR JTransitTime o
Definition: JTransitTime.sh:44
* usage
set_array INPUT_FILES
then JFileTuna f $INPUT_FILE
Definition: file-Tuna.sh:66
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
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
set_variable NUMBER_OF_ITERATIONS set_variable EPSILON cat acoustics_fit_parameters txt<< EOF $CONFIGURATION[*]Nmin=3;sigma_s=100.0e-6;stdev=10.0;mestimator=0;fixStrings=0;EOF for STRING in $STRINGS[*];do#fit stretching and(z) position of given string set_variable DETECTOR_TMP/tmp/detector_A.datx JEditDetector-a $DETECTOR-o $DETECTOR_TMP-r $STRING JEditDetector-a $DETECTOR-o $DETECTOR-k $STRING for MUL in 0.005 0.001;do DX_M=0.2 for((N=0;$N< $NUMBER_OF_ITERATIONS;++N));do CHI2[3]=$CHI2[1] fitPositionOfString $STRING Z $DX_M fitStretchingOfString $STRING $MUL if(($CHI2[3]-$CHI2[1]< $EPSILON));then break fi done if(($N >=$NUMBER_OF_ITERATIONS));then printf"warning: reached maximum number of iterations %d - converenge %7.3f\n"$N $(($CHI2[3]-$CHI2[1])) fi done JMergeDetector-a $DETECTOR-a $DETECTOR_TMP-o $DETECTOR rm-f $DETECTOR_TMP JConvertDetectorFormat-a $DETECTOR-o $DETECTOR-r-d 0 > &dev null done
script
Definition: JAcoustics.sh:2
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
set_array RUNS
Definition: JDataQuality.sh:23
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null