Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
software/JTrigger/JTriggerEfficiencyRunByRun.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3# \author mdejong
4#
5script=${0##*/}
6
7# ------------------------------------------------------------------------------------------
8#
9# Script to run JTriggerEfficiency in run-by-run mode.
10#
11# ------------------------------------------------------------------------------------------
12
13if [ -z $JPP_DIR ]; then
14 echo "Variable JPP_DIR undefined."
15 exit
16fi
17
18source $JPP_DIR/setenv.sh $JPP_DIR
19
20set_variable: DEBUG TRIGGEREFFICIENCY_DEBUG 1
21set_variable: WORKDIR TRIGGEREFFICIENCY_WORKDIR ./
22set_variable: BACKGROUND_HZ TRIGGEREFFICIENCY_BACKGROUND_HZ `getK40Rates`
23set_variable: SEED TRIGGEREFFICIENCY_SEED 0
24set_variable: NUMBER_OF_TIMESLICES TRIGGEREFFICIENCY_NUMBER_OF_TIMESLICES 0
25set_variable: FACTOR TRIGGEREFFICIENCY_FACTOR 1.0
26set_variable: MARGIN TRIGGEREFFICIENCY_MARGIN 20
27set_variable: SAMPLER TRIGGEREFFICIENCY_SAMPLER "100 1000"
28set_variable+ OPTION TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY -O
29set_variable+ DISABLE_TURBOT TRIGGEREFFICIENCY_DISABLE_TURBOT Y
30
31if do_usage $*; then
32 usage "$script <detector file> <detector file> (input file)+ <output file> <DAQ file> <PMT parameters file>"\
33 "\nAuxiliary script to trigger Monte Carlo events."\
34 "\nThe first detector file is used to convert the true data to DAQ data and the second to covert DAQ data to calibrated data."\
35 "\nNormally, these correspond to the 'perfect' calibration and the 'online' calibration, respectively."
36fi
37
38if (( $# >= 6 )); then
39 set_variable PMT_FILE $argv[-1]
40 set_variable DAQ_FILE $argv[-2]
41 set_variable OUTPUT_FILE $argv[-3]
42 set_array INPUT_FILES $argv[3,-4]
43 set_variable DETECTORB $argv[2]
44 set_variable DETECTORA $argv[1]
45else
46 fatal "Wrong number of arguments."
47fi
48
49timer_start
50
51JPrintTree -f $DAQ_FILE -@ "type = JDAQSummaryslice" -k number_of_entries | read N
52
53set_variable RUNBYRUN $DAQ_FILE
54
55set_variable DETECTORA_2 `mktemp $WORKDIR/${${DETECTORA:t}:r}_XXXXXX.datx`
56set_variable DETECTORB_2 `mktemp $WORKDIR/${${DETECTORB:t}:r}_XXXXXX.datx`
57set_variable PMT_FILE_2 `mktemp $WORKDIR/PMT_XXXXXX.txt`
58
59JConvertDetectorFormat -a ${DETECTORA} -o ${DETECTORA_2}
60JConvertDetectorFormat -a ${DETECTORB} -o ${DETECTORB_2}
61
62
63# Procedure to determine optical modules with out-sync-problem.
64# The given detector file is accordingly updated.
65
66if [[ "$DISABLE_TURBOT" != "Y" ]]; then
67
68 JTurbot \
69 -f ${DAQ_FILE} \
70 -a ${DETECTORA_2} \
71 -A \
72 -d ${DEBUG} \
73 -N ${NUMBER_OF_TIMESLICES} \
74 --!
75
76 CHECK_EXIT_CODE
77
78 timer_lap
79fi
80
81
82# Procedure to determine Jpp version used during data taking as default handling of UDP packet losses has changed.
83# The given detector file is accordingly updated.
84
85JPrintMeta -f ${DAQ_FILE} -k GIT | read DAQ_VERSION
86
87echo ${(s/./)DAQ_VERSION} | read DAQ_MAJOR DAQ_MINOR DAQ_PATCH
88
89if [[ "$DAQ_MAJOR" != [0-9][0-9]* ]] || (( $DAQ_MAJOR <= 12 )); then # Jpp-version dependence
90
91 notice "Set UDP counter and trailer disable."
92
93 JEditDetector \
94 -a ${DETECTORB_2} \
95 -P "-1 -1 set UDP_COUNTER_DISABLE" \
96 -P "-1 -1 set UDP_TRAILER_DISABLE" \
97 -o ${DETECTORB_2}
98
99 CHECK_EXIT_CODE
100fi
101
102
103JEditPMTParameters \
104 -P ${PMT_FILE} \
105 -o ${PMT_FILE_2} \
106 -Q "0 $((1.0 / $FACTOR))" \
107 -d ${DEBUG} \
108 --!
109
110
111JTriggerEfficiency \
112 -a ${DETECTORA_2} \
113 -b ${DETECTORB_2} \
114 -f"${INPUT_FILES[*]}" \
115 -o ${OUTPUT_FILE} \
116 -P ${PMT_FILE_2} \
117 -P "QE=${FACTOR}" \
118 ${OPTION} \
119 -S ${SEED} \
120 -B "$BACKGROUND_HZ" \
121 -r "${RUNBYRUN}" \
122 -m ${MARGIN} \
123 -d ${DEBUG} \
124 --!
125
126CHECK_EXIT_CODE
127
128timer_lap
129
130
131JPrintMeta \
132 -f ${OUTPUT_FILE}
133
134JPrintTree \
135 -f ${OUTPUT_FILE}
136
137JTriggerMonitor \
138 -f ${OUTPUT_FILE} \
139 -o /dev/null
140
141
142rm -f ${DETECTORA_2}
143rm -f ${DETECTORB_2}
144rm -f ${PMT_FILE_2}