7 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
9 if ( do_usage $* ); then
10 usage "$script <daq_file> <detector_file> <jra_file> <output_file(.pdf)>"
14 fatal "No input files."
17 set_variable DAQ_FILE $1
19 set_variable DETECTOR_FILE $2
21 set_variable JRA_FILE $3
23 set_variable JRA_REPORT $4
25 set_variable OUT_DIR `readlink -f $(dirname ${JRA_REPORT})`
27 if [ ! -d ${OUT_DIR} ]
32 set_variable REPORT_NAME `echo $(basename ${JRA_REPORT} .pdf)`
34 set_variable TEMPLATE_DIR ${JPP_DIR}/software/JRunAnalyzer/report
36 set_variable PALETTE 112
38 set_array DAQ_HEADER `JPrintDAQHeader -f ${DAQ_FILE} -d 0`
40 typeset -Z 8 RUN_NUMBER=${DAQ_HEADER[2]}
42 set_variable REPORT_DIR `readlink -f ${OUT_DIR}/JRA_report_${RUN_NUMBER}`
44 set_variable FIGURE_DIR ${REPORT_DIR}/figures
46 set_variable INCLUDE_DIR ${REPORT_DIR}/include
48 if [ ! -d ${REPORT_DIR} ]
50 mkdir -p ${REPORT_DIR}
53 if [ ! -d ${FIGURE_DIR} ]
55 mkdir -p ${FIGURE_DIR}
58 if [ ! -d ${INCLUDE_DIR} ]
60 mkdir -p ${INCLUDE_DIR}
63 cp -r ${TEMPLATE_DIR}/figures/logo ${REPORT_DIR}/figures
65 cp -r ${TEMPLATE_DIR}/Makefile ${REPORT_DIR}
67 DET_FILE=$(basename ${DETECTOR_FILE} .detx).detx
69 TEX_DETFILE=$(sed -e "s/_/\$\\\\\\\\\\\_\$/g" <<< "${DET_FILE}")
71 # Here we start appending sed commands to a script that we will later apply to the template.
72 # These commands search a pattern in the template and substitute this pattern by some information obtained from the DAQ files.
74 printf 's/%s/%s/g\n' "--runNumber--" "${RUN_NUMBER}">script.sed
75 printf 's/%s/%s/g\n' "--detectorFile--" "${TEX_DETFILE}">>script.sed
76 printf 's/%s/%s/g\n' "--instrument--" "${INSTRUMENT}">>script.sed
78 ################################################################################################
79 # Get detector information such as the number of modules, number of DUs and number of floors. #
80 ################################################################################################
82 eval `JPrintDetector -a $DETECTOR_FILE -O SUMMARY`
84 printf 's/%s/%s/g\n' "--nStrings--" "${NUMBER_OF_STRINGS}">>script.sed
85 printf 's/%s/%s/g\n' "--nFloors--" "${NUMBER_OF_FLOORS}">>script.sed
86 printf 's/%s/%s/g\n' "--nModules--" "${NUMBER_OF_MODULES}">>script.sed
89 ##############################################
90 # Extract JDAQ Types present in the run file #
91 ##############################################
95 TIMESLICES=("TimesliceL0" "TimesliceL1" "TimesliceSN" "TimesliceL2")
97 set_array trees `JPrintTree -f $DAQ_FILE 2>&1`
100 for i in "${trees[@]}"; do
101 if [[ $i =~ '::JDAQ'(.*) ]]
103 printf 's/%s/%s/g\n' "--n${match[1]}--" "${trees[$((c+2))]}"
104 printf 's/%s/%s/g\n' "--s${match[1]}--" "${trees[$((c+3))]}"
105 if [ $trees[$((c+2))] -ne 0 ]
107 JDAQTYPES+=(${match[1]})
115 for i in "${TIMESLICES[@]}"; do
116 if [[ ${JDAQTYPES[(ie)$i]} -le ${#JDAQTYPES} ]]
123 ############################################################
124 # Extract ROOT versions of objects present in the run file #
125 ############################################################
127 set_array trees `JPrintRootVersion -f $DAQ_FILE 2>&1`
130 for i in "${trees[@]}"; do
131 if [[ $i =~ '::JDAQ'(.*) ]]
133 printf 's/%s/%s/g\n' "--r1${match[1]}--" "${trees[$((c+2))]}"
134 printf 's/%s/%s/g\n' "--r2${match[1]}--" "${trees[$((c+3))]}"
139 ##########################################
140 # Extract Trigger Parameters from JPrint #
141 ##########################################
143 parameter_list=("trigger3DShower.enabled" "trigger3DShower.numberOfHits" "trigger3DShower.numberOfModules" "trigger3DShower.DMax_m" "trigger3DShower.TMaxExtra_ns" "trigger3DShower.factoryLimit" "triggerMXShower.enabled" "triggerMXShower.numberOfHits" "triggerMXShower.numberOfModules" "triggerMXShower.DMax_m" "triggerMXShower.TMaxExtra_ns" "triggerMXShower.factoryLimit" "trigger3DMuon.enabled" "trigger3DMuon.numberOfHits" "trigger3DMuon.numberOfModules" "trigger3DMuon.DMax_m" "trigger3DMuon.roadWidth_m" "trigger3DMuon.gridAngle_deg" "trigger3DMuon.TMaxExtra_ns" "trigger3DMuon.factoryLimit" "highRateVeto_Hz" "writeTimeslices.prescale" "writeSummary.prescale" "writeL0.prescale" "writeL1.prescale" "writeL2.prescale" "writeSN.prescale")
145 for i in "${parameter_list[@]}"
147 TEX_REMATCH=$(sed -e "s/_/\\\\\\\_/g" <<< "${i}")
148 printf 's/%s/%s/g\n' "--${TEX_REMATCH}--" "$(JPrintTriggerParameters -f $DAQ_FILE -k ${i})"
152 #######################################
153 # Extract information from JPrintMeta #
154 #######################################
156 set_array run_info `JPrintMeta -f $DAQ_FILE 2>&1`
158 printf 's:%s:%s:g\n' "--rootdaq--" "${run_info[4]}">>script.sed
159 TEX_JPP=$(sed -e "s/_/\\\\\\\_/g" <<< "${run_info[2]}")
160 printf 's/%s/%s/g\n' "--jppdaq--" "${TEX_JPP}">>script.sed
162 set_array run_info `JPrintMeta -f $JRA_FILE 2>&1`
164 printf 's:%s:%s:g\n' "--rootjra--" "${run_info[4]}">>script.sed
165 TEX_JPP=$(sed -e "s/_/\\\\\\\_/g" <<< "${run_info[2]}")
166 printf 's/%s/%s/g\n' "--jppjra--" "${TEX_JPP}">>script.sed
168 root_v=`echo $run_info[4] | cut -c1`
170 if [[ $root_v -lt 6 ]];
175 set_array QAQC_V `${JPP_DIR}/software/JGizmo/JQAQC.sh $DETECTOR_FILE $DAQ_FILE`
177 set_array QAQC_H `${JPP_DIR}/software/JGizmo/JQAQC.sh -h!`
179 QAQC_P=("${QAQC_H[@]:5}")
182 for KEY in ${QAQC_P[*]}; do
183 TEX_KEY=$(sed -e "s/_/\\\\\\\_/g" <<< "${KEY}")
184 printf 's/%s/%s/g\n' "--${TEX_KEY}--" "${QAQC_V[$i]}"
188 ####################################################
189 # Create subsections in report for the desired DUs #
190 ####################################################
192 if [ "${#STRINGS[@]}" -gt 0 ];then
193 printf '/%%DU_SECTION%%/i \\\\\section{DU plots} \\\\\\nThe following section contains figures for specific DUs which are based on the explanations given in the previous sections. The axes titles and labels should be enough to understand the plots.
195 for du in "${STRINGS[@]}"; do
196 du_report=${INCLUDE_DIR}/DU_${du}.tex
197 printf 's/%s/%s/g\n' "--DUXX--" "${du}">script_${du}.sed
198 printf 's/%s/%s/g\n' "--least_bias_type--" "${least_bias_type}">>script_${du}.sed
199 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/h_mean_summary_rate -p "${PALETTE}" -O "colz" -T "DU${du} summary rates" -o "$FIGURE_DIR/mean_rate_summary_S${du}.png" -B
201 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/h_Snapshot_hits_per_pmt -p "${PALETTE}" -O "colz" -T "DU${du} Snapshot hits" -o "$FIGURE_DIR/snapshot_hits_pmt_S${du}.png" -B
203 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/h_Trigger_map -p "${PALETTE}" -O "colz" -T "DU${du} Trigger map" -o "$FIGURE_DIR/trigger_map_S${du}.png" -B
205 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/h_mean_ToT_"${least_bias_type}" -p "${PALETTE}" -O "colz" -T "mean ToT DU${du}" -o "$FIGURE_DIR/mean_ToT_S${du}_${least_bias_type}.png" -B
207 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/h_ToT_255_"${least_bias_type}" -p "${PALETTE}" -O "colz" -T "ToT = 255 ns DU${du}" -o "$FIGURE_DIR/ToT_255_S${du}_${least_bias_type}.png" -B
210 JPlot1D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/h_module_rate_vs_t. -O hist -L "TR" -y "1 2000000" -Y -T "" -o "$FIGURE_DIR/module_rates_S${du}F${f}.png" -B
212 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/"._${least_bias_type}_2SToT" -p "${PALETTE}" -O "colz" -T "DU${du}F${f} ${least_bias_type}" -o "$FIGURE_DIR/pmt_tot_S${du}F${f}_${least_bias_type}.png" -B
214 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/h_Trigger_map -p "${PALETTE}" -O "colz" -T "Trigger Map DU${du}F${f}" -o "$FIGURE_DIR/trigger_map_S${du}F${f}.png" -B
216 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/h_pmt_rate_distributions_"${least_bias_type}" -p "${PALETTE}" -O "colz" -x "1e-3 2e1" -X -T "DU${du}F${f} ${least_bias_type}" -o "$FIGURE_DIR/pmt_rates_S${du}F${f}_${least_bias_type}.png" -B
218 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/ToT_vs_time_"${least_bias_type}" -p "${PALETTE}" -O "colz" -z "1 100" -Z -T "DU${du}F${f} ${least_bias_type}" -o "$FIGURE_DIR/pmt_tot_vs_t_S${du}F${f}_${least_bias_type}.png" -B
220 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/h_rate_vs_time_"${least_bias_type}" -p "${PALETTE}" -O "colz" -z "1e0 5e2" -Z -T "DU${du}F${f} ${least_bias_type}" -o "$FIGURE_DIR/pmt_rate_vs_t_S${du}F${f}_${least_bias_type}.png" -B
222 JPlot2D -f "${JRA_FILE}":Detector/DU"${du}"/F"${f}"/h_dt_consecutive_hits_"${least_bias_type}" -p "${PALETTE}" -O "colz" -T "DU${du}F${f} ${least_bias_type}" -o "$FIGURE_DIR/pmt_consecutive_hits_S${du}F${f}_${least_bias_type}.png" -B
226 sed -f script_${du}.sed <${TEMPLATE_DIR}/include/DU.template >${du_report} && rm -f script_${du}.sed
227 printf '/%%DU_SECTION%%/i \\\\\input{%s}\n' "${du_report}"
231 ################################################################
232 # Now the sed script is used to replace in the template report #
233 ################################################################
235 sed -f script.sed <${TEMPLATE_DIR}/JRA_report.template >${REPORT_DIR}/${REPORT_NAME}.tex && rm -f script.sed
238 ############################
239 # Plot rest of the figures #
240 ############################
244 JPlot1D -f "${JRA_FILE}":Detector/h_fifo -O hist -L "TR" -T "" -o "$FIGURE_DIR/fifo_vs_time.png" -B
246 JPlot1D -f "${JRA_FILE}":Detector/h_daq_status -O hist -L "TR" -T "" -o "$FIGURE_DIR/daq_status_vs_time.png" -B
248 JPlot1D -f "${JRA_FILE}":Detector/h_hrv -O hist -L "TR" -T "" -o "$FIGURE_DIR/hrv_vs_time.png" -B
250 JPlot2D -f "${JRA_FILE}":Detector/h_fifo_per_dom -p "${PALETTE}" -O "colz" -T "" -o "$FIGURE_DIR/fifo_doms.png" -B
252 JPlot2D -f "${JRA_FILE}":Detector/h_daq_status_per_dom -p "${PALETTE}" -O "colz" -T "" -o "$FIGURE_DIR/daq_status_doms.png" -B
254 JPlot2D -f "${JRA_FILE}":Detector/h_hrv_per_dom -p "${PALETTE}" -O "colz" -T "" -o "$FIGURE_DIR/hrv_doms.png" -B
260 JPlot1D -f "${JRA_FILE}":Detector/h_pmt_rate_distribution -O hist -L "TR" -T "" -G "[X][Y]" -X -Y -s "1" -o "$FIGURE_DIR/pmt_rates_summary.png" -B
262 JPlot2D -f "${JRA_FILE}":Detector/h_rate_summary -p "${PALETTE}" -O "colz" -T "" -o "$FIGURE_DIR/mean_rates_summary.png" -B
264 JPlot1D -f "${JRA_FILE}":Detector/Rate/. -O hist -L "TR" -y "1 20000" -Y -T "" -o "$FIGURE_DIR/rates_vs_time.png" -B
266 JPlot2D -f "${JRA_FILE}":Detector/DOM_mean_rates/h_mean_dom_rates_"$least_bias_type" -p "${PALETTE}" -O "colz" -z "1 10000" -Z -T "$least_bias_type" -o "$FIGURE_DIR/mean_rates_DOM.png" -B
272 JPlot1D -f "${JRA_FILE}":Detector/Active_modules_detector/. -O hist -L "TR" -y "0 1.3" -T "" -o "$FIGURE_DIR/active_modules_vs_time.png" -B
274 JPlot2D -f "${JRA_FILE}":Detector/Active_modules_du/h_du_active_DOMS_"$least_bias_type" -p "${PALETTE}" -z "0 18" -O "colz" -T "$least_bias_type" -o "$FIGURE_DIR/active_modules_DU_vs_time.png" -B
279 JPlot1D -f "${JRA_FILE}":Detector/ToT_255_vs_time/. -O hist -L "TR" -T "Hits with ToT=255 ns" -X -G "[X][Y]" -o "$FIGURE_DIR/ToT_255_vs_time.png" -B
281 JPlot2D -f "${JRA_FILE}":Detector/ToT_255_Floor_vs_time/ToT_255_Floor_vs_time_2"$least_bias_type" -p "${PALETTE}" -O "colz" -T "Hits with ToT=255 ns ($i)" -o "$FIGURE_DIR/ToT_255_Floor_vs_time_.png" -B
286 JPlot1D -f "${JRA_FILE}":JDAQEvent/hits_per_event/. -O hist -L "TR" -T "" -G "[X][Y]" -X -o "$FIGURE_DIR/event_hits.png" -B
288 JPlot1D -f "${JRA_FILE}":JDAQEvent/hits_pmt_distributions/. -O hist -L "TR" -T "" -G "[X][Y]" -s "0" -o "$FIGURE_DIR/pmt_event_hits.png" -B
290 JPlot1D -f "${JRA_FILE}":JDAQEvent/hits_tot_distributions/. -O hist -L "TR" -T "" -y "0.5e-3 0.5" -Y -G "[X][Y]" -s "0" -o "$FIGURE_DIR/tot_event_hits.png" -B
292 JPlot1D -f "${JRA_FILE}":JDAQEvent/trigger_rates/. -O hist -L "BL" -T "Trigger rates" -y "0.5e-3 5" -Y -G "[X][Y]" -s "0" -o "$FIGURE_DIR/trigger_rates.png" -B
294 JPlot2D -f "${JRA_FILE}":JDAQEvent/h_Triggered_hits_per_module -p "${PALETTE}" -O "colz" -T "Triggered hits" -o "$FIGURE_DIR/triggered_hits_module.png" -B
296 JPlot2D -f "${JRA_FILE}":JDAQEvent/h_Snapshot_hits_per_module -p "${PALETTE}" -O "colz" -T "" -o "$FIGURE_DIR/snapshot_hits_module.png" -B
304 make doc >& /dev/null