Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
JCalibrateK40.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 #
4 # \author mdejong
5 #
6 version=1.0
7 script=${0##*/}
8 
9 # ------------------------------------------------------------------------------------------
10 #
11 # Utility script to test JCalibrateK40/JFitK40.
12 #
13 # ------------------------------------------------------------------------------------------
14 
15 if [ -z $JPP_DIR ]; then
16  echo "Variable JPP_DIR undefined."
17  exit
18 fi
19 
20 source $JPP_DIR/setenv.sh $JPP_DIR
21 
22 set_variable DEBUG 2
23 set_variable WORKDIR ${TMPDIR:-/tmp}/
24 set_variable: FORMAT GRAPHICS_FORMAT gif
25 set_variable+ BATCH GRAPHICS_BATCH -B
26 
27 if do_usage $*; then
28  usage "$script [working directory]"
29 fi
30 
31 case $# in
32  1) set_variable WORKDIR $1;;
33 esac
34 
35 set_variable DETECTOR $WORKDIR/detector.detx
36 set_variable BACKGROUND_HZ 5e3 440 50 5 0.5
37 set_variable QE 1.0
38 set_variable numberOfSlices 6000
39 
40 
41 if (( 1 )); then
42 
43  set_variable detectorType 1
44  set_variable numberOfLines 1
45  set_variable numberOfFloors 1
46 
47  JDetector \
48  -D 1 \
49  -@ "detectorType = $detectorType" \
50  -@ "numberOfLines = $numberOfLines" \
51  -@ "numberOfFloors = $numberOfFloors" \
52  -o $DETECTOR -V V2 \
53  -d $DEBUG
54 
55 fi
56 
57 if (( 1 )); then
58 
59  debug "Generating random background."
60 
61  if ( ! reuse_file $WORKDIR/timeslice.root ); then
62 
63  JRandomTimesliceWriter \
64  -a $DETECTOR \
65  -o $WORKDIR/timeslice.root \
66  -B "$BACKGROUND_HZ" \
67  -n $numberOfSlices \
68  -P "pmt= 101 0 QE=$QE" \
69  -P "pmt= 101 1 QE=$QE" \
70  -P "pmt= 101 2 QE=$QE" \
71  -P "pmt= 101 1 QE=$QE" \
72  -P "pmt= 101 3 QE=$QE" \
73  -P "pmt= 101 4 QE=$QE" \
74  -P "pmt= 101 5 QE=$QE" \
75  -P "pmt= 101 6 QE=$QE" \
76  -P "pmt= 101 7 QE=$QE" \
77  -P "pmt= 101 8 QE=$QE" \
78  -P "pmt= 101 9 QE=$QE" \
79  -P "pmt= 101 10 QE=$QE" \
80  -P "pmt= 101 11 QE=$QE" \
81  -P "pmt= 101 12 QE=$QE" \
82  -P "pmt= 101 11 QE=$QE" \
83  -P "pmt= 101 13 QE=$QE" \
84  -P "pmt= 101 14 QE=$QE" \
85  -P "pmt= 101 15 QE=$QE" \
86  -P "pmt= 101 16 QE=$QE" \
87  -P "pmt= 101 17 QE=$QE" \
88  -P "pmt= 101 18 QE=$QE" \
89  -P "pmt= 101 19 QE=$QE" \
90  -P "pmt= 101 20 QE=$QE" \
91  -P "pmt= 101 21 QE=$QE" \
92  -P "pmt= 101 22 QE=$QE" \
93  -P "pmt= 101 21 QE=$QE" \
94  -P "pmt= 101 23 QE=$QE" \
95  -P "pmt= 101 24 QE=$QE" \
96  -P "pmt= 101 25 QE=$QE" \
97  -P "pmt= 101 26 QE=$QE" \
98  -P "pmt= 101 27 QE=$QE" \
99  -P "pmt= 101 28 QE=$QE" \
100  -P "pmt= 101 29 QE=$QE" \
101  -P "pmt= 101 30 QE=$QE" \
102  -d $DEBUG --!
103 
104  fi
105 fi
106 
107 if (( 1 )); then
108 
109  debug "Processing data."
110 
111  if ( ! reuse_file $WORKDIR/trigger_processor.root ); then
112 
113  JTriggerProcessor \
114  -a $DETECTOR \
115  -f $WORKDIR/timeslice.root \
116  -o $WORKDIR/trigger_processor.root \
117  -@"ctMin=-1.0" \
118  -@"TMaxLocal_ns=50" \
119  -@"writeL1=1" \
120  -d $DEBUG
121 
122  fi
123 fi
124 
125 if (( 1 )); then
126 
127  debug "Monitoring data."
128 
129  JCalibrateK40 \
130  -f $WORKDIR/trigger_processor.root \
131  -C JDAQTimesliceL1 \
132  -a $DETECTOR \
133  -o $WORKDIR/monitor.root \
134  -d $DEBUG
135 
136  debug "Merging data."
137 
138  JMergeCalibrateK40 \
139  -f $WORKDIR/monitor.root \
140  -o $WORKDIR/merge.root \
141  -d $DEBUG
142 
143  debug "Fitting data."
144  debug "Detector: $DETECTOR"
145 
146  JFitK40 \
147  -a $DETECTOR \
148  -f $WORKDIR/merge.root \
149  -o $WORKDIR/fit.root \
150  -w \
151  -d $DEBUG
152 
153 fi
154 
155 if (( 1 )); then
156 
157  debug "Plotting results"
158 
159  JPlot2D \
160  -f $WORKDIR/monitor.root:\.\*2S \
161  -OLEGO \
162  -> "PMT pair" \
163  -< "#DeltaT [ns]" \
164  -T "" \
165  -o monitor.$FORMAT $BATCH
166 
167 fi
168 
169 if (( 1 )); then
170 
171  debug "Plotting standard deviations"
172 
173  JPlot2D \
174  -f $WORKDIR/fit.root:\.\*2F \
175  -OLEGO \
176  -> "PMT pair" \
177  -< "#DeltaT [ns]" \
178  -z "-3 +3" \
179  -T "standard deviation" \
180  -o stdev.$FORMAT $BATCH
181 
182 fi
183 
184 if (( 1 )); then
185 
186  debug "Plotting results for t0"
187 
188  JPlot1D \
189  -f $WORKDIR/fit.root:\.\*1t0 \
190  -y "-10 +10" \
191  -> "PMT" \
192  -\^ "#DeltaT [ns]" \
193  -L TR \
194  -T "time calibration" \
195  -o t0.$FORMAT $BATCH
196 
197 fi
198 
199 if (( 1 )); then
200 
201  debug "Plotting results for sigma"
202 
203  JPlot1D \
204  -f $WORKDIR/fit.root:\.\*1sigma \
205  -y "0 5" \
206  -> "PMT" \
207  -\^ "#sigma [ns]" \
208  -L TR \
209  -T "time resolution" \
210  -o sigma.$FORMAT $BATCH
211 
212 fi
213 
214 
215 if (( 1 )); then
216 
217  debug "Plotting results for QE"
218 
219  JPlot1D \
220  -f $WORKDIR/fit.root:\.\*1QE \
221  -y "0 2" \
222  -> "PMT" \
223  -\^ "QE" \
224  -L TR \
225  -T "QE" \
226  -o QE.$FORMAT $BATCH
227 
228 fi