Skip to content
Snippets Groups Projects
Commit b0c7d689 authored by Felix Weiglhofer's avatar Felix Weiglhofer Committed by Florian Uhlig
Browse files

algo: Add test to ensure online reconstruction can process timeslice.

parent 6ee55548
No related branches found
No related tags found
1 merge request!1457algo: Add test to ensure online reconstruction can process timeslice.
Pipeline #25156 passed
...@@ -20,3 +20,20 @@ AddBasicTest(_GTestDigiEventSelector) ...@@ -20,3 +20,20 @@ AddBasicTest(_GTestDigiEventSelector)
AddBasicTest(_GTestYamlConfig) AddBasicTest(_GTestYamlConfig)
AddBasicTest(_GTestPartitionedVector) AddBasicTest(_GTestPartitionedVector)
AddBasicTest(_GTestPartitionedSpan) AddBasicTest(_GTestPartitionedSpan)
if (DEFINED ENV{RAW_DATA_PATH})
set(RAW_DATA_PATH $ENV{RAW_DATA_PATH})
set(TEST_SCRIPT ${CMAKE_SOURCE_DIR}/algo/test/realdata_test.sh)
set(RECO_BIN ${EXECUTABLE_OUTPUT_PATH}/cbmreco)
set(PARAMS_DIR ${CMAKE_SOURCE_DIR}/parameters/online)
set(TSA_FILE ${RAW_DATA_PATH}/2391_firstTs.tsa)
Add_Test(
NAME OnlineRecoCanProcessTimeslice
COMMAND ${TEST_SCRIPT} ${RECO_BIN} ${PARAMS_DIR} ${TSA_FILE}
)
set_tests_properties(OnlineRecoCanProcessTimeslice PROPERTIES TIMEOUT 600)
endif()
#!/bin/bash
cbmreco_bin=$1
parameter_dir=$2
tsa_file=$3
reco_args=" \
-p $parameter_dir \
-i $tsa_file \
-n1 \
--steps Unpack DigiTrigger LocalReco \
"
script=$(readlink -f "$0")
function check_arg {
if [ -z "$1" ]; then
echo "Error: <$2> not specified."
echo "Usage: $script <cbmreco_bin> <parameter_dir> <tsa_file>"
exit 1
fi
}
function ensure_gt_zero {
local output="$1"
local pattern="$2"
# Extract placeholders from the pattern, e.g. %1, %2, ..., %9
# [[ $? == 1 ]] is a workaround for the following issue:
# grep returns 1 if no match is found, but set -e causes the script to exit in this case
placeholders=($(echo "$pattern" | grep -o '%[0-9]\+' || [[ $? == 1 ]]))
if [[ $? -ne 0 ]]; then
echo "Error: Failed to extract placeholders: $pattern"
exit 1
fi
if [ -z "${placeholders[*]}" ]; then
echo "Error: No placeholders found: $pattern"
exit 1
fi
# Replace placeholders with a regex that matches the value
sed_pattern=$pattern
for placeholder in "${placeholders[@]}"; do
sed_pattern="${sed_pattern//$placeholder/\\([0-9]\\+\\)}"
done
for placeholder in "${placeholders[@]}"; do
# Use sed to extract the value for the current placeholder
# echo "Searching for $placeholder..."
id=$(echo "$placeholder" | grep -o '[0-9]\+')
value=$(echo "$output" | sed -n "s/.*$sed_pattern.*/\\$id/p")
if [ -n "$value" ] && [ "$value" -gt 0 ]; then
continue
else
echo "$pattern: FAIL ($placeholder is not greater than zero.)"
echo "Output:"
echo "$output"
exit 1
fi
done
echo "$pattern: OK"
}
check_arg "$cbmreco_bin" "cbmreco_bin"
check_arg "$parameter_dir" "parameter_dir"
check_arg "$tsa_file" "tsa_file"
# Run the reconstruction and capture the log
echo "Running '$cbmreco_bin $reco_args'"
log="$($cbmreco_bin $reco_args 2>&1)"
reco_ok=$?
echo "$log"
echo "=============================="
if [ $reco_ok -ne 0 ]; then
echo "Error: Reconstruction failed. Exit early."
exit 1
fi
# Check Digis
ensure_gt_zero "$log" "Timeslice contains %1 STS Digis"
ensure_gt_zero "$log" "Timeslice contains %1 TOF Digis"
ensure_gt_zero "$log" "Timeslice contains %1 BMON Digis"
ensure_gt_zero "$log" "Timeslice contains %1 MUCH Digis"
ensure_gt_zero "$log" "Timeslice contains %1 TRD Digis"
ensure_gt_zero "$log" "Timeslice contains %1 TRD2D Digis"
ensure_gt_zero "$log" "Timeslice contains %1 RICH Digis"
# Check Events
ensure_gt_zero "$log" "Triggers: %1, events %2"
# Check Hits
ensure_gt_zero "$log" "TS contains %1 TOF Hits"
ensure_gt_zero "$log" "Timeslice contains %1 STS hits and %2 STS clusters"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment