8 # ------------------------------------------------------------------------------------------
10 # Script to jointly run JRandomTimesliceWriter and JTriggerProcessor in run-by-run mode.
12 # ------------------------------------------------------------------------------------------
14 if [ -z $JPP_DIR ]; then
15 echo "Variable JPP_DIR undefined."
19 source $JPP_DIR/setenv.sh $JPP_DIR
21 set_variable: DEBUG RANDOMEVENT_DEBUG 1
22 set_variable: WORKDIR RANDOMEVENT_WORKDIR ./
23 set_variable: BACKGROUND_HZ RANDOMEVENT_BACKGROUND_HZ `getK40Rates`
24 set_variable: SEED RANDOMEVENT_SEED 0
25 set_variable: NUMBER_OF_SLICES RANDOMEVENT_SLICES 10
26 set_variable: RECYCLING RANDOMEVENT_RECYCLING "0 0"
27 set_variable: FACTOR RANDOMEVENT_FACTOR 1.0
28 set_variable: SAMPLER RANDOMEVENT_SAMPLER "1 1000"
30 set_variable DAQ_TIMESLICE JDAQTimesliceL0
33 usage "$script <detector file> <detector file> <output file> <DAQ file> <PMT parameters file>"\
34 "\nAuxiliary script to produce random event data."
37 if (( $# == 5 )); then
38 set_variable DETECTORA $1
39 set_variable DETECTORB $2
40 set_variable OUTPUT_FILE $3
41 set_variable DAQ_FILE $4
42 set_variable PMT_FILE $5
44 fatal "Wrong number of arguments."
47 JPrintTree -f $DAQ_FILE -@ "type = JDAQSummaryslice" -k number_of_entries | read N
49 set_variable RUNBYRUN "file=$DAQ_FILE; sampler=${SAMPLER%% *} $(($N / 2))"
51 #################################################################################################
53 # The sampler values correspond to N_on N_off, respectively (note that sampler calls JSampler),
55 # N_on = number of time slices to read;
56 # N_off = number of time slices to skip.
58 # The sampler option works as follows.
60 # read -on average- N_on consecutive time slices and
61 # skip -on average- N_off time slices
62 # modulo the number of time slices in the file.
64 # The larger N_on, the faster the reading, because this reduces the random accesses
65 # of the data taking file to pick up a next time slice.
66 # The smaller N_off, the less time slices are skipped.
67 # So, N_on = 0 guarantees that all time slices are sampled.
68 # Note that if the number of time slices to be produced is small, then too small a value of N_off
69 # could create a bias because only the first time slices of the data taking file are then sampled.
70 #################################################################################################
72 set_variable DIR `mktemp -d $WORKDIR/XXXXXX`
73 set_variable PIPE $DIR/pipe.dat
74 set_variable PARAMETERS $DIR/trigger_parameters.txt
75 set_variable TRIGGER $DIR/trigger_processor.root
76 set_variable HEADER $DIR/header.root
80 if [[ ! -p $PIPE ]]; then
81 fatal "Error opening $PIPE."
86 JRandomTimesliceWriter \
90 -n ${NUMBER_OF_SLICES} \
102 JPrintTriggerParameters \
103 -f ${DAQ_FILE} > $PARAMETERS
109 -C ${DAQ_TIMESLICE} \
124 # check exit code background process
130 if (( $STATUS != 0 )); then
131 error "JRandomTimesliceWriter exit status $STATUS"