diff --git a/macro/beamtime/mcbm2024/reco_mcbm.sh b/macro/beamtime/mcbm2024/reco_mcbm.sh index cd5ac8a6655eaa69dc8a56b293afddc2b4f94738..bda9fb5f80d37654110cbfccc7388e6c7046381c 100755 --- a/macro/beamtime/mcbm2024/reco_mcbm.sh +++ b/macro/beamtime/mcbm2024/reco_mcbm.sh @@ -325,6 +325,9 @@ if [[ ! -x "${ONLINE_BINARY}" ]]; then fi fi +# The run_info must be in the same directory as the cbmreco +RUN_INFO=${ONLINE_BINARY%/*}/run_info + printf "I- Online binary path: %s, with parameters: %s\n" ${ONLINE_BINARY} ${ONLINE_PAR} @@ -377,27 +380,13 @@ 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" MACRO_KFPF="${VMCWORKDIR}/macro/mcbm/mcbm_hadron_kfp_ana.C" -SETUP_NAME= +SETUP_NAME=$(${RUN_INFO} --run ${RUN} --geotag) # ----- !!! Setting selections vs. run number -# FIXME: map of the run number range to a particular setup geometry tag must be stored in a text (yaml/ascii/json/...) file -# in the cbmroot_parameters or cbmroot_geometry. Until then the setup tags are defined here explicitly. -# # -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" +if [[ ${RUN} -ge 2350 && ${RUN} -le 2610 ]]; then 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" +elif [[ ${RUN} -ge 2724 ]]; then MACRO_RECO="${VMCWORKDIR}/macro/beamtime/mcbm2024/mcbm_event_reco_L1.C" else printf "E- Run %5d is undefined. Exiting" "${RUN}" @@ -417,7 +406,7 @@ SETUP_GEO_FILE="${DIR_SETUP}/${SETUP_NAME}.geo.root" RECO_PAR_FILE="${DIR_RECO}/${FILE_LABEL}.par.root" RECO_FILE="${DIR_RECO}/${FILE_LABEL}.rec.root" KF_SETUP_FILE="${DIR_RECO}/${FILE_LABEL}.rec.kf.setup" -KF_MATERIAL="${DIR_RECO}/${SETUP_NAME}." +KF_MATERIAL="${DIR_RECO}/${SETUP_NAME}.mat.kf.bin" CA_PAR_FILE="${DIR_RECO}/${FILE_LABEL}.rec.ca.par" @@ -532,6 +521,7 @@ if [[ ${DO_QA_MODULE} -eq 1 ]]; then ln -s -f $(realpath ${RECO_PAR_FILE}) $(basename ${QA_PAR}) popd fi + ln -s ${SETUP_GEO_FILE} $(basename ${QA_GEO}) PARS="-1,\"${QA_REC}\",\"${SETUP_NAME}\",kFALSE,${RECO_ALI}" root -b -l -q ${MACRO_QA_MODULE}"(${PARS})" &> ${RECO_QA_LOG} @@ -554,7 +544,7 @@ if [[ ${DO_QA} -eq 1 ]]; then QA_RAW=${DIGI_OFFLINE_FILE} QA_REC=${RECO_FILE} QA_PAR=${RECO_PAR_FILE} - QA_GEO=${SETUP_QA_LOG} + QA_GEO=${SETUP_GEO_FILE} QA_OUT="${DIR_QA}/${FILE_LABEL}.qa.root" PARS="0,\"\",\"${QA_RAW}\",\"${QA_REC}\",\"${QA_PAR}\",\"${QA_GEO}\",\"${QA_OUT}\",\"${SETUP_NAME}\"" diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt index 39051bcf6107518fefd780eca1abd81b55ff515f..db898cd633680625740e2be7b8ded8b6acc49907 100644 --- a/services/CMakeLists.txt +++ b/services/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(archive_explorer) add_subdirectory(histserv) add_subdirectory(online_par_dump) add_subdirectory(tsa_dump) +add_subdirectory(run_info) diff --git a/services/run_info/CMakeLists.txt b/services/run_info/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5f27b90e3f2bc26a6499a17c114a1f6855b4012f --- /dev/null +++ b/services/run_info/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(app) diff --git a/services/run_info/app/Application.cxx b/services/run_info/app/Application.cxx new file mode 100644 index 0000000000000000000000000000000000000000..9cfb3be43779357c006221c9d59b802458022728 --- /dev/null +++ b/services/run_info/app/Application.cxx @@ -0,0 +1,90 @@ +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file Application.cxx +/// \brief The application class for the run_info service (implementation) +/// \since 24.01.2025 +/// \author Sergei Zharko <s.zharko@gsi.de> + +#include "Application.h" + +#include "CbmEnumArray.h" +#include "CbmMcbmUtils.h" + +#include <boost/program_options.hpp> + +#include <exception> +#include <iostream> +#include <sstream> + +using cbm::services::run_info::Application; +using cbm::services::run_info::EInfo; + +namespace po = boost::program_options; + + +// --------------------------------------------------------------------------------------------------------------------- +// +std::optional<EInfo> Application::ParseOptions(int argc, char* argv[]) +{ + cbm::core::EnumArray<EInfo, bool> vbSelected{{0}}; + + // ----- Define options + po::options_description opts(" Options"); + auto optsAdd = opts.add_options(); + // Default options + optsAdd("help,h", "display this help and exit"); + + // Required options + optsAdd("r,run", po::value<uint32_t>(&fRunId)->required(), "standard CBM run identifier (required)"); + + // Info selection options + optsAdd("g,geotag", po::bool_switch(&vbSelected[EInfo::GeoTag])->default_value(false), "prints the geometry tag"); + optsAdd("p,print", po::bool_switch(&vbSelected[EInfo::Print])->default_value(false), + "prints available information on the run ID"); + + po::variables_map vars; + po::store(po::parse_command_line(argc, argv, opts), vars); + po::notify(vars); + + if (vars.count("help")) { + std::cout << opts << std::endl; + return std::nullopt; + } + + int nSelectedInfos{0}; + EInfo selectedInfo{EInfo::Print}; + for (size_t iInfo = 0; iInfo < vbSelected.size(); ++iInfo) { + if (vbSelected[iInfo]) { + selectedInfo = static_cast<EInfo>(iInfo); + ++nSelectedInfos; + } + } + if (nSelectedInfos > 1) { + throw std::logic_error("More then one information items were requested"); + } + + return std::make_optional(selectedInfo); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void Application::Print(EInfo info) const +{ + switch (info) { + case EInfo::GeoTag: std::cout << cbm::mcbm::GetSetupFromRunId(fRunId) << std::endl; break; + case EInfo::Print: std::cout << GetRunInfo() << std::endl; + case EInfo::END: break; + }; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string Application::GetRunInfo() const +{ + std::stringstream msg; + msg << "------ Run #" << fRunId << '\n'; + msg << "geometry tag: " << cbm::mcbm::GetSetupFromRunId(fRunId); + return msg.str(); +} diff --git a/services/run_info/app/Application.h b/services/run_info/app/Application.h new file mode 100644 index 0000000000000000000000000000000000000000..f2cabc4ecfcfe0683d89b257cfe03da879435c63 --- /dev/null +++ b/services/run_info/app/Application.h @@ -0,0 +1,68 @@ +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file Application.h +/// \brief The application class for the run_info service +/// \since 24.01.2025 +/// \author Sergei Zharko <s.zharko@gsi.de> + +#pragma once + +#include <optional> +#include <string> + +namespace cbm::services::run_info +{ + /// \enum Information type required + enum class EInfo + { + GeoTag, //< Returns geometry setup tag + //StsTag, + //MvdTag, + //...... + //CollisionSystem, + //CollisionEnergyCm, + //...... + Print, //< Prints run information into stdout + END + }; + + /// \class Application + /// \brief Main class for the run_info service + class Application { + public: + /// \brief Constructor from parameters + Application() = default; + + /// \brief Copy constructor + Application(const Application&) = default; + + /// \brief Move constructor + Application(Application&&) = default; + + /// \brief Copy assignment operator + Application& operator=(const Application&) = default; + + /// \brief Move assignment operator + Application& operator=(Application&&) = default; + + /// \brief Destructor + ~Application() = default; + + /// \brief Parse command line arguments + /// \return Selected info + /// \throw std::logic_error, if the option list is invalid + std::optional<EInfo> ParseOptions(int argc, char* argv[]); + + /// \brief Gets and prints information to the stdout + /// \param info Requested information + void Print(EInfo info) const; + + /// \brief Prints all info + std::string GetRunInfo() const; + + private: + uint32_t fRunId{0}; ///< Run identifier + }; +} // namespace cbm::services::run_info diff --git a/services/run_info/app/CMakeLists.txt b/services/run_info/app/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a74b1ea1c8615b6bb211a835b12f1c8d1e1cff02 --- /dev/null +++ b/services/run_info/app/CMakeLists.txt @@ -0,0 +1,28 @@ +set(INCLUDE_DIRECTORIES + ${INCLUDE_DIRECTORIES} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +set(SRCS + Application.cxx + main.cxx + ) + +set(HEADERS + Application.h + ) + +set(INCLUDE_DIRECTORIES + ${INCLUDE_DIRECTORIES} + ${CBMROOT_SOURCE_DIR} + ) + +add_executable(run_info ${SRCS} ${HEADERS}) + +target_link_libraries(run_info + PRIVATE + CbmBase + Boost::program_options + ) + +install(TARGETS run_info DESTINATION bin) diff --git a/services/run_info/app/main.cxx b/services/run_info/app/main.cxx new file mode 100644 index 0000000000000000000000000000000000000000..19182ce68c01538f61993708ffd8e364c905f6d7 --- /dev/null +++ b/services/run_info/app/main.cxx @@ -0,0 +1,31 @@ +/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file main.cxx +/// \brief Main function of the run_info service +/// \since 24.01.2025 +/// \author Sergei Zharko <s.zharko@gsi.de> + +#include "Application.h" + +#include <iostream> + +using namespace cbm::services::run_info; + +int main(int argc, char* argv[]) +{ + Application app; + try { + auto info = app.ParseOptions(argc, argv); + if (info.has_value()) { + app.Print(info.value()); + } + } + catch (const std::exception& err) { + std::cerr << "Error: " << err.what() << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}