From 1d9c082d0aa9800bae6db6a2d50e5815f219e5d3 Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Thu, 20 Jun 2024 15:41:59 +0200 Subject: [PATCH] mcbm2024: a script for data reconstruction steps execution --- algo/ca/core/CMakeLists.txt | 42 ++-- macro/beamtime/mcbm2024/reco_mcbm.sh | 274 +++++++++++++++++++++++++++ 2 files changed, 295 insertions(+), 21 deletions(-) create mode 100755 macro/beamtime/mcbm2024/reco_mcbm.sh diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index 5d1b64b618..9b947db60a 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -82,8 +82,8 @@ install( #data/CaGridEntry.h #data/CaHit.h #data/CaInputData.h - #data/CaTrackParam.h - #data/CaTrack.h + data/CaTrackParam.h + data/CaTrack.h #data/CaMeasurementU.h #data/CaMeasurementXy.h #data/CaMeasurementTime.h @@ -94,38 +94,38 @@ install( #data/CaGridArea.h #data/CaTriplet.h #data/CaBranch.h - #data/CaWindowData.h + data/CaWindowData.h #data/CaTimesliceHeader.h - #pars/CaConstants.h - #pars/CaField.h - #pars/CaInitManager.h - #pars/CaIteration.h - #pars/CaMaterialMap.h - #pars/CaMaterialMonitor.h - #pars/CaParameters.h - #pars/CaSearchWindow.h - #pars/CaStation.h + pars/CaConstants.h + pars/CaField.h + pars/CaInitManager.h + pars/CaIteration.h + pars/CaMaterialMap.h + pars/CaMaterialMonitor.h + pars/CaParameters.h + pars/CaSearchWindow.h + pars/CaStation.h #pars/CaStationInitializer.h - #utils/CaTrackingMonitor.h - #utils/CaEnumArray.h - #utils/CaMonitor.h - #utils/CaMonitorData.h + utils/CaTrackingMonitor.h + utils/CaEnumArray.h + utils/CaMonitor.h + utils/CaMonitorData.h #utils/CaObjectInitController.h #utils/CaSimd.h #utils/CaSimdVc.h #utils/CaSimdPseudo.h #utils/CaTimer.h - #utils/CaVector.h - #utils/CaUtils.h - #utils/CaDefines.h + utils/CaVector.h + utils/CaUtils.h + utils/CaDefines.h #tracking/CaCloneMerger.h #tracking/CaFramework.h #tracking/CaTrackExtender.h #tracking/CaTrackFinder.h #tracking/CaTrackFinderWindow.h - #tracking/CaTrackFit.h - #tracking/CaTrackFitter.h + tracking/CaTrackFit.h + tracking/CaTrackFitter.h #tracking/CaTripletConstructor.h DESTINATION include/ diff --git a/macro/beamtime/mcbm2024/reco_mcbm.sh b/macro/beamtime/mcbm2024/reco_mcbm.sh new file mode 100755 index 0000000000..7fc3c80ddd --- /dev/null +++ b/macro/beamtime/mcbm2024/reco_mcbm.sh @@ -0,0 +1,274 @@ +#!/bin/bash +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only +# Authors: Sergei Zharko [committer] +# +# @file reco_mcbm.sh +# @brief Script to run the TSA file reconstruction in mCBM +# @since 21.05.2024 +# @author Sergei Zharko <s.zharko@gsi.de> +# +# ********************************************************************************************************************** +# *** User Manual (v. 0.0.1, 19.06.2024) *** +# ********************************************************************************************************************** +# +# 1. Definitions +# <setup>: +# An official setup tag, e.g. "mcbm_beam_2024_05_08_nickel". +# <label>: +# A common part of name bases of the data-files, e.g. "3105_node8_05_0002" +# NOTE: <label> is strictly determined at least for a particular setup. +# <top_dir>: +# A top "data" directory. +# +# 2. Introduction +# +# This script aims to provide a generic data reconstruction scenario in mCBM, which includes: +# - setup files generation: [--setup] +# - TSA file unpacking [--unpack] +# - reconstruction [--reco] +# - main QA [--qa] +# - reconstruciton QA (Alex) [--qa-module] +# +# Required options: +# --tsa <path> Path to the input TSA file +# NOTE: must contain a run index as a first integer in its base name. +# --param-online <path> Path to the online parameters +# NOTE: must be ${VMCWORKDIR}/parameters/online, but the current parameter repositories +# a diverged for the detector and online binary parameters. +# Auxiliary options: +# -n [--nts] <N_TS> Number of timeslices to procede +# --setup, --unpack, --reco, --qa, --qa-module +# +# 3. File names involved: +# <geo>: Input geometry file: <top_dir>/<setup>.geo.root +# <par>: Input parameter file: <top_dir>/<setup>.par.root --copy--> <top_dir>/<label>.par.root +# <tra>: Dummy transport file: <top_dir>/<setup>.tra.root +# <digi>: Digitization output: <top_dir>/<label>.digi.root --ln--> <top_dir>/<label>.raw.root +# <reco>: Reconstruction output: <top_dir>/<label>.reco.root --ln--> <top_dir>/<label>.rec.root +# <qa>: Main QA output: <top_dir>/<label>.qa.root +# <qa-module>: Reconstruction module QA: <top_dir>/<label>.rqa.root +# +# +# 4. Parameters situation (for 20.06.2024) +# The cbmroot_parameter repository is diverged: the valid online binary parameters are stored in the main CbmSoft/ +# cbmroot_parameter repository, and the detector parameters are stored on the mCBM fork of this repository. This +# will be changed with the merger request !1864 to the cbmroot master. For now one can checkout the main parameter +# repository with: +# cd /path/to/dir +# git clone https://git.cbm.gsi.de/CbmSoft/cbmroot_parameter.git +# cd cbmroot_parameter +# git remote add upstream https://git.cbm.gsi.de/CbmSoft/cbmroot_parameter.git +# git fetch --al +# Provide a path --param-online /path/to/dir/cbmroot_parameter/online +# +# To configure CbmRoot with correct mcbm parameters, one must provide a parameter -DCBM_MCBM_PARS=1 in the +# cmake configuration command. +# +# +# ********************* +# ** USER PARAMETERS ** +# ********************* + +# Data directory +DATA_TOP_DIR='./data' + +# Subsystem flags +RECO_MVD=0 +RECO_STS=1 +RECO_TRD=1 +RECO_TRD2d=1 +RECO_RICH=0 +RECO_MUCH=0 +RECO_TOF=1 +RECO_FSD=0 +RECO_PSD=0 + +# Algorithm flags +RECO_TOFtr=0 +RECO_ALI=0 +RECO_EvB=1 +RECO_CA=1 +RECO_QA=0 + + +# ---------------------------------------------------------------------------------------------------------------------- +# ---------------------------------------------------------------------------------------------------------------------- + + +# ************************* +# ** Parameter selection ** +# ************************* + +# ----- Execution steps +DO_CREATE_SETUP=0 +DO_UNPACK=0 +DO_RECO=0 +DO_QA=0 # Main QA Macro +DO_QA_MODULE=0 # QA Macro by Alexandru +ONLINE_PAR= + +# ----- Run information +RUN=-1 +TSA= +N_TS=-1 +while [[ $# > 0 ]]; do + case ${1} in + --setup ) + CREATE_SETUP=1 + ;; + --unpack ) + DO_UNPACK=1 + ;; + --reco ) + DO_RECO=1 + ;; + --qa ) + DO_QA=1 + ;; + --qa-module ) + DO_QA_MODULE=1 + ;; + --tsa ) + TSA=${2} + ;; + --param-online ) + ONLINE_PAR=${2} + ;; + -n | --nts ) + N_TS=${2} + ;; + esac + shift +done + +# ----- Check the environment +# +if [[ -z "${VMCWORKDIR}" ]]; then + printf "E- CBM environment is not defined (VMCWORKDIR is not found). Please, configure your CbmRoot\n" + exit 1 +fi + +# ----- Select the reconstruction binary +ONLINE_BINARY="${VMCWORKDIR}/../../bin/cbmreco" +if [[ ! -x "${ONLINE_BINARY}" ]]; then + ONLINE_BINARY=$(which cbmreco) + if [[ ! -x "${ONLINE_BINARY}" ]]; then + printf "E- Online binary was not found. Please, install and configure your CbmRoot " + printf "or provide the bin directory in the PATH environmental variable\n" + exit 2 + fi +fi + +printf "I- Online binary path: %s, with parameters: %s\n" ${ONLINE_BINARY} ${ONLINE_PAR} + +# ----- Check the TSA input and retrieve the run index +if [[ -z ${TSA} ]]; then + printf "E- TSA input file is not defined\n" + exit 3 +fi +TSA_INFO=($(basename $(echo ${TSA}) | grep -oE '[0-9]*')) + +RUN=${TSA_INFO[0]} # Implying, that TSA basename contains run index as the first integer +if [[ ${RUN} -lt 0 ]]; then + printf "E- Run number is undefined, please try again with option -r <RUN> or --run <RUN>\n" +fi + +mkdir -p ${DATA_TOP_DIR} + +# ----- Filenames definition +TSA_INP=${TSA} +MACRO_SETUP="${VMCWORKDIR}/macro/run/create_mcbm_geo_setup.C" +MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C" +MACRO_QA="${VMCWORKDIR}/macro/mcbm/mcbm_qa.C" +MACRO_QA_MODULE="${VMCWORKDIR}/macro/qa/run_recoQa.C" +SETUP_NAME= + +if [[ ${RUN} -ge 2350 && ${RUN} -le 2397 ]]; then + SETUP_NAME="mcbm_beam_2022_05_23_nickel" + MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C" +elif [[ ${RUN} -ge 2454 && ${RUN} -le 2497 ]]; then + SETUP_NAME="mcbm_beam_2022_06_16_gold" + MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C" +elif [[ ${RUN} -ge 2498 && ${RUN} -le 2610 ]]; then + SETUP_NAME="mcbm_beam_2022_06_18_gold" + MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2022/mcbm_event_reco_L1.C" +elif [[ ${RUN} -ge 2724 && ${RUN} -le 2917 ]]; then + SETUP_NAME="mcbm_beam_2024_03_22_gold" + MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2024/mcbm_event_reco_L1.C" +elif [[ ${RUN} -ge 2918 ]]; then + SETUP_NAME="mcbm_beam_2024_05_08_nickel" + MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2024/mcbm_event_reco_L1.C" +else + printf "E- Run ${RUN} is undefined. Exiting" + exit 4 +fi + +# ----- +# File +FILE_LABEL=$(printf $(basename ${TSA_INP}) | cut -f 1 -d '.') +INP_FILE="${FILE_LABEL}" +OUT_DIGI= +if [[ ${RUN} -ge 2724 ]]; then + OUT_DIGI="${DATA_TOP_DIR}/${FILE_LABEL}.digi.out" + INP_FILE="${DATA_TOP_DIR}/${FILE_LABEL}.digi.root" +fi + +# ********************* +# ** Steps execution ** +# ********************* + +# ----- Create setup files +if [[ ${CREATE_SETUP} -eq 1 ]]; then + root -b -l -q ${MACRO_SETUP}"(${RUN}, \"${DATA_TOP_DIR}\")" +fi + +# ----- Run unpacker +if [[ ${DO_UNPACK} -eq 1 ]]; then + # TODO: Define unpack options for different setups + ${ONLINE_BINARY} --steps Unpack -i ${TSA_INP} -r ${RUN} -p ${ONLINE_PAR} -O DigiTimeslice -o ${OUT_DIGI} -s STS BMON TOF TRD RICH + + root -l -b -q ${VMCWORKDIR}/macro/run/run_inspect_digi_timeslice.C"(\"${OUT_DIGI}\", \"${INP_FILE}\")" + rm ${OUT_DIGI} +fi + +# ----- Run reconstruction +if [[ ${DO_RECO} -eq 1 ]]; then + UNP_FILE_ID=-1 + cp "${DATA_TOP_DIR}/${SETUP_NAME}.par.root" "${DATA_TOP_DIR}/${FILE_LABEL}.par.root" + DATA_PREF="${DATA_TOP_DIR}" + PARS="${RUN},${N_TS},\"${DATA_PREF}\",\"${DATA_PREF}\",${UNP_FILE_ID},${RECO_MVD},${RECO_STS},${RECO_TRD}" + PARS="${PARS},${RECO_TRD2d},${RECO_RICH},${RECO_MUCH},${RECO_TOF},${RECO_TOFtr},${RECO_PSD},${RECO_ALI},${RECO_EvB}" + PARS="${PARS},${RECO_CA},${RECO_QA},${RECO_FSD},\"${INP_FILE}\"" + root -b -l -q ${MACRO_RECO}"(${PARS})" + ln -s "${FILE_LABEL}.digi.root" "${DATA_TOP_DIR}/${FILE_LABEL}.raw.root" # TMP for QA + ln -s "${FILE_LABEL}.reco.root" "${DATA_TOP_DIR}/${FILE_LABEL}.rec.root" # TMP for QA +fi + +# ----- Run QA of reco modules +if [[ ${DO_QA_MODULE} -eq 1 ]]; then + QA_GEO="${DATA_TOP_DIR}/${SETUP_NAME}.geo.root" + QA_REC="${DATA_TOP_DIR}/${FILE_LABEL}.rec.root" + ln -s ${QA_GEO} "${SETUP_NAME}.geo.root" + PARS="-1,\"${QA_REC}\",\"${SETUP_NAME}\",kFALSE" + root -b -l -q ${MACRO_QA_ALEX}"(${PARS})" +fi + +# ----- Run QA +if [[ ${DO_QA} -eq 1 ]]; then + USE_MC="kFALSE" + CONFIG="" + BENCHMARK="" + #PARS="1,\"${DATA_TOP_DIR}/${FILE_LABEL}\",\"${SETUP_NAME}\",${USE_MC},\"${CONFIG}\",\"${BENCHMARK}\"" + QA_RAW="${DATA_TOP_DIR}/${FILE_LABEL}.raw.root" + QA_REC="${DATA_TOP_DIR}/${FILE_LABEL}.rec.root" + QA_PAR="${DATA_TOP_DIR}/${FILE_LABEL}.par.root" + QA_GEO="${DATA_TOP_DIR}/${SETUP_NAME}.geo.root" + QA_OUT="${DATA_TOP_DIR}/${FILE_LABEL}.qa.root" + + PARS="0,\"\",\"${QA_RAW}\",\"${QA_REC}\",\"${QA_PAR}\",\"${QA_GEO}\",\"${QA_OUT}\",\"${SETUP_NAME}\"" + PARS="${PARS},${USE_MC},\"${CONFIG}\",\"${BENCHMARK}\"" + root -b -l -q ${MACRO_QA}"(${PARS})" +fi + +printf "Reconstruction of ${TSA_INP} succeeded\n" -- GitLab