Jpp  19.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRandomEventRunByRun.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author zaly
4 #
5 version=1.0
6 script=${0##*/}
7 
8 # ------------------------------------------------------------------------------------------
9 #
10 # Script to jointly run JRandomTimesliceWriter and JTriggerProcessor in run-by-run mode.
11 #
12 # ------------------------------------------------------------------------------------------
13 
14 if [ -z $JPP_DIR ]; then
15  echo "Variable JPP_DIR undefined."
16  exit
17 fi
18 
19 source $JPP_DIR/setenv.sh $JPP_DIR
20 
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"
29 
30 set_variable DAQ_TIMESLICE JDAQTimesliceL0
31 
32 if do_usage $*; then
33  usage "$script <detector file> <detector file> <output file> <DAQ file> <PMT parameters file>"\
34  "\nAuxiliary script to produce random event data."
35 fi
36 
37 if (( $# == 5 )); then
38  set_variable DETECTORA $1
39  set_variable DETECTORB $2
43 else
44  fatal "Wrong number of arguments."
45 fi
46 
47 JPrintTree -f $DAQ_FILE -@ "type = JDAQSummaryslice" -k number_of_entries | read N
48 
49 set_variable RUNBYRUN "file=$DAQ_FILE; sampler=${SAMPLER%% *} $(($N / 2))"
50 
51 #################################################################################################
52 #
53 # The sampler values correspond to N_on N_off, respectively (note that sampler calls JSampler),
54 # where:
55 # N_on = number of time slices to read;
56 # N_off = number of time slices to skip.
57 #
58 # The sampler option works as follows.
59 # It will
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.
63 #
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 #################################################################################################
71 
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
77 
78 mkfifo $PIPE
79 
80 if [[ ! -p $PIPE ]]; then
81  fatal "Error opening $PIPE."
82 fi
83 
85 
86 JRandomTimesliceWriter \
87  -a ${DETECTORA} \
88  -o ${HEADER} \
89  -o ${PIPE} \
90  -n ${NUMBER_OF_SLICES} \
91  -P ${PMT_FILE} \
92  -P "QE=${FACTOR}" \
93  -S ${SEED} \
94  -B "$BACKGROUND_HZ" \
95  -N "$RECYCLING" \
96  -r "${RUNBYRUN}" \
97  -d ${DEBUG} \
98  --! &
99 
100 BG=$!
101 
102 JPrintTriggerParameters \
103  -f ${DAQ_FILE} > $PARAMETERS
104 
105 JTriggerProcessor \
106  -a ${DETECTORB} \
107  -f ${PIPE} \
108  -@ ${PARAMETERS} \
109  -C ${DAQ_TIMESLICE} \
110  -o ${TRIGGER} \
111  -d ${DEBUG} \
112  --!
113 
114 CHECK_EXIT_CODE
115 
116 JConvert \
117  -f ${HEADER} \
118  -f ${TRIGGER} \
119  -o ${OUTPUT_FILE} \
120  -m
121 
122 CHECK_EXIT_CODE
123 
124 # check exit code background process
125 
126 wait $BG
127 
128 STATUS=$?
129 
130 if (( $STATUS != 0 )); then
131  error "JRandomTimesliceWriter exit status $STATUS"
132  exit $STATUS
133 fi
134 
135 rm -rf ${DIR}
136 
137 timer_stop
138 timer_print
139 
140 JPrintTree \
141  -f ${OUTPUT_FILE}
142 
143 JTriggerMonitor \
144  -f ${OUTPUT_FILE} \
145  -o /dev/null
&set_variable DAQ_TIMESLICE
Definition: JLegolas.sh:32
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
std::istream & read(std::istream &in, JTestSummary &summary, const char delimiter= ' ')
Read test summary.
then usage $script[detector file[output file[trigger file[PMT parameters file]]]] fi case set_variable PMT_FILE
version
Definition: JEditTuneHV.sh:5
#define STATUS(A)
Definition: JMessage.hh:63
exit
Definition: JPizza.sh:36
data_type r[M+1]
Definition: JPolint.hh:868
then
Definition: datalogs.sh:34
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DETECTOR_ID set_array RUNS if do_usage *then usage $script< source directory > nThe source directory corresponds to a pre calibrated D0ARCA009 detector fi case set_variable DIR
then fatal Wrong number of arguments fi JConvertDetectorFormat a o
static const double C
Physics constants.
const int n
Definition: JPolint.hh:786
then timer_start(JRandomTimesliceWriter-a ${DETECTOR}-o ${PIPE}-n ${NUMBER_OF_SLICES}-P ${PMT_FILE}-d ${DEBUG}-S ${SEED}-B"$BACKGROUND_HZ"-N"$RECYCLING"--!&&for((i=0;$i!=10;++i));do;echo 'EOF' > $PIPE;usleep 100000;done &&rm-f $PIPE)&JTimesliceReprocessor-a $
then rm
Definition: sftpput.zsh:30
&set_variable PIPE
then JCalibrateToT a
Definition: JTuneHV.sh:107
const JK40Rates & getK40Rates()
Get K40 rates.
Definition: Antares.hh:27
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
&set_variable OUTPUT_FILE
&set_variable OUT_FILE set_variable DETECTOR_FILE set_variable DAQ_FILE
Definition: JRunAnalyzer.sh:24
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonStart.sh:47
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition: JDrawPDF.sh:45
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition: JMuonPostfit.sh:40
then JHobbit a $DETECTOR f
then echo
Definition: JQAQC.sh:92
then getFile sh $JPP_ARCHIVE $DETECTOR_ID $RUNS[1] $KEY $VERSION $WORKDIR
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
then $DIR JPlotNPE PDG P
Definition: JPlotNPE-PDG.sh:62
&set_variable TRIGGER
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62