diff --git a/.clang-format b/.clang-format index 6ccf60bb62..9c00910f7d 100644 --- a/.clang-format +++ b/.clang-format @@ -4,6 +4,7 @@ BasedOnStyle: Mozilla AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: Empty +AllowShortEnumsOnASingleLine: false AllowShortFunctionsOnASingleLine: Inline AllowShortIfStatementsOnASingleLine: Never AllowShortLambdasOnASingleLine: All @@ -18,7 +19,9 @@ BreakBeforeBinaryOperators: NonAssignment BreakBeforeBraces: Custom BraceWrapping: AfterClass: true + AfterEnum: true AfterFunction: true + AfterNamespace: true AfterStruct: true SplitEmptyFunction: false SplitEmptyRecord: false diff --git a/.clang-tidy b/.clang-tidy index 3bcd1dd46c..10bb1fb058 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,14 +2,26 @@ HeaderFilterRegex: '.*' # disable clang-analyzer-core.UndefinedBinaryOperatorResult # ROOT throws lots of them in their headers -# enable cppcoreguidelines-virtual-class-destructor +# Bugprone: +# These could cause actual bugs. +# C++ Core Guidelines +# * cppcoreguidelines-virtual-class-destructor # Avoid undefined behaviour +# * cppcoreguidelines-pro-type-cstyle-cast +# Avoid C-Style Casts which might be problematic # enable google-build-using-namespace # "using namespace" imports a changing amount of symbols, avoid it # improve readability: # readability-simplify-boolean-expr Checks: >- -clang-analyzer-core.UndefinedBinaryOperatorResult, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-narrowing-conversions, + -bugprone-virtual-near-miss, + -bugprone-unhandled-self-assignment, + -bugprone-reserved-identifier, + cppcoreguidelines-pro-type-cstyle-cast, cppcoreguidelines-virtual-class-destructor, modernize-make-unique, google-build-using-namespace, diff --git a/.github/workflows/check_metadata.yaml b/.github/workflows/check_metadata.yaml new file mode 100644 index 0000000000..dc200b215b --- /dev/null +++ b/.github/workflows/check_metadata.yaml @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH, Darmstadt, Germany +# +# SPDX-License-Identifier: CC0-1.0 + +name: Check AUTHORS and CONTRIBUTORS in metadata + +on: + push: + paths: + - AUTHORS + - CONTRIBUTORS + - codemeta.json + - .zenodo.json + pull_request: + paths: + - AUTHORS + - CONTRIBUTORS + - codemeta.json + - .zenodo.json + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Try updating metadata + run: python meta_update.py + - name: Check for Updates + run: git diff --exit-code diff --git a/.github/workflows/codemeta_validate.yaml b/.github/workflows/codemeta_validate.yaml index 46a7b0c00f..503f664ce6 100644 --- a/.github/workflows/codemeta_validate.yaml +++ b/.github/workflows/codemeta_validate.yaml @@ -16,6 +16,6 @@ jobs: container: image: gitlab-registry.in2p3.fr/escape2020/wp3/eossr:v1.0 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: validate codemeta run: eossr-metadata-validator codemeta.json diff --git a/AUTHORS b/AUTHORS index 7919167787..3f3af1ea28 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,7 +1,7 @@ -Al-Turany, Mohammad -Karabowicz, Radoslaw -Klein, Dennis -Kresan, Dmytro -Rybalchenko, Alexey -Tacke, Christian -Uhlig, Florian +Al-Turany, Mohammad [https://orcid.org/0000-0002-8071-4497] +Karabowicz, Radoslaw [https://orcid.org/0009-0005-4083-2711] +Klein, Dennis [https://orcid.org/0000-0003-3787-1910] +Kresan, Dmytro [https://orcid.org/0000-0002-7537-2875] +Rybalchenko, Alexey [https://orcid.org/0000-0002-6249-155X] +Tacke, Christian [https://orcid.org/0000-0002-5321-8404] +Uhlig, Florian [https://orcid.org/0009-0005-3057-8561] diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0f2c9438..ba2b5781f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,110 @@ All notable changes to FairRoot will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -## 18.8.2 - 2023-03-01 +## 19.0.0 - 2024-05-17 + +### Breaking Changes + +* CMake + * Dropped [our custom `FindROOT.cmake`](https://github.com/FairRootGroup/FairRoot/commit/764b2c66432d2e63f765df6f6d328aa4b61dba10) + * Using the native CMake package of ROOT, see + https://root.cern/manual/integrate_root_into_my_cmake_project/ + * ROOT targets **MUST BE** prefixed with `ROOT::` now, see + https://root.cern/manual/integrate_root_into_my_cmake_project/#full-example-event-project + * Explicitely `include(ROOTMacros)` after your `find_package2(... ROOT ...)` + now + * Dropped `ROOT_VERSION_NUMBER`, use `ROOT_VERSION` (which is the dotted + version number) and [`VERSION_GREATER`/etc](https://cmake.org/cmake/help/latest/command/if.html#version-comparisons) + instead + * Dropped `ROOTSYS`, use ROOT CMake targets instead + * Some CMake macros have been factored out into the + [FairCMakeModules](https://github.com/FairRootGroup/FairCMakeModules) + project which is required by FairRoot + * FairSoft `apr21` and later ship it (see alternative + [installation methods](https://fairrootgroup.github.io/FairCMakeModules/latest/installation.html)) + * `find_package2` has moved to [`FairFindPackage2`](https://fairrootgroup.github.io/FairCMakeModules/latest/module/FairFindPackage2.html). + To use it in your code, perform something like this: + ```cmake + find_package(FairCMakeModules 1.0 REQUIRED) + include(FairFindPackage2) + ``` + * Dropped Color Codes and `pad()`, use [`FairFormattedOutput` from FairCMakeModules](https://fairrootgroup.github.io/FairCMakeModules/latest/module/FairFormattedOutput.html) + instead + * Note that [`fair_pad()`](https://fairrootgroup.github.io/FairCMakeModules/latest/module/FairFormattedOutput.html#fair-pad) + needs the width argument to be incremented by 1, and the `COLOR` option + takes no argument + * Dropped `Generate_Exe_Script()`, it was never meant for external use + * Dropped `GENERATE_TEST_SCRIPT()`, replace it with a locally maintained solution + * Consider using `source @FairRoot_BINDIR@/FairRootConfig.sh -p` + * Dropped `Generate_Version_Info()` + * If you just need to generate some files with your version number in it, + use the standard [`configure_file`](https://cmake.org/cmake/help/latest/command/configure_file.html) + CMake command. + * Alternatively, consider creating a [proper CMake Package](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages) + with `configure_package_config_file()`, and `write_basic_package_version_file()`. + * If you need the "git version", use + [`fair_get_git_version()` from FairCMakeModules](https://fairrootgroup.github.io/FairCMakeModules/latest/module/FairProjectConfig.html#fair-get-git-version) + in addition. + * Renamed our `ROOT_GENERATE_DICTIONARY()` to `FAIRROOT_GENERATE_DICTIONARY()` + * Dropped build switch `BUILD_UNITTESTS`, it was in conflict with the CMake + standard switch [`BUILD_TESTING` from the CTest module](https://cmake.org/cmake/help/latest/module/CTest.html) + +* C++ + * `fEvtHeader` member variable now is a private unique pointer owned by + `FairRun`. To access the event header, use the public member function + `GetEventHeader()`. + * Dropped headers: + * `basemq/baseMQtools/baseMQtools.h` + * `basemq/policies/Sampler/FairMQFileSource.h` + * `basemq/policies/Sampler/FairSourceMQInterface.h` + * `basemq/policies/Sampler/SimpleTreeReader.h` + * `basemq/policies/Serialization/BinaryBaseClassSerializer.h` + * `basemq/policies/Storage/BinaryOutFileManager.h` + * `basemq/policies/Storage/BoostDataSaver.h` + * `basemq/policies/Storage/RootOutFileManager.h` + * `basemq/policies/Storage/TriviallyCopyableDataSaver.h` + * `basemq/policies/Serialization/IOPolicy.h` + * The following files/classes have been moved to the example where they are used and renamed: + * `basemq/devices/FairMQProcessor.h` -> `examples/advanced/Tutorial3/MQ/processor.cxx` + * `basemq/devices/FairMQSampler.h` -> `examples/advanced/Tutorial3/MQ/sampler.cxx` + * `basemq/tasks/FairMQProcessorTask.h` -> `examples/advanced/Tutorial3/MQ/processorTask/ProcessorTask.h` + * `basemq/tasks/FairMQSamplerTask.h` -> `examples/advanced/Tutorial3/MQ/samplerTask/SamplerTask.h` + * FairTimeStamp + * `virtual bool operator<(const FairTimeStamp* rValue) const` changed to `bool operator<(const FairTimeStamp& rValue) const` + +### Deprecations + +If you think you really require a deprecated API, please +[file an issue](https://github.com/FairRootGroup/FairRoot/issues/new). + +* Deprecated MbsAPI + * We plan to remove it completely in the next major release + * Disabled by default, enable via `-DBUILD_MBS=ON` +* Deprecated Proof related classes + * [Proof was deprecated in ROOT 6.26](https://github.com/root-project/root/commit/40c3e85970f83b52d6e29bb3c509498bf15fe9e5) + * Disabled by default, enable via `-DBUILD_PROOF_SUPPORT=ON` +* Deprecated `FairEventBuilder` and `FairEventBuilderManager` (https://github.com/FairRootGroup/FairRoot/pull/1414) + * Disabled by default, enable via `-DBUILD_EVENT_BUILDER=ON` +* Deprecated `FairRun::SetEventHeader(FairEventHeader*)`, use + `FairRun::SetEventHeader(std::unique_ptr EvHeader)` instead + * Clarified ownership semantics +* Deprecated `FairRunAna::Run(Long64_t entry)`, use + `FairRunAna::RunSingleEntry(Long64_t entry)` instead + * Semantics were unclear due to dubious `Run(int)` and `Run(long)` + +### Other Notable Changes + +* Restructured the source tree by moving all public components to the new + '/fairroot' folder +* Consider calling `fairroot_check_root_cxxstd_compatibility()` + in your `CMakeLists.txt` +* `fairsoft-config` isn't searched for and not needed any more + +### Example Changes in Experiment Repos + +* https://github.com/R3BRootGroup/R3BRoot/pull/413 + +## 18.8.2 - 2024-03-01 ### Bug fixes * Fix wrong init order in eventdisplay. @@ -24,16 +127,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * Add codemeta.json in accordance with ESCAPE * Add config for zenodo.org -## 18.8.1 - 2023-02-24 +## 18.8.1 - 2024-02-24 ### Breaking Changes * The output folder name changed from 'folderName_0' to 'folderName'. -In the MT mode of Geant4 the folder names changed from 'folderName_1' and 'folderName_2' to 'folderName'. + In the MT mode of Geant4 the folder names changed from 'folderName_1' and 'folderName_2' to 'folderName'. +* Removed the FairRunOnline::InitContainers() function. + It has not been used in FairRoot. Tested with R3BRoot. ### Bug fixes * Check the return value of `source->InitUnpackers()`/`source->ReinitUnpackers()` in `FairRunOnline`. Stop run if `false` returned. * Remove sink from Tutorial3/MQ/sampler.cxx. +* Fixed broken `StaticContainer` functionality (do not `ReInit`ialize when `RunId` changes) in `FairRunOnline`. ### Other Notable Changes * Allow running without output sink. In this case even persistent branches would not be stored anywhere. @@ -92,7 +198,6 @@ In the MT mode of Geant4 the folder names changed from 'folderName_1' and 'folde There is also a convenience header `` which includes all class-based support headers currently offered. - ### Deprecations This release of FairRoot deprecates many APIs for various diff --git a/CMakeLists.txt b/CMakeLists.txt index d888dc3734..dd41dd6a1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,16 @@ ################################################################################ - # Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # # copied verbatim in the file "LICENSE" # ################################################################################ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -cmake_policy(VERSION 3.15...3.27) +cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_policy(VERSION 3.18...3.27) set(PROJECT_MIN_CXX_STANDARD 17) -project(FairRoot VERSION 18.8.2) +project(FairRoot VERSION 19.0.0) list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") list(PREPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/private") @@ -68,7 +68,22 @@ SET(VMCWORKDIR ${CMAKE_SOURCE_DIR}/examples) include(CheckSymbolExists) + +if(DEFINED ENV{SIMPATH}) + set(SIMPATH $ENV{SIMPATH}) + list(PREPEND CMAKE_PREFIX_PATH ${SIMPATH}) + set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${SIMPATH}/lib) +endif() + # Load some basic macros which are needed later on +find_package(FairCMakeModules 0.2 QUIET REQUIRED) +include(FairFindPackage2) +include(FairFormattedOutput) +include(FairSummary) +if(FairCMakeModules_VERSION VERSION_GREATER_EQUAL 1.0.0) + include(FairProjectConfig) +endif() + include(FairRootTargets) include(FairRootPackage) include(FairRootSummary) @@ -77,6 +92,9 @@ include(WriteConfigFile) include(CheckCompiler) include(FairRootCodemeta) +if(FairCMakeModules_VERSION VERSION_GREATER_EQUAL 1.0.0) + fair_get_git_version() +endif() get_codemeta_version() if (PROJECT_CODEMETA_VERSION AND NOT "${PROJECT_CODEMETA_VERSION}" STREQUAL "${PROJECT_VERSION}") @@ -84,11 +102,9 @@ if (PROJECT_CODEMETA_VERSION "CodeMeta Version (${PROJECT_CODEMETA_VERSION}) do not match!") endif() -#Check the compiler and set the compile and link flags -Check_Compiler() - set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") + # Check if the user wants to build the project in the source # directory and if the install directory is different from the build # directory @@ -102,38 +118,39 @@ IF(NOT UNIX) ENDIF(NOT UNIX) -#Check if necessary environment variables are set -#If not stop execution unless modular build is activated -#Option(FAIRROOT_MODULAR_BUILD "Modular build without environment variables" OFF) -#IF(NOT FAIRROOT_MODULAR_BUILD) -If(FAIRSOFT_CONFIG) - IF(NOT DEFINED ENV{SIMPATH}) - MESSAGE(FATAL_ERROR "You did not define the environment variable SIMPATH which is nedded to find the external packages. Please set this variable and execute cmake again.") - ENDIF(NOT DEFINED ENV{SIMPATH}) - STRING(REGEX MATCHALL "[^:]+" PATH $ENV{PATH}) - SET(SIMPATH $ENV{SIMPATH}) -endif() - # Set option(s) -option(BUILD_UNITTESTS "Build all unittests and add them as new tests" OFF) option(ENABLE_GEANT3_TESTING "Enable tests utilizing Geant3" OFF) -option(BUILD_PROOF_SUPPORT "Support ROOT::Proof (deprecated)" ON) +option(BUILD_PROOF_SUPPORT "Support ROOT::Proof (deprecated)" OFF) +option(BUILD_EVENT_BUILDER "Build FairEventBuild" OFF) + option(BUILD_ONLINE "Build the online library" ON) -option(BUILD_MBS "Build MBS" ON) +option(BUILD_MBS "Build MBS" OFF) if (BUILD_MBS) set(BUILD_ONLINE ON) endif() option(BUILD_BASEMQ "Build the 'FairRoot::BaseMQ' library" ON) +Option(BUILD_EXAMPLES "Build Examples" ON) # searches for needed packages # REQUIRED means that cmake will stop if this packages are not found # For example the framework can run without GEANT4, but ROOT is # mandatory -if(SIMPATH) - set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH}) - set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${SIMPATH}/lib) +# FairRoot only supports ROOT6, so check which version is available +list(APPEND required_root_components RIO) +if(BUILD_SIM) + list(APPEND required_root_components pythia6 pythia8) endif() +list(APPEND optional_root_components opengl) +list(APPEND optional_root_components gdml vmc) +find_package2(PUBLIC ROOT REQUIRED + VERSION 6.18.00 + COMPONENTS ${required_root_components} + OPTIONAL_COMPONENTS ${optional_root_components}) +include(ROOTMacros) + +#Check the compiler and set the compile and link flags +Check_Compiler() if(CMAKE_CXX_CLANG_TIDY) # Force clang-tidy to the same C++ Standard @@ -141,27 +158,14 @@ if(CMAKE_CXX_CLANG_TIDY) "--extra-arg=-std=c++${CMAKE_CXX_STANDARD}") endif() -# FairRoot only supports ROOT6, so check which version is available -find_package2(PUBLIC ROOT VERSION 6.10.00 REQUIRED) +fairroot_check_root_cxxstd_compatibility() + if(ROOT_vmc_FOUND) set(VMCLIB ROOT::VMC) else() find_package2(PUBLIC VMC REQUIRED) set(VMCLIB VMCLibrary) endif() -find_package2(PUBLIC FairLogger VERSION 1.2.0 REQUIRED) - -foreach(dep IN LISTS FairLogger_PACKAGE_DEPENDENCIES) -if(NOT dep STREQUAL "Boost") - find_package2(PUBLIC ${dep} REQUIRED VERSION ${FairLogger_${dep}_VERSION}) - set(PROJECT_${dep}_VERSION ${FairLogger_${dep}_VERSION}) - if(dep STREQUAL "fmt") # handling of external fmt installation - get_target_property(FMT_INCLUDE_DIR fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) - set(FairLogger_INCDIR ${FairLogger_INCDIR} ${FMT_INCLUDE_DIR}) - endif() -endif() -endforeach() - find_package2(PUBLIC Pythia6) find_package2(PUBLIC Pythia8) # Protobuf https://github.com/protocolbuffers/protobuf/releases/tag/v22.0 @@ -179,7 +183,6 @@ if(NOT Protobuf_FOUND) set(Protobuf_FOUND NOTFOUND CACHE FORCE) endif() endif() -find_package2(PUBLIC msgpack) find_package2(PUBLIC Flatbuffers) find_package2(PUBLIC Geant3) @@ -192,17 +195,17 @@ find_package2(PUBLIC Geant4VMC) find_package2(PUBLIC IWYU) find_package2(PUBLIC GSL) -if(NOT DEFINED GTEST_ROOT) - set(GTEST_ROOT ${SIMPATH}) -endif() if(BUILD_BASEMQ) find_package2(PUBLIC FairMQ VERSION 1.4.0 REQUIRED) endif() find_package2(PUBLIC DDS) +find_package2(PUBLIC FairLogger VERSION 1.2.0 REQUIRED) + +find_package2(PRIVATE fmt REQUIRED) -if(BUILD_BASEMQ OR BUILD_UNITTESTS OR BUILD_EXAMPLES) +if(BUILD_BASEMQ OR BUILD_EXAMPLES OR BUILD_TESTING) if(NOT DEFINED Boost_NO_SYSTEM_PATHS) Set(Boost_NO_SYSTEM_PATHS TRUE) endif() @@ -220,21 +223,21 @@ if(BUILD_BASEMQ OR BUILD_UNITTESTS OR BUILD_EXAMPLES) if(BUILD_BASEMQ) list(APPEND boost_dependencies filesystem serialization program_options) endif() - if(BUILD_UNITTESTS) - list(APPEND boost_dependencies unit_test_framework) - endif() if(BUILD_EXAMPLES) list(APPEND boost_dependencies program_options) endif() + if(BUILD_TESTING) + list(APPEND boost_dependencies filesystem) + endif() find_package2(PUBLIC Boost VERSION 1.67 COMPONENTS ${boost_dependencies} - ADD_REQUIREMENTS_OF FairMQ FairLogger REQUIRED ) endif() + If (Boost_FOUND) Set(Boost_Avail 1) Else (Boost_FOUND) @@ -264,64 +267,24 @@ endif() # The target name includes the namespace yaml-cpp begining # from version 0.8.0. So the new exported target is now # yaml-cpp::yaml-cpp. -if(yaml-cpp_FOUND) - if(TARGET yaml-cpp::yaml-cpp) - set(YAMLCPPLIB yaml-cpp::yaml-cpp) - else() - set(YAMLCPPLIB yaml-cpp) - endif() +# To work also with previous versions of yaml-cpp an alias +# is created and the new target name is used in the project +if(yaml-cpp_FOUND AND TARGET yaml-cpp AND NOT TARGET yaml-cpp::yaml-cpp) + message(VERBOSE "Creating target alias yaml-cpp::yaml-cpp") + add_library(yaml-cpp::yaml-cpp ALIAS yaml-cpp) endif() -configure_file(${CMAKE_SOURCE_DIR}/cmake/private/FairRootConfigVersion.cmake.in "${CMAKE_BINARY_DIR}/FairRootConfigVersion.cmake" @ONLY) - -# Load the macro to generate the needed version info at compile time -Generate_Version_Info() +add_subdirectory(third_party) # Set some useful variables SetBasicVariables() +SET(ROOT_INCLUDE_PATH ${CMAKE_INSTALL_FULL_INCLUDEDIR}) -# Recurse into the given subdirectories. This does not actually -# cause another cmake executable to run. The same process will walk through -# the project's entire directory structure. -add_subdirectory(fairtools) -add_subdirectory(alignment) -add_subdirectory(base) -add_subdirectory(geobase) -add_subdirectory(parbase) -add_subdirectory(generators) - -if(BUILD_MBS) - add_subdirectory(MbsAPI) -endif() -if(BUILD_ONLINE) - add_subdirectory(online) -endif() - -If(Geant3_FOUND) - add_subdirectory(geane) - add_subdirectory(trackbase) -EndIf () - -execute_process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-opengl OUTPUT_VARIABLE - ROOT_HAS_OPENGL_VAR) -if(${ROOT_HAS_OPENGL_VAR} MATCHES "yes") - add_subdirectory(eventdisplay) - Set(ROOT_HAS_OPENGL TRUE) -else() - message(STATUS "eventdisplay will not be built, because ROOT has no opengl support.") - Set(ROOT_HAS_OPENGL FALSE) -endif() - -add_subdirectory(datamatch) +# All the main / public components +add_subdirectory(fairroot) add_subdirectory(templates) -if(BUILD_BASEMQ) - add_subdirectory(fairmq) - add_subdirectory(basemq) - add_subdirectory(parmq) -endif() - Option(BUILD_DOXYGEN "Build Doxygen" OFF) if(BUILD_DOXYGEN) find_package2(PRIVATE Doxygen COMPONENTS dot) @@ -335,7 +298,6 @@ if(BUILD_DOXYGEN) endif() endif(BUILD_DOXYGEN) -Option(BUILD_EXAMPLES "Build Examples" ON) if(BUILD_EXAMPLES) add_subdirectory(examples) endif(BUILD_EXAMPLES) @@ -355,16 +317,11 @@ if(ClangFormat_FOUND) ) endif() -if(${CMAKE_BUILD_TYPE} MATCHES PROFILE) - set(BUILD_UNITTESTS ON) +if(BUILD_TESTING) + add_subdirectory(tests) endif() -if(BUILD_UNITTESTS) - find_package2(PRIVATE GTest REQUIRED VERSION 1.7.0) - message(STATUS "Building the unit tests.") - add_subdirectory(test) -endif() -add_subdirectory(test/tgeo) +find_package2_implicit_dependencies() add_subdirectory(cmake) @@ -375,9 +332,6 @@ install(FILES ${CMAKE_BINARY_DIR}/config.sh_install install(FILES ${CMAKE_BINARY_DIR}/check_system.sh DESTINATION ${CMAKE_INSTALL_LIBEXECDIR} ) -install(FILES ${CMAKE_BINARY_DIR}/FairVersion.h - DESTINATION include -) install(FILES ${CMAKE_BINARY_DIR}/config.csh_install DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME FairRootConfig.csh @@ -386,29 +340,16 @@ install(FILES ${CMAKE_BINARY_DIR}/check_system.csh DESTINATION ${CMAKE_INSTALL_LIBEXECDIR} ) -find_package(Git) -set (Git_VERSION ${GIT_VERSION_STRING}) -string(REPLACE "git" " " Git_ROOT ${GIT_EXECUTABLE} ) -If(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git") - Execute_Process(COMMAND ${GIT_EXECUTABLE} describe --tags - OUTPUT_VARIABLE PROJECT_GIT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) -Else() - set(PROJECT_GIT_VERSION "v${PROJECT_VERSION}") -EndIf() Configure_File(${CMAKE_SOURCE_DIR}/cmake/scripts/fairroot-config.in ${CMAKE_BINARY_DIR}/fairroot-config @ONLY) install(PROGRAMS ${CMAKE_BINARY_DIR}/fairroot-config - DESTINATION bin + DESTINATION ${CMAKE_INSTALL_BINDIR} ) WRITE_CONFIG_FILE(config.sh) WRITE_CONFIG_FILE(config.csh) SET(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/fairbase/examples) -SET(ROOT_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include) WRITE_CONFIG_FILE(config.sh_install) WRITE_CONFIG_FILE(config.csh_install) @@ -417,8 +358,8 @@ install_cmake_package() # Summary ###################################################################### fairroot_summary_header() fairroot_summary_install_prefix() -fairroot_summary_global_cxx_flags_standard() -fairroot_summary_build_types() +fair_summary_global_cxx_flags_standard() +fair_summary_build_types() fairroot_summary_package_dependencies() fairroot_summary_components() diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 5785dc6bab..64bcc6c353 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -32,6 +32,7 @@ Shahoyan, Ruben Stockmanns, Tobias Ustyuzhanin, Andrey von Haller, Barthélémy +Wang, Yanzhao [https://orcid.org/0000-0002-7006-7986] Wenzel, Sandro Wielanek, Daniel Winckler, Nicolas diff --git a/COPYRIGHT b/COPYRIGHT index 7523cea96e..ea9801d749 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -4,6 +4,17 @@ Upstream-Contact: Mohammad Al-Turany Source: https://github.com/FairRootGroup/FairRoot Files: * -Copyright: 2003-2019, GSI Helmholtzzentrum fuer Schwerionenforschung GmbH -Copyright: 2003-2019, [see AUTHORS file] -Copyright: 2003-2019, [see CONTRIBUTORS file] +Copyright: 2003-2023, GSI Helmholtzzentrum fuer Schwerionenforschung GmbH +Copyright: 2003-2023, [see AUTHORS file] +Copyright: 2003-2023, [see CONTRIBUTORS file] +License: LGPL-3.0-only + +Files: third_party/Catch2* +Copyright: Catch2 Authors, https://github.com/catchorg/Catch2 +License: BSL-1.0 + +License: LGPL-3.0-only + [see LICENSE file] + +License: BSL-1.0 + [see third_party/Catch2*/LICENSE.txt file] diff --git a/CTestCustom.cmake b/CTestCustom.cmake index 01730a95a7..ed1c2f295f 100644 --- a/CTestCustom.cmake +++ b/CTestCustom.cmake @@ -37,9 +37,9 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "ignoring return value of 'char* fscanf(char*, int, FILE*)'" # filter warnings from generated files - "FairTestDetectorPayloadDigi_generated.h" - "FairTestDetectorPayloadHit_generated.h" - "FairTestDetectorPayload.pb" + "PayloadDigi_generated.h" + "PayloadHit_generated.h" + "Payload.pb" "MyPayload.pb" "G__.*Dict" @@ -58,6 +58,7 @@ set(CTEST_CUSTOM_WARNING_MATCH ${CTEST_CUSTOM_WARNING_MATCH} Set (CTEST_CUSTOM_COVERAGE_EXCLUDE ".*Dict.h" ".*Dict.cxx" + "third_party" "_.*" ) diff --git a/FairRoot_build_test.cmake b/FairRoot_build_test.cmake index 11832b32ce..7c721b710c 100644 --- a/FairRoot_build_test.cmake +++ b/FairRoot_build_test.cmake @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2021-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -14,19 +14,8 @@ fairroot_ctest_setup() set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 102400) set(CTEST_CONFIGURATION_TYPE "RelWithDebInfo") -if(NOT NCPUS) - if(DEFINED ENV{SLURM_CPUS_PER_TASK}) - set(NCPUS $ENV{SLURM_CPUS_PER_TASK}) - elseif(DEFINED ENV{SLURM_JOB_CPUS_PER_NODE}) - set(NCPUS $ENV{SLURM_JOB_CPUS_PER_NODE}) - else() - include(ProcessorCount) - ProcessorCount(NCPUS) - if(NCPUS EQUAL 0) - set(NCPUS 1) - endif() - endif() -endif() +get_NCPUS() +get_os_name_release() if ("$ENV{LABEL}" STREQUAL "") set(CTEST_BUILD_NAME "build") @@ -48,12 +37,17 @@ list(APPEND options if ((NOT DEFINED BUILD_MBS) OR BUILD_MBS) list(APPEND options "-DBUILD_MBS=ON") endif() +if ((NOT DEFINED BUILD_PROOF_SUPPORT) OR BUILD_PROOF_SUPPORT) + list(APPEND options "-DBUILD_PROOF_SUPPORT=ON") +endif() +if ((NOT DEFINED BUILD_EVENT_BUILDER) OR BUILD_EVENT_BUILDER) + list(APPEND options "-DBUILD_EVENT_BUILDER=ON") +endif() if (USE_CLANG_TIDY) list(APPEND options "-DCMAKE_CXX_CLANG_TIDY=clang-tidy") endif() -if ("$ENV{CHANGE_ID}" STREQUAL "") - # Branch build - list(APPEND options "-DENABLE_GEANT3_TESTING:BOOL=ON") +if (ENABLE_GEANT3_TESTING) + list(APPEND options "-DENABLE_GEANT3_TESTING=ON") endif() ctest_configure(OPTIONS "${options}") diff --git a/FairRoot_doxygen_test.cmake b/FairRoot_doxygen_test.cmake index 02a22d8dc6..d60d87dfea 100644 --- a/FairRoot_doxygen_test.cmake +++ b/FairRoot_doxygen_test.cmake @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2020-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -76,6 +76,6 @@ endif() ctest_submit() if (web_url) - file(WRITE "build/generated-doxygen.url" "${web_url}") + file(WRITE "${CTEST_BINARY_DIRECTORY}/generated-doxygen.url" "${web_url}") message(STATUS " Created Doxygen URL ..: ${web_url}") endif() diff --git a/FairRoot_profile_test.cmake b/FairRoot_profile_test.cmake new file mode 100644 index 0000000000..d92f10b9b3 --- /dev/null +++ b/FairRoot_profile_test.cmake @@ -0,0 +1,99 @@ +################################################################################ +# Copyright (C) 2021-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +list(PREPEND CMAKE_MODULE_PATH "cmake/private") +include(Testlib) + +fairroot_ctest_setup() + +set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 102400) +set(CTEST_CONFIGURATION_TYPE "RelWithDebInfo") + +get_NCPUS() +get_os_name_release() + +if ("$ENV{LABEL}" STREQUAL "") + set(CTEST_BUILD_NAME "build") +else() + set(CTEST_BUILD_NAME $ENV{LABEL}) +endif() + +find_program(GCOV_COMMAND gcov) +if(GCOV_COMMAND) + message("Found GCOV: ${GCOV_COMMAND}") + set(CTEST_COVERAGE_COMMAND ${GCOV_COMMAND}) +endif(GCOV_COMMAND) + +show_jenkins_info() + +ctest_read_custom_files(${CTEST_SOURCE_DIRECTORY}) + +ctest_start(Continuous) + +get_filename_component(test_install_prefix "${CTEST_BINARY_DIRECTORY}/install" + ABSOLUTE) +list(APPEND options + "-Werror=dev" + "-DDISABLE_COLOR=ON" + "-DCMAKE_BUILD_TYPE=PROFILE" + "-DBUILD_EXAMPLES=OFF" + "-DCMAKE_INSTALL_PREFIX:PATH=${test_install_prefix}" +) +if ((NOT DEFINED BUILD_MBS) OR BUILD_MBS) + list(APPEND options "-DBUILD_MBS=ON") +endif() +if ((NOT DEFINED BUILD_PROOF_SUPPORT) OR BUILD_PROOF_SUPPORT) + list(APPEND options "-DBUILD_PROOF_SUPPORT=ON") +endif() +if ((NOT DEFINED BUILD_EVENT_BUILDER) OR BUILD_EVENT_BUILDER) + list(APPEND options "-DBUILD_EVENT_BUILDER=ON") +endif() +if (USE_CLANG_TIDY) + list(APPEND options "-DCMAKE_CXX_CLANG_TIDY=clang-tidy") +endif() +if (ENABLE_GEANT3_TESTING) + list(APPEND options "-DENABLE_GEANT3_TESTING=ON") +endif() +ctest_configure(OPTIONS "${options}") + +ctest_build(FLAGS "-j${NCPUS}" TARGET install + NUMBER_ERRORS _ctest_build_num_errs + RETURN_VALUE _ctest_build_ret_val) + +unset(repeat) +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) + if ("$ENV{CHANGE_ID}" STREQUAL "") + # Branch build + set(repeat REPEAT UNTIL_PASS:7) + endif() +endif() +if(_ctest_build_ret_val OR _ctest_build_num_errs) + message(STATUS "Skipping tests, because build failed" + " (return value: ${_ctest_build_ret_val}," + " number of errors: ${_ctest_build_num_errs})") + set(_ctest_test_ret_val -1) +else() + ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" + PARALLEL_LEVEL 4 + SCHEDULE_RANDOM ON + ${repeat} + RETURN_VALUE _ctest_test_ret_val) +endif() + + If(GCOV_COMMAND) + ctest_coverage(BUILD "${CTEST_BINARY_DIRECTORY}") + EndIf() + + + +fairroot_ctest_submit(FINAL) +fairroot_summary_cdash() + +if(_ctest_test_ret_val) + Message(FATAL_ERROR "Some tests failed.") +endif() diff --git a/Jenkinsfile b/Jenkinsfile index 387ac663d0..dc987cb587 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,46 +1,113 @@ #!groovy -def jobMatrix(String prefix, String type, List specs) { +def macos_builds = [ + [os: "macos", ver: "13", arch: "x86_64", compiler: "apple-clang-14", fairsoft: "24.01"], + [os: "macos", ver: "14", arch: "x86_64", compiler: "apple-clang-14", fairsoft: "24.01"], + [os: "macos", ver: "14", arch: "arm64", compiler: "apple-clang-15", fairsoft: "24.01"], +] + +def linux_builds = [ + [os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "jan24_patches", image: "jan24"], + [os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "jan24_patches_mt", image: "jan24"], + [os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "nov22_patches", image: "nov22"], + [os: "debian", ver: "10", compiler: "gcc-8", fairsoft: "apr22_patches", image: "apr22"], + [os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "jan24_patches", image: "jan24"], + [os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "jan24_patches_mt", image: "jan24"], + [os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "nov22_patches", image: "nov22"], + [os: "debian", ver: "11", compiler: "gcc-10", fairsoft: "apr22_patches", image: "apr22"], + [os: "debian", ver: "12", compiler: "gcc-12", fairsoft: "jan24_patches", image: "jan24"], + [os: "debian", ver: "12", compiler: "gcc-12", fairsoft: "jan24_patches_mt", image: "jan24"], + [os: "debian", ver: "12", compiler: "gcc-12", fairsoft: "nov22_patches", image: "nov22"], + [os: "fedora", ver: "39", compiler: "gcc-13", fairsoft: "jan24_patches", image: "jan24"], + [os: "fedora", ver: "39", compiler: "gcc-13", fairsoft: "jan24_patches_mt", image: "jan24"], + [os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "jan24_patches", image: "jan24"], + [os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "jan24_patches_mt", image: "jan24"], + [os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "nov22_patches", image: "nov22"], + [os: "ubuntu", ver: "20.04", compiler: "gcc-9", fairsoft: "apr22_patches", image: "apr22"], + [os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "jan24_patches", image: "jan24"], + [os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "jan24_patches_mt", image: "jan24"], + [os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "nov22_patches", image: "nov22"], + [os: "ubuntu", ver: "22.04", compiler: "gcc-11", fairsoft: "apr22_patches", image: "apr22"], + [os: "ubuntu", ver: "rolling", compiler: "current", fairsoft: "dev", check: "warnings", + extra: "-DUSE_CLANG_TIDY=ON -DBUILD_MBS=OFF -DBUILD_PROOF_SUPPORT=OFF"], +] + +def linux_checks = [ + [os: 'ubuntu', ver: 'rolling', compiler: 'current', fairsoft: 'dev', check: 'doxygen'], +] + +def isBranchBuild() { + return !env.CHANGE_ID +} + +if (!isBranchBuild()) { // PRs only + linux_checks += [ + [os: "ubuntu", ver: "rolling", compiler: "current", fairsoft: "dev", check: "format"] + ] +} + +def jobMatrix(String type, String src, List specs) { def nodes = [:] for (spec in specs) { - def job = '' + def arch = spec.getOrDefault("arch", "x86_64") + def check = spec.getOrDefault("check", null) + def extra = spec.getOrDefault("extra", null) + def image = spec.getOrDefault("image", null) + def fairsoft = spec.fairsoft + def os = spec.os + def ver = spec.ver + def compiler = spec.compiler + def selector = "${os}-${ver}-${arch}" + def label = "" switch(type) { - case 'build': - job = "${spec.os}-${spec.ver}-${spec.arch}-${spec.compiler}-fairsoft-${spec.fairsoft}" + case "build": + label = "${os}-${ver}-${arch} ${compiler} ${fairsoft}" break - case 'check': - job = spec.check + case "check": + label = "Check ${check}" break } - def label = "${type}/${job}" - def selector = "${spec.os}-${spec.ver}-${spec.arch}" - def fairsoft = spec.fairsoft - def os = spec.os - def ver = spec.ver - def arch = spec.arch - def check = spec.getOrDefault("check", null) - def extra = spec.getOrDefault("extra", null) nodes[label] = { node(selector) { - githubNotify(context: "${prefix}/${label}", description: 'Building ...', status: 'PENDING') - def logpattern = 'build/Testing/Temporary/*.log' + githubNotify(context: "${label}", description: "Building ...", status: "PENDING") try { - deleteDir() - checkout scm + def sourcedir = src + if (!sourcedir) { + deleteDir() + checkout scm + sourcedir = pwd() + } + def builddir = "build-${os}-${ver}-${arch}-${fairsoft}" + def builddir_abs = "${pwd()}/${builddir}" + echo "Source dir: ${sourcedir}" + echo "Build dir: ${builddir_abs}" + def logpattern = "${builddir}/Testing/Temporary/*.log" - def jobscript = 'job.sh' - def ctestcmd = "ctest -S FairRoot_${type}_test.cmake -V --output-on-failure" + if (check == "warnings" || check == "doxygen") { + discoverGitReferenceBuild() + } + if (check == "doxygen") { + gitDiffStat() + // mineRepository() + } + + def jobscript = "${pwd()}/job.sh" + def ctestcmd = "ctest -S ${sourcedir}/FairRoot_${type}_test.cmake -V --output-on-failure" sh "echo \"set -e\" >> ${jobscript}" - if (type == 'check') { - ctestcmd = "ctest -S FairRoot_${check}_test.cmake -VV" + if (type == "check") { + ctestcmd = "ctest -S ${sourcedir}/FairRoot_${check}_test.cmake -VV" sh "echo \"export FAIRROOT_FORMAT_BASE=origin/\${CHANGE_TARGET}\" >> ${jobscript}" } + if (isBranchBuild() && !(os =~ /^macos/)) { + ctestcmd += " -DENABLE_GEANT3_TESTING=ON" + } if (extra) { ctestcmd = ctestcmd + " " + extra } + ctestcmd += " -DCTEST_SOURCE_DIRECTORY='${sourcedir}' -DCTEST_BINARY_DIRECTORY='${builddir_abs}'" if (selector =~ /^macos/) { - sh "echo \"export SIMPATH=\$(brew --prefix fairsoft@${fairsoft})\" >> ${jobscript}" + // sh "echo \"export SIMPATH=\$(brew --prefix fairsoft)\" >> ${jobscript}" } else { sh "echo \"export SIMPATH=/fairsoft/${fairsoft}\" >> ${jobscript}" } @@ -51,17 +118,21 @@ def jobMatrix(String prefix, String type, List specs) { sh "bash ${jobscript}" } else { def container = "${os}.${ver}.sif" + if (image) { + container = "${os}.${ver}.${image}.sif" + } sh(label: "Create Slurm Job Script", script: """ - exec test/ci/slurm-create-jobscript.sh "${label}" "${container}" "${jobscript}" ${ctestcmd} + exec ${sourcedir}/tests/ci/slurm-create-jobscript.sh "${label}" "${container}" "${jobscript}" ${ctestcmd} """) - sh "./test/ci/slurm-submit.sh \"FairRoot \${JOB_BASE_NAME} ${label}\" ${jobscript}" - } - if (check == "warnings" || check == "doxygen") { - discoverGitReferenceBuild() + dir(sourcedir) { + sh "tests/ci/slurm-submit.sh \"${type}\" \"FairRoot \${JOB_BASE_NAME} ${label}\" ${jobscript}" + } } + if (check == "warnings") { recordIssues(tools: [clangTidy(pattern: logpattern)], - filters: [excludeFile('build/.*/G__.*[.]cxx')], + filters: [excludeFile("build.*/.*/G__.*[.]cxx"), excludeFile("third_party/.*")], + qualityGates: [[threshold: 4, type: "NEW", unstable: true]], ignoreFailedBuilds: false, skipBlames: true) archiveArtifacts(artifacts: logpattern, allowEmptyArchive: true, fingerprint: true) @@ -70,20 +141,20 @@ def jobMatrix(String prefix, String type, List specs) { recordIssues(tools: [doxygen()], ignoreFailedBuilds: false, skipBlames: true) - def result_url = readFile(file: 'build/generated-doxygen.url') - publishChecks(name: 'Doxygen-Preview', - title: 'Doxygen Preview', + def result_url = readFile(file: "${builddir_abs}/generated-doxygen.url") + publishChecks(name: "Doxygen-Preview", + title: "Doxygen Preview", summary: result_url) } deleteDir() - githubNotify(context: "${prefix}/${label}", description: 'Success', status: 'SUCCESS') + githubNotify(context: "${label}", description: "Success", status: "SUCCESS") } catch (e) { if (check == "warnings") { archiveArtifacts(artifacts: logpattern, allowEmptyArchive: true, fingerprint: true) } deleteDir() - githubNotify(context: "${prefix}/${label}", description: 'Error', status: 'ERROR') + githubNotify(context: "${label}", description: "Error", status: "ERROR") throw e } } @@ -92,50 +163,22 @@ def jobMatrix(String prefix, String type, List specs) { return nodes } -pipeline{ - agent none - stages { - stage("Run CI Matrix") { - steps{ - script { - def builds = jobMatrix('alfa-ci', 'build', [ - [os: 'centos', ver: '7', arch: 'x86_64', compiler: 'gcc-7', fairsoft: 'apr21_patches'], - [os: 'centos', ver: '7', arch: 'x86_64', compiler: 'gcc-7', fairsoft: 'apr21_patches_mt'], - [os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches'], - [os: 'debian', ver: '10', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches_mt'], - [os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches'], - [os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr21_patches_mt'], - [os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr22_patches'], - [os: 'debian', ver: '11', arch: 'x86_64', compiler: 'gcc-8', fairsoft: 'apr22_patches_mt'], - [os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'apr21_patches'], - [os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', fairsoft: 'apr21_patches_mt'], - [os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev', - check: 'warnings', - extra: '-DUSE_CLANG_TIDY=ON -DBUILD_MBS=OFF'], - [os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'apr21_patches'], - [os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10', fairsoft: 'apr21_patches_mt'], - [os: 'macos', ver: '12', arch: 'x86_64', compiler: 'apple-clang-14', fairsoft: '22.11'], - // [os: 'macos', ver: '13', arch: 'x86_64', compiler: 'apple-clang-14', fairsoft: '22.11'], - // [os: 'macos', ver: '13', arch: 'arm64', compiler: 'apple-clang-14', fairsoft: '22.11'], - // [os: 'macos', ver: '12', arch: 'x86_64', compiler: 'apple-clang-14', fairsoft: '23.6'], - // [os: 'macos', ver: '13', arch: 'x86_64', compiler: 'apple-clang-14', fairsoft: '23.6'], - // [os: 'macos', ver: '13', arch: 'arm64', compiler: 'apple-clang-14', fairsoft: '23.6'], - ]) - - def checks = jobMatrix('alfa-ci', 'check', [ - [os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev', - check: 'doxygen'], - ]) - if (env.CHANGE_ID != null) { // only run checks for PRs - checks += jobMatrix('alfa-ci', 'check', [ - [os: 'ubuntu', ver: 'rolling', arch: 'x86_64', compiler: 'current', fairsoft: 'dev', - check: 'format'], - ]) - } +def linux_source = "" - parallel(checks + builds) - } - } - } - } -} +pipeline { + agent none + options { skipDefaultCheckout() } + stages { stage("CI") { parallel { + stage("Linux") { + agent { label "slurm" } + stages { + stage("SCM Checkout") { + steps { + checkout scm + script { linux_source = pwd() } + echo "Source dir: ${linux_source}" } } + stage("Builds and Checks") { + steps { script { parallel( jobMatrix("check", linux_source, linux_checks) + + jobMatrix("build", linux_source, linux_builds)) } } + post { always { dir(linux_source) { deleteDir() } } } } } } + stage("macOS") { steps { script { parallel(jobMatrix("build", null, macos_builds)) } } } } } } } diff --git a/apply-format.sh b/apply-format.sh index 12f7369609..6a60068b86 100755 --- a/apply-format.sh +++ b/apply-format.sh @@ -2,6 +2,6 @@ CLANG_FORMAT_BIN=${FAIRROOT_CLANG_FORMAT_BIN:-clang-format} -FILES=$(find . -type f \( -iname "*.h" ! -iname "*.pb.h" ! -iname "*LinkDef.h" -o -iname "*.hpp" -o -iname "*.cxx" -o -iname "*.cpp" -o -iname "*.tpl" -o -iname "*.c" -o -iname "*.C" \) -not \( -path "./build/*" -o -path "./cmake/*" -prune \)) +FILES=$(find . -type f \( -iname "*.h" ! -iname "*.pb.h" ! -iname "*LinkDef.h" -o -iname "*.hpp" -o -iname "*.cxx" -o -iname "*.cpp" -o -iname "*.c" -o -iname "*.C" \) -not \( -path "./build/*" -o -path "./cmake/*" -prune \)) $CLANG_FORMAT_BIN -i $FILES --verbose diff --git a/basemq/baseMQtools/baseMQtools.h b/basemq/baseMQtools/baseMQtools.h deleted file mode 100644 index c1629f57e1..0000000000 --- a/basemq/baseMQtools/baseMQtools.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * File: baseMQtools.h - * Author: winckler - * - * Created on November 19, 2014, 4:50 PM - */ - -#ifndef FAIRMQTEMPLATE_H -#define FAIRMQTEMPLATE_H - -// std -#include -#include -#include -#include - -// boost -#include - -// FairRoot - FairMQ -#include "FairLogger.h" - -namespace baseMQ { -namespace tools { -/// ///////////////////////// to print tuple elements //////////////////////////////////////////// -/// Define a type which holds an unsigned integer value -template -struct int_ -{}; - -template -std::ostream& print_tuple(std::ostream& out, const Tuple& t, int_) -{ - out << std::get::value - Pos>(t) << ','; - return print_tuple(out, t, int_()); -} - -template -std::ostream& print_tuple(std::ostream& out, const Tuple& t, int_<1>) -{ - return out << std::get::value - 1>(t); -} - -template -std::ostream& operator<<(std::ostream& out, const std::tuple& t) -{ - out << '('; - print_tuple(out, t, int_()); - return out << ')'; -} - -namespace resolve { -/// test function member signature in given class - -namespace details { - -// test whether T has SetFileProperties member function -template -struct has_SetFileProperties : std::false_type -{}; - -template -struct has_SetFileProperties< - T, - R(Args...), - typename std::enable_if< - std::is_convertible().SetFileProperties(std::declval()...)), R>::value - || std::is_same::value // all return types are compatible with void - // and, due to SFINAE, we can invoke T.foo(Args...) (otherwise previous clause - // fails) - >::type> : std::true_type -{}; - -// test whether T has InitTClonesArray member function -template -struct has_InitTClonesArray : std::false_type -{}; - -template -struct has_InitTClonesArray< - T, - R(Args...), - typename std::enable_if< - std::is_convertible().InitTClonesArray(std::declval()...)), R>::value - || std::is_same::value // all return types are compatible with void - // and, due to SFINAE, we can invoke T.foo(Args...) (otherwise previous clause - // fails) - >::type> : std::true_type -{}; - -} // end namespace details - -template -using has_SetFileProperties = std::integral_constant::value>; - -template -using has_InitTClonesArray = std::integral_constant::value>; - -} // end namespace resolve - -namespace typeinfo { -template -void DataTypeInfo(std::string classname) -{ - LOG(info) << "Info on type " << classname; - - if (std::is_class::value) { - - if (std::is_pod::value) { - LOG(info) << classname << " is POD"; - } else { - LOG(info) << classname << " is not POD"; - } - - if (std::is_trivial::value) { - LOG(info) << classname << " is trivial"; - } else { - LOG(info) << classname << " is not trivial"; - } - - // below commented because not yet implemented in gcc - // if(std::is_trivially_copyable::value) not implemented yet in gcc 4.8.2 - // LOG(info) << classname << " is trivially copyable" ; - // else - // LOG(info) << classname << " is not trivially copyable" ; - - if (std::is_standard_layout::value) { - LOG(info) << classname << " is standard layout"; - } else { - LOG(info) << classname << " is not standard layout"; - } - - if (resolve::has_BoostSerialization::value) { - LOG(info) << classname << " is boost serializable"; - } else { - if (resolve::has_BoostSerialization::value) { - LOG(info) << classname << " is boost serializable"; - } else { - LOG(info) << classname << " has no void serialize(BoostArchive&) member"; - } - } - } else { - LOG(info) << classname << " is not a class"; - } -}; - -} // namespace typeinfo - -} // end namespace tools - -} // namespace baseMQ - -#endif /* FAIRMQTEMPLATE_H */ diff --git a/basemq/devices/BaseMQFileSink.h b/basemq/devices/BaseMQFileSink.h deleted file mode 100644 index eda26cf0c0..0000000000 --- a/basemq/devices/BaseMQFileSink.h +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: BaseMQFileSink.h - * Author: winckler - * - * Created on October 7, 2014, 6:06 PM - */ - -#ifndef BASEMQFILESINK_H -#define BASEMQFILESINK_H - -#include "FairMQ.h" // for fair::mq::Device - -#include - -template -class BaseMQFileSink - : public fair::mq::Device - , public InputPolicy - , public OutputPolicy -{ - public: - BaseMQFileSink() - : InputPolicy() - , OutputPolicy() - , fInputChanName() - {} - - virtual ~BaseMQFileSink() {} - - template - void InitInputData(Args&&... args) - { - InputPolicy::Create(std::forward(args)...); - } - - protected: - virtual void InitTask() - { - fInputChanName = fConfig->GetValue("in-chan-name"); - OutputPolicy::SetFileProperties(*fConfig); - OutputPolicy::InitOutputFile(); - } - - virtual void Run() - { - int receivedMsg = 0; - while (!NewStatePending()) { - auto msg(NewMessage()); - if (Receive(msg, fInputChanName) > 0) { - InputPolicy::Deserialize(*msg, InputPolicy::fInput); // get data from message. - OutputPolicy::Serialize(InputPolicy::fInput); // put data into output. - receivedMsg++; - } - } - - LOG(info) << "Received " << receivedMsg << " messages!"; - } - - private: - std::string fInputChanName; -}; - -#endif /* BASEMQFILESINK_H */ diff --git a/basemq/devices/FairMQProcessor.h b/basemq/devices/FairMQProcessor.h deleted file mode 100644 index 5cdaadc053..0000000000 --- a/basemq/devices/FairMQProcessor.h +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQProcessor.h - * - * @since 2012-12-06 - * @author D. Klein, A. Rybalchenko - */ - -#ifndef FAIRMQPROCESSOR_H_ -#define FAIRMQPROCESSOR_H_ - -#include "FairMQ.h" // for fair::mq::Device, fair::mq::MessagePtr -#include "FairMQProcessorTask.h" - -#include - -template -class FairMQProcessor : public fair::mq::Device -{ - public: - FairMQProcessor() - : fProcessorTask(new Task) - , fInChannelName("data1") - , fOutChannelName("data2") - , fReceivedMsgs(0) - , fSentMsgs(0) - {} - - /// Copy Constructor - FairMQProcessor(const FairMQProcessor&) = delete; - FairMQProcessor operator=(const FairMQProcessor&) = delete; - - virtual ~FairMQProcessor() {} - - protected: - virtual void InitTask() - { - std::string inChannelName = fConfig->GetValue("in-channel"); - std::string outChannelName = fConfig->GetValue("out-channel"); - // check if the returned value actually exists, for the compatibility with old devices. - if (inChannelName != "") { - fInChannelName = inChannelName; - } - if (outChannelName != "") { - fOutChannelName = outChannelName; - } - - fProcessorTask->InitTask(); - OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { - ++fReceivedMsgs; - fProcessorTask->SetPayload(msg); - fProcessorTask->Exec(); - fProcessorTask->GetPayload(msg); - - Send(msg, fOutChannelName); - ++fSentMsgs; - - return true; - }); - } - - virtual void PostRun() { LOG(info) << "Received " << fReceivedMsgs << " and sent " << fSentMsgs << " messages!"; } - - private: - std::unique_ptr fProcessorTask; - std::string fInChannelName; - std::string fOutChannelName; - int fReceivedMsgs; - int fSentMsgs; -}; - -#endif /* FAIRMQPROCESSOR_H_ */ diff --git a/basemq/policies/Sampler/FairSourceMQInterface.h b/basemq/policies/Sampler/FairSourceMQInterface.h deleted file mode 100644 index 4c15b0f15b..0000000000 --- a/basemq/policies/Sampler/FairSourceMQInterface.h +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#ifndef FAIRSOURCEMQINTERFACE_H -#define FAIRSOURCEMQINTERFACE_H - -#include "BaseSourcePolicy.h" -#include "FairFileSource.h" -#include "FairRunAna.h" - -#include -#include -#include - -template -using enable_if_match = typename std::enable_if::value, int>::type; - -template -class FairSourceMQInterface : public BaseSourcePolicy> -{ - typedef DataType* DataType_ptr; - typedef FairSourceMQInterface this_type; - - public: - FairSourceMQInterface() - : BaseSourcePolicy>() - , fSource(nullptr) - , fInput(nullptr) - , fIndex(0) - , fMaxIndex(-1) - , fClassName("") - , fBranchName("") - , fSourceName("") - , fRunAna(nullptr) - {} - - FairSourceMQInterface(const FairSourceMQInterface&) = delete; - FairSourceMQInterface operator=(const FairSourceMQInterface&) = delete; - - virtual ~FairSourceMQInterface() - { - delete fInput; - fInput = nullptr; - - delete fSource; - fSource = nullptr; - - delete fRunAna; - fRunAna = nullptr; - } - - int64_t GetNumberOfEvent() { return fMaxIndex; } - - void SetFileProperties(const std::string& filename, const std::string& branchname) - { - fSourceName = filename; - fBranchName = branchname; - } - - //______________________________________________________________________________ - // FairFileSource - - template = 0> - void InitSource() - { - fRunAna = new FairRunAna(); - fSource = new FairSourceType(fSourceName.c_str()); - fSource->Init(); - fSource->ActivateObject(reinterpret_cast(&fInput), fBranchName.c_str()); - // fSource->ActivateObject(dynamic_cast(fData),fBranchName.c_str()); - fMaxIndex = fSource->CheckMaxEventNo(); - } - - template = 0> - void SetIndex(int64_t eventIdx) - { - fIndex = eventIdx; - } - - template = 0> - DataType_ptr GetOutData() - { - fSource->ReadEvent(fIndex); - return fInput; - } - - void GetOutData(DataType_ptr& data, int64_t evtIdx) - { - fSource->ReadEvent(evtIdx); - data = fInput; - } - - /*required for MQ*/ - void deserialize_impl(int64_t evtIdx) { fSource->ReadEvent(evtIdx); } - - protected: - FairSourceType* fSource; - DataType_ptr fInput; - std::unique_ptr fInput2; - int64_t fIndex; - int64_t fMaxIndex; - std::string fClassName; - std::string fBranchName; - std::string fSourceName; - FairRunAna* fRunAna; -}; - -#endif diff --git a/basemq/policies/Sampler/SimpleTreeReader.h b/basemq/policies/Sampler/SimpleTreeReader.h deleted file mode 100644 index 7715cd9e8b..0000000000 --- a/basemq/policies/Sampler/SimpleTreeReader.h +++ /dev/null @@ -1,184 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: SimpleTreeReader.h - * Author: winckler - * - * Created on November 25, 2014, 11:17 AM - */ - -#ifndef SIMPLEROOTSAMPLER_H -#define SIMPLEROOTSAMPLER_H - -// std -#include -#include -#include -#include - -// ROOT -#include -#include -#include -#include -#include - -template -class BaseSimpleTreeReader -{ - public: - BaseSimpleTreeReader() - : fSendHeader() - , fGetSocketNumber() - , fGetCurrentIndex() - , fInput(nullptr) - , fFileName("") - , fTreeName("") - , fBranchName("") - , fInputFile(nullptr) - , fTree(nullptr) - , fIndex(0) - , fIndexMax(0) - {} - - BaseSimpleTreeReader(const BaseSimpleTreeReader&) = delete; - BaseSimpleTreeReader operator=(const BaseSimpleTreeReader&) = delete; - - virtual ~BaseSimpleTreeReader() - { - if (fInputFile) { - fInputFile->Close(); - delete fInputFile; - } - } - - void SetFileProperties(const std::string& filename, const std::string& treename, const std::string& branchname) - { - fFileName = filename; - fTreeName = treename; - fBranchName = branchname; - } - - // template < std::enable_if::value,int> = 0> - void InitSource() - { - fInputFile = TFile::Open(fFileName.c_str(), "READ"); - if (fInputFile) { - fTree = fInputFile->Get(fTreeName.c_str()); - if (fTree) { - fTree->SetBranchAddress(fBranchName.c_str(), &fInput); - fIndexMax = fTree->GetEntries(); - } else { - LOG(error) << "Could not find tree " << fTreeName; - } - } else { - LOG(error) << "Could not open file " << fFileName << " in SimpleTreeReader::InitSource()"; - } - } - - void SendMultiPart() - { - fSendHeader(0); // callback that does the zmq multipart AND increment the current index (Event number) in - // generic sampler - } - - void SetIndex(int64_t Event) { fIndex = Event; } - - DataType* GetOutData() { return GetOutData(fIndex); } - - DataType* GetOutData(int64_t Event) - { - fTree->GetEntry(Event); - return fInput; - } - void GetOutData(DataType*& data, int64_t Event) - { - fTree->GetEntry(Event); - data = fInput; - } - void deserialize_impl(DataType*& data, int64_t Event) - { - /*required for MQ*/ - fTree->GetEntry(Event); - data = fInput; - } - void deserialize_impl(int64_t Event) - { - /*required for MQ*/ - fTree->GetEntry(Event); - } - - int64_t GetNumberOfEvent() - { - if (fTree) { - return fIndexMax; - } else { - return 0; - } - } - - template - std::vector> GetDataVector() - { - std::vector> allObj; - std::vector tempObj; - - if (std::is_same::value) { - for (int64_t i = 0; i < fTree->GetEntries(); i++) { - tempObj.clear(); - fTree->GetEntry(i); - for (int64_t iobj = 0; iobj < fInput->GetEntriesFast(); ++iobj) { - T* data = reinterpret_cast(fInput->At(iobj)); - if (!data) { - continue; - } - tempObj.push_back(*data); - } - allObj.push_back(tempObj); - } - } else { - for (int64_t i = 0; i < fTree->GetEntries(); i++) { - tempObj.clear(); - fTree->GetEntry(i); - T data = *fInput; - tempObj.push_back(data); - allObj.push_back(tempObj); - } - } - return allObj; - } - - // provides a callback to the Sampler. - void BindSendHeader(std::function callback) { fSendHeader = callback; } - - void BindGetSocketNumber(std::function callback) { fGetSocketNumber = callback; } - - void BindGetCurrentIndex(std::function callback) { fGetCurrentIndex = callback; } - - protected: - DataType* fInput; // data type of the branch you want to extract - - private: - std::function fSendHeader; // function pointer for the Sampler callback. - std::function fGetSocketNumber; // function pointer for the Sampler callback. - std::function fGetCurrentIndex; // function pointer for the Sampler callback. - - std::string fFileName; - std::string fTreeName; - std::string fBranchName; - TFile* fInputFile; - TTree* fTree; - int64_t fIndex; - int64_t fIndexMax; -}; - -template -using SimpleTreeReader = BaseSimpleTreeReader; - -#endif /* SIMPLEROOTSAMPLER_H */ diff --git a/basemq/policies/Serialization/BinaryBaseClassSerializer.h b/basemq/policies/Serialization/BinaryBaseClassSerializer.h deleted file mode 100644 index 8aaa287703..0000000000 --- a/basemq/policies/Serialization/BinaryBaseClassSerializer.h +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: BinaryBaseClassSerializer.h - * Author: winckler - * - * Created on October 10, 2014, 5:22 PM - */ - -#ifndef BINARYBASECLASSSERIALIZER_H -#define BINARYBASECLASSSERIALIZER_H - -#include "FairMQ.h" // for fair::mq::Message - -template -class BinaryBaseClassSerializer -{ - public: - BinaryBaseClassSerializer() - : fPayload(nullptr) - , fMessage(nullptr) - , fNumInput(0) - {} - - BinaryBaseClassSerializer(const BinaryBaseClassSerializer&) = delete; - BinaryBaseClassSerializer operator=(const BinaryBaseClassSerializer&) = delete; - - virtual ~BinaryBaseClassSerializer() {} - - void GetPayload(fair::mq::Message* msg) - { - int inputSize = msg->GetSize(); - if (inputSize > 0) { - fNumInput = inputSize / sizeof(TPayload); - } - fPayload = static_cast(msg->GetData()); - } - - void SetMessage(fair::mq::Message* msg) { fMessage = msg; } - - fair::mq::Message* GetMessage() { return fMessage; } - - protected: - TPayload* fPayload; - fair::mq::Message* fMessage; - int fNumInput; -}; - -#endif /* BINARYBASECLASSSERIALIZER_H */ diff --git a/basemq/policies/Serialization/IOPolicy.h b/basemq/policies/Serialization/IOPolicy.h deleted file mode 100644 index 8dd95b2d18..0000000000 --- a/basemq/policies/Serialization/IOPolicy.h +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#ifndef IOPOLICY_H -#define IOPOLICY_H - -#include - -namespace fair { -namespace mq { -namespace policy { - -// PassTypes -struct PointerType -{}; -struct ReferenceType -{}; -struct ValueType -{}; -struct UniquePtrType -{}; -struct SharedPtrType -{}; - -// PassType -template -struct SelectPassType; - -// PassType -template -struct SelectPassType -{ - using Type = T*; -}; - -// PassType -template -struct SelectPassType -{ - using Type = T&; -}; - -// PassType -template -struct SelectPassType -{ - using Type = T; -}; - -// PassType -template -struct SelectPassType -{ - using Type = std::unique_ptr; -}; - -// PassType -template -struct SelectPassType -{ - using Type = std::shared_ptr; -}; - -// AllocatorType -struct OpNewCreator -{ - template - static void CreateImpl(T*& input, Args&&... args) - { - input = new T(std::forward(args)...); - } -}; - -// AllocatorType -struct NullptrCreator -{ - template - static void CreateImpl(T*& input, [[gnu::unused]] Args&&... args) - { - input = nullptr; - } -}; - -// AllocatorType -struct EmptyCreator -{ - template - static void CreateImpl([[gnu::unused]] Args&&... args) - {} -}; - -// AllocatorType -template -struct SmartPtrCreator -{ - template - static void CreateImpl(std::unique_ptr& input, Args&&... args) - { - input = std::unique_ptr(new T(std::forward(args)...), Deleter()); - } - - template - static void CreateImpl(std::shared_ptr& input, Args&&... args) - { - input = std::shared_ptr(new T(std::forward(args)...), Deleter()); - } -}; - -// InitializerType -struct NullptrInitializer -{ - template - static void InitializeImpl(T*& input, [[gnu::unused]] Args&&... args) - { - input = nullptr; - } - template - static void InitializeImpl(std::unique_ptr& input, [[gnu::unused]] Args&&... args) - { - input = nullptr; - } - template - static void InitializeImpl(std::shared_ptr& input, [[gnu::unused]] Args&&... args) - { - input = nullptr; - } -}; - -// InitializerType -struct EmptyInitializer -{ - template - static void InitializeImpl([[gnu::unused]] Args&&... args) - {} -}; - -// DeleterType -struct EmptyDeleter -{ - template - static void DestroyImpl([[gnu::unused]] Args&&... args) - {} -}; - -// DeleterType -struct RawPtrDeleter -{ - template - static void DestroyImpl(T* input) - { - delete input; - input = nullptr; - } -}; - -// Input Policy -template -class InputPolicy : public Deserializer -{ - public: - InputPolicy(const InputPolicy&) = delete; - InputPolicy operator=(const InputPolicy&) = delete; - - using DeserializerType = Deserializer; - using DataType = typename SelectPassType::Type; - - InputPolicy() - : Deserializer() - , fInput() - { - InitializerType::InitializeImpl(fInput); - } - - template - void Create(Args&&... args) - { - AllocatorType::CreateImpl(fInput, std::forward(args)...); - } - - protected: - virtual ~InputPolicy() { DeleterType::DestroyImpl(fInput); } - - DataType fInput; -}; - -// Output Policy -template -class OutputPolicy : public Serializer -{ - public: - using SerializerType = Serializer; - using DataType = typename SelectPassType::Type; - - OutputPolicy() - : Serializer() - { - InitializerType::InitializeImpl(fOutput); - } - - template - void Create(Args&&... args) - { - AllocatorType::CreateImpl(fOutput, std::forward(args)...); - } - - protected: - ~OutputPolicy() { DeleterType::DestroyImpl(fOutput); } - - DataType fOutput; -}; - -} // namespace policy -} // namespace mq -} // namespace fair - -#endif // IOPOLICY_H diff --git a/basemq/policies/Storage/BinaryOutFileManager.h b/basemq/policies/Storage/BinaryOutFileManager.h deleted file mode 100644 index 74eb733280..0000000000 --- a/basemq/policies/Storage/BinaryOutFileManager.h +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: BinaryOutFileManager.h - * Author: winckler - * - * Created on October 15, 2014, 11:36 AM - */ - -#ifndef BINARYOUTFILEMANAGER_H -#define BINARYOUTFILEMANAGER_H - -// std -#include -#include -#include -#include - -// boost -namespace boost { -namespace serialization { -class access; -} -} // namespace boost -#include -#include -#include - -// FairRoot -#include "BoostDataSaver.h" -#include "FairMQ.h" // for fair::mq::Message -#include "TriviallyCopyableDataSaver.h" -#include "baseMQtools.h" - -#define GET_POLICY_ID(Policy) #Policy - -using BinArchive = boost::archive::binary_oarchive; - -template -using BoostSerializable = baseMQ::tools::resolve::has_BoostSerialization; - -template> -class BinaryOutFileManager : public TStoragePolicy -{ - public: - using TStoragePolicy::Read; - using TStoragePolicy::Write; - - BinaryOutFileManager() - : TStoragePolicy() - , fFileName("test.dat") - { - ; - } - virtual ~BinaryOutFileManager() { fOutfile.close(); } - - std::string GetPolicyID() - { - std::string str(GET_POLICY_ID(TStoragePolicy)); - return str; - } - - void SetFileProperties(const std::string& filename) { fFileName = filename; } - - void AddToFile(fair::mq::Message* msg) { TStoragePolicy::Write(fOutfile, msg); } - - void AddToFile(TPayload* objArr, long size) { AppendObjArray(fOutfile, objArr, size); } - - template - void AppendObjArray(std::ofstream& outfile, T* objArr, long size) - { - TStoragePolicy::Write(outfile, objArr, size); - } - - std::vector> GetAllObj(const std::string& filename) - { - std::ifstream infile; - infile = std::ifstream(filename); - std::vector> vec = TStoragePolicy::Read(infile); - - return vec; - } - - virtual void InitOutputFile() - { - fOutfile = std::ofstream(fFileName, std::ios::out | std::ios::binary | std::ios::app); - } - - protected: - std::string fFileName; - std::ofstream fOutfile; -}; - -#endif /* BINARYOUTFILEMANAGER_H */ diff --git a/basemq/policies/Storage/BoostDataSaver.h b/basemq/policies/Storage/BoostDataSaver.h deleted file mode 100644 index cdb121c64c..0000000000 --- a/basemq/policies/Storage/BoostDataSaver.h +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: BoostDataSaver.h - * Author: winckler - * - * Created on October 22, 2014, 5:16 PM - */ - -#ifndef BOOSTDATASAVER_H -#define BOOSTDATASAVER_H - -// FairRoot -#include "FairMQ.h" // for fair::mq::Message - -// std -#include -#include -#include -#include -#include - -// boost -namespace boost { -namespace serialization { -class access; -} -} // namespace boost -#include -#include -#include -#include - -template -class BoostDataSaver -{ - public: - BoostDataSaver() {} - virtual ~BoostDataSaver() {} - - virtual void InitOutputFile() {} - - void Write(std::ofstream& outfile, TPayload* objArr, long sizeArr = 1) - { - std::vector dataVector(objArr, objArr + sizeArr); - TArchiveOut outArchive(outfile); - outArchive << dataVector; - } - - void Write(std::ofstream& outfile, std::vector dataVector) - { - TArchiveOut outArchive(outfile); - outArchive << dataVector; - } - - void Write(std::ofstream& outfile, fair::mq::Message* msg) - { - std::vector objArr; - std::string msgStr(static_cast(msg->GetData()), msg->GetSize()); - std::istringstream ibuffer(msgStr); - TArchiveIn inputArchive(ibuffer); - try { - inputArchive >> objArr; - } catch (boost::archive::archive_exception& e) { - LOG(error) << e.what(); - } - TArchiveOut outArchive(outfile); - outArchive << objArr; - } - - std::vector> Read(std::ifstream& infile) - { - std::vector> dataContainer; - while (infile.peek() != EOF && !infile.eof()) { - TArchiveIn inArchive(infile); - std::vector temp; - inArchive >> temp; - dataContainer.push_back(temp); - } - return dataContainer; - } -}; - -#endif /* BOOSTDATASAVER_H */ diff --git a/basemq/policies/Storage/RootOutFileManager.h b/basemq/policies/Storage/RootOutFileManager.h deleted file mode 100644 index ba0f88cefa..0000000000 --- a/basemq/policies/Storage/RootOutFileManager.h +++ /dev/null @@ -1,383 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: RootOutFileManager.h - * Author: winckler - * - * Created on October 7, 2014, 9:40 PM - */ - -#ifndef ROOTOUTFILEMANAGER_H -#define ROOTOUTFILEMANAGER_H - -// std -#include -#include -#include - -// ROOT -#include -#include -#include -#include -#include -#include -#include -#include - -// FairRoot -#include "FairLogger.h" -#include "FairMQ.h" // for fair::mq::Message, fair::mq::ProgOptions - -template -class RootOutFileManager -{ - public: - RootOutFileManager() - : fFilename() - , fTreeName() - , fBranchName() - , fClassName() - , fFileOption() - , fUseClonesArray(false) - , fFlowMode(true) - , fWrite(false) - , fOutFile(nullptr) - , fTree(nullptr) - , fOutput(nullptr) - , fOutputData(nullptr) - , fFolder(nullptr) - {} - - RootOutFileManager(const std::string& filename, - const std::string& treeName, - const std::string& branchName, - const std::string& className, - const std::string& fileOption) - : fFilename(filename) - , fTreeName(treeName) - , fBranchName(branchName) - , fClassName(className) - , fFileOption(fileOption) - , fUseClonesArray(false) - , fFlowMode(true) - , fWrite(false) - , fOutFile(nullptr) - , fTree(nullptr) - , fOutput(nullptr) - , fOutputData(nullptr) - , fFolder(nullptr) - {} - - RootOutFileManager(const RootOutFileManager&) = delete; - RootOutFileManager operator=(const RootOutFileManager&) = delete; - - virtual ~RootOutFileManager() - { - if (fFlowMode && fWrite) { - fTree->Write("", TObject::kOverwrite); - } - - delete fTree; - - if (fOutFile) { - if (fOutFile->IsOpen()) { - fOutFile->Close(); - } - delete fOutFile; - } - - delete fFolder; - } - - void SetFileProperties(const std::string& filename, - const std::string& treeName, - const std::string& branchName, - const std::string& className = "", - const std::string& fileOption = "RECREATE", - bool useClonesArray = false, - bool flowMode = true) - { - fFilename = filename; - fTreeName = treeName; - fBranchName = branchName; - fClassName = className; - fFileOption = fileOption; - fUseClonesArray = useClonesArray; - fFlowMode = flowMode; - if (!std::is_base_of::value && fUseClonesArray) { - fUseClonesArray = false; - LOG(warn) << "Deactivate TClonesArray method: the data class must inherit from TObject."; - } - } - - void SetFileProperties(const fair::mq::ProgOptions& config) - { - fFilename = config.GetValue("output-file-name"); - fTreeName = config.GetValue("output-file-tree"); - fBranchName = config.GetValue("output-file-branch"); - fClassName = config.GetValue("hit-classname"); - fFileOption = config.GetValue("output-file-option"); - fUseClonesArray = config.GetValue("use-clones-array"); - fFlowMode = config.GetValue("flow-mode"); - - if (!std::is_base_of::value && fUseClonesArray) { - fUseClonesArray = false; - LOG(warn) << "Deactivate TClonesArray method: the data class must inherit from TObject."; - } - } - - void AddToFile(std::vector& inputData) - { - if (fUseClonesArray) { - fOutput->Delete(); - - for (unsigned int i = 0; i < inputData.size(); ++i) { - new ((*fOutput)[i]) DataType(inputData.at(i)); - } - - if (fOutput->IsEmpty()) { - LOG(debug) << "RootOutFileManager::AddToFile(vector&): No Output array!"; - } - - fTree->Fill(); - } else { - for (unsigned int i = 0; i < inputData.size(); ++i) { - fOutputData = &inputData.at(i); - fTree->Fill(); - } - } - if (!fFlowMode) { - fTree->Write("", TObject::kOverwrite); - } - } - - void AddToFile(DataType* objArr, long size) - { - // todo : check if fine when update option - if (fUseClonesArray) { - fOutput->Delete(); - - for (unsigned int i = 0; i < size; ++i) { - new ((*fOutput)[i]) DataType(objArr[i]); - } - - if (fOutput->IsEmpty()) { - LOG(debug) << "RootOutFileManager::AddToFile(vector&): No Output array!"; - } - - fTree->Fill(); - if (!fFlowMode) { - fTree->Write("", TObject::kOverwrite); - } - } else { - std::vector dataVector(objArr, objArr + size); - AddToFile(dataVector); - } - } - - void AddToFile(TClonesArray* inputData) - { - if (fUseClonesArray) { - fOutput = inputData; - fTree->SetBranchAddress(fBranchName.c_str(), &fOutput); - - if (fOutput->IsEmpty()) { - LOG(debug) << "RootOutFileManager::AddToFile(TClonesArray*): No Output array!"; - } - fTree->Fill(); - if (!fFlowMode) { - fTree->Write("", TObject::kOverwrite); - } - } else { - LOG(debug) << "RootOutFileManager::AddToFile(TClonesArray*): TClonesArray not set as output container"; - } - } - - void AddToFile(fair::mq::Message* msg) - { - int inputSize = msg->GetSize(); - int numInput = 0; - if (inputSize > 0) { - numInput = inputSize / sizeof(DataType); - } - fOutputData = static_cast(msg->GetData()); - AddToFile(fOutputData, numInput); - } - - void AddToFile(std::unique_ptr& input) { AddToFile(input.get()); } - - void InitOutputFile() - { - fWrite = true; - fOutFile = TFile::Open(fFilename.c_str(), fFileOption.c_str()); - - bool updateTree = false; - - // if given option is update attempt to get tree from file - if (fFileOption == "UPDATE") { - fTree = fOutFile->Get(fTreeName.c_str()); - if (fTree) { - updateTree = true; - LOG(info) << "Update tree"; - } else { - updateTree = false; - LOG(info) << "Create new tree"; - } - } - - // if tree not found or option is not UPDATE, create a new tree - if (!updateTree) { - fTree = new TTree(fTreeName.c_str(), "Test output"); - } - - // direct storage or TClonesArray - if (fUseClonesArray) { - fOutput = new TClonesArray(fClassName.c_str()); - if (updateTree) { - fTree->SetBranchAddress(fBranchName.c_str(), &fOutput); - } else { - fTree->Branch(fBranchName.c_str(), "TClonesArray", &fOutput); - } - } else { - if (updateTree) { - fTree->SetBranchAddress(fBranchName.c_str(), &fOutputData); - } else { - fTree->Branch(fBranchName.c_str(), fClassName.c_str(), &fOutputData); - } - } - - fFolder = new TFolder("cbmroot", "/cbmroot"); - TList* branchNameList = new TList(); - branchNameList->AddLast(new TObjString(fBranchName.c_str())); - branchNameList->Write("BranchList", TObject::kSingleKey); - - branchNameList->Delete(); - delete branchNameList; - } - void InitTCA(const std::string& classname); - - std::vector> GetAllObj(const std::string& filename, - const std::string& treename, - const std::string& branchname) - { - fWrite = false; - - TFile* file = TFile::Open(filename.c_str(), "READ"); - - std::vector> allObj; - std::vector tempObj; - - if (file) { - fTree = file->Get(fTreeName.c_str()); - } else { - LOG(error) << "Could not open file" << fTreeName.c_str(); - } - - if (fTree) { - if (fUseClonesArray) { - fOutput = new TClonesArray(fClassName.c_str()); - fTree->SetBranchAddress(fBranchName.c_str(), &fOutput); - - for (Long64_t i = 0; i < fTree->GetEntries(); i++) { - tempObj.clear(); - fTree->GetEntry(i); - for (Int_t iobj = 0; iobj < fOutput->GetEntriesFast(); ++iobj) { - DataType* data = reinterpret_cast(fOutput->At(iobj)); - if (!data) { - continue; - } - tempObj.push_back(*data); - } - allObj.push_back(tempObj); - } - } else { - fTree->SetBranchAddress(branchname.c_str(), &fOutputData); - for (Long64_t i = 0; i < fTree->GetEntries(); i++) { - fTree->GetEntry(i); - DataType data = *fOutputData; - tempObj.push_back(data); - } - allObj.push_back(tempObj); - } - } else { - LOG(error) << "Could not find tree " << treename.c_str(); - } - - if (file) { - file->Close(); - } - return allObj; - } - - template - void Serialize(Args&&... args) - { - AddToFile(std::forward(args)...); - } - - protected: - virtual void Init() - { - fWrite = true; - fOutFile = TFile::Open(fFilename.c_str(), fFileOption.c_str()); - - bool updateTree = false; - - // if given option is update attempt to get tree from file - if (fFileOption == "UPDATE") { - fTree = fOutFile->Get(fTreeName.c_str()); - if (fTree) { - updateTree = true; - LOG(info) << "Update tree"; - } else { - updateTree = false; - LOG(info) << "Create new tree"; - } - } - - // if tree not found or option is not UPDATE, create a new tree - if (!updateTree) { - fTree = new TTree(fTreeName.c_str(), "Test output"); - } - - // direct storage or TClonesArray - if (fUseClonesArray) { - fOutput = new TClonesArray(fClassName.c_str()); - if (updateTree) { - fTree->SetBranchAddress(fBranchName.c_str(), &fOutput); - } else { - fTree->Branch(fBranchName.c_str(), "TClonesArray", &fOutput); - } - } else { - if (updateTree) { - fTree->SetBranchAddress(fBranchName.c_str(), &fOutputData); - } else { - fTree->Branch(fBranchName.c_str(), fClassName.c_str(), &fOutputData); - } - } - } - - std::string fFilename; - std::string fTreeName; - std::string fBranchName; - std::string fClassName; - std::string fFileOption; - bool fUseClonesArray; - bool fFlowMode; - bool fWrite; - - TFile* fOutFile; - TTree* fTree; - TClonesArray* fOutput; - DataType* fOutputData; - TFolder* fFolder; -}; - -#endif /* ROOTOUTFILEMANAGER_H */ diff --git a/basemq/policies/Storage/TriviallyCopyableDataSaver.h b/basemq/policies/Storage/TriviallyCopyableDataSaver.h deleted file mode 100644 index 997abfe573..0000000000 --- a/basemq/policies/Storage/TriviallyCopyableDataSaver.h +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -/* - * File: TriviallyCopyableDataSaver.h - * Author: winckler - * - * Created on October 22, 2014, 5:45 PM - */ - -#ifndef TRIVIALLYCOPYABLEDATASAVER_H -#define TRIVIALLYCOPYABLEDATASAVER_H - -#include "FairMQ.h" // for fair::mq::Message - -#include -#include - -template -class TriviallyCopyableDataSaver -{ - public: - TriviallyCopyableDataSaver() {} - virtual ~TriviallyCopyableDataSaver() {} - - virtual void InitOutputFile() {} - - void Write(std::ofstream& outfile, TPayload* ObjArr, long sizeArr = 1) - { - // if (std::is_trivially_copyable::value) not implemented yet in gcc 4.8.2 - if (std::is_trivial::value) { - write_pod_array(outfile, ObjArr, sizeArr); - outfile.close(); - } - } - - void Write(std::ofstream& outfile, fair::mq::Message* msg) - { - int inputSize = msg->GetSize(); - long sizeArr = 0; - if (inputSize > 0) { - sizeArr = inputSize / sizeof(TPayload); - } - TPayload* ObjArr = static_cast(msg->GetData()); - // if (std::is_trivially_copyable::value) - if (std::is_trivial::value) { - write_pod_array(outfile, ObjArr, sizeArr); - outfile.close(); - } - } - - std::vector> Read(std::ifstream& infile) - { - std::vector> DataContainer; - ReadArr(infile, DataContainer); - return DataContainer; - } - - void ReadArr(std::ifstream& infile, std::vector>& DataContainer) - { - // if (std::is_trivially_copyable::value) - if (std::is_trivial::value) { - int c = infile.peek(); - if (c == EOF) { - if (infile.eof()) { - infile.close(); - } - } else { - long sizeArr; - read_pod(infile, sizeArr); - TPayload* ObjArr = new TPayload[sizeArr]; - infile.read(reinterpret_cast(ObjArr), sizeArr * sizeof(TPayload)); - std::vector DataVector(ObjArr, ObjArr + sizeArr); - delete[] ObjArr; - DataContainer.push_back(DataVector); - ReadArr(infile, DataContainer); - } - } else { - LOG(error) << "In ReadArr(std::ifstream& , std::vector >& ) :"; - LOG(error) - << "(de)serialization of object is not supported (Object must be a 'trivially copyable' data class)."; - } - } - - template - void ReadArr(std::ifstream& infile, T* ObjArr, long posArr = 0) - { - // if(std::is_trivially_copyable::value) - if (std::is_trivial::value) { - int c = infile.peek(); - if (c == EOF) { - if (infile.eof()) { - infile.close(); - } - } else { - posArr += read_pod_array(infile, ObjArr, posArr); - ReadArr(infile, ObjArr, posArr); - } - } else { - LOG(error) << "In ReadArr(std::ifstream& infile, T* ObjArr, long posArr = 0):"; - LOG(error) - << "(de)serialization of object is not supported (Object must be a 'trivially copyable' data class)."; - } - } - - template - void write_pod(std::ofstream& out, T& t) - { - out.write(reinterpret_cast(&t), sizeof(T)); - } - - template - void read_pod(std::ifstream& in, T& t) - { - in.read(reinterpret_cast(&t), sizeof(T)); - } - - template - void write_pod_vector(std::ofstream& out, std::vector& vect) - { - long size = vect.size(); - write_pod(out, size); - out.write(reinterpret_cast(vect.front()), size * sizeof(T)); - } - - template - void read_pod_vector(std::ifstream& in, std::vector& vect) - { - long size; - read_pod(in, size); - vect.resize(size); - in.read(reinterpret_cast(vect.front()), size * sizeof(T)); - } - - template - void write_pod_array(std::ofstream& out, T* objarr, long size) - { - write_pod(out, size); - out.write(reinterpret_cast(objarr), size * sizeof(T)); - } - - template - int count_podObj_inFile(std::ifstream& in) - { - int count = 0; - // if (std::is_trivially_copyable::value) - if (std::is_trivial::value) { - int c = in.peek(); - if (c == EOF) { - if (in.eof()) { - in.close(); - } - } else { - long size; - read_pod(in, size); - count += size; - in.seekg(size * sizeof(T), std::ios::cur); - count += count_podObj_inFile(in); - } - } - return count; - } - - template - long read_pod_array(std::ifstream& in, T* objarr, long posArr = 0) - { - long size; - read_pod(in, size); - in.read(reinterpret_cast(objarr + posArr), size * sizeof(T)); - return size; - } -}; - -#endif /* TRIVIALLYCOPYABLEDATASAVER_H */ diff --git a/basemq/tasks/FairMQProcessorTask.cxx b/basemq/tasks/FairMQProcessorTask.cxx deleted file mode 100644 index 6fe59a40b6..0000000000 --- a/basemq/tasks/FairMQProcessorTask.cxx +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQProcessorTask.cxx - * - * @since Dec 6, 2012-12-06 - * @author: D. Klein, A. Rybalchenko - */ - -#include "FairMQProcessorTask.h" - -FairMQProcessorTask::FairMQProcessorTask() - : fPayload() -{} - -FairMQProcessorTask::~FairMQProcessorTask() {} - -void FairMQProcessorTask::Exec(Option_t* /*opt*/) {} - -void FairMQProcessorTask::SetPayload(std::unique_ptr& msg) -{ - fPayload = std::move(msg); -} - -void FairMQProcessorTask::GetPayload(std::unique_ptr& msg) -{ - msg = std::move(fPayload); -} diff --git a/basemq/tasks/FairMQProcessorTask.h b/basemq/tasks/FairMQProcessorTask.h deleted file mode 100644 index 853e836ff0..0000000000 --- a/basemq/tasks/FairMQProcessorTask.h +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQProcessorTask.h - * - * @since Dec 6, 2012-12-06 - * @author: D. Klein, A. Rybalchenko - */ - -#ifndef FAIRMQPROCESSORTASK_H_ -#define FAIRMQPROCESSORTASK_H_ - -#include "FairMQ.h" // for fair::mq::Message -#include "FairTask.h" - -class FairMQProcessorTask : public FairTask -{ - public: - FairMQProcessorTask(); - FairMQProcessorTask(const FairMQProcessorTask&) = delete; - FairMQProcessorTask operator=(const FairMQProcessorTask&) = delete; - - virtual ~FairMQProcessorTask(); - - virtual void Exec(Option_t* opt = "0"); - - void SetPayload(std::unique_ptr& msg); - void GetPayload(std::unique_ptr& msg); - - protected: - std::unique_ptr fPayload; -}; - -#endif /* FAIRMQPROCESSORTASK_H_ */ diff --git a/basemq/tasks/FairMQSamplerTask.cxx b/basemq/tasks/FairMQSamplerTask.cxx deleted file mode 100644 index bd2933eab5..0000000000 --- a/basemq/tasks/FairMQSamplerTask.cxx +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQSamplerTask.cxx - * - * @since 2012-11-22 - * @author D. Klein, A. Rybalchenko - */ - -#include "FairMQSamplerTask.h" - -#include "FairRootManager.h" - -FairMQSamplerTask::FairMQSamplerTask() - : FairTask("Abstract base task used for loading a branch from a root file into memory") - , fBranch() - , fInput(nullptr) - , fPayload() - , fEventIndex(0) - , fEvtHeader(nullptr) - , fTransportFactory(nullptr) -{} - -FairMQSamplerTask::FairMQSamplerTask(const Text_t* name, int iVerbose) - : FairTask(name, iVerbose) - , fBranch() - , fInput(nullptr) - , fPayload() - , fEventIndex(0) - , fEvtHeader(nullptr) - , fTransportFactory(nullptr) -{} - -FairMQSamplerTask::~FairMQSamplerTask() -{ - delete fInput; -} - -InitStatus FairMQSamplerTask::Init() -{ - FairRootManager* ioman = FairRootManager::Instance(); - fEvtHeader = static_cast(ioman->GetObject("EventHeader.")); - fInput = static_cast(ioman->GetObject(fBranch.c_str())); - - return kSUCCESS; -} - -void FairMQSamplerTask::Exec(Option_t* /*opt*/) {} - -void FairMQSamplerTask::SetBranch(const std::string& branch) -{ - fBranch = branch; -} - -void FairMQSamplerTask::SetEventIndex(Long64_t eventIndex) -{ - fEventIndex = eventIndex; -} - -void FairMQSamplerTask::GetPayload(fair::mq::MessagePtr& msg) -{ - msg = move(fPayload); -} - -void FairMQSamplerTask::SetTransport(std::shared_ptr factory) -{ - fTransportFactory = factory; -} diff --git a/basemq/tasks/FairMQSamplerTask.h b/basemq/tasks/FairMQSamplerTask.h deleted file mode 100644 index c600b23ac5..0000000000 --- a/basemq/tasks/FairMQSamplerTask.h +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairMQSamplerTask.h - * - * @since 2012-11-22 - * @author D. Klein, A. Rybalchenko - */ - -#ifndef FAIRMQSAMPLERTASK_H_ -#define FAIRMQSAMPLERTASK_H_ - -#include "FairEventHeader.h" -#include "FairMQ.h" // for fair::mq::Message, fair::mq::TransportFactory -#include "FairTask.h" - -#include -#include -#include - -class FairMQSamplerTask : public FairTask -{ - public: - FairMQSamplerTask(); - FairMQSamplerTask(const Text_t* name, int iVerbose = 1); - FairMQSamplerTask(const FairMQSamplerTask&) = delete; - FairMQSamplerTask operator=(const FairMQSamplerTask&) = delete; - - virtual ~FairMQSamplerTask(); - - virtual InitStatus Init(); - virtual void Exec(Option_t* opt); - - void SetEventIndex(Long64_t eventIndex); - void SetBranch(const std::string& branch); - - void GetPayload(std::unique_ptr& msg); - void SetTransport(std::shared_ptr factory); - - protected: - std::string fBranch; - TClonesArray* fInput; - fair::mq::MessagePtr fPayload; - Long64_t fEventIndex; - FairEventHeader* fEvtHeader; - std::shared_ptr fTransportFactory; -}; - -#endif /* FAIRMQSAMPLERTASK_H_ */ diff --git a/check-format.sh b/check-format.sh index f459531d08..29276f003c 100755 --- a/check-format.sh +++ b/check-format.sh @@ -4,10 +4,14 @@ BASE_COMMIT=${FAIRROOT_FORMAT_BASE:-HEAD} CLANG_FORMAT=${FAIRROOT_CLANG_FORMAT_BIN:-clang-format} GIT_CLANG_FORMAT_BIN=${FAIRROOT_GIT_CLANG_FORMAT_BIN:-git-clang-format} -FILES=$(git diff --name-only $BASE_COMMIT | grep -E '*\.(h|hpp|c|C|cpp|cxx|tpl)$' | grep -viE '*LinkDef.h$') -# Include only files that exist -FILES=$(ls -1 $FILES 2>/dev/null) -RESULT=$($GIT_CLANG_FORMAT_BIN --commit $BASE_COMMIT --diff $FILES --extensions h,hpp,c,C,cpp,cxx,tpl) +FILES=$(git diff --name-only $BASE_COMMIT | grep -E '\.(h|hpp|c|C|cpp|cxx)$' | grep -viE 'LinkDef.h$' | grep -viE 'third_party/') + +RESULT="no modified files to format" +if [ -n "$FILES" ]; then + # Include only files that exist + FILES=$(ls -1 $FILES 2>/dev/null) + RESULT=$($GIT_CLANG_FORMAT_BIN --commit $BASE_COMMIT --diff $FILES --extensions h,hpp,c,C,cpp,cxx) +fi $CLANG_FORMAT --version diff --git a/cmake/README.md b/cmake/README.md index 117f79a206..2edf805b1f 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -1,9 +1,37 @@ -cmake -======== +CMake {#cmake} +===== + +CMake for Consuming Projects +---------------------------- + +Most of the typical usage of the CMake related APIs +of FairRoot can be seen in +`templates/project_stl_containers/CMakeLists.txt`. + +Also many CMake related tooling that was shipped in +earlier releases is (or will) be available via +[FairCMakeModules](https://github.com/FairRootGroup/FairCMakeModules), +and is documented there. + +### fairroot_check_root_cxxstd_compatibility() + +This CMake function checks whether the C++ level of the +calling project matches with the level that ROOT was configured. +If it doesn't match, a warning is generated. +It it part of `ROOTMacros.cmake`. + +Typical usage: + +```cmake +find_package2(PUBLIC ROOT REQUIRED) +include(ROOTMacros) +fairroot_check_root_cxxstd_compatibility() +``` + +cmake Directory Structure +========================= Steering classes for the `cmake` software that manages the build processes of the FairRoot software. * *modules* directory stores the functions responsible for the identification of the packages that FairRoot depends on; * *scripts* folder stores the functions that are checking the system requirements; -* *cuda* contains cmake modules to find the CUDA Toolkit (http://www.nvidia.com/object/cuda_home_new.html) enabling parallel computations on the NVIDIA GPUs; -* *checks* to test the cxx11 compatibility. \ No newline at end of file diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake index 3a2474c7cd..b8137d1c79 100644 --- a/cmake/modules/CheckCompiler.cmake +++ b/cmake/modules/CheckCompiler.cmake @@ -14,115 +14,50 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo) endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) -# Check for the existence of fairsoft-config -# This program only exist in newer versions of fairsoft. If the file exist extract information about -# the compiler and compiler flags used to install fairsoft. -# Compare compiler and compiler flags used to compile fairsoft with the compiler and flags used now -# In case of differences print a warning -Find_Program(FAIRSOFT_CONFIG fairsoft-config PATHS $ENV{SIMPATH}/bin $ENV{FAIRSOFT_ROOT}/bin NO_DEFAULT_PATH) - -If(FAIRSOFT_CONFIG) - Message(STATUS "fairsoft-config found") - Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cc - OUTPUT_VARIABLE FAIRSOFT_C_COMPILER) - Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cxx - OUTPUT_VARIABLE FAIRSOFT_CXX_COMPILER) - Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --f77 - OUTPUT_VARIABLE FAIRSOFT_Fortran_COMPILER) - - # Strip whitespaces, otherwise readlink and comparison don't work - String(STRIP ${FAIRSOFT_C_COMPILER} FAIRSOFT_C_COMPILER) - String(STRIP ${FAIRSOFT_CXX_COMPILER} FAIRSOFT_CXX_COMPILER) - String(STRIP ${FAIRSOFT_Fortran_COMPILER} FAIRSOFT_Fortran_COMPILER) - - Get_Filename_Component(FAIRSOFT_C_COMPILER ${FAIRSOFT_C_COMPILER} REALPATH) - Get_Filename_Component(FAIRSOFT_CXX_COMPILER ${FAIRSOFT_CXX_COMPILER} REALPATH) - Get_Filename_Component(FAIRSOFT_Fortran_COMPILER ${FAIRSOFT_Fortran_COMPILER} REALPATH) - - Set(FAIRROOT_C_COMPILER ${CMAKE_C_COMPILER}) - Set(FAIRROOT_CXX_COMPILER ${CMAKE_CXX_COMPILER}) - Set(FAIRROOT_Fortran_COMPILER ${CMAKE_Fortran_COMPILER}) - - String(STRIP ${FAIRROOT_C_COMPILER} FAIRROOT_C_COMPILER) - String(STRIP ${FAIRROOT_CXX_COMPILER} FAIRROOT_CXX_COMPILER) - - If(FAIRROOT_Fortran_COMPILER) - String(STRIP ${FAIRROOT_Fortran_COMPILER} FAIRROOT_Fortran_COMPILER) - Get_Filename_Component(FAIRROOT_Fortran_COMPILER ${FAIRROOT_Fortran_COMPILER} REALPATH) - EndIf() - - Get_Filename_Component(FAIRROOT_C_COMPILER ${FAIRROOT_C_COMPILER} REALPATH) - Get_Filename_Component(FAIRROOT_CXX_COMPILER ${FAIRROOT_CXX_COMPILER} REALPATH) - - Execute_Process(COMMAND ${FAIRSOFT_C_COMPILER} --version - OUTPUT_VARIABLE FAIRSOFT_C_COMPILER_STRING - ) - - Execute_Process(COMMAND ${FAIRROOT_C_COMPILER} --version - OUTPUT_VARIABLE FAIRROOT_C_COMPILER_STRING - ) - - Execute_Process(COMMAND ${FAIRSOFT_CXX_COMPILER} --version - OUTPUT_VARIABLE FAIRSOFT_CXX_COMPILER_STRING - ) - Execute_Process(COMMAND ${FAIRROOT_CXX_COMPILER} --version - OUTPUT_VARIABLE FAIRROOT_CXX_COMPILER_STRING - ) - - set(compiler_wrapper "(omebrew/shim|ccache)") - if(NOT FAIRSOFT_C_COMPILER MATCHES ${compiler_wrapper} AND - NOT FAIRSOFT_CXX_COMPILER MATCHES ${compiler_wrapper} AND - NOT FAIRSOFT_Fortran_COMPILER MATCHES ${compiler_wrapper} AND - NOT FAIRROOT_C_COMPILER MATCHES ${compiler_wrapper} AND - NOT FAIRROOT_CXX_COMPILER MATCHES ${compiler_wrapper} AND - NOT FAIRROOT_Fortran_COMPILER MATCHES ${compiler_wrapper}) - - If(NOT ("${FAIRSOFT_C_COMPILER_STRING}" STREQUAL "${FAIRROOT_C_COMPILER_STRING}") OR NOT ("${FAIRSOFT_CXX_COMPILER_STRING}" STREQUAL "${FAIRROOT_CXX_COMPILER_STRING}")) - execute_process(COMMAND cmake -E compare_files ${FAIRSOFT_CXX_COMPILER} ${FAIRROOT_CXX_COMPILER} RESULT_VARIABLE COMPILER_DIFF) - If(NOT ${COMPILER_DIFF} EQUAL 0) - Message(STATUS "C compiler used for FairSoft installation: ${FAIRSOFT_C_COMPILER}") - Message(STATUS "C compiler used now: ${FAIRROOT_C_COMPILER}") - Message(STATUS "CXX compiler used for FairSoft installation: ${FAIRSOFT_CXX_COMPILER}") - Message(STATUS "CXX compiler used now: ${FAIRROOT_CXX_COMPILER}") - Message(STATUS "The compiler during the compilation of FairSoft is different from the current one.") - If(USE_DIFFERENT_COMPILER) - Message(STATUS "The error was silenced by the usage of -DUSE_DIFFERENT_COMPILER=TRUE") - Else() - Message(FATAL_ERROR "This is seen as an error. If you know that the setting is correct you can silence the error by using the CMake flag -DUSE_DIFFERENT_COMPILER=TRUE") - EndIf() - EndIf() - EndIf() - - If(FAIRROOT_Fortran_COMPILER) - If(NOT (${FAIRSOFT_Fortran_COMPILER} STREQUAL ${FAIRROOT_Fortran_COMPILER})) - String(STRIP ${FAIRSOFT_Fortran_COMPILER} FAIRSOFT_Fortran_COMPILER) - Message(STATUS "Fortran compiler used for FairSoft installation: ${FAIRSOFT_Fortran_COMPILER}") - Message(STATUS "Fortran compiler used now: ${FAIRROOT_Fortran_COMPILER}") - Message(STATUS "The compiler during the compilation of FairSoft is different from the current one.") - If(USE_DIFFERENT_COMPILER) - Message(STATUS "The error was silenced by the usage of -DUSE_DIFFERENT_COMPILER=TRUE") - Else() - Message(FATAL_ERROR "This is seen as an error. If you know that the setting is correct you can silence the error by using the CMake flag -DUSE_DIFFERENT_COMPILER=TRUE") - EndIf() - EndIf() - EndIf() +if ((NOT CMAKE_CXX_STANDARD) AND TARGET ROOT::Core) + get_property(ROOT_CXX_STANDARD TARGET ROOT::Core + PROPERTY INTERFACE_COMPILE_FEATURES) + message(VERBOSE "Using ROOT to detect CXX_STANDARD: [${ROOT_CXX_STANDARD}]") + list(FILTER ROOT_CXX_STANDARD INCLUDE REGEX "^cxx_std_.*") + list(TRANSFORM ROOT_CXX_STANDARD REPLACE "^cxx_std_" "") + list(SORT ROOT_CXX_STANDARD ORDER DESCENDING) + list(GET ROOT_CXX_STANDARD 0 ROOT_CXX_STANDARD) + if(ROOT_CXX_STANDARD) + set(CMAKE_CXX_STANDARD ${ROOT_CXX_STANDARD}) + message(VERBOSE "Taking CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} from ROOT") endif() +endif() + +if (NOT CMAKE_CXX_STANDARD) + find_program(FAIRSOFT_CONFIG fairsoft-config PATHS $ENV{SIMPATH}/bin $ENV{FAIRSOFT_ROOT}/bin NO_DEFAULT_PATH) + + if(FAIRSOFT_CONFIG) + message(VERBOSE "fairsoft-config found") + Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cxxflags + OUTPUT_VARIABLE FAIRSOFT_CXX_FLAGS) + unset(CMAKE_MATCH_1) + String(REGEX REPLACE "-std=c\\+\\+(..)" "" FAIRSOFT_CXX_FLAGS "${FAIRSOFT_CXX_FLAGS}") + if(CMAKE_MATCH_1) + set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1}) + message(VERBOSE "Taking CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} from fairsoft-config") + endif() + endif() +endif() - Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cxxflags - OUTPUT_VARIABLE FAIRSOFT_CXX_FLAGS) - unset(CMAKE_MATCH_1) - String(REGEX REPLACE "-std=c\\+\\+(..)" "" FAIRSOFT_CXX_FLAGS "${FAIRSOFT_CXX_FLAGS}") - if(CMAKE_MATCH_1 AND (NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD VERSION_LESS CMAKE_MATCH_1)) - set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1}) +if (FairRoot_CXX_STANDARD) + if ((NOT CMAKE_CXX_STANDARD) + OR (CMAKE_CXX_STANDARD VERSION_LESS FairRoot_CXX_STANDARD)) + set(CMAKE_CXX_STANDARD "${FairRoot_CXX_STANDARD}") endif() - String(STRIP ${FAIRSOFT_CXX_FLAGS} FAIRSOFT_CXX_FLAGS) - if(FAIRSOFT_CXX_FLAGS) - Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FAIRSOFT_CXX_FLAGS}") +endif() + +if (PROJECT_MIN_CXX_STANDARD) + if ((NOT CMAKE_CXX_STANDARD) + OR (CMAKE_CXX_STANDARD VERSION_LESS PROJECT_MIN_CXX_STANDARD)) + set(CMAKE_CXX_STANDARD "${PROJECT_MIN_CXX_STANDARD}") endif() -Else() - Message(STATUS "fairsoft-config not found. Is SIMPATH or FAIRSOFT_ROOT set correctly?") -EndIf() +endif() if (CMAKE_SYSTEM_NAME MATCHES Linux) @@ -188,7 +123,10 @@ endif (CMAKE_SYSTEM_NAME MATCHES Linux) if (CMAKE_SYSTEM_NAME MATCHES Darwin) - EXEC_PROGRAM("sw_vers -productVersion | cut -d . -f 1-2" OUTPUT_VARIABLE MAC_OS_VERSION) + execute_process(COMMAND sw_vers -productVersion + COMMAND cut -d . -f 1-2 + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE MAC_OS_VERSION) MESSAGE("-- Found a Mac OS X System ${MAC_OS_VERSION}") if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") MESSAGE("-- Found GNU compiler collection") diff --git a/cmake/modules/FairMacros.cmake b/cmake/modules/FairMacros.cmake index 7122a60912..4ede2e71d8 100644 --- a/cmake/modules/FairMacros.cmake +++ b/cmake/modules/FairMacros.cmake @@ -45,26 +45,6 @@ string(CONCAT Geant4Data_Variables_csh ${Geant4Data_Variables_csh} "\ ################################################################################ ENDMACRO() -#Defines some variables with console color escape sequences - if(NOT WIN32 AND NOT DISABLE_COLOR) - string(ASCII 27 Esc) - set(CR "${Esc}[m") - set(CB "${Esc}[1m") - set(Red "${Esc}[31m") - set(Green "${Esc}[32m") - set(Yellow "${Esc}[33m") - set(Blue "${Esc}[34m") - set(Magenta "${Esc}[35m") - set(Cyan "${Esc}[36m") - set(White "${Esc}[37m") - set(BRed "${Esc}[1;31m") - set(BGreen "${Esc}[1;32m") - set(BYellow "${Esc}[1;33m") - set(BBlue "${Esc}[1;34m") - set(BMagenta "${Esc}[1;35m") - set(BCyan "${Esc}[1;36m") - set(BWhite "${Esc}[1;37m") - endif() ################################################################################ MACRO(SUBDIRLIST result curdir) @@ -250,82 +230,7 @@ MACRO(REMOVE_FROM_LIST var_name list1 list2) SET(${var_name} ${filter_tmp}) ENDMACRO(REMOVE_FROM_LIST) ################################################################################ -MACRO (GENERATE_TEST_SCRIPT SCRIPT_FULL_NAME) - - get_filename_component(path_name ${SCRIPT_FULL_NAME} PATH) - get_filename_component(file_extension ${SCRIPT_FULL_NAME} EXT) - get_filename_component(file_name ${SCRIPT_FULL_NAME} NAME_WE) - set(shell_script_name "${file_name}.sh") - - if(${ARGC} GREATER 1) - set(new_path ${ARGV1}) - Else() - string(REPLACE ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} new_path ${path_name} - ) - EndIf() - CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH}) - set(MY_LD_LIBRARY_PATH ${output}) - set(my_script_name ${SCRIPT_FULL_NAME}) - Write_Geant4Data_Variables_sh() - IF(FAIRROOT_FOUND) - configure_file(${FAIRROOT_CMAKEMOD_DIR}/scripts/set_env.sh.in - ${new_path}/${shell_script_name} - ) - ELSE(FAIRROOT_FOUND) - configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/set_env.sh.in - ${new_path}/${shell_script_name} - ) - ENDIF(FAIRROOT_FOUND) - EXEC_PROGRAM(/bin/chmod ARGS "u+x ${new_path}/${shell_script_name}" OUTPUT_VARIABLE tmp) -ENDMACRO (GENERATE_TEST_SCRIPT) -################################################################################ - -Macro(Generate_Exe_Script _Path _ExeName) - - Message("PATH: ${_Path}") - Message("ExeName: ${_ExeName}") - set(shell_script_name "${_ExeName}.sh") - Message("shell_script_name: ${shell_script_name}") - - string(REPLACE ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} new_path ${_Path} - ) - - set(my_exe_name ${EXECUTABLE_OUTPUT_PATH}/${_ExeName}) - Write_Geant4Data_Variables_sh() - configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/run_binary.sh.in - ${new_path}/${shell_script_name} - ) - - EXEC_PROGRAM(/bin/chmod ARGS "u+x ${new_path}/${shell_script_name}" OUTPUT_VARIABLE tmp ) - -EndMacro(Generate_Exe_Script) -################################################################################ - -Macro (Generate_Version_Info) - if(FairRoot_FOUND) - Add_Custom_Target(svnheader ALL) - - Add_Custom_Command(TARGET svnheader - COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${PROJECT_SOURCE_DIR} - -DBINARY_DIR=${CMAKE_BINARY_DIR} - -DINCLUDE_OUTPUT_DIRECTORY=${INCLUDE_OUTPUT_DIRECTORY} - -DFAIRROOT=${FAIRROOT_CMAKEMOD_DIR} - -P ${FAIRROOT_CMAKEMOD_DIR}/modules/GenerateVersionInfo.cmake - ) - else() - Add_Custom_Target(svnheader ALL) - Add_Custom_Command(TARGET svnheader - COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} - -DBINARY_DIR=${CMAKE_BINARY_DIR} - -DINCLUDE_OUTPUT_DIRECTORY=${INCLUDE_OUTPUT_DIRECTORY} - -P ${CMAKE_SOURCE_DIR}/cmake/modules/GenerateVersionInfo.cmake - ) - endif() -EndMacro (Generate_Version_Info) -################################################################################ Macro (SetBasicVariables) if(FairRoot_FOUND) @@ -340,7 +245,6 @@ if(FairRoot_FOUND) ${FMT_INCLUDE_DIR} ) Set(SYSTEM_INCLUDE_DIRECTORIES - ${ROOT_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ) Set(ROOT_INCLUDE_PATH @@ -360,121 +264,6 @@ endif() EndMacro (SetBasicVariables) -################################################################################ -# -# find_package2(PRIVATE|PUBLIC|INTERFACE -# [VERSION ] -# [COMPONENTS ] -# [ADD_REQUIREMENTS_OF ] -# [any other option the native find_package supports]...) -# -# Wrapper around CMake's native find_package command to add some features and bookkeeping. -# -# The qualifier (PRIVATE|PUBLIC|INTERFACE) to the package to populate -# the variables PROJECT_[INTERFACE]__([VERSION]|[COMPONENTS]|PACKAGE_DEPENDENCIES) -# accordingly. This bookkeeping information is used to print our dependency found summary -# table and to generate a part of our CMake package. -# -# When a dependending package is listed with ADD_REQUIREMENTS_OF the variables -# __VERSION|COMPONENTS are looked up to and added to the native -# VERSION (selected highest version) and COMPONENTS (deduplicated) args. -# -# COMPONENTS and VERSION args are then just passed to the native find_package. -# -macro(find_package2 qualifier pkgname) - cmake_parse_arguments(ARGS "" "VERSION" "COMPONENTS;ADD_REQUIREMENTS_OF" ${ARGN}) - - string(TOUPPER ${pkgname} pkgname_upper) - set(__old_cpp__ ${CMAKE_PREFIX_PATH}) - set(CMAKE_PREFIX_PATH ${${pkgname_upper}_ROOT} $ENV{${pkgname_upper}_ROOT} ${CMAKE_PREFIX_PATH}) - - # build lists of required versions and components - unset(__required_versions__) - unset(__components__) - if(ARGS_VERSION) - list(APPEND __required_versions__ ${ARGS_VERSION}) - endif() - if(ARGS_COMPONENTS) - list(APPEND __components__ ${ARGS_COMPONENTS}) - endif() - if(ARGS_ADD_REQUIREMENTS_OF) - foreach(dep_pkgname IN LISTS ARGS_ADD_REQUIREMENTS_OF) - if(${dep_pkgname}_${pkgname}_VERSION) - list(APPEND __required_versions__ ${${dep_pkgname}_${pkgname}_VERSION}) - endif() - if(${dep_pkgname}_${pkgname}_COMPONENTS) - list(APPEND __components__ ${${dep_pkgname}_${pkgname}_COMPONENTS}) - endif() - endforeach() - endif() - - # select highest required version - unset(__version__) - if(__required_versions__) - list(GET __required_versions__ 0 __version__) - foreach(v IN LISTS __required_versions__) - if(${v} VERSION_GREATER ${__version__}) - set(__version__ ${v}) - endif() - endforeach() - endif() - # deduplicate required component list - if(__components__) - list(REMOVE_DUPLICATES __components__) - endif() - - # call native find_package - if(__components__) - find_package(${pkgname} ${__version__} QUIET COMPONENTS ${__components__} ${ARGS_UNPARSED_ARGUMENTS}) - else() - find_package(${pkgname} ${__version__} QUIET ${ARGS_UNPARSED_ARGUMENTS}) - endif() - - if(${pkgname}_FOUND) - if(${qualifier} STREQUAL PRIVATE) - set(PROJECT_${pkgname}_VERSION ${__version__}) - set(PROJECT_${pkgname}_COMPONENTS ${__components__}) - set(PROJECT_PACKAGE_DEPENDENCIES ${PROJECT_PACKAGE_DEPENDENCIES} ${pkgname}) - elseif(${qualifier} STREQUAL PUBLIC) - set(PROJECT_${pkgname}_VERSION ${__version__}) - set(PROJECT_${pkgname}_COMPONENTS ${__components__}) - set(PROJECT_PACKAGE_DEPENDENCIES ${PROJECT_PACKAGE_DEPENDENCIES} ${pkgname}) - set(PROJECT_INTERFACE_${pkgname}_VERSION ${__version__}) - set(PROJECT_INTERFACE_${pkgname}_COMPONENTS ${__components__}) - set(PROJECT_INTERFACE_PACKAGE_DEPENDENCIES ${PROJECT_INTERFACE_PACKAGE_DEPENDENCIES} ${pkgname}) - elseif(${qualifier} STREQUAL INTERFACE) - set(PROJECT_INTERFACE_${pkgname}_VERSION ${__version__}) - set(PROJECT_INTERFACE_${pkgname}_COMPONENTS ${__components__}) - set(PROJECT_INTERFACE_PACKAGE_DEPENDENCIES ${PROJECT_INTERFACE_PACKAGE_DEPENDENCIES} ${pkgname}) - endif() - endif() - - unset(__version__) - unset(__components__) - unset(__required_versions__) - set(CMAKE_PREFIX_PATH ${__old_cpp__}) - unset(__old_cpp__) -endmacro() -################################################################################ -function(pad str width char out) - cmake_parse_arguments(ARGS "LEFT" "COLOR" "" ${ARGN}) - string(LENGTH ${str} length) - if(ARGS_COLOR) - math(EXPR padding "${width}-(${length}-10*${ARGS_COLOR})") - else() - math(EXPR padding "${width}-${length}") - endif() - if(padding GREATER 0) - foreach(i RANGE ${padding}) - if(ARGS_LEFT) - set(str "${char}${str}") - else() - set(str "${str}${char}") - endif() - endforeach() - endif() - set(${out} ${str} PARENT_SCOPE) -endfunction() ################################################################################ function(generate_package_components) join("${PROJECT_PACKAGE_COMPONENTS}" " " COMPS) @@ -493,3 +282,23 @@ check_required_components(${PROJECT_NAME}) set(PACKAGE_COMPONENTS ${PACKAGE_COMPONENTS} PARENT_SCOPE) endfunction() ################################################################################ + +function(fairroot_check_root_cxxstd_compatibility) + if(NOT CMAKE_CXX_STANDARD) + return() + endif() + if(ROOT_cxx${CMAKE_CXX_STANDARD}_FOUND) + return() + endif() + if(NOT TARGET ROOT::Core) + message(WARNING "ROOT::Core target not found, can't check CXX standard") + return() + endif() + get_property(compile_features TARGET ROOT::Core + PROPERTY INTERFACE_COMPILE_FEATURES) + if("cxx_std_${CMAKE_CXX_STANDARD}" IN_LIST compile_features) + return() + endif() + message(WARNING "CXX Standard ${CMAKE_CXX_STANDARD} not found " + "in compile features of ROOT: ${compile_features}") +endfunction() diff --git a/cmake/modules/FairRootTargetRootDictionary.cmake b/cmake/modules/FairRootTargetRootDictionary.cmake index b83833d7f9..2724cae168 100644 --- a/cmake/modules/FairRootTargetRootDictionary.cmake +++ b/cmake/modules/FairRootTargetRootDictionary.cmake @@ -113,11 +113,6 @@ function(fairroot_target_root_dictionary target) # Need at least root core library # get_filename_component(LD_LIBRARY_PATH ROOT::Core DIRECTORY) set(LD_LIBRARY_PATH ${ROOT_LIBRARY_DIR}) - # and possibly toolchain libs if we are using a toolchain - if(DEFINED ENV{GCC_TOOLCHAIN_ROOT}) - set(LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:$ENV{GCC_TOOLCHAIN_ROOT}/lib") - set(LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:$ENV{GCC_TOOLCHAIN_ROOT}/lib64") - endif() set(includeDirs $) set(includeDirs "$") @@ -134,7 +129,7 @@ function(fairroot_target_root_dictionary target) OUTPUT ${dictionaryFile} ${pcmFile} ${rootmapFile} VERBATIM COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ENV{LD_LIBRARY_PATH}" - ${ROOT_CINT_EXECUTABLE} + $ -f ${dictionaryFile} -inlineInputHeader -rmf ${rootmapFile} diff --git a/cmake/modules/FindFairRoot.cmake b/cmake/modules/FindFairRoot.cmake index a1e2156c3c..6fd2de4ce2 100644 --- a/cmake/modules/FindFairRoot.cmake +++ b/cmake/modules/FindFairRoot.cmake @@ -1,5 +1,5 @@ ################################################################################ - # Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -34,6 +34,9 @@ set(FAIRROOTPATH "${FairRoot_PREFIX}") MESSAGE(STATUS "Setting FairRoot environment:") message(STATUS " FairRoot Version : ${FairRoot_VERSION}") +if(FairRoot_GIT_VERSION) + message(STATUS " FairRoot Version (Git) : ${FairRoot_GIT_VERSION}") +endif() message(STATUS " FairRoot CXX Standard : ${FairRoot_CXX_STANDARD}") message(STATUS " FairRoot prefix : ${FairRoot_PREFIX}") diff --git a/cmake/modules/FindHEPMC.cmake b/cmake/modules/FindHEPMC.cmake index 484ec902f5..3f241bbf7d 100644 --- a/cmake/modules/FindHEPMC.cmake +++ b/cmake/modules/FindHEPMC.cmake @@ -15,13 +15,11 @@ FIND_PATH(HEPMC_INCLUDE_DIR NAMES HepMC/HepMCDefs.h PATHS ${HEPMC_DIR}/include - ${AlFa_DIR}/include ${SIMPATH}/include/ ) FIND_PATH(HEPMC_LIB_DIR NAMES libHepMC.so libHepMC.dylib PATHS ${HEPMC_DIR} - ${AlFa_DIR} ${SIMPATH} PATH_SUFFIXES lib ) diff --git a/cmake/modules/FindPythia8.cmake b/cmake/modules/FindPythia8.cmake index 80b47bbe35..950e2e8c0c 100644 --- a/cmake/modules/FindPythia8.cmake +++ b/cmake/modules/FindPythia8.cmake @@ -16,12 +16,8 @@ ################################################################################ set(_pythia8dirs - ${PYTHIA8} - $ENV{PYTHIA8} ${PYTHIA8_DIR} $ENV{PYTHIA8_DIR} - $ENV{PYTHIA_ROOT} - ${AlFa_DIR} ${SIMPATH} ${SIMPATH}/generators /usr @@ -48,7 +44,6 @@ find_library(PYTHIA8_LIBRARY find_path(PYTHIA8_LIB_DIR NAMES libpythia8.so libpythia8.dylib PATHS $ENV{PYTHIA8_DIR} ${PYTHIA8_DIR} - ${AlFa_DIR} ${SIMPATH} ${SIMPATH}/generators PATH_SUFFIXES lib diff --git a/cmake/modules/FindROOT.cmake b/cmake/modules/FindROOT.cmake deleted file mode 100644 index 3d0dfb4640..0000000000 --- a/cmake/modules/FindROOT.cmake +++ /dev/null @@ -1,216 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ -# - Find ROOT instalation -# This module tries to find the ROOT installation on your system. -# It tries to find the root-config script which gives you all the needed -# information. -# If the system variable ROOTSYS is set this is straight forward. -# If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH. -# If you need an other path you should add this path to this varaible. -# The root-config script is then used to detect basically everything else. -# This module defines a number of key variables and macros. -# -# Variables defined by this module: -# -# ROOT_FOUND System has ROOT, this means the root-config -# executable was found. -# -# ROOT_INCLUDE_DIR ROOT include directories: not cached -# -# ROOT_INCLUDES Same as above, -# -# ROOT_LIBRARIES Link to these to use the ROOT libraries, not cached -# -# ROOT_LIBRARY_DIR The path to where the ROOT library files are. -# -# ROOT_VERSION_STRING The version string of the ROOT libraries which -# is reported by root-config -# -# ROOT_VERSION_MAJOR Major version number of ROOT -# ROOT_VERSION_MINOR Minor version number of ROOT -# ROOT_VERSION_PATCH Patch version number of ROOT -# -# ROOT_VERSION_NUMBER A unique version number which is calculated from -# major, minor and patch version found -# -# ROOT_CINT_EXECUTABLE The rootcint executable. -# -# RLIBMAP_EXECUTABLE The rlibmap executable. - -#Message(STATUS "Looking for Root...") - -Set(ROOT_FOUND FALSE) -Set(ROOT_DEFINITIONS "") -Set(ROOT_INSTALLED_VERSION_TOO_OLD FALSE) -Set(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND) - -Find_Program(ROOT_CONFIG_EXECUTABLE NAMES root-config - HINTS ${ROOT_DIR} ${SIMPATH} ${ROOTSYS} $ENV{ROOTSYS} - PATH_SUFFIXES bin tools/root/bin - NO_DEFAULT_PATH -) - -If(ROOT_CONFIG_EXECUTABLE) - - String(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) - Set(ENV{ROOTSYS} ${test}) - Set(ROOTSYS ${test}) - - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --version - OUTPUT_VARIABLE ROOT_VERSION_STRING - ) - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix - OUTPUT_VARIABLE ROOT_INSTALL_DIR - ) - String(STRIP ${ROOT_VERSION_STRING} ROOT_VERSION_STRING) - String(STRIP ${ROOT_INSTALL_DIR} ROOT_INSTALL_DIR) - - - # MESSAGE(STATUS "Looking for Root... - Found ${ROOT_INSTALL_DIR}/bin/root") - # MESSAGE(STATUS "Looking for Root... - Found version is ${ROOT_VERSION_STRING} ") - - # extract major, minor, and patch versions from - # the version string given by root-config - String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+[\\/.][0-9][0-9]+.*" "\\1" ROOT_VERSION_MAJOR "${ROOT_VERSION_STRING}") - String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+[\\/.][0-9][0-9]+.*" "\\1" ROOT_VERSION_MINOR "${ROOT_VERSION_STRING}") - String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+[\\/.]([0-9][0-9]+).*" "\\1" ROOT_VERSION_PATCH "${ROOT_VERSION_STRING}") - - if(NOT ROOT_FIND_VERSION_MAJOR) - set(ROOT_FIND_VERSION_MAJOR 0) - endif() - if(NOT ROOT_FIND_VERSION_MINOR) - set(ROOT_FIND_VERSION_MINOR 0) - endif() - if(NOT ROOT_FIND_VERSION_PATCH) - set(ROOT_FIND_VERSION_PATCH 0) - endif() - # compute overall version numbers which can be compared at once - Math(EXPR req_vers "${ROOT_FIND_VERSION_MAJOR}*10000 + ${ROOT_FIND_VERSION_MINOR}*100 + ${ROOT_FIND_VERSION_PATCH}") - Math(EXPR found_vers "${ROOT_VERSION_MAJOR}*10000 + ${ROOT_VERSION_MINOR}*100 + ${ROOT_VERSION_PATCH}") - Math(EXPR ROOT_FOUND_VERSION "${ROOT_VERSION_MAJOR}*10000 + ${ROOT_VERSION_MINOR}*100 + ${ROOT_VERSION_PATCH}") - - Set(ROOT_Version ${found_vers}) - Set(ROOT_VERSION_NUMBER ${found_vers}) - Set(ROOT_VERSION ${ROOT_VERSION_STRING}) - Set(ROOT_ROOT ${ROOT_INSTALL_DIR}) - - If(found_vers LESS req_vers) - Set(ROOT_FOUND FALSE) - Set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE) - Else(found_vers LESS req_vers) - Set(ROOT_FOUND TRUE) - EndIf(found_vers LESS req_vers) - -Else(ROOT_CONFIG_EXECUTABLE) - Message(STATUS "Looking for Root... - Not found") - Message(FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the subdirectory cmake/modules.") -Endif(ROOT_CONFIG_EXECUTABLE) - - -If(ROOT_FOUND) - - # ask root-config for the library dir - # Set ROOT_LIBRARY_DIR - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir - OUTPUT_VARIABLE ROOT_LIBRARY_DIR - ) - String(STRIP ${ROOT_LIBRARY_DIR} ROOT_LIBRARY_DIR) - - # ask root-config for the binary dir - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir - OUTPUT_VARIABLE ROOT_BINARY_DIR - ) - String(STRIP ${ROOT_BINARY_DIR} ROOT_BINARY_DIR) - - # ask root-config for the include dir - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir - OUTPUT_VARIABLE ROOT_INCLUDE_DIR - ) - String(STRIP ${ROOT_INCLUDE_DIR} ROOT_INCLUDE_DIR) - - # ask root-config for the library varaibles - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --glibs - OUTPUT_VARIABLE ROOT_LIBRARIES - ) - String(STRIP ${ROOT_LIBRARIES} ROOT_LIBRARIES) - - if("${ROOT_VERSION_MAJOR}.${ROOT_VERSION_MINOR}" VERSION_GREATER 6.16) - Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --has-vmc - OUTPUT_VARIABLE ROOT_vmc_FOUND - RESULT_VARIABLE __root_config_has_vmc_rc - ) - if(NOT __root_config_has_vmc_rc EQUAL 0) - set(ROOT_vmc_FOUND no) - else() - string(STRIP ${ROOT_vmc_FOUND} ROOT_vmc_FOUND) - endif() - unset(__root_config_has_vmc_rc) - else() - set(ROOT_vmc_FOUND yes) - endif() - - # Make variables changeble to the advanced user - Mark_As_Advanced(ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS) - - # Set ROOT_INCLUDES - Set(ROOT_INCLUDES ${ROOT_INCLUDE_DIR}) - - Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR}) - - ####################################### - # - # Check the executables of ROOT - # ( root, rootcint, etc. ) - # - ####################################### - - Find_Program(ROOT_CINT_EXECUTABLE - NAMES rootcint - PATHS ${ROOT_BINARY_DIR} - NO_DEFAULT_PATH - ) - - Find_Program(RLIBMAP_EXECUTABLE - NAMES rlibmap - PATHS ${ROOT_BINARY_DIR} - NO_DEFAULT_PATH - ) - - find_program(ROOT_EXECUTABLE - NAMES root root.exe - HINTS ${ROOT_BINARY_DIR} - NO_DEFAULT_PATH - ) - - Include(ROOTMacros) - - # Aliases for imported VMC packages ROOT dependencies - set(__root_targets_list VMC Core RIO Tree Rint Physics MathCore Thread Geom EG EGPythia6 Gpad Hist RHTTP Proof Net Matrix GeomPainter Graf3d Graf RooFit RooFitCore XMLParser XMLIO Eve RGL Gui Ged Gdml) - if(ROOT_vmc_FOUND) - list(APPEND __root_targets_list VMC) - endif() - foreach(_root_dep ${__root_targets_list}) - find_library(${_root_dep}_LIB ${_root_dep} PATHS ${ROOT_LIBRARY_DIR}) - if(${_root_dep}_LIB) - add_library(${_root_dep} SHARED IMPORTED GLOBAL) - set_target_properties(${_root_dep} PROPERTIES IMPORTED_LOCATION ${${_root_dep}_LIB}) - add_library(ROOT::${_root_dep} ALIAS ${_root_dep}) - message(STATUS "ROOT::${_root_dep} target added by hand.") - endif() - endforeach(_root_dep) - unset(__root_targets_list) - -Else(ROOT_FOUND) - - If(ROOT_FIND_REQUIRED) - Message(STATUS "Looking for ROOT... - Found version to old.") - Message(STATUS "Looking for ROOT... - Minimum required version is ${ROOT_FIND_VERSION}") - Message(FATAL_ERROR "Stop here because of a wrong Root version.") - EndIf(ROOT_FIND_REQUIRED) - -Endif(ROOT_FOUND) diff --git a/cmake/modules/GenerateVersionInfo.cmake b/cmake/modules/GenerateVersionInfo.cmake deleted file mode 100644 index d50f7dc358..0000000000 --- a/cmake/modules/GenerateVersionInfo.cmake +++ /dev/null @@ -1,39 +0,0 @@ - ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # - # # - # This software is distributed under the terms of the # - # GNU Lesser General Public Licence (LGPL) version 3, # - # copied verbatim in the file "LICENSE" # - ################################################################################ - # Configure FairVersion.h - # ------------------------------ - - Find_Package(Git) - - If(GIT_FOUND AND EXISTS "${SOURCE_DIR}/.git") - Execute_Process(COMMAND ${GIT_EXECUTABLE} describe --tags - OUTPUT_VARIABLE FAIRROOT_GIT_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${SOURCE_DIR} - ) - Execute_Process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%cd - OUTPUT_VARIABLE FAIRROOT_GIT_DATE - OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY ${SOURCE_DIR} - ) - Message(STATUS "FairRoot Version - ${FAIRROOT_GIT_VERSION} from - ${FAIRROOT_GIT_DATE}") - if(FAIRROOT) - Configure_File(${FAIRROOT}/scripts/FairVersion.h.tmp ${BINARY_DIR}/FairVersion.h @ONLY) - else(FAIRROOT) - Configure_File(${SOURCE_DIR}/cmake/scripts/FairVersion.h.tmp ${BINARY_DIR}/FairVersion.h @ONLY) - endif(FAIRROOT) - - Else() - include(${BINARY_DIR}/FairRootConfigVersion.cmake) - if(FAIRROOT) - Configure_File(${FAIRROOT}/scripts/FairVersion.h.default ${BINARY_DIR}/FairVersion.h @ONLY) - else(FAIRROOT) - Configure_File(${SOURCE_DIR}/cmake/scripts/FairVersion.h.default ${BINARY_DIR}/FairVersion.h @ONLY) - endif(FAIRROOT) - EndIf() - diff --git a/cmake/modules/ROOTMacros.cmake b/cmake/modules/ROOTMacros.cmake index f5e0eb26ca..2c09cc9ceb 100644 --- a/cmake/modules/ROOTMacros.cmake +++ b/cmake/modules/ROOTMacros.cmake @@ -35,28 +35,21 @@ endfunction(Format) # Macros for building ROOT dictionary # ########################################### -Macro(ROOT_GENERATE_DICTIONARY) - # Macro to switch between the old implementation with parameters - # and the new implementation without parameters. - # For the new implementation some CMake variables has to be defined - # before calling the macro. +Find_Program(ROOT_CINT_EXECUTABLE + NAMES rootcint + PATHS ${ROOT_BINDIR} + NO_DEFAULT_PATH + ) - If(${ARGC} EQUAL 0) -# Message("New Version") - ROOT_GENERATE_DICTIONARY_NEW() - Else(${ARGC} EQUAL 0) - If(${ARGC} EQUAL 4) -# Message("Old Version") - ROOT_GENERATE_DICTIONARY_OLD("${ARGV0}" "${ARGV1}" "${ARGV2}" "${ARGV3}") - Else(${ARGC} EQUAL 4) - Message(FATAL_ERROR "Has to be implemented") - EndIf(${ARGC} EQUAL 4) - EndIf(${ARGC} EQUAL 0) -EndMacro(ROOT_GENERATE_DICTIONARY) - -Macro(ROOT_GENERATE_DICTIONARY_NEW) +macro(FAIRROOT_GENERATE_DICTIONARY) + if(${ARGC} GREATER 0) + message(FATAL_ERROR "FAIRROOT_GENERATE_DICTIONARY has no args") + endif() + if(NOT FAIRROOTPATH) + message(FATAL_ERROR "Do not call from inside FairRoot") + endif() # All Arguments needed for this new version of the macro are defined # in the parent scope, namely in the CMakeLists.txt of the submodule @@ -93,7 +86,7 @@ Macro(ROOT_GENERATE_DICTIONARY_NEW) String(REPLACE ";" " " Int_HDRS_STR "${Int_HDRS}") Set(EXTRA_DICT_PARAMETERS "") - If (ROOT_FOUND_VERSION GREATER 59999) + If(TRUE) Set(Int_ROOTMAPFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap) Set(Int_PCMFILE G__${Int_LIB}Dict_rdict.pcm) @@ -110,69 +103,21 @@ Macro(ROOT_GENERATE_DICTIONARY_NEW) # time we run make. To pass the variables a script is created containing the # correct values for the needed variables - IF(FAIRROOTPATH) + if(TRUE) Configure_File(${FAIRROOTPATH}/share/fairbase/cmake/scripts/generate_dictionary_root.sh.in ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh ) - #EXEC_PROGRAM(/bin/chmod ARGS "u+x ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh") execute_process(COMMAND /bin/chmod u+x ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh OUTPUT_QUIET) - ELSE(FAIRROOTPATH) - Configure_File(${PROJECT_SOURCE_DIR}/cmake/scripts/generate_dictionary_root.sh.in - ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh - ) - ENDIF(FAIRROOTPATH) - - - If (ROOT_FOUND_VERSION GREATER 59999) Add_Custom_Command(OUTPUT ${OUTPUT_FILES} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${Int_PCMFILE} ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} DEPENDS ${Int_HDRS} ${Int_LINKDEF} ) Install(FILES ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} ${Int_ROOTMAPFILE} DESTINATION lib) - Else() - Add_Custom_Command(OUTPUT ${OUTPUT_FILES} - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh - DEPENDS ${Int_HDRS} ${Int_LINKDEF} - ) EndIf() +endmacro() -endmacro(ROOT_GENERATE_DICTIONARY_NEW) - - -MACRO (ROOT_GENERATE_DICTIONARY_OLD INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN) - - set(INCLUDE_DIRS) - - foreach (_current_FILE ${INCLUDE_DIRS_IN}) - set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE}) - endforeach (_current_FILE ${INCLUDE_DIRS_IN}) - -# Message("Definitions: ${DEFINITIONS}") -# MESSAGE("INFILES: ${INFILES}") -# MESSAGE("OutFILE: ${OUTFILE}") -# MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}") -# MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}") - - STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}") -# MESSAGE("BLA: ${bla}") - SET (OUTFILES ${OUTFILE} ${bla}) - - - if (CMAKE_SYSTEM_NAME MATCHES Linux) - ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} - COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:${_intel_lib_dirs} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} - ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE}) - else (CMAKE_SYSTEM_NAME MATCHES Linux) - if (CMAKE_SYSTEM_NAME MATCHES Darwin) - ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES} - COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} - ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE}) - endif (CMAKE_SYSTEM_NAME MATCHES Darwin) - endif (CMAKE_SYSTEM_NAME MATCHES Linux) - -ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD) MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME) @@ -260,7 +205,7 @@ Macro(GENERATE_LIBRARY) Else( IS_ABSOLUTE ${LINKDEF}) Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF}) EndIf( IS_ABSOLUTE ${LINKDEF}) - ROOT_GENERATE_DICTIONARY() + FAIRROOT_GENERATE_DICTIONARY() SET(Int_SRCS ${Int_SRCS} ${DICTIONARY}) SET_SOURCE_FILES_PROPERTIES(${DICTIONARY} PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast" diff --git a/cmake/modules/WriteConfigFile.cmake b/cmake/modules/WriteConfigFile.cmake index 2258435473..533b637bbd 100644 --- a/cmake/modules/WriteConfigFile.cmake +++ b/cmake/modules/WriteConfigFile.cmake @@ -126,9 +126,6 @@ MACRO (WRITE_CONFIG_FILE filename) CONVERT_LIST_TO_STRING(${ROOT_LIBRARIES}) Set(ROOT_LIBRARIES ${output}) - CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_DIR}) - Set(ROOT_INCLUDE_DIR ${output} ) - # Set(VMCWORKDIR ${C}) Set(FAIRLIBDIR ${FAIRLIBDIR}) @@ -153,7 +150,7 @@ MACRO (WRITE_CONFIG_FILE filename) CONVERT_LIST_TO_STRING(${PYTHONPATH}) SET(MY_PYTHONPATH ${output}) - SET (PATH ${ROOTSYS}/bin ${PATH}) + SET (PATH ${ROOT_BINDIR} ${PATH}) UNIQUE(PATH "${PATH}") CONVERT_LIST_TO_STRING(${PATH}) Set(MY_PATH ${output}) diff --git a/cmake/private/FairRootConfig.cmake.in b/cmake/private/FairRootConfig.cmake.in index 0923ed046b..a3d84fdcbc 100644 --- a/cmake/private/FairRootConfig.cmake.in +++ b/cmake/private/FairRootConfig.cmake.in @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -10,8 +10,13 @@ set_and_check(@PROJECT_NAME@_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@") set(@PROJECT_NAME@_BINDIR "@PACKAGE_CMAKE_INSTALL_FULL_BINDIR@") +set(@PROJECT_NAME@_GIT_VERSION "@PROJECT_GIT_VERSION@") set(@PROJECT_NAME@_CXX_STANDARD "@CMAKE_CXX_STANDARD@") check_required_components(@PROJECT_NAME@) +# ***** PACKAGE_DEPENDENCIES ***** +@PACKAGE_DEPENDENCIES@ +# ***** PACKAGE_DEPENDENCIES ***** + include(@PACKAGE_PACKAGE_INSTALL_DESTINATION@/@PROJECT_NAME@Targets.cmake) diff --git a/cmake/private/FairRootConfigVersion.cmake.in b/cmake/private/FairRootConfigVersion.cmake.in deleted file mode 100644 index d459eaba31..0000000000 --- a/cmake/private/FairRootConfigVersion.cmake.in +++ /dev/null @@ -1,3 +0,0 @@ - -set(@PROJECT_NAME@_VERSION "@PROJECT_VERSION@") - diff --git a/cmake/private/FairRootPackage.cmake b/cmake/private/FairRootPackage.cmake index f8c3f2085f..76b70f6f69 100644 --- a/cmake/private/FairRootPackage.cmake +++ b/cmake/private/FairRootPackage.cmake @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -10,6 +10,13 @@ include(CMakePackageConfigHelpers) # Configure/Install CMake package function(install_cmake_package) + if(FairCMakeModules_VERSION VERSION_GREATER_EQUAL 1.0.0) + # FairCMakeModules 1.0.0 needed for OPTIONAL_COMPONENTS exporting + fair_generate_package_dependencies() + else() + set(PACKAGE_DEPENDENCIES "# Not supported") + endif() + set(PACKAGE_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}) if(PROJECT_EXPORT_SET) diff --git a/cmake/private/FairRootSummary.cmake b/cmake/private/FairRootSummary.cmake index d480c997c1..a53f94d98f 100644 --- a/cmake/private/FairRootSummary.cmake +++ b/cmake/private/FairRootSummary.cmake @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -30,49 +30,13 @@ function(fairroot_summary_install_prefix) set(dirval "") endif() if(dirval) - pad("${dirtype}" 11 " " type_padded) + fair_pad("${dirtype}" 12 " " type_padded) message(VERBOSE " ${type_padded} ${dirval}") endif() endforeach() endfunction() -function(fairroot_summary_global_cxx_flags_standard) - if(CMAKE_CXX_FLAGS OR CMAKE_CXX_STANDARD) - message(STATUS " ") - endif() - if(CMAKE_CXX_FLAGS) - message(STATUS " ${Cyan}GLOBAL CXX FLAGS${CR} ${BGreen}${CMAKE_CXX_FLAGS}${CR}") - endif() - if(CMAKE_CXX_STANDARD) - message(STATUS " ${Cyan}GLOBAL CXX STANDARD${CR} ${BGreen}c++${CMAKE_CXX_STANDARD}${CR}") - endif() -endfunction() - - -function(fairroot_summary_build_types) - if(CMAKE_CONFIGURATION_TYPES) - message(STATUS " ") - message(STATUS " ${Cyan}BUILD TYPE CXX FLAGS${CR}") - string(TOUPPER "${CMAKE_BUILD_TYPE}" selected_type) - foreach(type IN LISTS CMAKE_CONFIGURATION_TYPES) - string(TOUPPER "${type}" type_upper) - if(type_upper STREQUAL selected_type) - pad("${type}" 20 " " type_padded) - message(STATUS "${BGreen}* ${type_padded}${CMAKE_CXX_FLAGS_${type_upper}}${CR}") - else() - pad("${type}" 20 " " type_padded) - message(STATUS " ${BWhite}${type_padded}${CR}${CMAKE_CXX_FLAGS_${type_upper}}") - endif() - unset(type_padded) - unset(type_upper) - endforeach() - message(STATUS " ") - message(STATUS " (Change the build type with ${BMagenta}-DCMAKE_BUILD_TYPE=...${CR})") - endif() -endfunction() - - function(fairroot_summary_package_dependencies) if(PROJECT_PACKAGE_DEPENDENCIES) message(STATUS " ") @@ -100,12 +64,8 @@ function(fairroot_summary_package_dependencies) if(PROJECT_${dep}_VERSION) set(version_req_str " (>= ${PROJECT_${dep}_VERSION})") endif() - pad(${dep} 20 " " dep_padded) - if(DISABLE_COLOR) - pad("${version_str}${version_req_str}" 25 " " version_padded) - else() - pad("${version_str}${version_req_str}" 25 " " version_padded COLOR 1) - endif() + fair_pad(${dep} 21 " " dep_padded) + fair_pad("${version_str}${version_req_str}" 26 " " version_padded COLOR) set(prefix ${${dep}_PREFIX}) if(${dep} STREQUAL Boost) if(TARGET Boost::headers) @@ -116,9 +76,6 @@ function(fairroot_summary_package_dependencies) get_filename_component(prefix ${boost_include}/.. ABSOLUTE) elseif(${dep} STREQUAL Protobuf) get_filename_component(prefix ${Protobuf_INCLUDE_DIRS}/.. ABSOLUTE) - elseif(${dep} STREQUAL msgpack) - get_target_property(msgpack_include msgpackc INTERFACE_INCLUDE_DIRECTORIES) - get_filename_component(prefix ${msgpack_include}/.. ABSOLUTE) elseif(${dep} STREQUAL Pythia6) get_filename_component(prefix ${PYTHIA6_LIBRARY_DIR}/.. ABSOLUTE) elseif(${dep} STREQUAL FairLogger) @@ -181,7 +138,7 @@ function(fairroot_summary_package_dependencies) endif() if(${dep} STREQUAL Geant4) foreach(dataset IN LISTS Geant4_DATASETS) - pad(${Geant4_DATASET_${dataset}_ENVVAR} 20 " " envvar_padded LEFT) + fair_pad(${Geant4_DATASET_${dataset}_ENVVAR} 21 " " envvar_padded LEFT) message(STATUS " ${envvar_padded}: ${Geant4_DATASET_${dataset}_PATH}") endforeach() endif() @@ -211,11 +168,4 @@ function(fairroot_summary_components) set(doxygen_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_DOXYGEN=ON${CR})") endif() message(STATUS " ${BWhite}Doxygen${CR} ${doxygen_summary}") - - if(BUILD_UNITTESTS) - set(unittests_summary "${BGreen} YES${CR} (disable with ${BMagenta}-DBUILD_UNITTESTS=OFF${CR})") - else() - set(unittests_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_UNITTESTS=ON${CR})") - endif() - message(STATUS " ${BWhite}Unit tests${CR} ${unittests_summary}") endfunction() diff --git a/cmake/private/FairRootTargets.cmake b/cmake/private/FairRootTargets.cmake index 1052af28e8..27da721d4b 100644 --- a/cmake/private/FairRootTargets.cmake +++ b/cmake/private/FairRootTargets.cmake @@ -1,11 +1,12 @@ ################################################################################ -# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2021-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # # copied verbatim in the file "LICENSE" # ################################################################################ +include_guard(GLOBAL) # Set the C++ language level on exported targets # @@ -52,3 +53,59 @@ function(fairroot_install_exported) ARCHIVE DESTINATION ${PROJECT_INSTALL_LIBDIR} LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}) endfunction() + + +function(fairroot_discover_catch2_tests target) + cmake_parse_arguments(PARSE_ARGV 1 ARGS "ENABLE_LD_LIBRARY_PATH_WORKAROUND" "SUITE" "") + + set(test_prefix "") + if(ARGS_SUITE) + set(test_prefix "${ARGS_SUITE}::") + endif() + + set(dl_paths "") + set(req_version 3.22) + if(ARGS_ENABLE_LD_LIBRARY_PATH_WORKAROUND) + set(dl_paths ${LD_LIBRARY_PATH}) + endif() + + if(dl_paths) + if(CMAKE_VERSION VERSION_GREATER_EQUAL ${req_version}) + catch_discover_tests(${target} TEST_PREFIX "${test_prefix}" DL_PATHS ${dl_paths}) + else() + message(VERBOSE "Skipping tests discovery for target \"${target}\" " + "because CMake ${req_version} is required " + "(current: ${CMAKE_VERSION}).") + endif() + else() + catch_discover_tests(${target} TEST_PREFIX "${test_prefix}") + endif() +endfunction() + + +function(fairroot_add_catch2_test_suite suite) + cmake_parse_arguments(PARSE_ARGV 1 ARGS + "ENABLE_LD_LIBRARY_PATH_WORKAROUND" "" "SOURCES;DEPENDENCIES") + + if(NOT suite) + message(AUTHOR_WARNING "First positional parameter required. Skipping.") + return() + endif() + if(NOT ARGS_SOURCES) + message(AUTHOR_WARNING "Parameter SOURCES required. Skipping.") + return() + endif() + + set(exe "test_${suite}") + add_executable(${exe}) + target_sources(${exe} PRIVATE ${ARGS_SOURCES}) + target_link_libraries(${exe} PRIVATE Catch2::Catch2WithMain) + if(ARGS_DEPENDENCIES) + target_link_libraries(${exe} PRIVATE ${ARGS_DEPENDENCIES}) + endif() + if(ARGS_ENABLE_LD_LIBRARY_PATH_WORKAROUND) + fairroot_discover_catch2_tests(${exe} SUITE ${suite} ENABLE_LD_LIBRARY_PATH_WORKAROUND) + else() + fairroot_discover_catch2_tests(${exe} SUITE ${suite}) + endif() +endfunction() diff --git a/cmake/private/Testlib.cmake b/cmake/private/Testlib.cmake index 8aed7bbfff..d2d7b160b0 100644 --- a/cmake/private/Testlib.cmake +++ b/cmake/private/Testlib.cmake @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2020-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -9,8 +9,12 @@ macro(fairroot_ctest_setup) cmake_host_system_information(RESULT fqdn QUERY FQDN) - set(CTEST_SOURCE_DIRECTORY .) - set(CTEST_BINARY_DIRECTORY build) + if(NOT CTEST_SOURCE_DIRECTORY) + set(CTEST_SOURCE_DIRECTORY .) + endif() + if(NOT CTEST_BINARY_DIRECTORY) + set(CTEST_BINARY_DIRECTORY build) + endif() set(CTEST_PROJECT_NAME "FairRoot") set(CTEST_CMAKE_GENERATOR "Unix Makefiles") set(CTEST_USE_LAUNCHERS ON) @@ -22,6 +26,51 @@ macro(fairroot_ctest_setup) endif() endmacro() +macro(get_NCPUS) + if(NOT NCPUS) + if(DEFINED ENV{SLURM_CPUS_PER_TASK}) + set(NCPUS $ENV{SLURM_CPUS_PER_TASK}) + set(NCPUS_SOURCE "SLURM_CPUS_PER_TASK") + elseif(DEFINED ENV{SLURM_JOB_CPUS_PER_NODE}) + set(NCPUS $ENV{SLURM_JOB_CPUS_PER_NODE}) + set(NCPUS_SOURCE "SLURM_JOB_CPUS_PER_NODE") + else() + include(ProcessorCount) + ProcessorCount(NCPUS) + if(NCPUS EQUAL 0) + set(NCPUS 1) + endif() + set(NCPUS_SOURCE "ProcessorCount()") + endif() + else() + set(NCPUS_SOURCE "Already-Set") + endif() + message(STATUS " NCPUS ................: ${NCPUS} (from ${NCPUS_SOURCE})") +endmacro() + +macro(get_os_name_release) + find_program(LSB_RELEASE_EXEC lsb_release) + if(NOT LSB_RELEASE_EXEC) + # message(WARNING "lsb_release not found") + cmake_host_system_information(RESULT os_name QUERY OS_NAME) + cmake_host_system_information(RESULT os_release QUERY OS_RELEASE) + else() + execute_process(COMMAND ${LSB_RELEASE_EXEC} -si + OUTPUT_VARIABLE os_name + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LSB_RELEASE_EXEC} -sr + OUTPUT_VARIABLE os_release + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${LSB_RELEASE_EXEC} -sd + OUTPUT_VARIABLE os_description + OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + if(NOT os_description) + set(os_description "${os_name}-${os_release}") + endif() + message(STATUS " OS Description .......: ${os_description}") +endmacro() + macro(show_jenkins_info) if(DEFINED ENV{CHANGE_URL}) message(STATUS " Pull / Merge Request .: $ENV{CHANGE_URL}") diff --git a/cmake/scripts/CMakeLists.txt_roc b/cmake/scripts/CMakeLists.txt_roc index 65a32f5384..74109b7cab 100644 --- a/cmake/scripts/CMakeLists.txt_roc +++ b/cmake/scripts/CMakeLists.txt_roc @@ -28,7 +28,7 @@ EndIf(CMAKE_SYSTEM_NAME MATCHES Darwin) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRoc.so COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} - ROOTSYS=${ROOTSYS} make roclib + make roclib WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/patch_okay ) @@ -43,7 +43,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcRoc.so ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcMbs.so ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRocDict.rootmap COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} - ROOTSYS=${ROOTSYS} make rocdict + make rocdict WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcBase.so ) diff --git a/cmake/scripts/FairVersion.h.tmp b/cmake/scripts/FairVersion.h.tmp deleted file mode 100644 index f5944de092..0000000000 --- a/cmake/scripts/FairVersion.h.tmp +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef FAIRROOT_VERSION -#define FAIRROOT_VERSION "@PROJECT_GIT_VERSION@" -#define FAIRROOT_GIT_DATE "@PROJECT_GIT_DATE@" -#endif - diff --git a/cmake/scripts/config.csh.in b/cmake/scripts/config.csh.in index aea856b85e..4d0a8502e2 100644 --- a/cmake/scripts/config.csh.in +++ b/cmake/scripts/config.csh.in @@ -5,7 +5,6 @@ setenv System_ "@_system@" . @_EXECDIR@/check_system.csh if ( "$same_system" == "1" ) then setenv SIMPATH "@SIMPATH@" - setenv ROOTSYS "@ROOTSYS@" setenv FAIRROOTPATH "@FAIRROOTPATH@" if ( @FULL_CONFIG_FILE@ == true ) then setenv Geant4_INCLUDE_DIRS "@Geant4_INCLUDE_DIRS@" @@ -25,7 +24,6 @@ if ( "$same_system" == "1" ) then setenv Geant3_INCLUDE_DIRS "@Geant3_INCLUDE_DIRS@" setenv ROOT_LIBRARY_DIR "@ROOT_LIBRARY_DIR@" setenv ROOT_LIBRARIES "@ROOT_LIBRARIES@" - setenv ROOT_INCLUDE_DIR "@ROOT_INCLUDE_DIR@" setenv ROOT_INCLUDE_PATH "@Geant3_INCLUDE_DIRS@:@ROOT_INCLUDE_PATH@" setenv VMCWORKDIR "@VMCWORKDIR@" setenv FAIRLIBDIR "@FAIRLIBDIR@" diff --git a/cmake/scripts/config.sh.in b/cmake/scripts/config.sh.in index c5e135a93d..5990528635 100644 --- a/cmake/scripts/config.sh.in +++ b/cmake/scripts/config.sh.in @@ -5,7 +5,6 @@ export System_="@_system@" . @_EXECDIR@/check_system.sh if [ $same_system -eq 1 ]; then export SIMPATH="@SIMPATH@" - export ROOTSYS="@ROOTSYS@" export FAIRROOTPATH="@FAIRROOTPATH@" if (@FULL_CONFIG_FILE@); then export Geant4_INCLUDE_DIRS="@Geant4_INCLUDE_DIRS@" @@ -24,7 +23,6 @@ if [ $same_system -eq 1 ]; then export Geant3_INCLUDE_DIRS="@Geant3_INCLUDE_DIRS@" export ROOT_LIBRARY_DIR="@ROOT_LIBRARY_DIR@" export ROOT_LIBRARIES="@ROOT_LIBRARIES@" - export ROOT_INCLUDE_DIR="@ROOT_INCLUDE_DIR@" export ROOT_INCLUDE_PATH="@Geant3_INCLUDE_DIRS@:@ROOT_INCLUDE_PATH@" export VMCWORKDIR="@VMCWORKDIR@" export FAIRLIBDIR="@FAIRLIBDIR@" diff --git a/cmake/scripts/generate_dictionary_root.sh.in b/cmake/scripts/generate_dictionary_root.sh.in index 679a2b668f..699a17751b 100755 --- a/cmake/scripts/generate_dictionary_root.sh.in +++ b/cmake/scripts/generate_dictionary_root.sh.in @@ -9,6 +9,5 @@ # Setup the needed environment export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@ export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@ -export ROOTSYS=@ROOTSYS@ @ROOT_CINT_EXECUTABLE@ -f @Int_DICTIONARY@ @EXTRA_DICT_PARAMETERS_STR@ -c @Int_DEF_STR@ @Int_INC_STR@ @Int_HDRS_STR@ @Int_LINKDEF@ diff --git a/cmake/scripts/root_macro.sh.in b/cmake/scripts/root_macro.sh.in index 535797a33b..1336a11c63 100644 --- a/cmake/scripts/root_macro.sh.in +++ b/cmake/scripts/root_macro.sh.in @@ -11,7 +11,6 @@ export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@:$DYLD_LIBRARY_PATH export PATH=@SIMPATH@/bin:$PATH:@Geant4_DIR@ -export ROOTSYS=@ROOTSYS@ export ROOTEXE=@ROOT_EXECUTABLE@ export ROOT_INCLUDE_PATH=@Geant3_INCLUDE_DIRS@:@MY_ROOT_INCLUDE_PATH@ export FAIRROOTPATH="@FAIRROOTPATH@" diff --git a/cmake/scripts/run_binary.sh.in b/cmake/scripts/run_binary.sh.in index 5dfb8eca7e..492d274449 100644 --- a/cmake/scripts/run_binary.sh.in +++ b/cmake/scripts/run_binary.sh.in @@ -1,11 +1,9 @@ #!/bin/bash #export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@ -#export ROOTSYS=@ROOTSYS@ export VMCWORKDIR=@VMCWORKDIR@ export Geant4VMC_MACRO_DIR=@Geant4VMC_MACRO_DIR@ export USE_VGM=1 -#export PATH=@ROOTSYS@/bin:$PATH #export GEANT4_LIBRARY_DIR=@GEANT4_LIBRARY_DIR@ #export Geant4_INCLUDE_DIRS=@Geant4_INCLUDE_DIRS@ diff --git a/cmake/scripts/set_env.sh.in b/cmake/scripts/set_env.sh.in index 6a7e742abd..0b443838f6 100644 --- a/cmake/scripts/set_env.sh.in +++ b/cmake/scripts/set_env.sh.in @@ -4,7 +4,6 @@ export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@:$LD_LIBRARY_PATH export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@:$DYLD_LIBRARY_PATH export PATH=@SIMPATH@/bin:$PATH:@Geant4_DIR@ -export ROOTSYS=@ROOTSYS@ export ROOTEXE=@ROOT_EXECUTABLE@ export ROOT_INCLUDE_PATH="@Geant3_INCLUDE_DIRS@:@MY_ROOT_INCLUDE_PATH@" export VMCWORKDIR=@VMCWORKDIR@ diff --git a/codemeta.json b/codemeta.json index 6737b23fcc..3fbcd40469 100644 --- a/codemeta.json +++ b/codemeta.json @@ -4,7 +4,7 @@ "name": "FairRoot", "description": "

A simulation, reconstruction and analysis framework that is based on the ROOT system. The user can create simulated data and/or perform analysis with the same framework. Geant3 and Geant4 transport engines are supported, however the user code that creates simulated data do not depend on a particular monte carlo engine. The framework delivers base classes which enable the users to construct their detectors and /or analysis tasks in a simple way, it also delivers some general functionality like track visualization. Moreover an interface for reading magnetic field maps is also implemented.

", "license": "https://spdx.org/licenses/LGPL-3.0-only", - "softwareVersion": "18.8.2", + "softwareVersion": "19.0.0", "datePublished": "2012-05-25", "keywords": [ "geant4", diff --git a/doxygen/doxyfile.in b/doxygen/doxyfile.in index c2b851441d..88275d392d 100644 --- a/doxygen/doxyfile.in +++ b/doxygen/doxyfile.in @@ -5,7 +5,7 @@ #--------------------------------------------------------------------------- DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = @DOXYGEN_PROJECT_NAME@ -PROJECT_NUMBER = @PROJECT_VERSION@ +PROJECT_NUMBER = @PROJECT_VERSION@ (@PROJECT_GIT_VERSION@) PROJECT_BRIEF = PROJECT_LOGO = OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@/doc" @@ -97,15 +97,19 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = "@CMAKE_SOURCE_DIR@" +INPUT = "@CMAKE_SOURCE_DIR@/README.md" \ + "@CMAKE_SOURCE_DIR@/CHANGELOG.md" \ + "@CMAKE_SOURCE_DIR@/CONTRIBUTING.md" \ + "@CMAKE_SOURCE_DIR@/cmake" \ + "@CMAKE_SOURCE_DIR@/doxygen" \ + "@CMAKE_SOURCE_DIR@/examples" \ + "@CMAKE_SOURCE_DIR@/fairroot" \ + "@CMAKE_SOURCE_DIR@/templates" \ + "@CMAKE_SOURCE_DIR@/tests" INPUT_ENCODING = UTF-8 FILE_PATTERNS = RECURSIVE = YES -EXCLUDE = .git/ \ - build/ xbuild \ - build-dir/ \ - html-docs/ \ - doxygen cmake config gconfig geometry input parameters .svn vis +EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = diff --git a/doxygen/singleton.dox b/doxygen/singleton.dox new file mode 100644 index 0000000000..6190bb547c --- /dev/null +++ b/doxygen/singleton.dox @@ -0,0 +1,33 @@ +/** + * \weakgroup fairroot_singleton FairRoot/ROOT Style "singleton"-like Objects + +These classes are currently using a singleton-like pattern that is +NOT [the classic textbook pattern](https://en.wikipedia.org/wiki/Singleton_pattern). + +This pattern is discouraged for new code! +Also the existing code utilising it is slowly getting deprecated +in favour of code not relying on singleton like behaviour. + +Attributes / Design: + +- There can only be one or zero instances per process (or thread for some). + Note that zero is explicitly allowed. + + Some classes enforce this at runtime, some don't. + +- Global access via the static `::Instance()` function on the class + returns a pointer to that object or `nullptr` if the instance does + not exist. It DOES NOT lazily create the "singleton" instance (see + also below). + + Note: This function is likely getting deprecated in the process + of getting away from this behaviour. + +- Other code is responsible for creating (thus owning) and + destructing the object. The object can be created on the stack, + on the heap or even as a member variable of another class + (constructors are public). That code can either be internal + FairRoot code or code by the user (like with the \ref FairRun + classes). + + */ diff --git a/examples/MQ/Lmd/CMakeLists.txt b/examples/MQ/Lmd/CMakeLists.txt index d73259b174..d0620500e5 100644 --- a/examples/MQ/Lmd/CMakeLists.txt +++ b/examples/MQ/Lmd/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -25,11 +25,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Online diff --git a/examples/MQ/Lmd/FairMBSUnpacker.cxx b/examples/MQ/Lmd/FairMBSUnpacker.cxx index 88d973463b..43b8d24a91 100644 --- a/examples/MQ/Lmd/FairMBSUnpacker.cxx +++ b/examples/MQ/Lmd/FairMBSUnpacker.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -101,5 +101,3 @@ void FairMBSUnpacker::Reset() fRawData->Clear(); fNHits = 0; } - -ClassImp(FairMBSUnpacker); diff --git a/examples/MQ/Lmd/runMBSSink.cxx b/examples/MQ/Lmd/runMBSSink.cxx index b9a93461a6..2cf873e9ea 100644 --- a/examples/MQ/Lmd/runMBSSink.cxx +++ b/examples/MQ/Lmd/runMBSSink.cxx @@ -1,53 +1,91 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include "BaseMQFileSink.h" -#include "FairMBSRawItem.h" // data type for the OutputPolicy +// this example +#include "FairMBSRawItem.h" // data type + +// FairRoot +#include "FairMQ.h" // for fair::mq::Device #include "FairRunFairMQDevice.h" -#include "IOPolicy.h" // fair::mq::policy:: -#include "RootOutFileManager.h" // OutputPolicy -#include "RootSerializer.h" // RootSerializer +#include "RootSerializer.h" // RootSerializer + +// ROOT +#include +#include +#include -#include // data type for the InputPolicy +// logger +#include -// InputPolicy - initialize input and deserialize message into it -using RootDefaultInputPolicy = - fair::mq::policy::InputPolicy; // input deleter +// std +#include +#include namespace bpo = boost::program_options; +struct MBSSink : fair::mq::Device +{ + MBSSink() + : fInput(nullptr) + , fTree("mbstree", "Test output") + {} + + void InitTask() override + { + fInputChanName = fConfig->GetValue("in-chan-name"); + fFileName = fConfig->GetValue("output-file-name"); + fOutputFile.reset(TFile::Open(fFileName.c_str(), "RECREATE")); + fInput = new TClonesArray("FairMBSRawItem"); + fTree.Branch("FairMBSRawItem", "TClonesArray", &fInput); + } + + void Run() override + { + int receivedMsg = 0; + while (!NewStatePending()) { + auto msg(NewMessage()); + if (Receive(msg, fInputChanName) > 0) { + RootSerializer().Deserialize(*msg, fInput); + fTree.SetBranchAddress("FairMBSRawItem", &fInput); + fTree.Fill(); + ++receivedMsg; + } + } + + LOG(info) << "Received " << receivedMsg << " messages!"; + } + + void Reset() override + { + fTree.Write("", TObject::kOverwrite); + if (fInput) { + delete fInput; + } + } + + private: + std::string fInputChanName; + std::string fFileName; + std::unique_ptr fOutputFile; + TClonesArray* fInput; + TTree fTree; +}; + void addCustomOptions(bpo::options_description& options) { // clang-format off options.add_options() - ("output-file-name", bpo::value(), "Path to the input file") - ("output-file-tree", bpo::value()->default_value("mbstree"), "Name of the output tree") - ("output-file-branch", bpo::value()->default_value("FairMBSRawItem"), "Name of the output Branch") - ("hit-classname", bpo::value()->default_value("FairMBSRawItem"), "Hit class name for initializing TClonesArray") - ("output-file-option", bpo::value()->default_value("RECREATE"), "Root file option : UPDATE, RECREATE etc.") - ("use-clones-array", bpo::value()->default_value(true), "Use TClonesArray") - ("flow-mode", bpo::value()->default_value(true), "Flow mode") - ("in-chan-name", bpo::value()->default_value("data"), "input channel name"); + ("output-file-name", bpo::value(), "Path to the output file") + ("in-chan-name", bpo::value()->default_value("data"), "Input channel name"); // clang-format on } std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) { - using Sink = BaseMQFileSink>; - auto sink = std::make_unique(); - - // call function member from deserialization policy - sink->InitInputData(config.GetValue("hit-classname").c_str()); - - return sink; + return std::make_unique(); } diff --git a/examples/MQ/histogramServer/CMakeLists.txt b/examples/MQ/histogramServer/CMakeLists.txt index 7aa72454cc..e57b8c0f66 100644 --- a/examples/MQ/histogramServer/CMakeLists.txt +++ b/examples/MQ/histogramServer/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -26,11 +26,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::FairMQ diff --git a/examples/MQ/histogramServer/FairMQExHistoDevice.cxx b/examples/MQ/histogramServer/FairMQExHistoDevice.cxx index d4a2d885d0..37629029a1 100644 --- a/examples/MQ/histogramServer/FairMQExHistoDevice.cxx +++ b/examples/MQ/histogramServer/FairMQExHistoDevice.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,6 +8,7 @@ #include "FairMQExHistoDevice.h" +#include "FairMQ.h" #include "RootSerializer.h" #include @@ -55,7 +56,7 @@ bool FairMQExHistoDevice::ConditionalRun() auto message(NewMessage()); RootSerializer().Serialize(*message, &fArrayHisto); - for (auto& channel : fChannels) { + for (auto& channel : fairroot::GetFairMQDeviceChannels(*this)) { Send(message, channel.first); } diff --git a/examples/MQ/parameters/CMakeLists.txt b/examples/MQ/parameters/CMakeLists.txt index 42c0dcf10a..da00c106a8 100644 --- a/examples/MQ/parameters/CMakeLists.txt +++ b/examples/MQ/parameters/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -29,11 +29,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator FairRoot::BaseMQ # Serialization policies diff --git a/examples/MQ/parameters/FairMQExParamsContFact.cxx b/examples/MQ/parameters/FairMQExParamsContFact.cxx index b83e1ecdcb..bbc63f56e4 100644 --- a/examples/MQ/parameters/FairMQExParamsContFact.cxx +++ b/examples/MQ/parameters/FairMQExParamsContFact.cxx @@ -32,5 +32,3 @@ FairParSet* FairMQExParamsContFact::createContainer(FairContainer* container) return p; } - -ClassImp(FairMQExParamsContFact); diff --git a/examples/MQ/parameters/FairMQExParamsContFact.h b/examples/MQ/parameters/FairMQExParamsContFact.h index ccbcb51340..5b6d45ff3a 100644 --- a/examples/MQ/parameters/FairMQExParamsContFact.h +++ b/examples/MQ/parameters/FairMQExParamsContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,9 +10,6 @@ #include "FairContFact.h" -class FairContainer; -class FairParSet; - class FairMQExParamsContFact : public FairContFact { public: diff --git a/examples/MQ/parameters/FairMQExParamsParOne.cxx b/examples/MQ/parameters/FairMQExParamsParOne.cxx index 2bfee9b459..c7193eebf6 100644 --- a/examples/MQ/parameters/FairMQExParamsParOne.cxx +++ b/examples/MQ/parameters/FairMQExParamsParOne.cxx @@ -1,16 +1,16 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ - #include "FairMQExParamsParOne.h" - #include // for TGenericClassInfo - #include // for TString - #include // for LOG, Logger - #include "FairParamList.h" // for FairParamList +#include "FairMQExParamsParOne.h" +#include "FairParamList.h" // for FairParamList + +#include // for TString +#include // for LOG, Logger FairMQExParamsParOne::FairMQExParamsParOne(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) @@ -19,17 +19,9 @@ FairMQExParamsParOne::FairMQExParamsParOne(const char* name, const char* title, detName = "TutorialDet"; } -FairMQExParamsParOne::~FairMQExParamsParOne() { clear(); } - -void FairMQExParamsParOne::clear() -{ - status = kFALSE; - resetInputVersions(); -} - void FairMQExParamsParOne::print() { - LOG(info) << "Print"; + FairParGenericSet::print(); LOG(info) << "fParameterValue: " << fParameterValue; } @@ -58,5 +50,3 @@ Bool_t FairMQExParamsParOne::getParams(FairParamList* list) return kTRUE; } - -ClassImp(FairMQExParamsParOne); diff --git a/examples/MQ/parameters/FairMQExParamsParOne.h b/examples/MQ/parameters/FairMQExParamsParOne.h index b4719c41a1..31f1816504 100644 --- a/examples/MQ/parameters/FairMQExParamsParOne.h +++ b/examples/MQ/parameters/FairMQExParamsParOne.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,14 +8,7 @@ #ifndef FAIRMQEXPARAMSPARONE_H_ #define FAIRMQEXPARAMSPARONE_H_ -#include // for THashConsistencyHolder, ClassDef -#include // for Int_t, Bool_t -#include "FairParGenericSet.h" // for FairParGenericSet -class FairParamList; // lines 15-15 -class TBuffer; -class TClass; -class TMemberInspector; - +#include "FairParGenericSet.h" class FairMQExParamsParOne : public FairParGenericSet { @@ -26,13 +19,10 @@ class FairMQExParamsParOne : public FairParGenericSet const char* context = "Default"); /** Destructor **/ - ~FairMQExParamsParOne() override; + ~FairMQExParamsParOne() override = default; void print() override; - /** Reset all parameters **/ - void clear() override; - void putParams(FairParamList* list) override; Bool_t getParams(FairParamList* list) override; diff --git a/examples/MQ/pixelAlternative/src/CMakeLists.txt b/examples/MQ/pixelAlternative/src/CMakeLists.txt index 4b8927289a..976d2bcf26 100644 --- a/examples/MQ/pixelAlternative/src/CMakeLists.txt +++ b/examples/MQ/pixelAlternative/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -36,11 +36,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/MQ/pixelAlternative/src/PixelAltDigiWriteToRootVector.cxx b/examples/MQ/pixelAlternative/src/PixelAltDigiWriteToRootVector.cxx index 82c3132625..60d3476321 100644 --- a/examples/MQ/pixelAlternative/src/PixelAltDigiWriteToRootVector.cxx +++ b/examples/MQ/pixelAlternative/src/PixelAltDigiWriteToRootVector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -172,5 +172,3 @@ void PixelAltDigiWriteToRootVector::Finish() fOutputRootFile[ifile]->Close(); } } - -ClassImp(PixelAltDigiWriteToRootVector); diff --git a/examples/MQ/pixelAlternative/src/PixelAltFindHits.cxx b/examples/MQ/pixelAlternative/src/PixelAltFindHits.cxx index 4a77c5cc63..00e6301dfe 100644 --- a/examples/MQ/pixelAlternative/src/PixelAltFindHits.cxx +++ b/examples/MQ/pixelAlternative/src/PixelAltFindHits.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -183,14 +183,15 @@ void PixelAltFindHits::GetParList(TList* tempList) { fDigiPar = new PixelDigiPar("PixelDigiParameters"); tempList->Add(fDigiPar); - - return; } void PixelAltFindHits::InitMQ(TList* tempList) { LOG(info) << "********************************************** PixelAltFindHits::InitMQ()"; - fDigiPar = (PixelDigiPar*)tempList->FindObject("PixelDigiParameters"); + fDigiPar = dynamic_cast(tempList->FindObject("PixelDigiParameters")); + if (!fDigiPar) { + throw std::runtime_error("no PixelDigiParameters"); + } fFeCols = fDigiPar->GetFECols(); fFeRows = fDigiPar->GetFERows(); @@ -205,8 +206,6 @@ void PixelAltFindHits::InitMQ(TList* tempList) LOG(info) << ">> fPitchY = " << fPitchY; fHits = new TClonesArray("PixelHit", 10000); - - return; } void PixelAltFindHits::ExecMQ(TList* inputList, TList* outputList) @@ -215,10 +214,15 @@ void PixelAltFindHits::ExecMQ(TList* inputList, TList* outputList) // << "," << outputList->GetName() << "), Event " << fTNofEvents; LOG(info) << // "********************************************** PixelAltFindHits::ExecMQ(), Event " << fTNofEvents; LOG(info) << // "h" << FairLogger::flush; - fDigis = (TClonesArray*)inputList->FindObject("PixelDigis"); + fDigis = dynamic_cast(inputList->FindObject("PixelDigis")); + if (!fDigis) { + throw std::runtime_error("no PixelDigis"); + } + if (!fDigis->GetClass()->InheritsFrom(PixelDigi::Class())) { + throw std::runtime_error("wrong type in PixelDigis TCA"); + } outputList->Add(fHits); Exec(""); - return; } void PixelAltFindHits::ExecMQ(PixelPayload::Digi* digiPalVector, @@ -241,7 +245,6 @@ void PixelAltFindHits::ExecMQ(PixelPayload::Digi* digiPalVector, hitPalVector[idigi].fDetectorID = digiPalVector[idigi].fDetectorID; nofHits++; } - return; } InitStatus PixelAltFindHits::Init() @@ -296,5 +299,3 @@ void PixelAltFindHits::Finish() << static_cast(fTNofHits) / (static_cast(fTNofEvents)) << " per event)"; LOG(info) << "---------------------------------------------------------------------"; } - -ClassImp(PixelAltFindHits); diff --git a/examples/MQ/pixelAlternative/src/devices/FairMQPixAltTaskProcessorBin.h b/examples/MQ/pixelAlternative/src/devices/FairMQPixAltTaskProcessorBin.h index f986abfd51..616b96bed3 100644 --- a/examples/MQ/pixelAlternative/src/devices/FairMQPixAltTaskProcessorBin.h +++ b/examples/MQ/pixelAlternative/src/devices/FairMQPixAltTaskProcessorBin.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -72,7 +72,7 @@ class FairMQPixAltTaskProcessorBin : public fair::mq::Device // creating output multipart message fair::mq::Parts partsOut; - for (int ievent = 0; ievent < parts.Size() / nPPE; ievent++) { + for (decltype(parts.Size()) ievent = 0; ievent < parts.Size() / nPPE; ievent++) { // the first part should be the event header PixelPayload::EventHeader* payloadE = static_cast(parts.At(nPPE * ievent)->GetData()); diff --git a/examples/MQ/pixelDetector/README.md b/examples/MQ/pixelDetector/README.md index 200f80fd58..7f993be966 100644 --- a/examples/MQ/pixelDetector/README.md +++ b/examples/MQ/pixelDetector/README.md @@ -14,10 +14,10 @@ The following MQ devices are implemented: - FairMQPixelSampler - reads data branch names specified by AddInputBranchName(string) from the input file(s) set by AddInputFileName(string) via FairSource. Currently one may attach FairFileSource (chains of ROOT files), PixelDigiSource (ascii files with PixelDigis) or PixelDigiBinSource (binary files with PixelDigis); -- template FairMQPixelTaskProcessor - runs a task of class T. The class T needs to have the following functions: -void GetParList (TList* parList); - used to get the list of parameter objects needed by class T; -void InitMQ (TList* parList); - initialization of the class T object using the parameters; -void ExecMQ (TList* inputList, TList* outputList); - analyze data from inputList and store the result in outputList; +- `template FairMQPixelTaskProcessor` - runs a task of class T. The class T needs to have the following functions: + `void GetParList (TList* parList);` - used to get the list of parameter objects needed by class T; + `void InitMQ (TList* parList);` - initialization of the class T object using the parameters; + `void ExecMQ (TList* inputList, TList* outputList);` - analyze data from inputList and store the result in outputList; - FairMQPixelFileSink creates output ROOT file set by SetOutputFileName(string) and tree, with the branches specified by AddOutputBranch(string className, string branchName). Currently only two classes (FairEventHeader and TClonesArray of any objects) are allowed: fileSink.AddOutputBranch(“FairEventHeader”,”EventHeader.”); diff --git a/examples/MQ/pixelDetector/macros/CMakeLists.txt b/examples/MQ/pixelDetector/macros/CMakeLists.txt index 3903036d18..1b80d261ea 100644 --- a/examples/MQ/pixelDetector/macros/CMakeLists.txt +++ b/examples/MQ/pixelDetector/macros/CMakeLists.txt @@ -1,15 +1,24 @@ ################################################################################ -# Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # # copied verbatim in the file "LICENSE" # ################################################################################ +set(prefix ex_pixel) + GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_sim.C) GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_digi.C) GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_digiToBin.C) +# Try to compile the macros as normal files +add_library(${prefix}_check_compile OBJECT + run_dAsciiSource.C + run_dBinSource.C) +target_link_libraries(${prefix}_check_compile PRIVATE + FairRoot::ExPixel) + set(maxTestTime 30) add_test(NAME ex_pixel_sim_${pixel_simulation_engine} diff --git a/examples/MQ/pixelDetector/macros/run_dAsciiSource.C b/examples/MQ/pixelDetector/macros/run_dAsciiSource.C index a2e113d49d..74ee9b025b 100644 --- a/examples/MQ/pixelDetector/macros/run_dAsciiSource.C +++ b/examples/MQ/pixelDetector/macros/run_dAsciiSource.C @@ -1,15 +1,36 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#if !defined(__CLING__) || defined(__ROOTCLING__) +// Example includes +#include "PixelDigiSource.h" +#include "PixelEventHeader.h" +#include "PixelFindHits.h" + +// FairRoot includes +#include "FairParAsciiFileIo.h" +#include "FairParRootFileIo.h" +#include "FairRootFileSink.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "FairSystemInfo.h" +#endif + +#include +#include +#include +#include + +using std::cout; +using std::endl; + void run_dAsciiSource(TString mcEngine = "TGeant3") { - // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) - Int_t iVerbose = 0; // just forget about it, for the moment - // Parameter file TString parFile = "pixel_"; parFile = parFile + mcEngine + ".params.root"; @@ -26,19 +47,17 @@ void run_dAsciiSource(TString mcEngine = "TGeant3") // ----- Timer -------------------------------------------------------- TStopwatch timer; - PixelEventHeader* pixelEventHeader = new PixelEventHeader(); - // ----- Reconstruction run ------------------------------------------- - FairRunAna* fRun = new FairRunAna(); - fRun->SetEventHeader(pixelEventHeader); - fRun->SetSink(new FairRootFileSink(outFile)); + FairRunAna run{}; + run.SetEventHeader(std::make_unique()); + run.SetSink(std::make_unique(outFile)); PixelDigiSource* digiSource = new PixelDigiSource("Pixel Digi Source"); digiSource->SetInputFileName("digis.p0.dat"); - fRun->SetSource(digiSource); + run.SetSource(digiSource); - FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); @@ -50,15 +69,15 @@ void run_dAsciiSource(TString mcEngine = "TGeant3") // ----- TorinoDetector hit producers --------------------------------- // PixelDigiReadFromFile* digiRead = new PixelDigiReadFromFile(); - // fRun->AddTask(digiRead); + // run->AddTask(digiRead); - PixelFindHits* hitFinderTask = new PixelFindHits(); - fRun->AddTask(hitFinderTask); + auto hitFinderTask = std::make_unique(); + run.AddTask(std::move(hitFinderTask)); - fRun->Init(); + run.Init(); timer.Start(); - fRun->Run(); + run.Run(); // ----- Finish ------------------------------------------------------- diff --git a/examples/MQ/pixelDetector/macros/run_dBinSource.C b/examples/MQ/pixelDetector/macros/run_dBinSource.C index ff3b52ed20..151307ab65 100644 --- a/examples/MQ/pixelDetector/macros/run_dBinSource.C +++ b/examples/MQ/pixelDetector/macros/run_dBinSource.C @@ -1,15 +1,36 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#if !defined(__CLING__) || defined(__ROOTCLING__) +// Example includes +#include "PixelDigiBinSource.h" +#include "PixelEventHeader.h" +#include "PixelFindHits.h" + +// FairRoot includes +#include "FairParAsciiFileIo.h" +#include "FairParRootFileIo.h" +#include "FairRootFileSink.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "FairSystemInfo.h" +#endif + +#include +#include +#include +#include + +using std::cout; +using std::endl; + void run_dBinSource(TString mcEngine = "TGeant3") { - // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) - Int_t iVerbose = 0; // just forget about it, for the moment - // Parameter file TString parFile = "pixel_"; parFile = parFile + mcEngine + ".params.root"; @@ -26,19 +47,17 @@ void run_dBinSource(TString mcEngine = "TGeant3") // ----- Timer -------------------------------------------------------- TStopwatch timer; - PixelEventHeader* pixelEventHeader = new PixelEventHeader(); - // ----- Reconstruction run ------------------------------------------- - FairRunAna* fRun = new FairRunAna(); - fRun->SetEventHeader(pixelEventHeader); - fRun->SetSink(new FairRootFileSink(outFile)); + FairRunAna run{}; + run.SetEventHeader(std::make_unique()); + run.SetSink(std::make_unique(outFile)); PixelDigiBinSource* digiSource = new PixelDigiBinSource("Pixel Digi Source"); digiSource->SetInputFileName("digisBin.dat"); - fRun->SetSource(digiSource); + run.SetSource(digiSource); - FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); @@ -50,15 +69,15 @@ void run_dBinSource(TString mcEngine = "TGeant3") // ----- TorinoDetector hit producers --------------------------------- // PixelDigiReadFromFile* digiRead = new PixelDigiReadFromFile(); - // fRun->AddTask(digiRead); + // run->AddTask(digiRead); - PixelFindHits* hitFinderTask = new PixelFindHits(); - fRun->AddTask(hitFinderTask); + auto hitFinderTask = std::make_unique(); + run.AddTask(std::move(hitFinderTask)); - fRun->Init(); + run.Init(); timer.Start(); - fRun->Run(); + run.Run(); // ----- Finish ------------------------------------------------------- diff --git a/examples/MQ/pixelDetector/src/CMakeLists.txt b/examples/MQ/pixelDetector/src/CMakeLists.txt index 87f694f445..1239700848 100644 --- a/examples/MQ/pixelDetector/src/CMakeLists.txt +++ b/examples/MQ/pixelDetector/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -64,11 +64,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/MQ/pixelDetector/src/FairOnlineSink.cxx b/examples/MQ/pixelDetector/src/FairOnlineSink.cxx index 46e48c8686..08d19c9169 100644 --- a/examples/MQ/pixelDetector/src/FairOnlineSink.cxx +++ b/examples/MQ/pixelDetector/src/FairOnlineSink.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -19,18 +19,8 @@ #include -FairOnlineSink::FairOnlineSink() - : FairSink() - , fMQRunDevice(nullptr) -{} - -FairOnlineSink::FairOnlineSink(const FairOnlineSink&) - : FairSink() - , fMQRunDevice(nullptr) -{} - //_____________________________________________________________________________ -void FairOnlineSink::RegisterImpl(const char*, const char*, void*) { return; } +void FairOnlineSink::RegisterImpl(const char*, const char*, void*) {} //_____________________________________________________________________________ void FairOnlineSink::RegisterAny(const char* brname, const std::type_info& oi, const std::type_info& pi, void* obj) @@ -59,16 +49,16 @@ void FairOnlineSink::Fill() /// Fill the Root tree. LOG(debug) << "[" << FairRootManager::Instance()->GetInstanceId() << "] called FairOnlineSink::Fill()!!!!"; - if (fMQRunDevice) - fMQRunDevice->SendBranches(); + if (fMQRunDevice) { + fMQRunDevice->SendBranches(*this); + } } //_____________________________________________________________________________ FairSink* FairOnlineSink::CloneSink() { FairRootManager* tempMan = FairRootManager::Instance(); - FairOnlineSink* newSink = new FairOnlineSink(*this); - newSink->SetMQRunDevice(this->GetMQRunDevice()); + auto newSink = new FairOnlineSink(*this); LOG(info) << "[" << tempMan->GetInstanceId() << "] FairOnlineSink::CloneSink() setting MQRunDevice to " << this->GetMQRunDevice(); diff --git a/examples/MQ/pixelDetector/src/FairOnlineSink.h b/examples/MQ/pixelDetector/src/FairOnlineSink.h index 6df774c6fd..4f478f329f 100644 --- a/examples/MQ/pixelDetector/src/FairOnlineSink.h +++ b/examples/MQ/pixelDetector/src/FairOnlineSink.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -24,14 +24,13 @@ class FairEventHeader; class FairMQRunDevice; -class TObject; -class TTree; class FairOnlineSink : public FairSink { public: - FairOnlineSink(); + FairOnlineSink() = default; ~FairOnlineSink() override = default; + FairOnlineSink& operator=(const FairOnlineSink&) = delete; Bool_t InitSink() override { return kTRUE; } void Close() override {} @@ -41,7 +40,7 @@ class FairOnlineSink : public FairSink virtual void FillEventHeader(FairEventHeader* /* feh */) {} - void SetOutTree(TTree* /* fTree */) override { return; } + void SetOutTree(TTree* /* fTree */) override {} void Fill() override; @@ -70,13 +69,13 @@ class FairOnlineSink : public FairSink T GetPersistentBranchAny(const char* name) const; private: - FairMQRunDevice* fMQRunDevice; + FairMQRunDevice* fMQRunDevice{nullptr}; // private helper function to emit a warning void EmitPersistentBranchWrongTypeWarning(const char* brname, const char* typen1, const char* typen2) const; - FairOnlineSink(const FairOnlineSink&); - FairOnlineSink& operator=(const FairOnlineSink&); + /// internal helper function for CloneSink() + FairOnlineSink(const FairOnlineSink&) = default; }; // try to retrieve an object address from the registered branches/names @@ -88,7 +87,7 @@ T FairOnlineSink::GetPersistentBranchAny(const char* brname) const auto iter = fPersistentBranchesMap.find(brname); if (iter != fPersistentBranchesMap.end()) { // verify type consistency - if (typeid(P).hash_code() != iter->second->origtypeinfo.hash_code()) { + if (typeid(P) != iter->second->origtypeinfo) { EmitPersistentBranchWrongTypeWarning(brname, typeid(P).name(), iter->second->origtypeinfo.name()); return nullptr; } diff --git a/examples/MQ/pixelDetector/src/Pixel.cxx b/examples/MQ/pixelDetector/src/Pixel.cxx index 2246a1e4f4..75129c8e66 100644 --- a/examples/MQ/pixelDetector/src/Pixel.cxx +++ b/examples/MQ/pixelDetector/src/Pixel.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -73,8 +73,6 @@ Pixel::~Pixel() } } -void Pixel::Initialize() { FairDetector::Initialize(); } - Bool_t Pixel::ProcessHits(FairVolume* vol) { /** This method is called from the MC stepping */ @@ -196,5 +194,3 @@ extern "C" void ExternCreateDetector() run->AddModule(det); cout << "-- ExternCreateDetector(" << det->GetName() << ") DONE --" << endl; } - -ClassImp(Pixel); diff --git a/examples/MQ/pixelDetector/src/Pixel.h b/examples/MQ/pixelDetector/src/Pixel.h index ece0112046..38c13e5303 100644 --- a/examples/MQ/pixelDetector/src/Pixel.h +++ b/examples/MQ/pixelDetector/src/Pixel.h @@ -33,9 +33,6 @@ class Pixel : public FairDetector /** destructor */ ~Pixel() override; - /** Initialization of the detector is done here */ - void Initialize() override; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ diff --git a/examples/MQ/pixelDetector/src/PixelContFact.cxx b/examples/MQ/pixelDetector/src/PixelContFact.cxx index af9dcf205c..e912d1b60e 100644 --- a/examples/MQ/pixelDetector/src/PixelContFact.cxx +++ b/examples/MQ/pixelDetector/src/PixelContFact.cxx @@ -15,10 +15,6 @@ #include // for TString #include // for strcmp -class FairParSet; - -ClassImp(PixelContFact); - static PixelContFact gPixelContFact; PixelContFact::PixelContFact() diff --git a/examples/MQ/pixelDetector/src/PixelDigi.cxx b/examples/MQ/pixelDetector/src/PixelDigi.cxx index 3d4adf11d1..c6fe52af25 100644 --- a/examples/MQ/pixelDetector/src/PixelDigi.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigi.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,7 +13,6 @@ */ #include "PixelDigi.h" -ClassImp(PixelDigi); PixelDigi::PixelDigi() : FairTimeStamp() diff --git a/examples/MQ/pixelDetector/src/PixelDigiBinSource.cxx b/examples/MQ/pixelDetector/src/PixelDigiBinSource.cxx index aad50b9dac..e702085a31 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiBinSource.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigiBinSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,21 +15,16 @@ // #include "PixelDigiBinSource.h" -#include "FairLogger.h" #include "FairRootManager.h" #include "PixelDigi.h" -#include "PixelEventHeader.h" -#include -#include -#include #include +#include #include PixelDigiBinSource::PixelDigiBinSource(TString inputFileName) : FairSource() - , fEventHeader(nullptr) - , fDigis(nullptr) + , fDigis(PixelDigi::Class(), 10000) , fNDigis(0) , fTNofEvents(0) , fTNofDigis(0) @@ -43,8 +38,6 @@ PixelDigiBinSource::PixelDigiBinSource(TString inputFileName) LOG(debug) << "PixelDigiBinSource created------------"; } -PixelDigiBinSource::~PixelDigiBinSource() {} - Bool_t PixelDigiBinSource::Init() { // Get input array @@ -55,12 +48,10 @@ Bool_t PixelDigiBinSource::Init() LOG(fatal) << "No FairRootManager"; // Register output array StsDigi - fDigis = new TClonesArray("PixelDigi", 10000); - ioman->Register("PixelDigis", "Pixel", fDigis, kFALSE); + ioman->Register("PixelDigis", "Pixel", &fDigis, kFALSE); - fEventHeader = new PixelEventHeader(); - fEventHeader->SetName("EventHeader."); - ioman->Register("EventHeader.", "EvtHeader", fEventHeader, kFALSE); + fEventHeader.SetName("EventHeader."); + ioman->Register("EventHeader.", "EvtHeader", &fEventHeader, kFALSE); fInputFile.open(fInputFileName.Data(), std::fstream::in | std::fstream::binary); @@ -74,7 +65,7 @@ Bool_t PixelDigiBinSource::Init() Int_t PixelDigiBinSource::ReadEvent(UInt_t i) { - fDigis->Clear(); + fDigis.Clear(); fNDigis = 0; if (!fInputFile) { @@ -89,41 +80,41 @@ Int_t PixelDigiBinSource::ReadEvent(UInt_t i) fCurrentEntryNo = i; std::string buffer; - LOG(debug) << "PixelDigiBinSource::ReadEvent() Begin of (" << fDigis->GetEntries() << ")"; + LOG(debug) << "PixelDigiBinSource::ReadEvent() Begin of (" << fDigis.GetEntries() << ")"; Int_t head[4]; // runId, MCEntryNo, PartNo, NofDigis - fInputFile.read((char*)head, sizeof(head)); + fInputFile.read(reinterpret_cast(head), sizeof(head)); if (fInputFile.eof()) { LOG(info) << "End of file reached!"; return 1; } - Int_t dataSize = 4; // detId, feId, col, row + const int dataSize = 4; // detId, feId, col, row const Int_t constNofData = head[3] * dataSize; short int dataCont[constNofData]; - fInputFile.read((char*)dataCont, sizeof(dataCont)); + fInputFile.read(reinterpret_cast(dataCont), sizeof(dataCont)); fRunId = head[0]; fMCEntryNo = head[1]; fPartNo = head[2]; - fEventHeader->SetRunId(fRunId); - fEventHeader->SetMCEntryNumber(fMCEntryNo); - fEventHeader->SetPartNo(fPartNo); + fEventHeader.SetRunId(fRunId); + fEventHeader.SetMCEntryNumber(fMCEntryNo); + fEventHeader.SetPartNo(fPartNo); for (Int_t idata = 0; idata < head[3]; idata++) { LOG(debug) << " --/" << idata << "/--> " << dataCont[idata * dataSize + 0] << " / " << dataCont[idata * dataSize + 1] << " / " << dataCont[idata * dataSize + 2] << " / " << dataCont[idata * dataSize + 3] << " / " << " 0."; - new ((*fDigis)[fNDigis]) PixelDigi(-1, - (Int_t)dataCont[idata * dataSize + 0], - (Int_t)dataCont[idata * dataSize + 1], - (Int_t)dataCont[idata * dataSize + 2], - (Int_t)dataCont[idata * dataSize + 3], - 0., - 0.); + new (fDigis[fNDigis]) PixelDigi(-1, + dataCont[idata * dataSize + 0], + dataCont[idata * dataSize + 1], + dataCont[idata * dataSize + 2], + dataCont[idata * dataSize + 3], + 0., + 0.); fNDigis++; } LOG(debug) << "PixelDigiBinSource::ReadEvent() End of"; @@ -138,9 +129,9 @@ Int_t PixelDigiBinSource::ReadEvent(UInt_t i) Bool_t PixelDigiBinSource::ActivateObject(TObject** obj, const char* BrName) { if (strcmp(BrName, "PixelDigis") == 0) - *obj = (TObject*)fDigis; + *obj = &fDigis; else if (strcmp(BrName, "EventHeader.") == 0) - *obj = (TObject*)fEventHeader; + *obj = &fEventHeader; else return kFALSE; @@ -155,9 +146,7 @@ Int_t PixelDigiBinSource::CheckMaxEventNo(Int_t /*EvtEnd*/) { return -1; } void PixelDigiBinSource::FillEventHeader(FairEventHeader* feh) { - ((PixelEventHeader*)feh)->SetRunId(fRunId); - ((PixelEventHeader*)feh)->SetMCEntryNumber(fMCEntryNo); - ((PixelEventHeader*)feh)->SetPartNo(fPartNo); + FairSource::FillEventHeader(feh); + feh->SetMCEntryNumber(fMCEntryNo); + static_cast(feh)->SetPartNo(fPartNo); } - -ClassImp(PixelDigiBinSource); diff --git a/examples/MQ/pixelDetector/src/PixelDigiBinSource.h b/examples/MQ/pixelDetector/src/PixelDigiBinSource.h index e0550b7b17..57bcb4afef 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiBinSource.h +++ b/examples/MQ/pixelDetector/src/PixelDigiBinSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,21 +17,18 @@ #define PIXELDIGIBINSOURCE_H_ #include "FairSource.h" +#include "PixelEventHeader.h" #include +#include #include #include -class TClonesArray; -class TObject; -class PixelEventHeader; -class FairEventHeader; - class PixelDigiBinSource : public FairSource { public: PixelDigiBinSource(TString inputFileName = "test.dat"); - ~PixelDigiBinSource() override; + ~PixelDigiBinSource() override = default; Bool_t Init() override; @@ -62,8 +59,8 @@ class PixelDigiBinSource : public FairSource Bool_t ActivateObject(TObject** obj, const char* BrName) override; private: - PixelEventHeader* fEventHeader; - TClonesArray* fDigis; /** Output array of PixelDigi **/ + PixelEventHeader fEventHeader{}; + TClonesArray fDigis; /** Output array of PixelDigi **/ Int_t fNDigis; Int_t fTNofEvents; diff --git a/examples/MQ/pixelDetector/src/PixelDigiPar.cxx b/examples/MQ/pixelDetector/src/PixelDigiPar.cxx index cdf4e7f1ba..2703e6e327 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiPar.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigiPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,12 +33,7 @@ PixelDigiPar::PixelDigiPar(const char* name, const char* title, const char* cont , fChargeConvMethod(0) , fPixelSorterCellWidth(0.) , fPixelSorterNumberOfCells(0) -{ - clear(); -} - -// ----- Destructor ---------------------------------------------------- -PixelDigiPar::~PixelDigiPar(void) {} +{} void PixelDigiPar::putParams(FairParamList* list) { @@ -109,5 +104,3 @@ void PixelDigiPar::Print(Option_t*) const std::cout << " Charge cloud sigma (cm) = " << fCSigma << std::endl; std::cout << " charge conv. (0:ideal, 1:TOT) = " << fChargeConvMethod << std::endl; } - -ClassImp(PixelDigiPar); diff --git a/examples/MQ/pixelDetector/src/PixelDigiPar.h b/examples/MQ/pixelDetector/src/PixelDigiPar.h index 09bfedb31d..625221b9eb 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiPar.h +++ b/examples/MQ/pixelDetector/src/PixelDigiPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,8 +27,7 @@ class PixelDigiPar : public FairParGenericSet PixelDigiPar(const char* name = "PixelDigiParameters", const char* title = "Pixel digi parameters", const char* context = "TestDefaultContext"); - ~PixelDigiPar() override; - void clear() override {} + ~PixelDigiPar() override = default; void putParams(FairParamList* list) override; Bool_t getParams(FairParamList* list) override; diff --git a/examples/MQ/pixelDetector/src/PixelDigiSource.cxx b/examples/MQ/pixelDetector/src/PixelDigiSource.cxx index 84636bd4ba..12d5006872 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiSource.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigiSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,21 +15,17 @@ // #include "PixelDigiSource.h" -#include "FairLogger.h" #include "FairRootManager.h" #include "PixelDigi.h" -#include "PixelEventHeader.h" -#include -#include #include #include +#include #include PixelDigiSource::PixelDigiSource(TString inputFileName) : FairSource() - , fEventHeader(nullptr) - , fDigis(nullptr) + , fDigis(PixelDigi::Class(), 10000) , fNDigis(0) , fTNofEvents(0) , fTNofDigis(0) @@ -43,8 +39,6 @@ PixelDigiSource::PixelDigiSource(TString inputFileName) LOG(debug) << "PixelDigiSource created------------"; } -PixelDigiSource::~PixelDigiSource() {} - Bool_t PixelDigiSource::Init() { // Get input array @@ -55,12 +49,10 @@ Bool_t PixelDigiSource::Init() LOG(fatal) << "No FairRootManager"; // Register output array StsDigi - fDigis = new TClonesArray("PixelDigi", 10000); - ioman->Register("PixelDigis", "Pixel", fDigis, kFALSE); + ioman->Register("PixelDigis", "Pixel", &fDigis, kFALSE); - fEventHeader = new PixelEventHeader(); - fEventHeader->SetName("EventHeader."); - ioman->Register("EventHeader.", "EvtHeader", fEventHeader, kFALSE); + fEventHeader.SetName("EventHeader."); + ioman->Register("EventHeader.", "EvtHeader", &fEventHeader, kFALSE); fInputFile.open(fInputFileName.Data(), std::fstream::in); @@ -72,7 +64,7 @@ Bool_t PixelDigiSource::Init() return kTRUE; } -int ReadIntFromString(const std::string& wholestr, const std::string& pattern) +static int ReadIntFromString(const std::string& wholestr, const std::string& pattern) { std::string tempstr = wholestr; tempstr.replace(0, tempstr.find(pattern) + pattern.length(), ""); @@ -82,7 +74,7 @@ int ReadIntFromString(const std::string& wholestr, const std::string& pattern) Int_t PixelDigiSource::ReadEvent(UInt_t i) { - fDigis->Delete(); + fDigis.Delete(); fNDigis = 0; if (i == 0) { @@ -93,7 +85,7 @@ Int_t PixelDigiSource::ReadEvent(UInt_t i) fCurrentEntryNo = i; std::string buffer; - LOG(debug) << "PixelDigiSource::ReadEvent() Begin of (" << fDigis->GetEntries() << ")"; + LOG(debug) << "PixelDigiSource::ReadEvent() Begin of (" << fDigis.GetEntries() << ")"; do { getline(fInputFile, buffer); LOG(debug) << "read from file: \"" << buffer << "\""; @@ -101,9 +93,9 @@ Int_t PixelDigiSource::ReadEvent(UInt_t i) fRunId = ReadIntFromString(buffer, "RUNID"); fMCEntryNo = ReadIntFromString(buffer, "MCENTRYNO"); fPartNo = ReadIntFromString(buffer, "PARTNO"); - fEventHeader->SetRunId(fRunId); - fEventHeader->SetMCEntryNumber(fMCEntryNo); - fEventHeader->SetPartNo(fPartNo); + fEventHeader.SetRunId(fRunId); + fEventHeader.SetMCEntryNumber(fMCEntryNo); + fEventHeader.SetPartNo(fPartNo); LOG(debug) << "GOT NEW EVENT " << fMCEntryNo << " (part " << fPartNo << ") with run id = " << fRunId; } @@ -120,9 +112,9 @@ Int_t PixelDigiSource::ReadEvent(UInt_t i) Double_t charge = atof(buffer.c_str()); LOG(debug) << " --/" << fNDigis << "/--> " << detId << " / " << feId << " / " << col << " / " << row << " / " << charge; - new ((*fDigis)[fNDigis]) PixelDigi(-1, detId, feId, col, row, charge, 0.); + new (fDigis[fNDigis]) PixelDigi(-1, detId, feId, col, row, charge, 0.); fNDigis++; - } while (fInputFile && buffer.compare("EVENT END")); + } while (fInputFile && (buffer == "EVENT END")); LOG(debug) << "PixelDigiSource::ReadEvent() End of"; if (!fInputFile) { @@ -134,10 +126,10 @@ Int_t PixelDigiSource::ReadEvent(UInt_t i) Bool_t PixelDigiSource::ActivateObject(TObject** obj, const char* BrName) { - if (strcmp(BrName, "PixelDigis")) - *obj = (TObject*)fDigis; - else if (strcmp(BrName, "EventHeader.")) - *obj = (TObject*)fEventHeader; + if (strcmp(BrName, "PixelDigis") == 0) + *obj = &fDigis; + else if (strcmp(BrName, "EventHeader.") == 0) + *obj = &fEventHeader; else return kFALSE; @@ -152,9 +144,7 @@ Int_t PixelDigiSource::CheckMaxEventNo(Int_t /*EvtEnd*/) { return -1; } void PixelDigiSource::FillEventHeader(FairEventHeader* feh) { - ((PixelEventHeader*)feh)->SetRunId(fRunId); - ((PixelEventHeader*)feh)->SetMCEntryNumber(fMCEntryNo); - ((PixelEventHeader*)feh)->SetPartNo(fPartNo); + FairSource::FillEventHeader(feh); + feh->SetMCEntryNumber(fMCEntryNo); + static_cast(feh)->SetPartNo(fPartNo); } - -ClassImp(PixelDigiSource); diff --git a/examples/MQ/pixelDetector/src/PixelDigiSource.h b/examples/MQ/pixelDetector/src/PixelDigiSource.h index 97ab6ff92c..ec1749c730 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiSource.h +++ b/examples/MQ/pixelDetector/src/PixelDigiSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,21 +17,18 @@ #define PIXELDIGISOURCE_H_ #include "FairSource.h" +#include "PixelEventHeader.h" #include +#include #include #include -class TClonesArray; - -class PixelEventHeader; -class FairEventHeader; - class PixelDigiSource : public FairSource { public: PixelDigiSource(TString inputFileName = "test.dat"); - ~PixelDigiSource() override; + ~PixelDigiSource() override = default; Bool_t Init() override; @@ -62,8 +59,8 @@ class PixelDigiSource : public FairSource Bool_t ActivateObject(TObject** obj, const char* BrName) override; private: - PixelEventHeader* fEventHeader; - TClonesArray* fDigis; /** Output array of PixelDigi **/ + PixelEventHeader fEventHeader{}; + TClonesArray fDigis; /** Output array of PixelDigi **/ Int_t fNDigis; Int_t fTNofEvents; diff --git a/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.cxx b/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.cxx index b02bfbe2f4..ea58418821 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,15 +14,12 @@ #include "PixelDigiWriteToBinFile.h" +#include "PixelDigi.h" + // Includes from base -#include "FairLogger.h" #include "FairRootManager.h" -// Includes from ROOT -#include "PixelDigi.h" - -#include -#include +#include PixelDigiWriteToBinFile::PixelDigiWriteToBinFile() : PixelDigiWriteToBinFile("Pixel DigiWriter", 0) @@ -42,17 +39,10 @@ PixelDigiWriteToBinFile::PixelDigiWriteToBinFile(const char* name, Int_t iVerbos , fRunId(0) , fMCEntryNo(0) , fPartNo(0) - -{ - Reset(); -} - -PixelDigiWriteToBinFile::~PixelDigiWriteToBinFile() { Reset(); } +{} void PixelDigiWriteToBinFile::Exec(Option_t* /*opt*/) { - Reset(); - Int_t nofDigis = fDigis->GetEntriesFast(); Int_t digisPerFile[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -103,7 +93,6 @@ void PixelDigiWriteToBinFile::Exec(Option_t* /*opt*/) InitStatus PixelDigiWriteToBinFile::Init() { - // Get input array FairRootManager* ioman = FairRootManager::Instance(); @@ -163,5 +152,3 @@ void PixelDigiWriteToBinFile::Finish() fOutputFiles[ifile].close(); } } - -ClassImp(PixelDigiWriteToBinFile); diff --git a/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.h b/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.h index 7ccda08f83..94b496b12f 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.h +++ b/examples/MQ/pixelDetector/src/PixelDigiWriteToBinFile.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,10 +18,8 @@ #include "FairTask.h" #include +#include #include - -class TClonesArray; - #include class PixelDigiWriteToBinFile : public FairTask @@ -37,7 +35,7 @@ class PixelDigiWriteToBinFile : public FairTask PixelDigiWriteToBinFile(const char* name, Int_t iVerbose); /** Destructor **/ - ~PixelDigiWriteToBinFile() override; + ~PixelDigiWriteToBinFile() override = default; /** Execution **/ void Exec(Option_t* opt) override; @@ -65,9 +63,6 @@ class PixelDigiWriteToBinFile : public FairTask /** Reinitialisation **/ InitStatus ReInit() override; - /** Reset eventwise counters **/ - void Reset() {} - /** Finish at the end of each event **/ void Finish() override; diff --git a/examples/MQ/pixelDetector/src/PixelDigiWriteToFile.cxx b/examples/MQ/pixelDetector/src/PixelDigiWriteToFile.cxx index 87f2f78575..af756bdcba 100644 --- a/examples/MQ/pixelDetector/src/PixelDigiWriteToFile.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigiWriteToFile.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -143,5 +143,3 @@ void PixelDigiWriteToFile::Finish() fOutputFiles[ifile].close(); } } - -ClassImp(PixelDigiWriteToFile); diff --git a/examples/MQ/pixelDetector/src/PixelDigitize.cxx b/examples/MQ/pixelDetector/src/PixelDigitize.cxx index d61bcccc4e..6c109f1662 100644 --- a/examples/MQ/pixelDetector/src/PixelDigitize.cxx +++ b/examples/MQ/pixelDetector/src/PixelDigitize.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -178,14 +178,15 @@ void PixelDigitize::GetParList(TList* tempList) { fDigiPar = new PixelDigiPar("PixelDigiParameters"); tempList->Add(fDigiPar); - - return; } void PixelDigitize::InitMQ(TList* tempList) { LOG(info) << "********************************************** PixelDigitize::InitMQ()"; - fDigiPar = (PixelDigiPar*)tempList->FindObject("PixelDigiParameters"); + fDigiPar = dynamic_cast(tempList->FindObject("PixelDigiParameters")); + if (!fDigiPar) { + throw std::runtime_error("no PixelDigiParameters"); + } fFeCols = fDigiPar->GetFECols(); fFeRows = fDigiPar->GetFERows(); @@ -200,8 +201,6 @@ void PixelDigitize::InitMQ(TList* tempList) LOG(info) << ">> fPitchY = " << fPitchY; fDigis = new TClonesArray("PixelDigi", 10000); - - return; } void PixelDigitize::ExecMQ(TList* inputList, TList* outputList) @@ -209,10 +208,15 @@ void PixelDigitize::ExecMQ(TList* inputList, TList* outputList) // LOG(info) << "********************************************** PixelDigitize::ExecMQ(" << inputList->GetName() << // "," << outputList->GetName() << "), Event " << fTNofEvents; LOG(info) << // "********************************************** PixelDigitize::ExecMQ(), Event " << fTNofEvents; - fPoints = (TClonesArray*)inputList->FindObject("PixelPoint"); + fPoints = dynamic_cast(inputList->FindObject("PixelPoint")); + if (!fPoints) { + throw std::runtime_error("no PixelPoint"); + } + if (!fPoints->GetClass()->InheritsFrom(PixelPoint::Class())) { + throw std::runtime_error("wrong type in PixelPoint TCA"); + } outputList->Add(fDigis); Exec(""); - return; } InitStatus PixelDigitize::Init() @@ -264,5 +268,3 @@ void PixelDigitize::Finish() << static_cast(fTNofDigis) / (static_cast(fTNofEvents)) << " per event )"; LOG(info) << "---------------------------------------------------------------------"; } - -ClassImp(PixelDigitize); diff --git a/examples/MQ/pixelDetector/src/PixelEventHeader.cxx b/examples/MQ/pixelDetector/src/PixelEventHeader.cxx index 4227164604..c7f9698afc 100644 --- a/examples/MQ/pixelDetector/src/PixelEventHeader.cxx +++ b/examples/MQ/pixelDetector/src/PixelEventHeader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,5 +20,3 @@ PixelEventHeader::PixelEventHeader() {} PixelEventHeader::~PixelEventHeader() {} - -ClassImp(PixelEventHeader); diff --git a/examples/MQ/pixelDetector/src/PixelFindHits.cxx b/examples/MQ/pixelDetector/src/PixelFindHits.cxx index 38949a7072..ccdfa10622 100644 --- a/examples/MQ/pixelDetector/src/PixelFindHits.cxx +++ b/examples/MQ/pixelDetector/src/PixelFindHits.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -146,14 +146,15 @@ void PixelFindHits::GetParList(TList* tempList) { fDigiPar = new PixelDigiPar("PixelDigiParameters"); tempList->Add(fDigiPar); - - return; } void PixelFindHits::InitMQ(TList* tempList) { LOG(info) << "********************************************** PixelFindHits::InitMQ()"; - fDigiPar = (PixelDigiPar*)tempList->FindObject("PixelDigiParameters"); + fDigiPar = dynamic_cast(tempList->FindObject("PixelDigiParameters")); + if (!fDigiPar) { + throw std::runtime_error("no PixelDigiParameters"); + } fFeCols = fDigiPar->GetFECols(); fFeRows = fDigiPar->GetFERows(); @@ -168,8 +169,6 @@ void PixelFindHits::InitMQ(TList* tempList) LOG(info) << ">> fPitchY = " << fPitchY; fHits = new TClonesArray("PixelHit", 10000); - - return; } void PixelFindHits::ExecMQ(TList* inputList, TList* outputList) @@ -178,10 +177,15 @@ void PixelFindHits::ExecMQ(TList* inputList, TList* outputList) // "," << outputList->GetName() << "), Event " << fTNofEvents; LOG(info) << // "********************************************** PixelFindHits::ExecMQ(), Event " << fTNofEvents; LOG(info) << // "h" << FairLogger::flush; - fDigis = (TClonesArray*)inputList->FindObject("PixelDigis"); + fDigis = dynamic_cast(inputList->FindObject("PixelDigis")); + if (!fDigis) { + throw std::runtime_error("no PixelDigis"); + } + if (!fDigis->GetClass()->InheritsFrom(PixelDigi::Class())) { + throw std::runtime_error("wrong type in PixelDigis TCA"); + } outputList->Add(fHits); Exec(""); - return; } InitStatus PixelFindHits::Init() @@ -236,5 +240,3 @@ void PixelFindHits::Finish() << static_cast(fTNofHits) / (static_cast(fTNofEvents)) << " per event)"; LOG(info) << "---------------------------------------------------------------------"; } - -ClassImp(PixelFindHits); diff --git a/examples/MQ/pixelDetector/src/PixelFindTracks.cxx b/examples/MQ/pixelDetector/src/PixelFindTracks.cxx index 3623136e4c..1359f4e632 100644 --- a/examples/MQ/pixelDetector/src/PixelFindTracks.cxx +++ b/examples/MQ/pixelDetector/src/PixelFindTracks.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -151,19 +151,18 @@ void PixelFindTracks::GetParList(TList* tempList) { fDigiPar = new PixelDigiPar("PixelDigiParameters"); tempList->Add(fDigiPar); - - return; } void PixelFindTracks::InitMQ(TList* tempList) { LOG(info) << "********************************************** PixelFindTracks::InitMQ()"; - fDigiPar = (PixelDigiPar*)tempList->FindObject("PixelDigiParameters"); + fDigiPar = dynamic_cast(tempList->FindObject("PixelDigiParameters")); + if (!fDigiPar) { + throw std::runtime_error("no PixelDigiParameters"); + } fTracks = new TClonesArray("PixelTrack", 10000); fhDist2D = new TH2F("fhDist2D", "Distance between hit and expected track", 400, -1., 1., 400, -1., 1.); - - return; } void PixelFindTracks::ExecMQ(TList* inputList, TList* outputList) @@ -172,10 +171,15 @@ void PixelFindTracks::ExecMQ(TList* inputList, TList* outputList) // << "," << outputList->GetName() << "), Event " << fTNofEvents; LOG(info) << // "********************************************** PixelFindTracks::ExecMQ(), Event " << fTNofEvents; LOG(info) << // "t" << FairLogger::flush; - fHits = (TClonesArray*)inputList->FindObject("PixelHits"); + fHits = dynamic_cast(inputList->FindObject("PixelHits")); + if (!fHits) { + throw std::runtime_error("no PixelHits"); + } + if (!fHits->GetClass()->InheritsFrom(PixelHit::Class())) { + throw std::runtime_error("wrong type in PixelHits TCA"); + } outputList->Add(fTracks); Exec(""); - return; } InitStatus PixelFindTracks::Init() @@ -223,5 +227,3 @@ void PixelFindTracks::Finish() << static_cast(fTNofTracks) / (static_cast(fTNofEvents)) << " per event )"; LOG(info) << "---------------------------------------------------------------------"; } - -ClassImp(PixelFindTracks); diff --git a/examples/MQ/pixelDetector/src/PixelFitTracks.cxx b/examples/MQ/pixelDetector/src/PixelFitTracks.cxx index 4cf55a7dde..0f5ddadc9e 100644 --- a/examples/MQ/pixelDetector/src/PixelFitTracks.cxx +++ b/examples/MQ/pixelDetector/src/PixelFitTracks.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,7 +14,6 @@ #include "PixelFitTracks.h" -#include "FairLogger.h" #include "FairRootManager.h" #include "FairRun.h" #include "FairRuntimeDb.h" @@ -22,9 +21,8 @@ #include "PixelHit.h" #include "PixelTrack.h" -#include -#include #include +#include PixelFitTracks::PixelFitTracks() : PixelFitTracks("Pixel Track Fitter", 0) @@ -46,13 +44,10 @@ PixelFitTracks::PixelFitTracks(const char* name, Int_t iVerbose) , fTNofTracks(0) , fNFitTracks(0) , fTNofFitTracks(0) -{ - Reset(); -} +{} PixelFitTracks::~PixelFitTracks() { - Reset(); delete fDigiPar; if (fFitTracks) { fFitTracks->Delete(); @@ -62,7 +57,9 @@ PixelFitTracks::~PixelFitTracks() void PixelFitTracks::Exec(Option_t* /*opt*/) { - Reset(); + fNFitTracks = 0; + if (fFitTracks) + fFitTracks->Clear(); fNHits = fHits->GetEntriesFast(); fNTracks = fTracks->GetEntriesFast(); @@ -175,8 +172,6 @@ void PixelFitTracks::GetParList(TList* tempList) { fDigiPar = new PixelDigiPar("PixelDigiParameters"); tempList->Add(fDigiPar); - - return; } void PixelFitTracks::InitMQ(TList* tempList) @@ -186,7 +181,6 @@ void PixelFitTracks::InitMQ(TList* tempList) fFitTracks = new TClonesArray("PixelTrack", 10000); fFitTracks->SetName("PixelFitTracks"); - return; } void PixelFitTracks::ExecMQ(TList* inputList, TList* outputList) @@ -199,7 +193,6 @@ void PixelFitTracks::ExecMQ(TList* inputList, TList* outputList) fTracks = (TClonesArray*)inputList->FindObject("PixelTracks"); outputList->Add(fFitTracks); Exec(""); - return; } InitStatus PixelFitTracks::Init() @@ -223,15 +216,6 @@ InitStatus PixelFitTracks::Init() return kSUCCESS; } -InitStatus PixelFitTracks::ReInit() { return kSUCCESS; } - -void PixelFitTracks::Reset() -{ - fNFitTracks = fNTracks = fNHits = 0; - if (fFitTracks) - fFitTracks->Clear(); -} - void PixelFitTracks::Finish() { if (fFitTracks) @@ -245,5 +229,3 @@ void PixelFitTracks::Finish() << static_cast(fTNofFitTracks) / (static_cast(fTNofEvents)) << " per event)"; LOG(info) << "---------------------------------------------------------------------"; } - -ClassImp(PixelFitTracks); diff --git a/examples/MQ/pixelDetector/src/PixelFitTracks.h b/examples/MQ/pixelDetector/src/PixelFitTracks.h index 7857c41764..4cc48fc4d3 100644 --- a/examples/MQ/pixelDetector/src/PixelFitTracks.h +++ b/examples/MQ/pixelDetector/src/PixelFitTracks.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,10 +18,10 @@ #include "FairTask.h" #include +#include +#include -class TClonesArray; class PixelDigiPar; -class TList; class PixelFitTracks : public FairTask { @@ -76,12 +76,6 @@ class PixelFitTracks : public FairTask /** Intialisation **/ InitStatus Init() override; - /** Reinitialisation **/ - InitStatus ReInit() override; - - /** Reset eventwise counters **/ - void Reset(); - /** Finish at the end of each event **/ void Finish() override; diff --git a/examples/MQ/pixelDetector/src/PixelGeo.cxx b/examples/MQ/pixelDetector/src/PixelGeo.cxx index cadb0709b1..deaa92aada 100644 --- a/examples/MQ/pixelDetector/src/PixelGeo.cxx +++ b/examples/MQ/pixelDetector/src/PixelGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,37 +7,6 @@ ********************************************************************************/ #include "PixelGeo.h" -#include // for sprintf - -ClassImp(PixelGeo); - PixelGeo::PixelGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "Pixel"; - strcpy(modName, "Pixel"); - strcpy(eleName, "Pixel"); - maxSectors = 0; - maxModules = 10; -} - -const char* PixelGeo::getModuleName(Int_t m) -{ - /** Returns the module name of Pixel number m - Setting Pixel here means that all modules names in the - ASCII file should start with Pixel otherwise they will - not be constructed - */ - sprintf(modName, "Pixel%i", m + 1); - return modName; -} - -const char* PixelGeo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - sprintf(eleName, "Pixel%i", m + 1); - return eleName; -} + : FairGeoSet("Pixel", 10) +{} diff --git a/examples/MQ/pixelDetector/src/PixelGeo.h b/examples/MQ/pixelDetector/src/PixelGeo.h index e193fbc2a5..b38ee845d2 100644 --- a/examples/MQ/pixelDetector/src/PixelGeo.h +++ b/examples/MQ/pixelDetector/src/PixelGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,33 +10,14 @@ #include "FairGeoSet.h" // for FairGeoSet -#include // for PixelGeo::Class, ClassDef, PixelGeo::Streamer -#include // for TString +#include // for PixelGeo::Class, ClassDef, PixelGeo::Streamer class PixelGeo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module - public: PixelGeo(); ~PixelGeo() override = default; - const char* getModuleName(Int_t) override; - const char* getEleName(Int_t) override; - inline Int_t getModNumInMod(const TString&) override; - ClassDefOverride(PixelGeo, 1); }; -inline Int_t PixelGeo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - newdetector ?? has to be 11. - */ - return static_cast((name[5] - '0') - 1); // -} - #endif diff --git a/examples/MQ/pixelDetector/src/PixelGeoPar.cxx b/examples/MQ/pixelDetector/src/PixelGeoPar.cxx index d37903da6c..0576ae1fc7 100644 --- a/examples/MQ/pixelDetector/src/PixelGeoPar.cxx +++ b/examples/MQ/pixelDetector/src/PixelGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,17 +11,15 @@ #include -ClassImp(PixelGeoPar); - PixelGeoPar ::PixelGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -PixelGeoPar::~PixelGeoPar(void) {} +PixelGeoPar::~PixelGeoPar() {} -void PixelGeoPar::clear(void) +void PixelGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/MQ/pixelDetector/src/PixelHit.cxx b/examples/MQ/pixelDetector/src/PixelHit.cxx index dc7b5eeebd..a106c2c576 100644 --- a/examples/MQ/pixelDetector/src/PixelHit.cxx +++ b/examples/MQ/pixelDetector/src/PixelHit.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,5 +23,3 @@ PixelHit::PixelHit(Int_t detID, Int_t mcindex, const TVector3& pos, const TVecto {} PixelHit::~PixelHit() {} - -ClassImp(PixelHit); diff --git a/examples/MQ/pixelDetector/src/PixelPoint.cxx b/examples/MQ/pixelDetector/src/PixelPoint.cxx index 9ba67eb30f..2cbbc830d2 100644 --- a/examples/MQ/pixelDetector/src/PixelPoint.cxx +++ b/examples/MQ/pixelDetector/src/PixelPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,5 +35,3 @@ void PixelPoint::Print(const Option_t* /*opt*/) const cout << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" << endl; } - -ClassImp(PixelPoint); diff --git a/examples/MQ/pixelDetector/src/PixelTrack.cxx b/examples/MQ/pixelDetector/src/PixelTrack.cxx index 9c74828ec9..4e13726d6e 100644 --- a/examples/MQ/pixelDetector/src/PixelTrack.cxx +++ b/examples/MQ/pixelDetector/src/PixelTrack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -50,5 +50,3 @@ PixelTrack::PixelTrack(Double_t x0, {} PixelTrack::~PixelTrack() {} - -ClassImp(PixelTrack); diff --git a/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSink.cxx b/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSink.cxx index 7c12481ba8..b560537e2c 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSink.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSink.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -41,8 +41,8 @@ void FairMQPixelFileSink::InitTask() fFileOption = "RECREATE"; fTreeName = "cbmsim"; - if (::getenv("DDS_SESSION_ID")) { - std::string DDS_SESSION_ID = ::getenv("DDS_SESSION_ID"); + if (const char* dds_session_env = ::getenv("DDS_SESSION_ID")) { + std::string DDS_SESSION_ID{dds_session_env}; if (fFileName.length() > 5) { DDS_SESSION_ID = "." + DDS_SESSION_ID + ".root"; fFileName.replace(fFileName.length() - 5, 5, DDS_SESSION_ID.c_str()); @@ -57,7 +57,7 @@ void FairMQPixelFileSink::InitTask() bool FairMQPixelFileSink::StoreData(fair::mq::Parts& parts, int /*index*/) { bool creatingTree = false; - auto numParts = parts.Size(); + const auto numParts = parts.Size(); std::vector> cleanup; std::vector objectsForBranches; @@ -68,7 +68,7 @@ bool FairMQPixelFileSink::StoreData(fair::mq::Parts& parts, int /*index*/) cleanup.reserve(numParts); objectsForBranches.resize(numParts, nullptr); - for (int ipart = 0; ipart < numParts; ipart++) { + for (decltype(parts.Size()) ipart = 0; ipart < numParts; ipart++) { auto curobj = RootSerializer().DeserializeTo(*parts.At(ipart)); objectsForBranches.at(ipart) = curobj.get(); if (creatingTree) { diff --git a/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSinkBin.cxx b/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSinkBin.cxx index 1566567c3a..4741284d0f 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSinkBin.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQPixelFileSinkBin.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -100,16 +100,19 @@ void FairMQPixelFileSinkBin::Init() bool FairMQPixelFileSinkBin::StoreData(fair::mq::Parts& parts, int /*index*/) { - if (parts.Size() == 0) + const auto numParts = parts.Size(); + + if (numParts == 0) { return true; // probably impossible, but still check + } // expecting even number of parts in the form: header,data,header,data,header,data and so on... - int nPPE = 2; // nof parts per event + constexpr auto nPPE = 2; // nof parts per event - if (parts.Size() % nPPE >= 1) - LOG(info) << "received " << parts.Size() << " parts, will ignore last part!!!"; + if (numParts % nPPE >= 1) + LOG(info) << "received " << numParts << " parts, will ignore last part!!!"; - for (int ievent = 0; ievent < parts.Size() / nPPE; ievent++) { + for (decltype(parts.Size()) ievent = 0; ievent < numParts / nPPE; ievent++) { // the first part should be the event header PixelPayload::EventHeader* payloadE = static_cast(parts.At(nPPE * ievent)->GetData()); diff --git a/examples/MQ/pixelDetector/src/devices/FairMQPixelMerger.cxx b/examples/MQ/pixelDetector/src/devices/FairMQPixelMerger.cxx index 458ade59ff..5cc87e7b9c 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQPixelMerger.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQPixelMerger.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -52,9 +52,9 @@ bool FairMQPixelMerger::MergeData(fair::mq::Parts& parts, int /*index*/) int nofArrays = 0; // LOG(debug) << // "******************************************************************************************************"; - for (int ipart = 0; ipart < parts.Size(); ipart++) { + for (auto& part : parts) { tempObject = nullptr; - RootSerializer().Deserialize(*parts.At(ipart), tempObject); + RootSerializer().Deserialize(*part, tempObject); if (strcmp(tempObject->GetName(), "EventHeader.") == 0) { fEventHeader = (PixelEventHeader*)tempObject; // LOG(debug) << "GOT PART [" << fEventHeader->GetRunId() << "][" << fEventHeader->GetMCEntryNumber() << diff --git a/examples/MQ/pixelDetector/src/devices/FairMQPixelSamplerBin.cxx b/examples/MQ/pixelDetector/src/devices/FairMQPixelSamplerBin.cxx index ae180631e3..6acd37a62b 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQPixelSamplerBin.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQPixelSamplerBin.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -96,8 +96,8 @@ bool FairMQPixelSamplerBin::ConditionalRun() for (int iobj = 0; iobj < fNObjects; iobj++) { if (strcmp(fInputObjects[iobj]->GetName(), "EventHeader.") == 0) { PixelPayload::EventHeader* header = new PixelPayload::EventHeader(); - header->fRunId = ((FairEventHeader*)fInputObjects[iobj])->GetRunId(); - header->fMCEntryNo = ((FairEventHeader*)fInputObjects[iobj])->GetMCEntryNumber(); + header->fRunId = static_cast(fInputObjects[iobj])->GetRunId(); + header->fMCEntryNo = static_cast(fInputObjects[iobj])->GetMCEntryNumber(); header->fPartNo = 0; auto msgHeader(NewMessage(header, sizeof(PixelPayload::EventHeader), [](void* data, void* /*hint*/) { delete static_cast(data); @@ -106,7 +106,7 @@ bool FairMQPixelSamplerBin::ConditionalRun() // LOG(debug) << "-----------------------------"; // LOG(debug) << "first part has size = " << sizeof(PixelPayload::EventHeader); } else { - Int_t nofEntries = ((TClonesArray*)fInputObjects[iobj])->GetEntries(); + Int_t nofEntries = static_cast(fInputObjects[iobj])->GetEntries(); size_t digisSize = nofEntries * sizeof(PixelPayload::Digi); auto msgTCA(NewMessage(digisSize)); @@ -114,7 +114,7 @@ bool FairMQPixelSamplerBin::ConditionalRun() PixelPayload::Digi* digiPayload = static_cast(msgTCA->GetData()); for (int idigi = 0; idigi < nofEntries; idigi++) { - PixelDigi* digi = static_cast(((TClonesArray*)fInputObjects[iobj])->At(idigi)); + auto digi = static_cast(static_cast(fInputObjects[iobj])->At(idigi)); if (!digi) { continue; } diff --git a/examples/MQ/pixelDetector/src/devices/FairMQPixelTaskProcessor.h b/examples/MQ/pixelDetector/src/devices/FairMQPixelTaskProcessor.h index 91248cfa20..7eab681d46 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQPixelTaskProcessor.h +++ b/examples/MQ/pixelDetector/src/devices/FairMQPixelTaskProcessor.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -71,11 +71,10 @@ class FairMQPixelTaskProcessor : public fair::mq::Device fReceivedMsgs++; std::vector tempObjects; - for (int ipart = 0; ipart < parts.Size(); ipart++) { + for (auto& part : parts) { TObject* obj = nullptr; - RootSerializer().Deserialize(*parts.At(ipart), obj); + RootSerializer().Deserialize(*part, obj); tempObjects.push_back(obj); - // LOG(trace) << "got TObject with name \"" << tempObjects[ipart]->GetName() << "\"."; if (strcmp(tempObjects.back()->GetName(), "EventHeader.") == 0) { fEventHeader = (FairEventHeader*)(tempObjects.back()); } diff --git a/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.cxx b/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.cxx index 980655cbc4..ef273dd865 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -14,6 +14,7 @@ #include "FairMQRunDevice.h" +#include "FairMQ.h" #include "FairOnlineSink.h" #include "FairRootManager.h" #include "RootSerializer.h" @@ -23,7 +24,6 @@ #include #include // printf #include - #include // std::mutex std::mutex mtx; // mutex for critical section @@ -59,31 +59,27 @@ void FairMQRunDevice::SendObject(TObject* obj, const std::string& chan) } } -void FairMQRunDevice::SendBranches() +void FairMQRunDevice::SendBranches(FairOnlineSink& sink) { /// Fill the Root tree. LOG(debug) << "called FairMQRunDevice::SendBranches()!!!!"; TList* branchNameList = FairRootManager::Instance()->GetBranchNameList(); - TObjString* ObjStr; - for (auto& mi : fChannels) { + for (auto& mi : fairroot::GetFairMQDeviceChannels(*this)) { LOG(debug) << "trying channel >" << mi.first << "<"; fair::mq::Parts parts; for (Int_t t = 0; t < branchNameList->GetEntries(); t++) { - ObjStr = static_cast(branchNameList->TList::At(t)); + auto ObjStr = static_cast(branchNameList->TList::At(t)); LOG(debug) << " branch >" << ObjStr->GetString().Data() << "<"; std::string modifiedBranchName = std::string("#") + ObjStr->GetString().Data() + "#"; if (mi.first.find(modifiedBranchName) != std::string::npos || mi.first.find("#all#") != std::string::npos) { - if ((static_cast(FairRootManager::Instance()->GetSink())) - ->IsPersistentBranchAny(ObjStr->GetString())) { + if (sink.IsPersistentBranchAny(ObjStr->GetString())) { LOG(debug) << "Branch \"" << ObjStr->GetString() << "\" is persistent ANY"; if (ObjStr->GetString().CompareTo("MCTrack") == 0) { - TClonesArray** mcTrackArray = - (static_cast(FairRootManager::Instance()->GetSink())) - ->GetPersistentBranchAny(ObjStr->GetString()); + auto mcTrackArray = sink.GetPersistentBranchAny(ObjStr->GetString()); if (mcTrackArray) { (*mcTrackArray)->SetName("MCTrack"); LOG(debug) << "[" << FairRootManager::Instance()->GetInstanceId() << "] mcTrack " diff --git a/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.h b/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.h index d700c25359..db19e4b982 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.h +++ b/examples/MQ/pixelDetector/src/devices/FairMQRunDevice.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -32,7 +32,7 @@ class FairMQRunDevice : public fair::mq::Device FairMQRunDevice& operator=(const FairMQRunDevice&) = delete; ~FairMQRunDevice() override; - virtual void SendBranches(); + virtual void SendBranches(FairOnlineSink& sink); void SetSink(std::unique_ptr sink); diff --git a/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx b/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx index b1e4904806..0d7a54ec09 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx +++ b/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -17,7 +17,6 @@ #include "FairModule.h" #include "FairParSet.h" #include "FairPrimaryGenerator.h" -#include "FairRunSim.h" #include "FairRuntimeDb.h" #include @@ -31,7 +30,6 @@ FairMQSimDevice::FairMQSimDevice() , fSimDeviceId(0) , fUpdateChannelName("updateChannel") , fRunInitialized(false) - , fRunSim(nullptr) , fNofEvents(1) , fTransportName("TGeant3") , fMaterialsFile("") @@ -46,7 +44,7 @@ FairMQSimDevice::FairMQSimDevice() void FairMQSimDevice::InitTask() { - fRunSim = new FairRunSim(); + fRunSim = std::make_unique(); SetupRunSink(*fRunSim); @@ -80,6 +78,11 @@ void FairMQSimDevice::InitTask() } } +void FairMQSimDevice::ResetTask() +{ + fRunSim.reset(); +} + void FairMQSimDevice::InitializeRun() { // ----- Negotiate the run number ------------------------------------- @@ -161,10 +164,10 @@ void FairMQSimDevice::UpdateParameterServer() printf("FairMQSimDevice::UpdateParameterServer() finished\n"); } -void FairMQSimDevice::SendBranches() +void FairMQSimDevice::SendBranches(FairOnlineSink& sink) { if (NewStatePending()) { fRunSim->StopMCRun(); } - FairMQRunDevice::SendBranches(); + FairMQRunDevice::SendBranches(sink); } diff --git a/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.h b/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.h index c886d13573..759fb880ce 100644 --- a/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.h +++ b/examples/MQ/pixelDetector/src/devices/FairMQSimDevice.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -17,6 +17,7 @@ #define FAIRMQSIMDEVICE_H_ #include "FairMQRunDevice.h" +#include "FairRunSim.h" #include #include @@ -24,7 +25,6 @@ #include #include -class FairRunSim; class FairField; class FairParIo; class FairPrimaryGenerator; @@ -55,10 +55,11 @@ class FairMQSimDevice : public FairMQRunDevice void InitializeRun(); - void SendBranches() override; + void SendBranches(FairOnlineSink& sink) override; protected: void InitTask() override; + void ResetTask() override; void PreRun() override; void PostRun() override {} bool ConditionalRun() override; @@ -69,7 +70,7 @@ class FairMQSimDevice : public FairMQRunDevice bool fRunInitialized; // false, set to true after initialization in the run stage (!) - FairRunSim* fRunSim; + std::unique_ptr fRunSim; // ------ FairRunSim settings ------ int64_t fNofEvents; std::string fTransportName; diff --git a/examples/MQ/pixelSimSplit/run/scripts/test-splitMQ.sh.in b/examples/MQ/pixelSimSplit/run/scripts/test-splitMQ.sh.in index 76499c9585..2103d9d7bc 100755 --- a/examples/MQ/pixelSimSplit/run/scripts/test-splitMQ.sh.in +++ b/examples/MQ/pixelSimSplit/run/scripts/test-splitMQ.sh.in @@ -99,7 +99,13 @@ echo "Terminating topology ..." kill ${PIDS[TRANSPORTER]} ${PIDS[MERGER]} ${PIDS[PARMQSERVER]} ${PIDS[FILESINK]} for DEVICE in TRANSPORTER MERGER PARMQSERVER FILESINK do - wait ${PIDS[$DEVICE]} || { ret=$?; echo "$DEVICE failed with exit code $ret"; RC=$(($RC + $ret)); } + wait ${PIDS[$DEVICE]} || { + ret=$? + echo "*** $DEVICE failed with exit code $ret" + RC=$(($RC + $ret)) + echo " Last lines of log:" + tail -n 50 "${LOGS[$DEVICE]}" | sed -e 's/^/ | /' + } done echo "... terminated (RC=$RC)." diff --git a/examples/MQ/pixelSimSplit/src/CMakeLists.txt b/examples/MQ/pixelSimSplit/src/CMakeLists.txt index 27da53320c..94aac184ee 100644 --- a/examples/MQ/pixelSimSplit/src/CMakeLists.txt +++ b/examples/MQ/pixelSimSplit/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -36,11 +36,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/MQ/pixelSimSplit/src/FairMCSplitEventHeader.cxx b/examples/MQ/pixelSimSplit/src/FairMCSplitEventHeader.cxx index 0ba46e3fbd..939d9b875d 100644 --- a/examples/MQ/pixelSimSplit/src/FairMCSplitEventHeader.cxx +++ b/examples/MQ/pixelSimSplit/src/FairMCSplitEventHeader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,5 +31,3 @@ void FairMCSplitEventHeader::Register() // Dot at the end of the name is needed for splitting!! FairRootManager::Instance()->Register("MCEventHeader.", "Event", this, kTRUE); } - -ClassImp(FairMCSplitEventHeader); diff --git a/examples/MQ/pixelSimSplit/src/devices/FairMQChunkMerger.cxx b/examples/MQ/pixelSimSplit/src/devices/FairMQChunkMerger.cxx index 45e9f12199..c5031940db 100644 --- a/examples/MQ/pixelSimSplit/src/devices/FairMQChunkMerger.cxx +++ b/examples/MQ/pixelSimSplit/src/devices/FairMQChunkMerger.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -59,9 +59,9 @@ bool FairMQChunkMerger::MergeData(fair::mq::Parts& parts, int /*index*/) // dataDuplicationFlag = false; std::vector tcaVector; - for (int ipart = 0; ipart < parts.Size(); ++ipart) { + for (auto& part : parts) { TObject* tempObject = nullptr; - RootSerializer().Deserialize(*parts.At(ipart), tempObject); + RootSerializer().Deserialize(*part, tempObject); // LOG(INFO) << "Got object " << tempObject->ClassName() << " named " << tempObject->GetName(); if (strcmp(tempObject->GetName(), "MCEventHeader.") == 0) { diff --git a/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx b/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx index 4c609c63fe..b129ba9f14 100644 --- a/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx +++ b/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -19,7 +19,6 @@ #include "FairMCSplitEventHeader.h" #include "FairModule.h" #include "FairParSet.h" -#include "FairRunSim.h" #include "FairRuntimeDb.h" #include "FairTask.h" #include "RootSerializer.h" @@ -46,7 +45,6 @@ FairMQTransportDevice::FairMQTransportDevice() , fVMC(nullptr) , fStack(nullptr) , fMCApplication(nullptr) - , fRunSim(nullptr) , fNofEvents(1) , fTransportName("TGeant3") , fMaterialsFile("") @@ -67,7 +65,7 @@ void FairMQTransportDevice::Init() void FairMQTransportDevice::InitTask() { - fRunSim = new FairRunSim(); + fRunSim = std::make_unique(); fMCSplitEventHeader = new FairMCSplitEventHeader(fRunId, 0, 0, 0); fRunSim->SetMCEventHeader(fMCSplitEventHeader); @@ -137,9 +135,13 @@ void FairMQTransportDevice::InitTask() } } -void FairMQTransportDevice::InitializeRun() +void FairMQTransportDevice::ResetTask() { + fRunSim.reset(); +} +void FairMQTransportDevice::InitializeRun() +{ // ----- Negotiate the run number ------------------------------------- // ----- via the fUpdateChannelName -------------------------------- // ----- ask the fParamMQServer ------------------------------------ @@ -231,9 +233,9 @@ bool FairMQTransportDevice::TransportData(fair::mq::Parts& mParts, int /*index*/ { TClonesArray* chunk = nullptr; FairMCSplitEventHeader* meh = nullptr; - for (int ipart = 0; ipart < mParts.Size(); ipart++) { + for (auto& part : mParts) { TObject* obj = nullptr; - RootSerializer().Deserialize(*mParts.At(ipart), obj); + RootSerializer().Deserialize(*part, obj); if (strcmp(obj->GetName(), "MCEvent") == 0) meh = dynamic_cast(obj); else if (strcmp(obj->GetName(), "TParticles") == 0) diff --git a/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.h b/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.h index c5d61a76fa..928941f280 100644 --- a/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.h +++ b/examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2017-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -17,6 +17,7 @@ #define FAIRMQTRANSPORTDEVICE_H_ #include "FairMQRunDevice.h" +#include "FairRunSim.h" #include #include @@ -25,7 +26,6 @@ #include class FairMCSplitEventHeader; -class FairRunSim; class FairField; class FairParIo; class TObjArray; @@ -65,6 +65,7 @@ class FairMQTransportDevice : public FairMQRunDevice // bool TransportData(fair::mq::MessagePtr&, int); void Init() override; void InitTask() override; + void ResetTask() override; void PreRun() override; void PostRun() override; bool ConditionalRun() override; @@ -81,7 +82,7 @@ class FairMQTransportDevice : public FairMQRunDevice TVirtualMC* fVMC; FairGenericStack* fStack; FairMCApplication* fMCApplication; - FairRunSim* fRunSim; + std::unique_ptr fRunSim; // ------ FairRunSim settings ------ int64_t fNofEvents; std::string fTransportName; diff --git a/examples/MQ/serialization/CMakeLists.txt b/examples/MQ/serialization/CMakeLists.txt index 588c34fa8d..c914cb8644 100644 --- a/examples/MQ/serialization/CMakeLists.txt +++ b/examples/MQ/serialization/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -22,11 +22,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator FairRoot::BaseMQ # Serialization policies diff --git a/examples/MQ/serialization/data_generator/RooDataGenerator.h b/examples/MQ/serialization/data_generator/RooDataGenerator.h index 0f673260ed..e63db62d05 100644 --- a/examples/MQ/serialization/data_generator/RooDataGenerator.h +++ b/examples/MQ/serialization/data_generator/RooDataGenerator.h @@ -92,7 +92,7 @@ class MultiVariatePDF , fT("t", "t", static_cast(tStart), static_cast(tStart + 1)) , fTErr("tErr", "tErr", fOpt.fTErr.fMin, fOpt.fTErr.fMax) , fMeanT("mu_t", "mean of t-distribution", (static_cast(tStart) + static_cast(tStart + 1)) / 2) - , fSigmaT("fSigmaT", "width of t-distribution", 0.1) + , fSigmaT("fSigmaT", "width of t-distribution", 0.1, 1e-4, 1000.) , fGaussX("fGaussX", "gaussian PDF", fX, RooFit::RooConst(fOpt.fX.fMean), RooFit::RooConst(fOpt.fX.fSigma)) , fGaussY("fGaussY", "gaussian PDF", fY, RooFit::RooConst(fOpt.fY.fMean), RooFit::RooConst(fOpt.fY.fSigma)) , fGaussZ("fGaussZ", "gaussian PDF", fZ, RooFit::RooConst(fOpt.fZ.fMean), RooFit::RooConst(fOpt.fZ.fSigma)) @@ -113,7 +113,7 @@ class MultiVariatePDF MultiVariatePDF(const MultiVariatePDF&) = delete; MultiVariatePDF operator=(const MultiVariatePDF&) = delete; - ~MultiVariatePDF() {} + ~MultiVariatePDF() = default; RooDataSet* GetGeneratedData(unsigned int n, unsigned int ti) { diff --git a/examples/MQ/serialization/data_generator/RootOutFileManager.h b/examples/MQ/serialization/data_generator/RootOutFileManager.h new file mode 100644 index 0000000000..2814f8ef0e --- /dev/null +++ b/examples/MQ/serialization/data_generator/RootOutFileManager.h @@ -0,0 +1,88 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef ROOTOUTFILEMANAGER_H +#define ROOTOUTFILEMANAGER_H + +// FairRoot +#include "FairLogger.h" +#include "FairMQ.h" // for fair::mq::Message, fair::mq::ProgOptions + +// ROOT +#include +#include +#include +#include +#include +#include + +// std +#include +#include +#include + +template +class RootOutFileManager +{ + public: + RootOutFileManager(const std::string& fileName, + const std::string& treeName, + const std::string& branchName, + const std::string& className) + : fFileName(fileName) + , fTreeName(treeName) + , fBranchName(branchName) + , fClassName(className) + , fTree(fTreeName.c_str(), "Test output") + , fFolder("cbmroot", "/cbmroot") + , fOutput(new TClonesArray(fClassName.c_str())) + { + fOutputFile.reset(TFile::Open(fFileName.c_str(), "RECREATE")); + fTree.Branch(fBranchName.c_str(), "TClonesArray", &fOutput); + + TList branchNameList; + branchNameList.AddLast(new TObjString(fBranchName.c_str())); + branchNameList.Write("BranchList", TObject::kSingleKey); + branchNameList.Delete(); + } + + RootOutFileManager(const RootOutFileManager&) = delete; + RootOutFileManager operator=(const RootOutFileManager&) = delete; + + void AddToFile(std::vector& inputData) + { + fOutput->Delete(); + for (unsigned int i = 0; i < inputData.size(); ++i) { + new ((*fOutput)[i]) DataType(inputData.at(i)); + } + if (fOutput->IsEmpty()) { + LOG(debug) << "RootOutFileManager::AddToFile(vector&): No Output array!"; + } + fTree.Fill(); + } + + virtual ~RootOutFileManager() + { + fTree.Write("", TObject::kOverwrite); + if (fOutput) { + delete fOutput; + } + } + + std::string fFileName; + std::string fTreeName; + std::string fBranchName; + std::string fClassName; + + std::unique_ptr fOutputFile; + TTree fTree; + TFolder fFolder; + TClonesArray* fOutput; +}; + +#endif /* ROOTOUTFILEMANAGER_H */ diff --git a/examples/MQ/serialization/data_generator/dataGenerator.cxx b/examples/MQ/serialization/data_generator/dataGenerator.cxx index efea8858eb..b5a373ef0e 100644 --- a/examples/MQ/serialization/data_generator/dataGenerator.cxx +++ b/examples/MQ/serialization/data_generator/dataGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,8 +16,6 @@ // this example #include "MyDigi.h" #include "RooDataGenerator.h" - -// FairRoot #include "RootOutFileManager.h" // root @@ -42,25 +40,26 @@ using std::string; using std::vector; // fill data payload and save to file -template -void SaveDataToFile(ManagerType& outMan, RooDataSet* dataset, bool printval = false); - -template -void SavePodDataToFile(ManagerType& outMan, RooDataSet* dataset, bool printval = false); - -typedef MyDigi TDigi; // non POD/complex data -typedef RootOutFileManager RootFileManager; +static void SaveDataToFile(RootOutFileManager& outMan, RooDataSet& dataset) +{ + vector dataBunch; + dataBunch.reserve(dataset.numEntries()); + for (int i = 0; i < dataset.numEntries(); i++) { + auto& data = dataBunch.emplace_back(); + data.SetTimeStamp(dataset.get(i)->getRealValue("t")); + data.SetTimeStampError(dataset.get(i)->getRealValue("tErr")); + data.SetX(static_cast(round(dataset.get(i)->getRealValue("x")))); + data.SetY(static_cast(round(dataset.get(i)->getRealValue("y")))); + data.SetZ(static_cast(round(dataset.get(i)->getRealValue("z")))); + } + outMan.AddToFile(dataBunch); +} int main(int argc, char** argv) { try { string filename; string treename; - string branchname; - string classname; - string fileoption; - bool useTClonesArray; - bool plotdata; unsigned int tmax; double nMean; double nSigma; @@ -70,16 +69,11 @@ int main(int argc, char** argv) po::options_description desc("Data generator options"); // clang-format off desc.add_options() - ("output-file", po::value(&filename)->required(), "Path to the output root file of generated data") - ("tree", po::value(&treename)->default_value("ExampleTree"), "Name of the tree") - ("branch", po::value(&branchname)->default_value("MyDigi"), "Name of the Branch") - ("class-name", po::value(&classname)->default_value("MyDigi"), "Name of the Payload class") - ("rootfile-option", po::value(&fileoption)->default_value("RECREATE"), "Root file option.") - ("use-TCA", po::value(&useTClonesArray)->default_value(true), "Store data bunches in TClonesArray") - ("plot-data", po::value(&plotdata)->default_value(false), "Plot generated data") - ("tmax", po::value(&tmax)->default_value(100), "max time index=bunch number") - ("Nmean", po::value(&nMean)->default_value(1595), "mean number of generated data / bunch") - ("Nsigma", po::value(&nSigma)->default_value(25.98), "std deviation of the number of generated data / bunch"); + ("output-file", po::value(&filename)->required(), "Path to the output root file of generated data") + ("tree", po::value(&treename)->default_value("ExampleTree"), "Name of the tree") + ("tmax", po::value(&tmax)->default_value(100), "max time index=bunch number") + ("Nmean", po::value(&nMean)->default_value(1595), "mean number of generated data / bunch") + ("Nsigma", po::value(&nSigma)->default_value(25.98), "std deviation of the number of generated data / bunch"); // clang-format on po::variables_map vm; @@ -99,9 +93,7 @@ int main(int argc, char** argv) } // Init output file manager - RootFileManager rootman; - rootman.SetFileProperties(filename, treename, branchname, classname, fileoption, useTClonesArray); - rootman.InitOutputFile(); + RootOutFileManager rootman(filename, treename, "MyDigi", "MyDigi"); // Init density function for the number of digi/bunch RdmVarParameters nval(nMean, nSigma); @@ -123,75 +115,13 @@ int main(int argc, char** argv) LOG(info) << "Bunch number " << t + 1 << "/" << tmax << " (" << 100. * static_cast(t + 1) / static_cast(tmax) << " %). Number of generated digis: " << nDigi - << ", payload = " << nDigi * (3 * sizeof(Int_t) + 2 * sizeof(Double_t)) << " bytes"; + << ", payload = " << nDigi * (3 * sizeof(int) + 2 * sizeof(Double_t)) << " bytes"; - std::unique_ptr simdataset(model.GetGeneratedData(nDigi, t)); - SaveDataToFile(rootman, simdataset.get()); + std::unique_ptr simDataSet(model.GetGeneratedData(nDigi, t)); + SaveDataToFile(rootman, *simDataSet); } LOG(info) << "Data generation successful"; - - // option : plot generated data - if (plotdata) { - RootFileManager man; - man.SetFileProperties(filename, treename, branchname, classname, "READ", useTClonesArray); - vector> data = man.GetAllObj(filename, treename, branchname); - - TH2D histoxy("fxy", - "digi.fxy", - 100, - pdfConfig.fX.fMin, - pdfConfig.fX.fMax, - 100, - pdfConfig.fY.fMin, - pdfConfig.fY.fMax); - TH1D histox("fx", "digi.fx", 100, pdfConfig.fX.fMin, pdfConfig.fX.fMax); - TH1D histoy("fy", "digi.fy", 100, pdfConfig.fY.fMin, pdfConfig.fY.fMax); - TH1D histoz("fz", "digi.fz", 100, pdfConfig.fZ.fMin, pdfConfig.fZ.fMax); - TH1D histot("ftimestamp", "digi.ftimestamp", 10 * tmax, 0., static_cast(tmax + 1)); - TH1D histoterr("ftimestampErr", "digi.ftimestampErr", 100, pdfConfig.fTErr.fMin, pdfConfig.fTErr.fMax); - TH1D histoN("f_N", "Number of digi distribution", 100, nval.fMin, nval.fMax); - - for (auto& p : data) { - histoN.Fill(static_cast(p.size())); - for (auto& q : p) { - histox.Fill(q.GetX()); - histoy.Fill(q.GetY()); - histoxy.Fill(q.GetX(), q.GetY()); - histoz.Fill(q.GetZ()); - histot.Fill(q.GetTimeStamp()); - histoterr.Fill(q.GetTimeStampError()); - } - } - - TApplication app("App", &argc, argv); - - TCanvas canvas("Tutorial7", "Tutorial7", 1000, 800); - canvas.Divide(4, 2); - - canvas.cd(1); - histox.Draw(); - - canvas.cd(2); - histoy.Draw(); - - canvas.cd(3); - histoxy.Draw("zcol"); - - canvas.cd(4); - histoz.Draw(); - - canvas.cd(5); - histot.Draw(); - - canvas.cd(6); - histoterr.Draw(); - - canvas.cd(7); - histoN.Draw(); - - app.Run(); - } } catch (std::exception& e) { LOG(error) << e.what(); return 1; @@ -199,49 +129,3 @@ int main(int argc, char** argv) return 0; } - -template -void SaveDataToFile(ManagerType& outMan, RooDataSet* dataset, bool printval) -{ - vector dataBunch; - for (int i = 0; i < dataset->numEntries(); i++) { - T data; - data.SetTimeStamp(dataset->get(i)->getRealValue("t")); - data.SetTimeStampError(dataset->get(i)->getRealValue("tErr")); - - data.SetX(static_cast(round(dataset->get(i)->getRealValue("x")))); - data.SetY(static_cast(round(dataset->get(i)->getRealValue("y")))); - data.SetZ(static_cast(round(dataset->get(i)->getRealValue("z")))); - - if (printval) { - LOG(info) << "x=" << data.GetX() << " y=" << data.GetY() << " z=" << data.GetZ() - << " t=" << data.GetTimeStamp() << " tErr=" << data.GetTimeStampError(); - } - dataBunch.push_back(data); - } - - outMan.AddToFile(dataBunch); -} - -template -void SavePodDataToFile(ManagerType& outMan, RooDataSet* dataset, bool printval) -{ - vector dataBunch; - for (int i = 0; i < dataset->numEntries(); i++) { - T data; - data.fTimeStamp = dataset->get(i)->getRealValue("t"); - data.fTimeStampError = dataset->get(i)->getRealValue("tErr"); - - data.fX = static_cast(round(dataset->get(i)->getRealValue("x"))); - data.fY = static_cast(round(dataset->get(i)->getRealValue("y"))); - data.fZ = static_cast(round(dataset->get(i)->getRealValue("z"))); - - if (printval) { - LOG(info) << "x=" << data.fX << " y=" << data.fY << " z=" << data.fZ << " t=" << data.fTimeStamp - << " tErr=" << data.fTimeStampError; - } - dataBunch.push_back(data); - } - - outMan.AddToFile(dataBunch); -} diff --git a/examples/MQ/serialization/processor.cxx b/examples/MQ/serialization/processor.cxx index fafa595f1a..ff6c917870 100644 --- a/examples/MQ/serialization/processor.cxx +++ b/examples/MQ/serialization/processor.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -56,7 +56,7 @@ struct Processor : fair::mq::Device partsOut.AddPart(std::move(partsIn.At(0))); partsOut.AddPart(NewMessage()); - BoostSerializer().Serialize(partsOut.AtRef(1), &hits); + BoostSerializer().Serialize(*partsOut.At(1), &hits); if (Send(partsOut, "data2") >= 0) { sentMsgs++; } diff --git a/examples/MQ/serialization/sampler.cxx b/examples/MQ/serialization/sampler.cxx index a32600e541..fbcb0082bd 100644 --- a/examples/MQ/serialization/sampler.cxx +++ b/examples/MQ/serialization/sampler.cxx @@ -33,17 +33,14 @@ namespace bpo = boost::program_options; struct Sampler : fair::mq::Device { - Sampler() - : fInput(nullptr) - , fTree(nullptr) - {} + Sampler() = default; void Init() override { fFileName = fConfig->GetValue("input-file"); fInputFile.reset(TFile::Open(fFileName.c_str(), "READ")); if (fInputFile) { - fTree = fInputFile->Get("cbmsim"); + fTree.reset(fInputFile->Get("cbmsim")); if (fTree) { fTree->SetBranchAddress("MyDigi", &fInput); } else { @@ -116,10 +113,10 @@ struct Sampler : fair::mq::Device return hits; } - TClonesArray* fInput; - TTree* fTree; + TClonesArray* fInput{nullptr}; std::string fFileName; std::unique_ptr fInputFile; + std::unique_ptr fTree; }; void addCustomOptions(bpo::options_description& options) diff --git a/examples/advanced/MbsTutorial/CMakeLists.txt b/examples/advanced/MbsTutorial/CMakeLists.txt index 21594c83fc..59bafabc65 100644 --- a/examples/advanced/MbsTutorial/CMakeLists.txt +++ b/examples/advanced/MbsTutorial/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -27,11 +27,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base diff --git a/examples/advanced/MbsTutorial/FairMBSRawItem.cxx b/examples/advanced/MbsTutorial/FairMBSRawItem.cxx index 465d15903b..b6ce9f1799 100644 --- a/examples/advanced/MbsTutorial/FairMBSRawItem.cxx +++ b/examples/advanced/MbsTutorial/FairMBSRawItem.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -50,5 +50,3 @@ FairMBSRawItem::FairMBSRawItem(const FairMBSRawItem& right) , fTacData(right.fTacData) , fQdcData(right.fQdcData) {} - -ClassImp(FairMBSRawItem); diff --git a/examples/advanced/MbsTutorial/FairMBSTask.cxx b/examples/advanced/MbsTutorial/FairMBSTask.cxx index ce6e68e357..ca84602307 100644 --- a/examples/advanced/MbsTutorial/FairMBSTask.cxx +++ b/examples/advanced/MbsTutorial/FairMBSTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,30 +10,15 @@ #include "FairMBSRawItem.h" #include "FairRootManager.h" -#include "FairRunOnline.h" #include -#include #include -#include - -FairMBSTask::FairMBSTask(const char* name, Int_t iVerbose) - : FairTask(name, iVerbose) - , fRawData(nullptr) - , fhQdc(nullptr) - , fhTac(nullptr) - , fhClock(nullptr) - , fhTacCh(nullptr) -{} InitStatus FairMBSTask::Init() { - FairRootManager* mgr = FairRootManager::Instance(); - if (nullptr == mgr) { - return kFATAL; - } + FairRootManager& mgr = fRunOnline.GetRootManager(); - fRawData = static_cast(mgr->GetObject("MBSRawItem")); + fRawData = static_cast(mgr.GetObject("MBSRawItem")); if (nullptr == fRawData) { return kERROR; } @@ -43,15 +28,10 @@ InitStatus FairMBSTask::Init() fhClock = new TH1F("hClock", "Raw Clock distribution", 64, 0., 64.); fhTacCh = new TH1F("hTacCh", "Raw TAC Channel distribution", 20, 0., 20.); - FairRunOnline* run = FairRunOnline::Instance(); - if (nullptr == run) { - return kERROR; - } - - run->AddObject(fhQdc); - run->RegisterHttpCommand("/Reset_hQdc", "/hQdc/->Reset()"); + fRunOnline.AddObject(fhQdc); + fRunOnline.RegisterHttpCommand("/Reset_hQdc", "/hQdc/->Reset()"); - TCanvas* c1 = new TCanvas("c1", "", 10, 10, 500, 500); + auto c1 = new TCanvas("c1", "", 10, 10, 500, 500); c1->Divide(2, 2); c1->cd(1); fhQdc->Draw(); @@ -62,14 +42,14 @@ InitStatus FairMBSTask::Init() c1->cd(4); fhTacCh->Draw(); c1->cd(0); - run->AddObject(c1); + fRunOnline.AddObject(c1); - TFolder* folder = new TFolder("MbsDetFolder", "Example Folder"); + auto folder = new TFolder("MbsDetFolder", "Example Folder"); folder->Add(fhQdc); folder->Add(fhTac); folder->Add(fhClock); folder->Add(fhTacCh); - run->AddObject(folder); + fRunOnline.AddObject(folder); return kSUCCESS; } @@ -80,9 +60,8 @@ void FairMBSTask::Exec(Option_t*) return; } Int_t nItems = fRawData->GetEntriesFast(); - FairMBSRawItem* item; for (Int_t i = 0; i < nItems; i++) { - item = static_cast(fRawData->At(i)); + auto item = static_cast(fRawData->At(i)); if (nullptr == item) { continue; } @@ -92,5 +71,3 @@ void FairMBSTask::Exec(Option_t*) fhTacCh->Fill(item->GetTacCh()); } } - -ClassImp(FairMBSTask); diff --git a/examples/advanced/MbsTutorial/FairMBSTask.h b/examples/advanced/MbsTutorial/FairMBSTask.h index 0501dfdea5..3a648f144e 100644 --- a/examples/advanced/MbsTutorial/FairMBSTask.h +++ b/examples/advanced/MbsTutorial/FairMBSTask.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,12 +9,12 @@ #ifndef _FAIRMBS_TASK_ #define _FAIRMBS_TASK_ +#include "FairRunOnline.h" #include "FairTask.h" #include - -class TClonesArray; -class TH1F; +#include +#include /** * An example analysis task for demonstartion of THttpServer usage. @@ -24,35 +24,30 @@ class FairMBSTask : public FairTask { public: /** Standard Constructor. */ - FairMBSTask(const char* name, Int_t iVerbose); + explicit FairMBSTask(FairRunOnline& run) + : FairTask("ExampleMBSTask") + , fRunOnline(run) + {} /** Destructor. */ - virtual ~FairMBSTask() {} + ~FairMBSTask() override = default; /** Initialization of the task. */ - virtual InitStatus Init(); + InitStatus Init() override; /** Process an event. */ - virtual void Exec(Option_t*); - - /** Called at the end of each event. */ - virtual void FinishEvent() {} - - /** Called at the end of task. */ - virtual void FinishTask() {} + void Exec(Option_t*) override; private: - TClonesArray* fRawData; /**< Array with input data. */ - TH1F* fhQdc; /**< Histogram object which is registered on http server. */ - TH1F* fhTac; - TH1F* fhClock; - TH1F* fhTacCh; - - FairMBSTask(const FairMBSTask&); - FairMBSTask& operator=(const FairMBSTask&); + TClonesArray* fRawData{nullptr}; /**< Array with input data. */ + TH1F* fhQdc{nullptr}; /**< Histogram object which is registered on http server. */ + TH1F* fhTac{nullptr}; + TH1F* fhClock{nullptr}; + TH1F* fhTacCh{nullptr}; + FairRunOnline& fRunOnline; //! public: - ClassDef(FairMBSTask, 1); + ClassDefOverride(FairMBSTask, 1); }; #endif diff --git a/examples/advanced/MbsTutorial/FairMBSUnpack.cxx b/examples/advanced/MbsTutorial/FairMBSUnpack.cxx index c01f87229f..4c9fe1f8f4 100644 --- a/examples/advanced/MbsTutorial/FairMBSUnpack.cxx +++ b/examples/advanced/MbsTutorial/FairMBSUnpack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -114,5 +114,3 @@ void FairMBSUnpack::Reset() fRawData->Clear(); fNHits = 0; } - -ClassImp(FairMBSUnpack); diff --git a/examples/advanced/MbsTutorial/README.md b/examples/advanced/MbsTutorial/README.md index d905b0410a..525102bd51 100644 --- a/examples/advanced/MbsTutorial/README.md +++ b/examples/advanced/MbsTutorial/README.md @@ -32,7 +32,7 @@ ActivateHttpServer() Histograms to be published can be added from an analysis task by: ~~~~~~~~~~~~~~~~~~ -FairRunOnline::Instance()->AddObject(h1); +fRunOnline.AddObject(h1); where h1 is of type TH1F* or TH2F* ~~~~~~~~~~~~~~~~~~ @@ -40,20 +40,20 @@ In addition, one can publish a canvas by using the same AddObject method. The ca ~~~~~~~~~~~~~~~~~~ TCanvas *c1 = new TCanvas("c1", "Title", 10, 10, 500, 500); h1->Draw(); -FairRunOnline::Instance()->AddObject(c1); +fRunOnline.AddObject(c1); ~~~~~~~~~~~~~~~~~~ In case of large amount of histogram objects for multiple detectors, the histograms can be organized in folder structure. ~~~~~~~~~~~~~~~~~~ TFolder *f1 = new TFolder("myfolder", "Title"); f1->Add(h1); -FairRunOnline::Instance()->AddObject(f1); +fRunOnline.AddObject(f1); ~~~~~~~~~~~~~~~~~~ Analysis task can also register a command, which can be executed on a histogram object: ~~~~~~~~~~~~~~~~~~ -FairRunOnline::Instance()->RegisterHttpCommand("/Reset_h1", "/h1/->Reset()"); +fRunOnline.RegisterHttpCommand("/Reset_h1", "/h1/->Reset()"); In this case the command will reset the histogram with name "h1" ~~~~~~~~~~~~~~~~~~ diff --git a/examples/advanced/MbsTutorial/unpack_mbs.C b/examples/advanced/MbsTutorial/unpack_mbs.C index 041c0fac72..d72115ab65 100644 --- a/examples/advanced/MbsTutorial/unpack_mbs.C +++ b/examples/advanced/MbsTutorial/unpack_mbs.C @@ -1,3 +1,5 @@ +#include +#include void unpack_mbs() { @@ -29,7 +31,7 @@ void unpack_mbs() // --------------------------------------------------------------------------- // Create analysis task ------------------------------------------------------ - FairMBSTask* task = new FairMBSTask("ExampleTask", 1); + auto task = new FairMBSTask(*run); run->AddTask(task); // --------------------------------------------------------------------------- diff --git a/examples/advanced/Tutorial3/CMakeLists.txt b/examples/advanced/Tutorial3/CMakeLists.txt index 9a6455827b..a64a1f551f 100644 --- a/examples/advanced/Tutorial3/CMakeLists.txt +++ b/examples/advanced/Tutorial3/CMakeLists.txt @@ -35,9 +35,9 @@ set(sources timeBasedSimulation/FairTestDetectorTimeDigiTask.cxx timeBasedSimulation/FairTestDetectorTimeRecoTask.cxx - $<$:${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayload.pb.cc> - $<$:${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayloadDigi_generated.h> - $<$:${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayloadHit_generated.h> + $<$:${CMAKE_CURRENT_BINARY_DIR}/Payload.pb.cc> + $<$:${CMAKE_CURRENT_BINARY_DIR}/PayloadDigi_generated.h> + $<$:${CMAKE_CURRENT_BINARY_DIR}/PayloadHit_generated.h> ) fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers) @@ -45,8 +45,8 @@ fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers) if(TARGET protobuf::libprotobuf) list(APPEND defs PROTOBUF) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayload.pb.h ${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayload.pb.cc - COMMAND $ -I=. --cpp_out=${CMAKE_CURRENT_BINARY_DIR} FairTestDetectorPayload.proto + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Payload.pb.h ${CMAKE_CURRENT_BINARY_DIR}/Payload.pb.cc + COMMAND $ -I=. --cpp_out=${CMAKE_CURRENT_BINARY_DIR} Payload.proto WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/MQ/data ) endif() @@ -55,13 +55,13 @@ if(Flatbuffers_FOUND) set(FLATBUFFERS_USED true) list(APPEND defs FLATBUFFERS) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayloadDigi_generated.h - COMMAND $ -c -o ${CMAKE_CURRENT_BINARY_DIR} FairTestDetectorPayloadDigi.fbs + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/PayloadDigi_generated.h + COMMAND $ -c -o ${CMAKE_CURRENT_BINARY_DIR} PayloadDigi.fbs WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/MQ/data ) add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FairTestDetectorPayloadHit_generated.h - COMMAND $ -c -o ${CMAKE_CURRENT_BINARY_DIR} FairTestDetectorPayloadHit.fbs + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/PayloadHit_generated.h + COMMAND $ -c -o ${CMAKE_CURRENT_BINARY_DIR} PayloadHit.fbs WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/MQ/data ) @@ -74,18 +74,7 @@ else() set(FLATBUFFERS_USED false) endif() -if(msgpack_FOUND) - set(MSGPACK_USED true) - list(APPEND defs MSGPACK) -else() - set(MSGPACK_USED false) -endif() - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/run/startMQTut3Three.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startMQTut3Three.sh) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/run/startMQTut3All.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startMQTut3All.sh) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/run/startMQTut3AllProxy.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startMQTut3AllProxy.sh) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/run/startMQTut3PushPull.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startMQTut3PushPull.sh) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/run/startMQTut3ExtraProcessor.sh.in ${CMAKE_CURRENT_BINARY_DIR}/startMQTut3ExtraProcessor.sh) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/start.sh.in ${CMAKE_CURRENT_BINARY_DIR}/start.sh) add_library(${target} SHARED ${sources} ${headers}) add_library(FairRoot::${target} ALIAS ${target}) @@ -109,11 +98,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator FairRoot::BaseMQ # Serialization policies @@ -127,7 +111,6 @@ target_link_libraries(${target} PUBLIC $<$:protobuf::libprotobuf> $<$:${flatbuffers_lib}> - $<$:msgpackc> ROOT::Physics # TVector3, TLorentzVector ROOT::Core # Rtypes @@ -150,18 +133,41 @@ fairroot_target_root_dictionary(${target} install(TARGETS ${target} LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}) install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -add_executable(tut3-sampler MQ/run/runTestDetectorSampler.cxx) +add_executable(tut3-sampler MQ/sampler.cxx) target_link_libraries(tut3-sampler PRIVATE FairRoot::BaseMQ FairRoot::ExTestDetector FairRoot::FairMQ) target_compile_definitions(tut3-sampler PRIVATE ${defs}) -add_executable(tut3-processor MQ/run/runTestDetectorProcessor.cxx) +add_executable(tut3-processor MQ/processor.cxx) target_link_libraries(tut3-processor PRIVATE FairRoot::BaseMQ FairRoot::ExTestDetector FairRoot::FairMQ) target_compile_definitions(tut3-processor PRIVATE ${defs}) -add_executable(tut3-sink MQ/run/runTestDetectorFileSink.cxx) +add_executable(tut3-sink MQ/sink.cxx) target_link_libraries(tut3-sink PRIVATE FairRoot::BaseMQ FairRoot::ExTestDetector FairRoot::FairMQ) target_compile_definitions(tut3-sink PRIVATE ${defs}) install(TARGETS tut3-sampler tut3-processor tut3-sink RUNTIME DESTINATION ${PROJECT_INSTALL_DATADIR}/examples/advanced/Tutorial3/bin ) + +# test script +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/MQ/test.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test.sh) + +macro(add_ex_tutorial3_mq_test serializationformat) + add_test(NAME ex_tutorial3_mq_${serializationformat} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh ${serializationformat}) + set_tests_properties(ex_tutorial3_mq_${serializationformat} PROPERTIES + TIMEOUT "30" + FIXTURES_REQUIRED fixture.ex_tutorial3_digi_TGeant4 + PASS_REGULAR_EXPRESSION "Received 100 messages!") +endmacro() + +add_ex_tutorial3_mq_test("tmessage") +add_ex_tutorial3_mq_test("binary") +add_ex_tutorial3_mq_test("boost") + +if(Flatbuffers_FOUND) + add_ex_tutorial3_mq_test("flatbuffers") +endif() + +if(Protobuf_FOUND) + add_ex_tutorial3_mq_test("protobuf") +endif() diff --git a/examples/advanced/Tutorial3/MQ/README.md b/examples/advanced/Tutorial3/MQ/README.md index 4010812f32..1ce68cc6bd 100644 --- a/examples/advanced/Tutorial3/MQ/README.md +++ b/examples/advanced/Tutorial3/MQ/README.md @@ -2,4 +2,26 @@ This part of Tutorial3 demonstrates how to transport data of Tutorial3 (FairTestDetector) via FairMQ. -- \subpage ex_tutorial3_mq_dataformat +## Data Format {#ex_tutorial3_mq_dataformat} + +Each device in this example implements several serialization approaches: + +- binary format +- boost::serialization +- Google FlatBuffers +- Google Protocol Buffers +- ROOT TMessage + +To choose specific format when running the device, provide it to the start script (binary is default): + +```bash +./start.sh +``` + +## Topology + +The devices are started in the following topology: + +sampler -> 2 processors -> sink + +Data is distributed round-robin between processors. diff --git a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayload.h b/examples/advanced/Tutorial3/MQ/data/Payload.h similarity index 67% rename from examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayload.h rename to examples/advanced/Tutorial3/MQ/data/Payload.h index 06d5a0e9a1..2590d17927 100644 --- a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayload.h +++ b/examples/advanced/Tutorial3/MQ/data/Payload.h @@ -1,21 +1,16 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/** - * TestDetectorPayload.h - * - * @since 2013-04-22 - * @author A. Rybalchenko - */ -#ifndef TESTDETECTORPAYLOAD_H_ -#define TESTDETECTORPAYLOAD_H_ +#ifndef FAIR_TESTDETECTOR_PAYLOAD_H +#define FAIR_TESTDETECTOR_PAYLOAD_H + +namespace Payload { -namespace TestDetectorPayload { class TimeStamp { public: @@ -43,6 +38,15 @@ class Hit : public TimeStamp Double_t dposY; Double_t dposZ; }; -} // namespace TestDetectorPayload -#endif /* TESTDETECTORPAYLOAD_H_ */ +// serialization types tags + +} // namespace Payload + +struct TestDetectorBin; +struct TestDetectorBoost; +struct TestDetectorFlatBuffers; +struct TestDetectorProtobuf; +struct TestDetectorTMessage; + +#endif /* FAIR_TESTDETECTOR_PAYLOAD_H */ diff --git a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayload.proto b/examples/advanced/Tutorial3/MQ/data/Payload.proto similarity index 100% rename from examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayload.proto rename to examples/advanced/Tutorial3/MQ/data/Payload.proto diff --git a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayloadDigi.fbs b/examples/advanced/Tutorial3/MQ/data/PayloadDigi.fbs similarity index 85% rename from examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayloadDigi.fbs rename to examples/advanced/Tutorial3/MQ/data/PayloadDigi.fbs index f12e027d18..cc3f1d91ae 100644 --- a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayloadDigi.fbs +++ b/examples/advanced/Tutorial3/MQ/data/PayloadDigi.fbs @@ -5,7 +5,7 @@ table Digi { y:int; z:int; timestamp:double; - timestampError:double; + timestamp_error:double; } table DigiPayload { diff --git a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayloadHit.fbs b/examples/advanced/Tutorial3/MQ/data/PayloadHit.fbs similarity index 77% rename from examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayloadHit.fbs rename to examples/advanced/Tutorial3/MQ/data/PayloadHit.fbs index 09397a8bef..d9e7df71b2 100644 --- a/examples/advanced/Tutorial3/MQ/data/FairTestDetectorPayloadHit.fbs +++ b/examples/advanced/Tutorial3/MQ/data/PayloadHit.fbs @@ -1,8 +1,8 @@ namespace TestDetectorFlat; table Hit { - detID:int; - mcIndex:int; + det_id:int; + mc_index:int; x:double; y:double; z:double; @@ -10,7 +10,7 @@ table Hit { dy:double; dz:double; timestamp:double; - timestampError:double; + timestamp_error:double; } table HitPayload { diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSink.h b/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSink.h deleted file mode 100644 index 92d4295040..0000000000 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSink.h +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * FairTestDetectorFileSink.h - * - * @since 2013-06-05 - * @author A. Rybalchenko - */ - -#ifndef FAIRTESTDETECTORFILESINK_H_ -#define FAIRTESTDETECTORFILESINK_H_ - -#include "FairMQ.h" // for fair::mq::Device -#include "FairTestDetectorHit.h" -#include "FairTestDetectorPayload.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -template -class FairTestDetectorFileSink : public fair::mq::Device -{ - public: - FairTestDetectorFileSink() - : fOutput(new TClonesArray("FairTestDetectorHit")) - , fOutFile(nullptr) - , fTree("MQOut", "Test output") - , fReceivedMsgs(0) - , fInChannelName("data2") - , fAckChannelName("ack") - { - gSystem->ResetSignal(kSigInterrupt); - gSystem->ResetSignal(kSigTermination); - } - - FairTestDetectorFileSink(const FairTestDetectorFileSink&) = delete; - FairTestDetectorFileSink operator=(const FairTestDetectorFileSink&) = delete; - - ~FairTestDetectorFileSink() override - { - fTree.Write(); - fOutFile->Close(); - } - - virtual void InitOutputFile(const std::string& defaultId = "100") - { - std::string filename("filesink_" + defaultId + ".root"); - fOutFile = std::unique_ptr(TFile::Open(filename.c_str(), "recreate")); - fTree.Branch("Output", "TClonesArray", fOutput.get(), 64000, 99); - } - - protected: - void Init() override - { - fInChannelName = fConfig->GetValue("in-channel"); - fAckChannelName = fConfig->GetValue("ack-channel"); - - InitOutputFile(fConfig->GetValue("data-format")); - } - - void PostRun() override { LOG(info) << "Received " << fReceivedMsgs << " messages!"; } - - void InitTask() override; - - private: - std::unique_ptr fOutput; - std::unique_ptr fOutFile; - TTree fTree; - int fReceivedMsgs; - std::string fInChannelName; - std::string fAckChannelName; -}; - -// Template implementation of Run() in FairTestDetectorFileSink.tpl : -#include "FairTestDetectorFileSinkBin.tpl" -#include "FairTestDetectorFileSinkBoost.tpl" -#include "FairTestDetectorFileSinkFlatBuffers.tpl" -#include "FairTestDetectorFileSinkMsgpack.tpl" -#include "FairTestDetectorFileSinkProtobuf.tpl" -#include "FairTestDetectorFileSinkTMessage.tpl" - -#endif /* FAIRTESTDETECTORFILESINK_H_ */ diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkMsgpack.tpl b/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkMsgpack.tpl deleted file mode 100644 index b350bddfeb..0000000000 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkMsgpack.tpl +++ /dev/null @@ -1,164 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -// Implementation of FairTestDetectorFileSink::Run() with Msgpack data format - -#ifdef MSGPACK - -#include - -struct MsgPack -{}; -// struct MsgPackRef { msgpack::vrefbuffer* container; void* content; }; -// struct MsgPackStream {}; - -template<> -void FairTestDetectorFileSink::InitTask() -{ - OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { - ++fReceivedMsgs; - - // deserialize - - std::vector> hits; - - msgpack::unpacked unpackedHits; - - size_t offset = 0; - - msgpack::unpack(unpackedHits, static_cast(msg->GetData()), msg->GetSize(), offset); - - msgpack::object hitsObj = unpackedHits.get(); - - hitsObj.convert(hits); - - int numEntries = hits.size(); - - fOutput->Delete(); - - for (int i = 0; i < numEntries; ++i) { - TVector3 pos(std::get<2>(hits.at(i)), std::get<3>(hits.at(i)), std::get<4>(hits.at(i))); - TVector3 dpos(std::get<5>(hits.at(i)), std::get<6>(hits.at(i)), std::get<7>(hits.at(i))); - new ((*fOutput)[i]) FairTestDetectorHit(std::get<0>(hits.at(i)), std::get<1>(hits.at(i)), pos, dpos); - } - - if (fOutput->IsEmpty()) { - LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; - } - - auto ack(fTransportFactory->CreateMessage()); - fChannels.at(fAckChannelName).at(0).Send(ack); - - fTree.Fill(); - - return true; - }); -} - -// template <> -// void FairTestDetectorFileSink::Run() -// { -// int receivedMsgs = 0; - -// // channel references to avoid traversing the map on every loop iteration -// FairMQChannel& dataInChannel = fChannels.at("data-in").at(0); - -// while (CheckCurrentState(RUNNING)) -// { -// FairMQMessagePtr msg(fTransportFactory->CreateMessage()); - -// if (dataInChannel.Receive(msg) > 0) -// { -// receivedMsgs++; - -// msgpack::unpacked pmsg; -// msgpack::unpack(&pmsg, static_cast(msg->GetData()), msg->GetSize()); -// msgpack::object hitsObj = pmsg.get(); - -// std::vector> hits; -// hitsObj.convert(&hits); - -// int numEntries = hits.size(); - -// fOutput->Clear(); - -// for (int i = 0; i < numEntries; ++i) -// { -// TVector3 pos(std::get<2>(hits.at(i)), std::get<3>(hits.at(i)), std::get<4>(hits.at(i))); -// TVector3 dpos(std::get<5>(hits.at(i)), std::get<6>(hits.at(i)), std::get<7>(hits.at(i))); -// new ((*fOutput)[i]) FairTestDetectorHit(std::get<0>(hits.at(i)), std::get<1>(hits.at(i)), pos, dpos); -// } - -// if (fOutput->IsEmpty()) -// { -// LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; -// } - -// FairMQMessagePtr ack(fTransportFactory->CreateMessage()); -// fChannels.at("ack-out").at(0).Send(ack); - -// fTree->Fill(); -// } -// } - -// LOG(info) << "I've received " << receivedMsgs << " messages!"; -// } - -// template <> -// void FairTestDetectorFileSink::Run() -// { -// int receivedMsgs = 0; - -// // channel references to avoid traversing the map on every loop iteration -// FairMQChannel& dataInChannel = fChannels.at("data-in").at(0); - -// while (CheckCurrentState(RUNNING)) -// { -// FairMQMessagePtr msg(fTransportFactory->CreateMessage()); - -// if (dataInChannel.Receive(msg) > 0) -// { -// receivedMsgs++; - -// fOutput->Clear(); - -// msgpack::unpacker pac; - -// pac.reserve_buffer(msg->GetSize()); -// memcpy(pac.buffer(), msg->GetData(), msg->GetSize()); -// pac.buffer_consumed(msg->GetSize()); - -// msgpack::unpacked umsg; - -// int numEntries = 0; -// while (pac.next(&umsg)) -// { -// msgpack::object hitObj = umsg.get(); -// msgpack::type::tuple hit; -// hitObj.convert(&hit); -// TVector3 pos(std::get<2>(hits.at(i)), std::get<3>(hits.at(i)), std::get<4>(hits.at(i))); -// TVector3 dpos(std::get<5>(hits.at(i)), std::get<6>(hits.at(i)), std::get<7>(hits.at(i))); -// new ((*fOutput)[i]) FairTestDetectorHit(std::get<0>(hits.at(i)), std::get<1>(hits.at(i)), pos, dpos); -// numEntries++; -// } - -// if (fOutput->IsEmpty()) -// { -// LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; -// } - -// FairMQMessagePtr ack(fTransportFactory->CreateMessage()); -// fChannels.at("ack-out").at(0).Send(ack); - -// fTree->Fill(); -// } -// } - -// LOG(info) << "I've received " << receivedMsgs << " messages!"; -// } - -#endif /* MSGPACK */ diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FileSink.h b/examples/advanced/Tutorial3/MQ/fileSink/FileSink.h new file mode 100644 index 0000000000..a5887f1dda --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/fileSink/FileSink.h @@ -0,0 +1,80 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_TESTDETECTOR_FILESINK_H +#define FAIR_TESTDETECTOR_FILESINK_H + +// this example +#include "FairTestDetectorHit.h" +#include "Payload.h" + +// FairRoot +#include "FairMQ.h" // for fair::mq::Device + +// ROOT +#include +#include +#include +#include +#include + +// logger +#include + +// std +#include +#include + +template +class FileSink : public fair::mq::Device +{ + public: + FileSink() + : fOutput(new TClonesArray("FairTestDetectorHit")) + , fOutFile(nullptr) + , fTree("MQOut", "Test output") + , fInChannelName("data2") + { + gSystem->ResetSignal(kSigInterrupt); + gSystem->ResetSignal(kSigTermination); + } + + FileSink(const FileSink&) = delete; + FileSink operator=(const FileSink&) = delete; + + ~FileSink() override + { + fTree.Write(); + delete fOutput; + } + + void Init() override + { + fInChannelName = fConfig->GetValue("in-channel"); + fMaxMsgs = fConfig->GetValue("max-msgs"); + + std::string format = fConfig->GetValue("data-format"); + std::string filename("filesink_" + format + ".root"); + fOutFile = std::unique_ptr(TFile::Open(filename.c_str(), "recreate")); + fTree.Branch("Output", "TClonesArray", fOutput, 64000, 99); + } + + void PostRun() override { LOG(info) << "Received " << fReceivedMsgs << " messages!"; } + + void InitTask() override; + + private: + TClonesArray* fOutput; + std::unique_ptr fOutFile; + TTree fTree; + uint64_t fReceivedMsgs = 0; + uint64_t fMaxMsgs = 0; + std::string fInChannelName; +}; + +#endif /* FAIR_TESTDETECTOR_FILESINK_H */ diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkBin.tpl b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkBin.h similarity index 59% rename from examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkBin.tpl rename to examples/advanced/Tutorial3/MQ/fileSink/FileSinkBin.h index 8b79eb945e..ad0cc7ee36 100644 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkBin.tpl +++ b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkBin.h @@ -1,29 +1,28 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorFileSink.tpl - * Author: winckler, A. Rybalchenko - * - * Created on March 11, 2014, 12:12 PM - */ -// Implementation of FairTestDetectorFileSink::Run() with pure binary transport data format +// Implementation of FileSink::Run() with pure binary transport data format + +#ifndef FAIR_TESTDETECTOR_FILESINK_BIN_H +#define FAIR_TESTDETECTOR_FILESINK_BIN_H + +#include "Payload.h" template<> -void FairTestDetectorFileSink::InitTask() +void FileSink::InitTask() { OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { ++fReceivedMsgs; fOutput->Delete(); - int numEntries = msg->GetSize() / sizeof(TestDetectorPayload::Hit); + int numEntries = msg->GetSize() / sizeof(Payload::Hit); - TestDetectorPayload::Hit* input = static_cast(msg->GetData()); + Payload::Hit* input = static_cast(msg->GetData()); for (int i = 0; i < numEntries; ++i) { TVector3 pos(input[i].posX, input[i].posY, input[i].posZ); @@ -32,14 +31,19 @@ void FairTestDetectorFileSink::In } if (fOutput->IsEmpty()) { - LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; + LOG(error) << "FileSink::Run(): No Output array!"; } - auto ack(fTransportFactory->CreateMessage()); - fChannels.at(fAckChannelName).at(0).Send(ack); - fTree.Fill(); + if (fMaxMsgs != 0) { + if (fReceivedMsgs == fMaxMsgs) { + return false; + } + } + return true; }); } + +#endif // FAIR_TESTDETECTOR_FILESINK_BIN_H diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkBoost.tpl b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkBoost.h similarity index 52% rename from examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkBoost.tpl rename to examples/advanced/Tutorial3/MQ/fileSink/FileSinkBoost.h index a8b5774764..b269471159 100644 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkBoost.tpl +++ b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkBoost.h @@ -1,40 +1,41 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorFileSink.tpl - * Author: winckler, A. Rybalchenko - * - * Created on March 11, 2014, 12:12 PM - */ -// Implementation of FairTestDetectorFileSink::Run() with Boost transport data format +// Implementation of FileSink::Run() with Boost transport data format + +#ifndef FAIR_TESTDETECTOR_FILESINK_BOOST_H +#define FAIR_TESTDETECTOR_FILESINK_BOOST_H #include "BoostSerializer.h" +#include "Payload.h" -// example TIn: FairTestDetectorHit -// example TPayloadIn: boost::archive::binary_iarchive -template -void FairTestDetectorFileSink::InitTask() +template<> +void FileSink::InitTask() { OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { ++fReceivedMsgs; - BoostSerializer().Deserialize(*msg, fOutput); + BoostSerializer().Deserialize(*msg, fOutput); if (fOutput->IsEmpty()) { - LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; + LOG(error) << "FileSink::Run(): No Output array!"; } - auto ack(NewMessage()); - Send(ack, fAckChannelName); - fTree.Fill(); + if (fMaxMsgs != 0) { + if (fReceivedMsgs == fMaxMsgs) { + return false; + } + } + return true; }); } + +#endif // FAIR_TESTDETECTOR_FILESINK_BOOST_H diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkFlatBuffers.tpl b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkFlatBuffers.h similarity index 68% rename from examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkFlatBuffers.tpl rename to examples/advanced/Tutorial3/MQ/fileSink/FileSinkFlatBuffers.h index b261daff15..5e1e0640ae 100644 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkFlatBuffers.tpl +++ b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkFlatBuffers.h @@ -1,19 +1,24 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -// Implementation of FairTestDetectorFileSink::Run() with Google FlatBuffers transport data format + +// Implementation of FileSink::Run() with Google FlatBuffers transport data format + +#ifndef FAIR_TESTDETECTOR_FILESINK_FLATBUFFERS_H +#define FAIR_TESTDETECTOR_FILESINK_FLATBUFFERS_H #ifdef FLATBUFFERS -#include "FairTestDetectorPayloadHit_generated.h" +#include "Payload.h" +#include "PayloadHit_generated.h" #include "flatbuffers/flatbuffers.h" template<> -void FairTestDetectorFileSink::InitTask() +void FileSink::InitTask() { OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { ++fReceivedMsgs; @@ -27,22 +32,27 @@ void FairTestDetectorFileSink for (auto it = hits->begin(); it != hits->end(); ++it) { TVector3 pos((*it)->x(), (*it)->y(), (*it)->z()); TVector3 dpos((*it)->dx(), (*it)->dy(), (*it)->dz()); - new ((*fOutput)[it - hits->begin()]) FairTestDetectorHit((*it)->detID(), (*it)->mcIndex(), pos, dpos); + new ((*fOutput)[it - hits->begin()]) FairTestDetectorHit((*it)->det_id(), (*it)->mc_index(), pos, dpos); // LOG(warn) << " " << (*it)->detID() << " " << (*it)->x() << " " << (*it)->y() << " " << (*it)->z() << " " // << (*it)->dx() << " " << (*it)->dy() << " " << (*it)->dz(); } if (fOutput->IsEmpty()) { - LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; + LOG(error) << "FileSink::Run(): No Output array!"; } - auto ack(fTransportFactory->CreateMessage()); - fChannels.at(fAckChannelName).at(0).Send(ack); - fTree.Fill(); + if (fMaxMsgs != 0) { + if (fReceivedMsgs == fMaxMsgs) { + return false; + } + } + return true; }); } -#endif /* FLATBUFFERS */ +#endif // FLATBUFFERS + +#endif // FAIR_TESTDETECTOR_FILESINK_FLATBUFFERS_H diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkProtobuf.tpl b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkProtobuf.h similarity index 66% rename from examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkProtobuf.tpl rename to examples/advanced/Tutorial3/MQ/fileSink/FileSinkProtobuf.h index 30743a3626..012168c73d 100644 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkProtobuf.tpl +++ b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkProtobuf.h @@ -1,24 +1,23 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorFileSink.tpl - * Author: winckler, A. Rybalchenko - * - * Created on March 11, 2014, 12:12 PM - */ -// Implementation of FairTestDetectorFileSink::Run() with Google Protocol Buffers transport data format +// Implementation of FileSink::Run() with Google Protocol Buffers transport data format + +#ifndef FAIR_TESTDETECTOR_FILESINK_PROTOBUF_H +#define FAIR_TESTDETECTOR_FILESINK_PROTOBUF_H #ifdef PROTOBUF -#include "FairTestDetectorPayload.pb.h" + +#include "Payload.h" +#include "Payload.pb.h" template<> -void FairTestDetectorFileSink::InitTask() +void FileSink::InitTask() { OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { ++fReceivedMsgs; @@ -37,16 +36,21 @@ void FairTestDetectorFileSinkIsEmpty()) { - LOG(error) << "FairTestDetectorFileSink::Run(): No Output array!"; + LOG(error) << "FileSink::Run(): No Output array!"; } - auto ack(fTransportFactory->CreateMessage()); - fChannels.at(fAckChannelName).at(0).Send(ack); - fTree.Fill(); + if (fMaxMsgs != 0) { + if (fReceivedMsgs == fMaxMsgs) { + return false; + } + } + return true; }); } -#endif /* PROTOBUF */ +#endif // PROTOBUF + +#endif // FAIR_TESTDETECTOR_FILESINK_PROTOBUF_H diff --git a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkTMessage.tpl b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkTMessage.h similarity index 63% rename from examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkTMessage.tpl rename to examples/advanced/Tutorial3/MQ/fileSink/FileSinkTMessage.h index 8dab2a06ab..c7ee419dc4 100644 --- a/examples/advanced/Tutorial3/MQ/fileSink/FairTestDetectorFileSinkTMessage.tpl +++ b/examples/advanced/Tutorial3/MQ/fileSink/FileSinkTMessage.h @@ -1,23 +1,21 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorFileSink.tpl - * Author: winckler, A. Rybalchenko - * - * Created on March 11, 2014, 12:12 PM - */ -// Implementation of FairTestDetectorFileSink::Run() with Root TMessage transport data format +// Implementation of FileSink::Run() with Root TMessage transport data format +#ifndef FAIR_TESTDETECTOR_FILESINK_TMESSAGE_H +#define FAIR_TESTDETECTOR_FILESINK_TMESSAGE_H + +#include "Payload.h" #include "RootSerializer.h" template<> -void FairTestDetectorFileSink::InitTask() +void FileSink::InitTask() { OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { ++fReceivedMsgs; @@ -25,12 +23,16 @@ void FairTestDetectorFileSink::InitTask() RootSerializer().Deserialize(*msg, fOutput); fTree.SetBranchAddress("Output", &fOutput); - - auto ack(fTransportFactory->CreateMessage()); - fChannels.at(fAckChannelName).at(0).Send(ack); - fTree.Fill(); + if (fMaxMsgs != 0) { + if (fReceivedMsgs == fMaxMsgs) { + return false; + } + } + return true; }); } + +#endif // FAIR_TESTDETECTOR_FILESINK_TMESSAGE_H diff --git a/examples/advanced/Tutorial3/MQ/processor.cxx b/examples/advanced/Tutorial3/MQ/processor.cxx new file mode 100644 index 0000000000..bf54778b17 --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/processor.cxx @@ -0,0 +1,133 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +// this example +#include "MQRecoTask.h" +#include "MQRecoTaskBin.h" +#include "MQRecoTaskBoost.h" +#include "MQRecoTaskFlatBuffers.h" +#include "MQRecoTaskProtobuf.h" +#include "MQRecoTaskTMessage.h" +#include "ProcessorTask.h" + +// FairRoot +#include "FairMQ.h" // for fair::mq::Device, fair::mq::MessagePtr +#include "FairRunFairMQDevice.h" + +// logger +#include + +// std +#include // std::quoted +#include +#include + +namespace bpo = boost::program_options; + +template +class Processor : public fair::mq::Device +{ + public: + Processor() + : fProcessorTask(new Task) + , fInChannelName("data1") + , fOutChannelName("data2") + , fReceivedMsgs(0) + , fSentMsgs(0) + {} + + /// Copy Constructor + Processor(const Processor&) = delete; + Processor operator=(const Processor&) = delete; + + virtual ~Processor() {} + + protected: + virtual void InitTask() + { + std::string inChannelName = fConfig->GetValue("in-channel"); + std::string outChannelName = fConfig->GetValue("out-channel"); + // check if the returned value actually exists, for the compatibility with old devices. + if (inChannelName != "") { + fInChannelName = inChannelName; + } + if (outChannelName != "") { + fOutChannelName = outChannelName; + } + + fProcessorTask->InitTask(); + OnData(fInChannelName, [this](fair::mq::MessagePtr& msg, int /*index*/) { + ++fReceivedMsgs; + fProcessorTask->SetPayload(msg); + fProcessorTask->Exec("0"); + fProcessorTask->GetPayload(msg); + + Send(msg, fOutChannelName); + ++fSentMsgs; + + return true; + }); + } + + virtual void PostRun() { LOG(info) << "Received " << fReceivedMsgs << " and sent " << fSentMsgs << " messages!"; } + + private: + std::unique_ptr fProcessorTask; + std::string fInChannelName; + std::string fOutChannelName; + int fReceivedMsgs; + int fSentMsgs; +}; + +void addCustomOptions(bpo::options_description& options) +{ + // clang-format off + options.add_options() + ("in-channel", bpo::value()->default_value("data1"), "Name of the input channel") + ("out-channel", bpo::value()->default_value("data2"), "Name of the output channel") + ("data-format", bpo::value()->default_value("binary"), "Data format (binary|boost|flatbuffers|protobuf|tmessage)"); + // clang-format on +} + +std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) +{ + std::string dataFormat = config.GetValue("data-format"); + + LOG(info) << "Starting Processor with " << dataFormat << " data serialization"; + + if (dataFormat == "binary") { + return std::make_unique>>(); + } else if (dataFormat == "boost") { + return std::make_unique>>(); + } else if (dataFormat == "tmessage") { + return std::make_unique>>(); + } +#ifdef FLATBUFFERS + else if (dataFormat == "flatbuffers") { + return std::make_unique>>(); + } +#endif +#ifdef PROTOBUF + else if (dataFormat == "protobuf") { + return std::make_unique>>(); + } +#endif + else { + std::stringstream ss; + ss << "Invalid valid data format provided (--data-format): " << std::quoted(dataFormat) + << ", available are: binary, boost, tmessage" +#ifdef FLATBUFFERS + << ", flatbuffers" +#endif +#ifdef PROTOBUF + << ", protobuf" +#endif + ; + throw std::runtime_error(ss.str()); + } +} diff --git a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskBoost.tpl b/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskBoost.tpl deleted file mode 100644 index 9dbad58054..0000000000 --- a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskBoost.tpl +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/* - * File: FairTestDetectorMQRecoTask.tpl - * Author: winckler - * - * Created on March 11, 2014, 11:07 AM - */ - -// Implementation of FairTestDetectorMQRecoTask::Exec() with Boost transport data format - -#include "BoostSerializer.h" - -// example TIn: FairTestDetectorDigi -// example TOut: FairTestDetectorHit -// example TPayloadIn: boost::archive::binary_iarchive -// example TPayloadOut: boost::archive::binary_oarchive -template -void FairTestDetectorMQRecoTask::Exec(Option_t* opt) -{ - BoostSerializer().Deserialize(*fPayload, fRecoTask.fDigiArray); - - if (!fRecoTask.fDigiArray) { - LOG(error) << "FairTestDetectorMQRecoTask::Exec(): No Point array!"; - } - - fRecoTask.Exec(opt); - - BoostSerializer().Serialize(*fPayload, fRecoTask.fHitArray); -} diff --git a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskMsgpack.tpl b/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskMsgpack.tpl deleted file mode 100644 index 114c0720a0..0000000000 --- a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskMsgpack.tpl +++ /dev/null @@ -1,182 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * File: FairTestDetectorMQRecoTaskMsgpack.tpl - * @since 2014-12-12 - * @author: A. Rybalchenko - */ - -// Implementation of FairTestDetectorMQRecoTask::Exec() with Msgpack data format - -#ifdef MSGPACK - -#include - -// Types to be used as template parameters. -struct MsgPack -{}; -// struct MsgPackRef { msgpack::vrefbuffer vbuf; std::vector> hits; }; struct MsgPackStream {}; - -template<> -void FairTestDetectorMQRecoTask::Exec(Option_t* opt) -{ - // deserialize - - std::vector> digis; - - msgpack::unpacked unpackedDigis; - - size_t offset = 0; - - msgpack::unpack(unpackedDigis, static_cast(fPayload->GetData()), fPayload->GetSize(), offset); - - msgpack::object digisObj = unpackedDigis.get(); - - digisObj.convert(digis); - - int numEntries = digis.size(); - - fRecoTask.fDigiArray->Clear(); - - for (int i = 0; i < numEntries; ++i) { - new ((*fRecoTask.fDigiArray)[i]) FairTestDetectorDigi( - std::get<0>(digis.at(i)), std::get<1>(digis.at(i)), std::get<2>(digis.at(i)), std::get<3>(digis.at(i))); - static_cast(((*fRecoTask.fDigiArray)[i]))->SetTimeStampError(std::get<4>(digis.at(i))); - } - - if (!fRecoTask.fDigiArray) { - LOG(error) << "FairTestDetectorMQRecoTask::Exec(): No Point array!"; - } - - // execute task on the deserialized data (digis) - - fRecoTask.Exec(opt); - - // serialize the task results (hits) - - msgpack::sbuffer* sbuf = new msgpack::sbuffer(); - msgpack::packer packer(sbuf); - - std::vector> hits; - - for (int i = 0; i < numEntries; ++i) { - FairTestDetectorHit* hit = static_cast(fRecoTask.fHitArray->At(i)); - hits.push_back(std::make_tuple(hit->GetDetectorID(), - hit->GetRefIndex(), - hit->GetX(), - hit->GetY(), - hit->GetZ(), - hit->GetDx(), - hit->GetDy(), - hit->GetDz())); - } - - packer.pack(hits); - - fPayload->Rebuild( - sbuf->data(), - sbuf->size(), - [](void* /* data */, void* obj) { delete static_cast(obj); }, - sbuf); -} - -// MsgPackRef version sends the vector of tuples without copying it into the sbuffer -// void free_vrefbuffer(void *data, void *hint) -// { -// delete static_cast(hint); -// } - -// template <> -// void FairTestDetectorMQRecoTask::Exec(Option_t* -// opt) -// { -// msgpack::unpacked msg; -// msgpack::unpack(&msg, static_cast(fPayload->GetData()), fPayload->GetSize()); -// msgpack::object digisObj = msg.get(); - -// std::vector> digis; -// digisObj.convert(&digis); - -// int numEntries = digis.size(); - -// fRecoTask.fDigiArray->Clear(); - -// for (int i = 0; i < numEntries; ++i) -// { -// new ((*fRecoTask.fDigiArray)[i]) FairTestDetectorDigi(std::get<0>(digis.at(i)), std::get<1>(digis.at(i)), -// std::get<2>(digis.at(i)), std::get<3>(digis.at(i))); -// } - -// if (!fRecoTask.fDigiArray) -// { -// LOG(error) << "FairTestDetectorMQRecoTask::Exec(): No Point array!"; -// } - -// fRecoTask.Exec(opt); - -// MsgPackRef* container = new MsgPackRef(); - -// for (int i = 0; i < numEntries; ++i) -// { -// FairTestDetectorHit* hit = static_cast(fRecoTask.fHitArray->At(i)); -// container->hits.push_back(std::make_tuple(hit->GetDetectorID(), hit->GetX(), hit->GetY(), hit->GetZ(), -// hit->GetDx(), hit->GetDy(), hit->GetDz())); -// } - -// msgpack::pack(container->vbuf, container->hits); - -// fPayload->Rebuild(container->vbuf.vector()->iov_base, container->vbuf.vector()->iov_len, free_vrefbuffer, -// container); -// } - -// template <> -// void FairTestDetectorMQRecoTask::Exec(Option_t* opt) -// { -// fRecoTask.fDigiArray->Clear(); - -// msgpack::unpacker pac; - -// pac.reserve_buffer(fPayload->GetSize()); -// memcpy(pac.buffer(), fPayload->GetData(), fPayload->GetSize()); -// pac.buffer_consumed(fPayload->GetSize()); - -// msgpack::unpacked msg; - -// int numEntries = 0; -// while (pac.next(&msg)) -// { -// msgpack::object digiObj = msg.get(); -// msgpack::type::tuple digi; -// digiObj.convert(&digi); -// new ((*fRecoTask.fDigiArray)[numEntries]) FairTestDetectorDigi(std::get<0>(digi), std::get<1>(digi), -// std::get<2>(digi), std::get<3>(digi)); numEntries++; -// } - -// if (!fRecoTask.fDigiArray) -// { -// LOG(error) << "FairTestDetectorMQRecoTask::Exec(): No Point array!"; -// } - -// fRecoTask.Exec(opt); - -// msgpack::sbuffer* sbuf = new msgpack::sbuffer(); -// msgpack::packer packer(sbuf); - -// for (int i = 0; i < numEntries; ++i) -// { -// FairTestDetectorHit* hit = static_cast(fRecoTask.fHitArray->At(i)); -// packer.pack(std::make_tuple(hit->GetDetectorID(), hit->GetX(), hit->GetY(), hit->GetZ(), hit->GetDx(), -// hit->GetDy(), hit->GetDz())); -// } - -// fPayload->Rebuild(sbuf->data(), sbuf->size(), free_sbuffer, sbuf); -// } - -#endif /* MSGPACK */ diff --git a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTask.h b/examples/advanced/Tutorial3/MQ/processorTask/MQRecoTask.h similarity index 57% rename from examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTask.h rename to examples/advanced/Tutorial3/MQ/processorTask/MQRecoTask.h index 2420d37cce..f5b70f1b3a 100644 --- a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTask.h +++ b/examples/advanced/Tutorial3/MQ/processorTask/MQRecoTask.h @@ -1,39 +1,46 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#ifndef FAIRTESTDETECTORMQRECOTASK_H -#define FAIRTESTDETECTORMQRECOTASK_H -#include "FairMQProcessorTask.h" -#include "FairRootManager.h" +#ifndef FAIR_TESTDETECTOR_MQRECOTASK_H +#define FAIR_TESTDETECTOR_MQRECOTASK_H + +// this example #include "FairTestDetectorDigi.h" #include "FairTestDetectorHit.h" -#include "FairTestDetectorPayload.h" #include "FairTestDetectorRecoTask.h" +#include "Payload.h" +#include "ProcessorTask.h" + +// FairRoot +#include "FairRootManager.h" +// ROOT #include + +// logger #include -template -class FairTestDetectorMQRecoTask : public FairMQProcessorTask +template +class MQRecoTask : public ProcessorTask { public: - FairTestDetectorMQRecoTask() + MQRecoTask() : fRecoTask() {} - FairTestDetectorMQRecoTask(Int_t /*verbose*/) + MQRecoTask(Int_t /*verbose*/) : fRecoTask() {} - FairTestDetectorMQRecoTask(const FairTestDetectorMQRecoTask&) = delete; - FairTestDetectorMQRecoTask operator=(const FairTestDetectorMQRecoTask&) = delete; + MQRecoTask(const MQRecoTask&) = delete; + MQRecoTask operator=(const MQRecoTask&) = delete; - ~FairTestDetectorMQRecoTask() override + ~MQRecoTask() override { if (fRecoTask.fDigiArray) { fRecoTask.fDigiArray->Delete(); @@ -60,12 +67,4 @@ class FairTestDetectorMQRecoTask : public FairMQProcessorTask FairTestDetectorRecoTask fRecoTask; }; -// Template implementation of exec in FairTestDetectorMQRecoTask.tpl : -#include "FairTestDetectorMQRecoTaskBin.tpl" -#include "FairTestDetectorMQRecoTaskBoost.tpl" -#include "FairTestDetectorMQRecoTaskFlatBuffers.tpl" -#include "FairTestDetectorMQRecoTaskMsgpack.tpl" -#include "FairTestDetectorMQRecoTaskProtobuf.tpl" -#include "FairTestDetectorMQRecoTaskTMessage.tpl" - -#endif /* FAIRTESTDETECTORMQRECOTASK_H */ +#endif /* FAIR_TESTDETECTOR_MQRECOTASK_H */ diff --git a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskBin.tpl b/examples/advanced/Tutorial3/MQ/processorTask/MQRecoTaskBin.h similarity index 62% rename from examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskBin.tpl rename to examples/advanced/Tutorial3/MQ/processorTask/MQRecoTaskBin.h index 1ab3846e24..f735fdb092 100644 --- a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskBin.tpl +++ b/examples/advanced/Tutorial3/MQ/processorTask/MQRecoTaskBin.h @@ -1,28 +1,25 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorMQRecoTask.tpl - * Author: winckler - * - * Created on March 11, 2014, 11:07 AM - */ - -// Implementation of FairTestDetectorMQRecoTask::Exec() with pure binary transport data format + +// Implementation of MQRecoTask::Exec() with pure binary transport data format + +#ifndef FAIR_TESTDETECTOR_PROCESSORTASK_BIN_H +#define FAIR_TESTDETECTOR_PROCESSORTASK_BIN_H + +#include "Payload.h" + template<> -void FairTestDetectorMQRecoTask::Exec(Option_t* opt) +void MQRecoTask::Exec(Option_t* opt) { int inputSize = fPayload->GetSize(); - int numEntries = inputSize / sizeof(TestDetectorPayload::Digi); + int numEntries = inputSize / sizeof(Payload::Digi); - TestDetectorPayload::Digi* input = static_cast(fPayload->GetData()); + Payload::Digi* input = static_cast(fPayload->GetData()); fRecoTask.fDigiArray->Clear(); @@ -33,16 +30,16 @@ void FairTestDetectorMQRecoTaskRebuild(hitsSize); - TestDetectorPayload::Hit* output = static_cast(fPayload->GetData()); + Payload::Hit* output = static_cast(fPayload->GetData()); if (inputSize > 0) { for (int i = 0; i < numEntries; ++i) { @@ -59,3 +56,5 @@ void FairTestDetectorMQRecoTask +void MQRecoTask::Exec(Option_t* opt) +{ + BoostSerializer().Deserialize(*fPayload, fRecoTask.fDigiArray); + + if (!fRecoTask.fDigiArray) { + LOG(error) << "MQRecoTask::Exec(): No Point array!"; + } + + fRecoTask.Exec(opt); + + BoostSerializer().Serialize(*fPayload, fRecoTask.fHitArray); +} + +#endif // FAIR_TESTDETECTOR_PROCESSORTASK_BOOST_H diff --git a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskFlatBuffers.tpl b/examples/advanced/Tutorial3/MQ/processorTask/MQRecoTaskFlatBuffers.h similarity index 62% rename from examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskFlatBuffers.tpl rename to examples/advanced/Tutorial3/MQ/processorTask/MQRecoTaskFlatBuffers.h index 8c4010b1a8..4f6f79bf29 100644 --- a/examples/advanced/Tutorial3/MQ/processorTask/FairTestDetectorMQRecoTaskFlatBuffers.tpl +++ b/examples/advanced/Tutorial3/MQ/processorTask/MQRecoTaskFlatBuffers.h @@ -1,23 +1,25 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -// Implementation of FairTestDetectorMQRecoTask::Exec() with Google FlatBuffers transport data format + +// Implementation of MQRecoTask::Exec() with Google FlatBuffers transport data format + +#ifndef FAIR_TESTDETECTOR_PROCESSORTASK_FLATBUFFERS_H +#define FAIR_TESTDETECTOR_PROCESSORTASK_FLATBUFFERS_H #ifdef FLATBUFFERS -#include "FairTestDetectorPayloadDigi_generated.h" -#include "FairTestDetectorPayloadHit_generated.h" +#include "Payload.h" +#include "PayloadDigi_generated.h" +#include "PayloadHit_generated.h" #include "flatbuffers/flatbuffers.h" template<> -void FairTestDetectorMQRecoTask::Exec(Option_t* opt) +void MQRecoTask::Exec(Option_t* opt) { fRecoTask.fDigiArray->Clear(); @@ -29,13 +31,13 @@ void FairTestDetectorMQRecoTaskbegin()]) FairTestDetectorDigi((*it)->x(), (*it)->y(), (*it)->z(), (*it)->timestamp()); static_cast(((*fRecoTask.fDigiArray)[it - digis->begin()])) - ->SetTimeStampError((*it)->timestampError()); + ->SetTimeStampError((*it)->timestamp_error()); // LOG(info) << (*it)->x() << " " << (*it)->y() << " " << (*it)->z() << " " << (*it)->timestamp() << " " << - // (*it)->timestampError(); + // (*it)->timestamp_error(); } if (!fRecoTask.fDigiArray) { - LOG(error) << "FairTestDetectorMQRecoTask::Exec(): No Point array!"; + LOG(error) << "MQRecoTask::Exec(): No Point array!"; } fRecoTask.Exec(opt); @@ -51,16 +53,16 @@ void FairTestDetectorMQRecoTaskGetDetectorID() << " " << hit->GetX() << " " << hit->GetY() << " " << hit->GetZ() << // " " << hit->GetDx() << " " << hit->GetDy() << " " << hit->GetDz(); TestDetectorFlat::HitBuilder hb(*builder); - hb.add_detID(hit->GetDetectorID()); // detID:int - hb.add_mcIndex(hit->GetRefIndex()); // GetRefIndex:int - hb.add_x(hit->GetX()); // x:double - hb.add_y(hit->GetY()); // y:double - hb.add_z(hit->GetZ()); // z:double - hb.add_dx(hit->GetDx()); // dx:double - hb.add_dy(hit->GetDy()); // dy:double - hb.add_dz(hit->GetDz()); // dz:double - hb.add_timestamp(hit->GetTimeStamp()); // timestamp:double - hb.add_timestampError(hit->GetTimeStampError()); // timestampError:double + hb.add_det_id(hit->GetDetectorID()); // det_id:int + hb.add_mc_index(hit->GetRefIndex()); // GetRefIndex:int + hb.add_x(hit->GetX()); // x:double + hb.add_y(hit->GetY()); // y:double + hb.add_z(hit->GetZ()); // z:double + hb.add_dx(hit->GetDx()); // dx:double + hb.add_dy(hit->GetDy()); // dy:double + hb.add_dz(hit->GetDz()); // dz:double + hb.add_timestamp(hit->GetTimeStamp()); // timestamp:double + hb.add_timestamp_error(hit->GetTimeStampError()); // timestamp_error:double hits[i] = hb.Finish(); } auto hvector = builder->CreateVector(hits, numEntries); @@ -76,4 +78,6 @@ void FairTestDetectorMQRecoTask -void FairTestDetectorMQRecoTask::Exec(Option_t* opt) +void MQRecoTask::Exec(Option_t* opt) { fRecoTask.fDigiArray->Clear(); @@ -37,7 +33,7 @@ void FairTestDetectorMQRecoTask -void FairTestDetectorMQRecoTask::Exec(Option_t* opt) +void MQRecoTask::Exec(Option_t* opt) { RootSerializer().Deserialize(*fPayload, fRecoTask.fDigiArray); fRecoTask.Exec(opt); RootSerializer().Serialize(*fPayload, fRecoTask.fHitArray); } + +#endif // FAIR_TESTDETECTOR_PROCESSORTASK_TMESSAGE_H diff --git a/examples/advanced/Tutorial3/MQ/processorTask/ProcessorTask.h b/examples/advanced/Tutorial3/MQ/processorTask/ProcessorTask.h new file mode 100644 index 0000000000..5d13a236aa --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/processorTask/ProcessorTask.h @@ -0,0 +1,31 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_TESTDETECTOR_PROCESSORTASK_H +#define FAIR_TESTDETECTOR_PROCESSORTASK_H + +#include "FairMQ.h" // for fair::mq::Message +#include "FairTask.h" + +class ProcessorTask : public FairTask +{ + public: + ProcessorTask() = default; + ProcessorTask(const ProcessorTask&) = delete; + ProcessorTask operator=(const ProcessorTask&) = delete; + + ~ProcessorTask() override = default; + + void SetPayload(std::unique_ptr& msg) { fPayload = std::move(msg); } + void GetPayload(std::unique_ptr& msg) { msg = std::move(fPayload); } + + protected: + std::unique_ptr fPayload; +}; + +#endif /* FAIR_TESTDETECTOR_PROCESSORTASK_H */ diff --git a/examples/advanced/Tutorial3/MQ/run/README.md b/examples/advanced/Tutorial3/MQ/run/README.md deleted file mode 100644 index 98e3321d10..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Data Format {#ex_tutorial3_mq_dataformat} - -Each device in this example implements several serialization approaches: - -- binary format -- boost::serialization -- Google FlatBuffers -- Google Protocol Buffers -- Msgpack -- ROOT TMessage - -To choose specific format when running the device, provide it to the start script (binary is default): - -```bash -./startMQTut3All.sh -``` - -## Topologies - -The devices can be started in different topologies: - -- `startMQTut3Three` : sampler -> processor -> sink -- `startMQTut3All` : sampler -> splitter -> 3 processors -> merger -> sink -- `startMQTut3AllProxy` : sampler -> proxy -> 3 processors -> proxy -> sink -- `startMQTut3PushPull` : sampler -> 2 processors -> sink (load-balanced/round robin between processors) -- `startMQTut3ExtraProcessor` : additional processor to plug into PushPull topology diff --git a/examples/advanced/Tutorial3/MQ/run/runTestDetectorFileSink.cxx b/examples/advanced/Tutorial3/MQ/run/runTestDetectorFileSink.cxx deleted file mode 100644 index a0a4536fb8..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/runTestDetectorFileSink.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "FairRunFairMQDevice.h" -#include "FairTestDetectorFileSink.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - // clang-format off - options.add_options() - ("in-channel", bpo::value()->default_value("data2"), "Name of the input channel") - ("ack-channel", bpo::value()->default_value("ack"), "Name of the acknowledgement channel") - ("data-format", bpo::value()->default_value("binary"), "Data format (binary|boost|flatbuffers|msgpack|protobuf|tmessage)"); - // clang-format on -} - -std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) -{ - std::string dataFormat = config.GetValue("data-format"); - - if (dataFormat == "binary") { - using Sink = FairTestDetectorFileSink; - return std::make_unique(); - } else if (dataFormat == "boost") { - if (fair::base::serialization::has_BoostSerialization::value - == 0) { - LOG(error) << "Boost serialization for Input Payload requested, but the input type does not support it. " - "Check the TIn parameter. Aborting."; - return {nullptr}; - } - using Sink = FairTestDetectorFileSink; - return std::make_unique(); - } else if (dataFormat == "tmessage") { - using Sink = FairTestDetectorFileSink; - return std::make_unique(); - } -#ifdef FLATBUFFERS - else if (dataFormat == "flatbuffers") { - using Sink = FairTestDetectorFileSink; - return std::make_unique(); - } -#endif -#ifdef MSGPACK - else if (dataFormat == "msgpack") { - using Sink = FairTestDetectorFileSink; - return std::make_unique(); - } -#endif -#ifdef PROTOBUF - else if (dataFormat == "protobuf") { - using Sink = FairTestDetectorFileSink; - return std::make_unique(); - } -#endif - else { - LOG(error) - << "No valid data format provided. (--data-format binary|boost|flatbuffers|msgpack|protobuf|tmessage). "; - return {nullptr}; - } -} diff --git a/examples/advanced/Tutorial3/MQ/run/runTestDetectorProcessor.cxx b/examples/advanced/Tutorial3/MQ/run/runTestDetectorProcessor.cxx deleted file mode 100644 index 835566f995..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/runTestDetectorProcessor.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "FairMQProcessor.h" -#include "FairRunFairMQDevice.h" -#include "FairTestDetectorMQRecoTask.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - // clang-format off - options.add_options() - ("in-channel", bpo::value()->default_value("data1"), "Name of the input channel") - ("out-channel", bpo::value()->default_value("data2"), "Name of the output channel") - ("data-format", bpo::value()->default_value("binary"), "Data format (binary|boost|flatbuffers|msgpack|protobuf|tmessage)"); - // clang-format on -} - -std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) -{ - std::string dataFormat = config.GetValue("data-format"); - - if (dataFormat == "binary") { - using Processor = FairMQProcessor>; - return std::make_unique(); - } else if (dataFormat == "boost") { - if (fair::base::serialization::has_BoostSerialization::value - == 0) { - LOG(error) << "Boost serialization for Input Payload requested, but the input type does not support it. " - "Check the TIn parameter. Aborting."; - return {nullptr}; - } - if (fair::base::serialization::has_BoostSerialization::value - == 0) { - LOG(error) << "Boost serialization for Output Payload requested, but the output type does not support it. " - "Check the TOut parameter. Aborting."; - return {nullptr}; - } - using Processor = FairMQProcessor>; - return std::make_unique(); - } else if (dataFormat == "tmessage") { - using Processor = - FairMQProcessor>; - return std::make_unique(); - } -#ifdef FLATBUFFERS - else if (dataFormat == "flatbuffers") { - using Processor = FairMQProcessor>; - return std::make_unique(); - } -#endif -#ifdef MSGPACK - else if (dataFormat == "msgpack") { - using Processor = - FairMQProcessor>; - return std::make_unique(); - } -#endif -#ifdef PROTOBUF - else if (dataFormat == "protobuf") { - using Processor = FairMQProcessor>; - return std::make_unique(); - } -#endif - else { - LOG(error) - << "No valid data format provided. (--data-format binary|boost|flatbuffers|msgpack|protobuf|tmessage). "; - return {nullptr}; - } -} diff --git a/examples/advanced/Tutorial3/MQ/run/runTestDetectorSampler.cxx b/examples/advanced/Tutorial3/MQ/run/runTestDetectorSampler.cxx deleted file mode 100644 index cd9fde3f4b..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/runTestDetectorSampler.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ - -#include "FairMQSampler.h" -#include "FairRunFairMQDevice.h" -#include "FairTestDetectorDigiLoader.h" - -namespace bpo = boost::program_options; - -void addCustomOptions(bpo::options_description& options) -{ - // clang-format off - options.add_options() - ("data-format", bpo::value()->default_value("binary"), "Data format (binary|boost|flatbuffers|msgpack|protobuf|tmessage)") - ("input-file", bpo::value()->required(), "Path to the input file") - ("parameter-file", bpo::value()->default_value(""), "Path to the parameter file") - ("branch", bpo::value()->default_value("FairTestDetectorDigi"), "Name of the Branch") - ("out-channel", bpo::value()->default_value("data1"), "Name of the output channel") - ("ack-channel", bpo::value()->default_value("ack"), "Name of the acknowledgement channel") - ("chain-input", bpo::value()->default_value(0), "Chain input file more than once (default)"); - // clang-format on -} - -std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) -{ - std::string dataFormat = config.GetValue("data-format"); - - if (dataFormat == "binary") { - using Sampler = FairMQSampler>; - return std::make_unique(); - } else if (dataFormat == "boost") { - if (fair::base::serialization::has_BoostSerialization::value - == 0) { - LOG(error) << "Boost serialization for Output Payload requested, but the output type does not support it. " - "Check the TOut parameter. Aborting."; - return {nullptr}; - } - using Sampler = - FairMQSampler>; - return std::make_unique(); - } else if (dataFormat == "tmessage") { - using Sampler = FairMQSampler>; - return std::make_unique(); - } -#ifdef FLATBUFFERS - else if (dataFormat == "flatbuffers") { - using Sampler = FairMQSampler>; - return std::make_unique(); - } -#endif -#ifdef MSGPACK - else if (dataFormat == "msgpack") { - using Sampler = FairMQSampler>; - return std::make_unique(); - } -#endif -#ifdef PROTOBUF - else if (dataFormat == "protobuf") { - using Sampler = FairMQSampler>; - return std::make_unique(); - } -#endif - else { - LOG(error) - << "No valid data format provided. (--data-format binary|boost|flatbuffers|msgpack|protobuf|tmessage). "; - exit(EXIT_FAILURE); - } -} diff --git a/examples/advanced/Tutorial3/MQ/run/startMQTut3All.sh.in b/examples/advanced/Tutorial3/MQ/run/startMQTut3All.sh.in deleted file mode 100755 index d19e053d15..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/startMQTut3All.sh.in +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -mcEngine="TGeant3" - -echo "Supported data formats: binary, boost, boost-text, flatbuffers, msgpack, protobuf, tmessage" -dataFormat="binary" -if [ "$1" = "binary" ]; then - echo "Using: binary" -elif [ "$1" = "boost" ]; then - dataFormat="boost" - echo "Using: boost (Boost binary)" -elif [ "$1" = "flatbuffers" ]; then - if(@FLATBUFFERS_USED@); then - dataFormat="flatbuffers" - echo "Using: flatbuffers (Google FlatBuffers)" - else - echo "Cannot use flatbuffers: library not found at build time" - exit 1 - fi -elif [ "$1" = "msgpack" ]; then - if(@MSGPACK_USED@); then - dataFormat="msgpack" - echo "Using: msgpack (MessagePack)" - else - echo "Cannot use msgpack: library not found at build time" - exit 1 - fi -elif [ "$1" = "protobuf" ]; then - if(@PROTOBUF_USED@); then - dataFormat="protobuf" - echo "Using: protobuf (Google Protocol Buffers)" - else - echo "Cannot use protobuf: library not found at build time" - exit 1 - fi -elif [ "$1" = "tmessage" ]; then - dataFormat="tmessage" - echo "Using: tmessage (Root TMessage)" -else - echo "None or incorrect data format provided!" - echo "Using: binary" -fi - -SAMPLER="tut3-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --data-format $dataFormat" -SAMPLER+=" --severity info" -SAMPLER+=" --chain-input 99" -SAMPLER+=" --input-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testdigi_$mcEngine.root" -SAMPLER+=" --parameter-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testparams_$mcEngine.root" -SAMPLER+=" --channel-config name=data1,type=push,method=connect,address=tcp://localhost:5565" -SAMPLER+=" name=ack,type=pull,method=bind,address=tcp://localhost:5999" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & - -SPLITTER="fairmq-splitter" -SPLITTER+=" --id splitter" -SPLITTER+=" --in-channel data1" -SPLITTER+=" --out-channel data2" -SPLITTER+=" --channel-config name=data1,type=pull,method=bind,address=tcp://localhost:5565" -SPLITTER+=" name=data2,type=push,method=bind,address=tcp://localhost:5566,address=tcp://localhost:5567,address=tcp://localhost:5568" -xterm -geometry 80x23+0+350 -hold -e @FairMQ_BINDIR@/$SPLITTER & - -PROCESSOR1="tut3-processor" -PROCESSOR1+=" --id processor1" -PROCESSOR1+=" --in-channel data2" -PROCESSOR1+=" --out-channel data3" -PROCESSOR1+=" --channel-config name=data2,type=pull,method=connect,address=tcp://localhost:5566" -PROCESSOR1+=" name=data3,type=push,method=connect,address=tcp://localhost:5569" -PROCESSOR1+=" --data-format $dataFormat" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 & - -PROCESSOR2="tut3-processor" -PROCESSOR2+=" --id processor2" -PROCESSOR2+=" --in-channel data2" -PROCESSOR2+=" --out-channel data3" -PROCESSOR2+=" --channel-config name=data2,type=pull,method=connect,address=tcp://localhost:5567" -PROCESSOR2+=" name=data3,type=push,method=connect,address=tcp://localhost:5570" -PROCESSOR2+=" --data-format $dataFormat" -xterm -geometry 80x23+500+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & - -PROCESSOR3="tut3-processor" -PROCESSOR3+=" --id processor3" -PROCESSOR3+=" --in-channel data2" -PROCESSOR3+=" --out-channel data3" -PROCESSOR3+=" --channel-config name=data2,type=pull,method=connect,address=tcp://localhost:5568" -PROCESSOR3+=" name=data3,type=push,method=connect,address=tcp://localhost:5571" -PROCESSOR3+=" --data-format $dataFormat" -xterm -geometry 80x23+500+700 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR3 & - -MERGER="fairmq-merger" -MERGER+=" --id merger" -MERGER+=" --in-channel data3" -MERGER+=" --out-channel data4" -MERGER+=" --channel-config name=data3,type=pull,method=bind,address=tcp://localhost:5569,address=tcp://localhost:5570,address=tcp://localhost:5571" -MERGER+=" name=data4,type=push,method=bind,address=tcp://localhost:5572" -xterm -geometry 80x23+1000+0 -hold -e @FairMQ_BINDIR@/$MERGER & - -FILESINK="tut3-sink" -FILESINK+=" --id sink1" -FILESINK+=" --in-channel data4" -FILESINK+=" --channel-config name=data4,type=pull,method=connect,address=tcp://localhost:5572" -FILESINK+=" name=ack,type=push,method=connect,address=tcp://localhost:5999" -FILESINK+=" --data-format $dataFormat" -xterm -geometry 80x23+1000+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$FILESINK & diff --git a/examples/advanced/Tutorial3/MQ/run/startMQTut3AllProxy.sh.in b/examples/advanced/Tutorial3/MQ/run/startMQTut3AllProxy.sh.in deleted file mode 100755 index 885b55eab0..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/startMQTut3AllProxy.sh.in +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -mcEngine="TGeant3" - -echo "Supported data formats: binary, boost, boost-text, flatbuffers, msgpack, protobuf, tmessage" -dataFormat="binary" -if [ "$1" = "binary" ]; then - echo "Using: binary" -elif [ "$1" = "boost" ]; then - dataFormat="boost" - echo "Using: boost (Boost binary)" -elif [ "$1" = "flatbuffers" ]; then - if(@FLATBUFFERS_USED@); then - dataFormat="flatbuffers" - echo "Using: flatbuffers (Google FlatBuffers)" - else - echo "Cannot use flatbuffers: library not found at build time" - exit 1 - fi -elif [ "$1" = "msgpack" ]; then - if(@MSGPACK_USED@); then - dataFormat="msgpack" - echo "Using: msgpack (MessagePack)" - else - echo "Cannot use msgpack: library not found at build time" - exit 1 - fi -elif [ "$1" = "protobuf" ]; then - if(@PROTOBUF_USED@); then - dataFormat="protobuf" - echo "Using: protobuf (Google Protocol Buffers)" - else - echo "Cannot use protobuf: library not found at build time" - exit 1 - fi -elif [ "$1" = "tmessage" ]; then - dataFormat="tmessage" - echo "Using: tmessage (Root TMessage)" -else - echo "None or incorrect data format provided!" - echo "Using: binary" -fi - -SAMPLER="tut3-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --data-format $dataFormat" -SAMPLER+=" --severity info" -SAMPLER+=" --chain-input 99" -SAMPLER+=" --input-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testdigi_$mcEngine.root" -SAMPLER+=" --parameter-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testparams_$mcEngine.root" -SAMPLER+=" --channel-config name=data1,type=push,method=connect,address=tcp://localhost:5565" -SAMPLER+=" name=ack,type=pull,method=bind,address=tcp://localhost:5999" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & - -PROXY1="fairmq-proxy" -PROXY1+=" --id proxy1" -PROXY1+=" --in-channel data1" -PROXY1+=" --out-channel data2" -PROXY1+=" --channel-config name=data1,type=pull,method=bind,address=tcp://localhost:5565" -PROXY1+=" name=data2,type=push,method=bind,address=tcp://localhost:5566" -xterm -geometry 80x23+0+350 -hold -e @FairMQ_BINDIR@/$PROXY1 & - -PROCESSOR1="tut3-processor" -PROCESSOR1+=" --id processor1" -PROCESSOR1+=" --in-channel data2" -PROCESSOR1+=" --out-channel data3" -PROCESSOR1+=" --data-format $dataFormat" -PROCESSOR1+=" --channel-config name=data2,type=pull,method=connect,address=tcp://localhost:5566" -PROCESSOR1+=" name=data3,type=push,method=connect,address=tcp://localhost:5567" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 & - -PROCESSOR2="tut3-processor" -PROCESSOR2+=" --id processor2" -PROCESSOR2+=" --in-channel data2" -PROCESSOR2+=" --out-channel data3" -PROCESSOR2+=" --data-format $dataFormat" -PROCESSOR2+=" --channel-config name=data2,type=pull,method=connect,address=tcp://localhost:5566" -PROCESSOR2+=" name=data3,type=push,method=connect,address=tcp://localhost:5567" -xterm -geometry 80x23+500+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & - -PROCESSOR3="tut3-processor" -PROCESSOR3+=" --id processor3" -PROCESSOR3+=" --in-channel data2" -PROCESSOR3+=" --out-channel data3" -PROCESSOR3+=" --data-format $dataFormat" -PROCESSOR3+=" --channel-config name=data2,type=pull,method=connect,address=tcp://localhost:5566" -PROCESSOR3+=" name=data3,type=push,method=connect,address=tcp://localhost:5567" -xterm -geometry 80x23+500+700 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR3 & - -PROXY2="fairmq-proxy" -PROXY2+=" --id proxy2" -PROXY2+=" --in-channel data3" -PROXY2+=" --out-channel data4" -PROXY2+=" --channel-config name=data3,type=pull,method=bind,address=tcp://localhost:5567" -PROXY2+=" name=data4,type=push,method=bind,address=tcp://localhost:5570" -xterm -geometry 80x23+1000+0 -hold -e @FairMQ_BINDIR@/$PROXY2 & - -FILESINK="tut3-sink" -FILESINK+=" --id sink1" -FILESINK+=" --in-channel data4" -FILESINK+=" --data-format $dataFormat" -FILESINK+=" --channel-config name=data4,type=pull,method=connect,address=tcp://localhost:5570" -FILESINK+=" name=ack,type=push,method=connect,address=tcp://localhost:5999" -xterm -geometry 80x23+1000+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$FILESINK & \ No newline at end of file diff --git a/examples/advanced/Tutorial3/MQ/run/startMQTut3ExtraProcessor.sh.in b/examples/advanced/Tutorial3/MQ/run/startMQTut3ExtraProcessor.sh.in deleted file mode 100755 index 8980136ab7..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/startMQTut3ExtraProcessor.sh.in +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -echo "Supported data formats: binary, boost, boost-text, flatbuffers, msgpack, protobuf, tmessage" -dataFormat="binary" -if [ "$1" = "binary" ]; then - echo "Using: binary" -elif [ "$1" = "boost" ]; then - dataFormat="boost" - echo "Using: boost (Boost binary)" -elif [ "$1" = "flatbuffers" ]; then - if(@FLATBUFFERS_USED@); then - dataFormat="flatbuffers" - echo "Using: flatbuffers (Google FlatBuffers)" - else - echo "Cannot use flatbuffers: library not found at build time" - exit 1 - fi -elif [ "$1" = "msgpack" ]; then - if(@MSGPACK_USED@); then - dataFormat="msgpack" - echo "Using: msgpack (MessagePack)" - else - echo "Cannot use msgpack: library not found at build time" - exit 1 - fi -elif [ "$1" = "protobuf" ]; then - if(@PROTOBUF_USED@); then - dataFormat="protobuf" - echo "Using: protobuf (Google Protocol Buffers)" - else - echo "Cannot use protobuf: library not found at build time" - exit 1 - fi -elif [ "$1" = "tmessage" ]; then - dataFormat="tmessage" - echo "Using: tmessage (Root TMessage)" -else - echo "None or incorrect data format provided!" - echo "Using: binary" -fi - -PROCESSOR2="tut3-processor" -PROCESSOR2+=" --id extraProcessor" -PROCESSOR2+=" --data-format $dataFormat" -PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565" -PROCESSOR2+=" name=data2,type=push,method=connect,address=tcp://localhost:5570" -PROCESSOR2+=" --data-format $dataFormat" -xterm -geometry 80x23+500+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & diff --git a/examples/advanced/Tutorial3/MQ/run/startMQTut3PushPull.sh.in b/examples/advanced/Tutorial3/MQ/run/startMQTut3PushPull.sh.in deleted file mode 100755 index 9b6643cdd6..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/startMQTut3PushPull.sh.in +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - -mcEngine="TGeant3" - -echo "Supported data formats: binary, boost, boost-text, flatbuffers, msgpack, protobuf, tmessage" -dataFormat="binary" -if [ "$1" = "binary" ]; then - echo "Using: binary" -elif [ "$1" = "boost" ]; then - dataFormat="boost" - echo "Using: boost (Boost binary)" -elif [ "$1" = "flatbuffers" ]; then - if(@FLATBUFFERS_USED@); then - dataFormat="flatbuffers" - echo "Using: flatbuffers (Google FlatBuffers)" - else - echo "Cannot use flatbuffers: library not found at build time" - exit 1 - fi -elif [ "$1" = "msgpack" ]; then - if(@MSGPACK_USED@); then - dataFormat="msgpack" - echo "Using: msgpack (MessagePack)" - else - echo "Cannot use msgpack: library not found at build time" - exit 1 - fi -elif [ "$1" = "protobuf" ]; then - if(@PROTOBUF_USED@); then - dataFormat="protobuf" - echo "Using: protobuf (Google Protocol Buffers)" - else - echo "Cannot use protobuf: library not found at build time" - exit 1 - fi -elif [ "$1" = "tmessage" ]; then - dataFormat="tmessage" - echo "Using: tmessage (Root TMessage)" -else - echo "None or incorrect data format provided!" - echo "Using: binary" -fi - -SAMPLER="tut3-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --data-format $dataFormat" -SAMPLER+=" --severity info" -SAMPLER+=" --chain-input 99" -SAMPLER+=" --input-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testdigi_$mcEngine.root" -SAMPLER+=" --parameter-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testparams_$mcEngine.root" -SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=tcp://localhost:5565" -SAMPLER+=" name=ack,type=pull,method=bind,address=tcp://localhost:5999" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & - -PROCESSOR1="tut3-processor" -PROCESSOR1+=" --id processor1" -PROCESSOR1+=" --data-format $dataFormat" -PROCESSOR1+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565" -PROCESSOR1+=" name=data2,type=push,method=connect,address=tcp://localhost:5570" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 & - -PROCESSOR2="tut3-processor" -PROCESSOR2+=" --id processor2" -PROCESSOR2+=" --data-format $dataFormat" -PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565" -PROCESSOR2+=" name=data2,type=push,method=connect,address=tcp://localhost:5570" -xterm -geometry 80x23+500+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & - -FILESINK="tut3-sink" -FILESINK+=" --id sink1" -FILESINK+=" --data-format $dataFormat" -FILESINK+=" --channel-config name=data2,type=pull,method=bind,address=tcp://localhost:5570" -FILESINK+=" name=ack,type=push,method=connect,address=tcp://localhost:5999" -xterm -geometry 80x23+1000+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$FILESINK & diff --git a/examples/advanced/Tutorial3/MQ/run/startMQTut3Three.sh.in b/examples/advanced/Tutorial3/MQ/run/startMQTut3Three.sh.in deleted file mode 100755 index 6349fa3474..0000000000 --- a/examples/advanced/Tutorial3/MQ/run/startMQTut3Three.sh.in +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -mcEngine="TGeant3" - -echo "Supported data formats: binary, boost, boost-text, flatbuffers, msgpack, protobuf, tmessage" -dataFormat="binary" -if [ "$1" = "binary" ]; then - echo "Using: binary" -elif [ "$1" = "boost" ]; then - dataFormat="boost" - echo "Using: boost (Boost binary)" -elif [ "$1" = "flatbuffers" ]; then - if(@FLATBUFFERS_USED@); then - dataFormat="flatbuffers" - echo "Using: flatbuffers (Google FlatBuffers)" - else - echo "Cannot use flatbuffers: library not found at build time" - exit 1 - fi -elif [ "$1" = "msgpack" ]; then - if(@MSGPACK_USED@); then - dataFormat="msgpack" - echo "Using: msgpack (MessagePack)" - else - echo "Cannot use msgpack: library not found at build time" - exit 1 - fi -elif [ "$1" = "protobuf" ]; then - if(@PROTOBUF_USED@); then - dataFormat="protobuf" - echo "Using: protobuf (Google Protocol Buffers)" - else - echo "Cannot use protobuf: library not found at build time" - exit 1 - fi -elif [ "$1" = "tmessage" ]; then - dataFormat="tmessage" - echo "Using: tmessage (Root TMessage)" -else - echo "None or incorrect data format provided!" - echo "Using: binary" -fi - -SAMPLER="tut3-sampler" -SAMPLER+=" --id sampler1" -SAMPLER+=" --data-format $dataFormat" -SAMPLER+=" --severity info" -SAMPLER+=" --chain-input 99" -SAMPLER+=" --input-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testdigi_$mcEngine.root" -SAMPLER+=" --parameter-file @CMAKE_CURRENT_SOURCE_DIR@/macro/data/testparams_$mcEngine.root" -SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=tcp://localhost:5565" -SAMPLER+=" name=ack,type=pull,method=bind,address=tcp://localhost:5999" -xterm -geometry 80x23+0+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & - -PROCESSOR="tut3-processor" -PROCESSOR+=" --id processor1" -PROCESSOR+=" --data-format $dataFormat" -PROCESSOR+=" --severity info" -PROCESSOR+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565" -PROCESSOR+=" name=data2,type=push,method=connect,address=tcp://localhost:5570" -xterm -geometry 80x23+500+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR & - -FILESINK="tut3-sink" -FILESINK+=" --id sink1" -FILESINK+=" --data-format $dataFormat" -FILESINK+=" --severity info" -FILESINK+=" --channel-config name=data2,type=pull,method=bind,address=tcp://localhost:5570" -FILESINK+=" name=ack,type=push,method=connect,address=tcp://localhost:5999" -xterm -geometry 80x23+1000+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$FILESINK & \ No newline at end of file diff --git a/basemq/devices/FairMQSampler.h b/examples/advanced/Tutorial3/MQ/sampler.cxx similarity index 53% rename from basemq/devices/FairMQSampler.h rename to examples/advanced/Tutorial3/MQ/sampler.cxx index 588fb55658..e15f8f5773 100644 --- a/basemq/devices/FairMQSampler.h +++ b/examples/advanced/Tutorial3/MQ/sampler.cxx @@ -1,31 +1,39 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/** - * FairMQSampler.h - * - * @since 2012-09-27 - * @author D. Klein, A. Rybalchenko, N. Winckler - */ -#ifndef FAIRMQSAMPLER_H_ -#define FAIRMQSAMPLER_H_ +// this example +#include "DigiLoader.h" +#include "DigiLoaderBin.h" +#include "DigiLoaderBoost.h" +#include "DigiLoaderFlatBuffers.h" +#include "DigiLoaderProtobuf.h" +#include "DigiLoaderTMessage.h" +#include "SamplerTask.h" +// FairRoot #include "FairFileSource.h" #include "FairMQ.h" // for fair::mq::Device, fair::mq::MessagePtr -#include "FairMQSamplerTask.h" #include "FairParRootFileIo.h" #include "FairRunAna.h" +#include "FairRunFairMQDevice.h" #include "FairRuntimeDb.h" -#include +// logger #include + +// std +#include +#include // std::quoted +#include #include +namespace bpo = boost::program_options; + /** * Reads simulated digis from a root file and samples the digi as a time-series UDP stream. * Must be initialized with the filename to the root file and the name of the sub-detector @@ -39,29 +47,25 @@ */ template -class FairMQSampler : public fair::mq::Device +class Sampler : public fair::mq::Device { public: - FairMQSampler() + Sampler() : fFairRunAna(nullptr) , fSamplerTask(nullptr) - , fStart() - , fEnd() , fInputFile() , fParFile() , fBranch() , fOutChannelName("data1") - , fAckChannelName("ack") , fNumEvents(0) , fChainInput(0) , fSentMsgs(0) - , fAckListener() {} - FairMQSampler(const FairMQSampler&) = delete; - FairMQSampler operator=(const FairMQSampler&) = delete; + Sampler(const Sampler&) = delete; + Sampler operator=(const Sampler&) = delete; - virtual ~FairMQSampler() {} + virtual ~Sampler() {} protected: virtual void InitTask() @@ -77,14 +81,10 @@ class FairMQSampler : public fair::mq::Device fChainInput = fConfig->GetValue("chain-input"); std::string outChannelName = fConfig->GetValue("out-channel"); - std::string ackChannelName = fConfig->GetValue("ack-channel"); // check if the returned value actually exists, for the compatibility with old devices. if (outChannelName != "") { fOutChannelName = outChannelName; } - if (ackChannelName != "") { - fAckChannelName = ackChannelName; - } fSamplerTask->SetBranch(fBranch); fSamplerTask->SetTransport(fTransportFactory); @@ -111,43 +111,34 @@ class FairMQSampler : public fair::mq::Device fFairRunAna->Init(); // fFairRunAna->Run(0, 0); - fNumEvents = int((FairRootManager::Instance()->GetInChain())->GetEntries()); + fNumEvents = FairRootManager::Instance()->GetInChain()->GetEntries(); LOG(info) << "Task initialized."; LOG(info) << "Number of events to process: " << fNumEvents; } - virtual void PreRun() + virtual void Run() { - fStart = std::chrono::high_resolution_clock::now(); - fAckListener = std::thread(&FairMQSampler::ListenForAcks, this); - } + while (fSentMsgs < fNumEvents) { + fair::mq::MessagePtr msg; - virtual bool ConditionalRun() - { - fair::mq::MessagePtr msg; + fSamplerTask->SetEventIndex(fSentMsgs); + fFairRunAna->RunMQ(fSentMsgs); + fSamplerTask->GetPayload(msg); - fSamplerTask->SetEventIndex(fSentMsgs); - fFairRunAna->RunMQ(fSentMsgs); - fSamplerTask->GetPayload(msg); + if (Send(msg, fOutChannelName) >= 0) { + ++fSentMsgs; + } - if (Send(msg, fOutChannelName) >= 0) { - ++fSentMsgs; - if (fSentMsgs == fNumEvents) { - return false; + if (NewStatePending()) { + break; } } - return true; - } - - virtual void PostRun() - { - try { - fAckListener.join(); - } catch (std::exception& e) { - LOG(error) << "Exception when ending AckListener thread: " << e.what(); - exit(EXIT_FAILURE); + LOG(info) << "Sent " << fSentMsgs << " messages!"; + // stay in the Running state until a transition to Ready is requested + while (!NewStatePending()) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); } } @@ -159,39 +150,65 @@ class FairMQSampler : public fair::mq::Device delete fSamplerTask; } - void ListenForAcks() - { - uint64_t numAcks = 0; - for (Long64_t eventNr = 0; eventNr < fNumEvents; ++eventNr) { - auto ack(NewMessage()); - if (Receive(ack, fAckChannelName) >= 0) { - ++numAcks; - } - - if (NewStatePending()) { - break; - } - } - - fEnd = std::chrono::high_resolution_clock::now(); - LOG(info) << "Acknowledged " << numAcks - << " messages in: " << std::chrono::duration(fEnd - fStart).count() << "ms."; - } - private: FairRunAna* fFairRunAna; - FairMQSamplerTask* fSamplerTask; - std::chrono::high_resolution_clock::time_point fStart; - std::chrono::high_resolution_clock::time_point fEnd; + SamplerTask* fSamplerTask; std::string fInputFile; // Filename of a root file containing the simulated digis. std::string fParFile; std::string fBranch; // The name of the sub-detector branch to stream the digis from. std::string fOutChannelName; - std::string fAckChannelName; - int fNumEvents; + int64_t fNumEvents; int fChainInput; int fSentMsgs; - std::thread fAckListener; }; -#endif /* FAIRMQSAMPLER_H_ */ +void addCustomOptions(bpo::options_description& options) +{ + // clang-format off + options.add_options() + ("data-format", bpo::value()->default_value("binary"), "Data format (binary|boost|flatbuffers|protobuf|tmessage)") + ("input-file", bpo::value()->required(), "Path to the input file") + ("parameter-file", bpo::value()->default_value(""), "Path to the parameter file") + ("branch", bpo::value()->default_value("FairTestDetectorDigi"), "Name of the Branch") + ("out-channel", bpo::value()->default_value("data1"), "Name of the output channel") + ("chain-input", bpo::value()->default_value(0), "Chain input file more than once (default)"); + // clang-format on +} + +std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) +{ + std::string dataFormat = config.GetValue("data-format"); + + LOG(info) << "Starting Sampler with " << dataFormat << " data serialization"; + + if (dataFormat == "binary") { + return std::make_unique>>(); + } else if (dataFormat == "boost") { + return std::make_unique>>(); + } else if (dataFormat == "tmessage") { + return std::make_unique>>(); + } +#ifdef FLATBUFFERS + else if (dataFormat == "flatbuffers") { + return std::make_unique>>(); + } +#endif +#ifdef PROTOBUF + else if (dataFormat == "protobuf") { + return std::make_unique>>(); + } +#endif + else { + std::stringstream ss; + ss << "Invalid valid data format provided (--data-format): " << std::quoted(dataFormat) + << ", available are: binary, boost, tmessage" +#ifdef FLATBUFFERS + << ", flatbuffers" +#endif +#ifdef PROTOBUF + << ", protobuf" +#endif + ; + throw std::runtime_error(ss.str()); + } +} diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoader.h b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoader.h new file mode 100644 index 0000000000..e39496d155 --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoader.h @@ -0,0 +1,31 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_TESTDETECTOR_DIGILOADER_H +#define FAIR_TESTDETECTOR_DIGILOADER_H + +// this example +#include "FairTestDetectorDigi.h" +#include "Payload.h" +#include "SamplerTask.h" + +// logger +#include + +template +class DigiLoader : public SamplerTask +{ + public: + DigiLoader() + : SamplerTask("Load class TOut") + {} + + void Exec(Option_t* opt) override; +}; + +#endif /* FAIR_TESTDETECTOR_DIGILOADER_H */ diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderBin.tpl b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderBin.h similarity index 61% rename from examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderBin.tpl rename to examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderBin.h index 33cc739927..b3e24a6d9b 100644 --- a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderBin.tpl +++ b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderBin.h @@ -1,35 +1,34 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorDigiLoader.tpl - * @since 2014-02-08 - * @author: A. Rybalchenko, N. Winckler - * - */ - -// Implementation of FairTestDetectorDigiLoader::Exec() with pure binary transport data format + +// Implementation of DigiLoader::Exec() with pure binary transport data format + +#ifndef FAIR_TESTDETECTOR_DIGILOADER_BIN_H +#define FAIR_TESTDETECTOR_DIGILOADER_BIN_H + +#include "Payload.h" + template<> -void FairTestDetectorDigiLoader::Exec(Option_t* /*opt*/) +void DigiLoader::Exec(Option_t* /*opt*/) { int numEntries = fInput->GetEntriesFast(); - size_t digisSize = numEntries * sizeof(TestDetectorPayload::Digi); + size_t digisSize = numEntries * sizeof(Payload::Digi); fPayload = fTransportFactory->CreateMessage(digisSize); - TestDetectorPayload::Digi* digiPayload = static_cast(fPayload->GetData()); + Payload::Digi* digiPayload = static_cast(fPayload->GetData()); for (int i = 0; i < numEntries; ++i) { FairTestDetectorDigi* digi = static_cast(fInput->At(i)); if (!digi) { continue; } - new (&digiPayload[i]) TestDetectorPayload::Digi(); - digiPayload[i] = TestDetectorPayload::Digi(); + new (&digiPayload[i]) Payload::Digi(); digiPayload[i].fX = digi->GetX(); digiPayload[i].fY = digi->GetY(); digiPayload[i].fZ = digi->GetZ(); @@ -37,3 +36,5 @@ void FairTestDetectorDigiLoader digiPayload[i].fTimeStampError = digi->GetTimeStampError(); } } + +#endif // FAIR_TESTDETECTOR_DIGILOADER_BIN_H diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderBoost.tpl b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderBoost.h similarity index 52% rename from examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderBoost.tpl rename to examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderBoost.h index a61d157bc7..db3f77893c 100644 --- a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderBoost.tpl +++ b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderBoost.h @@ -1,26 +1,24 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorDigiLoader.tpl - * @since 2014-02-08 - * @author: A. Rybalchenko, N. Winckler - * - */ -// Default implementation of FairTestDetectorDigiLoader::Exec() with Boost transport data format +// Implementation of DigiLoader::Exec() with Boost transport data format + +#ifndef FAIR_TESTDETECTOR_DIGILOADER_BOOST_H +#define FAIR_TESTDETECTOR_DIGILOADER_BOOST_H #include "BoostSerializer.h" +#include "Payload.h" -// example TOut: FairTestDetectorDigi -// example TPayloadOut: boost::archive::binary_oarchive -template -void FairTestDetectorDigiLoader::Exec(Option_t* /*opt*/) +template<> +void DigiLoader::Exec(Option_t* /*opt*/) { fPayload = fTransportFactory->CreateMessage(); - BoostSerializer().Serialize(*fPayload, fInput); + BoostSerializer().Serialize(*fPayload, fInput); } + +#endif // FAIR_TESTDETECTOR_DIGILOADER_BOOST_H diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderFlatBuffers.tpl b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderFlatBuffers.h similarity index 66% rename from examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderFlatBuffers.tpl rename to examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderFlatBuffers.h index da90a5baa4..f5c6536c19 100644 --- a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderFlatBuffers.tpl +++ b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderFlatBuffers.h @@ -1,19 +1,24 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -// Implementation of FairTestDetectorDigiLoader::Exec() with Google FlatBuffers transport data format + +// Implementation of DigiLoader::Exec() with Google FlatBuffers transport data format + +#ifndef FAIR_TESTDETECTOR_DIGILOADER_FLATBUFFERS_H +#define FAIR_TESTDETECTOR_DIGILOADER_FLATBUFFERS_H #ifdef FLATBUFFERS -#include "FairTestDetectorPayloadDigi_generated.h" +#include "Payload.h" +#include "PayloadDigi_generated.h" #include "flatbuffers/flatbuffers.h" template<> -void FairTestDetectorDigiLoader::Exec(Option_t* /*opt*/) +void DigiLoader::Exec(Option_t* /*opt*/) { int nDigis = fInput->GetEntriesFast(); @@ -27,11 +32,11 @@ void FairTestDetectorDigiLoaderGetX()); // x:int - db.add_y(digi->GetY()); // y:int - db.add_z(digi->GetZ()); // z:int - db.add_timestamp(digi->GetTimeStamp()); // timestamp:double - db.add_timestampError(digi->GetTimeStampError()); // timestampError:double + db.add_x(digi->GetX()); // x:int + db.add_y(digi->GetY()); // y:int + db.add_z(digi->GetZ()); // z:int + db.add_timestamp(digi->GetTimeStamp()); // timestamp:double + db.add_timestamp_error(digi->GetTimeStampError()); // timestamp_error:double digis[i] = db.Finish(); // LOG(info) << digi->GetX() << " " << digi->GetY() << " " << digi->GetZ() << " " << digi->GetTimeStamp() << " " @@ -51,4 +56,6 @@ void FairTestDetectorDigiLoader -void FairTestDetectorDigiLoader::Exec(Option_t* /*opt*/) +void DigiLoader::Exec(Option_t* /*opt*/) { int nDigis = fInput->GetEntriesFast(); @@ -40,11 +39,13 @@ void FairTestDetectorDigiLoaderCreateMessage(const_cast(str->c_str()), - str->length(), - [](void* /* data */, void* obj) { delete static_cast(obj); }, - str); + fPayload = fTransportFactory->CreateMessage( + const_cast(str->c_str()), + str->length(), + [](void* /* data */, void* obj) { delete static_cast(obj); }, + str); } -#endif /* PROTOBUF */ +#endif // PROTOBUF + +#endif // FAIR_TESTDETECTOR_DIGILOADER_PROTOBUF_H diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderTMessage.tpl b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderTMessage.h similarity index 63% rename from examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderTMessage.tpl rename to examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderTMessage.h index ccde3e4061..5bcbd711bf 100644 --- a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderTMessage.tpl +++ b/examples/advanced/Tutorial3/MQ/samplerTask/DigiLoaderTMessage.h @@ -1,24 +1,24 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -/* - * File: FairTestDetectorDigiLoader.tpl - * @since 2014-02-08 - * @author: A. Rybalchenko, N. Winckler - * - */ -// Implementation of FairTestDetectorDigiLoader::Exec() with Root TMessage transport data format +// Implementation of DigiLoader::Exec() with Root TMessage transport data format +#ifndef FAIR_TESTDETECTOR_DIGILOADER_TMESSAGE_H +#define FAIR_TESTDETECTOR_DIGILOADER_TMESSAGE_H + +#include "Payload.h" #include "RootSerializer.h" template<> -void FairTestDetectorDigiLoader::Exec(Option_t* /*opt*/) +void DigiLoader::Exec(Option_t* /*opt*/) { fPayload = fTransportFactory->CreateMessage(); RootSerializer().Serialize(*fPayload, fInput); } + +#endif // FAIR_TESTDETECTOR_DIGILOADER_TMESSAGE_H diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoader.h b/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoader.h deleted file mode 100644 index 6c40a6c5ea..0000000000 --- a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoader.h +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * File: FairTestDetectorDigiLoader.h - * @since 2014-02-08 - * @author: A. Rybalchenko, N. Winckler - */ - -#ifndef FAIRTESTDETECTORDIGILOADER_H -#define FAIRTESTDETECTORDIGILOADER_H - -#include "FairMQSamplerTask.h" -#include "FairTestDetectorDigi.h" -#include "FairTestDetectorPayload.h" - -#include -#include -#include - -template -class FairTestDetectorDigiLoader : public FairMQSamplerTask -{ - public: - FairTestDetectorDigiLoader() - : FairMQSamplerTask("Load class TOut") - {} - - void Exec(Option_t* opt) override; -}; - -// Template implementation is in FairTestDetectorDigiLoader.tpl : -#include "FairTestDetectorDigiLoaderBin.tpl" -#include "FairTestDetectorDigiLoaderBoost.tpl" -#include "FairTestDetectorDigiLoaderFlatBuffers.tpl" -#include "FairTestDetectorDigiLoaderMsgpack.tpl" -#include "FairTestDetectorDigiLoaderProtobuf.tpl" -#include "FairTestDetectorDigiLoaderTMessage.tpl" - -#endif /* FAIRTESTDETECTORDIGILOADER_H */ diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderMsgpack.tpl b/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderMsgpack.tpl deleted file mode 100644 index d6feb699a4..0000000000 --- a/examples/advanced/Tutorial3/MQ/samplerTask/FairTestDetectorDigiLoaderMsgpack.tpl +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -/** - * File: FairTestDetectorDigiLoaderMsgpack.tpl - * @since 2014-12-12 - * @author: A. Rybalchenko - */ - -// Implementation of FairTestDetectorDigiLoader::Exec() with Msgpack data format. - -#ifdef MSGPACK - -#include - -// Types to be used as template parameters. -struct MsgPack -{}; -// struct MsgPackRef { msgpack::vrefbuffer vbuf; std::vector> digis; -// }; struct MsgPackStream {}; - -template<> -void FairTestDetectorDigiLoader::Exec(Option_t* /*opt*/) -{ - int nDigis = fInput->GetEntriesFast(); - - msgpack::sbuffer* sbuf = new msgpack::sbuffer(); - msgpack::packer packer(sbuf); - - std::vector> digis; - - for (int i = 0; i < nDigis; ++i) { - FairTestDetectorDigi* digi = static_cast(fInput->At(i)); - digis.push_back( - std::make_tuple(digi->GetX(), digi->GetY(), digi->GetZ(), digi->GetTimeStamp(), digi->GetTimeStampError())); - } - - packer.pack(digis); - - fPayload = fTransportFactory->CreateMessage( - sbuf->data(), - sbuf->size(), - [](void* /* data */, void* obj) { delete static_cast(obj); }, - sbuf); -} - -// MsgPackRef version sends the vector of tuples without copying it into the sbuffer -// void free_vrefbuffer(void* data, void* object) -// { -// delete static_cast(object); -// } - -// template <> -// void FairTestDetectorDigiLoader::Exec(Option_t* opt) -// { -// int nDigis = fInput->GetEntriesFast(); - -// MsgPackRef* container = new MsgPackRef(); - -// for (int i = 0; i < nDigis; ++i) -// { -// FairTestDetectorDigi* digi = static_cast(fInput->At(i)); -// container->digis.push_back(make_tuple(digi->GetX(), digi->GetY(), digi->GetZ(), digi->GetTimeStamp())); -// } - -// msgpack::pack(container->vbuf, container->digis); - -// fPayload = fTransportFactory->CreateMessage(container->vbuf.vector()->iov_base, -// container->vbuf.vector()->iov_len, free_vrefbuffer, container); -// } - -// MsgPackStream version copies the data values into a stream of tuples. -// template <> -// void FairTestDetectorDigiLoader::Exec(Option_t* opt) -// { -// int nDigis = fInput->GetEntriesFast(); - -// msgpack::sbuffer* sbuf = new msgpack::sbuffer(); -// msgpack::packer packer(sbuf); - -// for (int i = 0; i < nDigis; ++i) -// { -// FairTestDetectorDigi* digi = static_cast(fInput->At(i)); -// packer.pack(std::make_tuple(digi->GetX(), digi->GetY(), digi->GetZ(), digi->GetTimeStamp())); -// } - -// fPayload = fTransportFactory->CreateMessage(sbuf->data(), sbuf->size(), free_sbuffer, sbuf); -// } - -#endif /* MSGPACK */ diff --git a/examples/advanced/Tutorial3/MQ/samplerTask/SamplerTask.h b/examples/advanced/Tutorial3/MQ/samplerTask/SamplerTask.h new file mode 100644 index 0000000000..7302a9087e --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/samplerTask/SamplerTask.h @@ -0,0 +1,62 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_TESTDETECTOR_SAMPLERTASK_H +#define FAIR_TESTDETECTOR_SAMPLERTASK_H + +// FairRoot +#include "FairEventHeader.h" +#include "FairMQ.h" // for fair::mq::Message, fair::mq::TransportFactory +#include "FairRootManager.h" +#include "FairTask.h" + +// ROOT +#include + +// std +#include +#include + +class SamplerTask : public FairTask +{ + public: + SamplerTask() + : FairTask("Abstract base task used for loading a branch from a root file into memory") + {} + + SamplerTask(const Text_t* name, int iVerbose = 1) + : FairTask(name, iVerbose) + {} + + SamplerTask(const SamplerTask&) = delete; + SamplerTask operator=(const SamplerTask&) = delete; + + InitStatus Init() override + { + FairRootManager* ioman = FairRootManager::Instance(); + fEvtHeader = static_cast(ioman->GetObject("EventHeader.")); + fInput = static_cast(ioman->GetObject(fBranch.c_str())); + return kSUCCESS; + } + + void SetEventIndex(Long64_t eventIndex) { fEventIndex = eventIndex; } + void SetBranch(const std::string& branch) { fBranch = branch; } + + void GetPayload(std::unique_ptr& msg) { msg = std::move(fPayload); } + void SetTransport(std::shared_ptr factory) { fTransportFactory = factory; } + + protected: + std::string fBranch; + TClonesArray* fInput = nullptr; // non-owning ptr, populated from FairRootManager during Init + fair::mq::MessagePtr fPayload; + Long64_t fEventIndex = 0; + FairEventHeader* fEvtHeader = nullptr; // non-owning ptr, populated from FairRootManager during Init + std::shared_ptr fTransportFactory; +}; + +#endif /* FAIR_TESTDETECTOR_SAMPLERTASK_H */ diff --git a/examples/advanced/Tutorial3/MQ/sink.cxx b/examples/advanced/Tutorial3/MQ/sink.cxx new file mode 100644 index 0000000000..7fe69feaf6 --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/sink.cxx @@ -0,0 +1,71 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +// this example +#include "FileSink.h" +#include "FileSinkBin.h" +#include "FileSinkBoost.h" +#include "FileSinkFlatBuffers.h" +#include "FileSinkProtobuf.h" +#include "FileSinkTMessage.h" + +// FairRoot +#include "FairRunFairMQDevice.h" + +// std +#include // std::quoted + +namespace bpo = boost::program_options; + +void addCustomOptions(bpo::options_description& options) +{ + // clang-format off + options.add_options() + ("in-channel", bpo::value()->default_value("data2"), "Name of the input channel") + ("data-format", bpo::value()->default_value("binary"), "Data format (binary|boost|flatbuffers|protobuf|tmessage)") + ("max-msgs", bpo::value()->default_value(0), "Stop after msgs (0 - no limit)."); + // clang-format on +} + +std::unique_ptr fairGetDevice(const fair::mq::ProgOptions& config) +{ + std::string dataFormat = config.GetValue("data-format"); + + LOG(info) << "Starting Sink with " << dataFormat << " data serialization"; + + if (dataFormat == "binary") { + return std::make_unique>(); + } else if (dataFormat == "boost") { + return std::make_unique>(); + } else if (dataFormat == "tmessage") { + return std::make_unique>(); + } +#ifdef FLATBUFFERS + else if (dataFormat == "flatbuffers") { + return std::make_unique>(); + } +#endif +#ifdef PROTOBUF + else if (dataFormat == "protobuf") { + return std::make_unique>(); + } +#endif + else { + std::stringstream ss; + ss << "Invalid valid data format provided (--data-format): " << std::quoted(dataFormat) + << ", available are: binary, boost, tmessage" +#ifdef FLATBUFFERS + << ", flatbuffers" +#endif +#ifdef PROTOBUF + << ", protobuf" +#endif + ; + throw std::runtime_error(ss.str()); + } +} diff --git a/examples/advanced/Tutorial3/MQ/start.sh.in b/examples/advanced/Tutorial3/MQ/start.sh.in new file mode 100755 index 0000000000..6ce96afacb --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/start.sh.in @@ -0,0 +1,51 @@ +#!/bin/bash + +mcEngine="TGeant3" + +session="$(@FairMQ_BINDIR@/fairmq-uuid-gen -h)" + +echo "Supported data formats: binary, boost, flatbuffers, protobuf, tmessage" +dataFormat="binary" + +if (($# == 1)); then + dataFormat=$1 +elif (($# > 1)); then + echo "Usage: start.sh [data_format[=binary]]" + exit +fi + +echo "Data format: $dataFormat" +echo "Session ID: $session" + +SAMPLER="tut3-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --session $session" +SAMPLER+=" --data-format $dataFormat" +SAMPLER+=" --chain-input 99" +SAMPLER+=" --input-file @CMAKE_CURRENT_BINARY_DIR@/macro/data/testdigi_$mcEngine.root" +SAMPLER+=" --parameter-file @CMAKE_CURRENT_BINARY_DIR@/macro/data/testparams_$mcEngine.root" +SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=tcp://localhost:5565" +xterm -geometry 80x23+0+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & + +PROCESSOR1="tut3-processor" +PROCESSOR1+=" --id processor1" +PROCESSOR1+=" --session $session" +PROCESSOR1+=" --data-format $dataFormat" +PROCESSOR1+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565" +PROCESSOR1+=" name=data2,type=push,method=connect,address=tcp://localhost:5570" +xterm -geometry 80x23+500+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 & + +PROCESSOR2="tut3-processor" +PROCESSOR2+=" --id processor2" +PROCESSOR2+=" --session $session" +PROCESSOR2+=" --data-format $dataFormat" +PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=tcp://localhost:5565" +PROCESSOR2+=" name=data2,type=push,method=connect,address=tcp://localhost:5570" +xterm -geometry 80x23+500+350 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & + +SINK="tut3-sink" +SINK+=" --id sink1" +SINK+=" --session $session" +SINK+=" --data-format $dataFormat" +SINK+=" --channel-config name=data2,type=pull,method=bind,address=tcp://localhost:5570" +xterm -geometry 80x23+1000+0 -hold -e @CMAKE_CURRENT_BINARY_DIR@/$SINK & diff --git a/examples/advanced/Tutorial3/MQ/test.sh.in b/examples/advanced/Tutorial3/MQ/test.sh.in new file mode 100755 index 0000000000..f913a55969 --- /dev/null +++ b/examples/advanced/Tutorial3/MQ/test.sh.in @@ -0,0 +1,86 @@ +#!/bin/bash + +set -e + +mcEngine="TGeant4" + +session="$(@FairMQ_BINDIR@/fairmq-uuid-gen -h)" + +echo "Supported data formats: binary, boost, flatbuffers, protobuf, tmessage" +dataFormat="binary" + +if (($# == 1)); then + dataFormat=$1 +elif (($# > 1)); then + echo "Usage: start.sh [data_format[=binary]]" + exit +fi + +echo "Data format: $dataFormat" +echo "Session ID: $session" + +trap 'kill -TERM $SAMPLER_PID; kill -TERM $P1_PID; kill -TERM $P2_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $P1_PID; wait $P2_PID; wait $SINK_PID;' TERM + +mkdir @CMAKE_CURRENT_BINARY_DIR@/testsession_$session +cd @CMAKE_CURRENT_BINARY_DIR@/testsession_$session + +# launch devices + +SAMPLER="tut3-sampler" +SAMPLER+=" --id sampler1" +SAMPLER+=" --control static" +SAMPLER+=" --color false" +SAMPLER+=" --verbosity veryhigh" +SAMPLER+=" --session $session" +SAMPLER+=" --data-format $dataFormat" +SAMPLER+=" --input-file @CMAKE_CURRENT_BINARY_DIR@/macro/data/testdigi_$mcEngine.root" +SAMPLER+=" --parameter-file @CMAKE_CURRENT_BINARY_DIR@/macro/data/testparams_$mcEngine.root" +SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=ipc://data1" +@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER & +SAMPLER_PID=$! + +PROCESSOR1="tut3-processor" +PROCESSOR1+=" --id processor1" +PROCESSOR1+=" --control static" +PROCESSOR1+=" --color false" +PROCESSOR1+=" --verbosity veryhigh" +PROCESSOR1+=" --session $session" +PROCESSOR1+=" --data-format $dataFormat" +PROCESSOR1+=" --channel-config name=data1,type=pull,method=connect,address=ipc://data1" +PROCESSOR1+=" name=data2,type=push,method=connect,address=ipc://data2" +@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 & +P1_PID=$! + +PROCESSOR2="tut3-processor" +PROCESSOR2+=" --id processor2" +PROCESSOR2+=" --control static" +PROCESSOR2+=" --color false" +PROCESSOR2+=" --verbosity veryhigh" +PROCESSOR2+=" --session $session" +PROCESSOR2+=" --data-format $dataFormat" +PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=ipc://data1" +PROCESSOR2+=" name=data2,type=push,method=connect,address=ipc://data2" +@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 & +P2_PID=$! + +SINK="tut3-sink" +SINK+=" --id sink1" +SINK+=" --control static" +SINK+=" --color false" +SINK+=" --verbosity veryhigh" +SINK+=" --session $session" +SINK+=" --data-format $dataFormat" +SINK+=" --max-msgs 100" +SINK+=" --channel-config name=data2,type=pull,method=bind,address=ipc://data2" +@CMAKE_CURRENT_BINARY_DIR@/$SINK & +SINK_PID=$! + +wait $SINK_PID + +kill -SIGINT $SAMPLER_PID +kill -SIGINT $P1_PID +kill -SIGINT $P2_PID + +wait $SAMPLER_PID +wait $P1_PID +wait $P2_PID diff --git a/examples/advanced/Tutorial3/data/FairTestDetectorDigi.cxx b/examples/advanced/Tutorial3/data/FairTestDetectorDigi.cxx index 1b52ea39d6..c589f08606 100644 --- a/examples/advanced/Tutorial3/data/FairTestDetectorDigi.cxx +++ b/examples/advanced/Tutorial3/data/FairTestDetectorDigi.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,7 +13,6 @@ */ #include "FairTestDetectorDigi.h" -ClassImp(FairTestDetectorDigi); FairTestDetectorDigi::FairTestDetectorDigi() : FairTimeStamp() diff --git a/examples/advanced/Tutorial3/data/FairTestDetectorHit.cxx b/examples/advanced/Tutorial3/data/FairTestDetectorHit.cxx index 2b8295356b..1fcc7c9ada 100644 --- a/examples/advanced/Tutorial3/data/FairTestDetectorHit.cxx +++ b/examples/advanced/Tutorial3/data/FairTestDetectorHit.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,5 +16,3 @@ FairTestDetectorHit::FairTestDetectorHit(Int_t detID, Int_t mcindex, const TVect {} FairTestDetectorHit::~FairTestDetectorHit() {} - -ClassImp(FairTestDetectorHit); diff --git a/examples/advanced/Tutorial3/data/FairTestDetectorPoint.cxx b/examples/advanced/Tutorial3/data/FairTestDetectorPoint.cxx index 62dcc2ad33..cabd74936a 100644 --- a/examples/advanced/Tutorial3/data/FairTestDetectorPoint.cxx +++ b/examples/advanced/Tutorial3/data/FairTestDetectorPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -48,5 +48,3 @@ void FairTestDetectorPoint::Print(const Option_t* /*opt*/) const LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV"; } - -ClassImp(FairTestDetectorPoint); diff --git a/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.cxx b/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.cxx index 786890e7c9..3f629e30ad 100644 --- a/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.cxx +++ b/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.cxx @@ -1,20 +1,22 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ - #include "FairTestDetectorDigiTask.h" - #include // for TClonesArray - #include // for TGenericClassInfo - #include // for Sqrt - #include // for TRandom, gRandom - #include // for operator<<, basic_ostream, endl - #include "FairLink.h" // for FairLink - #include "FairRootManager.h" // for FairRootManager - #include "FairTestDetectorDigi.h" // for FairTestDetectorDigi - #include "FairTestDetectorPoint.h" // for FairTestDetectorPoint +#include "FairTestDetectorDigiTask.h" + +#include "FairLink.h" // for FairLink +#include "FairRootManager.h" // for FairRootManager +#include "FairTestDetectorDigi.h" // for FairTestDetectorDigi +#include "FairTestDetectorPoint.h" // for FairTestDetectorPoint + +#include // for TClonesArray +#include // for TGenericClassInfo +#include // for Sqrt +#include // for TRandom, gRandom +#include // for operator<<, basic_ostream, endl FairTestDetectorDigiTask::FairTestDetectorDigiTask() : FairTask("TestDetectorDigTask") @@ -97,5 +99,3 @@ Double_t FairTestDetectorDigiTask::CalcTimeStamp(Double_t timeOfFlight) return result; } } - -ClassImp(FairTestDetectorDigiTask); diff --git a/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.h b/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.h index 7c29207d63..e91a11f367 100644 --- a/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.h +++ b/examples/advanced/Tutorial3/digitization/FairTestDetectorDigiTask.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,8 +13,7 @@ #include "FairTask.h" // for FairTask, InitStatus class TBuffer; class TClass; -class TClonesArray; // lines 15-15 -class TMemberInspector; +class TClonesArray; class FairTestDetectorDigiTask : public FairTask { diff --git a/examples/advanced/Tutorial3/digitization/FairTestDetectorHitProducerSmearing.cxx b/examples/advanced/Tutorial3/digitization/FairTestDetectorHitProducerSmearing.cxx index ffa3827356..4d6c501489 100644 --- a/examples/advanced/Tutorial3/digitization/FairTestDetectorHitProducerSmearing.cxx +++ b/examples/advanced/Tutorial3/digitization/FairTestDetectorHitProducerSmearing.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -92,6 +92,7 @@ void FairTestDetectorHitProducerSmearing::Exec(Option_t* /*option*/) } } -void FairTestDetectorHitProducerSmearing::Finish() { LOG(debug) << "Finish of FairTestDetectorHitProducerSmearing"; } - -ClassImp(FairTestDetectorHitProducerSmearing); +void FairTestDetectorHitProducerSmearing::Finish() +{ + LOG(debug) << "Finish of FairTestDetectorHitProducerSmearing"; +} diff --git a/examples/advanced/Tutorial3/macro/run_digi.C b/examples/advanced/Tutorial3/macro/run_digi.C index 7a196c2755..006ea94179 100644 --- a/examples/advanced/Tutorial3/macro/run_digi.C +++ b/examples/advanced/Tutorial3/macro/run_digi.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,9 +8,13 @@ #include #include +#include #include -void run_digi(TString mcEngine = "TGeant3") +using std::cout; +using std::endl; + +void run_digi(TString mcEngine = "TGeant4") { FairLogger* logger = FairLogger::GetLogger(); // logger->SetLogFileName("MyLog.log"); @@ -39,28 +43,28 @@ void run_digi(TString mcEngine = "TGeant3") TStopwatch timer; // ----- Reconstruction run ------------------------------------------- - FairRunAna* fRun = new FairRunAna(); + FairRunAna run{}; FairFileSource* fFileSource = new FairFileSource(inFile); - fRun->SetSource(fFileSource); - fRun->SetSink(std::make_unique(outFile)); - fRun->SetUseFairLinks(kTRUE); + run.SetSource(fFileSource); + run.SetSink(std::make_unique(outFile)); + run.SetUseFairLinks(kTRUE); FairLinkManager::Instance()->AddIncludeType(0); // FairLinkManager::Instance()->AddIncludeType(1); - fRun->SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file - FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); FairParRootFileIo* parInput1 = new FairParRootFileIo(); parInput1->open(parFile.Data()); rtdb->setFirstInput(parInput1); // ----- TorinoDetector hit producers --------------------------------- FairTestDetectorDigiTask* digiTask = new FairTestDetectorDigiTask(); - fRun->AddTask(digiTask); + run.AddTask(digiTask); - fRun->Init(); + run.Init(); timer.Start(); - fRun->Run(); + run.Run(); // ----- Finish ------------------------------------------------------- diff --git a/examples/advanced/Tutorial3/macro/run_sim.C b/examples/advanced/Tutorial3/macro/run_sim.C index 9c28e220e4..6a86e0717a 100644 --- a/examples/advanced/Tutorial3/macro/run_sim.C +++ b/examples/advanced/Tutorial3/macro/run_sim.C @@ -1,17 +1,34 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ +#if !defined(__CLING__) || defined(__ROOTCLING__) +#include "FairBoxGenerator.h" +#include "FairCave.h" +#include "FairConstField.h" +#include "FairMagnet.h" +#include "FairParRootFileIo.h" +#include "FairPrimaryGenerator.h" +#include "FairRootFileSink.h" +#include "FairRunSim.h" +#include "FairSystemInfo.h" +#include "FairTestDetector.h" +#endif + #include #include #include +#include #include -void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3") +using std::cout; +using std::endl; + +void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant4") { TStopwatch timer; timer.Start(); @@ -28,13 +45,13 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3") gSystem->Setenv("CONFIG_DIR", tut_configdir.Data()); // create Instance of Run Manager class - FairRunSim *fRun = new FairRunSim(); - fRun->SetUseFairLinks(kTRUE); + FairRunSim run{}; + run.SetUseFairLinks(kTRUE); // FairLinkManager::Instance()->AddIncludeType(0); // set the MC version used // ------------------------ - fRun->SetName(mcEngine); + run.SetName(mcEngine); TString outFile = "data/testrun_"; outFile = outFile + mcEngine + ".root"; @@ -45,40 +62,40 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3") TString parFile = "data/testparams_"; parFile = parFile + mcEngine + ".root"; - fRun->SetSink(std::make_unique(outFile)); - fRun->SetGenerateRunInfo(kTRUE); // Create FairRunInfo file + run.SetSink(std::make_unique(outFile)); + run.SetGenerateRunInfo(kTRUE); // Create FairRunInfo file // ----- Magnetic field ------------------------------------------- // Constant Field FairConstField *fMagField = new FairConstField(); fMagField->SetField(0., 10., 0.); // values are in kG fMagField->SetFieldRegion(-50, 50, -50, 50, 350, 450); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax) - fRun->SetField(fMagField); + run.SetField(fMagField); // -------------------------------------------------------------------- // Set Material file Name //----------------------- - fRun->SetMaterials("media.geo"); + run.SetMaterials("media.geo"); // Create and add detectors //------------------------- FairModule *Cave = new FairCave("CAVE"); Cave->SetGeometryFileName("cave.geo"); - fRun->AddModule(Cave); + run.AddModule(Cave); FairModule *Magnet = new FairMagnet("MAGNET"); Magnet->SetGeometryFileName("magnet.geo"); - fRun->AddModule(Magnet); + run.AddModule(Magnet); FairDetector *Torino = new FairTestDetector("TORINO", kTRUE); Torino->SetGeometryFileName("torino.geo"); - fRun->AddModule(Torino); + run.AddModule(Torino); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator *primGen = new FairPrimaryGenerator(); - fRun->SetGenerator(primGen); + run.SetGenerator(primGen); // Box Generator FairBoxGenerator *boxGen = new FairBoxGenerator(2212, 10); // 13 = muon; 1 = multipl. @@ -90,9 +107,9 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3") // boxGen->SetXYZ(0., 0.37, 0.); primGen->AddGenerator(boxGen); - fRun->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); - fRun->Init(); + run.Init(); // -Trajectories Visualization (TGeoManager Only ) // ----------------------------------------------- @@ -110,7 +127,7 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3") // Fill the Parameter containers for this run //------------------------------------------- - FairRuntimeDb *rtdb = fRun->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged); output->open(parFile); @@ -123,11 +140,12 @@ void run_sim(Int_t nEvents = 100, TString mcEngine = "TGeant3") // ----------------- // Int_t nEvents = 1; - fRun->Run(nEvents); + run.Run(nEvents); - fRun->CreateGeometryFile(geoFile); + run.CreateGeometryFile(geoFile); // ----- Finish ------------------------------------------------------- + run.ls(); cout << endl << endl; diff --git a/examples/advanced/Tutorial3/macro/run_sim_sep.C b/examples/advanced/Tutorial3/macro/run_sim_sep.C index cca86f2520..518c4d1da6 100644 --- a/examples/advanced/Tutorial3/macro/run_sim_sep.C +++ b/examples/advanced/Tutorial3/macro/run_sim_sep.C @@ -1,3 +1,16 @@ +/******************************************************************************** + * Copyright (C) 2012-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include +#include +#include +#include + void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3") { gRandom->SetSeed(1111 * fileId); @@ -17,49 +30,49 @@ void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3 gSystem->Setenv("CONFIG_DIR", tut_configdir.Data()); // create Instance of Run Manager class - FairRunSim *fRun = new FairRunSim(); + FairRunSim run{}; // set the MC version used // ------------------------ - fRun->SetName(mcEngine); + run.SetName(mcEngine); TString outfile = Form("data/testrun_%s_f%d.root", mcEngine.Data(), fileId); TString outparam = Form("data/testpar_%s_f%d.root", mcEngine.Data(), fileId); - fRun->SetSink(new FairRootFileSink(outfile)); + run.SetSink(new FairRootFileSink(outfile)); // ----- Magnetic field ------------------------------------------- // Constant Field FairConstField *fMagField = new FairConstField(); fMagField->SetField(0., 10., 0.); // values are in kG fMagField->SetFieldRegion(-50, 50, -50, 50, 350, 450); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax) - fRun->SetField(fMagField); + run.SetField(fMagField); // -------------------------------------------------------------------- // Set Material file Name //----------------------- - fRun->SetMaterials("media.geo"); + run.SetMaterials("media.geo"); // Create and add detectors //------------------------- FairModule *Cave = new FairCave("CAVE"); Cave->SetGeometryFileName("cave.geo"); - fRun->AddModule(Cave); + run.AddModule(Cave); FairModule *Magnet = new FairMagnet("MAGNET"); Magnet->SetGeometryFileName("magnet.geo"); - fRun->AddModule(Magnet); + run.AddModule(Magnet); FairDetector *Torino = new FairTestDetector("TORINO", kTRUE); Torino->SetGeometryFileName("torino.geo"); - fRun->AddModule(Torino); + run.AddModule(Torino); // Create and Set Event Generator //------------------------------- FairPrimaryGenerator *primGen = new FairPrimaryGenerator(); - fRun->SetGenerator(primGen); + run.SetGenerator(primGen); // Box Generator FairBoxGenerator *boxGen = new FairBoxGenerator(13, 10); // 13 = muon; 1 = multipl. @@ -71,9 +84,9 @@ void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3 // boxGen->SetXYZ(0., 0.37, 0.); primGen->AddGenerator(boxGen); - fRun->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); - fRun->Init(); + run.Init(); // -Trajectories Visualization (TGeoManager Only ) // ----------------------------------------------- @@ -91,7 +104,7 @@ void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3 // Fill the Parameter containers for this run //------------------------------------------- - FairRuntimeDb *rtdb = fRun->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); Bool_t kParameterMerged = kTRUE; FairParRootFileIo *output = new FairParRootFileIo(kParameterMerged); output->open(outparam); @@ -104,9 +117,9 @@ void run_sim_sep(Int_t fileId, Int_t nEvents = 1000, TString mcEngine = "TGeant3 // ----------------- // Int_t nEvents = 1; - fRun->Run(nEvents); + run.Run(nEvents); - fRun->CreateGeometryFile("data/geofile_full.root"); + run.CreateGeometryFile("data/geofile_full.root"); // ----- Finish ------------------------------------------------------- diff --git a/examples/advanced/Tutorial3/reconstruction/FairTestDetectorRecoTask.cxx b/examples/advanced/Tutorial3/reconstruction/FairTestDetectorRecoTask.cxx index 69bc4468e0..7b218f2427 100644 --- a/examples/advanced/Tutorial3/reconstruction/FairTestDetectorRecoTask.cxx +++ b/examples/advanced/Tutorial3/reconstruction/FairTestDetectorRecoTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -84,5 +84,3 @@ void FairTestDetectorRecoTask::Exec(Option_t* /*opt*/) hit->SetTimeStampError(digi->GetTimeStampError()); } } - -ClassImp(FairTestDetectorRecoTask); diff --git a/examples/advanced/Tutorial3/simulation/FairConstField.cxx b/examples/advanced/Tutorial3/simulation/FairConstField.cxx index a55d1e7d91..e60a3837ae 100644 --- a/examples/advanced/Tutorial3/simulation/FairConstField.cxx +++ b/examples/advanced/Tutorial3/simulation/FairConstField.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -165,5 +165,3 @@ void FairConstField::FillParContainer() Par->setInputVersion(fRun->GetRunId(), 1); Par->setChanged(); } - -ClassImp(FairConstField); diff --git a/examples/advanced/Tutorial3/simulation/FairConstFieldCreator.cxx b/examples/advanced/Tutorial3/simulation/FairConstFieldCreator.cxx index a240163682..dbe6370912 100644 --- a/examples/advanced/Tutorial3/simulation/FairConstFieldCreator.cxx +++ b/examples/advanced/Tutorial3/simulation/FairConstFieldCreator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -58,5 +58,3 @@ FairField *FairConstFieldCreator::createFairField() } return fMagneticField; } - -ClassImp(FairConstFieldCreator); diff --git a/examples/advanced/Tutorial3/simulation/FairConstPar.cxx b/examples/advanced/Tutorial3/simulation/FairConstPar.cxx index 52b48b5a32..6941038113 100644 --- a/examples/advanced/Tutorial3/simulation/FairConstPar.cxx +++ b/examples/advanced/Tutorial3/simulation/FairConstPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -107,5 +107,3 @@ void FairConstPar::SetParameters(FairField* field) fPosX = fPosY = fPosZ = fScale = 0.; fType = fieldConst->GetType(); } - -ClassImp(FairConstPar); diff --git a/examples/advanced/Tutorial3/simulation/FairMapPar.cxx b/examples/advanced/Tutorial3/simulation/FairMapPar.cxx index ce35f3886c..0fa6b040d0 100644 --- a/examples/advanced/Tutorial3/simulation/FairMapPar.cxx +++ b/examples/advanced/Tutorial3/simulation/FairMapPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -39,5 +39,3 @@ FairMapPar::FairMapPar() {} FairMapPar::~FairMapPar() {} - -ClassImp(FairMapPar); diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx b/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx index 98ba6c1d29..bd591c99ac 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx +++ b/examples/advanced/Tutorial3/simulation/FairTestDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -168,5 +168,3 @@ FairTestDetectorPoint* FairTestDetector::AddHit(Int_t trackID, myPoint->SetLink(FairLink(-1, fEventNr, FairRootManager::Instance()->GetBranchId("MCTrack"), trackID)); return myPoint; } - -ClassImp(FairTestDetector); diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.cxx b/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.cxx index dacf33837e..858e3faf46 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.cxx +++ b/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.cxx @@ -14,10 +14,6 @@ #include // for TString #include // for strcmp -class FairParSet; - -ClassImp(FairTestDetectorContFact); - static FairTestDetectorContFact gFairTestDetectorContFact; FairTestDetectorContFact::FairTestDetectorContFact() diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.h b/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.h index 5b5f28a5eb..7d1a6d6b1b 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.h +++ b/examples/advanced/Tutorial3/simulation/FairTestDetectorContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,10 +10,6 @@ #include "FairContFact.h" // for FairContFact, etc -#include // for ClassDef - -class FairParSet; - class FairTestDetectorContFact : public FairContFact { public: diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.cxx b/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.cxx index 7365bd2b38..2efb4a4563 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.cxx +++ b/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,37 +7,6 @@ ********************************************************************************/ #include "FairTestDetectorGeo.h" -#include // for sprintf - -ClassImp(FairTestDetectorGeo); - FairTestDetectorGeo::FairTestDetectorGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "torino"; - strcpy(modName, "torino"); - strcpy(eleName, "torino"); - maxSectors = 0; - maxModules = 10; -} - -const char* FairTestDetectorGeo::getModuleName(Int_t m) -{ - /** Returns the module name of FairTestDetector number m - Setting FairTestDetector here means that all modules names in the - ASCII file should start with FairTestDetector otherwise they will - not be constructed - */ - sprintf(modName, "torino%i", m + 1); - return modName; -} - -const char* FairTestDetectorGeo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - sprintf(eleName, "torino%i", m + 1); - return eleName; -} + : FairGeoSet("torino", 10) +{} diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.h b/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.h index 2687aeeacf..ad16e4b967 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.h +++ b/examples/advanced/Tutorial3/simulation/FairTestDetectorGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,31 +10,14 @@ #include "FairGeoSet.h" // for FairGeoSet -#include // for Int_t, etc -#include // for TString +#include // for Int_t, etc class FairTestDetectorGeo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module public: FairTestDetectorGeo(); ~FairTestDetectorGeo() override = default; - const char* getModuleName(Int_t) override; - const char* getEleName(Int_t) override; - inline Int_t getModNumInMod(const TString&) override; ClassDefOverride(FairTestDetectorGeo, 1); }; -inline Int_t FairTestDetectorGeo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - newdetector ?? has to be 11. - */ - return static_cast((name[6] - '0') - 1); // -} - #endif /* FAIRTESTDETECTORGEO_H_ */ diff --git a/examples/advanced/Tutorial3/simulation/FairTestDetectorGeoPar.cxx b/examples/advanced/Tutorial3/simulation/FairTestDetectorGeoPar.cxx index e99ddbabd0..a0d1f5e3b1 100644 --- a/examples/advanced/Tutorial3/simulation/FairTestDetectorGeoPar.cxx +++ b/examples/advanced/Tutorial3/simulation/FairTestDetectorGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,17 +11,15 @@ #include // for TObjArray -ClassImp(FairTestDetectorGeoPar); - FairTestDetectorGeoPar::FairTestDetectorGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -FairTestDetectorGeoPar::~FairTestDetectorGeoPar(void) {} +FairTestDetectorGeoPar::~FairTestDetectorGeoPar() {} -void FairTestDetectorGeoPar::clear(void) +void FairTestDetectorGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiRingSorter.cxx b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiRingSorter.cxx index 343862f5fa..99d09abaf2 100644 --- a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiRingSorter.cxx +++ b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiRingSorter.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,10 +16,6 @@ #include "FairTestDetectorDigi.h" // for FairTestDetectorDigi -class FairTimeStamp; - -ClassImp(FairTestDetectorDigiRingSorter); - FairTestDetectorDigiRingSorter::~FairTestDetectorDigiRingSorter() { // TODO Auto-generated destructor stub diff --git a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiSorterTask.cxx b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiSorterTask.cxx index 09e8ee6303..03cde12cf8 100644 --- a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiSorterTask.cxx +++ b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiSorterTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,11 +21,6 @@ #include // for TClonesArray -class FairRingSorter; -class FairTimeStamp; - -ClassImp(FairTestDetectorDigiSorterTask); - FairTestDetectorDigiSorterTask::FairTestDetectorDigiSorterTask() { // TODO Auto-generated constructor stub diff --git a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiWriteoutBuffer.cxx b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiWriteoutBuffer.cxx index 67f210349e..6cb340afce 100644 --- a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiWriteoutBuffer.cxx +++ b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorDigiWriteoutBuffer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,8 +21,6 @@ #include // for TClonesArray #include // for pair -ClassImp(FairTestDetectorDigiWriteoutBuffer); - FairTestDetectorDigiWriteoutBuffer::FairTestDetectorDigiWriteoutBuffer() : FairWriteoutBuffer() , fData_map() diff --git a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeDigiTask.cxx b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeDigiTask.cxx index 590ecbfe3c..9c61065cae 100644 --- a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeDigiTask.cxx +++ b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeDigiTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -107,5 +107,3 @@ Double_t FairTestDetectorTimeDigiTask::CalcTimeStamp(Double_t timeOfFlight) return result; } } - -ClassImp(FairTestDetectorTimeDigiTask); diff --git a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeRecoTask.cxx b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeRecoTask.cxx index f920c56994..68a20f987f 100644 --- a/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeRecoTask.cxx +++ b/examples/advanced/Tutorial3/timeBasedSimulation/FairTestDetectorTimeRecoTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -96,5 +96,3 @@ void FairTestDetectorTimeRecoTask::Exec(Option_t* /*opt*/) fDigiArray->Delete(); } - -ClassImp(FairTestDetectorTimeRecoTask); diff --git a/examples/advanced/propagator/macros/runMC.C b/examples/advanced/propagator/macros/runMC.C index 81827d645a..e4d258abb6 100644 --- a/examples/advanced/propagator/macros/runMC.C +++ b/examples/advanced/propagator/macros/runMC.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -55,32 +55,32 @@ int runMC(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - // run->SetSimulationConfig(new FairVMCConfig()); - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(std::make_unique(outFile)); - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + // run.SetSimulationConfig(new FairVMCConfig()); + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(std::make_unique(outFile)); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairTutPropDet* det = new FairTutPropDet("TutPropDetector", kTRUE); det->SetGeometryFileName("tutProp.geo"); - run->AddModule(det); + run.AddModule(det); FairTutPropDet* det2 = new FairTutPropDet("TutPropDetector2", kTRUE); det2->SetGeometryFileName("tutProp2.geo"); det2->SetPointsArrayName("FairTutPropPoint2"); - run->AddModule(det2); + run.AddModule(det2); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -99,13 +99,13 @@ int runMC(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals FairConstField* fMagField = new FairConstField(); fMagField->SetField(0., 0., 20.); // values are in kG fMagField->SetFieldRegion(-150, 150, -150, 150, -250, 250); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax) - run->SetField(fMagField); + run.SetField(fMagField); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ - run->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); // ----- Initialize simulation run ------------------------------------ - run->Init(); + run.Init(); // ------------------------------------------------------------------------ FairTrajFilter* trajFilter = FairTrajFilter::Instance(); trajFilter->SetStepSizeCut(0.01); // 1 cm @@ -126,8 +126,8 @@ int runMC(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/advanced/propagator/macros/runMM.C b/examples/advanced/propagator/macros/runMM.C index db3aeec1a7..652cff0369 100644 --- a/examples/advanced/propagator/macros/runMM.C +++ b/examples/advanced/propagator/macros/runMM.C @@ -1,10 +1,16 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#include +#include +#include +#include + int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = false) { UInt_t randomSeed = 123456; @@ -41,32 +47,32 @@ int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - // run->SetSimulationConfig(new FairVMCConfig()); - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(new FairRootFileSink(outFile)); // Output file - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + // run.SetSimulationConfig(new FairVMCConfig()); + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(new FairRootFileSink(outFile)); // Output file + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairTutPropDet* det = new FairTutPropDet("TutPropDetector", kTRUE); det->SetGeometryFileName("tutProp.geo"); - run->AddModule(det); + run.AddModule(det); FairTutPropDet* det2 = new FairTutPropDet("TutPropDetector", kTRUE); det2->SetGeometryFileName("tutProp2.geo"); det2->SetPointsArrayName("FairTutPropPoint2"); - run->AddModule(det2); + run.AddModule(det2); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -93,13 +99,13 @@ int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals FairConstField* fMagField = new FairConstField(); fMagField->SetField(0., 0., 20.); // values are in kG fMagField->SetFieldRegion(-150, 150, -150, 150, -250, 250); // values are in cm (xmin,xmax,ymin,ymax,zmin,zmax) - run->SetField(fMagField); + run.SetField(fMagField); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -113,8 +119,8 @@ int runMM(Int_t nEvents = 1000, TString mcEngine = "TGeant4", Bool_t isMT = fals // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/advanced/propagator/macros/runPull.C b/examples/advanced/propagator/macros/runPull.C index 90261b17ef..c801bf2d74 100644 --- a/examples/advanced/propagator/macros/runPull.C +++ b/examples/advanced/propagator/macros/runPull.C @@ -1,10 +1,29 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#if !defined(__CLING__) || defined(__ROOTCLING__) +#include "FairTrackParP.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using std::cout; +using std::endl; + int runPull(std::string propName = "rk", bool drawHist = false) { if (propName != "geane" && propName != "rk") { @@ -15,11 +34,10 @@ int runPull(std::string propName = "rk", bool drawHist = false) gROOT->Reset(); gStyle->SetOptFit(1); - TFile* f = new TFile(Form("prop.%s.cal.root", propName.c_str())); - TTree* simtree = (TTree*)f->Get("cbmsim"); + std::unique_ptr f{TFile::Open(Form("prop.%s.cal.root", propName.c_str()))}; + std::unique_ptr simtree{f->Get("cbmsim")}; TClonesArray* fTrackParProp = new TClonesArray("FairTrackParP"); - TClonesArray* fTrackParIni = new TClonesArray("FairTrackParP"); TClonesArray* fTrackParFinal = new TClonesArray("FairTrackParP"); Double_t maxDist = 0.1; diff --git a/examples/advanced/propagator/src/CMakeLists.txt b/examples/advanced/propagator/src/CMakeLists.txt index 0acfb8b6ab..f1df21bcec 100644 --- a/examples/advanced/propagator/src/CMakeLists.txt +++ b/examples/advanced/propagator/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ - # Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # Copyright (C) 2019-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -39,11 +39,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/advanced/propagator/src/FairEveRecoTracksExample.cxx b/examples/advanced/propagator/src/FairEveRecoTracksExample.cxx index c08e609d63..5c7d846d15 100644 --- a/examples/advanced/propagator/src/FairEveRecoTracksExample.cxx +++ b/examples/advanced/propagator/src/FairEveRecoTracksExample.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,6 +18,7 @@ #include "FairEveRecoTrack.h" #include "FairEveTrack.h" +#include "FairEventManager.h" #include "FairField.h" #include "FairHit.h" #include "FairMCTrack.h" @@ -197,19 +198,19 @@ InitStatus FairEveRecoTracksExample::Init() auto status = FairEveTracks::Init(); if (status != kSUCCESS) return status; - FairRootManager *mngr = FairRootManager::Instance(); - fContainerReco = (TClonesArray *)mngr->GetObject("FairTutPropTracks"); + FairRootManager& mngr = GetEventManager()->GetRootManager(); + fContainerReco = dynamic_cast(mngr.GetObject("FairTutPropTracks")); if (fContainerReco == nullptr) { LOG(error) << "Reco traks not found"; return kFATAL; } - fHits1 = (TClonesArray *)mngr->GetObject("FairTutPropHits"); - fHits2 = (TClonesArray *)mngr->GetObject("FairTutPropHits2"); + fHits1 = dynamic_cast(mngr.GetObject("FairTutPropHits")); + fHits2 = dynamic_cast(mngr.GetObject("FairTutPropHits2")); if (fHits1 == nullptr || fHits2 == nullptr) { LOG(error) << "Hits not found"; return kFATAL; } - fContainerSim = (TClonesArray *)mngr->GetObject("MCTrack"); + fContainerSim = dynamic_cast(mngr.GetObject("MCTrack")); if (fContainerSim == nullptr) { LOG(warning) << "No branch with MC tracks"; } diff --git a/examples/advanced/propagator/src/FairTutPropContFact.cxx b/examples/advanced/propagator/src/FairTutPropContFact.cxx index a42fdb8d2e..34614225e3 100644 --- a/examples/advanced/propagator/src/FairTutPropContFact.cxx +++ b/examples/advanced/propagator/src/FairTutPropContFact.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,8 +13,6 @@ #include // for strcmp, NULL -class FairParSet; - static FairTutPropContFact gFairTutPropContFact; FairTutPropContFact::FairTutPropContFact() @@ -45,5 +43,3 @@ FairParSet* FairTutPropContFact::createContainer(FairContainer* c) return nullptr; } - -ClassImp(FairTutPropContFact); diff --git a/examples/advanced/propagator/src/FairTutPropContFact.h b/examples/advanced/propagator/src/FairTutPropContFact.h index ea2decda72..bd6c9983fd 100644 --- a/examples/advanced/propagator/src/FairTutPropContFact.h +++ b/examples/advanced/propagator/src/FairTutPropContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,9 +9,6 @@ #define FAIRTUTPROPCONTFACT_H_ #include "FairContFact.h" // for FairContFact, etc -#include "Rtypes.h" // for ClassDef - -class FairParSet; class FairTutPropContFact : public FairContFact { diff --git a/examples/advanced/propagator/src/FairTutPropDet.cxx b/examples/advanced/propagator/src/FairTutPropDet.cxx index f4ab4777e0..e5860a8173 100644 --- a/examples/advanced/propagator/src/FairTutPropDet.cxx +++ b/examples/advanced/propagator/src/FairTutPropDet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -62,8 +62,6 @@ FairTutPropDet::~FairTutPropDet() } } -void FairTutPropDet::Initialize() { FairDetector::Initialize(); } - Bool_t FairTutPropDet::ProcessHits(FairVolume* vol) { @@ -160,5 +158,3 @@ FairTutPropPoint* FairTutPropDet::AddHit(Int_t trackID, Int_t size = fFairTutPropPointCollection->GetEntriesFast(); return new ((*fFairTutPropPointCollection)[size]) FairTutPropPoint(trackID, detID, pos, mom, time, length, eLoss); } - -ClassImp(FairTutPropDet); diff --git a/examples/advanced/propagator/src/FairTutPropDet.h b/examples/advanced/propagator/src/FairTutPropDet.h index 8f048b2b86..0f5f3bb183 100644 --- a/examples/advanced/propagator/src/FairTutPropDet.h +++ b/examples/advanced/propagator/src/FairTutPropDet.h @@ -32,9 +32,6 @@ class FairTutPropDet : public FairDetector /** destructor */ ~FairTutPropDet() override; - /** Initialization of the detector is done here */ - void Initialize() override; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ diff --git a/examples/advanced/propagator/src/FairTutPropGeo.cxx b/examples/advanced/propagator/src/FairTutPropGeo.cxx index 08956335b9..85d03f620e 100644 --- a/examples/advanced/propagator/src/FairTutPropGeo.cxx +++ b/examples/advanced/propagator/src/FairTutPropGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,40 +7,7 @@ ********************************************************************************/ #include "FairTutPropGeo.h" -#include // for sprintf - -ClassImp(FairTutPropGeo); - // ----- Default constructor ------------------------------------------- FairTutPropGeo::FairTutPropGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "Pixel"; - strcpy(modName, "Pixel"); - strcpy(eleName, "Pixel"); - maxSectors = 0; - maxModules = 10; -} - -// ------------------------------------------------------------------------- - -const char* FairTutPropGeo::getModuleName(Int_t m) -{ - /** Returns the module name of Pixel number m - Setting Pixel here means that all modules names in the - ASCII file should start with Pixel otherwise they will - not be constructed - */ - sprintf(modName, "Pixel%i", m + 1); - return modName; -} - -const char* FairTutPropGeo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - sprintf(eleName, "Pixel%i", m + 1); - return eleName; -} + : FairGeoSet("Pixel", 10) +{} diff --git a/examples/advanced/propagator/src/FairTutPropGeo.h b/examples/advanced/propagator/src/FairTutPropGeo.h index 0926baafc7..5a190d1462 100644 --- a/examples/advanced/propagator/src/FairTutPropGeo.h +++ b/examples/advanced/propagator/src/FairTutPropGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,32 +9,15 @@ #define FAIRTUTPROPGEO_H #include "FairGeoSet.h" // for FairGeoSet -#include "Rtypes.h" // for FairTutPropGeo::Class, ClassDef, FairTutPropGeo::Streamer -#include "TString.h" // for TString + +#include // for FairTutPropGeo::Class, ClassDef, FairTutPropGeo::Streamer class FairTutPropGeo : public FairGeoSet { - - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module public: FairTutPropGeo(); - ~FairTutPropGeo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(FairTutPropGeo, 1); + ~FairTutPropGeo() override = default; + ClassDefOverride(FairTutPropGeo, 1); }; -inline Int_t FairTutPropGeo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - newdetector ?? has to be 11. - */ - return static_cast((name[5] - '0') - 1); // -} - #endif // FAIRTUTPROPGEO_H diff --git a/examples/advanced/propagator/src/FairTutPropGeoPar.cxx b/examples/advanced/propagator/src/FairTutPropGeoPar.cxx index d410015abb..d0423d44f7 100644 --- a/examples/advanced/propagator/src/FairTutPropGeoPar.cxx +++ b/examples/advanced/propagator/src/FairTutPropGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,15 @@ #include -ClassImp(FairTutPropGeoPar); - FairTutPropGeoPar ::FairTutPropGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -FairTutPropGeoPar::~FairTutPropGeoPar(void) {} +FairTutPropGeoPar::~FairTutPropGeoPar() {} -void FairTutPropGeoPar::clear(void) +void FairTutPropGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/advanced/propagator/src/FairTutPropHit.cxx b/examples/advanced/propagator/src/FairTutPropHit.cxx index 2920e37cca..c4b3505ed7 100644 --- a/examples/advanced/propagator/src/FairTutPropHit.cxx +++ b/examples/advanced/propagator/src/FairTutPropHit.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -40,5 +40,3 @@ FairTutPropHit::FairTutPropHit(int detID, {} FairTutPropHit::~FairTutPropHit() {} - -ClassImp(FairTutPropHit); diff --git a/examples/advanced/propagator/src/FairTutPropHitProducer.cxx b/examples/advanced/propagator/src/FairTutPropHitProducer.cxx index 0414f6a451..a67aad4b92 100644 --- a/examples/advanced/propagator/src/FairTutPropHitProducer.cxx +++ b/examples/advanced/propagator/src/FairTutPropHitProducer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -133,6 +133,7 @@ void FairTutPropHitProducer::Exec(Option_t* /*option*/) } } -void FairTutPropHitProducer::Finish() { LOG(debug) << "Finish of FairTutPropHitProducer"; } - -ClassImp(FairTutPropHitProducer); +void FairTutPropHitProducer::Finish() +{ + LOG(debug) << "Finish of FairTutPropHitProducer"; +} diff --git a/examples/advanced/propagator/src/FairTutPropPoint.cxx b/examples/advanced/propagator/src/FairTutPropPoint.cxx index 0a75929244..5cc4997788 100644 --- a/examples/advanced/propagator/src/FairTutPropPoint.cxx +++ b/examples/advanced/propagator/src/FairTutPropPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -45,5 +45,3 @@ void FairTutPropPoint::Print(const Option_t* /*opt*/) const << endl; } // ------------------------------------------------------------------------- - -ClassImp(FairTutPropPoint); diff --git a/examples/advanced/propagator/src/FairTutPropTr.cxx b/examples/advanced/propagator/src/FairTutPropTr.cxx index ea5641fdd2..8f6b3f4ce9 100644 --- a/examples/advanced/propagator/src/FairTutPropTr.cxx +++ b/examples/advanced/propagator/src/FairTutPropTr.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2019-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -97,8 +97,8 @@ void FairTutPropTr::InitPropagator() fPro->SetDestinationPlane(planePoint, planeVectJ, planeVectK); fPropagatorSet = true; - return; } + // ------------------------------------------------------------------------- // ----- Public method Exec -------------------------------------------- @@ -235,5 +235,3 @@ void FairTutPropTr::Finish() if (fTrackParFinal) fTrackParFinal->Delete(); } - -ClassImp(FairTutPropTr); diff --git a/examples/advanced/propagator/src/FairTutPropTrack.cxx b/examples/advanced/propagator/src/FairTutPropTrack.cxx index 4564fc4cfe..aa83923528 100644 --- a/examples/advanced/propagator/src/FairTutPropTrack.cxx +++ b/examples/advanced/propagator/src/FairTutPropTrack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,8 +11,6 @@ #include "FairLogger.h" #include "FairRootManager.h" -ClassImp(FairTutPropTrack); - FairTutPropTrack::FairTutPropTrack() : TObject() , fPdgCode(0) diff --git a/examples/advanced/propagator/src/FairTutPropTrackFinder.cxx b/examples/advanced/propagator/src/FairTutPropTrackFinder.cxx index 85af19e42a..00db7c93ff 100644 --- a/examples/advanced/propagator/src/FairTutPropTrackFinder.cxx +++ b/examples/advanced/propagator/src/FairTutPropTrackFinder.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -178,6 +178,7 @@ void FairTutPropTrackFinder::Exec(Option_t* /*option*/) } } -void FairTutPropTrackFinder::Finish() { LOG(debug) << "Finish of FairTutPropTrackFinder"; } - -ClassImp(FairTutPropTrackFinder); +void FairTutPropTrackFinder::Finish() +{ + LOG(debug) << "Finish of FairTutPropTrackFinder"; +} diff --git a/examples/common/eventdisplay/CMakeLists.txt b/examples/common/eventdisplay/CMakeLists.txt index 55d09ff90a..7587204e9b 100644 --- a/examples/common/eventdisplay/CMakeLists.txt +++ b/examples/common/eventdisplay/CMakeLists.txt @@ -25,11 +25,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator @@ -49,7 +44,7 @@ target_link_libraries(${target} fairroot_target_root_dictionary(${target} HEADERS ${headers} - LINKDEF EventDisplayExampleLinkDef.h + LINKDEF LinkDef.h EXTRA_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR} ) diff --git a/examples/common/eventdisplay/FairEveMCTracks.cxx b/examples/common/eventdisplay/FairEveMCTracks.cxx index 64e502e5ab..63336eb2eb 100644 --- a/examples/common/eventdisplay/FairEveMCTracks.cxx +++ b/examples/common/eventdisplay/FairEveMCTracks.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -36,17 +36,15 @@ FairEveMCTracks::FairEveMCTracks() : FairEveTracks(kFALSE) - , fContainer(nullptr) , fShowPrimary(kTRUE) , fShowSecondary(kTRUE) , fUsePdg(kFALSE) , fPdgCut(0) - , fPDG(nullptr) { SetElementNameTitle("FairMCTracks", "FairMCTracks"); } -Bool_t FairEveMCTracks::CheckCuts(FairMCTrack *tr) +Bool_t FairEveMCTracks::CheckCuts(FairMCTrack* tr) { TLorentzVector mom; tr->Get4Momentum(mom); @@ -87,11 +85,11 @@ void FairEveMCTracks::DrawTrack(Int_t id) if (!fRK) return; - FairMCTrack *tr = (FairMCTrack *)fContainer->UncheckedAt(id); + auto tr = static_cast(fContainer->UncheckedAt(id)); if (!CheckCuts(tr)) return; Color_t color = GetEventManager()->Color(tr->GetPdgCode()); - TEveTrackList *trList = FindTrackGroup(Form("%i", tr->GetPdgCode()), color); + TEveTrackList* trList = FindTrackGroup(Form("%i", tr->GetPdgCode()), color); TParticle p(tr->GetPdgCode(), 0, 0, @@ -106,14 +104,14 @@ void FairEveMCTracks::DrawTrack(Int_t id) tr->GetStartY(), tr->GetStartZ(), tr->GetStartT()); - FairEveTrack *track = new FairEveTrack(&p, tr->GetPdgCode(), trList->GetPropagator()); + auto track = new FairEveTrack(&p, tr->GetPdgCode(), trList->GetPropagator()); track->SetElementTitle(Form("p={%4.3f,%4.3f,%4.3f}", p.Px(), p.Py(), p.Pz())); track->SetMainColor(color); TVector3 pos(p.Vx(), p.Vy(), p.Vz()); TVector3 mom(p.Px(), p.Py(), p.Pz()); track->SetFirstPoint(mom, pos); - TParticlePDG *part = fPDG->GetParticle(tr->GetPdgCode()); + TParticlePDG* part = fPDG->GetParticle(tr->GetPdgCode()); Double_t charge = 0; if (part) { @@ -150,20 +148,21 @@ InitStatus FairEveMCTracks::Init() auto status = FairEveTracks::Init(); if (status != kSUCCESS) return status; - FairRootManager *mngr = FairRootManager::Instance(); - fContainer = dynamic_cast(mngr->GetObject("MCTrack")); + FairEventManager* eveManager = GetEventManager(); + FairRootManager* mngr = &(eveManager->GetRootManager()); + fContainer = dynamic_cast(mngr->GetObject("MCTrack")); if (!fContainer) { LOG(warning) << "MCTrack branch not found ! FairMCTrackDraw will be deactivated."; return kERROR; } - TClass *classTrack = fContainer->GetClass(); + TClass* classTrack = fContainer->GetClass(); if (classTrack && !classTrack->InheritsFrom("FairMCTrack")) { LOG(warning) << "MCTrack branch found but does not contain FairMCTrack objects! FairMCTrackDraw will be deactivated."; return kERROR; } - FairRunAna *ana = FairRunAna::Instance(); - FairField *field = ana->GetField(); + FairRunAna* ana = FairRunAna::Instance(); + FairField* field = ana->GetField(); if (field == nullptr) { LOG(warning) << "Lack of magnetic field map!"; } diff --git a/examples/common/eventdisplay/FairEveMCTracks.h b/examples/common/eventdisplay/FairEveMCTracks.h index 1168a20889..a3159871c5 100644 --- a/examples/common/eventdisplay/FairEveMCTracks.h +++ b/examples/common/eventdisplay/FairEveMCTracks.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,17 +29,16 @@ class TBuffer; class TClass; class TClonesArray; class TDatabasePDG; -class TMemberInspector; class FairEveMCTracks : public FairEveTracks { - TClonesArray *fContainer; + TClonesArray* fContainer{nullptr}; Bool_t fShowPrimary; Bool_t fShowSecondary; Bool_t fUsePdg; Int_t fPdgCut; std::unique_ptr fRK{}; - TDatabasePDG *fPDG; + TDatabasePDG* fPDG{nullptr}; protected: Bool_t CheckCuts(FairMCTrack *tr); diff --git a/examples/common/eventdisplay/FairEveMCTracksEditor.h b/examples/common/eventdisplay/FairEveMCTracksEditor.h index 951fd4d5a5..770d9bd8b9 100644 --- a/examples/common/eventdisplay/FairEveMCTracksEditor.h +++ b/examples/common/eventdisplay/FairEveMCTracksEditor.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,10 +28,8 @@ class FairEveMinMaxCut; // lines 26-26 class TBuffer; class TClass; class TGWindow; -class TMemberInspector; class TObject; - class FairEveMCTracksEditor : public TGedFrame { std::unique_ptr fPtCut; diff --git a/examples/common/eventdisplay/FairMCTracksDraw.h b/examples/common/eventdisplay/FairMCTracksDraw.h index af85a0e296..38f4820435 100644 --- a/examples/common/eventdisplay/FairMCTracksDraw.h +++ b/examples/common/eventdisplay/FairMCTracksDraw.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,8 +23,7 @@ class FairEventManager; // lines 22-22 class FairMCTrack; // lines 23-23 class TBuffer; class TClass; -class TEveTrackList; // lines 24-24 -class TMemberInspector; +class TEveTrackList; class FairMCTracksDraw : public FairTask { diff --git a/examples/common/eventdisplay/EventDisplayExampleLinkDef.h b/examples/common/eventdisplay/LinkDef.h similarity index 100% rename from examples/common/eventdisplay/EventDisplayExampleLinkDef.h rename to examples/common/eventdisplay/LinkDef.h diff --git a/examples/common/gconfig/CMakeLists.txt b/examples/common/gconfig/CMakeLists.txt index a77319baa6..256c9a0165 100644 --- a/examples/common/gconfig/CMakeLists.txt +++ b/examples/common/gconfig/CMakeLists.txt @@ -24,11 +24,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator FairRoot::Tools # FairLogger @@ -40,7 +35,7 @@ target_link_libraries(${target} PUBLIC fairroot_target_root_dictionary(${target} HEADERS ${headers} - LINKDEF GConfigLinkDef.h + LINKDEF LinkDef.h EXTRA_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR} ) diff --git a/examples/common/gconfig/FairVMCConfig.cxx b/examples/common/gconfig/FairVMCConfig.cxx index 8d5accea83..2ff761ed7f 100644 --- a/examples/common/gconfig/FairVMCConfig.cxx +++ b/examples/common/gconfig/FairVMCConfig.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -32,5 +32,3 @@ void FairVMCConfig::SetupStack() stack->SetMinPoints(fYamlConfig["FairStack_MinPoints"].as()); TVirtualMC::GetMC()->SetStack(stack); } - -ClassImp(FairVMCConfig); diff --git a/examples/common/gconfig/GConfigLinkDef.h b/examples/common/gconfig/LinkDef.h similarity index 100% rename from examples/common/gconfig/GConfigLinkDef.h rename to examples/common/gconfig/LinkDef.h diff --git a/examples/common/geometry/target_rutherford.geo b/examples/common/geometry/target_rutherford.geo index 21c169a830..beeb2c1e34 100644 --- a/examples/common/geometry/target_rutherford.geo +++ b/examples/common/geometry/target_rutherford.geo @@ -1,5 +1,5 @@ //******************************** -targ +target1 cave BOX gold diff --git a/examples/common/mcstack/CMakeLists.txt b/examples/common/mcstack/CMakeLists.txt index 14c2527c2d..9cebc30630 100644 --- a/examples/common/mcstack/CMakeLists.txt +++ b/examples/common/mcstack/CMakeLists.txt @@ -28,11 +28,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator @@ -50,7 +45,7 @@ target_link_libraries(${target} fairroot_target_root_dictionary(${target} HEADERS ${headers} - LINKDEF MCStackLinkDef.h + LINKDEF LinkDef.h EXTRA_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR} ) diff --git a/examples/common/mcstack/FairMCTrack.cxx b/examples/common/mcstack/FairMCTrack.cxx index 4f0f699cde..2d7119abae 100644 --- a/examples/common/mcstack/FairMCTrack.cxx +++ b/examples/common/mcstack/FairMCTrack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -159,5 +159,3 @@ void FairMCTrack::SetNPoints(Int_t iDet, Int_t nPoints) else LOG(error) << "Unknown detector ID " << iDet; } - -ClassImp(FairMCTrack); diff --git a/examples/common/mcstack/FairStack.cxx b/examples/common/mcstack/FairStack.cxx index 262dec00f6..4b1691d44f 100644 --- a/examples/common/mcstack/FairStack.cxx +++ b/examples/common/mcstack/FairStack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -473,5 +473,3 @@ void FairStack::SelectTracks() } } } - -ClassImp(FairStack); diff --git a/examples/common/mcstack/FairStack.h b/examples/common/mcstack/FairStack.h index 7c4938d0d1..0586075d7d 100644 --- a/examples/common/mcstack/FairStack.h +++ b/examples/common/mcstack/FairStack.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -45,9 +45,6 @@ #include // for stack #include // for pair -class TClonesArray; -class TRefArray; - class FairStack : public FairGenericStack { public: @@ -165,7 +162,7 @@ class FairStack : public FairGenericStack void FillTrackArray() override; /** Update the track index in the MCTracks and MCPoints **/ - void UpdateTrackIndex(TRefArray* detArray = 0) override; + void UpdateTrackIndex(TRefArray* detArray = nullptr) override; /** Resets arrays and stack and deletes particles and tracks **/ void Reset() override; @@ -174,7 +171,6 @@ class FairStack : public FairGenericStack void Register() override; /** Output to screen - **@param iVerbose: 0=events summary, 1=track info **/ void Print(Option_t*) const override; @@ -199,24 +195,14 @@ class FairStack : public FairGenericStack TParticle* GetParticle(Int_t trackId) const; TClonesArray* GetListOfParticles() override { return fParticles; } - void SetParticleArray(TClonesArray* partArray) override - { - for (Int_t ipart = 0; ipart < partArray->GetEntries(); ipart++) { - ((TParticle*)(partArray->At(ipart)))->SetUniqueID(fNPrimaries); - fStack.push((TParticle*)partArray->At(ipart)); - AddParticle((TParticle*)partArray->At(ipart)); - fNParticles++; - fNPrimaries++; - } - } - void SetParticleArray(TClonesArray* partArray, Int_t partFrom, Int_t partTo) override { for (Int_t ipart = partFrom; ipart < partTo; ipart++) { - ((TParticle*)(partArray->At(ipart)))->SetUniqueID(fNPrimaries); - ((TParticle*)(partArray->At(ipart)))->SetStatusCode(fNPrimaries); - fStack.push((TParticle*)partArray->At(ipart)); - AddParticle((TParticle*)partArray->At(ipart)); + auto particle = static_cast(partArray->At(ipart)); + particle->SetUniqueID(fNPrimaries); + particle->SetStatusCode(fNPrimaries); + fStack.push(particle); + AddParticle(particle); fNParticles++; fNPrimaries++; } @@ -225,7 +211,7 @@ class FairStack : public FairGenericStack /** Clone this object (used in MT mode only) */ FairGenericStack* CloneStack() const override { - FairStack* clonedStack = new FairStack(); + auto clonedStack = new FairStack(); clonedStack->StoreSecondaries(fStoreSecondaries); clonedStack->SetMinPoints(fMinPoints); clonedStack->SetEnergyCut(fEnergyCut); diff --git a/examples/common/mcstack/MCStackLinkDef.h b/examples/common/mcstack/LinkDef.h similarity index 100% rename from examples/common/mcstack/MCStackLinkDef.h rename to examples/common/mcstack/LinkDef.h diff --git a/examples/common/passive/CMakeLists.txt b/examples/common/passive/CMakeLists.txt index 8483e51ae5..1ba42dc510 100644 --- a/examples/common/passive/CMakeLists.txt +++ b/examples/common/passive/CMakeLists.txt @@ -32,11 +32,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator @@ -50,7 +45,7 @@ target_link_libraries(${target} fairroot_target_root_dictionary(${target} HEADERS ${headers} - LINKDEF PassiveLinkDef.h + LINKDEF LinkDef.h EXTRA_INCLUDE_DIRS ${CMAKE_INSTALL_FULL_INCLUDEDIR} ) diff --git a/examples/common/passive/FairCave.cxx b/examples/common/passive/FairCave.cxx index e3c5f18c60..beb4a014d6 100644 --- a/examples/common/passive/FairCave.cxx +++ b/examples/common/passive/FairCave.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,8 +21,6 @@ #include // for TObjArray #include // for TString -ClassImp(FairCave); - void FairCave::ConstructGeometry() { FairGeoLoader* loader = FairGeoLoader::Instance(); diff --git a/examples/common/passive/FairGeoCave.cxx b/examples/common/passive/FairGeoCave.cxx index afd0694a04..20be28993a 100644 --- a/examples/common/passive/FairGeoCave.cxx +++ b/examples/common/passive/FairGeoCave.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,15 +28,10 @@ #include // for cout #include // for strcmp -ClassImp(FairGeoCave); - FairGeoCave::FairGeoCave() - : FairGeoSet() + : FairGeoSet("cave", 1) , name("cave") -{ - fName = "cave"; - maxModules = 1; -} +{} Bool_t FairGeoCave::read(std::fstream& fin, FairGeoMedia* media) { diff --git a/examples/common/passive/FairGeoCave.h b/examples/common/passive/FairGeoCave.h index 11eeb89cb4..f947930ebc 100644 --- a/examples/common/passive/FairGeoCave.h +++ b/examples/common/passive/FairGeoCave.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include // for TString #include // for fstream -class FairGeoMedia; - class FairGeoCave : public FairGeoSet { protected: @@ -23,14 +21,14 @@ class FairGeoCave : public FairGeoSet public: FairGeoCave(); - ~FairGeoCave() {} - const char* getModuleName(Int_t) { return name.Data(); } - Bool_t read(std::fstream&, FairGeoMedia*); - void addRefNodes(); - void write(std::fstream&); - void print(); + ~FairGeoCave() override = default; + const char* getModuleName(Int_t) override { return name.Data(); } + Bool_t read(std::fstream&, FairGeoMedia*) override; + void addRefNodes() override; + void write(std::fstream&) override; + void print() override; - ClassDef(FairGeoCave, 0); // Class for the geometry of CAVE + ClassDefOverride(FairGeoCave, 0); // Class for the geometry of CAVE }; #endif /* !FAIRGEOCAVE_H */ diff --git a/examples/common/passive/FairGeoMagnet.cxx b/examples/common/passive/FairGeoMagnet.cxx index a57bd8519e..bbb4dc2c84 100644 --- a/examples/common/passive/FairGeoMagnet.cxx +++ b/examples/common/passive/FairGeoMagnet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,18 +17,6 @@ #include "FairGeoMagnet.h" -#include // for TString -#include // for strcpy - -ClassImp(FairGeoMagnet); - FairGeoMagnet::FairGeoMagnet() - : FairGeoSet() -{ - // Constructor - fName = "magnet"; - maxSectors = 0; - maxModules = 1; - strcpy(modName, "m"); - strcpy(eleName, "m"); -} + : FairGeoSet("magnet", 1) +{} diff --git a/examples/common/passive/FairGeoMagnet.h b/examples/common/passive/FairGeoMagnet.h index 31e707c707..028b37cc23 100644 --- a/examples/common/passive/FairGeoMagnet.h +++ b/examples/common/passive/FairGeoMagnet.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,15 +15,15 @@ class FairGeoMagnet : public FairGeoSet { protected: - char modName[2]; // name of module - char eleName[2]; // substring for elements in module + char modName[2]{"m"}; // name of module + char eleName[2]{"m"}; // substring for elements in module public: FairGeoMagnet(); - ~FairGeoMagnet() {} - const char* getModuleName(Int_t) { return modName; } - const char* getEleName(Int_t) { return eleName; } - ClassDef(FairGeoMagnet, 0); // Class for the geometry of Magnet + ~FairGeoMagnet() override = default; + const char* getModuleName(Int_t) override { return modName; } + const char* getEleName(Int_t) override { return eleName; } + ClassDefOverride(FairGeoMagnet, 0); // Class for the geometry of Magnet }; #endif /* !FAIRGEOMAGNET_H */ diff --git a/examples/common/passive/FairGeoPassivePar.cxx b/examples/common/passive/FairGeoPassivePar.cxx index dc6bece2c5..81615e91fe 100644 --- a/examples/common/passive/FairGeoPassivePar.cxx +++ b/examples/common/passive/FairGeoPassivePar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,17 +14,15 @@ #include // for TObjArray -ClassImp(FairGeoPassivePar); - FairGeoPassivePar::FairGeoPassivePar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -FairGeoPassivePar::~FairGeoPassivePar(void) {} +FairGeoPassivePar::~FairGeoPassivePar() {} -void FairGeoPassivePar::clear(void) +void FairGeoPassivePar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/common/passive/FairGeoPassivePar.h b/examples/common/passive/FairGeoPassivePar.h index 93dceb068e..5bd09a62ad 100644 --- a/examples/common/passive/FairGeoPassivePar.h +++ b/examples/common/passive/FairGeoPassivePar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,8 +24,8 @@ class FairGeoPassivePar : public FairParGenericSet FairGeoPassivePar(const char* name = "FairGeoPassivePar", const char* title = "Passive Geometry Parameters", const char* context = "TestDefaultContext"); - ~FairGeoPassivePar(void); - void clear(void); + ~FairGeoPassivePar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/examples/common/passive/FairGeoPipe.cxx b/examples/common/passive/FairGeoPipe.cxx index 1990985b4e..e82f1d1713 100644 --- a/examples/common/passive/FairGeoPipe.cxx +++ b/examples/common/passive/FairGeoPipe.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,23 +22,11 @@ #include // for TList #include // for TString -#include // for strcpy - -class FairGeoBuilder; -class TObject; - -ClassImp(FairGeoPipe); FairGeoPipe::FairGeoPipe() - : FairGeoSet() -{ - // Constructor - fName = "pipe"; - strcpy(modName, "p"); - strcpy(eleName, "p"); - maxSectors = 0; - maxModules = 1; -} + : FairGeoSet("pipe", 1) +{} + Bool_t FairGeoPipe::create(FairGeoBuilder* build) { Bool_t rc = FairGeoSet::create(build); @@ -50,5 +38,3 @@ Bool_t FairGeoPipe::create(FairGeoBuilder* build) } return rc; } - -FairGeoPipe::~FairGeoPipe() {} diff --git a/examples/common/passive/FairGeoPipe.h b/examples/common/passive/FairGeoPipe.h index f36fa3352e..2e2077a426 100644 --- a/examples/common/passive/FairGeoPipe.h +++ b/examples/common/passive/FairGeoPipe.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,21 +12,19 @@ #include // for FairGeoPipe::Class, Int_t, etc -class FairGeoBuilder; - class FairGeoPipe : public FairGeoSet { protected: - char modName[2]; // name of module - char eleName[2]; // substring for elements in module + char modName[2]{"p"}; // name of module + char eleName[2]{"p"}; // substring for elements in module public: FairGeoPipe(); - virtual ~FairGeoPipe(); - const char* getModuleName(Int_t) { return modName; } - const char* getEleName(Int_t) { return eleName; } - Bool_t create(FairGeoBuilder*); - ClassDef(FairGeoPipe, 0); // Class for geometry of beam pipe + ~FairGeoPipe() override = default; + const char* getModuleName(Int_t) override { return modName; } + const char* getEleName(Int_t) override { return eleName; } + Bool_t create(FairGeoBuilder*) override; + ClassDefOverride(FairGeoPipe, 0); // Class for geometry of beam pipe }; #endif /* !FAIRGEOPIPE_H */ diff --git a/examples/common/passive/FairGeoTarget.cxx b/examples/common/passive/FairGeoTarget.cxx index a0e558050c..bf69b1193e 100644 --- a/examples/common/passive/FairGeoTarget.cxx +++ b/examples/common/passive/FairGeoTarget.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,18 +17,6 @@ #include "FairGeoTarget.h" -#include // for TString -#include // for strcpy - -ClassImp(FairGeoTarget); - FairGeoTarget::FairGeoTarget() - : FairGeoSet() -{ - // Constructor - fName = "target"; - strcpy(modName, "t"); - strcpy(eleName, "t"); - maxSectors = 0; - maxModules = 1; -} + : FairGeoSet("target", 1) +{} diff --git a/examples/common/passive/FairGeoTarget.h b/examples/common/passive/FairGeoTarget.h index c3e17d745e..3fbff578db 100644 --- a/examples/common/passive/FairGeoTarget.h +++ b/examples/common/passive/FairGeoTarget.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,14 +15,14 @@ class FairGeoTarget : public FairGeoSet { protected: - char modName[2]; // name of module - char eleName[2]; // substring for elements in module + char modName[2]{"t"}; // name of module + char eleName[2]{"t"}; // substring for elements in module public: FairGeoTarget(); - ~FairGeoTarget() {} - const char* getModuleName(Int_t) { return modName; } - const char* getEleName(Int_t) { return eleName; } - ClassDef(FairGeoTarget, 0); // Class for geometry of Target + ~FairGeoTarget() override = default; + const char* getModuleName(Int_t) override { return modName; } + const char* getEleName(Int_t) override { return eleName; } + ClassDefOverride(FairGeoTarget, 0); // Class for geometry of Target }; #endif /* !FAIRGEOTARGET_H */ diff --git a/examples/common/passive/FairMagnet.cxx b/examples/common/passive/FairMagnet.cxx index edff677e37..8893f2f79b 100644 --- a/examples/common/passive/FairMagnet.cxx +++ b/examples/common/passive/FairMagnet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -52,6 +52,7 @@ void FairMagnet::ConstructASCIIGeometry() FairModule::ConstructASCIIGeometry("FairGeoPassivePar"); } -FairModule* FairMagnet::CloneModule() const { return new FairMagnet(*this); } - -ClassImp(FairMagnet); +FairModule* FairMagnet::CloneModule() const +{ + return new FairMagnet(*this); +} diff --git a/examples/common/passive/FairPassiveContFact.cxx b/examples/common/passive/FairPassiveContFact.cxx index 4c7b32f8ff..73e3e24338 100644 --- a/examples/common/passive/FairPassiveContFact.cxx +++ b/examples/common/passive/FairPassiveContFact.cxx @@ -23,10 +23,6 @@ #include // for TString #include // for strcmp -class FairParSet; - -ClassImp(FairPassiveContFact); - static FairPassiveContFact gFairPassiveContFact; FairPassiveContFact::FairPassiveContFact() diff --git a/examples/common/passive/FairPassiveContFact.h b/examples/common/passive/FairPassiveContFact.h index 19d76bac1a..eba80f3101 100644 --- a/examples/common/passive/FairPassiveContFact.h +++ b/examples/common/passive/FairPassiveContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,18 +10,14 @@ #include "FairContFact.h" // for FairContFact, etc -#include // for FairPassiveContFact::Class, etc - -class FairParSet; - class FairPassiveContFact : public FairContFact { public: FairPassiveContFact(); - ~FairPassiveContFact() {} - FairParSet* createContainer(FairContainer*); + ~FairPassiveContFact() override = default; + FairParSet* createContainer(FairContainer*) override; - ClassDef(FairPassiveContFact, 0); // Factory for all Passive parameter containers + ClassDefOverride(FairPassiveContFact, 0); // Factory for all Passive parameter containers }; #endif /* !FAIRPASSIVECONTFACT_H */ diff --git a/examples/common/passive/FairPipe.cxx b/examples/common/passive/FairPipe.cxx index 3a977c8cb7..14ec55b2af 100644 --- a/examples/common/passive/FairPipe.cxx +++ b/examples/common/passive/FairPipe.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -176,6 +176,7 @@ void FairPipe::ConstructGeometry() cave->AddNode(beamPipe, 1); } -FairModule* FairPipe::CloneModule() const { return new FairPipe(*this); } - -ClassImp(FairPipe); +FairModule* FairPipe::CloneModule() const +{ + return new FairPipe(*this); +} diff --git a/examples/common/passive/FairTarget.cxx b/examples/common/passive/FairTarget.cxx index 64a2d9e200..889e99cca8 100644 --- a/examples/common/passive/FairTarget.cxx +++ b/examples/common/passive/FairTarget.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,6 +30,7 @@ void FairTarget::ConstructGeometry() ConstructASCIIGeometry("FairGeoPassivePar"); } -FairModule* FairTarget::CloneModule() const { return new FairTarget(*this); } - -ClassImp(FairTarget); +FairModule* FairTarget::CloneModule() const +{ + return new FairTarget(*this); +} diff --git a/examples/common/passive/PassiveLinkDef.h b/examples/common/passive/LinkDef.h similarity index 100% rename from examples/common/passive/PassiveLinkDef.h rename to examples/common/passive/LinkDef.h diff --git a/examples/simulation/Tutorial1/macros/CMakeLists.txt b/examples/simulation/Tutorial1/macros/CMakeLists.txt index ae7ffa0a39..6f59fbc93b 100644 --- a/examples/simulation/Tutorial1/macros/CMakeLists.txt +++ b/examples/simulation/Tutorial1/macros/CMakeLists.txt @@ -51,9 +51,16 @@ foreach(mcEngine IN LISTS mcEngine_list) ) endforeach() -add_test(NAME ex_tutorial1_PostInitConfig +add_test(NAME ex_sim_tutorial1_Geant4MT + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_tutorial1.sh 20 \"TGeant4\" true false) +set_tests_properties(ex_sim_tutorial1_Geant4MT PROPERTIES + TIMEOUT ${maxTestTime} + PASS_REGULAR_EXPRESSION "Simulation successful." +) + +add_test(NAME ex_sim_tutorial1_PostInitConfig COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_tutorial1.sh 1 \"TGeant4\" false true) -set_tests_properties(ex_tutorial1_PostInitConfig PROPERTIES +set_tests_properties(ex_sim_tutorial1_PostInitConfig PROPERTIES TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Loading Geant4 PostInit Config." ) diff --git a/examples/simulation/Tutorial1/macros/run_tutorial1.C b/examples/simulation/Tutorial1/macros/run_tutorial1.C index 999dc682ed..ac18abbf35 100644 --- a/examples/simulation/Tutorial1/macros/run_tutorial1.C +++ b/examples/simulation/Tutorial1/macros/run_tutorial1.C @@ -1,60 +1,59 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ +#include +#include #include #include #include +#include +#include #include +#include #include -void run_tutorial1(Int_t nEvents = 10, - TString mcEngine = "TGeant3", - Bool_t isMT = true, - Bool_t loadPostInitConfig = false) +using std::cout; +using std::endl; +using std::string; + +int run_tutorial1(int nEvents = 10, string mcEngine = "TGeant3", bool isMT = true, bool loadPostInitConfig = false) { - TString dir = getenv("VMCWORKDIR"); - TString tutdir = dir + "/simulation/Tutorial1"; + string dir = getenv("VMCWORKDIR"); + string tutdir = dir + "/simulation/Tutorial1"; + + string tut_geomdir = dir + "/common/geometry"; + gSystem->Setenv("GEOMPATH", tut_geomdir.c_str()); - TString tut_geomdir = dir + "/common/geometry"; - gSystem->Setenv("GEOMPATH", tut_geomdir.Data()); + string tut_configdir = dir + "/common/gconfig"; + gSystem->Setenv("CONFIG_DIR", tut_configdir.c_str()); - TString tut_configdir = dir + "/common/gconfig"; - gSystem->Setenv("CONFIG_DIR", tut_configdir.Data()); + string partName[] = {"pions", "eplus", "proton"}; + int partPdgC[] = {211, 11, 2212}; + auto chosenPart = 0; - TString partName[] = {"pions", "eplus", "proton"}; - Int_t partPdgC[] = {211, 11, 2212}; - Int_t chosenPart = 0; + auto momentum = 2.; - Double_t momentum = 2.; + auto theta = 0.; - Double_t theta = 0.; + auto nofPart = 1; - TString outDir = "./"; + string outDir = "./"; // Output file name - TString outFile = Form("%s/tutorial1_%s_%s.mc_p%1.3f_t%1.0f_n%d.root", - outDir.Data(), - mcEngine.Data(), - partName[chosenPart].Data(), - momentum, - theta, - nEvents); + string outFile = outDir + "/tutorial1_" + mcEngine + "_" + partName[chosenPart] + ".mc_p" + std::to_string(momentum) + + "_t" + std::to_string(theta) + "_n" + std::to_string(nEvents) + ".root"; // Parameter file name - TString parFile = Form("%s/tutorial1_%s_%s.params_p%1.3f_t%1.0f_n%d.root", - outDir.Data(), - mcEngine.Data(), - partName[chosenPart].Data(), - momentum, - theta, - nEvents); + string parFile = outDir + "/tutorial1_" + mcEngine + "_" + partName[chosenPart] + ".params_p" + + std::to_string(momentum) + "_t" + std::to_string(theta) + "_n" + std::to_string(nEvents) + + ".root"; - TString geoFile = "geofile_" + mcEngine + "_full.root"; + auto geoFile = "geofile_" + mcEngine + "_full.root"; // In general, the following parts need not be touched // ======================================================================== @@ -70,12 +69,12 @@ void run_tutorial1(Int_t nEvents = 10, // ----- Create simulation run ---------------------------------------- auto run = std::make_unique(); - run->SetName(mcEngine); // Transport engine + run->SetName(mcEngine.c_str()); // Transport engine auto config = std::make_unique(); if (loadPostInitConfig) config->UsePostInitConfig(); run->SetSimulationConfig(std::move(config)); - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) run->SetSink(std::make_unique(outFile)); FairRuntimeDb* rtdb = run->GetRuntimeDb(); // ------------------------------------------------------------------------ @@ -97,7 +96,7 @@ void run_tutorial1(Int_t nEvents = 10, // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); - FairBoxGenerator* boxGen = new FairBoxGenerator(partPdgC[chosenPart], 1); + FairBoxGenerator* boxGen = new FairBoxGenerator(partPdgC[chosenPart], nofPart); boxGen->SetThetaRange(theta, theta + 0.01); boxGen->SetPRange(momentum, momentum + 0.01); @@ -121,7 +120,7 @@ void run_tutorial1(Int_t nEvents = 10, Bool_t kParameterMerged = kTRUE; FairParRootFileIo* parOut = new FairParRootFileIo(kParameterMerged); - parOut->open(parFile.Data()); + parOut->open(parFile.c_str()); rtdb->setOutput(parOut); rtdb->saveOutput(); rtdb->print(); @@ -129,7 +128,7 @@ void run_tutorial1(Int_t nEvents = 10, // ----- Start run ---------------------------------------------------- run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run->CreateGeometryFile(geoFile.c_str()); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- @@ -160,4 +159,45 @@ void run_tutorial1(Int_t nEvents = 10, cout << "Macro finished successfully." << endl; // ------------------------------------------------------------------------ + + TChain chain("cbmsim"); + if (run->WasMT()) { + cout << endl << "MT mode, reading two files: t1 and t2" << endl; + chain.Add((outFile.replace(outFile.find(".root"), 5, "_t1.root")).c_str()); + chain.Add((outFile.replace(outFile.find("_t1.root"), 8, "_t2.root")).c_str()); + } else { + cout << endl << "Read from " << outFile << endl; + chain.Add(outFile.c_str()); + } + + auto nofE = chain.GetEntries(); + auto nofT = chain.Draw("MCTrack.fPx", "", "goff"); + auto nofP = chain.Draw("TutorialDetPoint.fX", "", "goff"); + auto nofB = (chain.GetListOfBranches())->GetEntries(); + auto nofL = (chain.GetListOfLeaves())->GetEntries(); + cout << "Output chain has " << nofE << " events, " << nofT << " tracks, " << nofP << " points in " << nofB + << " branches, " << nofL << " leaves." << endl; + if (nofE < nEvents) { + std::cerr << "Not enough events (" << nofE << " < " << nEvents << ") in the output chain." << endl; + return 1; + } + if (nofT < nEvents * nofPart) { + std::cerr << "Not enough tracks (" << nofT << " < " << nEvents * nofPart << ") in the output chain." << endl; + return 1; + } + if (nofP < nEvents * nofPart) { + std::cerr << "Not enough points (" << nofP << " < " << nEvents * nofPart << ") in the output chain." << endl; + return 1; + } + if (nofB != 3) { + std::cerr << "Wrong number of branches (" << nofB << " instead of 3) in the output chain." << endl; + return 1; + } + if (nofL != 46) { + std::cerr << "Wrong number of leaves (" << nofL << " instead of 46) in the output chain." << endl; + return 1; + } + cout << "Simulation successful." << endl; + + return 0; } diff --git a/examples/simulation/Tutorial1/macros/run_tutorial1_fastsim.C b/examples/simulation/Tutorial1/macros/run_tutorial1_fastsim.C index a1564d518a..c83c6bd64a 100644 --- a/examples/simulation/Tutorial1/macros/run_tutorial1_fastsim.C +++ b/examples/simulation/Tutorial1/macros/run_tutorial1_fastsim.C @@ -1,13 +1,17 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#include +#include +#include + void run_tutorial1_fastsim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t isMT = false) { - TString dir = getenv("VMCWORKDIR"); TString tutdir = dir + "/simulation/Tutorial1"; @@ -60,32 +64,32 @@ void run_tutorial1_fastsim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Boo // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(new FairRootFileSink(outFile)); // Output file - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(new FairRootFileSink(outFile)); // Output file + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairDetector* fastsim = new FairFastSimExample("FastSim"); - run->AddModule(fastsim); + run.AddModule(fastsim); FairDetector* fastsim2 = new FairFastSimExample2("FastSim2"); - run->AddModule(fastsim2); + run.AddModule(fastsim2); FairDetector* tutdet = new FairTutorialDet1("TUTDET", kTRUE); tutdet->SetGeometryFileName("double_sector.geo"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -99,7 +103,7 @@ void run_tutorial1_fastsim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Boo primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ @@ -107,11 +111,11 @@ void run_tutorial1_fastsim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Boo TRandom3 random(randomSeed); gRandom = &random; - run->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); gLogger->SetLogScreenLevel("info"); - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -125,8 +129,8 @@ void run_tutorial1_fastsim(Int_t nEvents = 10, TString mcEngine = "TGeant3", Boo // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/Tutorial1/macros/run_tutorial1_mesh.C b/examples/simulation/Tutorial1/macros/run_tutorial1_mesh.C index f144c53347..67ac1baa81 100644 --- a/examples/simulation/Tutorial1/macros/run_tutorial1_mesh.C +++ b/examples/simulation/Tutorial1/macros/run_tutorial1_mesh.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -63,25 +63,25 @@ void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetSink(std::make_unique(outFile)); - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetSink(std::make_unique(outFile)); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairDetector* tutdet = new FairTutorialDet1("TUTDET", kTRUE); tutdet->SetGeometryFileName("double_sector.geo"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -96,12 +96,12 @@ void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3") primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ - run->SetStoreTraj(kFALSE); // to store particle trajectories + run.SetStoreTraj(kFALSE); // to store particle trajectories - run->SetRadGridRegister(kTRUE); // activate RadGridManager + run.SetRadGridRegister(kTRUE); // activate RadGridManager // define two example meshs for dosimetry FairMesh* aMesh1 = new FairMesh("test1"); @@ -117,12 +117,12 @@ void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3") aMesh1->print(); aMesh2->print(); - run->AddMesh(aMesh1); - run->AddMesh(aMesh2); + run.AddMesh(aMesh1); + run.AddMesh(aMesh2); // ----- Initialize simulation run ------------------------------------ - run->Init(); - run->GetMCApplication()->GetRadGridMan()->SetOutputFileName("radGridResults.root"); + run.Init(); + run.GetMCApplication()->GetRadGridMan()->SetOutputFileName("radGridResults.root"); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -136,7 +136,7 @@ void run_tutorial1_mesh(Int_t nEvents = 10, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); + run.Run(nEvents); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/Tutorial1/macros/run_tutorial1_pythia6.C b/examples/simulation/Tutorial1/macros/run_tutorial1_pythia6.C index bde327d220..5e6d568777 100644 --- a/examples/simulation/Tutorial1/macros/run_tutorial1_pythia6.C +++ b/examples/simulation/Tutorial1/macros/run_tutorial1_pythia6.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -67,27 +67,27 @@ void run_tutorial1_pythia6(Int_t nEvents = 10, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetSink(std::make_unique(outFile)); - run->SetPythiaDecayer(pythia6Config); // Define Pythia6 as decayer + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetSink(std::make_unique(outFile)); + run.SetPythiaDecayer(pythia6Config); // Define Pythia6 as decayer - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairDetector* tutdet = new FairTutorialDet1("TUTDET", kTRUE); tutdet->SetGeometryFileName("double_sector.geo"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -101,11 +101,11 @@ void run_tutorial1_pythia6(Int_t nEvents = 10, TString mcEngine = "TGeant3") primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -119,8 +119,8 @@ void run_tutorial1_pythia6(Int_t nEvents = 10, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/Tutorial1/macros/run_tutorial1_pythia8.C b/examples/simulation/Tutorial1/macros/run_tutorial1_pythia8.C index 61db7babe3..a7f4e20f87 100644 --- a/examples/simulation/Tutorial1/macros/run_tutorial1_pythia8.C +++ b/examples/simulation/Tutorial1/macros/run_tutorial1_pythia8.C @@ -1,11 +1,12 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ +#include #include #include #include @@ -66,27 +67,27 @@ void run_tutorial1_pythia8(Int_t nEvents = 10, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetSink(std::make_unique(outFile)); - run->SetPythiaDecayer(pythia8Config); // Define Pythia8 as decayer + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetSink(std::make_unique(outFile)); + run.SetPythiaDecayer(pythia8Config); // Define Pythia8 as decayer - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairDetector* tutdet = new FairTutorialDet1("TUTDET", kTRUE); tutdet->SetGeometryFileName("double_sector.geo"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -100,11 +101,11 @@ void run_tutorial1_pythia8(Int_t nEvents = 10, TString mcEngine = "TGeant3") primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -118,8 +119,8 @@ void run_tutorial1_pythia8(Int_t nEvents = 10, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/Tutorial1/macros/run_tutorial1_urqmd.C b/examples/simulation/Tutorial1/macros/run_tutorial1_urqmd.C index 5279359568..972cddd6c8 100644 --- a/examples/simulation/Tutorial1/macros/run_tutorial1_urqmd.C +++ b/examples/simulation/Tutorial1/macros/run_tutorial1_urqmd.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,8 +9,12 @@ #include #include #include +#include #include +using std::cout; +using std::endl; + void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3") { TString dir = getenv("VMCWORKDIR"); @@ -49,25 +53,25 @@ void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetSink(std::make_unique(outFile)); - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetSink(std::make_unique(outFile)); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairDetector* tutdet = new FairTutorialDet1("TUTDET", kTRUE); tutdet->SetGeometryFileName("double_sector.geo"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -76,11 +80,11 @@ void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3") FairUrqmdGenerator* urqmdGen = new FairUrqmdGenerator(inFile.Data(), Urqmd_Conversion_table.Data()); primGen->AddGenerator(urqmdGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -94,8 +98,8 @@ void run_tutorial1_urqmd(Int_t nEvents = 2, TString mcEngine = "TGeant3") // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/Tutorial1/src/CMakeLists.txt b/examples/simulation/Tutorial1/src/CMakeLists.txt index 4c562c3d8a..c92cb469fe 100644 --- a/examples/simulation/Tutorial1/src/CMakeLists.txt +++ b/examples/simulation/Tutorial1/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -30,11 +30,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/simulation/Tutorial1/src/FairFastSimExample.cxx b/examples/simulation/Tutorial1/src/FairFastSimExample.cxx index 65f3b5b7d3..6041adedf1 100644 --- a/examples/simulation/Tutorial1/src/FairFastSimExample.cxx +++ b/examples/simulation/Tutorial1/src/FairFastSimExample.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -66,8 +66,6 @@ FairFastSimExample::~FairFastSimExample() } } -void FairFastSimExample::Initialize() { FairDetector::Initialize(); } - void FairFastSimExample::FastSimProcessParticle() { TVirtualMC::GetMC()->TrackPosition(fPos); @@ -176,6 +174,7 @@ FairTutorialDet1Point* FairFastSimExample::AddHit(Int_t trackID, Bool_t FairFastSimExample::IsSensitive(const std::string& name) { return name == "fast_sim_vol"; } -FairModule* FairFastSimExample::CloneModule() const { return new FairFastSimExample(*this); } - -ClassImp(FairFastSimExample); +FairModule* FairFastSimExample::CloneModule() const +{ + return new FairFastSimExample(*this); +} diff --git a/examples/simulation/Tutorial1/src/FairFastSimExample.h b/examples/simulation/Tutorial1/src/FairFastSimExample.h index 067d7801d6..c0fa92520b 100644 --- a/examples/simulation/Tutorial1/src/FairFastSimExample.h +++ b/examples/simulation/Tutorial1/src/FairFastSimExample.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,9 +30,6 @@ class FairFastSimExample : public FairFastSimDetector /** destructor */ virtual ~FairFastSimExample(); - /** Initialization of the detector is done here */ - virtual void Initialize(); - /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/examples/simulation/Tutorial1/src/FairFastSimExample2.cxx b/examples/simulation/Tutorial1/src/FairFastSimExample2.cxx index a39acbd60e..d0b6f475c8 100644 --- a/examples/simulation/Tutorial1/src/FairFastSimExample2.cxx +++ b/examples/simulation/Tutorial1/src/FairFastSimExample2.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -65,8 +65,6 @@ FairFastSimExample2::~FairFastSimExample2() } } -void FairFastSimExample2::Initialize() { FairDetector::Initialize(); } - void FairFastSimExample2::FastSimProcessParticle() { TVirtualMC::GetMC()->TrackPosition(fPos); @@ -156,6 +154,7 @@ FairTutorialDet1Point* FairFastSimExample2::AddHit(Int_t trackID, Bool_t FairFastSimExample2::IsSensitive(const std::string& name) { return name == "fast_sim_vol_n2"; } -FairModule* FairFastSimExample2::CloneModule() const { return new FairFastSimExample2(*this); } - -ClassImp(FairFastSimExample2); +FairModule* FairFastSimExample2::CloneModule() const +{ + return new FairFastSimExample2(*this); +} diff --git a/examples/simulation/Tutorial1/src/FairFastSimExample2.h b/examples/simulation/Tutorial1/src/FairFastSimExample2.h index 314f720549..1da52b4418 100644 --- a/examples/simulation/Tutorial1/src/FairFastSimExample2.h +++ b/examples/simulation/Tutorial1/src/FairFastSimExample2.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,9 +30,6 @@ class FairFastSimExample2 : public FairFastSimDetector /** destructor */ virtual ~FairFastSimExample2(); - /** Initialization of the detector is done here */ - virtual void Initialize(); - /** Registers the produced collections in FAIRRootManager. */ virtual void Register(); diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx b/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx index 7f0727abf1..2d68d35bd3 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -143,6 +143,7 @@ FairTutorialDet1Point* FairTutorialDet1::AddHit(Int_t trackID, return new (clref[size]) FairTutorialDet1Point(trackID, detID, pos, mom, time, length, eLoss); } -FairModule* FairTutorialDet1::CloneModule() const { return new FairTutorialDet1(*this); } - -ClassImp(FairTutorialDet1); +FairModule* FairTutorialDet1::CloneModule() const +{ + return new FairTutorialDet1(*this); +} diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.cxx b/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.cxx index 05ac604123..a9f59917c4 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.cxx +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.cxx @@ -13,10 +13,6 @@ #include // for TString #include // for strcmp -class FairParSet; - -ClassImp(FairTutorialDet1ContFact); - static FairTutorialDet1ContFact gFairTutorialDet1ContFact; FairTutorialDet1ContFact::FairTutorialDet1ContFact() diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.h b/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.h index 71e11916e2..2f81ea0ddf 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.h +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1ContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,17 +10,13 @@ #include "FairContFact.h" // for FairContFact, etc -#include - -class FairParSet; - class FairTutorialDet1ContFact : public FairContFact { public: FairTutorialDet1ContFact(); - ~FairTutorialDet1ContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(FairTutorialDet1ContFact, 0); // Factory for all MyDet parameter containers + ~FairTutorialDet1ContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(FairTutorialDet1ContFact, 0); // Factory for all MyDet parameter containers }; #endif /* !FAIRTUTORIALDETCONTFACT_H */ diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.cxx b/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.cxx index 6f7bc76648..e7f4db9af2 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.cxx +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,35 +7,6 @@ ********************************************************************************/ #include "FairTutorialDet1Geo.h" -#include // for sprintf - -ClassImp(FairTutorialDet1Geo); - FairTutorialDet1Geo::FairTutorialDet1Geo() - : FairGeoSet() -{ - // Constructor - fName = "tutdet"; - strcpy(modName, "tutdet"); - strcpy(eleName, "tutdet"); - maxSectors = 0; - maxModules = 10; -} - -const char* FairTutorialDet1Geo::getModuleName(Int_t m) -{ - /** Returns the module name of TutorialDet number m - Setting MyDet here means that all modules names in the - ASCII file should start with TutorialDet otherwise they will - not be constructed - */ - sprintf(modName, "tutdet%i", m + 1); - return modName; -} - -const char* FairTutorialDet1Geo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - sprintf(eleName, "tutdet%i", m + 1); - return eleName; -} + : FairGeoSet("tutdet", 10) +{} diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.h b/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.h index 61fb18e444..5b07fc3c92 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.h +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1Geo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,32 +10,14 @@ #include "FairGeoSet.h" // for FairGeoSet -#include // for Int_t, etc -#include // for TString +#include // for Int_t, etc class FairTutorialDet1Geo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module - public: FairTutorialDet1Geo(); - ~FairTutorialDet1Geo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(FairTutorialDet1Geo, 1); + ~FairTutorialDet1Geo() override = default; + ClassDefOverride(FairTutorialDet1Geo, 1); }; -inline Int_t FairTutorialDet1Geo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - tutdet ?? has to be 6. - */ - return static_cast((name[6] - '0') - 1); // -} - -#endif /* FAIRTUTORIALDETGEO_H */ +#endif \ No newline at end of file diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.cxx b/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.cxx index b1ed46ffd6..a3fcfaf5d4 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.cxx +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,17 +11,15 @@ #include // for TObjArray -ClassImp(FairTutorialDet1GeoPar); - FairTutorialDet1GeoPar ::FairTutorialDet1GeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -FairTutorialDet1GeoPar::~FairTutorialDet1GeoPar(void) {} +FairTutorialDet1GeoPar::~FairTutorialDet1GeoPar() {} -void FairTutorialDet1GeoPar::clear(void) +void FairTutorialDet1GeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.h b/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.h index f1c99a1bc9..4d21789839 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.h +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1GeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,8 +27,8 @@ class FairTutorialDet1GeoPar : public FairParGenericSet FairTutorialDet1GeoPar(const char* name = "FairTutorialDet1GeoPar", const char* title = "FairTutorialDet1 Geometry Parameters", const char* context = "TestDefaultContext"); - ~FairTutorialDet1GeoPar(void); - void clear(void); + ~FairTutorialDet1GeoPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/examples/simulation/Tutorial1/src/FairTutorialDet1Point.cxx b/examples/simulation/Tutorial1/src/FairTutorialDet1Point.cxx index 1107209d52..482173d422 100644 --- a/examples/simulation/Tutorial1/src/FairTutorialDet1Point.cxx +++ b/examples/simulation/Tutorial1/src/FairTutorialDet1Point.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,5 +33,3 @@ void FairTutorialDet1Point::Print(const Option_t* /*opt*/) const LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV"; } - -ClassImp(FairTutorialDet1Point); diff --git a/examples/simulation/Tutorial2/macros/CMakeLists.txt b/examples/simulation/Tutorial2/macros/CMakeLists.txt index bfbdd14e95..8873b91e40 100644 --- a/examples/simulation/Tutorial2/macros/CMakeLists.txt +++ b/examples/simulation/Tutorial2/macros/CMakeLists.txt @@ -6,79 +6,93 @@ # copied verbatim in the file "LICENSE" # ################################################################################ -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/create_digis_mixed.C) -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/create_digis.C) -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/read_digis.C) -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_background.C) -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_signal.C) -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/run_tutorial2.C) -GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/compare_seed_value.C) +set(prefix ex_sim_tutorial2) + +set(macrofiles + compare_seed_value.C + create_digis.C + create_digis_mixed.C + read_digis.C + run_background.C + run_signal.C + run_tutorial2.C) + +foreach(macro IN LISTS macrofiles) + GENERATE_ROOT_TEST_SCRIPT(${CMAKE_CURRENT_SOURCE_DIR}/${macro}) +endforeach() + +# Try to compile the macros as normal files +add_library(${prefix}_check_compile OBJECT ${macrofiles}) +target_link_libraries(${prefix}_check_compile PRIVATE + FairRoot::ExSimulation2 + FairRoot::ExPassive + FairRoot::Generators) set(maxTestTime 60) -add_test(NAME ex_sim_tutorial2 +add_test(NAME ${prefix} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_tutorial2.sh 10 \"TGeant4\" true 333) -set_tests_properties(ex_sim_tutorial2 PROPERTIES +set_tests_properties(${prefix} PROPERTIES TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_SETUP fixtures.ex_sim_tutorial2_sim - RESOURCE_LOCK ex_sim_tutorial2_paramFile + FIXTURES_SETUP fixtures.${prefix}_sim + RESOURCE_LOCK ${prefix}_paramFile ) -add_test(NAME ex_sim_tutorial2_compare_seed_value +add_test(NAME ${prefix}_compare_seed_value COMMAND ${CMAKE_CURRENT_BINARY_DIR}/compare_seed_value.sh \"tutorial2_pions.params_p2.000_t0_n10.root\" 333) -set_tests_properties(ex_sim_tutorial2_compare_seed_value PROPERTIES +set_tests_properties(${prefix}_compare_seed_value PROPERTIES TIMEOUT ${maxTestTime} - FIXTURES_REQUIRED fixtures.ex_sim_tutorial2_sim - RESOURCE_LOCK ex_sim_tutorial2_paramFile + FIXTURES_REQUIRED fixtures.${prefix}_sim + RESOURCE_LOCK ${prefix}_paramFile ) -add_test(NAME ex_sim_tutorial2_create_digis +add_test(NAME ${prefix}_create_digis COMMAND ${CMAKE_CURRENT_BINARY_DIR}/create_digis.sh) -set_tests_properties(ex_sim_tutorial2_create_digis PROPERTIES - FIXTURES_REQUIRED fixtures.ex_sim_tutorial2_sim +set_tests_properties(${prefix}_create_digis PROPERTIES + FIXTURES_REQUIRED fixtures.${prefix}_sim TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_SETUP fixtures.ex_sim_tutorial2_digi - RESOURCE_LOCK ex_sim_tutorial2_paramFile + FIXTURES_SETUP fixtures.${prefix}_digi + RESOURCE_LOCK ${prefix}_paramFile ) -add_test(NAME ex_sim_tutorial2_read_digis +add_test(NAME ${prefix}_read_digis COMMAND ${CMAKE_CURRENT_BINARY_DIR}/read_digis.sh) -set_tests_properties(ex_sim_tutorial2_read_digis PROPERTIES - FIXTURES_REQUIRED fixtures.ex_sim_tutorial2_digi +set_tests_properties(${prefix}_read_digis PROPERTIES + FIXTURES_REQUIRED fixtures.${prefix}_digi TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" ) -add_test(NAME ex_sim_tutorial2_run_background +add_test(NAME ${prefix}_run_background COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_background.sh) -set_tests_properties(ex_sim_tutorial2_run_background PROPERTIES +set_tests_properties(${prefix}_run_background PROPERTIES TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_SETUP fixtures.ex_sim_tutorial2_back + FIXTURES_SETUP fixtures.${prefix}_back ) -add_test(NAME ex_sim_tutorial2_run_signal1 +add_test(NAME ${prefix}_run_signal1 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_signal.sh 1 10) -set_tests_properties(ex_sim_tutorial2_run_signal1 PROPERTIES +set_tests_properties(${prefix}_run_signal1 PROPERTIES TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_SETUP fixtures.ex_sim_tutorial2_sig1 + FIXTURES_SETUP fixtures.${prefix}_sig1 ) -add_test(NAME ex_sim_tutorial2_run_signal2 +add_test(NAME ${prefix}_run_signal2 COMMAND ${CMAKE_CURRENT_BINARY_DIR}/run_signal.sh 2 20) -set_tests_properties(ex_sim_tutorial2_run_signal2 PROPERTIES +set_tests_properties(${prefix}_run_signal2 PROPERTIES TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" - FIXTURES_SETUP fixtures.ex_sim_tutorial2_sig2 + FIXTURES_SETUP fixtures.${prefix}_sig2 ) -add_test(NAME ex_sim_tutorial2_create_digis_mixed +add_test(NAME ${prefix}_create_digis_mixed COMMAND ${CMAKE_CURRENT_BINARY_DIR}/create_digis_mixed.sh) -set_tests_properties(ex_sim_tutorial2_create_digis_mixed PROPERTIES - FIXTURES_REQUIRED "fixtures.ex_sim_tutorial2_back;fixtures.ex_sim_tutorial2_sig1;fixtures.ex_sim_tutorial2_sig2" +set_tests_properties(${prefix}_create_digis_mixed PROPERTIES + FIXTURES_REQUIRED "fixtures.${prefix}_back;fixtures.${prefix}_sig1;fixtures.${prefix}_sig2" TIMEOUT ${maxTestTime} PASS_REGULAR_EXPRESSION "Macro finished successfully" ) diff --git a/examples/simulation/Tutorial2/macros/create_digis.C b/examples/simulation/Tutorial2/macros/create_digis.C index 03692f711b..6990ba0512 100644 --- a/examples/simulation/Tutorial2/macros/create_digis.C +++ b/examples/simulation/Tutorial2/macros/create_digis.C @@ -82,7 +82,8 @@ void create_digis() rtdb->getContainer("FairTutorialDet2DigiPar")->print(); - FairTutorialDet2DigiPar* DigiPar = (FairTutorialDet2DigiPar*)rtdb->getContainer("FairTutorialDet2DigiPar"); + auto DigiPar = dynamic_cast(rtdb->getContainer("FairTutorialDet2DigiPar")); + assert(DigiPar); DigiPar->setChanged(); DigiPar->setInputVersion(fRun->GetRunId(), 1); diff --git a/examples/simulation/Tutorial2/macros/create_digis_mixed.C b/examples/simulation/Tutorial2/macros/create_digis_mixed.C index 56b74255e4..09c9894e57 100644 --- a/examples/simulation/Tutorial2/macros/create_digis_mixed.C +++ b/examples/simulation/Tutorial2/macros/create_digis_mixed.C @@ -115,7 +115,8 @@ void create_digis_mixed() rtdb->getContainer("FairTutorialDet2DigiPar")->print(); - FairTutorialDet2DigiPar* DigiPar = (FairTutorialDet2DigiPar*)rtdb->getContainer("FairTutorialDet2DigiPar"); + auto DigiPar = dynamic_cast(rtdb->getContainer("FairTutorialDet2DigiPar")); + assert(DigiPar); DigiPar->setChanged(); DigiPar->setInputVersion(fRun->GetRunId(), 1); diff --git a/examples/simulation/Tutorial2/macros/read_digis.C b/examples/simulation/Tutorial2/macros/read_digis.C index 45344ea239..90ccd3d970 100644 --- a/examples/simulation/Tutorial2/macros/read_digis.C +++ b/examples/simulation/Tutorial2/macros/read_digis.C @@ -94,7 +94,8 @@ void read_digis() rtdb->saveOutput(); // -- Print out the random seed from the simulation ---------------------- - FairBaseParSet* BasePar = (FairBaseParSet*)rtdb->getContainer("FairBaseParSet"); + auto BasePar = dynamic_cast(rtdb->getContainer("FairBaseParSet")); + assert(BasePar); cout << "RndSeed used in simulation was " << BasePar->GetRndSeed() << endl; // ----------------------------------------------------------------------- @@ -102,7 +103,7 @@ void read_digis() // Second version to print the parameters // which also shows how to change and save them again - FairTutorialDet2DigiPar* DigiPar = (FairTutorialDet2DigiPar*)rtdb->getContainer("FairTutorialDet2DigiPar"); + auto DigiPar = static_cast(rtdb->getContainer("FairTutorialDet2DigiPar")); DigiPar->setChanged(); DigiPar->setInputVersion(fRun->GetRunId(), 1); diff --git a/examples/simulation/Tutorial2/src/CMakeLists.txt b/examples/simulation/Tutorial2/src/CMakeLists.txt index 202a004abc..5cff29b24e 100644 --- a/examples/simulation/Tutorial2/src/CMakeLists.txt +++ b/examples/simulation/Tutorial2/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -30,11 +30,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx index 3066789c1f..6040d39332 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -70,15 +70,6 @@ FairTutorialDet2::~FairTutorialDet2() } } -void FairTutorialDet2::Initialize() -{ - FairDetector::Initialize(); - /* - FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb(); - FairTutorialDet2GeoPar* par=(FairTutorialDet2GeoPar*)(rtdb->getContainer("FairTutorialDet2GeoPar")); -*/ -} - Bool_t FairTutorialDet2::ProcessHits(FairVolume* vol) { /** This method is called from the MC stepping */ @@ -177,6 +168,7 @@ FairTutorialDet2Point* FairTutorialDet2::AddHit(Int_t trackID, return new (clref[size]) FairTutorialDet2Point(trackID, detID, pos, mom, time, length, eLoss); } -FairModule* FairTutorialDet2::CloneModule() const { return new FairTutorialDet2(*this); } - -ClassImp(FairTutorialDet2); +FairModule* FairTutorialDet2::CloneModule() const +{ + return new FairTutorialDet2(*this); +} diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2.h b/examples/simulation/Tutorial2/src/FairTutorialDet2.h index eb9618c5dc..8e1a405cb9 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2.h +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2.h @@ -36,9 +36,6 @@ class FairTutorialDet2 : public FairDetector /** destructor */ virtual ~FairTutorialDet2(); - /** Initialization of the detector is done here */ - virtual void Initialize(); - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.cxx index ca02a6979a..13df8a2130 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.cxx @@ -12,8 +12,6 @@ #include // strcmp -ClassImp(FairTutorialDet2ContFact); - static FairTutorialDet2ContFact gFairTutorialDet2ContFact; FairTutorialDet2ContFact::FairTutorialDet2ContFact() diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.h b/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.h index e6f8181b37..0b1f586828 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.h +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2ContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,17 +10,13 @@ #include "FairContFact.h" -#include - -class FairParSet; - class FairTutorialDet2ContFact : public FairContFact { public: FairTutorialDet2ContFact(); - ~FairTutorialDet2ContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(FairTutorialDet2ContFact, 0); // Factory for all MyDet parameter containers + ~FairTutorialDet2ContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(FairTutorialDet2ContFact, 0); // Factory for all MyDet parameter containers }; #endif /* !FAIRTUTORIALDETCONTFACT_H */ diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2CustomTask.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2CustomTask.cxx index cdbe9f3915..405b482e18 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2CustomTask.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2CustomTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -70,5 +70,3 @@ void FairTutorialDet2CustomTask::Exec(Option_t* /*option*/) LOG(info) << " Got entry " << entry.GetX() << " " << entry.GetQ(); } } - -ClassImp(FairTutorialDet2CustomTask); diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.cxx index 0840d07835..db39964246 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,29 +12,17 @@ #include "FairTutorialDet2DigiPar.h" -#include "FairLogger.h" #include "FairParamList.h" -#include #include +#include FairTutorialDet2DigiPar::FairTutorialDet2DigiPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) - , ftutdetdigipar(new TArrayF(10)) , ftutdetdigiparsector() , ftutdetdigiparstation(-1) { detName = "TutorialDet"; - // ftutdetdigipar = new TArrayF(10); - // ftutdetdigipar = new TArrayF(10); -} - -FairTutorialDet2DigiPar::~FairTutorialDet2DigiPar() { clear(); } - -void FairTutorialDet2DigiPar::clear() -{ - status = kFALSE; - resetInputVersions(); } void FairTutorialDet2DigiPar::printparams() @@ -46,10 +34,10 @@ void FairTutorialDet2DigiPar::printparams() for (Int_t i = 0; i < size; i++) { LOG(info) << i << " :" << ftutdetdigiparsector.GetAt(i); } - size = ftutdetdigipar->GetSize(); + size = ftutdetdigipar.GetSize(); LOG(info) << "size: " << size; for (Int_t i = 0; i < size; i++) { - LOG(info) << i << " :" << ftutdetdigipar->GetAt(i); + LOG(info) << i << " :" << ftutdetdigipar.GetAt(i); } } @@ -73,8 +61,8 @@ void FairTutorialDet2DigiPar::putParams(FairParamList* l) zwischen[i] = ftutdetdigipar.GetAt(i); } */ - ftutdetdigipar->Set(array_size); - l->add("FairTutorialDet2DigiPar", *ftutdetdigipar); + ftutdetdigipar.Set(array_size); + l->add("FairTutorialDet2DigiPar", ftutdetdigipar); } Bool_t FairTutorialDet2DigiPar::getParams(FairParamList* l) @@ -103,14 +91,12 @@ Bool_t FairTutorialDet2DigiPar::getParams(FairParamList* l) Int_t array_size = (count_sectors * 10 + ftutdetdigiparstation * 3); LOG(info) << "Array Size: " << array_size; - ftutdetdigipar->Set(array_size); + ftutdetdigipar.Set(array_size); // Float_t zwischen[array_size]; - if (!(l->fill("FairTutorialDet2DigiPar", ftutdetdigipar))) { + if (!(l->fill("FairTutorialDet2DigiPar", &ftutdetdigipar))) { LOG(warn) << "Could not initialize FairTutorialDet2DigiPar"; return kFALSE; } // ftutdetdigipar.Set(array_size, zwischen); return kTRUE; } - -ClassImp(FairTutorialDet2DigiPar); diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.h b/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.h index 136d932613..2a004fff54 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.h +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2DigiPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,10 +16,10 @@ #include "FairParGenericSet.h" #include +#include #include class FairParamList; -class TArrayF; class FairTutorialDet2DigiPar : public FairParGenericSet { @@ -29,33 +29,22 @@ class FairTutorialDet2DigiPar : public FairParGenericSet const char* title = "Tutorial Det digi parameters", const char* context = "Default"); + FairTutorialDet2DigiPar(const FairTutorialDet2DigiPar&) = delete; + FairTutorialDet2DigiPar& operator=(const FairTutorialDet2DigiPar&) = delete; /** Destructor **/ - virtual ~FairTutorialDet2DigiPar(); + ~FairTutorialDet2DigiPar() override = default; - /** Initialisation from input device**/ - // virtual Bool_t init(FairParIo* input); - - /** Output to file **/ - // virtual Int_t write(FairParIo* output); - - // virtual void print(); virtual void printparams(); - /** Reset all parameters **/ - virtual void clear(); - - void putParams(FairParamList*); - Bool_t getParams(FairParamList*); + void putParams(FairParamList*) override; + Bool_t getParams(FairParamList*) override; private: - TArrayF* ftutdetdigipar; // + TArrayF ftutdetdigipar{10}; // TArrayI ftutdetdigiparsector; // Int_t ftutdetdigiparstation; // - FairTutorialDet2DigiPar(const FairTutorialDet2DigiPar&); - FairTutorialDet2DigiPar& operator=(const FairTutorialDet2DigiPar&); - - ClassDef(FairTutorialDet2DigiPar, 1); + ClassDefOverride(FairTutorialDet2DigiPar, 1); }; #endif diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2Digitizer.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2Digitizer.cxx index 13186ef322..34b1ea962f 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2Digitizer.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2Digitizer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -190,5 +190,3 @@ void FairTutorialDet2Digitizer::Register() LOG(info) << "Digitizer::Register\n"; FairRootManager::Instance()->RegisterAny("InMemory1", fCustomData2, false); } - -ClassImp(FairTutorialDet2Digitizer); diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.cxx index c60056dc75..048f6cab82 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,35 +7,6 @@ ********************************************************************************/ #include "FairTutorialDet2Geo.h" -#include - -ClassImp(FairTutorialDet2Geo); - FairTutorialDet2Geo::FairTutorialDet2Geo() - : FairGeoSet() -{ - // Constructor - fName = "tutdet"; - strcpy(modName, "tutdet"); - strcpy(eleName, "tutdet"); - maxSectors = 0; - maxModules = 10; -} - -const char* FairTutorialDet2Geo::getModuleName(Int_t m) -{ - /** Returns the module name of TutorialDet number m - Setting MyDet here means that all modules names in the - ASCII file should start with TutorialDet otherwise they will - not be constructed - */ - sprintf(modName, "tutdet%i", m + 1); - return modName; -} - -const char* FairTutorialDet2Geo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - sprintf(eleName, "tutdet%i", m + 1); - return eleName; -} + : FairGeoSet("tutdet", 10) +{} diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.h b/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.h index 1fb6135878..140d181ca3 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.h +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2Geo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,27 +14,10 @@ class FairTutorialDet2Geo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module - public: FairTutorialDet2Geo(); - ~FairTutorialDet2Geo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(FairTutorialDet2Geo, 1); + ~FairTutorialDet2Geo() override = default; + ClassDefOverride(FairTutorialDet2Geo, 1); }; -inline Int_t FairTutorialDet2Geo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - tutdet ?? has to be 6. - */ - return static_cast((name[6] - '0') - 1); // -} - #endif /* FAIRTUTORIALDETGEO_H */ diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.cxx index 35f6b568c7..e9016a5145 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,17 +11,15 @@ #include -ClassImp(FairTutorialDet2GeoPar); - FairTutorialDet2GeoPar ::FairTutorialDet2GeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -FairTutorialDet2GeoPar::~FairTutorialDet2GeoPar(void) {} +FairTutorialDet2GeoPar::~FairTutorialDet2GeoPar() {} -void FairTutorialDet2GeoPar::clear(void) +void FairTutorialDet2GeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.h b/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.h index 7410f79408..c726b39290 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.h +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2GeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,8 +27,8 @@ class FairTutorialDet2GeoPar : public FairParGenericSet FairTutorialDet2GeoPar(const char* name = "FairTutorialDet2GeoPar", const char* title = "FairTutorialDet2 Geometry Parameters", const char* context = "TestDefaultContext"); - ~FairTutorialDet2GeoPar(void); - void clear(void); + ~FairTutorialDet2GeoPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/examples/simulation/Tutorial2/src/FairTutorialDet2Point.cxx b/examples/simulation/Tutorial2/src/FairTutorialDet2Point.cxx index 972f48a524..43df6d9209 100644 --- a/examples/simulation/Tutorial2/src/FairTutorialDet2Point.cxx +++ b/examples/simulation/Tutorial2/src/FairTutorialDet2Point.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,5 +31,3 @@ void FairTutorialDet2Point::Print(const Option_t* /*opt*/) const LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV"; } - -ClassImp(FairTutorialDet2Point); diff --git a/examples/simulation/Tutorial4/macros/plots.C b/examples/simulation/Tutorial4/macros/plots.C index 718ad09c60..10270191b0 100644 --- a/examples/simulation/Tutorial4/macros/plots.C +++ b/examples/simulation/Tutorial4/macros/plots.C @@ -1,10 +1,35 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#if !defined(__CLING__) || defined(__ROOTCLING__) +#include "FairFileSource.h" +#include "FairMCEventHeader.h" +#include "FairMCTrack.h" +#include "FairParRootFileIo.h" +#include "FairRootFileSink.h" +#include "FairRunAna.h" +#include "FairRuntimeDb.h" +#include "FairSystemInfo.h" +#include "FairTutorialDet4Hit.h" +#include "FairTutorialDet4Point.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +using std::cout; +using std::endl; + int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant3") { TStopwatch timer; @@ -28,11 +53,11 @@ int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant parInput1->open(ParFile.Data()); rtdb->setFirstInput(parInput1); - TFile *f1 = TFile::Open(MCFile); - TFile *f2 = TFile::Open(RecoFile); + std::unique_ptr f1{TFile::Open(MCFile)}; + std::unique_ptr f2{TFile::Open(RecoFile)}; - auto t1 = f1->Get("cbmsim"); - auto t2 = f2->Get("cbmsim"); + std::unique_ptr t1{f1->Get("cbmsim")}; + std::unique_ptr t2{f2->Get("cbmsim")}; FairMCEventHeader *MCEventHeader = new FairMCEventHeader(); TClonesArray *MCTracks = new TClonesArray("FairMCTrack"); @@ -44,7 +69,6 @@ int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant t1->SetBranchAddress("TutorialDetPoint", &TutorialDetPoints); t2->SetBranchAddress("TutorialDetHit", &TutorialDetHits); - FairMCTrack *MCTrack; FairTutorialDet4Point *Point; FairTutorialDet4Hit *Hit; @@ -64,11 +88,8 @@ int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant TH1F *pointy = new TH1F("pointy", "Hit; posy;", 200., -80., 80.); Int_t nMCTracks, nPoints, nHits; - Float_t x_point, y_point, z_point, tof_point, SMtype_point, mod_point, cel_point, gap_point; Float_t x_poi, y_poi, z_poi; - Float_t SMtype_poi, mod_poi, cel_poi, gap_poi; - Float_t p_MC, px_MC, py_MC, pz_MC; - Float_t x_hit, y_hit, z_hit, dy_hit; + Float_t x_hit, y_hit, z_hit; Int_t nevent = t1->GetEntries(); @@ -108,7 +129,6 @@ int plots(Int_t nEvents = 1000, Int_t iout = 1, TString mcEngine = "align_TGeant x_hit = Hit->GetX(); y_hit = Hit->GetY(); z_hit = Hit->GetZ(); - dy_hit = Hit->GetDy(); // Int_t flg_hit = Hit->GetFlag(); Float_t delta_x = x_poi - x_hit; diff --git a/examples/simulation/Tutorial4/macros/run_tutorial4.C b/examples/simulation/Tutorial4/macros/run_tutorial4.C index 2919fe1948..d033ac6117 100644 --- a/examples/simulation/Tutorial4/macros/run_tutorial4.C +++ b/examples/simulation/Tutorial4/macros/run_tutorial4.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,8 +9,12 @@ #include #include #include +#include #include +using std::cout; +using std::endl; + void run_tutorial4(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t doAlign = true, Bool_t isMT = false) { TString dir = getenv("VMCWORKDIR"); @@ -69,27 +73,27 @@ void run_tutorial4(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t doAl // gLogger->SetLogScreenLevel("INFO"); // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(std::make_unique(outFile)); - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(std::make_unique(outFile)); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairTutorialDet4* tutdet = new FairTutorialDet4("TUTDET", kTRUE); tutdet->SetGeometryFileName("tutorial4.root"); tutdet->SetModifyGeometry(doAlign); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -107,10 +111,10 @@ void run_tutorial4(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t doAl primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ----- Store information about particle trajectories ------------------ - run->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); // ----- Runtime database --------------------------------------------- @@ -124,7 +128,7 @@ void run_tutorial4(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t doAl // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ - run->Init(); + run.Init(); // -Trajectories Visualization (TGeoManager Only ) // ----------------------------------------------- @@ -142,16 +146,14 @@ void run_tutorial4(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t doAl // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - // run->CreateGeometryFile(geoFile); //misaligned geometry - run->Run(nEvents); - // run->CreateGeometryFile(geoFile); // original geometry + // run.CreateGeometryFile(geoFile); //misaligned geometry + run.Run(nEvents); + // run.CreateGeometryFile(geoFile); // original geometry // ------------------------------------------------------------------------ rtdb->saveOutput(); rtdb->print(); - delete run; - // ----- Finish ------------------------------------------------------- cout << endl << endl; diff --git a/examples/simulation/Tutorial4/macros/run_tutorial4_createGeometryFile.C b/examples/simulation/Tutorial4/macros/run_tutorial4_createGeometryFile.C index 13d0b89be9..d52b6c36dc 100644 --- a/examples/simulation/Tutorial4/macros/run_tutorial4_createGeometryFile.C +++ b/examples/simulation/Tutorial4/macros/run_tutorial4_createGeometryFile.C @@ -1,13 +1,21 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#include +#include +#include +#include + +using std::cout; +using std::endl; + void run_tutorial4_createGeometryFile(Int_t nEvents = 1, TString mcEngine = "TGeant3", Bool_t isMT = false) { - TString dir = getenv("VMCWORKDIR"); TString tut_configdir = dir + "/simulation/Tutorial4/gconfig"; @@ -58,26 +66,26 @@ void run_tutorial4_createGeometryFile(Int_t nEvents = 1, TString mcEngine = "TGe // gLogger->SetLogScreenLevel("INFO"); // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(new FairRootFileSink(outFile)); // Output file - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(new FairRootFileSink(outFile)); // Output file + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairTutorialDet4* tutdet = new FairTutorialDet4("TUTDET", kTRUE); tutdet->SetGeometryFileName("tutorial4.root"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -95,7 +103,7 @@ void run_tutorial4_createGeometryFile(Int_t nEvents = 1, TString mcEngine = "TGe primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Runtime database --------------------------------------------- @@ -109,20 +117,18 @@ void run_tutorial4_createGeometryFile(Int_t nEvents = 1, TString mcEngine = "TGe rtdb->setOutput(parOut); // ------------------------------------------------------------------------ - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); - run->CreateGeometryFile(geoFile); + run.Run(nEvents); + run.CreateGeometryFile(geoFile); // ------------------------------------------------------------------------ rtdb->saveOutput(); rtdb->print(); - delete run; - // ----- Finish ------------------------------------------------------- cout << endl << endl; diff --git a/examples/simulation/Tutorial4/macros/run_tutorial4_createMatrices.C b/examples/simulation/Tutorial4/macros/run_tutorial4_createMatrices.C index 58b9158367..63274bcff1 100644 --- a/examples/simulation/Tutorial4/macros/run_tutorial4_createMatrices.C +++ b/examples/simulation/Tutorial4/macros/run_tutorial4_createMatrices.C @@ -1,13 +1,20 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ + +#include +#include +#include +#include +#include +#include + void run_tutorial4_createMatrices(Int_t nEvents = 10, TString mcEngine = "TGeant3", Bool_t isMT = false) { - TString dir = getenv("VMCWORKDIR"); TString tut_configdir = dir + "/simulation/Tutorial4/gconfig"; @@ -56,26 +63,26 @@ void run_tutorial4_createMatrices(Int_t nEvents = 10, TString mcEngine = "TGeant // gLogger->SetLogScreenLevel("INFO"); // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(new FairRootFileSink(outFile)); // Output file - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(new FairRootFileSink(outFile)); // Output file + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairTutorialDet4* tutdet = new FairTutorialDet4("TUTDET", kTRUE); tutdet->SetGeometryFileName("tutorial4.root"); - run->AddModule(tutdet); + run.AddModule(tutdet); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- @@ -93,11 +100,11 @@ void run_tutorial4_createMatrices(Int_t nEvents = 10, TString mcEngine = "TGeant primGen->AddGenerator(boxGen); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // ------------------------------------------------------------------------ // ----- Initialize simulation run ------------------------------------ - run->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); // ----- Runtime database --------------------------------------------- @@ -110,7 +117,7 @@ void run_tutorial4_createMatrices(Int_t nEvents = 10, TString mcEngine = "TGeant rtdb->setOutput(parOut); // ------------------------------------------------------------------------ - run->Init(); + run.Init(); // sadly, the align parameters are only available AFTER we called fRun->Init() @@ -119,7 +126,7 @@ void run_tutorial4_createMatrices(Int_t nEvents = 10, TString mcEngine = "TGeant auto matrices = tutdet->getMisalignmentMatrices(); - ofstream myfile; + std::ofstream myfile; myfile.open("misalignmentMatrices.txt"); double* rot; @@ -140,6 +147,4 @@ void run_tutorial4_createMatrices(Int_t nEvents = 10, TString mcEngine = "TGeant LOG(info) << "AlignHandler: all matrices added!"; LOG(info) << "SUCCESS! All matrices created and saved!"; - - return; } diff --git a/examples/simulation/Tutorial4/macros/run_tutorial4_createParameterFile.C b/examples/simulation/Tutorial4/macros/run_tutorial4_createParameterFile.C index 8044620350..d1815a6550 100644 --- a/examples/simulation/Tutorial4/macros/run_tutorial4_createParameterFile.C +++ b/examples/simulation/Tutorial4/macros/run_tutorial4_createParameterFile.C @@ -1,17 +1,21 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ +#include +#include +#include +#include + // forward declaration void writeVectorToFile(std::vector& vec, ofstream* myfile); void run_tutorial4_createParameterFile() { - // Create shift in x, y, z when true Bool_t ShiftX = kTRUE; Bool_t ShiftY = kTRUE; @@ -42,14 +46,14 @@ void run_tutorial4_createParameterFile() TList* l = f->GetListOfKeys(); - TKey* key; - TIter next(l); - TGeoManager* geoMan{nullptr}; - while ((key = (TKey*)next())) { - if (key->ReadObj()->InheritsFrom("TGeoManager")) { - geoMan = static_cast(key->ReadObj()); + for (auto key : TRangeDynCast(l)) { + if (!key) { + continue; + } + geoMan = key->ReadObject(); + if (geoMan) { break; } } diff --git a/examples/simulation/Tutorial4/src/CMakeLists.txt b/examples/simulation/Tutorial4/src/CMakeLists.txt index 53d1014d29..c4aa79d554 100644 --- a/examples/simulation/Tutorial4/src/CMakeLists.txt +++ b/examples/simulation/Tutorial4/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -27,7 +27,7 @@ set(sources tools/Mille.cc ) -if(${ROOT_HAS_OPENGL}) +if(ROOT_opengl_FOUND) list(APPEND sources display/FairTutorialDet4PointDraw.cxx ) @@ -49,11 +49,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator @@ -73,7 +68,7 @@ target_link_libraries(${target} ${VMCLIB} ROOT::MathCore ROOT::Hist - $<$:ROOT::Eve> + $<$:ROOT::Eve> ) fairroot_target_root_dictionary(${target} diff --git a/examples/simulation/Tutorial4/src/data/FairTutorialDet4Hit.cxx b/examples/simulation/Tutorial4/src/data/FairTutorialDet4Hit.cxx index d56325b354..cf28735546 100644 --- a/examples/simulation/Tutorial4/src/data/FairTutorialDet4Hit.cxx +++ b/examples/simulation/Tutorial4/src/data/FairTutorialDet4Hit.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,5 +16,3 @@ FairTutorialDet4Hit::FairTutorialDet4Hit(Int_t detID, Int_t mcindex, const TVect {} FairTutorialDet4Hit::~FairTutorialDet4Hit() {} - -ClassImp(FairTutorialDet4Hit); diff --git a/examples/simulation/Tutorial4/src/data/FairTutorialDet4Point.cxx b/examples/simulation/Tutorial4/src/data/FairTutorialDet4Point.cxx index 52754a1a0c..2f462d016e 100644 --- a/examples/simulation/Tutorial4/src/data/FairTutorialDet4Point.cxx +++ b/examples/simulation/Tutorial4/src/data/FairTutorialDet4Point.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -32,5 +32,3 @@ void FairTutorialDet4Point::Print(const Option_t* /*opt*/) const LOG(info) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV"; } - -ClassImp(FairTutorialDet4Point); diff --git a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx index 65821aa8b0..cf68c0683f 100644 --- a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx +++ b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -348,6 +348,7 @@ FairTutorialDet4Point* FairTutorialDet4::AddHit(Int_t trackID, return new (clref[size]) FairTutorialDet4Point(trackID, detID, pos, mom, time, length, eLoss); } -FairModule* FairTutorialDet4::CloneModule() const { return new FairTutorialDet4(*this); } - -ClassImp(FairTutorialDet4); +FairModule* FairTutorialDet4::CloneModule() const +{ + return new FairTutorialDet4(*this); +} diff --git a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.cxx b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.cxx index b0d2354c9d..628b74b175 100644 --- a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.cxx +++ b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,35 +7,6 @@ ********************************************************************************/ #include "FairTutorialDet4Geo.h" -#include // for sprintf - -ClassImp(FairTutorialDet4Geo); - FairTutorialDet4Geo::FairTutorialDet4Geo() - : FairGeoSet() -{ - // Constructor - fName = "tutdet"; - strcpy(modName, "tutdet"); - strcpy(eleName, "tutdet"); - maxSectors = 0; - maxModules = 100; -} - -const char* FairTutorialDet4Geo::getModuleName(Int_t m) -{ - /** Returns the module name of TutorialDet number m - Setting MyDet here means that all modules names in the - ASCII file should start with TutorialDet otherwise they will - not be constructed - */ - sprintf(modName, "tutdet%i", m + 1); - return modName; -} - -const char* FairTutorialDet4Geo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - sprintf(eleName, "tutdet%i", m + 1); - return eleName; -} + : FairGeoSet("tutdet", 100) +{} diff --git a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.h b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.h index b0eb546ad2..e1bb9730d8 100644 --- a/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.h +++ b/examples/simulation/Tutorial4/src/mc/FairTutorialDet4Geo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,32 +10,14 @@ #include "FairGeoSet.h" // for FairGeoSet -#include // for Int_t, etc -#include // for TString +#include class FairTutorialDet4Geo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module - public: FairTutorialDet4Geo(); - ~FairTutorialDet4Geo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(FairTutorialDet4Geo, 1); + ~FairTutorialDet4Geo() override = default; + ClassDefOverride(FairTutorialDet4Geo, 1); }; -inline Int_t FairTutorialDet4Geo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - tutdet ?? has to be 6. - */ - return static_cast((name[6] - '0') - 1); // -} - #endif /* FAIRTUTORIALDETGEO_H */ diff --git a/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.cxx b/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.cxx index 5e5e569e04..6f71cbccac 100644 --- a/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.cxx +++ b/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.cxx @@ -14,10 +14,6 @@ #include // for TString #include // for strcmp -class FairParSet; - -ClassImp(FairTutorialDet4ContFact); - static FairTutorialDet4ContFact gFairTutorialDet4ContFact; FairTutorialDet4ContFact::FairTutorialDet4ContFact() diff --git a/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.h b/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.h index 205a71cb63..8feb69ca26 100644 --- a/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.h +++ b/examples/simulation/Tutorial4/src/param/FairTutorialDet4ContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,17 +10,13 @@ #include "FairContFact.h" // for FairContFact, etc -#include // for ClassDef - -class FairParSet; - class FairTutorialDet4ContFact : public FairContFact { public: FairTutorialDet4ContFact(); - ~FairTutorialDet4ContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(FairTutorialDet4ContFact, 0); // Factory for all MyDet parameter containers + ~FairTutorialDet4ContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(FairTutorialDet4ContFact, 0); // Factory for all MyDet parameter containers }; #endif /* !FAIRTUTORIALDETCONTFACT_H */ diff --git a/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.cxx b/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.cxx index c6669a862e..482c22c3ae 100644 --- a/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.cxx +++ b/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,8 +11,6 @@ #include // for TObjArray -ClassImp(FairTutorialDet4GeoPar); - FairTutorialDet4GeoPar ::FairTutorialDet4GeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) @@ -20,7 +18,7 @@ FairTutorialDet4GeoPar ::FairTutorialDet4GeoPar(const char* name, const char* ti , fGlobalCoordinates(kFALSE) {} -void FairTutorialDet4GeoPar::clear(void) +void FairTutorialDet4GeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.h b/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.h index 7719a447bf..2896c1a3ce 100644 --- a/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.h +++ b/examples/simulation/Tutorial4/src/param/FairTutorialDet4GeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,9 +21,9 @@ class FairTutorialDet4GeoPar : public FairParGenericSet FairTutorialDet4GeoPar(const char* name = "FairTutorialDet4GeoPar", const char* title = "FairTutorialDet4 Geometry Parameters", const char* context = "TestDefaultContext"); - ~FairTutorialDet4GeoPar(void) {} + ~FairTutorialDet4GeoPar() {} - void clear(void); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.cxx b/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.cxx index a417880b0e..3103d629dc 100644 --- a/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.cxx +++ b/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,8 +9,6 @@ #include "FairParamList.h" -ClassImp(FairTutorialDet4MisalignPar); - FairTutorialDet4MisalignPar ::FairTutorialDet4MisalignPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fShiftX() @@ -22,9 +20,9 @@ FairTutorialDet4MisalignPar ::FairTutorialDet4MisalignPar(const char* name, cons , fNrOfDetectors(0) {} -FairTutorialDet4MisalignPar::~FairTutorialDet4MisalignPar(void) {} +FairTutorialDet4MisalignPar::~FairTutorialDet4MisalignPar() {} -void FairTutorialDet4MisalignPar::clear(void) {} +void FairTutorialDet4MisalignPar::clear() {} void FairTutorialDet4MisalignPar::putParams(FairParamList* l) { diff --git a/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.h b/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.h index 8829a2c988..333eb698eb 100644 --- a/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.h +++ b/examples/simulation/Tutorial4/src/param/FairTutorialDet4MisalignPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +22,8 @@ class FairTutorialDet4MisalignPar : public FairParGenericSet const char* name = "FairTutorialDet4MissallignPar", const char* title = "Missalignment parameter for FairTutorialDet4HitProducerIdealMissallign Parameters", const char* context = "TestDefaultContext"); - ~FairTutorialDet4MisalignPar(void); - void clear(void); + ~FairTutorialDet4MisalignPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); diff --git a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4HitProducerIdealMisalign.cxx b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4HitProducerIdealMisalign.cxx index 5c040bae19..f1a61db634 100644 --- a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4HitProducerIdealMisalign.cxx +++ b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4HitProducerIdealMisalign.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -211,5 +211,3 @@ Double_t FairTutorialDet4HitProducerIdealMisalign::GetHitErr(Double_t sigma) Double_t err = gRandom->Gaus(0, sigma); return (TMath::Abs(err) < 3 * sigma) ? err : (err > 0) ? 3 * sigma : -3 * sigma; } - -ClassImp(FairTutorialDet4HitProducerIdealMisalign); diff --git a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4MilleWriter.cxx b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4MilleWriter.cxx index 8612702709..4c83120487 100644 --- a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4MilleWriter.cxx +++ b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4MilleWriter.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -260,6 +260,7 @@ void FairTutorialDet4MilleWriter::StraightLineShiftXY() delete[] label; } -void FairTutorialDet4MilleWriter::Finish() { LOG(debug) << "Finish of FairTutorialDet4MilleWriter"; } - -ClassImp(FairTutorialDet4MilleWriter); +void FairTutorialDet4MilleWriter::Finish() +{ + LOG(debug) << "Finish of FairTutorialDet4MilleWriter"; +} diff --git a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.cxx b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.cxx index 310579ba75..872cecd7f9 100644 --- a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.cxx +++ b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,35 +7,24 @@ ********************************************************************************/ #include "FairTutorialDet4StraightLineFitter.h" -#include "FairLogger.h" // for FairLogger, etc #include "FairRootManager.h" // for FairRootManager #include "FairTrackParam.h" // for FairTrackParam #include "FairTutorialDet4Hit.h" // for FairTutorialDet4Hit -#include // for TClonesArray #include // for TF1 #include // for TGraphErrors #include // for TVector3 -#include // for set, set<>::iterator, etc +#include +#include FairTutorialDet4StraightLineFitter::FairTutorialDet4StraightLineFitter() : FairTask("FairTutorialDet4StraightLineFitter") - , fHits(nullptr) - , fTracks(nullptr) + , fTracks(FairTrackParam::Class(), 100) , fVersion(2) { LOG(debug) << "Default Constructor of FairTutorialDet4StraightLineFitter"; } -FairTutorialDet4StraightLineFitter::~FairTutorialDet4StraightLineFitter() -{ - LOG(debug) << "Destructor of FairTutorialDet4StraightLineFitter"; - if (fTracks) { - fTracks->Delete(); - delete fTracks; - } -} - InitStatus FairTutorialDet4StraightLineFitter::Init() { LOG(debug) << "Initilization of FairTutorialDet4StraightLineFitter"; @@ -45,7 +34,7 @@ InitStatus FairTutorialDet4StraightLineFitter::Init() // Get a pointer to the previous already existing data level - fHits = static_cast(ioman->GetObject("TutorialDetHit")); + fHits = dynamic_cast(ioman->GetObject("TutorialDetHit")); if (!fHits) { LOG(error) << "No InputDataLevelName array!\n" << "FairTutorialDet4StraightLineFitter will be inactive"; @@ -54,8 +43,7 @@ InitStatus FairTutorialDet4StraightLineFitter::Init() // Create the TClonesArray for the output data and register // it in the IO manager - fTracks = new TClonesArray("FairTrackParam", 100); - ioman->Register("TutorialDetTrack", "TutorialDet", fTracks, kTRUE); + ioman->Register("TutorialDetTrack", "TutorialDet", &fTracks, kTRUE); // Do whatever else is needed at the initilization stage // Create histograms to be filled @@ -64,12 +52,6 @@ InitStatus FairTutorialDet4StraightLineFitter::Init() return kSUCCESS; } -InitStatus FairTutorialDet4StraightLineFitter::ReInit() -{ - LOG(debug) << "Initilization of FairTutorialDet4StraightLineFitter"; - return kSUCCESS; -} - void FairTutorialDet4StraightLineFitter::Exec(Option_t* /*option*/) { LOG(debug) << "Exec of FairTutorialDet4StraightLineFitter"; @@ -79,7 +61,6 @@ void FairTutorialDet4StraightLineFitter::Exec(Option_t* /*option*/) } // Declare some variables - FairTutorialDet4Hit* hit = nullptr; /* Int_t detID = 0; // Detector ID Int_t trackID = 0; // Track index @@ -98,7 +79,7 @@ void FairTutorialDet4StraightLineFitter::Exec(Option_t* /*option*/) Float_t* YPosErr = new Float_t[nHits]; for (Int_t iHit = 0; iHit < nHits; iHit++) { - hit = static_cast(fHits->At(iHit)); + auto hit = static_cast(fHits->At(iHit)); if (!hit) { continue; } @@ -111,24 +92,22 @@ void FairTutorialDet4StraightLineFitter::Exec(Option_t* /*option*/) YPosErr[iHit] = hit->GetDy(); } - TF1* f1 = new TF1("f1", "[0]*x + [1]"); - TGraphErrors* LineGraph; - - LineGraph = new TGraphErrors(nHits, ZPos, XPos, 0, XPosErr); - LineGraph->Fit("f1", "Q"); - Double_t SlopeX = f1->GetParameter(0); - Double_t OffX = f1->GetParameter(1); - Double_t Chi2X = f1->GetChisquare(); + auto f1 = TF1("f1", "[0]*x + [1]"); + auto linegraphX = TGraphErrors(nHits, ZPos, XPos, nullptr, XPosErr); + linegraphX.Fit(&f1, "Q"); + Double_t SlopeX = f1.GetParameter(0); + Double_t OffX = f1.GetParameter(1); + Double_t Chi2X = f1.GetChisquare(); Double_t SlopeY = 0.; Double_t OffY = 0.; Double_t Chi2Y; if (2 == fVersion) { - LineGraph = new TGraphErrors(nHits, ZPos, YPos, 0, YPosErr); - LineGraph->Fit("f1", "Q"); - SlopeY = f1->GetParameter(0); - OffY = f1->GetParameter(1); - Chi2Y = f1->GetChisquare(); + auto linegraphY = TGraphErrors(nHits, ZPos, YPos, nullptr, YPosErr); + linegraphY.Fit(&f1, "Q"); + SlopeY = f1.GetParameter(0); + OffY = f1.GetParameter(1); + Chi2Y = f1.GetChisquare(); LOG(debug) << XPos[0] << "," << XPos[nHits - 1] << "," << YPos[0] << "," << YPos[nHits - 1] << "," << ZPos[0] << "," << ZPos[nHits - 1]; @@ -141,7 +120,7 @@ void FairTutorialDet4StraightLineFitter::Exec(Option_t* /*option*/) LOG(debug) << "Chi2(x,y): " << Chi2X << " ," << Chi2Y; } - FairTrackParam* track = new FairTrackParam(); + auto track = static_cast(fTracks.ConstructedAt(0)); track->SetX(OffX); track->SetTx(SlopeX); track->SetZ(0.); @@ -149,7 +128,6 @@ void FairTutorialDet4StraightLineFitter::Exec(Option_t* /*option*/) track->SetY(OffY); track->SetTy(SlopeY); } - new ((*fTracks)[0]) FairTrackParam(*track); // const TMatrixFSym matrix; // Double_t Z = 0.; // new ((*fTracks)[0]) FairTrackParam(OffX, OffY, Z, SlopeX, SlopeY, matrix); @@ -168,15 +146,13 @@ Bool_t FairTutorialDet4StraightLineFitter::IsGoodEvent() // event, so we have to check for this. // In the end the algorithm should be able to work also with // missing hits in some stations - FairTutorialDet4Hit* hit; std::set detIdSet; - std::set::iterator it; Int_t nHits = fHits->GetEntriesFast(); for (Int_t iHit = 0; iHit < nHits; ++iHit) { - hit = static_cast(fHits->At(iHit)); + auto hit = static_cast(fHits->At(iHit)); Int_t detId = hit->GetDetectorID(); - it = detIdSet.find(detId); + auto it = detIdSet.find(detId); if (it == detIdSet.end()) { detIdSet.insert(detId); } else { @@ -187,7 +163,3 @@ Bool_t FairTutorialDet4StraightLineFitter::IsGoodEvent() } return kTRUE; } - -void FairTutorialDet4StraightLineFitter::Finish() { LOG(debug) << "Finish of FairTutorialDet4StraightLineFitter"; } - -ClassImp(FairTutorialDet4StraightLineFitter); diff --git a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.h b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.h index aa2bdc6fed..3f4e61eea3 100644 --- a/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.h +++ b/examples/simulation/Tutorial4/src/reco/FairTutorialDet4StraightLineFitter.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,8 +11,7 @@ #include "FairTask.h" // for InitStatus, FairTask #include // for ClassDef - -class TClonesArray; +#include class FairTutorialDet4StraightLineFitter : public FairTask { @@ -24,28 +23,22 @@ class FairTutorialDet4StraightLineFitter : public FairTask // FairTutorialDet4StraightLineFitter(Int_t verbose); /** Destructor **/ - ~FairTutorialDet4StraightLineFitter(); + ~FairTutorialDet4StraightLineFitter() override = default; /** Initiliazation of task at the beginning of a run **/ - virtual InitStatus Init(); - - /** ReInitiliazation of task when the runID changes **/ - virtual InitStatus ReInit(); + InitStatus Init() override; /** Executed for each event. **/ - virtual void Exec(Option_t* opt); - - /** Finish task called at the end of the run **/ - virtual void Finish(); + void Exec(Option_t* opt) override; void SetVersion(Int_t val) { fVersion = val; } private: /** Input array from previous already existing data level **/ - TClonesArray* fHits; + TClonesArray const* fHits{nullptr}; /** Output array to new data level**/ - TClonesArray* fTracks; + TClonesArray fTracks; Int_t fVersion; @@ -54,7 +47,7 @@ class FairTutorialDet4StraightLineFitter : public FairTask FairTutorialDet4StraightLineFitter(const FairTutorialDet4StraightLineFitter&); FairTutorialDet4StraightLineFitter operator=(const FairTutorialDet4StraightLineFitter&); - ClassDef(FairTutorialDet4StraightLineFitter, 1); + ClassDefOverride(FairTutorialDet4StraightLineFitter, 1); }; #endif diff --git a/examples/simulation/Tutorial4/src/tools/FairTutorialDet4GeoHandler.cxx b/examples/simulation/Tutorial4/src/tools/FairTutorialDet4GeoHandler.cxx index b0926ae81d..cf3c1a305c 100644 --- a/examples/simulation/Tutorial4/src/tools/FairTutorialDet4GeoHandler.cxx +++ b/examples/simulation/Tutorial4/src/tools/FairTutorialDet4GeoHandler.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -201,5 +201,3 @@ void FairTutorialDet4GeoHandler::NavigateTo(TString volName) // fGlobalMatrix = gGeoManager->GetCurrentMatrix(); } } - -ClassImp(FairTutorialDet4GeoHandler); diff --git a/examples/simulation/rutherford/macros/run_rad.C b/examples/simulation/rutherford/macros/run_rad.C index 1279bb6cdb..8f4d058a90 100644 --- a/examples/simulation/rutherford/macros/run_rad.C +++ b/examples/simulation/rutherford/macros/run_rad.C @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,8 +9,12 @@ #include #include #include +#include #include +using std::cout; +using std::endl; + void run_rad(Int_t nEvents = 100, TString mcEngine = "TGeant4") { TString dir = gSystem->Getenv("VMCWORKDIR"); @@ -54,38 +58,38 @@ void run_rad(Int_t nEvents = 100, TString mcEngine = "TGeant4") logger->SetLogVerbosityLevel("HIGH"); // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetSink(std::make_unique(outFile)); - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetSink(std::make_unique(outFile)); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ //----Start the radiation length manager ---------------------------------- - run->SetRadLenRegister(kTRUE); + run.SetRadLenRegister(kTRUE); // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairModule* target = new FairTarget("Target"); target->SetGeometryFileName("target_rutherford.geo"); - run->AddModule(target); + run.AddModule(target); FairDetector* rutherford = new FairRutherford("RutherfordDetector", kFALSE); rutherford->SetGeometryFileName("rutherford.geo"); - run->AddModule(rutherford); + run.AddModule(rutherford); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); - run->SetGenerator(primGen); + run.SetGenerator(primGen); FairBoxGenerator* boxGen1 = new FairBoxGenerator(0, 1); boxGen1->SetPRange(.005, .005); @@ -96,10 +100,10 @@ void run_rad(Int_t nEvents = 100, TString mcEngine = "TGeant4") // ------------------------------------------------------------------------ - run->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); // ----- Run initialisation ------------------------------------------- - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // Set cuts for storing the trajectories. @@ -127,9 +131,9 @@ void run_rad(Int_t nEvents = 100, TString mcEngine = "TGeant4") // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); + run.Run(nEvents); // ------------------------------------------------------------------------ - run->CreateGeometryFile(geoFile); + run.CreateGeometryFile(geoFile); // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/rutherford/macros/run_rutherford.C b/examples/simulation/rutherford/macros/run_rutherford.C index 2390cfc744..3a82c1c5ce 100644 --- a/examples/simulation/rutherford/macros/run_rutherford.C +++ b/examples/simulation/rutherford/macros/run_rutherford.C @@ -1,16 +1,22 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ +#include #include +#include #include #include +#include #include +using std::cout; +using std::endl; + void run_rutherford(Int_t nEvents = 10, TString mcEngine = "TGeant4", Bool_t isMT = true) { TString dir = gSystem->Getenv("VMCWORKDIR"); @@ -57,36 +63,36 @@ void run_rutherford(Int_t nEvents = 10, TString mcEngine = "TGeant4", Bool_t isM logger->SetLogVerbosityLevel("HIGH"); // ----- Create simulation run ---------------------------------------- - FairRunSim* run = new FairRunSim(); - run->SetName(mcEngine); // Transport engine - run->SetIsMT(isMT); // Multi-threading mode (Geant4 only) - run->SetSink(std::make_unique(outFile)); - FairRuntimeDb* rtdb = run->GetRuntimeDb(); + FairRunSim run{}; + run.SetName(mcEngine); // Transport engine + run.SetIsMT(isMT); // Multi-threading mode (Geant4 only) + run.SetSink(std::make_unique(outFile)); + FairRuntimeDb* rtdb = run.GetRuntimeDb(); // ------------------------------------------------------------------------ - run->SetGenerateRunInfo(kFALSE); + run.SetGenerateRunInfo(kFALSE); // ----- Create media ------------------------------------------------- - run->SetMaterials("media.geo"); // Materials + run.SetMaterials("media.geo"); // Materials // ------------------------------------------------------------------------ // ----- Create geometry ---------------------------------------------- FairModule* cave = new FairCave("CAVE"); cave->SetGeometryFileName("cave_vacuum.geo"); - run->AddModule(cave); + run.AddModule(cave); FairModule* target = new FairTarget("Target"); target->SetGeometryFileName("target_rutherford.geo"); - run->AddModule(target); + run.AddModule(target); FairDetector* rutherford = new FairRutherford("RutherfordDetector", kTRUE); rutherford->SetGeometryFileName("rutherford.geo"); - run->AddModule(rutherford); + run.AddModule(rutherford); // ------------------------------------------------------------------------ // ----- Create PrimaryGenerator -------------------------------------- FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); - run->SetGenerator(primGen); + run.SetGenerator(primGen); // Ion Generator @@ -113,10 +119,10 @@ void run_rutherford(Int_t nEvents = 10, TString mcEngine = "TGeant4", Bool_t isM primGen->AddGenerator(ypt); // ------------------------------------------------------------------------ - run->SetStoreTraj(kTRUE); + run.SetStoreTraj(kTRUE); // ----- Run initialisation ------------------------------------------- - run->Init(); + run.Init(); // ------------------------------------------------------------------------ // Set cuts for storing the trajectories. @@ -144,9 +150,9 @@ void run_rutherford(Int_t nEvents = 10, TString mcEngine = "TGeant4", Bool_t isM // ------------------------------------------------------------------------ // ----- Start run ---------------------------------------------------- - run->Run(nEvents); + run.Run(nEvents); // ------------------------------------------------------------------------ - run->CreateGeometryFile(geoFile); + run.CreateGeometryFile(geoFile); // ----- Finish ------------------------------------------------------- diff --git a/examples/simulation/rutherford/src/CMakeLists.txt b/examples/simulation/rutherford/src/CMakeLists.txt index fc483390e0..49d6512271 100644 --- a/examples/simulation/rutherford/src/CMakeLists.txt +++ b/examples/simulation/rutherford/src/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -27,11 +27,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRunIdGenerator diff --git a/examples/simulation/rutherford/src/FairRutherford.cxx b/examples/simulation/rutherford/src/FairRutherford.cxx index d5fa6747d9..215af07ef7 100644 --- a/examples/simulation/rutherford/src/FairRutherford.cxx +++ b/examples/simulation/rutherford/src/FairRutherford.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -42,15 +42,6 @@ FairRutherford::~FairRutherford() } } -void FairRutherford::Initialize() -{ - FairDetector::Initialize(); - /* - FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb(); - FairRutherfordGeoPar* par=(FairRutherfordGeoPar*)(rtdb->getContainer("FairRutherfordGeoPar")); -*/ -} - Bool_t FairRutherford::ProcessHits(FairVolume* vol) { /** This method is called from the MC stepping */ @@ -139,6 +130,7 @@ FairRutherfordPoint* FairRutherford::AddHit(Int_t trackID, FairRutherfordPoint(trackID, detID, pos, mom, time, length, eLoss, pos.Mag(), pos.Phi(), pos.Theta()); } -FairModule* FairRutherford::CloneModule() const { return new FairRutherford(*this); } - -ClassImp(FairRutherford); +FairModule* FairRutherford::CloneModule() const +{ + return new FairRutherford(*this); +} diff --git a/examples/simulation/rutherford/src/FairRutherford.h b/examples/simulation/rutherford/src/FairRutherford.h index ac1bb742da..218881d8bf 100644 --- a/examples/simulation/rutherford/src/FairRutherford.h +++ b/examples/simulation/rutherford/src/FairRutherford.h @@ -35,9 +35,6 @@ class FairRutherford : public FairDetector /** destructor */ ~FairRutherford() override; - /** Initialization of the detector is done here */ - void Initialize() override; - /** this method is called for each step during simulation * (see FairMCApplication::Stepping()) */ diff --git a/examples/simulation/rutherford/src/FairRutherfordContFact.cxx b/examples/simulation/rutherford/src/FairRutherfordContFact.cxx index 646dd8d884..62e24c079b 100644 --- a/examples/simulation/rutherford/src/FairRutherfordContFact.cxx +++ b/examples/simulation/rutherford/src/FairRutherfordContFact.cxx @@ -13,10 +13,6 @@ #include // for TString #include // for strcmp -class FairParSet; - -ClassImp(FairRutherfordContFact); - static FairRutherfordContFact gFairRutherfordContFact; FairRutherfordContFact::FairRutherfordContFact() diff --git a/examples/simulation/rutherford/src/FairRutherfordContFact.h b/examples/simulation/rutherford/src/FairRutherfordContFact.h index fc884bb462..deeda7d5c1 100644 --- a/examples/simulation/rutherford/src/FairRutherfordContFact.h +++ b/examples/simulation/rutherford/src/FairRutherfordContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,15 +10,11 @@ #include "FairContFact.h" // for FairContFact, etc -#include // for ClassDef - -class FairParSet; - class FairRutherfordContFact : public FairContFact { public: FairRutherfordContFact(); - ~FairRutherfordContFact() override {} + ~FairRutherfordContFact() override = default; FairParSet* createContainer(FairContainer*) override; ClassDefOverride(FairRutherfordContFact, 0); // Factory for all FairRutherford parameter containers }; diff --git a/examples/simulation/rutherford/src/FairRutherfordGeo.cxx b/examples/simulation/rutherford/src/FairRutherfordGeo.cxx index ca74d3f41b..93cc6c154d 100644 --- a/examples/simulation/rutherford/src/FairRutherfordGeo.cxx +++ b/examples/simulation/rutherford/src/FairRutherfordGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,35 +7,6 @@ ********************************************************************************/ #include "FairRutherfordGeo.h" -#include // for snprintf - -ClassImp(FairRutherfordGeo); - FairRutherfordGeo::FairRutherfordGeo() - : FairGeoSet() -{ - // Constructor - fName = "rutherford"; - strcpy(modName, "rutherford"); - strcpy(eleName, "rutherford"); - maxSectors = 0; - maxModules = 10; -} - -const char* FairRutherfordGeo::getModuleName(Int_t m) -{ - /** Returns the module name of FairRutherford number m - Setting MyDet here means that all modules names in the - ASCII file should start with FairRutherford otherwise they will - not be constructed - */ - std::snprintf(modName, sizeof(modName), "rutherford%i", m + 1); - return modName; -} - -const char* FairRutherfordGeo::getEleName(Int_t m) -{ - /** Returns the element name of Det number m */ - std::snprintf(eleName, sizeof(eleName), "rutherford%i", m + 1); - return eleName; -} + : FairGeoSet("rutherford", 10) +{} diff --git a/examples/simulation/rutherford/src/FairRutherfordGeo.h b/examples/simulation/rutherford/src/FairRutherfordGeo.h index aaa83edc6e..4236a9f2b7 100644 --- a/examples/simulation/rutherford/src/FairRutherfordGeo.h +++ b/examples/simulation/rutherford/src/FairRutherfordGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,31 +10,14 @@ #include "FairGeoSet.h" // for FairGeoSet -#include // for Int_t, etc -#include // for TString +#include // for Int_t, etc class FairRutherfordGeo : public FairGeoSet { - protected: - char modName[22]; // name of module - char eleName[22]; // substring for elements in module public: FairRutherfordGeo(); - ~FairRutherfordGeo() override {} - const char* getModuleName(Int_t) override; - const char* getEleName(Int_t) override; - inline Int_t getModNumInMod(const TString&) override; + ~FairRutherfordGeo() override = default; ClassDefOverride(FairRutherfordGeo, 1); }; -inline Int_t FairRutherfordGeo::getModNumInMod(const TString& name) -{ - /** returns the module index from module name - ?? in name[??] has to be the length of the detector name in the - .geo file. For example if all nodes in this file starts with - newdetector ?? has to be 11. - */ - return static_cast((name[10] - '0') - 1); // -} - #endif diff --git a/examples/simulation/rutherford/src/FairRutherfordGeoPar.cxx b/examples/simulation/rutherford/src/FairRutherfordGeoPar.cxx index c45ab5c457..14a37335fe 100644 --- a/examples/simulation/rutherford/src/FairRutherfordGeoPar.cxx +++ b/examples/simulation/rutherford/src/FairRutherfordGeoPar.cxx @@ -1,16 +1,16 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ - #include "FairRutherfordGeoPar.h" - #include // for TGenericClassInfo - #include // for TObjArray - #include "FairParamList.h" // for FairParamList +#include "FairRutherfordGeoPar.h" -ClassImp(FairRutherfordGeoPar); +#include "FairParamList.h" // for FairParamList + +#include // for TGenericClassInfo +#include // for TObjArray FairRutherfordGeoPar ::FairRutherfordGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) diff --git a/examples/simulation/rutherford/src/FairRutherfordGeoPar.h b/examples/simulation/rutherford/src/FairRutherfordGeoPar.h index 560210649e..f0eb106027 100644 --- a/examples/simulation/rutherford/src/FairRutherfordGeoPar.h +++ b/examples/simulation/rutherford/src/FairRutherfordGeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,9 +14,7 @@ class FairParamList; // lines 16-16 class TBuffer; class TClass; -class TMemberInspector; -class TObjArray; // lines 15-15 - +class TObjArray; // lines 15-15 class FairRutherfordGeoPar : public FairParGenericSet { diff --git a/examples/simulation/rutherford/src/FairRutherfordPoint.cxx b/examples/simulation/rutherford/src/FairRutherfordPoint.cxx index ee2b2a0dbf..d4af377aa8 100644 --- a/examples/simulation/rutherford/src/FairRutherfordPoint.cxx +++ b/examples/simulation/rutherford/src/FairRutherfordPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -46,5 +46,3 @@ void FairRutherfordPoint::Print(const Option_t* /*opt*/) const cout << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV" << endl; } - -ClassImp(FairRutherfordPoint); diff --git a/examples/simulation/rutherford/src/FairRutherfordPoint.h b/examples/simulation/rutherford/src/FairRutherfordPoint.h index c14575afbd..de8b1f3e00 100644 --- a/examples/simulation/rutherford/src/FairRutherfordPoint.h +++ b/examples/simulation/rutherford/src/FairRutherfordPoint.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include "FairMCPoint.h" // for FairMCPoint class TBuffer; class TClass; -class TMemberInspector; - class FairRutherfordPoint : public FairMCPoint { diff --git a/fairroot/CMakeLists.txt b/fairroot/CMakeLists.txt new file mode 100644 index 0000000000..e2004346ac --- /dev/null +++ b/fairroot/CMakeLists.txt @@ -0,0 +1,54 @@ +################################################################################ +# Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +# Shall be prefixed to all test executables +set(test_prefix fairroot_test) + +add_subdirectory(tools) +add_subdirectory(mcsteplogger) +add_subdirectory(alignment) +add_subdirectory(base) + +if(Geant4_FOUND AND Geant4VMC_FOUND) + add_subdirectory(fastsim) +endif() + +add_subdirectory(geobase) +add_subdirectory(parbase) +add_subdirectory(generators) + +if(BUILD_MBS) + add_subdirectory(mbsapi) +endif() +if(BUILD_ONLINE) + add_subdirectory(online) +endif() + +if(Geant3_FOUND) + add_subdirectory(geane) + add_subdirectory(trackbase) +endIf() + +if(ROOT_opengl_FOUND) + add_subdirectory(eventdisplay) +else() + message(STATUS "eventdisplay will not be built, because ROOT has no opengl support.") +endif() + +if(Geant3_FOUND AND Geant4VMC_FOUND AND yaml-cpp_FOUND + AND TARGET FairRoot::FastSim) + add_subdirectory(mcconfigurator) +endif() + +add_subdirectory(datamatch) + +if(BUILD_BASEMQ) + add_subdirectory(fairmq) + add_subdirectory(basemq) + add_subdirectory(parmq) +endif() diff --git a/alignment/CMakeLists.txt b/fairroot/alignment/CMakeLists.txt similarity index 87% rename from alignment/CMakeLists.txt rename to fairroot/alignment/CMakeLists.txt index e787549c22..34607c9656 100644 --- a/alignment/CMakeLists.txt +++ b/fairroot/alignment/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -22,11 +22,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC ROOT::Geom diff --git a/alignment/FairAlignmentHandler.cxx b/fairroot/alignment/FairAlignmentHandler.cxx similarity index 91% rename from alignment/FairAlignmentHandler.cxx rename to fairroot/alignment/FairAlignmentHandler.cxx index b7cac4f761..145dca91ea 100644 --- a/alignment/FairAlignmentHandler.cxx +++ b/fairroot/alignment/FairAlignmentHandler.cxx @@ -1,7 +1,6 @@ #include "FairAlignmentHandler.h" -#include "FairLogger.h" - +#include #include #include #include @@ -10,7 +9,7 @@ void FairAlignmentHandler::AlignGeometry() const { - if (fAlignmentMatrices.size() > 0) { + if (!fAlignmentMatrices.empty()) { LOG(info) << "aligning the geometry..."; LOG(info) << "aligning in total " << fAlignmentMatrices.size() << " volumes."; @@ -49,7 +48,7 @@ void FairAlignmentHandler::AlignGeometryByFullPath() const TGeoHMatrix local_volume_matrix = TGeoHMatrix(*volume_matrix); - TGeoHMatrix* new_volume_matrix = new TGeoHMatrix(local_volume_matrix * alignment_entry.second); + auto new_volume_matrix = new TGeoHMatrix(local_volume_matrix * alignment_entry.second); // new matrix, representing real position (from new local mis RS to the global one) TGeoPhysicalNode* pn = gGeoManager->MakePhysicalNode(volume_path); @@ -67,13 +66,13 @@ void FairAlignmentHandler::AlignGeometryBySymlink() const for (auto const& alignment_entry : fAlignmentMatrices) { volume_path = alignment_entry.first; - TGeoPhysicalNode* node = NULL; + TGeoPhysicalNode* node = nullptr; TGeoPNEntry* entry = gGeoManager->GetAlignableEntry(volume_path); if (entry) { node = gGeoManager->MakeAlignablePN(entry); } - TGeoMatrix* volume_matrix = NULL; + TGeoMatrix* volume_matrix = nullptr; if (node) { volume_matrix = node->GetMatrix(); } else { @@ -83,7 +82,7 @@ void FairAlignmentHandler::AlignGeometryBySymlink() const // it is implimnted now in TGeoHMatrix TGeoHMatrix local_volume_matrix = TGeoHMatrix(*volume_matrix); - TGeoHMatrix* new_volume_matrix = new TGeoHMatrix(local_volume_matrix * alignment_entry.second); + auto new_volume_matrix = new TGeoHMatrix(local_volume_matrix * alignment_entry.second); // new matrix, representing real position (from new local mis RS to the global one) node->Align(new_volume_matrix); } diff --git a/alignment/FairAlignmentHandler.h b/fairroot/alignment/FairAlignmentHandler.h similarity index 100% rename from alignment/FairAlignmentHandler.h rename to fairroot/alignment/FairAlignmentHandler.h diff --git a/alignment/LinkDef.h b/fairroot/alignment/LinkDef.h similarity index 100% rename from alignment/LinkDef.h rename to fairroot/alignment/LinkDef.h diff --git a/alignment/README.dox b/fairroot/alignment/README.dox similarity index 100% rename from alignment/README.dox rename to fairroot/alignment/README.dox diff --git a/base/CMakeLists.txt b/fairroot/base/CMakeLists.txt similarity index 92% rename from base/CMakeLists.txt rename to fairroot/base/CMakeLists.txt index 6962f7e69b..b7cac9fbf7 100644 --- a/base/CMakeLists.txt +++ b/fairroot/base/CMakeLists.txt @@ -5,15 +5,10 @@ # GNU Lesser General Public Licence (LGPL) version 3, # # copied verbatim in the file "LICENSE" # ################################################################################ -If(Geant4_FOUND AND Geant4VMC_FOUND) - add_subdirectory (sim/fastsim) -EndIf() set(target Base) set(sources - event/FairEventBuilder.cxx - event/FairEventBuilderManager.cxx event/FairEventHeader.cxx event/FairFileHeader.cxx event/FairFileInfo.cxx @@ -83,6 +78,13 @@ if(BUILD_PROOF_SUPPORT) ) endif() +if(BUILD_EVENT_BUILDER) + list(APPEND sources + event/FairEventBuilder.cxx + event/FairEventBuilderManager.cxx + ) +endif() + fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers) add_library(${target} SHARED ${sources} ${headers}) @@ -98,11 +100,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Alignment @@ -128,7 +125,7 @@ target_link_libraries(${target} target_compile_definitions(${target} PRIVATE - $<$:ROOT_HAS_GDML> + $<$:ROOT_HAS_GDML> # $<$:Linux> ) @@ -137,6 +134,10 @@ if(BUILD_PROOF_SUPPORT) target_compile_definitions(${target} PRIVATE BUILD_PROOF_SUPPORT) endif() +if(BUILD_EVENT_BUILDER) + target_compile_definitions(${target} PRIVATE BUILD_EVENT_BUILDER) +endif() + fairroot_target_root_dictionary(${target} HEADERS ${headers} LINKDEF LinkDef.h diff --git a/base/LinkDef.h b/fairroot/base/LinkDef.h similarity index 95% rename from base/LinkDef.h rename to fairroot/base/LinkDef.h index 29bba94923..803f77554f 100644 --- a/base/LinkDef.h +++ b/fairroot/base/LinkDef.h @@ -1,5 +1,5 @@ /************************************************************************************* - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,9 +16,7 @@ #pragma link C++ class FairGeoParSet; #pragma link C++ class FairDetector+; //#pragma link C++ class FairDoubleHit+; -#pragma link C++ class FairEventBuilder+; -#pragma link C++ class FairEventBuilderManager+; -#pragma link C++ class FairEventHeader; +#pragma link C++ class FairEventHeader+; #pragma link C++ class FairFileHeader+; #pragma link C++ class FairGeaneApplication+; #pragma link C++ class FairGenerator+; @@ -79,5 +77,9 @@ #pragma link C++ class FairAnaSelector+; #pragma link C++ class FairRunAnaProof; #endif +#ifdef BUILD_EVENT_BUILDER +#pragma link C++ class FairEventBuilder+; +#pragma link C++ class FairEventBuilderManager+; +#endif #endif diff --git a/base/README.dox b/fairroot/base/README.dox similarity index 100% rename from base/README.dox rename to fairroot/base/README.dox diff --git a/base/event/FairEventBuilder.cxx b/fairroot/base/event/FairEventBuilder.cxx similarity index 97% rename from base/event/FairEventBuilder.cxx rename to fairroot/base/event/FairEventBuilder.cxx index f6504e5d60..e20f2495ea 100644 --- a/base/event/FairEventBuilder.cxx +++ b/fairroot/base/event/FairEventBuilder.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -99,5 +99,3 @@ void FairEventBuilder::Finish() std::cout << " Should be implemented by the user" << std::endl; std::cout << "---------------------------------------------------------------------" << std::endl; } - -ClassImp(FairEventBuilder); diff --git a/base/event/FairEventBuilder.h b/fairroot/base/event/FairEventBuilder.h similarity index 92% rename from base/event/FairEventBuilder.h rename to fairroot/base/event/FairEventBuilder.h index 714d09f042..703b339e49 100644 --- a/base/event/FairEventBuilder.h +++ b/fairroot/base/event/FairEventBuilder.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -53,7 +53,7 @@ class FairEventBuilder : public FairWriteoutBuffer FairEventBuilder(TString branchName, TString className, TString folderName, Bool_t persistance); /** Destructor **/ - virtual ~FairEventBuilder(); + ~FairEventBuilder() override; virtual void WriteOutAllDeadTimeData(); @@ -65,7 +65,7 @@ class FairEventBuilder : public FairWriteoutBuffer virtual Bool_t Init() = 0; - virtual void Print(Option_t* option = "") const = 0; + void Print(Option_t* option = "") const override = 0; /** Finish at the end of each event **/ virtual void Finish(); @@ -85,7 +85,7 @@ class FairEventBuilder : public FairWriteoutBuffer Int_t fIdentifier; Double_t fMaxAllowedEventCreationTime; - ClassDef(FairEventBuilder, 1); + ClassDefOverride(FairEventBuilder, 1); }; #endif diff --git a/base/event/FairEventBuilderManager.cxx b/fairroot/base/event/FairEventBuilderManager.cxx similarity index 98% rename from base/event/FairEventBuilderManager.cxx rename to fairroot/base/event/FairEventBuilderManager.cxx index 7e54c64986..1c477cb8c6 100644 --- a/base/event/FairEventBuilderManager.cxx +++ b/fairroot/base/event/FairEventBuilderManager.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -70,8 +70,6 @@ void FairEventBuilderManager::Exec(Option_t*) // - should extract possible events // - is implemented by different experiments AnalyzeAndExtractEvents(maxEventTimeAllowed); - - return; } Double_t FairEventBuilderManager::FillEventVectors() @@ -162,5 +160,3 @@ void FairEventBuilderManager::Finish() } cout << "=====================================================================" << endl; } - -ClassImp(FairEventBuilderManager); diff --git a/base/event/FairEventBuilderManager.h b/fairroot/base/event/FairEventBuilderManager.h similarity index 90% rename from base/event/FairEventBuilderManager.h rename to fairroot/base/event/FairEventBuilderManager.h index 02da83933f..736c354e3b 100644 --- a/base/event/FairEventBuilderManager.h +++ b/fairroot/base/event/FairEventBuilderManager.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -49,10 +49,10 @@ class FairEventBuilderManager : public FairTask FairEventBuilderManager(const char* name, Int_t iVerbose = 1); /** Destructor **/ - virtual ~FairEventBuilderManager(); + ~FairEventBuilderManager() override; /** Execution **/ - virtual void Exec(Option_t* opt); + void Exec(Option_t* opt) override; /** Adding FairEventBuilder **/ virtual void AddEventBuilder(FairEventBuilder* eventBuilder); @@ -72,15 +72,15 @@ class FairEventBuilderManager : public FairTask private: /** Intialisation **/ - virtual InitStatus Init(); + InitStatus Init() override; /** Reinitialisation **/ - virtual InitStatus ReInit(); + InitStatus ReInit() override; /** Finish at the end of each event **/ - virtual void Finish(); + void Finish() override; - ClassDef(FairEventBuilderManager, 1); + ClassDefOverride(FairEventBuilderManager, 1); }; #endif diff --git a/base/event/FairEventHeader.cxx b/fairroot/base/event/FairEventHeader.cxx similarity index 97% rename from base/event/FairEventHeader.cxx rename to fairroot/base/event/FairEventHeader.cxx index 8c794a83ae..86689e0ffc 100644 --- a/base/event/FairEventHeader.cxx +++ b/fairroot/base/event/FairEventHeader.cxx @@ -18,5 +18,3 @@ void FairEventHeader::Register(Bool_t Persistence) { FairRootManager::Instance()->Register("EventHeader.", "EvtHeader", this, Persistence); } - -ClassImp(FairEventHeader); diff --git a/base/event/FairEventHeader.h b/fairroot/base/event/FairEventHeader.h similarity index 100% rename from base/event/FairEventHeader.h rename to fairroot/base/event/FairEventHeader.h diff --git a/base/event/FairFileHeader.cxx b/fairroot/base/event/FairFileHeader.cxx similarity index 93% rename from base/event/FairFileHeader.cxx rename to fairroot/base/event/FairFileHeader.cxx index 8f5a88a47f..eae0f9ccbc 100644 --- a/base/event/FairFileHeader.cxx +++ b/fairroot/base/event/FairFileHeader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,7 +18,6 @@ #include // for TList #include // for TObjString #include // for TObject -class TFile; FairFileHeader::FairFileHeader() : TNamed() @@ -51,5 +50,3 @@ FairFileInfo* FairFileHeader::GetFileInfo(UInt_t id, UInt_t ChId) } FairFileHeader::~FairFileHeader() {} - -ClassImp(FairFileHeader); diff --git a/base/event/FairFileHeader.h b/fairroot/base/event/FairFileHeader.h similarity index 93% rename from base/event/FairFileHeader.h rename to fairroot/base/event/FairFileHeader.h index b71edf491e..f51d990266 100644 --- a/base/event/FairFileHeader.h +++ b/fairroot/base/event/FairFileHeader.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -50,7 +50,7 @@ class FairFileHeader : public TNamed /** * Destructor */ - virtual ~FairFileHeader(); + ~FairFileHeader() override; FairFileInfo* GetFileInfo(UInt_t id, UInt_t ChId); @@ -68,7 +68,7 @@ class FairFileHeader : public TNamed FairFileHeader(const FairFileHeader&); FairFileHeader& operator=(const FairFileHeader&); - ClassDef(FairFileHeader, 2); + ClassDefOverride(FairFileHeader, 2); }; #endif diff --git a/base/event/FairFileInfo.cxx b/fairroot/base/event/FairFileInfo.cxx similarity index 94% rename from base/event/FairFileInfo.cxx rename to fairroot/base/event/FairFileInfo.cxx index ed1e0605da..493ec2f888 100644 --- a/base/event/FairFileInfo.cxx +++ b/fairroot/base/event/FairFileInfo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -45,4 +45,3 @@ void FairFileInfo::Print(Option_t*) const printf("File order in input chain : %i \n", fInChainId); } //__________________________________________________________________________ -ClassImp(FairFileInfo); diff --git a/base/event/FairFileInfo.h b/fairroot/base/event/FairFileInfo.h similarity index 88% rename from base/event/FairFileInfo.h rename to fairroot/base/event/FairFileInfo.h index 1991332266..4da5617406 100644 --- a/base/event/FairFileInfo.h +++ b/fairroot/base/event/FairFileInfo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,14 +22,14 @@ class FairFileInfo : public TNamed public: FairFileInfo(); FairFileInfo(TFile* file, UInt_t id, UInt_t ChId); - virtual ~FairFileInfo(); + ~FairFileInfo() override; TString GetPath() { return fPath; } UInt_t GetSize() { return fSize; } UInt_t GetIdentifier() { return fIdentifier; } UInt_t GetOrderInChain() { return fInChainId; } - void Print(Option_t* option = "") const; + void Print(Option_t* option = "") const override; void SetPath(TString path) { fPath = path; } void SetSize(UInt_t size) { fSize = size; } @@ -50,7 +50,7 @@ class FairFileInfo : public TNamed FairFileInfo(const FairFileInfo&); FairFileInfo& operator=(const FairFileInfo&); - ClassDef(FairFileInfo, 1); + ClassDefOverride(FairFileInfo, 1); }; #endif // FAIRFILEINFO_H diff --git a/base/event/FairHit.cxx b/fairroot/base/event/FairHit.cxx similarity index 90% rename from base/event/FairHit.cxx rename to fairroot/base/event/FairHit.cxx index d1c61696d2..3b0c677b4a 100644 --- a/base/event/FairHit.cxx +++ b/fairroot/base/event/FairHit.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -32,5 +32,3 @@ FairHit::FairHit(Int_t detID, const TVector3& pos, const TVector3& dpos, Int_t i {} FairHit::~FairHit() {} - -ClassImp(FairHit); diff --git a/base/event/FairHit.h b/fairroot/base/event/FairHit.h similarity index 94% rename from base/event/FairHit.h rename to fairroot/base/event/FairHit.h index 6ec6bb8356..98aac1f3af 100644 --- a/base/event/FairHit.h +++ b/fairroot/base/event/FairHit.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,7 +29,7 @@ class FairHit : public FairTimeStamp FairHit(Int_t detID, const TVector3& pos, const TVector3& dpos, Int_t index); /** Destructor **/ - virtual ~FairHit(); + ~FairHit() override; /** Accessors **/ Double_t GetDx() const { return fDx; }; @@ -58,7 +58,7 @@ class FairHit : public FairTimeStamp void SetPosition(const TVector3& pos); /*** Output to screen */ - virtual void Print(const Option_t*) const { ; } + void Print(const Option_t*) const override { ; } protected: Double32_t fDx, fDy, fDz; ///< Errors of position [cm] @@ -66,7 +66,7 @@ class FairHit : public FairTimeStamp Int_t fDetectorID; ///< Detector unique identifier Double32_t fX, fY, fZ; ///< Position of hit [cm] - ClassDef(FairHit, 3); + ClassDefOverride(FairHit, 3); }; inline void FairHit::PositionError(TVector3& dpos) const { dpos.SetXYZ(fDx, fDy, fDz); } diff --git a/base/event/FairLink.cxx b/fairroot/base/event/FairLink.cxx similarity index 92% rename from base/event/FairLink.cxx rename to fairroot/base/event/FairLink.cxx index 364026880c..6dbfdf0f4c 100644 --- a/base/event/FairLink.cxx +++ b/fairroot/base/event/FairLink.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,8 +16,6 @@ #include "FairRootManager.h" -ClassImp(FairLink); - FairLink::FairLink(TString branchName, Int_t index, Float_t weight) : fFile(0) , fType(0) diff --git a/base/event/FairLink.h b/fairroot/base/event/FairLink.h similarity index 97% rename from base/event/FairLink.h rename to fairroot/base/event/FairLink.h index 8e78ce6509..d434314d0c 100644 --- a/base/event/FairLink.h +++ b/fairroot/base/event/FairLink.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -34,7 +34,7 @@ class FairLink FairLink(TString branchName, Int_t index, Float_t weight = 1.); FairLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.); FairLink(Int_t file, Int_t entry, TString branchName, Int_t index, Float_t weight = 1.); - ~FairLink(){}; + ~FairLink() = default; void SetLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.) { diff --git a/base/event/FairMCEventHeader.cxx b/fairroot/base/event/FairMCEventHeader.cxx similarity index 96% rename from base/event/FairMCEventHeader.cxx rename to fairroot/base/event/FairMCEventHeader.cxx index c972e385a0..95956ef43e 100644 --- a/base/event/FairMCEventHeader.cxx +++ b/fairroot/base/event/FairMCEventHeader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -84,5 +84,3 @@ void FairMCEventHeader::Register() // Dot at the end of the name is needed for splitting!! FairRootManager::Instance()->Register("MCEventHeader.", "Event", this, kTRUE); } - -ClassImp(FairMCEventHeader); diff --git a/base/event/FairMCEventHeader.h b/fairroot/base/event/FairMCEventHeader.h similarity index 97% rename from base/event/FairMCEventHeader.h rename to fairroot/base/event/FairMCEventHeader.h index df89410107..405bbcfd5a 100644 --- a/base/event/FairMCEventHeader.h +++ b/fairroot/base/event/FairMCEventHeader.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -45,7 +45,7 @@ class FairMCEventHeader : public TNamed FairMCEventHeader(UInt_t runId); /** Destructor **/ - virtual ~FairMCEventHeader(); + ~FairMCEventHeader() override; /** Accessors **/ UInt_t GetRunID() const { return fRunId; } /// run identifier @@ -98,7 +98,7 @@ class FairMCEventHeader : public TNamed Double32_t fRotY; /// Rotation around y-axis (beam tilt) [rad] Double32_t fRotZ; /// Rotation around z-axis (event plane) [rad] - ClassDef(FairMCEventHeader, 2); + ClassDefOverride(FairMCEventHeader, 2); }; inline void FairMCEventHeader::SetVertex(Double_t x, Double_t y, Double_t z) diff --git a/base/event/FairMCPoint.cxx b/fairroot/base/event/FairMCPoint.cxx similarity index 94% rename from base/event/FairMCPoint.cxx rename to fairroot/base/event/FairMCPoint.cxx index 77b086b615..439cb80635 100644 --- a/base/event/FairMCPoint.cxx +++ b/fairroot/base/event/FairMCPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -58,5 +58,3 @@ void FairMCPoint::Print(const Option_t*) const LOG(debug) << " Time " << fTime << " ns, Length " << fLength << " cm, Energy loss " << fELoss * 1.0e06 << " keV"; } - -ClassImp(FairMCPoint); diff --git a/base/event/FairMCPoint.h b/fairroot/base/event/FairMCPoint.h similarity index 95% rename from base/event/FairMCPoint.h rename to fairroot/base/event/FairMCPoint.h index 5eaf6577be..d47a721e0e 100644 --- a/base/event/FairMCPoint.h +++ b/fairroot/base/event/FairMCPoint.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -44,7 +44,7 @@ class FairMCPoint : public FairMultiLinkedData_Interface UInt_t EventId = 0); /** Destructor **/ - virtual ~FairMCPoint(); + ~FairMCPoint() override; /** Accessors */ UInt_t GetEventID() const { return fEventId; } /// event identifier @@ -77,7 +77,7 @@ class FairMCPoint : public FairMultiLinkedData_Interface void SetPosition(const TVector3& pos); /** Output to screen **/ - virtual void Print(const Option_t* opt = 0) const; + void Print(const Option_t* opt = nullptr) const override; protected: Int_t fTrackID; ///< Track index @@ -89,7 +89,7 @@ class FairMCPoint : public FairMultiLinkedData_Interface Int_t fDetectorID; ///< Detector unique identifier Double32_t fX, fY, fZ; ///< Position of hit [cm] - ClassDef(FairMCPoint, 5); + ClassDefOverride(FairMCPoint, 5); }; inline void FairMCPoint::SetMomentum(const TVector3& mom) diff --git a/base/event/FairMesh.cxx b/fairroot/base/event/FairMesh.cxx similarity index 96% rename from base/event/FairMesh.cxx rename to fairroot/base/event/FairMesh.cxx index 02f449fc8d..16e0ef0c33 100644 --- a/base/event/FairMesh.cxx +++ b/fairroot/base/event/FairMesh.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -97,5 +97,3 @@ void FairMesh::print() cout << " Zmin " << fZmin << " Zmax " << fZmax << endl; cout << " NX " << NXbin << " NY " << NXbin << endl; } - -ClassImp(FairMesh); diff --git a/base/event/FairMesh.h b/fairroot/base/event/FairMesh.h similarity index 95% rename from base/event/FairMesh.h rename to fairroot/base/event/FairMesh.h index 21b33cc147..6da369a12a 100644 --- a/base/event/FairMesh.h +++ b/fairroot/base/event/FairMesh.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,7 +31,7 @@ class FairMesh : public TObject FairMesh(const char*); /** Destructor **/ - virtual ~FairMesh(); + ~FairMesh() override; /** Accessors **/ Double_t GetXmin() const { return fXmin; }; @@ -100,7 +100,7 @@ class FairMesh : public TObject FairMesh(const FairMesh&); FairMesh& operator=(const FairMesh&); - ClassDef(FairMesh, 1); + ClassDefOverride(FairMesh, 1); }; #endif diff --git a/base/event/FairMultiLinkedData.cxx b/fairroot/base/event/FairMultiLinkedData.cxx similarity index 98% rename from base/event/FairMultiLinkedData.cxx rename to fairroot/base/event/FairMultiLinkedData.cxx index e987dd69c6..f8961e2b37 100644 --- a/base/event/FairMultiLinkedData.cxx +++ b/fairroot/base/event/FairMultiLinkedData.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +22,6 @@ #include // for find #include // for distance -ClassImp(FairMultiLinkedData); - FairMultiLinkedData::FairMultiLinkedData() : TObject() , fLinks() @@ -197,7 +195,6 @@ void FairMultiLinkedData::InsertLink(FairLink link) } else { fLinks.insert(link); } - return; } void FairMultiLinkedData::InsertHistory(FairLink link) @@ -287,7 +284,10 @@ FairMultiLinkedData FairMultiLinkedData::GetLinksWithType(Int_t type) const return result; } -bool LargerWeight(FairLink val1, FairLink val2) { return val1.GetWeight() > val2.GetWeight(); } +static bool LargerWeight(FairLink const& val1, FairLink const& val2) +{ + return val1.GetWeight() > val2.GetWeight(); +} std::vector FairMultiLinkedData::GetSortedMCTracks() { diff --git a/base/event/FairMultiLinkedData.h b/fairroot/base/event/FairMultiLinkedData.h similarity index 97% rename from base/event/FairMultiLinkedData.h rename to fairroot/base/event/FairMultiLinkedData.h index 7735abfdb0..ba18ce61ad 100644 --- a/base/event/FairMultiLinkedData.h +++ b/fairroot/base/event/FairMultiLinkedData.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -45,7 +45,7 @@ class FairMultiLinkedData : public TObject Bool_t bypass = kFALSE, Float_t mult = 1.0); ///< Constructor - virtual ~FairMultiLinkedData(){}; + ~FairMultiLinkedData() override = default; virtual std::set GetLinks() const { return fLinks; } ///< returns stored links as FairLinks virtual FairLink GetEntryNr() const { return fEntryNr; } ///< gives back the entryNr @@ -151,7 +151,7 @@ class FairMultiLinkedData : public TObject } Int_t fDefaultType; - ClassDef(FairMultiLinkedData, 4); + ClassDefOverride(FairMultiLinkedData, 4); }; /**\fn virtual void FairMultiLinkedData::SetLinks(Int_t type, std::vector links) diff --git a/base/event/FairMultiLinkedData_Interface.cxx b/fairroot/base/event/FairMultiLinkedData_Interface.cxx similarity index 99% rename from base/event/FairMultiLinkedData_Interface.cxx rename to fairroot/base/event/FairMultiLinkedData_Interface.cxx index 27ffbda3d5..ad19e22a30 100644 --- a/base/event/FairMultiLinkedData_Interface.cxx +++ b/fairroot/base/event/FairMultiLinkedData_Interface.cxx @@ -9,8 +9,6 @@ #include "FairRootManager.h" // for FairRootManager -ClassImp(FairMultiLinkedData_Interface); - FairMultiLinkedData_Interface::FairMultiLinkedData_Interface(FairMultiLinkedData& links, Bool_t) { SetLinks(links); diff --git a/base/event/FairMultiLinkedData_Interface.h b/fairroot/base/event/FairMultiLinkedData_Interface.h similarity index 97% rename from base/event/FairMultiLinkedData_Interface.h rename to fairroot/base/event/FairMultiLinkedData_Interface.h index 6878100697..5388fbe02f 100644 --- a/base/event/FairMultiLinkedData_Interface.h +++ b/fairroot/base/event/FairMultiLinkedData_Interface.h @@ -40,7 +40,7 @@ class FairMultiLinkedData_Interface : public TObject Float_t mult = 1.0); ///< Constructor FairMultiLinkedData_Interface(const FairMultiLinkedData_Interface& toCopy); - ~FairMultiLinkedData_Interface() = default; + ~FairMultiLinkedData_Interface() override = default; FairMultiLinkedData_Interface& operator=(const FairMultiLinkedData_Interface& rhs); @@ -86,7 +86,7 @@ class FairMultiLinkedData_Interface : public TObject std::unique_ptr fLink; FairMultiLinkedData* CreateFairMultiLinkedData(); ///< returns non-owning pointer - ClassDef(FairMultiLinkedData_Interface, 6); + ClassDefOverride(FairMultiLinkedData_Interface, 6); }; /**\fn virtual void FairMultiLinkedData_Interface::SetLinks(Int_t type, std::vector links) diff --git a/base/event/FairPrintFairLinks.cxx b/fairroot/base/event/FairPrintFairLinks.cxx similarity index 82% rename from base/event/FairPrintFairLinks.cxx rename to fairroot/base/event/FairPrintFairLinks.cxx index c65f6fd60f..5df5ba7dd5 100644 --- a/base/event/FairPrintFairLinks.cxx +++ b/fairroot/base/event/FairPrintFairLinks.cxx @@ -1,25 +1,26 @@ +/******************************************************************************** + * Copyright (C) 2018-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ // ------------------------------------------------------------------------- // ----- FairPrintFairLinks source file ----- // ----- Created 18/07/08 by T.Stockmanns ----- // ------------------------------------------------------------------------- -// libc includes -#include - -// Root includes -#include +#include "FairPrintFairLinks.h" // framework includes -#include "FairLogger.h" #include "FairMultiLinkedData_Interface.h" #include "FairRootManager.h" +#include + FairPrintFairLinks::FairPrintFairLinks() - : FairTask("Creates PndMCMatch") - , fSelectedBranches(new TList()) + : FairTask("FairPrintFairLinks") {} -FairPrintFairLinks::~FairPrintFairLinks() {} - InitStatus FairPrintFairLinks::Init() { FairRootManager* ioman = FairRootManager::Instance(); @@ -30,8 +31,8 @@ InitStatus FairPrintFairLinks::Init() } TList* branchNames; - if (fSelectedBranches->GetEntries() > 0) { - branchNames = fSelectedBranches; + if (fSelectedBranches.GetEntries() > 0) { + branchNames = &fSelectedBranches; } else { branchNames = ioman->GetBranchNameList(); } @@ -104,7 +105,3 @@ void FairPrintFairLinks::Exec(Option_t*) } } } - -void FairPrintFairLinks::Finish() {} - -ClassImp(FairPrintFairLinks); diff --git a/base/event/FairPrintFairLinks.h b/fairroot/base/event/FairPrintFairLinks.h similarity index 54% rename from base/event/FairPrintFairLinks.h rename to fairroot/base/event/FairPrintFairLinks.h index 185ba32082..ed2941d321 100644 --- a/base/event/FairPrintFairLinks.h +++ b/fairroot/base/event/FairPrintFairLinks.h @@ -1,3 +1,10 @@ +/******************************************************************************** + * Copyright (C) 2018-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ // ------------------------------------------------------------------------- // ----- FairPrintFairLinks header file ----- // ----- Created 20/03/07 by R.Kliemt ----- @@ -12,14 +19,12 @@ #ifndef FairPrintFairLinks_H #define FairPrintFairLinks_H -// framework includes #include "FairTask.h" -#include "TObjString.h" +#include +#include #include -class TClonesArray; - class FairPrintFairLinks : public FairTask { public: @@ -27,31 +32,29 @@ class FairPrintFairLinks : public FairTask FairPrintFairLinks(); /** Destructor **/ - virtual ~FairPrintFairLinks(); + ~FairPrintFairLinks() override = default; - virtual void AddBranchName(const TString& name) { fSelectedBranches->AddLast(new TObjString(name.Data())); } + virtual void AddBranchName(const TString& name) { fSelectedBranches.AddLast(new TObjString(name.Data())); } virtual void PrintBranchNameList(TList* branches); - virtual InitStatus Init(); + InitStatus Init() override; /** Virtual method Exec **/ - virtual void Exec(Option_t* opt); - - virtual void Finish(); + void Exec(Option_t* opt) override; protected: void InitBranchList(TList* branches); private: std::map fBranches; - TList* fSelectedBranches; + TList fSelectedBranches; void Register(); void Reset(); void ProduceHits(); - ClassDef(FairPrintFairLinks, 1); + ClassDefOverride(FairPrintFairLinks, 1); }; #endif diff --git a/base/event/FairRadLenPoint.cxx b/fairroot/base/event/FairRadLenPoint.cxx similarity index 95% rename from base/event/FairRadLenPoint.cxx rename to fairroot/base/event/FairRadLenPoint.cxx index 30878697fe..f9a467ba70 100644 --- a/base/event/FairRadLenPoint.cxx +++ b/fairroot/base/event/FairRadLenPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -59,5 +59,3 @@ FairRadLenPoint::~FairRadLenPoint() {} void FairRadLenPoint::Print(const Option_t*) const { /**to be implimented*/ } - -ClassImp(FairRadLenPoint); diff --git a/base/event/FairRadLenPoint.h b/fairroot/base/event/FairRadLenPoint.h similarity index 93% rename from base/event/FairRadLenPoint.h rename to fairroot/base/event/FairRadLenPoint.h index 8213c74de3..99b3ad0304 100644 --- a/base/event/FairRadLenPoint.h +++ b/fairroot/base/event/FairRadLenPoint.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -44,7 +44,7 @@ class FairRadLenPoint : public FairMCPoint Float_t fRadLen); /** Destructor **/ - virtual ~FairRadLenPoint(); + ~FairRadLenPoint() override; /** Accessors **/ Float_t GetA() { return fA; } @@ -59,7 +59,7 @@ class FairRadLenPoint : public FairMCPoint void SetDensity(Double_t Density) { fDensity = Density; } /** Output to screen **/ - virtual void Print(const Option_t* opt) const; + void Print(const Option_t* opt) const override; Double_t GetXOut() const { return fXOut; }; Double_t GetYOut() const { return fYOut; }; @@ -84,7 +84,7 @@ class FairRadLenPoint : public FairMCPoint Double_t fXOut, fYOut, fZOut; Double_t fPxOut, fPyOut, fPzOut; - ClassDef(FairRadLenPoint, 1); + ClassDefOverride(FairRadLenPoint, 1); }; #endif diff --git a/base/event/FairRadMapPoint.cxx b/fairroot/base/event/FairRadMapPoint.cxx similarity index 95% rename from base/event/FairRadMapPoint.cxx rename to fairroot/base/event/FairRadMapPoint.cxx index 0bdc6eafde..ec5c8d07ff 100644 --- a/base/event/FairRadMapPoint.cxx +++ b/fairroot/base/event/FairRadMapPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -69,5 +69,3 @@ FairRadMapPoint::~FairRadMapPoint() {} void FairRadMapPoint::Print(const Option_t*) const { /**to be implimented*/ } - -ClassImp(FairRadMapPoint); diff --git a/base/event/FairRadMapPoint.h b/fairroot/base/event/FairRadMapPoint.h similarity index 94% rename from base/event/FairRadMapPoint.h rename to fairroot/base/event/FairRadMapPoint.h index 07f40560fc..4aeb3b1f85 100644 --- a/base/event/FairRadMapPoint.h +++ b/fairroot/base/event/FairRadMapPoint.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -47,7 +47,7 @@ class FairRadMapPoint : public FairMCPoint Int_t fPdg); /** Destructor **/ - virtual ~FairRadMapPoint(); + ~FairRadMapPoint() override; /** Accessors **/ Float_t GetA() { return fA; } @@ -62,7 +62,7 @@ class FairRadMapPoint : public FairMCPoint void SetDensity(Double_t Density) { fDensity = Density; } /** Output to screen **/ - virtual void Print(const Option_t* opt) const; + void Print(const Option_t* opt) const override; Int_t GetPdg() const { return fPdg; }; @@ -95,7 +95,7 @@ class FairRadMapPoint : public FairMCPoint Double_t fXOut, fYOut, fZOut; Double_t fPxOut, fPyOut, fPzOut; - ClassDef(FairRadMapPoint, 3); + ClassDefOverride(FairRadMapPoint, 3); }; #endif diff --git a/base/event/FairRecoEventHeader.cxx b/fairroot/base/event/FairRecoEventHeader.cxx similarity index 89% rename from base/event/FairRecoEventHeader.cxx rename to fairroot/base/event/FairRecoEventHeader.cxx index ff688c82cd..ec252cd95f 100644 --- a/base/event/FairRecoEventHeader.cxx +++ b/fairroot/base/event/FairRecoEventHeader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,5 +20,3 @@ FairRecoEventHeader::FairRecoEventHeader() {} FairRecoEventHeader::~FairRecoEventHeader() {} - -ClassImp(FairRecoEventHeader); diff --git a/base/event/FairRecoEventHeader.h b/fairroot/base/event/FairRecoEventHeader.h similarity index 94% rename from base/event/FairRecoEventHeader.h rename to fairroot/base/event/FairRecoEventHeader.h index d2c748a558..7c01663ef8 100644 --- a/base/event/FairRecoEventHeader.h +++ b/fairroot/base/event/FairRecoEventHeader.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -84,7 +84,7 @@ class FairRecoEventHeader : public TNamed /** * Destructor */ - virtual ~FairRecoEventHeader(); + ~FairRecoEventHeader() override; protected: /** Run Id */ @@ -96,7 +96,7 @@ class FairRecoEventHeader : public TNamed /** Event Time Error **/ Double_t fEventTimeError; - ClassDef(FairRecoEventHeader, 1); + ClassDefOverride(FairRecoEventHeader, 1); }; #endif diff --git a/base/event/FairRunInfo.cxx b/fairroot/base/event/FairRunInfo.cxx similarity index 98% rename from base/event/FairRunInfo.cxx rename to fairroot/base/event/FairRunInfo.cxx index 901831d14c..04f8efdc3a 100644 --- a/base/event/FairRunInfo.cxx +++ b/fairroot/base/event/FairRunInfo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,8 +19,6 @@ #include // for sort #include // for unique_ptr -ClassImp(FairRunInfo); - FairRunInfo::FairRunInfo() : TObject() , fTimeStamp() diff --git a/base/event/FairRunInfo.h b/fairroot/base/event/FairRunInfo.h similarity index 91% rename from base/event/FairRunInfo.h rename to fairroot/base/event/FairRunInfo.h index f4776b4a1f..7e9c9b1e18 100644 --- a/base/event/FairRunInfo.h +++ b/fairroot/base/event/FairRunInfo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,7 +20,7 @@ class FairRunInfo : public TObject { public: FairRunInfo(); - ~FairRunInfo(); + ~FairRunInfo() override; void StoreInfo(); void WriteInfo(); @@ -45,7 +45,7 @@ class FairRunInfo : public TObject FairRunInfo(const FairRunInfo&); FairRunInfo& operator=(const FairRunInfo&); - ClassDef(FairRunInfo, 2); + ClassDefOverride(FairRunInfo, 2); }; #endif diff --git a/base/event/FairTimeStamp.cxx b/fairroot/base/event/FairTimeStamp.cxx similarity index 87% rename from base/event/FairTimeStamp.cxx rename to fairroot/base/event/FairTimeStamp.cxx index 784da78984..5968017ee6 100644 --- a/base/event/FairTimeStamp.cxx +++ b/fairroot/base/event/FairTimeStamp.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,5 +13,3 @@ std::ostream& FairTimeStamp::PrintTimeInfo(std::ostream& out) const FairMultiLinkedData_Interface::PrintLinkInfo(out); return out; } - -ClassImp(FairTimeStamp); diff --git a/base/event/FairTimeStamp.h b/fairroot/base/event/FairTimeStamp.h similarity index 60% rename from base/event/FairTimeStamp.h rename to fairroot/base/event/FairTimeStamp.h index d15938179c..7cc936783d 100644 --- a/base/event/FairTimeStamp.h +++ b/fairroot/base/event/FairTimeStamp.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include // for ostream #include // for ostream, cout -class TObject; - /** * Base class for Time stamp information ** Aug. 2010 @@ -25,31 +23,35 @@ class FairTimeStamp : public FairMultiLinkedData_Interface { public: /** Default constructor **/ - FairTimeStamp(); + FairTimeStamp() = default; + /** Constructor with time **/ - FairTimeStamp(Double_t time); + FairTimeStamp(Double_t time) + : fTimeStamp(time) + {} /** Constructor with time and time error **/ - FairTimeStamp(Double_t time, Double_t timeerror); + FairTimeStamp(Double_t time, Double_t timeerror) + : fTimeStamp(time) + , fTimeStampError(timeerror) + {} /** Destructor **/ - virtual ~FairTimeStamp(){}; + ~FairTimeStamp() override = default; /** Accessors **/ Double_t GetTimeStamp() const { return fTimeStamp; } Double_t GetTimeStampError() const { return fTimeStampError; } /** Modifiers **/ void SetTimeStamp(Double_t t) { fTimeStamp = t; } void SetTimeStampError(Double_t t) { fTimeStampError = t; } - virtual Int_t Compare(const TObject* obj) const + Int_t Compare(const TObject* obj) const override { if (this == obj) { return 0; } - FairTimeStamp* tsobj = static_cast(const_cast(obj)); + auto tsobj = static_cast(obj); Double_t ts = tsobj->GetTimeStamp(); Double_t tserror = tsobj->GetTimeStampError(); - if (fTimeStamp < ts) { - return -1; - } else if (fTimeStamp == ts && fTimeStampError < tserror) { + if ((fTimeStamp < ts) || (fTimeStamp == ts && fTimeStampError < tserror)) { return -1; } else if (fTimeStamp == ts && fTimeStampError == tserror) { return 0; @@ -59,7 +61,7 @@ class FairTimeStamp : public FairMultiLinkedData_Interface } virtual std::ostream& PrintTimeInfo(std::ostream& out = std::cout) const; - virtual Bool_t IsSortable() const { return kTRUE; }; + Bool_t IsSortable() const override { return kTRUE; }; virtual bool equal(FairTimeStamp* data) { @@ -72,33 +74,13 @@ class FairTimeStamp : public FairMultiLinkedData_Interface return out; } - virtual bool operator<(const FairTimeStamp* rValue) const { return GetTimeStamp() < rValue->GetTimeStamp(); } + bool operator<(const FairTimeStamp& rValue) const { return fTimeStamp < rValue.fTimeStamp; } protected: - Double_t fTimeStamp; /** Time of digit or Hit [ns] */ - Double_t fTimeStampError; /** Error on time stamp */ + Double_t fTimeStamp{-1}; //< Time of digit or Hit [ns] + Double_t fTimeStampError{-1}; //< Error on time stamp - ClassDef(FairTimeStamp, 4); + ClassDefOverride(FairTimeStamp, 4); }; -// ----- Default constructor ------------------------------------------- -inline FairTimeStamp::FairTimeStamp() - : FairMultiLinkedData_Interface() - , fTimeStamp(-1) - , fTimeStampError(-1) -{} - -// ----- Standard constructor ------------------------------------------ -inline FairTimeStamp::FairTimeStamp(Double_t time) - : FairMultiLinkedData_Interface() - , fTimeStamp(time) - , fTimeStampError(-1) -{} - -inline FairTimeStamp::FairTimeStamp(Double_t time, Double_t timeerror) - : FairMultiLinkedData_Interface() - , fTimeStamp(time) - , fTimeStampError(timeerror) -{} - #endif // FAIRTIMESTAMP_H diff --git a/base/event/FairTrackParam.cxx b/fairroot/base/event/FairTrackParam.cxx similarity index 97% rename from base/event/FairTrackParam.cxx rename to fairroot/base/event/FairTrackParam.cxx index 6e43e96d71..de080b71b0 100644 --- a/base/event/FairTrackParam.cxx +++ b/fairroot/base/event/FairTrackParam.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -187,7 +187,6 @@ void FairTrackParam::SetCovariance(Int_t i, Int_t j, Double_t val) index = 10 + j; } fCovMatrix[index] = val; - return; } FairTrackParam& FairTrackParam::operator=(const FairTrackParam& par) @@ -203,5 +202,3 @@ FairTrackParam& FairTrackParam::operator=(const FairTrackParam& par) SetCovMatrix(cov); return *this; } - -ClassImp(FairTrackParam); diff --git a/base/event/FairTrackParam.h b/fairroot/base/event/FairTrackParam.h similarity index 94% rename from base/event/FairTrackParam.h rename to fairroot/base/event/FairTrackParam.h index d6fafd4a95..95aa0ec0b3 100644 --- a/base/event/FairTrackParam.h +++ b/fairroot/base/event/FairTrackParam.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -49,10 +49,10 @@ class FairTrackParam : public TObject FairTrackParam(const FairTrackParam& param); /** Destructor **/ - virtual ~FairTrackParam(); + ~FairTrackParam() override; /** Output to screen **/ - void Print(Option_t* option = "") const; + void Print(Option_t* option = "") const override; /** Accessors **/ Double_t GetX() const { return fX; }; @@ -100,7 +100,7 @@ class FairTrackParam : public TObject Double32_t fCovMatrix[15]; - ClassDef(FairTrackParam, 1); + ClassDefOverride(FairTrackParam, 1); }; #endif diff --git a/base/event/README.dox b/fairroot/base/event/README.dox similarity index 100% rename from base/event/README.dox rename to fairroot/base/event/README.dox diff --git a/base/field/FairField.cxx b/fairroot/base/field/FairField.cxx similarity index 93% rename from base/field/FairField.cxx rename to fairroot/base/field/FairField.cxx index c81c271d2a..e42c50f028 100644 --- a/base/field/FairField.cxx +++ b/fairroot/base/field/FairField.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -41,5 +41,3 @@ void FairField::GetFieldValue(const Double_t point[3], Double_t* bField) bField[1] = GetBy(point[0], point[1], point[2]); bField[2] = GetBz(point[0], point[1], point[2]); } - -ClassImp(FairField); diff --git a/base/field/FairField.h b/fairroot/base/field/FairField.h similarity index 93% rename from base/field/FairField.h rename to fairroot/base/field/FairField.h index c447f62e98..7d2f137855 100644 --- a/base/field/FairField.h +++ b/fairroot/base/field/FairField.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -45,7 +45,7 @@ class FairField : public TVirtualMagField FairField& operator=(const FairField&) { return *this; } /** Destructor **/ - virtual ~FairField(); + ~FairField() override; /** Intialisation. E.g. read in the field map. If needed, to be ** implemented in the concrete class. @@ -94,10 +94,10 @@ class FairField : public TVirtualMagField **/ virtual void GetFieldValue(const Double_t point[3], Double_t* bField); - void Field(const Double_t point[3], Double_t* B) { GetFieldValue(point, B); } + void Field(const Double_t point[3], Double_t* B) override { GetFieldValue(point, B); } /** Screen output. To be implemented in the concrete class. **/ - virtual void Print(Option_t*) const { ; } + void Print(Option_t*) const override { ; } virtual void GetBxyz(const Double_t[3], Double_t*) { LOG(warn) << "FairField::GetBxyz Should be implemented in User class"; @@ -115,7 +115,7 @@ class FairField : public TVirtualMagField // FairField& operator=(const FairField&); // TODO: Check why the htrack needs this - ClassDef(FairField, 4); + ClassDefOverride(FairField, 4); }; #endif diff --git a/base/field/FairFieldFactory.cxx b/fairroot/base/field/FairFieldFactory.cxx similarity index 88% rename from base/field/FairFieldFactory.cxx rename to fairroot/base/field/FairFieldFactory.cxx index 50bf557c30..f016a4e769 100644 --- a/base/field/FairFieldFactory.cxx +++ b/fairroot/base/field/FairFieldFactory.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,6 +31,7 @@ FairFieldFactory::~FairFieldFactory() } } -FairFieldFactory* FairFieldFactory::Instance() { return fgRinstance; } - -ClassImp(FairFieldFactory); +FairFieldFactory* FairFieldFactory::Instance() +{ + return fgRinstance; +} diff --git a/base/field/FairFieldFactory.h b/fairroot/base/field/FairFieldFactory.h similarity index 97% rename from base/field/FairFieldFactory.h rename to fairroot/base/field/FairFieldFactory.h index 9bca4397e9..8bef2d2912 100644 --- a/base/field/FairFieldFactory.h +++ b/fairroot/base/field/FairFieldFactory.h @@ -17,6 +17,9 @@ class FairField; +/** + * \ingroup base_sim fairroot_singleton + */ class FairFieldFactory { public: diff --git a/base/field/README.dox b/fairroot/base/field/README.dox similarity index 100% rename from base/field/README.dox rename to fairroot/base/field/README.dox diff --git a/base/sim/FairBaseContFact.cxx b/fairroot/base/sim/FairBaseContFact.cxx similarity index 98% rename from base/sim/FairBaseContFact.cxx rename to fairroot/base/sim/FairBaseContFact.cxx index 6959bf67a8..e94e2fc54e 100644 --- a/base/sim/FairBaseContFact.cxx +++ b/fairroot/base/sim/FairBaseContFact.cxx @@ -21,10 +21,6 @@ #include #include -class FairParSet; - -ClassImp(FairBaseContFact); - static FairBaseContFact gFairBaseContFact; FairBaseContFact::FairBaseContFact() diff --git a/base/sim/FairBaseContFact.h b/fairroot/base/sim/FairBaseContFact.h similarity index 95% rename from base/sim/FairBaseContFact.h rename to fairroot/base/sim/FairBaseContFact.h index 9a5ff77a09..4894efcaca 100644 --- a/base/sim/FairBaseContFact.h +++ b/fairroot/base/sim/FairBaseContFact.h @@ -12,8 +12,6 @@ #include // for FairBaseContFact::Class, etc -class FairParSet; - class FairBaseContFact : public FairContFact { /** Factory for all Base parameter containers */ @@ -21,7 +19,7 @@ class FairBaseContFact : public FairContFact /**default ctor*/ FairBaseContFact(); /**default dtor*/ - ~FairBaseContFact() override {} + ~FairBaseContFact() override = default; /** Calls the constructor of the corresponding parameter container. * For an actual context, which is not an empty string and not the default context * of this container, the name is concatinated with the context. */ diff --git a/base/sim/FairBaseParSet.cxx b/fairroot/base/sim/FairBaseParSet.cxx similarity index 91% rename from base/sim/FairBaseParSet.cxx rename to fairroot/base/sim/FairBaseParSet.cxx index 20a8e29f97..00595b3c03 100644 --- a/base/sim/FairBaseParSet.cxx +++ b/fairroot/base/sim/FairBaseParSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,8 +17,6 @@ #include -ClassImp(FairBaseParSet); - FairBaseParSet::FairBaseParSet(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fDetList(0) @@ -28,7 +26,7 @@ FairBaseParSet::FairBaseParSet(const char* name, const char* title, const char* , fRandomSeed(99999999) {} -FairBaseParSet::~FairBaseParSet(void) +FairBaseParSet::~FairBaseParSet() { if (fContNameList) { fContNameList->Delete(); @@ -36,7 +34,10 @@ FairBaseParSet::~FairBaseParSet(void) } } -void FairBaseParSet::clear(void) { fContNameList->Delete(); } +void FairBaseParSet::clear() +{ + fContNameList->Delete(); +} void FairBaseParSet::putParams(FairParamList* l) { diff --git a/base/sim/FairBaseParSet.h b/fairroot/base/sim/FairBaseParSet.h similarity index 100% rename from base/sim/FairBaseParSet.h rename to fairroot/base/sim/FairBaseParSet.h diff --git a/base/sim/FairDetector.cxx b/fairroot/base/sim/FairDetector.cxx similarity index 88% rename from base/sim/FairDetector.cxx rename to fairroot/base/sim/FairDetector.cxx index 71542f29ac..e8642ca45d 100644 --- a/base/sim/FairDetector.cxx +++ b/fairroot/base/sim/FairDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,8 +13,6 @@ #include "FairDetector.h" #include "FairGeoNode.h" // for FairGeoNode -#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN -#include "FairModule.h" // for FairModule::svList, etc #include "FairRootManager.h" #include "FairVolume.h" // for FairVolume @@ -26,11 +24,11 @@ #include // for TRefArray #include // for TString #include // for TVirtualMC +#include FairDetector::FairDetector(const char* Name, Bool_t Active, Int_t DetId) : FairModule(Name, "FAIR Detector", Active) , fDetId(DetId) - , fLogger(FairLogger::GetLogger()) { flGeoPar = new TList(); TString lname(GetName()); @@ -42,7 +40,6 @@ FairDetector::FairDetector(const char* Name, Bool_t Active, Int_t DetId) FairDetector::FairDetector(const FairDetector& rhs) : FairModule(rhs) , fDetId(rhs.fDetId) - , fLogger(rhs.fLogger) {} FairDetector::~FairDetector() { delete flGeoPar; } @@ -58,14 +55,12 @@ FairDetector& FairDetector::operator=(const FairDetector& rhs) // assignment operator fDetId = rhs.fDetId; - fLogger = rhs.fLogger; return *this; } FairDetector::FairDetector() : fDetId(0) - , fLogger(FairLogger::GetLogger()) {} // ------------------------------------------------------------------------- @@ -98,13 +93,11 @@ void FairDetector::Initialize() DefineSensitiveVolumes(); } - Int_t NoOfEntries = svList->GetEntries(); Int_t fMCid; FairGeoNode* fN; TString cutName; TString copysign = "#"; - for (Int_t i = 0; i < NoOfEntries; i++) { - FairVolume* aVol = static_cast(svList->At(i)); + for (auto aVol : fAllSensitiveVolumes) { cutName = aVol->GetName(); Ssiz_t pos = cutName.Index(copysign, 1); if (pos > 1) { @@ -140,5 +133,3 @@ void FairDetector::SaveGeoParams() fGeoSaved = kTRUE; } } - -ClassImp(FairDetector); diff --git a/base/sim/FairDetector.h b/fairroot/base/sim/FairDetector.h similarity index 91% rename from base/sim/FairDetector.h rename to fairroot/base/sim/FairDetector.h index b89fa8ab79..a4020e81df 100644 --- a/base/sim/FairDetector.h +++ b/fairroot/base/sim/FairDetector.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,10 +11,9 @@ #include "FairModule.h" // for FairModule #include // for Int_t, Bool_t, etc +#include -class FairLogger; class FairVolume; -class TClonesArray; /** * Base class for constructing detecors @@ -39,7 +38,7 @@ class FairDetector : public FairModule /** destructor */ - virtual ~FairDetector(); + ~FairDetector() override; /** Initialization of the detector is done here */ @@ -107,9 +106,8 @@ class FairDetector : public FairModule void DefineSensitiveVolumes(); - Int_t fDetId; // Detector Id has to be set from ctr. - FairLogger* fLogger; //! /// FairLogger + Int_t fDetId; // Detector Id has to be set from ctr. - ClassDef(FairDetector, 1); + ClassDefOverride(FairDetector, 1); }; #endif // FAIRDETECTOR_H diff --git a/base/sim/FairDoubleHit.cxx b/fairroot/base/sim/FairDoubleHit.cxx similarity index 87% rename from base/sim/FairDoubleHit.cxx rename to fairroot/base/sim/FairDoubleHit.cxx index f3e8f7e4d0..08d2e9323c 100644 --- a/base/sim/FairDoubleHit.cxx +++ b/fairroot/base/sim/FairDoubleHit.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,5 +19,3 @@ FairDoubleHit::FairDoubleHit() {} FairDoubleHit::~FairDoubleHit() {} - -ClassImp(FairDoubleHit); diff --git a/base/sim/FairDoubleHit.h b/fairroot/base/sim/FairDoubleHit.h similarity index 89% rename from base/sim/FairDoubleHit.h rename to fairroot/base/sim/FairDoubleHit.h index 3173ca61d2..1669965c52 100644 --- a/base/sim/FairDoubleHit.h +++ b/fairroot/base/sim/FairDoubleHit.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,11 +26,11 @@ class FairDoubleHit : public FairMultiLinkedData public: FairDoubleHit(); - virtual ~FairDoubleHit(); + ~FairDoubleHit() override; // methods - virtual void Print(const Option_t* opt = 0) const = 0; + void Print(const Option_t* opt = 0) const override = 0; // set methods virtual void SetDetectorID(Int_t chamb) = 0; @@ -63,6 +63,6 @@ class FairDoubleHit : public FairMultiLinkedData virtual Double_t dy_out() = 0; virtual Double_t dz_out() = 0; - ClassDef(FairDoubleHit, 1); + ClassDefOverride(FairDoubleHit, 1); }; #endif // FAIRDOUBLEHIT_H diff --git a/base/sim/FairGeaneApplication.cxx b/fairroot/base/sim/FairGeaneApplication.cxx similarity index 92% rename from base/sim/FairGeaneApplication.cxx rename to fairroot/base/sim/FairGeaneApplication.cxx index 025fdd4670..2a7b8098b5 100644 --- a/base/sim/FairGeaneApplication.cxx +++ b/fairroot/base/sim/FairGeaneApplication.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -68,6 +68,7 @@ void FairGeaneApplication::GeaneStepping() } } -void FairGeaneApplication::SetField(FairField* field) { fxField = field; } - -ClassImp(FairGeaneApplication); +void FairGeaneApplication::SetField(FairField* field) +{ + fxField = field; +} diff --git a/base/sim/FairGeaneApplication.h b/fairroot/base/sim/FairGeaneApplication.h similarity index 96% rename from base/sim/FairGeaneApplication.h rename to fairroot/base/sim/FairGeaneApplication.h index 5d9862f439..d8978e1aeb 100644 --- a/base/sim/FairGeaneApplication.h +++ b/fairroot/base/sim/FairGeaneApplication.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,11 +21,11 @@ class FairField; /** * The Main Application for GEANE + * \ingroup base_sim fairroot_singleton * @author M. Al-Turany * @version 0.1 * @since 10.11.10 */ - class FairGeaneApplication : public TVirtualMCApplication { public: diff --git a/base/sim/FairGenerator.cxx b/fairroot/base/sim/FairGenerator.cxx similarity index 92% rename from base/sim/FairGenerator.cxx rename to fairroot/base/sim/FairGenerator.cxx index 046fdf97f3..153e9ac673 100644 --- a/base/sim/FairGenerator.cxx +++ b/fairroot/base/sim/FairGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -42,5 +42,3 @@ FairGenerator* FairGenerator::CloneGenerator() const Fatal("CloneGenerator", "Has to be overriden in multi-threading applications."); return 0; } - -ClassImp(FairGenerator); diff --git a/base/sim/FairGenerator.h b/fairroot/base/sim/FairGenerator.h similarity index 93% rename from base/sim/FairGenerator.h rename to fairroot/base/sim/FairGenerator.h index c36e7dc7e5..cca722c847 100644 --- a/base/sim/FairGenerator.h +++ b/fairroot/base/sim/FairGenerator.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -38,7 +38,7 @@ class FairGenerator : public TNamed FairGenerator(const char* name, const char* title = "FAIR Generator"); /** Destructor. **/ - virtual ~FairGenerator(); + ~FairGenerator() override; /** Abstract method ReadEvent must be implemented by any derived class. It has to handle the generation of input tracks (reading from input @@ -53,7 +53,7 @@ class FairGenerator : public TNamed virtual Bool_t Init() { return kTRUE; } /**Finalize the generator if needed */ - virtual void Finish() { return; } + virtual void Finish() {} /** Clone this object (used in MT mode only) */ virtual FairGenerator* CloneGenerator() const; @@ -64,7 +64,7 @@ class FairGenerator : public TNamed /** Assignment operator */ FairGenerator& operator=(const FairGenerator&); - ClassDef(FairGenerator, 1); + ClassDefOverride(FairGenerator, 1); }; #endif diff --git a/base/sim/FairGenericStack.cxx b/fairroot/base/sim/FairGenericStack.cxx similarity index 95% rename from base/sim/FairGenericStack.cxx rename to fairroot/base/sim/FairGenericStack.cxx index 3015d8bef2..d893f9a8ae 100644 --- a/base/sim/FairGenericStack.cxx +++ b/fairroot/base/sim/FairGenericStack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,8 +11,6 @@ // ------------------------------------------------------------------------- #include "FairGenericStack.h" -#include "FairLogger.h" // for FairLogger - #include #include #include @@ -20,10 +18,10 @@ #include #include #include // strcmp +#include FairGenericStack::FairGenericStack() : TVirtualMCStack() - , fLogger(FairLogger::GetLogger()) , fDetList(0) , fDetIter(0) , fVerbose(1) @@ -37,7 +35,6 @@ FairGenericStack::FairGenericStack() // ----- Constructor with estimated array dimension -------------------- FairGenericStack::FairGenericStack(Int_t) : TVirtualMCStack() - , fLogger(FairLogger::GetLogger()) , fDetList(0) , fDetIter(0) , fVerbose(1) @@ -52,7 +49,6 @@ FairGenericStack::~FairGenericStack() { delete fDetIter; } FairGenericStack::FairGenericStack(const FairGenericStack& rhs) : TVirtualMCStack(rhs) - , fLogger(FairLogger::GetLogger()) , fDetList(rhs.fDetList) , fDetIter(0) , fVerbose(rhs.fVerbose) @@ -68,7 +64,6 @@ FairGenericStack& FairGenericStack::operator=(const FairGenericStack& rhs) TVirtualMCStack::operator=(rhs); // assignment oiperator - fLogger = 0; fDetList = 0; fDetIter = 0; fVerbose = rhs.fVerbose; @@ -172,5 +167,3 @@ void FairGenericStack::FastSimPushSecondary(Int_t parentID, fFSFirstSecondary = GetListOfParticles()->GetEntries() - 1; fFSNofSecondaries++; } - -ClassImp(FairGenericStack); diff --git a/base/sim/FairGenericStack.h b/fairroot/base/sim/FairGenericStack.h similarity index 95% rename from base/sim/FairGenericStack.h rename to fairroot/base/sim/FairGenericStack.h index 1d71d7d358..2430d7e867 100644 --- a/base/sim/FairGenericStack.h +++ b/fairroot/base/sim/FairGenericStack.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,7 +25,6 @@ #include #include -class FairLogger; class TParticle; class TRefArray; class TIterator; @@ -40,7 +39,7 @@ class FairGenericStack : public TVirtualMCStack FairGenericStack(Int_t size); /** Destructor **/ - virtual ~FairGenericStack(); + ~FairGenericStack() override; /** Virtual method PushTrack. ** Add a TParticle to the stack. @@ -97,8 +96,13 @@ class FairGenericStack : public TVirtualMCStack /** Register the MCTrack array to the Root Manager **/ virtual void Register() {} - virtual TClonesArray* GetListOfParticles() { return 0; } - virtual void SetParticleArray(__attribute__((unused)) TClonesArray* partArray) {} + virtual TClonesArray* GetListOfParticles() { return nullptr; } + virtual void SetParticleArray(TClonesArray* partArray) + { + if (partArray) { + SetParticleArray(partArray, 0, partArray->GetEntries()); + } + } virtual void SetParticleArray(__attribute__((unused)) TClonesArray* partArray, __attribute__((unused)) Int_t partFrom, __attribute__((unused)) Int_t partTo) @@ -169,9 +173,6 @@ class FairGenericStack : public TVirtualMCStack /** Assignment operator */ FairGenericStack& operator=(const FairGenericStack&); - /** Fair Logger */ - FairLogger* fLogger; //! - /** List of detectors registering hits in the simulation */ TRefArray* fDetList; //! @@ -188,7 +189,7 @@ class FairGenericStack : public TVirtualMCStack Int_t fFSFirstSecondary; //! Int_t fFSNofSecondaries; //! - ClassDef(FairGenericStack, 1); + ClassDefOverride(FairGenericStack, 1); }; template diff --git a/base/sim/FairGenericVMCConfig.cxx b/fairroot/base/sim/FairGenericVMCConfig.cxx similarity index 98% rename from base/sim/FairGenericVMCConfig.cxx rename to fairroot/base/sim/FairGenericVMCConfig.cxx index 9e327ce469..96bfb3a60d 100644 --- a/base/sim/FairGenericVMCConfig.cxx +++ b/fairroot/base/sim/FairGenericVMCConfig.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -224,5 +224,3 @@ void FairGenericVMCConfig::SetupPostInit(const char* mcEngine) gROOT->ProcessLine("ConfigPostInit()"); } } - -ClassImp(FairGenericVMCConfig); diff --git a/base/sim/FairGenericVMCConfig.h b/fairroot/base/sim/FairGenericVMCConfig.h similarity index 100% rename from base/sim/FairGenericVMCConfig.h rename to fairroot/base/sim/FairGenericVMCConfig.h diff --git a/base/sim/FairGeoParSet.cxx b/fairroot/base/sim/FairGeoParSet.cxx similarity index 90% rename from base/sim/FairGeoParSet.cxx rename to fairroot/base/sim/FairGeoParSet.cxx index 1f953c73bd..0c1f329548 100644 --- a/base/sim/FairGeoParSet.cxx +++ b/fairroot/base/sim/FairGeoParSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,17 +16,15 @@ #include // for TObjArray -ClassImp(FairGeoParSet); - FairGeoParSet::FairGeoParSet(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoNodes(new TObjArray()) , fGeom(0) {} -FairGeoParSet::~FairGeoParSet(void) {} +FairGeoParSet::~FairGeoParSet() {} -void FairGeoParSet::clear(void) +void FairGeoParSet::clear() { // delete fGeoNodes; // delete fGeom; diff --git a/base/sim/FairGeoParSet.h b/fairroot/base/sim/FairGeoParSet.h similarity index 100% rename from base/sim/FairGeoParSet.h rename to fairroot/base/sim/FairGeoParSet.h diff --git a/base/sim/FairIon.cxx b/fairroot/base/sim/FairIon.cxx similarity index 86% rename from base/sim/FairIon.cxx rename to fairroot/base/sim/FairIon.cxx index 525289be6a..88add62fad 100644 --- a/base/sim/FairIon.cxx +++ b/fairroot/base/sim/FairIon.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,10 +10,9 @@ // ------------------------------------------------------------------------- #include "FairIon.h" -#include "FairLogger.h" - #include #include +#include FairIon::FairIon() : TNamed() @@ -22,7 +21,6 @@ FairIon::FairIon() , fQ(0) , fExcEnergy(0) , fMass(0) - , fLogger(FairLogger::GetLogger()) {} FairIon::FairIon(const char* name, Int_t z, Int_t a, Int_t q, Double_t e, Double_t mass) @@ -32,7 +30,6 @@ FairIon::FairIon(const char* name, Int_t z, Int_t a, Int_t q, Double_t e, Double , fQ(q) , fExcEnergy(e) , fMass(0) - , fLogger(FairLogger::GetLogger()) { TDatabasePDG* pdgDB = TDatabasePDG::Instance(); TParticlePDG* kProton = pdgDB->GetParticle(2212); @@ -45,7 +42,3 @@ FairIon::FairIon(const char* name, Int_t z, Int_t a, Int_t q, Double_t e, Double } LOG(info) << "New Ion " << name << " Z=" << z << " A=" << a << " Charge=" << q << " Mass=" << fMass << " GeV "; } - -FairIon::~FairIon(){}; - -ClassImp(FairIon); diff --git a/base/sim/FairIon.h b/fairroot/base/sim/FairIon.h similarity index 83% rename from base/sim/FairIon.h rename to fairroot/base/sim/FairIon.h index 6981d26bbc..ca63806cbc 100644 --- a/base/sim/FairIon.h +++ b/fairroot/base/sim/FairIon.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,8 +24,6 @@ #include // for Int_t, Double_t, etc #include // for TNamed -class FairLogger; - class FairIon : public TNamed { public: @@ -53,7 +51,7 @@ class FairIon : public TNamed fMass = m; } /** Destructor **/ - virtual ~FairIon(); + ~FairIon() override = default; /** Accessors **/ /** @@ -92,18 +90,17 @@ class FairIon : public TNamed void SetMass(Double_t mass) { fMass = mass; } private: - static Int_t fgNIon; //! /// Number of ions instantiated. One per generator. - Int_t fZ; /// Atomic number - Int_t fA; /// Atomic mass - Int_t fQ; /// Electric charge - Double_t fExcEnergy; /// Excitation energy [GeV] - Double_t fMass; /// Mass [GeV] - FairLogger* fLogger; //! /// FairLogger + static Int_t fgNIon; //! /// Number of ions instantiated. One per generator. + Int_t fZ; /// Atomic number + Int_t fA; /// Atomic mass + Int_t fQ; /// Electric charge + Double_t fExcEnergy; /// Excitation energy [GeV] + Double_t fMass; /// Mass [GeV] FairIon(const FairIon&); FairIon& operator=(const FairIon&); - ClassDef(FairIon, 2); + ClassDefOverride(FairIon, 2); }; #endif diff --git a/base/sim/FairMCApplication.cxx b/fairroot/base/sim/FairMCApplication.cxx similarity index 86% rename from base/sim/FairMCApplication.cxx rename to fairroot/base/sim/FairMCApplication.cxx index 9db4608863..fdd412b698 100644 --- a/base/sim/FairMCApplication.cxx +++ b/fairroot/base/sim/FairMCApplication.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -55,49 +55,35 @@ #include // for TObject #include // for TParticlePDG #include // for TROOT, gROOT -#include // for TRefArray #include // for TSystem, gSystem #include // for TVirtualMC #include // for TVirtualMCStack -class TParticle; +#include // for DBL_MAX +#include // for getenv, exit +#include // std::mutex +#include // for pair, move -#include // for DBL_MAX -#include // std::mutex -#include // for getenv, exit -#include // for pair, move -std::mutex mtx; // mutex for critical section +std::mutex mtx; // mutex for critical section using std::pair; //_____________________________________________________________________________ FairMCApplication::FairMCApplication(const char* name, const char* title, TObjArray* ModList, const char*) : TVirtualMCApplication(name, title) - , fActiveDetectors(nullptr) , fFairTaskList(nullptr) - , fDetectors(nullptr) - , fModIter(nullptr) - , fModules(nullptr) - , fNoSenVolumes(0) + , fModules(ModList) , fPythiaDecayer(kFALSE) , fPythiaDecayerConfig("") - , fStack(nullptr) , fRootManager(nullptr) - , fSenVolumes(nullptr) , fxField(nullptr) , fEvGen(nullptr) , fMcVersion(-1) - , fTrajFilter(nullptr) - , fTrajAccepted(kFALSE) , fUserDecay(kFALSE) , fUserDecayConfig("") , fDebug(kFALSE) , fVolMap() , fModVolMap() , fTrkPos(TLorentzVector(0, 0, 0, 0)) - , fRadLength(kFALSE) - , fRadLenMan(nullptr) - , fRadMap(kFALSE) - , fRadMapMan(nullptr) , fEventHeader(nullptr) , fMCEventHeader(nullptr) , listActiveDetectors() @@ -108,6 +94,7 @@ FairMCApplication::FairMCApplication(const char* name, const char* title, TObjAr , fState(FairMCApplicationState::kUnknownState) , fRunInfo() , fGeometryIsInitialized(kFALSE) + , fOwnedModules() , fWorkerRunSim() { // Standard Simulation constructor @@ -117,26 +104,21 @@ FairMCApplication::FairMCApplication(const char* name, const char* title, TObjAr LOG(debug) << "FairMCApplication-ctor " << this; fRootManager = &fRun->GetRootManager(); - fModules = ModList; - fModIter = fModules->MakeIterator(); - // Create and fill a list of active detectors - fDetectors = new TRefArray; - fActiveDetectors = new TRefArray(); - fModIter->Reset(); - FairDetector* detector; - TObject* obj; - - while ((obj = fModIter->Next())) { - detector = dynamic_cast(obj); + + fListModules.reserve(fModules->GetEntriesFast()); + for (auto module : TRangeDynCast(fModules)) { + if (!module) { + LOG(error) << "Dynamic cast fails. Object not a FairModule in module list"; + continue; + } + fListModules.push_back(module); + auto detector = dynamic_cast(module); if (detector) { - fDetectors->Add(detector); listDetectors.push_back(detector); if (detector->IsActive()) { - fActiveDetectors->Add(detector); + fActiveDetectors.Add(detector); listActiveDetectors.push_back(detector); } - } else if (!dynamic_cast(obj)) { - LOG(error) << "Dynamic cast fails. Object neither FairDetector nor FairModule in module list"; } } @@ -144,39 +126,26 @@ FairMCApplication::FairMCApplication(const char* name, const char* title, TObjAr fFairTaskList = new FairTask("Task List", 1); gROOT->GetListOfBrowsables()->Add(fFairTaskList); fMcVersion = -1; - // Initialise fTrajFilter pointer - fTrajFilter = nullptr; } //_____________________________________________________________________________ FairMCApplication::FairMCApplication(const FairMCApplication& rhs, std::unique_ptr otherRunSim) : TVirtualMCApplication(rhs.GetName(), rhs.GetTitle()) - , fActiveDetectors(nullptr) + , fParent(&rhs) , fFairTaskList(nullptr) - , fDetectors(nullptr) - , fModIter(nullptr) , fModules(nullptr) - , fNoSenVolumes(0) , fPythiaDecayer(kFALSE) , fPythiaDecayerConfig(rhs.fPythiaDecayerConfig) - , fStack(nullptr) , fRootManager(nullptr) - , fSenVolumes(nullptr) , fxField(rhs.fxField) , fEvGen(nullptr) , fMcVersion(rhs.fMcVersion) - , fTrajFilter(nullptr) - , fTrajAccepted(kFALSE) , fUserDecay(kFALSE) , fUserDecayConfig(rhs.fUserDecayConfig) , fDebug(rhs.fDebug) , fVolMap() , fModVolMap() , fTrkPos(rhs.fTrkPos) - , fRadLength(kFALSE) - , fRadLenMan(nullptr) - , fRadMap(kFALSE) - , fRadMapMan(nullptr) , fEventHeader(nullptr) , fMCEventHeader(nullptr) , listActiveDetectors() @@ -186,6 +155,7 @@ FairMCApplication::FairMCApplication(const FairMCApplication& rhs, std::unique_p , fState(FairMCApplicationState::kUnknownState) , fRunInfo() , fGeometryIsInitialized(kFALSE) + , fOwnedModules() , fWorkerRunSim(std::move(otherRunSim)) { // Copy constructor @@ -193,44 +163,35 @@ FairMCApplication::FairMCApplication(const FairMCApplication& rhs, std::unique_p LOG(debug) << "FairMCApplication-copy-ctor " << this; - fParent = &rhs; fRun = fWorkerRunSim.get(); fRootManager = &fRun->GetRootManager(); // Create an ObjArray of Modules and its iterator fModules = new TObjArray(); - fModIter = fModules->MakeIterator(); // Clone modules - TObject* obj; - rhs.fModIter->Reset(); - while ((obj = rhs.fModIter->Next())) { - LOG(debug) << "cloning " << (static_cast(obj))->GetName(); - fModules->Add(static_cast(obj)->CloneModule()); + fListModules.reserve(rhs.fListModules.size()); + fOwnedModules.reserve(rhs.fListModules.size()); + for (auto const* module : rhs.fListModules) { + LOG(debug) << "cloning " << module->GetName(); + auto& clone = fOwnedModules.emplace_back(module->CloneModule()); + fListModules.emplace_back(clone.get()); + fModules->Add(clone.get()); } // Create and fill a list of active detectors - fDetectors = new TRefArray; - fActiveDetectors = new TRefArray(); - fModIter->Reset(); - FairDetector* detector; - while ((obj = fModIter->Next())) { - if (obj->InheritsFrom("FairDetector")) { - detector = dynamic_cast(obj); - if (detector) { - fDetectors->Add(detector); - listDetectors.push_back(detector); - if (detector->IsActive()) { - fActiveDetectors->Add(detector); - listActiveDetectors.push_back(detector); - } - } else { - LOG(error) << "Dynamic cast fails."; + for (auto module : fListModules) { + auto detector = dynamic_cast(module); + if (detector) { + listDetectors.push_back(detector); + if (detector->IsActive()) { + fActiveDetectors.Add(detector); + listActiveDetectors.push_back(detector); } } } // Clone stack - fStack = rhs.fStack->CloneStack(); + fStack.reset(rhs.fStack->CloneStack()); if (rhs.fEvGen) { fEvGen = rhs.fEvGen->ClonePrimaryGenerator(); @@ -244,32 +205,20 @@ FairMCApplication::FairMCApplication(const FairMCApplication& rhs, std::unique_p //_____________________________________________________________________________ FairMCApplication::FairMCApplication() : TVirtualMCApplication() - , fActiveDetectors(0) , fFairTaskList(0) - , fDetectors(0) - , fModIter(0) , fModules(0) - , fNoSenVolumes(0) , fPythiaDecayer(kFALSE) , fPythiaDecayerConfig("") - , fStack(0) , fRootManager(0) - , fSenVolumes(0) , fxField(0) , fEvGen(0) , fMcVersion(-1) - , fTrajFilter(nullptr) - , fTrajAccepted(kFALSE) , fUserDecay(kFALSE) , fUserDecayConfig("") , fDebug(kFALSE) , fVolMap() , fModVolMap() , fTrkPos(TLorentzVector(0, 0, 0, 0)) - , fRadLength(kFALSE) - , fRadLenMan(nullptr) - , fRadMap(kFALSE) - , fRadMapMan(nullptr) , fEventHeader(nullptr) , fMCEventHeader(nullptr) , listActiveDetectors() @@ -279,6 +228,7 @@ FairMCApplication::FairMCApplication() , fState(FairMCApplicationState::kUnknownState) , fRunInfo() , fGeometryIsInitialized(kFALSE) + , fOwnedModules() , fWorkerRunSim() { // Default constructor @@ -288,11 +238,7 @@ FairMCApplication::~FairMCApplication() { // Destructor // LOG(debug3) << "Enter Destructor of FairMCApplication"; - delete fStack; - delete fActiveDetectors; // don't do fActiveDetectors->Delete() here // the modules are already deleted in FairRunSim - delete fDetectors; - delete fModIter; // LOG(debug3) << "Leave Destructor of FairMCApplication"; delete fMC; } @@ -311,8 +257,8 @@ void FairMCApplication::InitMC(const char*, const char*) LOG(fatal) << "No MC engine defined"; } - fStack = dynamic_cast(fMC->GetStack()); - if (fStack == nullptr) { + fStack.reset(dynamic_cast(fMC->GetStack())); + if (!fStack) { LOG(fatal) << "No Stack defined."; } fMC->SetMagField(fxField); @@ -331,7 +277,9 @@ void FairMCApplication::InitMC(const char*, const char*) } else { fMcVersion = 3; // Geane } - fTrajFilter = FairTrajFilter::Instance(); + if ((!fTrajFilter) && fRun->GetStoreTraj()) { + fTrajFilter = std::make_unique(); + } LOG(info) << "Monte Carlo Engine Initialisation with: " << MCName.Data(); } @@ -344,7 +292,7 @@ void FairMCApplication::RunMC(Int_t nofEvents) fRunInfo.Reset(); /** Set the list of active detectors to the stack*/ - fStack->SetDetArrayList(fActiveDetectors); + fStack->SetDetArrayList(&fActiveDetectors); // MC run. fMC->ProcessRun(nofEvents); @@ -416,7 +364,6 @@ void FairMCApplication::FinishRun() if (!fRadGridMan && fRootManager) { fRootManager->Write(); - fRootManager->CloseSink(); } if (fEvGen) { @@ -462,7 +409,7 @@ void FairMCApplication::PreTrack() } fTrajAccepted = kFALSE; - if (nullptr != fTrajFilter) { + if (fTrajFilter) { // Get the pointer to current track TParticle* particle = fStack->GetCurrentTrack(); // LOG(debug) << " FairMCApplication::PreTrack(): " << particle; @@ -490,12 +437,9 @@ TVirtualMCApplication* FairMCApplication::CloneForWorker() const auto workerRun = std::make_unique(kFALSE); workerRun->SetName(fRun->GetName()); // Transport engine workerRun->SetSink(std::unique_ptr{fRun->GetSink()->CloneSink()}); - - // Trajectories filter is created explicitly as we do not call - // FairRunSim::Init on workers - if (fRun->GetStoreTraj()) { - new FairTrajFilter(); - } + workerRun->SetMCEventHeader(new FairMCEventHeader(*(fRun->GetMCEventHeader()))); + workerRun->SetRunId(workerRun->GetMCEventHeader()->GetRunID()); + workerRun->SetStoreTraj(fRun->GetStoreTraj()); // Create new FairMCApplication object on worker return new FairMCApplication(*this, std::move(workerRun)); @@ -510,13 +454,18 @@ void FairMCApplication::InitOnWorker() // and create a new sink on worker // moved to CloneForWorker and specific sink->CloneSink(); - fRootManager->InitSink(); + { + std::lock_guard guard(mtx); + fRootManager->InitSink(); + RegisterOutput(); + fRootManager->WriteFolder(); + } // Cache thread-local gMC fMC = gMC; // Set data to MC - fMC->SetStack(fStack); + fMC->SetStack(fStack.get()); fMC->SetMagField(fxField); LOG(info) << "Monte Carlo Engine Worker Initialisation with: " << fMC->GetName(); @@ -528,6 +477,10 @@ void FairMCApplication::FinishRunOnWorker() LOG(debug) << "FairMCApplication::FinishRunOnWorker: "; FinishRun(); + + // Close the sink on workers so that the execution of main FairRunSim->Run() + // finishes with the output files properly closed. + fRootManager->CloseSink(); } //_____________________________________________________________________________ @@ -660,7 +613,6 @@ void FairMCApplication::StopRun() FinishRun(); if (fRootManager) { fRootManager->Write(); - fRootManager->CloseSink(); } LOG(warn) << "StopRun() exiting not safetly oopps !!!@@@!!!"; exit(0); @@ -689,7 +641,7 @@ void FairMCApplication::FinishEvent() // --> Fill the stack output array fStack->FillTrackArray(); // --> Update track indizes in MCTracks and MCPoints - fStack->UpdateTrackIndex(fActiveDetectors); + fStack->UpdateTrackIndex(&fActiveDetectors); // --> Screen output of stack // fStack->Print(); @@ -713,16 +665,16 @@ void FairMCApplication::FinishEvent() } fStack->Reset(); - if (nullptr != fTrajFilter) { + if (fTrajFilter) { fTrajFilter->Reset(); // TObjArray* fListOfTracks=gGeoManager->GetListOfTracks(); // fListOfTracks->Delete(); gGeoManager->GetListOfTracks()->Delete(); } - if (nullptr != fRadLenMan) { + if (fRadLenMan) { fRadLenMan->Reset(); } - if (nullptr != fRadMapMan) { + if (fRadMapMan) { fRadMapMan->Reset(); } @@ -747,7 +699,10 @@ Double_t FairMCApplication::TrackingZmax() const return DBL_MAX; } //_____________________________________________________________________________ -void FairMCApplication::SetField(FairField* field) { fxField = field; } +void FairMCApplication::SetField(FairField* field) +{ + fxField = field; +} //_____________________________________________________________________________ void FairMCApplication::ConstructOpGeometry() { @@ -763,8 +718,8 @@ void FairMCApplication::ConstructOpGeometry() NK = medium->getNpckov(); if (NK > 0) { Int_t Mid = 0; - TGeoMedium* Med = 0; - if (gGeoManager && (Med = gGeoManager->GetMedium(medium->GetName()))) { + TGeoMedium* Med = (gGeoManager ? gGeoManager->GetMedium(medium->GetName()) : nullptr); + if (Med) { Mid = Med->GetId(); } else { Mid = medium->getMediumIndex(); @@ -783,10 +738,8 @@ void FairMCApplication::ConstructOpGeometry() TVirtualMC::GetMC()->SetCerenkov(Mid, NK, ppckov, absco, effic, rindex); } } - fModIter->Reset(); - FairModule* Mod = nullptr; - while ((Mod = dynamic_cast(fModIter->Next()))) { - Mod->ConstructOpGeometry(); + for (auto module : fListModules) { + module->ConstructOpGeometry(); } } @@ -795,22 +748,19 @@ void FairMCApplication::ConstructGeometry() { // Construct geometry and also fill following member data: // - fModVolMap: (volId,moduleId) - // - fSenVolumes: list of sensitive volumes if (!gGeoManager) { LOG(fatal) << "gGeoManager not initialized at FairMCApplication::ConstructGeometry\n"; } fState = FairMCApplicationState::kConstructGeometry; - fModIter->Reset(); - FairModule* Mod = nullptr; Int_t NoOfVolumes = 0; Int_t NoOfVolumesBefore = 0; Int_t ModId = 0; TObjArray* tgeovolumelist = gGeoManager->GetListOfVolumes(); - while ((Mod = dynamic_cast(fModIter->Next()))) { + for (auto Mod : fListModules) { NoOfVolumesBefore = tgeovolumelist->GetEntriesFast(); Mod->InitParContainers(); Mod->ConstructGeometry(); @@ -862,8 +812,7 @@ void FairMCApplication::ConstructGeometry() } delete particleIter; } - fModIter->Reset(); - while ((Mod = dynamic_cast(fModIter->Next()))) { + for (auto Mod : fListModules) { Mod->RegisterAlignmentMatrices(); } @@ -898,73 +847,22 @@ void FairMCApplication::InitGeometry() /// Initialize geometry - /** Register stack and detector collections*/ - FairVolume* fv = 0; - Int_t id = 0; - fModIter->Reset(); - - // Register stack - if (fEvGen && fStack && fRootManager) { - fStack->Register(); - } else { - LOG(warn) << "Stack is not registered "; - } - - /** SetSpecialPhysicsCuts for FairDetector objects and all passive modules inheriting from FairModule */ - // initialize and register FairDetector objects in addition - // Note: listActiveDetectors or fActiveDetectors not used to include passive modules in the same loop. - FairModule* module; - FairDetector* detector; - TObject* obj; - fModIter->Reset(); - while ((obj = fModIter->Next())) { - detector = dynamic_cast(obj); - module = dynamic_cast(obj); - if (module) { - module->SetSpecialPhysicsCuts(); - } - if (detector) { - // check whether detector is active - if (detector->IsActive()) { - detector->Initialize(); - detector->Register(); - } - } - } - fModIter->Reset(); - - /**Tasks has to be initialized here, they have access to the detector branches and still can create objects in the - * tree*/ - /// There is always a Main Task ! - /// so .. always a InitTasks() is called - if (fFairTaskList) { - InitTasks(); - } - // store the EventHeader Info // Get and register EventHeader UInt_t runId = fRun->GetRunId(); LOG(info) << "Simulation RunID: " << runId; - // Get and register the MCEventHeader - fMCEventHeader = fRun->GetMCEventHeader(); - fMCEventHeader->SetRunID(runId); - if (fRootManager) { - fMCEventHeader->Register(); - } - - if (fEvGen) { - fEvGen->SetEvent(fMCEventHeader); + if ((!fTrajFilter) && fRun->GetStoreTraj()) { + fTrajFilter = std::make_unique(); } - fTrajFilter = FairTrajFilter::Instance(); - if (nullptr != fTrajFilter) { + if (fTrajFilter) { fTrajFilter->Init(); } - if (nullptr != fRadLenMan) { + if (fRadLenMan) { fRadLenMan->Init(); } - if (nullptr != fRadMapMan) { + if (fRadMapMan) { fRadMapMan->Init(); } if (fRadGridMan) { @@ -972,25 +870,27 @@ void FairMCApplication::InitGeometry() } /// save Geo Params in Output file - if (fRootManager) { - fRootManager->WriteFolder(); - } + if (fRootManager && !fParent) { + RegisterOutput(); + + /**Tasks has to be initialized here, they have access to the detector branches and still can create objects in + * the tree*/ + /// There is always a Main Task ! + /// so .. always a InitTasks() is called + if (fFairTaskList) { + InitTasks(); + } - // Get static thread local svList - fSenVolumes = FairModule::svList; - if (fSenVolumes) { - fNoSenVolumes = fSenVolumes->GetEntries(); + fRootManager->WriteFolder(); } + fMCEventHeader->SetRunID(runId); // Fill sensitive volumes in fVolMap - for (Int_t i = 0; i < fNoSenVolumes; i++) { - - fv = dynamic_cast(fSenVolumes->At(i)); + for (auto fv : FairModule::fAllSensitiveVolumes) { if (!fv) { - LOG(error) << "No FairVolume in fSenVolumes at position " << i; continue; } - id = fv->getMCid(); + auto id = fv->getMCid(); if (fv->getGeoNode() == 0) { TGeoNode* fN = 0; TGeoVolume* v = gGeoManager->GetVolume(fv->GetName()); @@ -1005,23 +905,23 @@ void FairMCApplication::InitGeometry() LOG(error) << "No TGeoNode in fNs at position " << k; continue; } - FairVolume* fNewV = new FairVolume(fv->GetName(), id); + auto fNewV = new FairVolume(fv->GetName(), id); fNewV->setModId(fv->getModId()); fNewV->SetModule(fv->GetModule()); fNewV->setCopyNo(fN->GetNumber()); fNewV->setMCid(id); - fVolMap.insert(pair(id, fNewV)); + fVolMap.emplace(id, fNewV); } } else { - FairVolume* fNewV = new FairVolume(fv->GetName(), id); + auto fNewV = new FairVolume(fv->GetName(), id); fNewV->setModId(fv->getModId()); fNewV->SetModule(fv->GetModule()); fNewV->setCopyNo(1); fNewV->setMCid(id); - fVolMap.insert(pair(id, fNewV)); + fVolMap.emplace(id, fNewV); } } else { - fVolMap.insert(pair(id, fv)); + fVolMap.emplace(id, fv); } } // end off loop Fill sensitive volumes @@ -1030,6 +930,43 @@ void FairMCApplication::InitGeometry() fState = FairMCApplicationState::kUnknownState; } +//_____________________________________________________________________________ +void FairMCApplication::RegisterOutput() +{ + // Register stack + if (fEvGen && fStack && fRootManager) { + fStack->Register(); + } else { + LOG(warn) << "Stack is not registered "; + } + + /** SetSpecialPhysicsCuts for FairDetector objects and all passive modules inheriting from FairModule */ + // initialize and register FairDetector objects in addition + // Note: listActiveDetectors or fActiveDetectors not used to include passive modules in the same loop. + for (auto module : fListModules) { + auto detector = dynamic_cast(module); + if (module) { + module->SetSpecialPhysicsCuts(); + } + if (detector) { + // check whether detector is active + if (detector->IsActive()) { + detector->Initialize(); + detector->Register(); + } + } + } + + fMCEventHeader = fRun->GetMCEventHeader(); + + if (fEvGen) { + fEvGen->SetEvent(fMCEventHeader); + } + if (fRootManager) { + fMCEventHeader->Register(); + } +} + //_____________________________________________________________________________ void FairMCApplication::GeneratePrimaries() { @@ -1039,7 +976,7 @@ void FairMCApplication::GeneratePrimaries() if (fEvGen) { // LOG(debug) << "FairMCApplication::GeneratePrimaries()"; - if (!fEvGen->GenerateEvent(fStack)) { + if (!fEvGen->GenerateEvent(fStack.get())) { StopRun(); } } @@ -1232,10 +1169,16 @@ void FairMCApplication::AddDecayModes() } //_____________________________________________________________________________ -FairPrimaryGenerator* FairMCApplication::GetGenerator() { return fEvGen; } +FairPrimaryGenerator* FairMCApplication::GetGenerator() +{ + return fEvGen; +} //_____________________________________________________________________________ -void FairMCApplication::SetGenerator(FairPrimaryGenerator* pGen) { fEvGen = pGen; } +void FairMCApplication::SetGenerator(FairPrimaryGenerator* pGen) +{ + fEvGen = pGen; +} //_____________________________________________________________________________ void FairMCApplication::AddTask(TTask* fTask) @@ -1249,10 +1192,16 @@ void FairMCApplication::AddTask(TTask* fTask) } //_____________________________________________________________________________ -FairGenericStack* FairMCApplication::GetStack() { return fStack; } +FairGenericStack* FairMCApplication::GetStack() +{ + return fStack.get(); +} //_____________________________________________________________________________ -TTask* FairMCApplication::GetListOfTasks() { return fFairTaskList; } +TTask* FairMCApplication::GetListOfTasks() +{ + return fFairTaskList; +} //_____________________________________________________________________________ void FairMCApplication::SetParTask() @@ -1261,13 +1210,13 @@ void FairMCApplication::SetParTask() if (fRun->GetNTasks() >= 1) { fFairTaskList->SetParTask(); } - fModIter->Reset(); - FairModule* Mod = nullptr; - while ((Mod = dynamic_cast(fModIter->Next()))) { - Mod->SetParContainers(); + for (auto module : fListModules) { + module->SetParContainers(); } FairRuntimeDb* fRTdb = fRun->GetRuntimeDb(); - fRTdb->initContainers(fRun->GetRunId()); + if (!fRTdb->initContainers(fRun->GetRunId())) { + LOG(error) << "FairMCApplication::SetParTask: rtdb->initContainers failed"; + } } //_____________________________________________________________________________ void FairMCApplication::InitTasks() @@ -1295,7 +1244,7 @@ void FairMCApplication::SetRadiationLengthReg(Bool_t RadLen) { fRadLength = RadLen; if (fRadLength) { - fRadLenMan = new FairRadLenManager(); + fRadLenMan = std::make_unique(); } } @@ -1304,7 +1253,7 @@ void FairMCApplication::SetRadiationMapReg(Bool_t RadMap) { fRadMap = RadMap; if (fRadMap) { - fRadMapMan = new FairRadMapManager(); + fRadMapMan = std::make_unique(); } } @@ -1359,4 +1308,19 @@ void FairMCApplication::UndoGeometryModifications() gGeoManager->ClearPhysicalNodes(kFALSE); } -ClassImp(FairMCApplication); +void FairMCApplication::ls(Option_t* option) const +{ + TVirtualMCApplication::ls(option); + TROOT::IncreaseDirLevel(); + if (fMC) { + fMC->ls(option); + } + if (fStack) { + fStack->ls(option); + } + // fTrajFilter->ls(option); + // fRadLenMan->ls(option); + // fRadMapMan->ls(option); + // fRadGridMan->ls(option); + TROOT::DecreaseDirLevel(); +} diff --git a/base/sim/FairMCApplication.h b/fairroot/base/sim/FairMCApplication.h similarity index 90% rename from base/sim/FairMCApplication.h rename to fairroot/base/sim/FairMCApplication.h index 34d6b1db68..fec407eb5f 100644 --- a/base/sim/FairMCApplication.h +++ b/fairroot/base/sim/FairMCApplication.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,16 +18,20 @@ #include // for Int_t, Bool_t, Double_t, etc #include // for TLorentzVector +#include // #include // for TString +#include // for TVirtualMC #include // for TVirtualMCApplication #include // for list #include // for map, multimap, etc #include // for std::unique_ptr +#include // for std::vector class FairDetector; class FairEventHeader; class FairField; class FairGenericStack; +class FairModule; class FairMCEventHeader; class FairPrimaryGenerator; class FairRadLenManager; @@ -38,21 +42,22 @@ class FairTrajFilter; class FairVolume; class FairRunSim; class TChain; -class TIterator; -class TObjArray; -class TRefArray; class TTask; -class TVirtualMC; -enum class FairMCApplicationState { kUnknownState, kConstructGeometry, kInitGeometry }; +enum class FairMCApplicationState +{ + kUnknownState, + kConstructGeometry, + kInitGeometry +}; /** * The Main Application ( Interface to MonteCarlo application ) + * \ingroup base_sim fairroot_singleton * @author M. Al-Turany, D. Bertini * @version 0.1 * @since 12.01.04 */ - class FairMCApplication : public TVirtualMCApplication { public: @@ -75,8 +80,7 @@ class FairMCApplication : public TVirtualMCApplication /** default destructor */ ~FairMCApplication() override; - /** Singelton instance - */ + static FairMCApplication* Instance(); virtual void AddDecayModes(); /** Add user defined particles (optional) */ @@ -224,12 +228,25 @@ class FairMCApplication : public TVirtualMCApplication */ auto GetRadGridMan() { return fRadGridMan.get(); } + /** + * Return the MT state of TVirtualMC + */ + auto GetIsMT() { return fMC ? fMC->IsMT() : false; } + + void ls(Option_t* option = "") const override; + private: // methods Int_t GetIonPdg(Int_t z, Int_t a) const; + /** Register output */ + void RegisterOutput(); + void UndoGeometryModifications(); + /** Simulation Stack */ + std::unique_ptr fStack; //! + protected: // data members /** @@ -241,27 +258,17 @@ class FairMCApplication : public TVirtualMCApplication */ const FairMCApplication* fParent{nullptr}; //! /**List of active detector */ - TRefArray* fActiveDetectors; + TRefArray fActiveDetectors; /**List of FairTask*/ FairTask* fFairTaskList; //! - /**detector list (Passive and Active)*/ - TRefArray* fDetectors; - /**Iterator for Module list*/ - TIterator* fModIter; //! /**Module list in simulation*/ TObjArray* fModules; - /**Number of sensetive volumes in simulation session*/ - Int_t fNoSenVolumes; //! /**flag for using Pythia as external decayer */ Bool_t fPythiaDecayer; /** Pythia decay config macro*/ TString fPythiaDecayerConfig; //! - /** Simulation Stack */ - FairGenericStack* fStack; //! /**Pointer to thr I/O Manager */ FairRootManager* fRootManager; //! - /**List of sensetive volumes in all detectors*/ - TRefArray* fSenVolumes; //! /**Magnetic Field Pointer*/ FairField* fxField; // /**Primary generator*/ @@ -269,9 +276,9 @@ class FairMCApplication : public TVirtualMCApplication /**MC Engine 1= Geant3, 2 = Geant4*/ Int_t fMcVersion; // mc Version /** Track visualization manager */ - FairTrajFilter* fTrajFilter; //! + std::unique_ptr fTrajFilter; //! /**Flag for accepted tracks for visualization*/ - Bool_t fTrajAccepted; //! + bool fTrajAccepted{false}; //! /**Flag for using user decay*/ Bool_t fUserDecay; /**User decay config macro*/ @@ -285,14 +292,14 @@ class FairMCApplication : public TVirtualMCApplication std::map fModVolMap; //! TLorentzVector fTrkPos; //! /** Flag for Radiation length register mode */ - Bool_t fRadLength; //! + bool fRadLength{false}; //! /**Radiation length Manager*/ - FairRadLenManager* fRadLenMan; //! + std::unique_ptr fRadLenMan; //! /** Flag for Radiation map register mode */ - Bool_t fRadMap; //! + bool fRadMap{false}; //! /**Radiation Map Manager*/ - FairRadMapManager* fRadMapMan; //! + std::unique_ptr fRadMapMan; //! /**Radiation map Grid Manager*/ std::unique_ptr fRadGridMan{}; //! @@ -324,6 +331,16 @@ class FairMCApplication : public TVirtualMCApplication FairRunInfo fRunInfo; //! Bool_t fGeometryIsInitialized; + /** + * List of modules, mirrors fModules + */ + std::vector fListModules{}; //! + + /** + * Owned Modules (inside the worker) + */ + std::vector> fOwnedModules; //! + /** * Clean up the FairRunSim created in CloneForWorker */ diff --git a/base/sim/FairModule.cxx b/fairroot/base/sim/FairModule.cxx similarity index 90% rename from base/sim/FairModule.cxx rename to fairroot/base/sim/FairModule.cxx index 57207c0e9e..0d15912d5e 100644 --- a/base/sim/FairModule.cxx +++ b/fairroot/base/sim/FairModule.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,6 +10,7 @@ // ----- Created 06/01/04 by M. Al-Turany ----- // ------------------------------------------------------------------------- /* Generated by Together */ + #include "FairModule.h" #include "FairGeoBuilder.h" // for FairGeoBuilder @@ -30,33 +31,23 @@ #include // for TFile #include // for TGeoManager, gGeoManager #include // for TGeoMaterial -#include // for TGeoMatrix, TGeoHMatrix #include // for TGeoMedium -#include // for TGeoNode -#include // for TGeoVolume #include // for TGeoVoxelFinder #include // for TKey -#include // for TList, TListIter #include // for TObjArray #include // for TObject -#include // for TRefArray #include // for TSystem, gSystem -#include #ifdef ROOT_HAS_GDML #include #endif +#include // for getenv +#include // for strcmp, strlen #include -#include // for getenv -#include // for strcmp, strlen - -class FairGeoMedium; +#include -thread_local TArrayI* FairModule::volNumber = 0; -thread_local Int_t FairModule::fNbOfVolumes = 0; -thread_local FairVolumeList* FairModule::vList = 0; -thread_local TRefArray* FairModule::svList = 0; +thread_local std::vector FairModule::fAllSensitiveVolumes; void FairModule::ConstructGeometry() { @@ -74,20 +65,8 @@ FairModule::~FairModule() {} FairModule::FairModule(const char* Name, const char* title, Bool_t Active) : TNamed(Name, title) - , fMotherVolumeName("") - , fgeoVer("Not defined") - , fgeoName("Not defined") - , fModId(-1) , fActive(Active) - , fNbOfSensitiveVol(0) - , fVerboseLevel(0) - , flGeoPar(nullptr) - , fGeoSaved(kFALSE) - , fMC(nullptr) { - if (!svList) { - svList = new TRefArray(); - } if (!vList) { vList = new FairVolumeList(); } @@ -102,22 +81,10 @@ FairModule::FairModule(const FairModule& rhs) , fActive(rhs.fActive) , fNbOfSensitiveVol(rhs.fNbOfSensitiveVol) , fVerboseLevel(rhs.fVerboseLevel) - , flGeoPar(nullptr) , fGeoSaved(rhs.fGeoSaved) - , fMC(nullptr) { - if (!svList) { - svList = new TRefArray(); - for (Int_t i = 0; i < rhs.svList->GetEntries(); i++) { - svList->Add(rhs.svList->At(i)); - } - } - if (!vList) { vList = new FairVolumeList(); - for (Int_t i = 0; i < rhs.vList->getEntries(); i++) { - vList->addVolume(rhs.vList->At(i)); - } } // Initialize cached pointer to MC (on worker) @@ -135,16 +102,6 @@ FairModule::FairModule(const FairModule& rhs) FairModule::FairModule() : TNamed() - , fMotherVolumeName("") - , fgeoVer("Not defined") - , fgeoName("Not defined") - , fModId(-1) - , fActive(kFALSE) - , fNbOfSensitiveVol(0) - , fVerboseLevel(0) - , flGeoPar(nullptr) - , fGeoSaved(kFALSE) - , fMC(nullptr) {} FairModule& FairModule::operator=(const FairModule& rhs) @@ -199,7 +156,6 @@ void FairModule::Streamer(TBuffer& b) void FairModule::SetGeometryFileName(TString fname, TString) { - // If absolute path is given as argument, try to find it there. // If the file don't exist break. Don't look anywhere else. if (fname.BeginsWith("/")) { @@ -239,7 +195,6 @@ void FairModule::SetGeometryFileName(TString fname, TString) // File not found LOG(fatal) << fName << ": geometry file " << fname << " not found in standard path "; fgeoName = ""; - return; } void FairModule::ProcessNodes(TList* aList) @@ -251,9 +206,6 @@ void FairModule::ProcessNodes(TList* aList) from ConstructGeometry() of your detector class. Aborting..."; } - if (!svList) { - svList = new TRefArray(); - } if (!vList) { vList = new FairVolumeList(); } @@ -284,7 +236,7 @@ void FairModule::ProcessNodes(TList* aList) if (node->isSensitive() && fActive) { volume->setModId(fModId); volume->SetModule(this); - svList->Add(volume); + fAllSensitiveVolumes.push_back(volume); aVol = dynamic_cast(node); fNodes->AddLast(aVol); fNbOfSensitiveVol++; @@ -294,7 +246,6 @@ void FairModule::ProcessNodes(TList* aList) void FairModule::AddSensitiveVolume(TGeoVolume* v) { - LOG(debug2) << "AddSensitiveVolume " << v->GetName(); // Only register volumes which are not already registered @@ -305,7 +256,7 @@ void FairModule::AddSensitiveVolume(TGeoVolume* v) vList->addVolume(volume); volume->setModId(fModId); volume->SetModule(this); - svList->Add(volume); + fAllSensitiveVolumes.push_back(volume); fNbOfSensitiveVol++; } } @@ -319,7 +270,6 @@ FairVolume* FairModule::getFairVolume(FairGeoNode* fN) if ((fv->getGeoNode()) == fN) { fvol = fv; return fvol; - break; } } return fvol; @@ -337,9 +287,8 @@ void FairModule::ConstructRootGeometry(TGeoMatrix* shiftM) */ TGeoManager* OldGeo = gGeoManager; TGeoManager* NewGeo = 0; - TGeoVolume* volume = 0; - ; - TFile* f = TFile::Open(GetGeometryFileName().Data()); + + std::unique_ptr f{TFile::Open(GetGeometryFileName().Data())}; TList* l = f->GetListOfKeys(); TKey* key; TIter next(l); @@ -349,11 +298,11 @@ void FairModule::ConstructRootGeometry(TGeoMatrix* shiftM) /**loop inside the delivered root file and try to fine a TGeoManager object * the first TGeoManager found will be read */ - if (strcmp(key->GetClassName(), "TGeoManager") != 0) { + NewGeo = key->ReadObject(); + if (!NewGeo) { continue; } gGeoManager = 0; - NewGeo = static_cast(key->ReadObj()); break; } if (NewGeo != 0) { @@ -361,7 +310,7 @@ void FairModule::ConstructRootGeometry(TGeoMatrix* shiftM) */ NewGeo->cd(); - volume = static_cast(NewGeo->GetNode(0)->GetDaughter(0)->GetVolume()); + TGeoVolume* volume = NewGeo->GetNode(0)->GetDaughter(0)->GetVolume(); v1 = volume->MakeCopyVolume(volume->GetShape()); // n=NewGeo->GetTopNode(); n = v1->GetNode(0); @@ -374,8 +323,8 @@ void FairModule::ConstructRootGeometry(TGeoMatrix* shiftM) */ key = static_cast(l->At(0)); // Get the first key in the list - volume = dynamic_cast(key->ReadObj()); - if (volume != 0) { + auto volume = key->ReadObject(); + if (volume) { n = volume->GetNode(0); } if (n != 0) { @@ -406,9 +355,6 @@ void FairModule::ConstructRootGeometry(TGeoMatrix* shiftM) voxels->SetNeedRebuild(); } - // else { fLogger->Fatal(MESSAGE_ORIGIN, "\033[5m\033[31mFairModule::ConstructRootGeometry(): could not find - // voxels \033[0m"); } - /**To avoid having different names of the default matrices * because we could have get the volume from another * TGeoManager, we reset the default matrix name @@ -454,7 +400,6 @@ void FairModule::ConstructRootGeometry(TGeoMatrix* shiftM) */ ExpandNode(n); delete NewGeo; - delete f; } else { LOG(fatal) << "Could not find the given mother volume " << fMotherVolumeName.Data() << " where the geomanger should be added."; @@ -713,5 +658,3 @@ FairModule* FairModule::CloneModule() const Fatal("CloneModule", "Has to be overriden in multi-threading applications."); return 0; } - -ClassImp(FairModule); diff --git a/base/sim/FairModule.h b/fairroot/base/sim/FairModule.h similarity index 89% rename from base/sim/FairModule.h rename to fairroot/base/sim/FairModule.h index 409d2340d2..7ca7b11ea4 100644 --- a/base/sim/FairModule.h +++ b/fairroot/base/sim/FairModule.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,21 +16,20 @@ #include "FairRun.h" // for FairRun #include "FairRuntimeDb.h" // for FairRuntimeDb -#include // for Bool_t, Int_t, etc +#include +#include +#include #include // for TList (ptr only), TListIter #include // for TNamed #include // for TObjArray +#include // for TRefArray #include // for TString, operator!= -#include // for string +#include +#include +#include class FairVolumeList; class FairVolume; -class TArrayI; -class TGeoMatrix; -class TGeoNode; -class TGeoVolume; -class TRefArray; -class TVirtualMC; /** * Base class for constructing all detecors and passive volumes @@ -137,15 +136,17 @@ class FairModule : public TNamed TList* GetListOfGeoPar() { return flGeoPar; } /**list of volumes in a simulation session*/ - static thread_local FairVolumeList* vList; //! + static thread_local inline FairVolumeList* vList{nullptr}; //! /**total number of volumes in a simulaion session*/ - static thread_local Int_t fNbOfVolumes; //! + static thread_local inline Int_t fNbOfVolumes{0}; //! /**list of all sensitive volumes in a simulaion session*/ - static thread_local TRefArray* svList; //! + static thread_local std::vector fAllSensitiveVolumes; //! - static thread_local TArrayI* volNumber; //! - TString fMotherVolumeName; //! - FairVolume* getFairVolume(FairGeoNode* fNode); + TString fMotherVolumeName{""}; //! + /** + * \deprecated Not used anywhere, will be removed in a future release + */ + [[deprecated]] FairVolume* getFairVolume(FairGeoNode* fNode); void AddSensitiveVolume(TGeoVolume* v); private: @@ -160,15 +161,15 @@ class FairModule : public TNamed protected: FairModule(const FairModule&); FairModule& operator=(const FairModule&); - TString fgeoVer; - TString fgeoName; - Int_t fModId; - Bool_t fActive; - Int_t fNbOfSensitiveVol; //! - Int_t fVerboseLevel; - TList* flGeoPar; //! list of Detector Geometry parameters - Bool_t fGeoSaved; //! flag for initialisation - TVirtualMC* fMC; //! cahed pointer to MC (available only after initialization) + TString fgeoVer{"Not defined"}; + TString fgeoName{"Not defined"}; + Int_t fModId{-1}; + Bool_t fActive{kFALSE}; + Int_t fNbOfSensitiveVol{0}; //! + Int_t fVerboseLevel{0}; + TList* flGeoPar{nullptr}; //! list of Detector Geometry parameters + Bool_t fGeoSaved{kFALSE}; //! flag for initialisation + TVirtualMC* fMC{nullptr}; //! cahed pointer to MC (available only after initialization) ClassDefOverride(FairModule, 4); }; diff --git a/base/sim/FairParticle.cxx b/fairroot/base/sim/FairParticle.cxx similarity index 98% rename from base/sim/FairParticle.cxx rename to fairroot/base/sim/FairParticle.cxx index 9df85a22b0..33876f2fb7 100644 --- a/base/sim/FairParticle.cxx +++ b/fairroot/base/sim/FairParticle.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,8 +23,6 @@ using std::cout; using std::endl; -ClassImp(FairParticle); - FairParticle::FairParticle(Int_t id, TParticle* particle) : TObject() , fpdg(id) diff --git a/base/sim/FairParticle.h b/fairroot/base/sim/FairParticle.h similarity index 100% rename from base/sim/FairParticle.h rename to fairroot/base/sim/FairParticle.h diff --git a/base/sim/FairPrimaryGenerator.cxx b/fairroot/base/sim/FairPrimaryGenerator.cxx similarity index 97% rename from base/sim/FairPrimaryGenerator.cxx rename to fairroot/base/sim/FairPrimaryGenerator.cxx index eee4cc8d46..2b18e2fce4 100644 --- a/base/sim/FairPrimaryGenerator.cxx +++ b/fairroot/base/sim/FairPrimaryGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,6 +18,7 @@ #include // for Sqrt #include // for TObject #include // for TParticlePDG +#include // #include // for TRandom, gRandom #include // for operator<<, basic_ostream, etc @@ -63,6 +64,7 @@ FairPrimaryGenerator::FairPrimaryGenerator() , fEventNr(0) { fTargetZ[0] = 0.; + fGenList->SetName("fGenList"); } FairPrimaryGenerator::FairPrimaryGenerator(const char *name, const char *title) @@ -101,6 +103,7 @@ FairPrimaryGenerator::FairPrimaryGenerator(const char *name, const char *title) , fEventNr(0) { fTargetZ[0] = 0.; + fGenList->SetName("fGenList"); } FairPrimaryGenerator::FairPrimaryGenerator(const FairPrimaryGenerator &rhs) @@ -139,6 +142,7 @@ FairPrimaryGenerator::FairPrimaryGenerator(const FairPrimaryGenerator &rhs) , fEventNr(rhs.fEventNr) { fTargetZ[0] = rhs.fTargetZ[0]; + fGenList->SetName("fGenList"); } Bool_t FairPrimaryGenerator::Init() @@ -550,4 +554,10 @@ void FairPrimaryGenerator::SmearGausVertexXY(Bool_t flag) } } -ClassImp(FairPrimaryGenerator); +void FairPrimaryGenerator::ls(Option_t* option) const +{ + TNamed::ls(option); + TROOT::IncreaseDirLevel(); + fGenList->ls(); + TROOT::DecreaseDirLevel(); +} diff --git a/base/sim/FairPrimaryGenerator.h b/fairroot/base/sim/FairPrimaryGenerator.h similarity index 96% rename from base/sim/FairPrimaryGenerator.h rename to fairroot/base/sim/FairPrimaryGenerator.h index d4b6cbca12..dc9c67ac6b 100644 --- a/base/sim/FairPrimaryGenerator.h +++ b/fairroot/base/sim/FairPrimaryGenerator.h @@ -1,9 +1,9 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * + * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * + * copied verbatim in the file "LICENSE" * ********************************************************************************/ /** FairPrimaryGenerator.h @@ -47,7 +47,7 @@ class FairPrimaryGenerator : public TNamed FairPrimaryGenerator(const char *name, const char *title = "FAIR Generator"); /** Destructor. **/ - virtual ~FairPrimaryGenerator(); + ~FairPrimaryGenerator() override; /** Initialize the generater (if needed!)*/ virtual Bool_t Init(); @@ -158,6 +158,8 @@ class FairPrimaryGenerator : public TNamed Int_t GetTotPrimary() { return fTotPrim; } + void ls(Option_t* option = "") const override; + protected: /** Copy constructor */ FairPrimaryGenerator(const FairPrimaryGenerator &); @@ -270,7 +272,7 @@ class FairPrimaryGenerator : public TNamed **/ void MakeEventPlane(); - ClassDef(FairPrimaryGenerator, 5); + ClassDefOverride(FairPrimaryGenerator, 5); }; #endif diff --git a/base/sim/FairRunIdGenerator.cxx b/fairroot/base/sim/FairRunIdGenerator.cxx similarity index 99% rename from base/sim/FairRunIdGenerator.cxx rename to fairroot/base/sim/FairRunIdGenerator.cxx index 67114c4760..1308c32e54 100644 --- a/base/sim/FairRunIdGenerator.cxx +++ b/fairroot/base/sim/FairRunIdGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -109,7 +109,6 @@ void FairRunIdGenerator::get_random_bytes(void* buf, int nbytes) for (i = 0; i < nbytes; i++) { *cp++ = rand() & 0xFF; } - return; } /* diff --git a/base/sim/FairRunIdGenerator.h b/fairroot/base/sim/FairRunIdGenerator.h similarity index 93% rename from base/sim/FairRunIdGenerator.h rename to fairroot/base/sim/FairRunIdGenerator.h index a282952ed8..0f9803b328 100644 --- a/base/sim/FairRunIdGenerator.h +++ b/fairroot/base/sim/FairRunIdGenerator.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -48,7 +48,7 @@ class FairRunIdGenerator FairRunIdGenerator() : fTimeSpec() {} - ~FairRunIdGenerator() {} + ~FairRunIdGenerator() = default; unsigned int generateId(void); }; diff --git a/base/sim/FairVolume.cxx b/fairroot/base/sim/FairVolume.cxx similarity index 92% rename from base/sim/FairVolume.cxx rename to fairroot/base/sim/FairVolume.cxx index 119ff14058..0ad01428d3 100644 --- a/base/sim/FairVolume.cxx +++ b/fairroot/base/sim/FairVolume.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,5 +33,3 @@ void FairVolume::SetModule(FairModule* mod) fModule = mod; fDetector = dynamic_cast(mod); } - -ClassImp(FairVolume); diff --git a/base/sim/FairVolume.h b/fairroot/base/sim/FairVolume.h similarity index 100% rename from base/sim/FairVolume.h rename to fairroot/base/sim/FairVolume.h diff --git a/base/sim/FairVolumeList.cxx b/fairroot/base/sim/FairVolumeList.cxx similarity index 89% rename from base/sim/FairVolumeList.cxx rename to fairroot/base/sim/FairVolumeList.cxx index 3a481331d2..a2158cfcab 100644 --- a/base/sim/FairVolumeList.cxx +++ b/fairroot/base/sim/FairVolumeList.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -58,7 +58,7 @@ FairVolume* FairVolumeList::findObject(TString name) obj = static_cast(fData->At(i)); if (obj) { if (obj->GetName() == name) { - return static_cast(obj); + return obj; } } } @@ -68,7 +68,7 @@ FairVolume* FairVolumeList::findObject(TString name) void FairVolumeList::addVolume(FairVolume* elem) { - FairVolume* v = static_cast(findObject(elem->GetName())); + FairVolume* v = findObject(elem->GetName()); if (v) { LOG(error) << "FairVolumeList element: " << elem->GetName() << " VolId : " << elem->getVolumeId() @@ -77,5 +77,3 @@ void FairVolumeList::addVolume(FairVolume* elem) fData->Add(elem); } } - -ClassImp(FairVolumeList); diff --git a/base/sim/FairVolumeList.h b/fairroot/base/sim/FairVolumeList.h similarity index 89% rename from base/sim/FairVolumeList.h rename to fairroot/base/sim/FairVolumeList.h index 342c04865b..ebca2ea32c 100644 --- a/base/sim/FairVolumeList.h +++ b/fairroot/base/sim/FairVolumeList.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,8 +15,6 @@ #include // for TObject #include // for TString -// class FairVolume; - /** * This Object is only used for internal book keeping! * @author M. Al-Turany, D. Bertini @@ -33,7 +31,7 @@ class FairVolumeList : public TObject public: FairVolumeList(); - virtual ~FairVolumeList(); + ~FairVolumeList() override; FairVolume* getVolume(TString* name); Int_t getVolumeId(TString* name); @@ -44,7 +42,7 @@ class FairVolumeList : public TObject Int_t getEntries() { return fData->GetEntries(); } FairVolume* At(Int_t pos) { return (dynamic_cast(fData->At(pos))); } - ClassDef(FairVolumeList, 1); + ClassDefOverride(FairVolumeList, 1); }; #endif // FAIR_VOLUMELIST_H diff --git a/base/sim/README.dox b/fairroot/base/sim/README.dox similarity index 100% rename from base/sim/README.dox rename to fairroot/base/sim/README.dox diff --git a/base/sink/FairRootFileSink.cxx b/fairroot/base/sink/FairRootFileSink.cxx similarity index 88% rename from base/sink/FairRootFileSink.cxx rename to fairroot/base/sink/FairRootFileSink.cxx index 05559f36f9..a00472e531 100644 --- a/base/sink/FairRootFileSink.cxx +++ b/fairroot/base/sink/FairRootFileSink.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -15,7 +15,6 @@ #include "FairRootFileSink.h" #include "FairEventHeader.h" -#include "FairLogger.h" #include "FairMonitor.h" // to store histograms at the end #include "FairRootManager.h" // to GetTreeName() @@ -33,18 +32,13 @@ #include #include // free #include // __cxa_demangle -#include // unique_ptr -#include // string +#include +#include FairRootFileSink::FairRootFileSink(TFile* f, const char* Title) : FairSink() , fOutputTitle(Title) , fRootFile(f) - , fOutTree(0) - , fListFolder(new TObjArray(16)) - , fCbmout(0) - , fIsInitialized(kFALSE) - , fFileHeader(0) { if ((!fRootFile) || fRootFile->IsZombie()) { LOG(fatal) << "Error opening the Input file"; @@ -55,14 +49,8 @@ FairRootFileSink::FairRootFileSink(TFile* f, const char* Title) FairRootFileSink::FairRootFileSink(const TString* RootFileName, const char* Title) : FairSink() , fOutputTitle(Title) - , fRootFile(0) - , fOutTree(0) - , fListFolder(new TObjArray(16)) - , fCbmout(0) - , fIsInitialized(kFALSE) - , fFileHeader(0) { - fRootFile = TFile::Open(RootFileName->Data(), "recreate"); + fRootFile.reset(TFile::Open(RootFileName->Data(), "recreate")); if ((!fRootFile) || fRootFile->IsZombie()) { LOG(fatal) << "Error opening the Output file"; } @@ -72,22 +60,14 @@ FairRootFileSink::FairRootFileSink(const TString* RootFileName, const char* Titl FairRootFileSink::FairRootFileSink(const TString RootFileName, const char* Title) : FairSink() , fOutputTitle(Title) - , fRootFile(0) - , fOutTree(0) - , fListFolder(new TObjArray(16)) - , fCbmout(0) - , fIsInitialized(kFALSE) - , fFileHeader(0) { - fRootFile = TFile::Open(RootFileName.Data(), "recreate"); + fRootFile.reset(TFile::Open(RootFileName.Data(), "recreate")); if ((!fRootFile) || fRootFile->IsZombie()) { LOG(fatal) << "Error opening file " << RootFileName; } LOG(debug) << "FairRootFileSink created------------"; } -FairRootFileSink::~FairRootFileSink() {} - TFile* FairRootFileSink::OpenRootFile(TString fileName) { if (fileName.Length() <= 5) @@ -107,8 +87,7 @@ Bool_t FairRootFileSink::InitSink() // FairRun* fRun = FairRun::Instance(); /**Check if a simulation run!*/ - fOutFolder = gROOT->GetRootFolder()->AddFolder( - Form("%s_%d", FairRootManager::GetFolderName(), FairRootManager::Instance()->GetInstanceId()), "Main Folder"); + fOutFolder = gROOT->GetRootFolder()->AddFolder(FairRootManager::GetFolderName(), "Main Folder"); gROOT->GetListOfBrowsables()->Add(fOutFolder); LOG(info) << "FairRootFileSink initialized."; @@ -230,7 +209,7 @@ void FairRootFileSink::Close() void FairRootFileSink::Reset() {} -void FairRootFileSink::FillEventHeader(FairEventHeader* /* feh */) { return; } +void FairRootFileSink::FillEventHeader(FairEventHeader* /* feh */) {} void FairRootFileSink::RegisterImpl(const char* /* name */, const char* folderName, void* obj) { @@ -263,12 +242,12 @@ void FairRootFileSink::WriteFolder() fOutFolder->Write(FairRootManager::GetFolderName()); // FairRun* fRun = FairRun::Instance(); - fOutTree = - new TTree(FairRootManager::GetTreeName(), - Form("/%s_%d", FairRootManager::GetFolderName(), FairRootManager::Instance()->GetInstanceId()), - 99); + fOutTree = new TTree(FairRootManager::GetTreeName(), Form("/%s", FairRootManager::GetFolderName()), 99); TruncateBranchNames(); CreatePersistentBranchesAny(); + + // Delete the folder to make place in the gROOT for fOutFolder created by the Geant4MT threads + gROOT->GetRootFolder()->Remove(fOutFolder); } } @@ -318,7 +297,10 @@ void FairRootFileSink::WriteObject(TObject* f, const char* name, Int_t option) f->Write(name, option); } -void FairRootFileSink::WriteGeometry() { fRootFile->WriteTObject(gGeoManager); } +void FairRootFileSink::WriteGeometry() +{ + fRootFile->WriteTObject(gGeoManager); +} void FairRootFileSink::Fill() { @@ -341,8 +323,10 @@ Int_t FairRootFileSink::Write(const char*, Int_t, Int_t) // fOutTree->Print(); - fRootFile = fOutTree->GetCurrentFile(); - FairMonitor::GetMonitor()->StoreHistograms(fRootFile); + if (fRootFile.get() != fOutTree->GetCurrentFile()) { + fRootFile.reset(fOutTree->GetCurrentFile()); + } + FairMonitor::GetMonitor()->StoreHistograms(fRootFile.get()); LOG(debug) << "FairRootFileSink::Write to file: " << fRootFile->GetName(); fRootFile->WriteTObject(fOutTree); } else { @@ -365,5 +349,3 @@ FairSink* FairRootFileSink::CloneSink() return newSink; } //_____________________________________________________________________________ - -ClassImp(FairRootFileSink); diff --git a/base/sink/FairRootFileSink.h b/fairroot/base/sink/FairRootFileSink.h similarity index 58% rename from base/sink/FairRootFileSink.h rename to fairroot/base/sink/FairRootFileSink.h index 610503e1e3..6fb1d9c3b8 100644 --- a/base/sink/FairRootFileSink.h +++ b/fairroot/base/sink/FairRootFileSink.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -18,17 +18,14 @@ #include "FairSink.h" #include +#include #include #include +#include #include class FairEventHeader; class FairFileHeader; -class TBranch; -class TObjArray; -class TObject; -class TTree; -class TFolder; class FairRootFileSink : public FairSink { @@ -36,66 +33,60 @@ class FairRootFileSink : public FairSink FairRootFileSink(TFile* f, const char* Title = "OutputRootFile"); FairRootFileSink(const TString* RootFileName, const char* Title = "OutputRootFile"); FairRootFileSink(const TString RootFileName, const char* Title = "OutputRootFile"); - // FairRootFileSink(const FairRootFileSink& file); - virtual ~FairRootFileSink(); + FairRootFileSink(const FairRootFileSink&) = delete; + FairRootFileSink operator=(const FairRootFileSink&) = delete; + ~FairRootFileSink() override = default; - virtual Bool_t InitSink(); - virtual void Close(); - virtual void Reset(); + Bool_t InitSink() override; + void Close() override; + void Reset() override; - virtual Sink_Type GetSinkType() { return kFILESINK; } + Sink_Type GetSinkType() override { return kFILESINK; } virtual void FillEventHeader(FairEventHeader* feh); virtual TFile* OpenRootFile(TString fileName = ""); - TFile* GetRootFile() { return fRootFile; } - virtual TString GetFileName() { return (fRootFile ? fRootFile->GetName() : ""); } + TFile* GetRootFile() { return fRootFile.get(); } + TString GetFileName() override { return (fRootFile ? fRootFile->GetName() : ""); } - virtual void SetOutTree(TTree* fTree) { fOutTree = fTree; } + void SetOutTree(TTree* fTree) override { fOutTree = fTree; } TTree* GetOutTree() { return fOutTree; } - virtual void Fill(); + void Fill() override; - virtual Int_t Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0); + Int_t Write(const char* name = nullptr, Int_t option = 0, Int_t bufsize = 0) override; - virtual void RegisterImpl(const char*, const char*, void*); - virtual void RegisterAny(const char* brname, const std::type_info& oi, const std::type_info& pi, void* obj); + void RegisterImpl(const char*, const char*, void*) override; + void RegisterAny(const char* brname, const std::type_info& oi, const std::type_info& pi, void* obj) override; - virtual void WriteFolder(); - virtual bool CreatePersistentBranchesAny(); + void WriteFolder() override; + bool CreatePersistentBranchesAny() override; - virtual void WriteObject(TObject* f, const char*, Int_t option = 0); - virtual void WriteGeometry(); + void WriteObject(TObject* f, const char*, Int_t option = 0) override; + void WriteGeometry() override; - virtual FairSink* CloneSink(); + FairSink* CloneSink() override; private: /** Title of input sink, could be input, background or signal*/ TString fOutputTitle; /** ROOT file */ - TFile* fRootFile; + std::unique_ptr fRootFile; /** Output Tree */ - TTree* fOutTree; - /** list of folders from all input (and friends) files */ - TObjArray* fListFolder; //! - /** folder structure of output */ - TFolder* fCbmout; + TTree* fOutTree{nullptr}; /** Initialization flag, true if initialized */ - Bool_t fIsInitialized; - - FairRootFileSink(const FairRootFileSink&); - FairRootFileSink operator=(const FairRootFileSink&); + Bool_t fIsInitialized{kFALSE}; void TruncateBranchNames(); void TruncateBranchNames(TBranch* b, TString ffn); // bool CreatePersistentBranchesAny(); /**File Header*/ - FairFileHeader* fFileHeader; //! + FairFileHeader* fFileHeader{nullptr}; //! bool fPersistentBranchesDone{false}; //! - ClassDef(FairRootFileSink, 1); + ClassDefOverride(FairRootFileSink, 1); }; #endif /* defined(__FAIRROOT__FairRootFileSink__) */ diff --git a/base/sink/FairSink.cxx b/fairroot/base/sink/FairSink.cxx similarity index 77% rename from base/sink/FairSink.cxx rename to fairroot/base/sink/FairSink.cxx index 5e36b08bab..c07eead4b0 100644 --- a/base/sink/FairSink.cxx +++ b/fairroot/base/sink/FairSink.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -15,7 +15,9 @@ #include "FairSink.h" #include +#include #include +#include FairSink::FairSink() : fRunId(0) @@ -29,4 +31,13 @@ FairSink::FairSink(const FairSink& sink) FairSink::~FairSink() {} -ClassImp(FairSink); +void FairSink::ls(Option_t*) const +{ + TROOT::IndentLevel(); + std::cout << "OBJ: " << IsA()->GetName() << "\n"; + TROOT::IncreaseDirLevel(); + if (fOutFolder) { + fOutFolder->ls(); + } + TROOT::DecreaseDirLevel(); +} diff --git a/base/sink/FairSink.h b/fairroot/base/sink/FairSink.h similarity index 96% rename from base/sink/FairSink.h rename to fairroot/base/sink/FairSink.h index 5367dacf50..4be278b77e 100644 --- a/base/sink/FairSink.h +++ b/fairroot/base/sink/FairSink.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence version 3 (LGPL) version 3, * @@ -66,6 +66,8 @@ class FairSink virtual FairSink* CloneSink() = 0; + virtual void ls(Option_t* option = "") const; + protected: struct TypeAddressPair { diff --git a/base/source/FairFileSource.cxx b/fairroot/base/source/FairFileSource.cxx similarity index 96% rename from base/source/FairFileSource.cxx rename to fairroot/base/source/FairFileSource.cxx index b1ac1d07f1..c2411be931 100644 --- a/base/source/FairFileSource.cxx +++ b/fairroot/base/source/FairFileSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,7 +16,6 @@ #include "FairFileSource.h" #include "FairEventHeader.h" -#include "FairLogger.h" #include "FairMCEventHeader.h" #include "FairRootManager.h" @@ -37,8 +36,9 @@ #include // for find #include // fmod #include // exit -#include // for _List_iterator, list, etc -#include // multimap +#include +#include // for _List_iterator, list, etc +#include // multimap #include #include @@ -46,7 +46,6 @@ FairFileSource::FairFileSource(TFile* f, const char* Title, UInt_t) : FairFileSourceBase() , fInputTitle(Title) , fRootFile(f) - , fCurrentEntryNr(0) , fFriendFileList() , fInputChainList() , fFriendTypeList() @@ -54,7 +53,6 @@ FairFileSource::FairFileSource(TFile* f, const char* Title, UInt_t) , fRunIdInfoAll() , fInChain(0) , fInTree(0) - , fListFolder(new TObjArray(16)) , fCbmout(0) , fCbmroot(0) , fSourceIdentifier(0) @@ -85,7 +83,6 @@ FairFileSource::FairFileSource(const TString* RootFileName, const char* Title, U : FairFileSourceBase() , fInputTitle(Title) , fRootFile(0) - , fCurrentEntryNr(0) , fFriendFileList() , fInputChainList() , fFriendTypeList() @@ -93,7 +90,6 @@ FairFileSource::FairFileSource(const TString* RootFileName, const char* Title, U , fRunIdInfoAll() , fInChain(0) , fInTree(0) - , fListFolder(new TObjArray(16)) , fCbmout(0) , fCbmroot(0) , fSourceIdentifier(0) @@ -125,7 +121,6 @@ FairFileSource::FairFileSource(const TString RootFileName, const char* Title, UI : FairFileSourceBase() , fInputTitle(Title) , fRootFile(0) - , fCurrentEntryNr(0) , fFriendFileList() , fInputChainList() , fFriendTypeList() @@ -133,7 +128,6 @@ FairFileSource::FairFileSource(const TString RootFileName, const char* Title, UI , fRunIdInfoAll() , fInChain(0) , fInTree(0) - , fListFolder(new TObjArray(16)) , fCbmout(0) , fCbmroot(0) , fSourceIdentifier(0) @@ -226,7 +220,7 @@ Bool_t FairFileSource::Init() } gROOT->GetListOfBrowsables()->Add(fCbmroot); - fListFolder->Add(fCbmroot); + fListFolder.Add(fCbmroot); // Store the information about the unique runids in the input file // together with the filename and the number of events for each runid @@ -272,8 +266,8 @@ Bool_t FairFileSource::Init() LOG(debug) << "Entries in this Source " << fNoOfEntries; - for (Int_t i = 0; i < fListFolder->GetEntriesFast(); i++) { - TFolder* fold = static_cast(fListFolder->At(i)); + for (Int_t i = 0; i < fListFolder.GetEntriesFast(); i++) { + TFolder* fold = static_cast(fListFolder.At(i)); fEvtHeader = static_cast(fold->FindObjectAny("EventHeader.")); fMCHeader = static_cast(fold->FindObjectAny("MCEventHeader.")); if (fEvtHeader) { @@ -284,7 +278,7 @@ Bool_t FairFileSource::Init() } } - FairRootManager::Instance()->SetListOfFolders(fListFolder); + FairRootManager::Instance()->SetListOfFolders(&fListFolder); AddFriendsToChain(); @@ -302,7 +296,7 @@ void FairFileSource::SetInTree(TTree* tempTree) { fInTree = nullptr; fInTree = tempTree; - fRootFile = static_cast(tempTree->GetCurrentFile()); + fRootFile = tempTree->GetCurrentFile(); fInChain->Reset(); IsInitialized = kFALSE; Init(); @@ -393,8 +387,8 @@ void FairFileSource::AddFriendsToChain() friendType++; } - TChain* chain = static_cast(fFriendTypeList[inputLevel]); - chain->AddFile(fileName, 1234567890, FairRootManager::GetTreeName()); + TChain* chain = fFriendTypeList[inputLevel]; + chain->AddFile(fileName, TTree::kMaxEntries, FairRootManager::GetTreeName()); } // Check if all friend chains have the same runids and the same @@ -539,7 +533,7 @@ void FairFileSource::CreateNewFriendChain(TString inputFile, TString inputLevel) } folderName1 = folderName1 + "_" + inputLevel; added->SetName(folderName1); - fListFolder->Add(added); + fListFolder.Add(added); /**Get The list of branches from the friend file and add it to the actual list*/ auto list = f->Get("BranchList"); @@ -705,8 +699,8 @@ void FairFileSource::ReadBranchEvent(const char* BrName) fEventTime = GetEventTime(); return; } - return; } + void FairFileSource::ReadBranchEvent(const char* BrName, Int_t Entry) { fCurrentEntryNo = Entry; @@ -720,7 +714,6 @@ void FairFileSource::ReadBranchEvent(const char* BrName, Int_t Entry) fEventTime = GetEventTime(); return; } - return; } void FairFileSource::FillEventHeader(FairEventHeader* feh) @@ -735,7 +728,4 @@ void FairFileSource::FillEventHeader(FairEventHeader* feh) feh->SetMCEntryNumber(fMCHeader->GetEventID()); } feh->SetInputFileId(0); - return; } - -ClassImp(FairFileSource); diff --git a/base/source/FairFileSource.h b/fairroot/base/source/FairFileSource.h similarity index 95% rename from base/source/FairFileSource.h rename to fairroot/base/source/FairFileSource.h index 4d9986ce5e..9ac4853c24 100644 --- a/base/source/FairFileSource.h +++ b/fairroot/base/source/FairFileSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,6 @@ class FairEventHeader; class FairFileHeader; class FairMCEventHeader; -class TTree; class FairFileSource : public FairFileSourceBase { @@ -73,7 +73,6 @@ class FairFileSource : public FairFileSourceBase } } void SetInTree(TTree* tempTree); - TObjArray* GetListOfFolders() { return fListFolder; } TFolder* GetBranchDescriptionFolder() { return fCbmroot; } UInt_t GetEntries() { return fNoOfEntries; } @@ -115,8 +114,6 @@ class FairFileSource : public FairFileSourceBase TString fInputTitle; /**ROOT file*/ TFile* fRootFile; - /** Current Entry number */ - Int_t fCurrentEntryNr; //! /** List of all files added with AddFriend */ std::list fFriendFileList; //! std::list fInputChainList; //! @@ -127,8 +124,6 @@ class FairFileSource : public FairFileSourceBase TChain* fInChain; /**Input Tree */ TTree* fInTree; - /** list of folders from all input (and friends) files*/ - TObjArray* fListFolder; //! /**folder structure of output*/ TFolder* fCbmout; /**folder structure of input*/ diff --git a/base/source/FairFileSourceBase.cxx b/fairroot/base/source/FairFileSourceBase.cxx similarity index 54% rename from base/source/FairFileSourceBase.cxx rename to fairroot/base/source/FairFileSourceBase.cxx index c19c1625b3..ad79c2ed9a 100644 --- a/base/source/FairFileSourceBase.cxx +++ b/fairroot/base/source/FairFileSourceBase.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,15 +8,18 @@ #include "FairFileSourceBase.h" +#include "FairRootManager.h" + +#include #include -#include // for std::for_each +#include +#include #include -using std::set; - -ClassImp(FairFileSourceBase); - -FairFileSourceBase::~FairFileSourceBase() {} +FairFileSourceBase::~FairFileSourceBase() +{ + FairRootManager::Instance()->SetListOfFolders(nullptr); +} Bool_t FairFileSourceBase::CompareBranchList(TFile* fileHandle, TString inputLevel) { @@ -37,13 +40,13 @@ Bool_t FairFileSourceBase::CompareBranchList(TFile* fileHandle, TString inputLev // If a branch with the same name is found, this branch is removed from // the list. If in the end no branch is left in the list everything is // fine. - set::iterator iter1; - auto list = fileHandle->Get("BranchList"); + std::unique_ptr list{fileHandle->Get("BranchList")}; if (list) { - TObjString* Obj = 0; - for (Int_t i = 0; i < list->GetEntries(); i++) { - Obj = dynamic_cast(list->At(i)); - iter1 = branches.find(Obj->GetString().Data()); + for (auto Obj : TRangeDynCast(list.get())) { + if (!Obj) { + continue; + } + auto iter1 = branches.find(Obj->GetString()); if (iter1 != branches.end()) { branches.erase(iter1); } else { @@ -57,12 +60,49 @@ Bool_t FairFileSourceBase::CompareBranchList(TFile* fileHandle, TString inputLev // If the size of branches is !=0 after removing all branches also in the // reference list, this is also a sign that both branch list are not the // same - if (branches.size() != 0) { + if (!branches.empty()) { LOG(info) << "Compare Branch List will return kFALSE. The list has " << branches.size() << " branches:"; - for (auto branchName : branches) + for (auto const& branchName : branches) { LOG(info) << " -> " << branchName; + } return kFALSE; } return kTRUE; } + +bool FairFileSourceBase::ActivateObjectAnyImpl(TTree* source, + void** obj, + const std::type_info& info, + const char* brname) +{ + if (!source) { + return false; + } + // we check if the types match at all + auto br = source->GetBranch(brname); + if (!br) { + // branch not found in source + return false; + } + + // look up the TClass and resulting typeid stored in this branch + auto cl = TClass::GetClass(br->GetClassName()); + if (!cl) { + // class not found + return false; + } + + auto storedtype = cl->GetTypeInfo(); + + // check consistency of types + if (info != *storedtype) { + LOG(info) << "Trying to read from branch " << brname << " with wrong type " << info.name() + << " (expected: " << storedtype->name() << ")\n"; + return false; + } + source->SetBranchStatus(brname, true); + // force to use the (void*) interface which is non-checking + source->SetBranchAddress(brname, (void*)obj); + return true; +} diff --git a/base/source/FairFileSourceBase.h b/fairroot/base/source/FairFileSourceBase.h similarity index 73% rename from base/source/FairFileSourceBase.h rename to fairroot/base/source/FairFileSourceBase.h index 6f819c7dcd..52fe2f176b 100644 --- a/base/source/FairFileSourceBase.h +++ b/fairroot/base/source/FairFileSourceBase.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,6 +12,8 @@ #include "FairSource.h" #include +#include +#include #include #include @@ -20,6 +22,9 @@ */ class FairFileSourceBase : public FairSource { + friend class FairFileSource; + friend class FairMixedSource; + public: ~FairFileSourceBase() override; void Reset() override {} @@ -28,6 +33,7 @@ class FairFileSourceBase : public FairSource Bool_t InitUnpackers() override { return kTRUE; } Bool_t ReInitUnpackers() override { return kTRUE; } + TObjArray* GetListOfFolders() { return &fListFolder; } Bool_t CompareBranchList(TFile* fileHandle, TString inputLevel); protected: @@ -36,6 +42,12 @@ class FairFileSourceBase : public FairSource std::map> fCheckInputBranches{}; //! + static bool ActivateObjectAnyImpl(TTree* source, void** obj, const std::type_info& info, const char* brname); + + private: + /** list of folders from all input (and friends) files*/ + TObjArray fListFolder{16}; //! + ClassDefOverride(FairFileSourceBase, 0); }; diff --git a/base/source/FairMixedSource.cxx b/fairroot/base/source/FairMixedSource.cxx similarity index 98% rename from base/source/FairMixedSource.cxx rename to fairroot/base/source/FairMixedSource.cxx index 9e75916b57..99e8a00e15 100644 --- a/base/source/FairMixedSource.cxx +++ b/fairroot/base/source/FairMixedSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,7 +16,6 @@ #include "FairMixedSource.h" #include "FairEventHeader.h" -#include "FairLogger.h" #include "FairMCEventHeader.h" #include "FairRootManager.h" @@ -30,6 +29,7 @@ #include // for TRandom, gRandom #include #include // floor, fmod +#include FairMixedSource::FairMixedSource(TFile* f, const char* Title, UInt_t) : FairFileSourceBase() @@ -41,7 +41,6 @@ FairMixedSource::FairMixedSource(TFile* f, const char* Title, UInt_t) , fFriendTypeList() , fInputLevel() , fRunIdInfoAll() - , fListFolder(new TObjArray(16)) , fCbmout(0) , fCbmroot(0) , fSourceIdentifier(0) @@ -93,7 +92,6 @@ FairMixedSource::FairMixedSource(const TString* RootFileName, const char* Title, , fFriendTypeList() , fInputLevel() , fRunIdInfoAll() - , fListFolder(new TObjArray(16)) , fCbmout(0) , fCbmroot(0) , fSourceIdentifier(0) @@ -145,7 +143,6 @@ FairMixedSource::FairMixedSource(const TString RootFileName, const Int_t signalI , fFriendTypeList() , fInputLevel() , fRunIdInfoAll() - , fListFolder(new TObjArray(16)) , fCbmout(0) , fCbmroot(0) , fSourceIdentifier(0) @@ -268,7 +265,7 @@ Bool_t FairMixedSource::Init() } gROOT->GetListOfBrowsables()->Add(fCbmroot); - fListFolder->Add(fCbmroot); + fListFolder.Add(fCbmroot); // Store the information about the unique runids in the input file // together with the filename and the number of events for each runid @@ -310,8 +307,8 @@ Bool_t FairMixedSource::Init() fNoOfEntries = fBackgroundChain->GetEntries(); FairRootManager::Instance()->SetInChain(fBackgroundChain, 0); - for (Int_t i = 0; i < fListFolder->GetEntriesFast(); i++) { - TFolder* fold = static_cast(fListFolder->At(i)); + for (Int_t i = 0; i < fListFolder.GetEntriesFast(); i++) { + TFolder* fold = static_cast(fListFolder.At(i)); fEvtHeader = static_cast(fold->FindObjectAny("EventHeader.")); fMCHeader = static_cast(fold->FindObjectAny("MCEventHeader.")); if (fEvtHeader) { @@ -321,7 +318,7 @@ Bool_t FairMixedSource::Init() ActivateObject(reinterpret_cast(&fMCHeader), "MCEventHeader."); } } - FairRootManager::Instance()->SetListOfFolders(fListFolder); + FairRootManager::Instance()->SetListOfFolders(&fListFolder); LOG(info) << "Entries in this Source " << fNoOfEntries << " ------------"; return kTRUE; @@ -416,7 +413,6 @@ void FairMixedSource::FillEventHeader(FairEventHeader* feh) LOG(debug) << "FairMixedSource::FillEventHeader() Event " << fCurrentEntryNo << " at " << feh->GetEventTime() << " -> Run id = " << fOutHeader->GetRunId() << " event#" << feh->GetMCEntryNumber() << " from file#" << fOutHeader->GetInputFileId(); - return; } void FairMixedSource::SetSignalFile(TString name, UInt_t identifier) @@ -527,7 +523,7 @@ Bool_t FairMixedSource::OpenBackgroundChain() } gROOT->GetListOfBrowsables()->Add(fCbmroot); - fListFolder->Add(fCbmroot); + fListFolder.Add(fCbmroot); return kTRUE; } @@ -744,7 +740,6 @@ void FairMixedSource::ReadBranchEvent(const char* BrName) return; } chain->FindBranch(BrName)->GetEntry(fEvtHeader->GetMCEntryNumber()); - return; } void FairMixedSource::ReadBranchEvent(const char* BrName, Int_t Entry) @@ -758,7 +753,6 @@ void FairMixedSource::ReadBranchEvent(const char* BrName, Int_t Entry) return; } chain->FindBranch(BrName)->GetEntry(Entry); - return; } void FairMixedSource::UseRunIdFromBG() @@ -775,4 +769,3 @@ void FairMixedSource::UseRunIdfromSG(UInt_t identifier) fRunIdFromSG = kTRUE; fRunIdFromSG_identifier = identifier; } -ClassImp(FairMixedSource); diff --git a/base/source/FairMixedSource.h b/fairroot/base/source/FairMixedSource.h similarity index 96% rename from base/source/FairMixedSource.h rename to fairroot/base/source/FairMixedSource.h index 2683cad5c1..c207e70ec7 100644 --- a/base/source/FairMixedSource.h +++ b/fairroot/base/source/FairMixedSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -29,10 +31,6 @@ class FairEventHeader; class FairFileHeader; class FairMCEventHeader; -class TString; -class TFolder; -class TObject; - class FairRootManager; class FairMixedSource : public FairFileSourceBase @@ -111,7 +109,6 @@ class FairMixedSource : public FairFileSourceBase void SetFileHeader(FairFileHeader* f) { fFileHeader = f; } Double_t GetEventTime(); - TObjArray* GetListOfFolders() { return fListFolder; } TFolder* GetBranchDescriptionFolder() { return fCbmroot; } UInt_t GetEntries() { return fNoOfEntries; } @@ -143,8 +140,6 @@ class FairMixedSource : public FairFileSourceBase std::map fFriendTypeList; //! std::list fInputLevel; //! std::map> fRunIdInfoAll; //! - /** list of folders from all input (and friends) files*/ - TObjArray* fListFolder; //! /**folder structure of output*/ TFolder* fCbmout; /**folder structure of input*/ diff --git a/base/source/FairSource.cxx b/fairroot/base/source/FairSource.cxx similarity index 92% rename from base/source/FairSource.cxx rename to fairroot/base/source/FairSource.cxx index bbcf93eab3..639b671cef 100644 --- a/base/source/FairSource.cxx +++ b/fairroot/base/source/FairSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -34,5 +34,3 @@ void FairSource::FillEventHeader(FairEventHeader* eh) eh->SetRunId(fRunId); } } - -ClassImp(FairSource); diff --git a/base/source/FairSource.h b/fairroot/base/source/FairSource.h similarity index 61% rename from base/source/FairSource.h rename to fairroot/base/source/FairSource.h index fd50b08ba8..e76a477e0b 100644 --- a/base/source/FairSource.h +++ b/fairroot/base/source/FairSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,9 +15,6 @@ #ifndef FAIRSOURCE_H #define FAIRSOURCE_H -#include "FairLogger.h" -#include "TClass.h" - #include #include @@ -34,7 +31,7 @@ class FairSource : public TObject public: FairSource(); FairSource(const FairSource& source); - virtual ~FairSource(); + ~FairSource() override; virtual Bool_t Init() = 0; virtual Int_t ReadEvent(UInt_t = 0) = 0; virtual Bool_t SpecifyRunId() = 0; @@ -49,8 +46,8 @@ class FairSource : public TObject /**Check the maximum event number we can run to*/ virtual Int_t CheckMaxEventNo(Int_t = 0) { return -1; } /**Read the tree entry on one branch**/ - virtual void ReadBranchEvent(const char*) { return; } - virtual void ReadBranchEvent(const char*, Int_t) { return; } + virtual void ReadBranchEvent(const char*) {} + virtual void ReadBranchEvent(const char*, Int_t) {} virtual void FillEventHeader(FairEventHeader* feh); void SetRunId(Int_t runId) { fRunId = runId; } Int_t GetRunId() const { return fRunId; } @@ -59,42 +56,7 @@ class FairSource : public TObject Int_t fRunId; public: - ClassDef(FairSource, 2); + ClassDefOverride(FairSource, 2); }; -namespace { - -template -bool ActivateObjectAnyImpl(S* source, void** obj, const std::type_info& info, const char* brname) -{ - // we check if the types match at all - auto br = source->GetBranch(brname); - if (!br) { - // branch not found in source - return false; - } - - // look up the TClass and resulting typeid stored in this branch - auto cl = TClass::GetClass(br->GetClassName()); - if (!cl) { - // class not found - return false; - } - - auto storedtype = cl->GetTypeInfo(); - - // check consistency of types - if (info.hash_code() != storedtype->hash_code()) { - LOG(info) << "Trying to read from branch " << brname << " with wrong type " << info.name() - << " (expected: " << storedtype->name() << ")\n"; - return false; - } - source->SetBranchStatus(brname, 1); - // force to use the (void*) interface which is non-checking - source->SetBranchAddress(brname, (void*)obj); - return true; -} - -} // namespace - #endif diff --git a/base/source/README.dox b/fairroot/base/source/README.dox similarity index 100% rename from base/source/README.dox rename to fairroot/base/source/README.dox diff --git a/base/steer/FairAnaSelector.cxx b/fairroot/base/steer/FairAnaSelector.cxx similarity index 100% rename from base/steer/FairAnaSelector.cxx rename to fairroot/base/steer/FairAnaSelector.cxx diff --git a/base/steer/FairAnaSelector.h b/fairroot/base/steer/FairAnaSelector.h similarity index 95% rename from base/steer/FairAnaSelector.h rename to fairroot/base/steer/FairAnaSelector.h index 044cafbd85..ebcc99ebaf 100644 --- a/base/steer/FairAnaSelector.h +++ b/fairroot/base/steer/FairAnaSelector.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -47,7 +47,7 @@ class FairAnaSelector : public TSelector , fCurrentDirectory("") {} - ~FairAnaSelector() override {} + ~FairAnaSelector() override = default; Int_t Version() const override { return 1; } void Begin(TTree* tree) override; void SlaveBegin(TTree* tree) override; diff --git a/base/steer/FairLinkManager.cxx b/fairroot/base/steer/FairLinkManager.cxx similarity index 73% rename from base/steer/FairLinkManager.cxx rename to fairroot/base/steer/FairLinkManager.cxx index cae97d1ddd..5cfd90d2d5 100644 --- a/base/steer/FairLinkManager.cxx +++ b/fairroot/base/steer/FairLinkManager.cxx @@ -1,3 +1,10 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ // ------------------------------------------------------------------------- // ----- FairLinkManager source file ----- // ----- Created 05/06/14 by T.Stockmanns ----- @@ -5,8 +12,7 @@ #include "FairLinkManager.h" -#include "FairLogger.h" -#include "FairRun.h" +#include TMCThreadLocal FairLinkManager* FairLinkManager::fgInstance = 0; @@ -21,7 +27,6 @@ FairLinkManager::FairLinkManager() : TObject() , fIgnoreTypes() , fIgnoreSetting(kTRUE) - , fLogger(0) { if (fgInstance) { Fatal("FairLinkManager", "Singleton instance already exists."); @@ -29,11 +34,6 @@ FairLinkManager::FairLinkManager() } // std::cout << "-I- FairLinkManager::FairLinkManager created!" << std::endl; fgInstance = this; - - // Logger only on master - TO DO - if (FairRun::Instance()->GetIsMaster()) { - fLogger = FairLogger::GetLogger(); - } } FairLinkManager::~FairLinkManager() @@ -70,5 +70,3 @@ Bool_t FairLinkManager::IsIgnoreType(Int_t type) const else return !fIgnoreTypes.count(type); } - -ClassImp(FairLinkManager); diff --git a/base/steer/FairLinkManager.h b/fairroot/base/steer/FairLinkManager.h similarity index 67% rename from base/steer/FairLinkManager.h rename to fairroot/base/steer/FairLinkManager.h index 1727453881..9c5e91120c 100644 --- a/base/steer/FairLinkManager.h +++ b/fairroot/base/steer/FairLinkManager.h @@ -1,3 +1,10 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ #ifndef FAIR_LINK_MANAGER_H #define FAIR_LINK_MANAGER_H @@ -6,17 +13,17 @@ #include // for TObject #include // for set of branch types to ignore -class FairLogger; - +/** + * \ingroup base_steer fairroot_singleton + */ class FairLinkManager : public TObject { public: /**ctor*/ FairLinkManager(); /**dtor*/ - virtual ~FairLinkManager(); + ~FairLinkManager() override; - /** static access method */ static FairLinkManager* Instance(); virtual void AddIgnoreType(Int_t type); ///< Adds a BranchId (Type) to which links are not included in the link ///< list. Either ignore types or include types can be given. @@ -40,9 +47,7 @@ class FairLinkManager : public TObject /**Singleton instance*/ static TMCThreadLocal FairLinkManager* fgInstance; - FairLogger* fLogger; //! - - ClassDef(FairLinkManager, 1); + ClassDefOverride(FairLinkManager, 1); }; #endif // FAIR_ROOT_MANAGER_H diff --git a/base/steer/FairRadGridManager.cxx b/fairroot/base/steer/FairRadGridManager.cxx similarity index 97% rename from base/steer/FairRadGridManager.cxx rename to fairroot/base/steer/FairRadGridManager.cxx index 62b0d5d50d..d673aa0e79 100644 --- a/base/steer/FairRadGridManager.cxx +++ b/fairroot/base/steer/FairRadGridManager.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,8 +19,6 @@ #include #include -ClassImp(FairRadGridManager); - FairRadGridManager* FairRadGridManager::fgInstance = nullptr; FairRadGridManager* FairRadGridManager::Instance() diff --git a/base/steer/FairRadGridManager.h b/fairroot/base/steer/FairRadGridManager.h similarity index 96% rename from base/steer/FairRadGridManager.h rename to fairroot/base/steer/FairRadGridManager.h index 2315fb58f1..61b9400b93 100644 --- a/base/steer/FairRadGridManager.h +++ b/fairroot/base/steer/FairRadGridManager.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,8 +24,8 @@ class TClonesArray; /** * @class FairRadGridManager + * \ingroup base_steer fairroot_singleton */ - class FairRadGridManager { public: diff --git a/base/steer/FairRadLenManager.cxx b/fairroot/base/steer/FairRadLenManager.cxx similarity index 97% rename from base/steer/FairRadLenManager.cxx rename to fairroot/base/steer/FairRadLenManager.cxx index fe58b35989..d9a1a48834 100644 --- a/base/steer/FairRadLenManager.cxx +++ b/fairroot/base/steer/FairRadLenManager.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,8 +20,6 @@ #include // for TVirtualMC #include // for TVirtualMCStack -ClassImp(FairRadLenManager); - FairRadLenManager* FairRadLenManager::fgInstance = nullptr; FairRadLenManager* FairRadLenManager::Instance() diff --git a/base/steer/FairRadLenManager.h b/fairroot/base/steer/FairRadLenManager.h similarity index 96% rename from base/steer/FairRadLenManager.h rename to fairroot/base/steer/FairRadLenManager.h index 700cfd93f6..ee5103e8df 100644 --- a/base/steer/FairRadLenManager.h +++ b/fairroot/base/steer/FairRadLenManager.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,8 +20,8 @@ class TVirtualMC; /** * @class FairRadLenManager + * \ingroup base_steer fairroot_singleton */ - class FairRadLenManager { public: diff --git a/base/steer/FairRadMapManager.cxx b/fairroot/base/steer/FairRadMapManager.cxx similarity index 98% rename from base/steer/FairRadMapManager.cxx rename to fairroot/base/steer/FairRadMapManager.cxx index aaab798e47..af661371f4 100644 --- a/base/steer/FairRadMapManager.cxx +++ b/fairroot/base/steer/FairRadMapManager.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,8 +30,6 @@ using std::cout; using std::endl; -ClassImp(FairRadMapManager); - FairRadMapManager* FairRadMapManager::fgInstance = nullptr; FairRadMapManager* FairRadMapManager::Instance() diff --git a/base/steer/FairRadMapManager.h b/fairroot/base/steer/FairRadMapManager.h similarity index 96% rename from base/steer/FairRadMapManager.h rename to fairroot/base/steer/FairRadMapManager.h index 4bd67b51fb..8b29c5e47e 100644 --- a/base/steer/FairRadMapManager.h +++ b/fairroot/base/steer/FairRadMapManager.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,8 +20,8 @@ class TVirtualMC; /** * @class FairRadMapManager + * \ingroup base_steer fairroot_singleton */ - class FairRadMapManager { public: diff --git a/base/steer/FairRingSorter.cxx b/fairroot/base/steer/FairRingSorter.cxx similarity index 97% rename from base/steer/FairRingSorter.cxx rename to fairroot/base/steer/FairRingSorter.cxx index a9926db45f..0b3ad125df 100644 --- a/base/steer/FairRingSorter.cxx +++ b/fairroot/base/steer/FairRingSorter.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -109,5 +109,3 @@ int FairRingSorter::CalcIndex(double val) } return index; } - -ClassImp(FairRingSorter); diff --git a/base/steer/FairRingSorter.h b/fairroot/base/steer/FairRingSorter.h similarity index 94% rename from base/steer/FairRingSorter.h rename to fairroot/base/steer/FairRingSorter.h index 5b2eb64c71..ec6c33b300 100644 --- a/base/steer/FairRingSorter.h +++ b/fairroot/base/steer/FairRingSorter.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -36,7 +36,7 @@ class FairRingSorter : public TObject , fVerbose(0) {} - virtual ~FairRingSorter(){}; + ~FairRingSorter() override = default; virtual FairTimeStamp* CreateElement(FairTimeStamp* data); @@ -70,7 +70,7 @@ class FairRingSorter : public TObject double fCellWidth; int fVerbose; - ClassDef(FairRingSorter, 1); + ClassDefOverride(FairRingSorter, 1); }; #endif /* FairRingSorter_H_ */ diff --git a/base/steer/FairRingSorterTask.cxx b/fairroot/base/steer/FairRingSorterTask.cxx similarity index 95% rename from base/steer/FairRingSorterTask.cxx rename to fairroot/base/steer/FairRingSorterTask.cxx index 5e77b7ead8..ea37cd5ce8 100644 --- a/base/steer/FairRingSorterTask.cxx +++ b/fairroot/base/steer/FairRingSorterTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -97,7 +97,7 @@ void FairRingSorterTask::FinishTask() } for (int i = 0; i < fInputArray->GetEntriesFast(); i++) { FairTimeStamp* myDigi = static_cast(fInputArray->At(i)); - fSorter->AddElement(myDigi, (static_cast(myDigi))->GetTimeStamp()); + fSorter->AddElement(myDigi, myDigi->GetTimeStamp()); } fSorter->Print(); fSorter->WriteOutAll(); @@ -120,5 +120,3 @@ void FairRingSorterTask::FinishTask() } ioman->SetLastFill(); } - -ClassImp(FairRingSorterTask); diff --git a/base/steer/FairRingSorterTask.h b/fairroot/base/steer/FairRingSorterTask.h similarity index 100% rename from base/steer/FairRingSorterTask.h rename to fairroot/base/steer/FairRingSorterTask.h diff --git a/base/steer/FairRootManager.cxx b/fairroot/base/steer/FairRootManager.cxx similarity index 83% rename from base/steer/FairRootManager.cxx rename to fairroot/base/steer/FairRootManager.cxx index 57c8433755..71df4b4588 100644 --- a/base/steer/FairRootManager.cxx +++ b/fairroot/base/steer/FairRootManager.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,12 +35,12 @@ #include // for TFolder #include // for TGeoManager, gGeoManager #include // for TList -#include -#include // for TNamed +#include #include // for TObjArray #include // for TObjString #include // for TTree #include // for find +#include #include #include #include // for strcmp @@ -58,13 +58,7 @@ using std::map; using std::pair; using std::set; -namespace { -// Define mutexes per operation which modify shared data -TMCMutex createMutex = TMCMUTEX_INITIALIZER; -TMCMutex deleteMutex = TMCMUTEX_INITIALIZER; -} // namespace - -Int_t FairRootManager::fgCounter = 0; +static std::atomic FRM_fgCounter{0}; std::string FairRootManager::fFolderName = ""; std::string FairRootManager::fTreeName = ""; @@ -78,15 +72,8 @@ FairRootManager* FairRootManager::Instance() FairRootManager::FairRootManager() : TObject() - , fOldEntryNr(-1) - , fOutFolder(0) - , fRootFolder(0) , fCurrentTime(0) - , fObj2(new TObject*[1000]) - , fNObj(-1) - , fMap() , fBranchSeqId(0) - , fBranchNameList(new TList()) , fMCTrackBranchId(-1) , fTimeBasedBranchNameList(new TList()) , fActiveContainer() @@ -95,43 +82,27 @@ FairRootManager::FairRootManager() , fInputBranchMap() , fBranchPerMap(kFALSE) , fBrPerMap() - , fCurrentEntryNo(0) - , fTimeforEntryNo(0) , fFillLastData(kFALSE) , fEntryNr(0) - , fListFolder(0) , fSource(0) , fSignalChainList() , fEventHeader(new FairEventHeader()) , fSink(nullptr) , fUseFairLinks(kFALSE) , fFinishRun(kFALSE) - , fId(0) { - LOG(debug) << "FairRootManager::FairRootManager: going to lock " << this; - - TMCAutoLock lk(&createMutex); - // Set Id - fId = fgCounter; + fId = FRM_fgCounter.fetch_add(1, std::memory_order_relaxed); - // Increment counter - ++fgCounter; + LOG(debug) << "FairRootManager::FairRootManager #" << fId << " at " << this; - lk.unlock(); - - LOG(debug) << "Released lock and done FairRootManager::FairRootManager in " << fId << " " << this; + fBranchNameList.SetOwner(kTRUE); } FairRootManager::~FairRootManager() { - // LOG(debug) << "Enter Destructor of FairRootManager"; - delete[] fObj2; - fBranchNameList->Delete(); - delete fBranchNameList; - LOG(debug) << "Leave Destructor of FairRootManager"; delete fEventHeader; delete fSourceChain; if (fSink) @@ -140,16 +111,10 @@ FairRootManager::~FairRootManager() delete fSource; // Global cleanup - TMCAutoLock lk(&deleteMutex); - - LOG(debug) << "FairRootManager::~FairRootManager: going to lock " << fId << " " << this; - - --fgCounter; - // - lk.unlock(); + FRM_fgCounter.fetch_sub(1, std::memory_order_relaxed); - LOG(debug) << "Released lock and done FairRootManager::~FairRootManager in " << fId << " " << this; + LOG(debug) << "FairRootManager::~FairRootManager done #" << fId << " at " << this; } Bool_t FairRootManager::InitSource() @@ -224,8 +189,8 @@ void FairRootManager::Register(const char* name, const char* folderName, TNamed* Int_t FairRootManager::AddBranchToList(const char* name) { - if (fBranchNameList->FindObject(name) == 0) { - fBranchNameList->AddLast(new TObjString(name)); + if (fBranchNameList.FindObject(name) == 0) { + fBranchNameList.AddLast(new TObjString(name)); // check if we are setting the MCTrack Branch if (strcmp(name, "MCTrack") == 0) { fMCTrackBranchId = fBranchSeqId; @@ -293,7 +258,7 @@ TString FairRootManager::GetBranchName(Int_t id) { /**Return the branch name from the id*/ if (id < fBranchSeqId) { - TObjString* ObjStr = static_cast(fBranchNameList->At(id)); + TObjString* ObjStr = static_cast(fBranchNameList.At(id)); return ObjStr->GetString(); } else { TString NotFound("Branch not found"); @@ -306,8 +271,8 @@ Int_t FairRootManager::GetBranchId(TString const& BrName) /**Return the branch id from the name*/ TObjString* ObjStr; Int_t Id = -1; - for (Int_t t = 0; t < fBranchNameList->GetEntries(); t++) { - ObjStr = static_cast(fBranchNameList->TList::At(t)); + for (Int_t t = 0; t < fBranchNameList.GetEntries(); t++) { + ObjStr = static_cast(fBranchNameList.TList::At(t)); if (BrName == ObjStr->GetString()) { Id = t; break; @@ -419,7 +384,7 @@ void FairRootManager::WriteFolder() { if (fSink) { fSink->WriteFolder(); - fSink->WriteObject(fBranchNameList, "BranchList", TObject::kSingleKey); + fSink->WriteObject(&fBranchNameList, "BranchList", TObject::kSingleKey); fSink->WriteObject(fTimeBasedBranchNameList, "TimeBasedBranchList", TObject::kSingleKey); } } @@ -434,7 +399,7 @@ Bool_t FairRootManager::SpecifyRunId() LOG(info) << "---FairRootManager::SpecifyRunId --- "; return Result; } -Int_t FairRootManager::ReadEvent(Int_t i) +Int_t FairRootManager::ReadEvent(const Int_t i) { if (!fSource) return 0; @@ -448,14 +413,12 @@ Int_t FairRootManager::ReadEvent(Int_t i) return -1; } - fCurrentEntryNo = i; - Int_t readEventResult = fSource->ReadEvent(i); fSource->FillEventHeader(fEventHeader); fCurrentTime = fEventHeader->GetEventTime(); - LOG(debug) << "--Event number --- " << fCurrentEntryNo << " with t0 time ---- " << fCurrentTime; + LOG(debug) << "--Event number --- " << i << " with t0 time ---- " << fCurrentTime; return readEventResult; } @@ -516,34 +479,9 @@ Bool_t FairRootManager::ReadNextEvent(Double_t) TObject* FairRootManager::GetObject(const char* BrName) { /**Get Data object by name*/ - TObject* Obj = nullptr; LOG(debug2) << " Try to find if the object " << BrName << " is already activated by another task or call"; - /**Try to find the object in the folder structure, object already activated by other task or call*/ - if (fOutFolder) { - Obj = fOutFolder->FindObjectAny(BrName); - if (Obj) { - LOG(debug2) << "Object " << BrName << " was already activated by another task"; - } - } - /**if the object does not exist then it could be a memory branch */ - if (!Obj) { - LOG(debug2) << "Try to find if the object " << BrName << " is a memory branch"; - Obj = GetMemoryBranch(BrName); - if (Obj) { - LOG(debug2) << "Object " << BrName << " is a memory branch"; - } - } - /**if the object does not exist then look in the input tree */ - if (fRootFolder && !Obj) { - /** there is an input tree and the object was not in memory */ - LOG(debug2) << "Object " << BrName - << " is not a memory branch and not yet activated, try the Input Tree (Chain)"; - Obj = fRootFolder->FindObjectAny(BrName); - Obj = ActivateBranch(BrName); - } - if (!Obj) { - Obj = ActivateBranch(BrName); - } + /**Get object from memory or source*/ + TObject* Obj = ActivateBranch(BrName); if (Obj != nullptr) FairMonitor::GetMonitor()->RecordGetting(BrName); return Obj; @@ -725,7 +663,7 @@ void FairRootManager::SetBranchNameList(TList* list) if (list == nullptr) return; // otherwise clear existing and add via the standard interface - fBranchNameList->Clear(); + fBranchNameList.Clear(); fMCTrackBranchId = -1; for (Int_t t = 0; t < list->GetEntries(); t++) { AddBranchToList(static_cast(list->At(t))->GetString().Data()); @@ -740,22 +678,41 @@ void FairRootManager::SetInChain(TChain* tempChain, Int_t ident) fSignalChainList[ident] = tempChain; } -Double_t FairRootManager::GetEventTime() { return fCurrentTime; } +Double_t FairRootManager::GetEventTime() +{ + return fCurrentTime; +} void FairRootManager::UpdateBranches() { - for (Int_t iobj = 0; iobj <= fNObj; iobj++) { - if (fObj2[iobj]) { - LOG(info) << "FairRootManager::UpdateBranches \"" << fObj2[iobj]->GetName() << "\" (\"" - << fObj2[iobj]->GetTitle() << "\")"; - TString tempBranchName = fObj2[iobj]->GetName(); - fSource->ActivateObject(&fObj2[fNObj], tempBranchName.Data()); + for (auto& iobj : fObj2) { + if (iobj) { + const char* objname = iobj->GetName(); + LOG(info) << "FairRootManager::UpdateBranches \"" << objname << "\" (\"" << iobj->GetTitle() << "\")"; + fSource->ActivateObject(&iobj, objname); } } } /** Private functions*/ +TObject* FairRootManager::ListFolderSearch(const char* brname) const +{ + if (!fListFolder) { + return nullptr; + } + for (auto const* fold : TRangeDynCast(fListFolder)) { + if (!fold) { + continue; + } + TObject* obj = fold->FindObjectAny(brname); + if (obj) { + return obj; + } + } + return nullptr; +} + TObject* FairRootManager::ActivateBranch(const char* BrName) { /** Set the branch address for a given branch name and return a TObject pointer, @@ -764,85 +721,48 @@ TObject* FairRootManager::ActivateBranch(const char* BrName) calls to activate branch is done , and then just forward the pointer. **/ - fNObj++; - fObj2[fNObj] = GetMemoryBranch(BrName); - if (fObj2[fNObj]) { - return fObj2[fNObj]; + auto& newentry = fObj2.emplace_back(GetMemoryBranch(BrName)); + if (newentry) { + return newentry; } /**try to find the object decribing the branch in the folder structure in file*/ LOG(debug) << "Try to find an object " << BrName << " describing the branch in the folder structure in file"; - if (fListFolder) { - for (Int_t i = 0; i < fListFolder->GetEntriesFast(); i++) { - TFolder* fold = static_cast(fListFolder->At(i)); - fObj2[fNObj] = fold->FindObjectAny(BrName); - if (fObj2[fNObj]) { - LOG(info) << "Object " << BrName << " describing the branch in the folder structure was found"; - break; - } - } - } + newentry = ListFolderSearch(BrName); - if (!fObj2[fNObj]) { + if (!newentry) { /** if we do not find an object corresponding to the branch in the folder structure * then we have no idea about what type of object is this and we cannot set the branch address */ LOG(info) << " Branch: " << BrName << " not found in Tree."; // Fatal(" No Branch in the tree", BrName ); - return 0; + return nullptr; } else { if (fSource) - fSource->ActivateObject(&fObj2[fNObj], BrName); + fSource->ActivateObject(&newentry, BrName); } - AddMemoryBranch(BrName, fObj2[fNObj]); - return fObj2[fNObj]; + AddMemoryBranch(BrName, newentry); + return newentry; } void FairRootManager::AddMemoryBranch(const char* fName, TObject* pObj) { /**branch will be available ionly in Memory, will not be written to disk */ - map::iterator p; TString BrName = fName; - p = fMap.find(BrName); - if (p != fMap.end()) { - } else { - fMap.insert(pair(BrName, pObj)); + auto p = fMap.find(BrName); + if (p == fMap.end()) { + fMap.emplace(std::move(BrName), pObj); } } Int_t FairRootManager::CheckBranchSt(const char* BrName) { // cout <<"FairRootManager::CheckBranchSt : " << BrName << endl; - Int_t returnvalue = 0; - TObject* Obj1 = nullptr; - if (fListFolder == 0) { - fListFolder = new TObjArray(16); - } + TObject* Obj1 = ListFolderSearch(BrName); + TObject* Obj2 = GetMemoryBranch(BrName); // Branch in Memory - // cout <<"FairRootManager::CheckBranchSt : " <Add(fRootFolder); - Obj1 = fRootFolder->FindObjectAny(BrName); - } - if (fOutFolder && !Obj1) { - fListFolder->Add(fOutFolder); - Obj1 = fOutFolder->FindObjectAny(BrName); // Branch in output folder - } - if (!Obj1) { - for (Int_t i = 0; i < fListFolder->GetEntriesFast(); i++) { - // cout << "Search in Folder: " << i << " " << fListFolder->At(i) << endl; - TFolder* fold = dynamic_cast(fListFolder->At(i)); - if (fold != 0) { - Obj1 = fold->FindObjectAny(BrName); - } - if (Obj1) { - break; - } - } - } - TObject* Obj2 = nullptr; - Obj2 = GetMemoryBranch(BrName); // Branch in Memory + Int_t returnvalue = 0; if (Obj1 != 0) { returnvalue = 1; } else if (Obj2 != 0) { @@ -863,25 +783,23 @@ void FairRootManager::CreatePerMap() // cout << " FairRootManager::CreatePerMap() " << endl; fBranchPerMap = kTRUE; for (Int_t i = 0; i < fBranchSeqId; i++) { - TObjString* name = static_cast(fBranchNameList->At(i)); + TObjString* name = static_cast(fBranchNameList.At(i)); // cout << " FairRootManager::CreatePerMap() Obj At " << i << " is " << name->GetString() << endl; TString BrName = name->GetString(); fBrPerMap.insert(pair(BrName, CheckBranchSt(BrName.Data()))); } } -TObject* FairRootManager::GetMemoryBranch(const char* fName) +TObject* FairRootManager::GetMemoryBranch(const char* fName) const { - // return fMap[BrName]; - TString BrName = fName; - map::iterator p; - p = fMap.find(BrName); + const TString BrName = fName; + auto p = fMap.find(BrName); if (p != fMap.end()) { return p->second; } else { - return 0; + return nullptr; } } @@ -1063,5 +981,3 @@ TTree* FairRootManager::GetOutTree() auto rootFileSink = static_cast(sink); return rootFileSink->GetOutTree(); } - -ClassImp(FairRootManager); diff --git a/base/steer/FairRootManager.h b/fairroot/base/steer/FairRootManager.h similarity index 94% rename from base/steer/FairRootManager.h rename to fairroot/base/steer/FairRootManager.h index f119c167b6..addffb804b 100644 --- a/base/steer/FairRootManager.h +++ b/fairroot/base/steer/FairRootManager.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -87,14 +87,15 @@ class FairRootManager : public TObject Int_t GetMCTrackBranchId() const { return fMCTrackBranchId; } /**Return a TList of TObjString of branch names available in this session*/ - TList* GetBranchNameList() { return fBranchNameList; } + TList* GetBranchNameList() { return &fBranchNameList; } /** Get the Object (container) for the given branch name, this method can be used to access the data of a branch that was created from a different analysis task, and not written in the tree yet. the user have to cast this pointer to the right type. - Return a pointer to the object (collection) saved in the fInChain branch named BrName*/ + Returns a non-owning pointer to the found object + or nullptr if none found*/ TObject* GetObject(const char* BrName); /// Initializes and returns a default object for a branch or looks it up when it exists already. @@ -135,7 +136,7 @@ class FairRootManager : public TObject static FairRootManager* Instance(); /**Read a single entry from background chain*/ - Int_t ReadEvent(Int_t i = 0); + Int_t ReadEvent(const Int_t i = 0); /** Read a single entry from each branch that is not read via TSBuffers*/ Int_t ReadNonTimeBasedEventFromBranches(Int_t i = 0); /**Read the tree entry on one branch**/ @@ -294,10 +295,14 @@ class FairRootManager : public TObject }; /**private methods*/ + /**ctor*/ FairRootManager(); FairRootManager(const FairRootManager&); FairRootManager& operator=(const FairRootManager&); + + TObject* ListFolderSearch(const char* brname) const; + /** Set the branch address for a given branch name and return a TObject pointer, the user have to cast this pointer to the right type.*/ TObject* ActivateBranch(const char* BrName); @@ -322,7 +327,7 @@ class FairRootManager : public TObject Int_t CheckBranchSt(const char* BrName); /**Create the Map for the branch persistency status */ void CreatePerMap(); - TObject* GetMemoryBranch(const char*); + TObject* GetMemoryBranch(const char*) const; // void GetRunIdInfo(TString fileName, TString inputLevel); FairWriteoutBuffer* GetWriteoutBuffer(TString branchName); @@ -331,16 +336,10 @@ class FairRootManager : public TObject void EmitMemoryBranchWrongTypeWarning(const char* brname, const char* typen1, const char* typen2) const; /**private Members*/ - Int_t fOldEntryNr; - /**folder structure of output*/ - TFolder* fOutFolder; - /**folder structure of input*/ - TFolder* fRootFolder; + /** current time in ns*/ Double_t fCurrentTime; - TObject** fObj2; //! - /** Counter for the number of branches activiated */ - Int_t fNObj; //! + std::vector fObj2{}; //! /** A list which hold the pointer to the branch * and the name of the branch in memory, it contains all branches (TClonesArrays) * persistance and Memory only branches @@ -361,7 +360,7 @@ class FairRootManager : public TObject /**Branch id for this run */ Int_t fBranchSeqId; /**List of branch names as TObjString*/ - TList* fBranchNameList; //! + TList fBranchNameList{}; //! /**The branch ID for the special (required) MCTrack branch**/ Int_t fMCTrackBranchId; //! @@ -379,14 +378,10 @@ class FairRootManager : public TObject /** Map for branch persistency list */ std::map fBrPerMap; //! - /** for internal use, to return the same event time for the same entry*/ - UInt_t fCurrentEntryNo; //! - /** for internal use, to return the same event time for the same entry*/ - UInt_t fTimeforEntryNo; //! - Bool_t fFillLastData; //! - Int_t fEntryNr; //! + Bool_t fFillLastData; //! + Int_t fEntryNr; //! - TObjArray* fListFolder; //! + TObjArray* fListFolder{nullptr}; //! FairSource* fSource; @@ -403,10 +398,8 @@ class FairRootManager : public TObject TRefArray fListOfNonTimebasedBranches{}; //! /**private Members for multi-threading */ - // global static data members - static Int_t fgCounter; // The counter of instances // data members - Int_t fId; // This manager ID + Int_t fId{0}; //! This manager ID ClassDefOverride(FairRootManager, 14); }; @@ -431,7 +424,7 @@ T FairRootManager::GetMemoryBranchAny(const char* brname) const auto iter = fAnyBranchMap.find(brname); if (iter != fAnyBranchMap.end()) { // verify type consistency - if (typeid(P).hash_code() != iter->second->origtypeinfo.hash_code()) { + if (typeid(P) != iter->second->origtypeinfo) { EmitMemoryBranchWrongTypeWarning(brname, typeid(P).name(), iter->second->origtypeinfo.name()); return nullptr; } diff --git a/base/steer/FairRun.cxx b/fairroot/base/steer/FairRun.cxx similarity index 88% rename from base/steer/FairRun.cxx rename to fairroot/base/steer/FairRun.cxx index 3bace793a3..acceeadebb 100644 --- a/base/steer/FairRun.cxx +++ b/fairroot/base/steer/FairRun.cxx @@ -13,7 +13,6 @@ #include "FairRun.h" #include "FairFileHeader.h" // for FairFileHeader -#include "FairLinkManager.h" // for FairLinkManager #include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN #include "FairRootFileSink.h" // only temporary, should be removed after the move to FairSink is finished #include "FairRootManager.h" // for FairRootManager @@ -38,13 +37,13 @@ FairRun* FairRun::Instance() { return fRunInstance; } FairRun::FairRun(Bool_t isMaster) : TNamed() , fNTasks(0) + , fEvtHeader() , fRtdb(FairRuntimeDb::instance()) , fTask(new FairTask("FairTaskList")) , fRootManager(0) , fUserOutputFileName() , fRunId(0) , fAna(kFALSE) - , fEvtHeader(nullptr) , fFileHeader(new FairFileHeader()) , fGenerateRunInfo(kFALSE) , fIsMaster(isMaster) @@ -77,8 +76,6 @@ FairRun::FairRun(Bool_t isMaster) #endif fRootManager = FairRootManager::Instance(); - - new FairLinkManager(); } FairRun::~FairRun() @@ -99,7 +96,6 @@ FairRun::~FairRun() // who is responsible for the RuntimeDataBase? delete fRtdb; } - delete fEvtHeader; if (fRunInstance == this) { // Do not point to a destructed object! fRunInstance = nullptr; @@ -149,12 +145,22 @@ FairTask* FairRun::GetTask(const char* taskName) return dynamic_cast(task); } +void FairRun::SetEventHeader(FairEventHeader* EvHeader) +{ + fEvtHeader.reset(EvHeader); +} + +void FairRun::SetEventHeader(std::unique_ptr EvHeader) +{ + fEvtHeader = std::move(EvHeader); +} + FairEventHeader* FairRun::GetEventHeader() { - if (nullptr == fEvtHeader) { - fEvtHeader = new FairEventHeader(); + if (!fEvtHeader) { + fEvtHeader = std::make_unique(); } - return fEvtHeader; + return fEvtHeader.get(); } void FairRun::SetUseFairLinks(Bool_t val) { fRootManager->SetUseFairLinks(val); } @@ -230,6 +236,19 @@ TString FairRun::GetUserOutputFileName() const { return fUserOutputFileName; } void FairRun::AlignGeometry() const { fAlignmentHandler.AlignGeometry(); } +/** + * \todo Should we check for `fEvtHeader` being set as well? + */ +void FairRun::FillEventHeader() +{ + if (!fSource) { + LOG(warning) << "FairRun::FillEventHeader: No Source!"; + return; + } + + fSource->FillEventHeader(fEvtHeader.get()); +} + void FairRun::AddAlignmentMatrices(const std::map& alignmentMatrices, bool invertMatrices) { fAlignmentHandler.AddAlignmentMatrices(alignmentMatrices, invertMatrices); @@ -241,4 +260,24 @@ void FairRun::SetSource(FairSource* othersource) fSource.reset(othersource); } -ClassImp(FairRun); +void FairRun::ls(Option_t* option) const +{ + TNamed::ls(option); + TROOT::IncreaseDirLevel(); + fRootManager->ls(option); + fRtdb->ls(option); + if (fSource) { + fSource->ls(option); + } + if (fSink) { + fSink->ls(option); + } + if (fEvtHeader) { + fEvtHeader->ls(option); + } + if (fTask) { + fTask->ls(); + } + fLinkManager.ls(option); + TROOT::DecreaseDirLevel(); +} diff --git a/base/steer/FairRun.h b/fairroot/base/steer/FairRun.h similarity index 88% rename from base/steer/FairRun.h rename to fairroot/base/steer/FairRun.h index bc62514e00..4d43032385 100644 --- a/base/steer/FairRun.h +++ b/fairroot/base/steer/FairRun.h @@ -10,10 +10,12 @@ #include "FairAlignmentHandler.h" #include "FairEventHeader.h" +#include "FairLinkManager.h" #include "FairSink.h" #include "FairSource.h" #include // for Int_t, Bool_t, etc +#include // #include // for multi-threading #include // for TNamed #include @@ -27,17 +29,15 @@ class FairRootManager; class FairRuntimeDb; class FairSink; class FairTask; -class TFile; class FairField; -class TGeoHMatrix; /** * Configure the Simuation or Analysis + * \ingroup base_steer fairroot_singleton * @author M. Al-Turany D. Bertini * @version 0.1 * @since 12.01.04 */ - class FairRun : public TNamed { friend class FairMCApplication; @@ -51,13 +51,12 @@ class FairRun : public TNamed * default dtor */ ~FairRun() override; - /** - * static instance - */ + static FairRun* Instance(); /** * Add a FAIRTask to the simulation or analysis */ + void AddTask(std::unique_ptr task) { AddTask(task.release()); } virtual void AddTask(FairTask* t); virtual void StoreTaskNames(const FairTask* t); virtual void SetTask(FairTask* t); @@ -77,7 +76,9 @@ class FairRun : public TNamed * Set the experiment dependent run header * for each run */ - void SetEventHeader(FairEventHeader* EvHeader) { fEvtHeader = EvHeader; } + void SetEventHeader(std::unique_ptr EvHeader); + [[deprecated("Use SetEventHeader(std::unique_ptr) instead")]] void SetEventHeader( + FairEventHeader* EvHeader); /** * return a pointer to the RuntimeDB */ @@ -197,17 +198,23 @@ class FairRun : public TNamed * * Takes an owning pointer! */ - virtual void SetSource(FairSource* tempSource); + void SetSource(FairSource* tempSource); /** Return non-owning pointer to source **/ FairSource* GetSource() { return fSource.get(); } FairRootManager& GetRootManager() { return *fRootManager; } FairRootManager const& GetRootManager() const { return *fRootManager; } + void ls(Option_t* option = "") const override; + private: FairRun(const FairRun& M); FairRun& operator=(const FairRun&) { return *this; } /** Number of Tasks added*/ Int_t fNTasks; + /** MC Event Header */ + std::unique_ptr fEvtHeader; //! + + FairLinkManager fLinkManager{}; //! protected: /** static pointer to this run*/ @@ -228,8 +235,6 @@ class FairRun : public TNamed UInt_t fRunId; //! /** true for Anaylsis session*/ Bool_t fAna; //! - /** MC Event Header */ - FairEventHeader* fEvtHeader; //! /** File Header */ FairFileHeader* fFileHeader; /** true if RunInfo file should be written*/ @@ -244,17 +249,19 @@ class FairRun : public TNamed std::unique_ptr fSource{}; //! void AlignGeometry() const; + /** - * Call FillEventHeader on the source + * \brief Internal facade for FairSource::FillEventHeader + * + * Call \ref FairSource::FillEventHeader with the current header + * on the current source. Will perform some checks. */ - void FillEventHeader() - { - if (fSource) - fSource->FillEventHeader(fEvtHeader); - } + void FillEventHeader(); /** - * Get the RunId of the Event Header + * \brief Internal facade: Get the RunId of the Event Header + * + * \todo Should `fEvtHeader` be checked? */ UInt_t GetEvtHeaderRunId() const { return fEvtHeader->GetRunId(); } diff --git a/base/steer/FairRunAna.cxx b/fairroot/base/steer/FairRunAna.cxx similarity index 86% rename from base/steer/FairRunAna.cxx rename to fairroot/base/steer/FairRunAna.cxx index 8ec07b14b8..4b5547cf4a 100644 --- a/base/steer/FairRunAna.cxx +++ b/fairroot/base/steer/FairRunAna.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,7 +28,7 @@ #include "FairTrajFilter.h" // for FairTrajFilter #include "signal.h" -#include // for TIter +#include // for TRangeDynCast #include // for TDirectory::TContext #include // for TFile #include // for gGeoManager, TGeoManager @@ -46,10 +46,10 @@ using std::cout; using std::endl; -Bool_t gFRAIsInterrupted; +static Bool_t gFRAIsInterrupted; //_____________________________________________________________________________ -void FRA_handler_ctrlc(int) +static void FRA_handler_ctrlc(int) { LOG(info) << "*********** CTRL C PRESSED *************"; gFRAIsInterrupted = kTRUE; @@ -59,7 +59,10 @@ void FRA_handler_ctrlc(int) //_____________________________________________________________________________ FairRunAna* FairRunAna::fgRinstance = nullptr; //_____________________________________________________________________________ -FairRunAna* FairRunAna::Instance() { return fgRinstance; } +FairRunAna* FairRunAna::Instance() +{ + return fgRinstance; +} //_____________________________________________________________________________ FairRunAna::FairRunAna() : FairRun() @@ -127,7 +130,6 @@ void FairRunAna::SetGeomFile(const char* GeoFileName) void FairRunAna::Init() { - if (fIsInitialized) { LOG(fatal) << "Error Init is already called before!"; exit(-1); @@ -142,17 +144,7 @@ void FairRunAna::Init() // Load Geometry from user file if (fLoadGeo) { - if (fInputGeoFile != 0) { // First check if the user has a separate Geo file! - TIter next(fInputGeoFile->GetListOfKeys()); - TKey* key; - while ((key = dynamic_cast(next()))) { - if (strcmp(key->GetClassName(), "TGeoManager") != 0) { - continue; - } - gGeoManager = dynamic_cast(key->ReadObj()); - break; - } - } + SearchForTGeoManagerInGeoFile(); } else { /*** Get the container that normly has the geometry and all the basic stuff from simulation*/ fRtdb->getContainer("FairGeoParSet"); @@ -178,17 +170,7 @@ void FairRunAna::Init() } else { // if(fInputFile ) // NO input file but there is a geometry file if (fLoadGeo) { - if (fInputGeoFile != 0) { // First check if the user has a separate Geo file! - TIter next(fInputGeoFile->GetListOfKeys()); - TKey* key; - while ((key = dynamic_cast(next()))) { - if (strcmp(key->GetClassName(), "TGeoManager") != 0) { - continue; - } - gGeoManager = dynamic_cast(key->ReadObj()); - break; - } - } + SearchForTGeoManagerInGeoFile(); } } @@ -200,38 +182,34 @@ void FairRunAna::Init() // Assure that basic info is there for the run // if(par && fInputFile) { + auto* evtHeader = GetEventHeader(); if (par && fInFileIsOpen) { LOG(info) << "Parameter and input file are available, Assure that basic info is there for the run!"; fRootManager->SpecifyRunId(); - - // fEvtHeader = GetEventHeader(); - GetEventHeader(); - FillEventHeader(); - fRunId = GetEvtHeaderRunId(); // Copy the Event Header Info to Output - fEvtHeader->Register(GetSink() ? fStoreEventHeader : false); + evtHeader->Register(GetSink() ? fStoreEventHeader : false); // Init the containers in Tasks LOG(info) << "--- Initialize with RunId --- " << fRunId; - fRtdb->initContainers(fRunId); + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAna::Init: fRtdb->initContainers failed"; + } fTask->SetParTask(); - - // fRtdb->initContainers( fRunId ); - } else { // end----- if(fMixedInput) LOG(info) << "Initializing without input file or Mixed input"; - FairEventHeader* evt = GetEventHeader(); - evt->Register(GetSink() ? fStoreEventHeader : false); + evtHeader->Register(GetSink() ? fStoreEventHeader : false); FairRunIdGenerator genid; fRunId = genid.generateId(); fRtdb->addRun(fRunId); - evt->SetRunId(fRunId); + evtHeader->SetRunId(fRunId); fTask->SetParTask(); - fRtdb->initContainers(fRunId); + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAna::Init: fRtdb->initContainers failed"; + } } FairFieldFactory* fieldfact = FairFieldFactory::Instance(); @@ -239,7 +217,9 @@ void FairRunAna::Init() fieldfact->SetParm(); } - fRtdb->initContainers(fRunId); + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAna::Init: fRtdb->initContainers failed"; + } fFileHeader->SetRunId(fRunId); // create a field @@ -319,8 +299,6 @@ void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end) fRunInfo.Reset(); } - Int_t readEventReturn = 0; - for (int i = Ev_start; i < Ev_end || MaxAllowed == -1; i++) { gSystem->IgnoreInterrupt(); @@ -332,7 +310,7 @@ void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end) break; } - readEventReturn = fRootManager->ReadEvent(i); + auto readEventReturn = fRootManager->ReadEvent(i); if (readEventReturn != 0) { LOG(warn) << "FairRunAna::Run() fRootManager->ReadEvent(" << i << ") returned " << readEventReturn @@ -341,15 +319,8 @@ void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end) } FillEventHeader(); + CheckRunIdChanged(); - auto const tmpId = GetEvtHeaderRunId(); - if (tmpId != fRunId) { - fRunId = tmpId; - if (!fStatic) { - Reinit(fRunId); - fTask->ReInitTask(); - } - } // std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime(); fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime()); fTask->ExecuteTask(""); @@ -379,8 +350,6 @@ void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end) //_____________________________________________________________________________ void FairRunAna::RunEventReco(Int_t Ev_start, Int_t Ev_end) { - UInt_t tmpId = 0; - Int_t MaxAllowed = fRootManager->CheckMaxEventNo(Ev_end); if (MaxAllowed != -1) { if (Ev_end == 0) { @@ -420,13 +389,9 @@ void FairRunAna::RunEventReco(Int_t Ev_start, Int_t Ev_end) * if we have simulation files then they have MC Event Header and the Run Id is in it, any way it * would be better to make FairMCEventHeader a subclass of FairEvtHeader. */ - if (tmpId != fRunId) { - fRunId = tmpId; - if (!fStatic) { - Reinit(fRunId); - fTask->ReInitTask(); - } - } + + CheckRunIdChanged(); + // FairMCEventHeader* header = dynamic_cast(fRootManager->GetObject("MCEventHeader."); // std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime(); fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime()); @@ -482,14 +447,7 @@ void FairRunAna::RunMQ(Long64_t entry) it read a certain event and call the task exec, but no output is written */ fRootManager->ReadEvent(entry); - auto const tmpId = GetEvtHeaderRunId(); - if (tmpId != fRunId) { - fRunId = tmpId; - if (!fStatic) { - Reinit(fRunId); - fTask->ReInitTask(); - } - } + CheckRunIdChanged(); fTask->ExecuteTask(""); FillEventHeader(); fTask->FinishTask(); @@ -497,17 +455,10 @@ void FairRunAna::RunMQ(Long64_t entry) //_____________________________________________________________________________ //_____________________________________________________________________________ -void FairRunAna::Run(Long64_t entry) +void FairRunAna::RunSingleEntry(Long64_t entry) { fRootManager->ReadEvent(entry); - auto const tmpId = GetEvtHeaderRunId(); - if (tmpId != fRunId) { - fRunId = tmpId; - if (!fStatic) { - Reinit(fRunId); - fTask->ReInitTask(); - } - } + CheckRunIdChanged(); fTask->ExecuteTask(""); FillEventHeader(); fTask->FinishTask(); @@ -611,10 +562,33 @@ void FairRunAna::TerminateRun() } //_____________________________________________________________________________ +/** + * \sa FairRunOnline::CheckRunIdChanged + */ +void FairRunAna::CheckRunIdChanged() +{ + auto newrunid = GetEvtHeaderRunId(); + if (newrunid == fRunId) { + return; + } + + LOG(debug) << "FairRunAna::CheckRunIdChanged() Detected changed RunID from " << fRunId << " to " << newrunid; + fRunId = newrunid; + if (fStatic) { + LOG(debug) << "FairRunAna::CheckRunIdChanged: ReInit not called because initialisation is static."; + return; + } + LOG(debug) << "FairRunAna::CheckRunIdChanged: Call Reinit."; + Reinit(fRunId); + fTask->ReInitTask(); +} + void FairRunAna::Reinit(UInt_t runId) { // reinit procedure - fRtdb->initContainers(runId); + if (!fRtdb->initContainers(runId)) { + LOG(error) << "FairRunAna::Reinit: fRtdb->initContainers failed"; + } } //_____________________________________________________________________________ @@ -650,12 +624,20 @@ void FairRunAna::Fill() } //_____________________________________________________________________________ -// void FairRunAna::SetMixAllInputs(Bool_t Status) -// { -// fLogger->Info(MESSAGE_ORIGIN, "Mixing for all input is choosed, in this mode one event per input file is read per -// step"); fRootManager->SetMixAllInputs(Status); -// } -//_____________________________________________________________________________ -// ABOVE FUNCTIONS SHOULD BE DELETED AND MOVED TO FairFileSource AND FairMixedSource ONLY - -ClassImp(FairRunAna); +void FairRunAna::SearchForTGeoManagerInGeoFile() +{ + if (!fInputGeoFile) { // First check if the user has a separate Geo file! + return; + } + for (auto key : TRangeDynCast(fInputGeoFile->GetListOfKeys())) { + if (!key) { + continue; + } + auto geo = key->ReadObject(); + if (!geo) { + continue; + } + gGeoManager = geo; + break; + } +} diff --git a/base/steer/FairRunAna.h b/fairroot/base/steer/FairRunAna.h similarity index 79% rename from base/steer/FairRunAna.h rename to fairroot/base/steer/FairRunAna.h index 2ce56fee38..deacdf5d23 100644 --- a/base/steer/FairRunAna.h +++ b/fairroot/base/steer/FairRunAna.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,45 +8,48 @@ #ifndef FAIRRUNANA_H #define FAIRRUNANA_H -/** - * Configure and manage the Analysis - * @author M. Al-Turany D. Bertini - * @version 0.1 - * @since 28.02.05 - */ - #include "FairRootManager.h" // for FairRootManager #include "FairRun.h" // for FairRun #include "FairRunInfo.h" // for FairRunInfo #include // for Bool_t, Double_t, UInt_t, etc +#include // #include // for TString class FairField; -class TF1; -class TFile; - -class FairSource; class FairFileSource; class FairMixedSource; +/** + * Configure and manage the Analysis + * \ingroup base_steer fairroot_singleton + * @author M. Al-Turany D. Bertini + * @version 0.1 + * @since 28.02.05 + */ class FairRunAna : public FairRun { - public: static FairRunAna* Instance(); - virtual ~FairRunAna(); + ~FairRunAna() override; FairRunAna(); /**initialize the run manager*/ void Init() override; - /**Run from event number NStart to event number NStop */ + /** Run analysis: + * for the whole input if NEntry == NStop == 0, + * for NEntry entries if NStop == 0, + * from NEntry until NStop entry is reached + * from NEntry to the end of input, if NStop = -1 */ void Run(Int_t NStart = 0, Int_t NStop = 0) override; /**Run over the whole input file with timpe window delta_t as unit (entry)*/ void Run(Double_t delta_t); + /** \deprecated Replaced by unambiguous RunSingleEntry(entry)*/ + [[deprecated("Replaced by unambiguous RunSingleEntry(entry)")]] void Run(Long64_t entry) { RunSingleEntry(entry); } /**Run for the given single entry*/ - void Run(Long64_t entry); + void RunSingleEntry(Long64_t entry); /**Run event reconstruction from event number NStart to event number NStop */ - void RunEventReco(Int_t NStart, Int_t NStop); + /** \deprecated Deprecated along with FairEventBuilder. */ + [[deprecated("Deprecated along with FairEventBuilder.")]] void RunEventReco(Int_t NStart, Int_t NStop); /**Run over all TSBuffers until the data is processed*/ void RunTSBuffers(); /** the dummy run does not check the evt header or the parameters!! */ @@ -86,9 +89,9 @@ class FairRunAna : public FairRun Bool_t IsTimeStamp() { return fTimeStamps; } /** Set the flag for proccessing lmd files */ - void StopProcessingLMD(void) { fFinishProcessingLMDFile = kTRUE; } + void StopProcessingLMD() { fFinishProcessingLMDFile = kTRUE; } /** Get the status of lmd file proccessing */ - Bool_t GetLMDProcessingStatus(void) { return fFinishProcessingLMDFile; } + Bool_t GetLMDProcessingStatus() { return fFinishProcessingLMDFile; } protected: /** @@ -134,6 +137,16 @@ class FairRunAna : public FairRun /** Flag for Event Header Persistency */ Bool_t fStoreEventHeader; //! + /** + * \brief Internal facade: Handle RunID changes + */ + void CheckRunIdChanged(); + + /** + * \brief Internal helper: Search for TGeoManager in fInputGeoFile + */ + void SearchForTGeoManagerInGeoFile(); + ClassDefOverride(FairRunAna, 6); }; diff --git a/base/steer/FairRunAnaProof.cxx b/fairroot/base/steer/FairRunAnaProof.cxx similarity index 79% rename from base/steer/FairRunAnaProof.cxx rename to fairroot/base/steer/FairRunAnaProof.cxx index 7d56fcab7e..ed2efcd522 100644 --- a/base/steer/FairRunAnaProof.cxx +++ b/fairroot/base/steer/FairRunAnaProof.cxx @@ -13,7 +13,6 @@ #include "FairRunAnaProof.h" #include "FairBaseParSet.h" -#include "FairEventHeader.h" #include "FairFieldFactory.h" #include "FairFileHeader.h" #include "FairLogger.h" @@ -32,7 +31,10 @@ FairRunAnaProof* FairRunAnaProof::fRAPInstance = nullptr; -FairRunAnaProof* FairRunAnaProof::Instance() { return fRAPInstance; } +FairRunAnaProof* FairRunAnaProof::Instance() +{ + return fRAPInstance; +} FairRunAnaProof::FairRunAnaProof(const char* proofName) : FairRunAna() @@ -83,21 +85,16 @@ void FairRunAnaProof::Init() // input chain. Do a check if the added files are of the same type // as the the input file. Same type means check if they contain the // same branch. + // FairRunAnaProof should accept only FairFileSource + fProofFileSource = dynamic_cast(GetSource()); + if (!fProofFileSource) { + LOG(error) << "FairRunAnaProof. Only FairFileSource is accepted as source"; + } } // Load Geometry from user file if (fLoadGeo) { - if (fInputGeoFile != 0) { // First check if the user has a separate Geo file! - TIter next(fInputGeoFile->GetListOfKeys()); - TKey* key; - while ((key = static_cast(next()))) { - if (strcmp(key->GetClassName(), "TGeoManager") != 0) { - continue; - } - gGeoManager = static_cast(key->ReadObj()); - break; - } - } + SearchForTGeoManagerInGeoFile(); } else { // FairGeoParSet* geopar=dynamic_cast(fRtdb->getContainer("FairGeoParSet")); fRtdb->getContainer("FairGeoParSet"); @@ -135,17 +132,7 @@ void FairRunAnaProof::Init() } else { // if(fInputFile ) // NO input file but there is a geometry file if (fLoadGeo) { - if (fInputGeoFile != 0) { // First check if the user has a separate Geo file! - TIter next(fInputGeoFile->GetListOfKeys()); - TKey* key; - while ((key = static_cast(next()))) { - if (strcmp(key->GetClassName(), "TGeoManager") != 0) { - continue; - } - gGeoManager = static_cast(key->ReadObj()); - break; - } - } + SearchForTGeoManagerInGeoFile(); } } // Init the Chain ptr @@ -167,46 +154,45 @@ void FairRunAnaProof::Init() // Assure that basic info is there for the run + auto* evtHeader = GetEventHeader(); if (par && fInFileIsOpen) { LOG(info) << "Parameter and input file are available, Assure that basic info is there for the run!"; - fRootManager->ReadEvent(0); - - GetEventHeader(); + fRootManager->SpecifyRunId(); FillEventHeader(); fRunId = GetEvtHeaderRunId(); // Copy the Event Header Info to Output - fEvtHeader->Register(GetSink() ? fStoreEventHeader : false); + evtHeader->Register(GetSink() ? fStoreEventHeader : false); // Init the containers in Tasks - - fRtdb->initContainers(fRunId); + LOG(info) << "--- Initialize with RunId --- " << fRunId; + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAnaProof::Init: fRtdb->initContainers failed"; + } fTask->SetParTask(); - - fRtdb->initContainers(fRunId); - if (gGeoManager == 0) {} - // fRootManager->SetBranchNameList(par->GetBranchNameList()); - - } else { + } else { // end----- if(fMixedInput) LOG(info) << "Initializing without input file or Mixed input"; - FairEventHeader* evt = GetEventHeader(); - evt->Register(GetSink() ? fStoreEventHeader : false); + evtHeader->Register(GetSink() ? fStoreEventHeader : false); FairRunIdGenerator genid; fRunId = genid.generateId(); fRtdb->addRun(fRunId); - evt->SetRunId(fRunId); + evtHeader->SetRunId(fRunId); fTask->SetParTask(); - fRtdb->initContainers(fRunId); + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAnaProof::Init: fRtdb->initContainers failed"; + } } FairFieldFactory* fieldfact = FairFieldFactory::Instance(); if (fieldfact) { fieldfact->SetParm(); } - fRtdb->initContainers(fRunId); + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAnaProof::Init: fRtdb->initContainers failed"; + } fFileHeader->SetRunId(fRunId); // create a field @@ -234,46 +220,30 @@ void FairRunAnaProof::InitContainers() fRtdb = GetRuntimeDb(); FairBaseParSet* par = dynamic_cast(fRtdb->getContainer("FairBaseParSet")); + auto* evtHeader = GetEventHeader(); if (par && fInFileIsOpen) { - fRootManager->ReadEvent(0); - - fEvtHeader = dynamic_cast(fRootManager->GetObject("EventHeader.")); - - if (nullptr == fEvtHeader) - LOG(fatal) << "Could not read event header."; + fRootManager->SpecifyRunId(); FillEventHeader(); fRunId = GetEvtHeaderRunId(); + LOG(info) << "RKGOT FEH " << evtHeader << " (" << fRunId << ") FROM FRM " << fRootManager << "."; + // Copy the Event Header Info to Output - fEvtHeader->Register(); + evtHeader->Register(GetSink() ? fStoreEventHeader : false); // Init the containers in Tasks - fRtdb->initContainers(fRunId); - fTask->ReInitTask(); - // fTask->SetParTask(); - fRtdb->initContainers(fRunId); - if (gGeoManager == 0) { - // par->GetGeometry(); + LOG(info) << "--- Initialize with RunId --- " << fRunId; + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunAnaProof::Init: fRtdb->initContainers failed"; } } } -void FairRunAnaProof::SetSource(FairSource* tempSource) -{ - // FairRunAnaProof should accept only FairFileSource - if (strncmp(tempSource->GetName(), "FairFileSource", 14) != 0) { - LOG(warn) << "FairRunAnaProof. Seems you are trying to set different source than FairFileSource"; - } - FairRunAna::SetSource(tempSource); - fProofFileSource = static_cast(tempSource); -} - void FairRunAnaProof::Run(Int_t Ev_start, Int_t Ev_end) { RunOnProof(Ev_start, Ev_end); - return; } void FairRunAnaProof::RunOneEvent(Long64_t entry) @@ -284,15 +254,8 @@ void FairRunAnaProof::RunOneEvent(Long64_t entry) fRootManager->ReadEvent(entry); FillEventHeader(); + CheckRunIdChanged(); - auto const tmpId = GetEvtHeaderRunId(); - if (tmpId != fRunId) { - fRunId = tmpId; - if (!fStatic) { - Reinit(fRunId); - fTask->ReInitTask(); - } - } fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime()); fTask->ExecuteTask(""); @@ -363,8 +326,4 @@ void FairRunAnaProof::RunOnProof(Int_t NStart, Int_t NStop) << nofEventsToAnalyze << "," << NStart << ")"; inChain->Process("FairAnaSelector", "", nofEventsToAnalyze, NStart); LOG(info) << "FairRunAnaProof::RunOnProof(): inChain->Process DONE"; - - return; } - -ClassImp(FairRunAnaProof); diff --git a/base/steer/FairRunAnaProof.h b/fairroot/base/steer/FairRunAnaProof.h similarity index 94% rename from base/steer/FairRunAnaProof.h rename to fairroot/base/steer/FairRunAnaProof.h index 2ba200be36..7acdde3b51 100644 --- a/base/steer/FairRunAnaProof.h +++ b/fairroot/base/steer/FairRunAnaProof.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,25 +8,24 @@ #ifndef FAIRRUNANAPROOF_H #define FAIRRUNANAPROOF_H +#include "FairFileSource.h" // FairRunAnaProof can only accept FairFileSource as source +#include "FairRunAna.h" + +#include + /** * Configure and manage the Analysis on proof + * \ingroup base_steer fairroot_singleton * @author R. Karabowicz * @version 0.1 * @since 30.04.2013 */ - -#include "FairFileSource.h" // FairRunAnaProof can only accept FairFileSource as source -#include "FairRunAna.h" - -#include -#include - class FairRunAnaProof : public FairRunAna { public: /** \deprecated Deprecated in v18.8, will be removed in v20. */ [[deprecated]] static FairRunAnaProof* Instance(); - virtual ~FairRunAnaProof(); + ~FairRunAnaProof() override; FairRunAnaProof(const char* proofName = ""); /**initialize the run manager*/ @@ -59,8 +58,6 @@ class FairRunAnaProof : public FairRunAna /** Set PROOF output status, possibilities: "copy","merge"*/ void SetProofOutputStatus(TString outStat) { fProofOutputStatus = outStat; } - void SetSource(FairSource* tempSource) override; - protected: static FairRunAnaProof* fRAPInstance; diff --git a/base/steer/FairRunSim.cxx b/fairroot/base/steer/FairRunSim.cxx similarity index 84% rename from base/steer/FairRunSim.cxx rename to fairroot/base/steer/FairRunSim.cxx index 9c8d56b24b..8d7ec6bc11 100644 --- a/base/steer/FairRunSim.cxx +++ b/fairroot/base/steer/FairRunSim.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,24 +28,23 @@ #include "FairRunIdGenerator.h" // for FairRunIdGenerator #include "FairRuntimeDb.h" // for FairRuntimeDb #include "FairTask.h" // for FairTask -#include "FairTrajFilter.h" // for FairTrajFilter #include // for TIter #include // for gGeoManager #include // for TList #include // for TObjString #include // for TObject +#include // #include // for gRandom #include // for TSystem, gSystem #include // for cout, endl, ostream #include // for getenv, nullptr #include // for strcmp, strncmp +#include // for std::ignore using std::cout; using std::endl; -ClassImp(FairRunSim); - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" FairRunSim::FairRunSim(Bool_t isMaster) @@ -56,7 +55,6 @@ FairRunSim::FairRunSim(Bool_t isMaster) , fParticles(new TObjArray()) , ListOfModules(new TObjArray()) , MatFname("") - , fStoreTraj(kFALSE) , fPythiaDecayer(kFALSE) , fPythiaDecayerConfig("") , fUserDecay(kFALSE) @@ -67,7 +65,6 @@ FairRunSim::FairRunSim(Bool_t isMaster) , fMeshList(new TObjArray()) , fUserConfig("") , fUserCuts("SetCuts.C") - , fIsMT(kFALSE) , fImportTGeoToVMC(kTRUE) { if (fginstance) { @@ -77,6 +74,9 @@ FairRunSim::FairRunSim(Bool_t isMaster) fginstance = this; fRunId = 0; fAna = kFALSE; + fIons->SetName("fIons"); + fParticles->SetName("fParticles"); + ListOfModules->SetName("ListOfModules"); } #pragma GCC diagnostic pop @@ -112,9 +112,16 @@ FairRunSim::~FairRunSim() // Do not point to a destructed object! fginstance = nullptr; } + + /// \bug Leaks GeoLoader and related resources, prevents memory issues (probably a double free) + /// See: https://github.com/FairRootGroup/FairRoot/issues/1514 + std::ignore = fGeoLoader.release(); } -FairRunSim* FairRunSim::Instance() { return fginstance; } +FairRunSim* FairRunSim::Instance() +{ + return fginstance; +} void FairRunSim::AddModule(FairModule* Mod) { @@ -151,11 +158,11 @@ void FairRunSim::Init() // fOutFile=fRootManager->OpenOutFile(fOutname); LOG(info) << "============== FairRunSim: Initialising simulation run =============="; - auto loader = new FairGeoLoader(fLoaderName.Data(), "Geo Loader"); - FairGeoInterface* GeoInterFace = loader->getGeoInterface(); - GeoInterFace->SetNoOfSets(ListOfModules->GetEntries()); - GeoInterFace->setMediaFile(MatFname.Data()); - GeoInterFace->readMedia(); + fGeoLoader = std::make_unique(fLoaderName.Data(), "Geo Loader"); + FairGeoInterface* geointerFace = fGeoLoader->getGeoInterface(); + geointerFace->SetNoOfSets(ListOfModules->GetEntries()); + geointerFace->setMediaFile(MatFname.Data()); + geointerFace->readMedia(); // gSystem->cd(flout.Data()); @@ -177,7 +184,7 @@ void FairRunSim::Init() /** Add Tasks to simulation if any*/ fApp->AddTask(fTask); /** This call will create the container if it does not exist*/ - FairBaseParSet* par = dynamic_cast(fRtdb->getContainer("FairBaseParSet")); + auto par = dynamic_cast(fRtdb->getContainer("FairBaseParSet")); if (par) { par->SetDetList(GetListOfModules()); par->SetGen(GetPrimaryGenerator()); @@ -185,7 +192,7 @@ void FairRunSim::Init() } /** This call will create the container if it does not exist*/ - FairGeoParSet* geopar = dynamic_cast(fRtdb->getContainer("FairGeoParSet")); + auto geopar = dynamic_cast(fRtdb->getContainer("FairGeoParSet")); if (geopar) { geopar->SetGeometry(gGeoManager); } @@ -207,7 +214,6 @@ void FairRunSim::Init() // on/off visualisation if (fStoreTraj) { LOG(info) << "Create visualisation manager "; - new FairTrajFilter(); } if (fRadLength) { fApp->SetRadiationLengthReg(fRadLength); @@ -310,9 +316,19 @@ void FairRunSim::SetMCConfig() } } -void FairRunSim::Run(Int_t NEvents, Int_t) { fApp->RunMC(NEvents); } +void FairRunSim::Run(Int_t NEvents, Int_t) +{ + fApp->RunMC(NEvents); + fWasMT = fApp->GetIsMT(); + if (fSink) { + fSink->Close(); + } +} -void FairRunSim::SetField(FairField* field) { fField = field; } +void FairRunSim::SetField(FairField* field) +{ + fField = field; +} void FairRunSim::SetGenerator(FairPrimaryGenerator* Gen) { @@ -374,4 +390,35 @@ FairMCEventHeader* FairRunSim::GetMCEventHeader() return fMCEvHead; } +void FairRunSim::ls(Option_t* option) const +{ + FairRun::ls(option); + TROOT::IncreaseDirLevel(); + if (fGeoLoader) { + fGeoLoader->ls(option); + } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + if (fGen) { + fGen->ls(option); + } +#pragma GCC diagnostic pop + if (fField) { + fField->ls(option); + } + // if (fSimulationConfig) { + // fSimulationConfig->ls(option); + // } + ListOfModules->ls(); + fParticles->ls(); + fIons->ls(); + if (fMCEvHead) { + fMCEvHead->ls(option); + } + if (fApp) { + fApp->ls(option); + } + TROOT::DecreaseDirLevel(); +} + TMCThreadLocal FairRunSim* FairRunSim::fginstance = nullptr; diff --git a/base/steer/FairRunSim.h b/fairroot/base/steer/FairRunSim.h similarity index 92% rename from base/steer/FairRunSim.h rename to fairroot/base/steer/FairRunSim.h index 3d845a2ffc..47f3de63d5 100644 --- a/base/steer/FairRunSim.h +++ b/fairroot/base/steer/FairRunSim.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,6 +23,7 @@ #include class FairField; +class FairGeoLoader; class FairMCEventHeader; class FairMesh; class FairModule; @@ -30,7 +31,7 @@ class FairPrimaryGenerator; /** * \brief Configure the Simulation session - * \ingroup base_steer + * \ingroup base_steer fairroot_singleton * @author M. Al-Turany D. Bertini * @version 0.1 * @since 12.01.04 @@ -42,7 +43,7 @@ class FairRunSim : public FairRun FairRunSim(Bool_t isMaster = kTRUE); /** default dtor*/ ~FairRunSim() override; - /** Singelton instance*/ + static FairRunSim* Instance(); /** * Add a module to the simulation (e.g. PIPE, Magnet, ..etc) @@ -190,8 +191,18 @@ class FairRunSim : public FairRun */ FairGenericVMCConfig* GetSimulationConfig() { return fSimulationConfig.get(); } - void SetIsMT(Bool_t isMT) { fIsMT = isMT; } - Bool_t IsMT() const { return fIsMT; } + /** + * Set the MultiThreaded mode, available only for Geant4 + */ + void SetIsMT(bool isMT) { fIsMT = isMT; } + /** + * Read the MultiThreaded mode + */ + bool IsMT() const { return fIsMT; } + /** + * Read the used transport MultiThreaded mode + */ + bool WasMT() const { return fWasMT; } void SetImportTGeoToVMC(Bool_t v) { fImportTGeoToVMC = v; } Bool_t IsImportTGeoToVMC() const { return fImportTGeoToVMC; } @@ -203,12 +214,18 @@ class FairRunSim : public FairRun */ auto GetMCApplication() { return fApp; } + void ls(Option_t* option = "") const override; + private: FairRunSim(const FairRunSim& M); FairRunSim& operator=(const FairRunSim&) { return *this; } void SetMCConfig(); void CheckFlukaExec(); + bool fWasMT{false}; //! /** Actual MT mode used */ + + std::unique_ptr fGeoLoader; //! + protected: Int_t count{0}; //!< Internal counter FairMCApplication* fApp{nullptr}; //!< Main VMC application @@ -229,7 +246,7 @@ class FairRunSim : public FairRun TObjArray* fParticles; //! /** Array of user defined particles*/ TObjArray* ListOfModules; //! /** Array of used modules */ TString MatFname; //! /** Material file name */ - Bool_t fStoreTraj; //! /** Trajectory store flags */ + bool fStoreTraj{false}; //!< Trajectory store flags TString fLoaderName{"TGeo"}; //!< Geometry Model (TGeo or G3) Bool_t fPythiaDecayer; //! /** flag for using Pythia decayer*/ TString fPythiaDecayerConfig; //! /** Macro for Pythia decay configuration*/ @@ -241,7 +258,7 @@ class FairRunSim : public FairRun TObjArray* fMeshList; //! /** radiation grid scoring TString fUserConfig; //! /** Macro for geant configuration*/ TString fUserCuts; //! /** Macro for geant cuts*/ - Bool_t fIsMT; //! /** MT mode option (Geant4 only)*/ + bool fIsMT{false}; //! /** MT mode option (Geant4 only)*/ Bool_t fImportTGeoToVMC; //! /** Allow importing TGeometry to VMC */ std::function fSimSetup; //! /** A user provided function to do sim setup / //! instead of using macros **/ diff --git a/base/steer/FairTSBufferFunctional.cxx b/fairroot/base/steer/FairTSBufferFunctional.cxx similarity index 98% rename from base/steer/FairTSBufferFunctional.cxx rename to fairroot/base/steer/FairTSBufferFunctional.cxx index 9f15ac40b6..4c307bf9b8 100644 --- a/base/steer/FairTSBufferFunctional.cxx +++ b/fairroot/base/steer/FairTSBufferFunctional.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,8 +16,6 @@ #include // for TClonesArray #include // for TTree -ClassImp(FairTSBufferFunctional); - FairTSBufferFunctional::FairTSBufferFunctional(TString branchName, TTree* sourceTree, BinaryFunctor* stopFunction, @@ -51,7 +49,7 @@ TClonesArray* FairTSBufferFunctional::GetData(Double_t stopParameter) if (fStopFunction == 0) { // no function is given ==> read in data in traditional way event by event ReadInNextEntry(); - fOutputArray->AbsorbObjects(static_cast(fInputArray), 0, fInputArray->GetEntriesFast() - 1); + fOutputArray->AbsorbObjects(fInputArray, 0, fInputArray->GetEntriesFast() - 1); return fOutputArray; } if (fVerbose > 1) { diff --git a/base/steer/FairTSBufferFunctional.h b/fairroot/base/steer/FairTSBufferFunctional.h similarity index 97% rename from base/steer/FairTSBufferFunctional.h rename to fairroot/base/steer/FairTSBufferFunctional.h index e9dbfade2d..b3aa21b6ae 100644 --- a/base/steer/FairTSBufferFunctional.h +++ b/fairroot/base/steer/FairTSBufferFunctional.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -44,7 +44,7 @@ class BinaryFunctor virtual bool TimeOut() { return false; } virtual void ResetTimeOut(){}; - virtual ~BinaryFunctor(){}; + virtual ~BinaryFunctor() = default; }; /** @@ -161,7 +161,7 @@ class FairTSBufferFunctional : public TObject BinaryFunctor* stopFunction, BinaryFunctor* startFunction = 0); - ~FairTSBufferFunctional() override {} + ~FairTSBufferFunctional() override = default; TClonesArray* GetData(Double_t stopParameter); TClonesArray* GetData(Double_t startParameter, Double_t stopParameter); Int_t GetBranchIndex() { return fBranchIndex; } diff --git a/base/steer/FairTask.cxx b/fairroot/base/steer/FairTask.cxx similarity index 95% rename from base/steer/FairTask.cxx rename to fairroot/base/steer/FairTask.cxx index bb69a051ee..040d35f381 100644 --- a/base/steer/FairTask.cxx +++ b/fairroot/base/steer/FairTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,7 +10,6 @@ #include "FairTask.h" -#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN #include "FairMonitor.h" // for FairMonitor #include "FairRootManager.h" // for FairRootManager @@ -18,7 +17,8 @@ #include // for TList #include // for TObject #include // printf -#include // pair +#include +#include // pair #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -26,7 +26,6 @@ FairTask::FairTask() : TTask() , fVerbose(0) , fInputPersistance(-1) - , fLogger(FairLogger::GetLogger()) , fStreamProcessing(kFALSE) , fOutputPersistance() {} @@ -35,7 +34,6 @@ FairTask::FairTask(const char* name, Int_t iVerbose) : TTask(name, "FairTask") , fVerbose(iVerbose) , fInputPersistance(-1) - , fLogger(FairLogger::GetLogger()) , fOutputPersistance() {} @@ -257,5 +255,3 @@ Bool_t FairTask::IsOutputBranchPersistent(TString branchName) return kTRUE; } } - -ClassImp(FairTask); diff --git a/base/steer/FairTask.h b/fairroot/base/steer/FairTask.h similarity index 97% rename from base/steer/FairTask.h rename to fairroot/base/steer/FairTask.h index ff527c7422..f8246a3da2 100644 --- a/base/steer/FairTask.h +++ b/fairroot/base/steer/FairTask.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,8 +26,6 @@ #include // for TTask #include -class FairLogger; - enum InitStatus { kSUCCESS, @@ -110,7 +108,6 @@ class FairTask : public TTask protected: Int_t fVerbose; // Verbosity level [[deprecated]] Int_t fInputPersistance; ///< \deprecated Deprecated in v18.8, will be removed in v20. - FairLogger* fLogger; //! Bool_t fStreamProcessing; /** Intialisation at begin of run. To be implemented in the derived class. diff --git a/base/steer/FairTrajFilter.cxx b/fairroot/base/steer/FairTrajFilter.cxx similarity index 98% rename from base/steer/FairTrajFilter.cxx rename to fairroot/base/steer/FairTrajFilter.cxx index a2081fe2e0..cf0fa216cc 100644 --- a/base/steer/FairTrajFilter.cxx +++ b/fairroot/base/steer/FairTrajFilter.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,8 +27,6 @@ using std::cout; using std::endl; -ClassImp(FairTrajFilter); - TMCThreadLocal FairTrajFilter* FairTrajFilter::fgInstance = nullptr; FairTrajFilter* FairTrajFilter::Instance() { return fgInstance; } diff --git a/base/steer/FairTrajFilter.h b/fairroot/base/steer/FairTrajFilter.h similarity index 96% rename from base/steer/FairTrajFilter.h rename to fairroot/base/steer/FairTrajFilter.h index ff158ca0dc..d3a414cb3e 100644 --- a/base/steer/FairTrajFilter.h +++ b/fairroot/base/steer/FairTrajFilter.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,6 +24,7 @@ class TParticle; /** * @class FairTrajFilter + * \ingroup base_steer fairroot_singleton * The filter for storing of the trajectories. * This singleton class controls storing of trajectories * in the gGeoManager list during the simulation. @@ -117,11 +118,7 @@ class FairTrajFilter void Init(TString brName = "GeoTracks", TString folderName = "MCGeoTrack"); void Reset(); - /** - * This function is used to access the methods of the class. - * @return Pointer to the singleton FairTrajFilter object, created - * with FairTrajFilter::FairTrajFilter(). - */ + static FairTrajFilter* Instance(); /** @@ -253,7 +250,8 @@ class FairTrajFilter /** * This is the getter for the total energy cut. - * @param References to the variables where return values should be stored. + * + * \param [out] etotMin,etotMax References to the variables where return values should be stored. */ void GetEnergyCut(Double_t& etotMin, Double_t& etotMax) const; diff --git a/base/steer/FairWriteoutBuffer.cxx b/fairroot/base/steer/FairWriteoutBuffer.cxx similarity index 98% rename from base/steer/FairWriteoutBuffer.cxx rename to fairroot/base/steer/FairWriteoutBuffer.cxx index 211fc716ca..67dd5afa66 100644 --- a/base/steer/FairWriteoutBuffer.cxx +++ b/fairroot/base/steer/FairWriteoutBuffer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,7 +14,6 @@ #include "FairWriteoutBuffer.h" -#include "FairLogger.h" // for FairLogger #include "FairRootManager.h" // for FairRootManager #include // for operator<<, ostream, cout, etc @@ -29,7 +28,6 @@ FairWriteoutBuffer::FairWriteoutBuffer(TString branchName, TString className, TS , fTreeSave(true) , fActivateBuffering(kTRUE) , fVerbose(0) - , fLogger(FairLogger::GetLogger()) { FairRootManager::Instance()->Register(branchName, className, folderName, persistance); fTreeSave = !(fBranchName == "" || fClassName == ""); @@ -274,5 +272,3 @@ void FairWriteoutBuffer::PrintDeadTimeMap() } std::cout << std::endl; } - -ClassImp(FairWriteoutBuffer); diff --git a/base/steer/FairWriteoutBuffer.h b/fairroot/base/steer/FairWriteoutBuffer.h similarity index 96% rename from base/steer/FairWriteoutBuffer.h rename to fairroot/base/steer/FairWriteoutBuffer.h index bf073ac63a..dacc1d6bd1 100644 --- a/base/steer/FairWriteoutBuffer.h +++ b/fairroot/base/steer/FairWriteoutBuffer.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -32,7 +32,6 @@ #ifndef FairWriteoutBuffer_H_ #define FairWriteoutBuffer_H_ -#include "FairLogger.h" // for FairLogger #include "FairRootManager.h" // for FairRootManager #include "FairTimeStamp.h" // for FairTimeStamp @@ -57,9 +56,9 @@ class FairWriteoutBuffer : public TObject , fTreeSave(false) , fActivateBuffering(kFALSE) , fVerbose(0) - , fLogger(FairLogger::GetLogger()){}; + {} FairWriteoutBuffer(TString branchName, TString className, TString folderName, Bool_t persistance); - ~FairWriteoutBuffer() override {} + ~FairWriteoutBuffer() override = default; virtual void SaveDataToTree(Bool_t val = kTRUE) { @@ -137,7 +136,6 @@ class FairWriteoutBuffer : public TObject Bool_t fTreeSave; Bool_t fActivateBuffering; Int_t fVerbose; - FairLogger* fLogger; //! /// FairLogger private: FairWriteoutBuffer(const FairWriteoutBuffer&); diff --git a/base/steer/FairWriteoutBufferAbsBasis.h b/fairroot/base/steer/FairWriteoutBufferAbsBasis.h similarity index 82% rename from base/steer/FairWriteoutBufferAbsBasis.h rename to fairroot/base/steer/FairWriteoutBufferAbsBasis.h index 0bf4f81446..f81047789d 100644 --- a/base/steer/FairWriteoutBufferAbsBasis.h +++ b/fairroot/base/steer/FairWriteoutBufferAbsBasis.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,12 +20,12 @@ class FairWriteoutBufferAbsBasis : public TObject { public: - virtual ~FairWriteoutBufferAbsBasis(){}; + ~FairWriteoutBufferAbsBasis() override = default; virtual void WriteOutData(double time) = 0; virtual void WriteOutAllData() = 0; - ClassDef(FairWriteoutBufferAbsBasis, 1); + ClassDefOverride(FairWriteoutBufferAbsBasis, 1); }; #endif /* FAIRWRITEOUTBUFFERABSBASIS_H_ */ diff --git a/base/steer/README.dox b/fairroot/base/steer/README.dox similarity index 100% rename from base/steer/README.dox rename to fairroot/base/steer/README.dox diff --git a/basemq/CMakeLists.txt b/fairroot/basemq/CMakeLists.txt similarity index 60% rename from basemq/CMakeLists.txt rename to fairroot/basemq/CMakeLists.txt index 61e2b47e3c..a5d78eb0e2 100644 --- a/basemq/CMakeLists.txt +++ b/fairroot/basemq/CMakeLists.txt @@ -10,57 +10,29 @@ set(target BaseMQ) -set(sources - tasks/FairMQProcessorTask.cxx - tasks/FairMQSamplerTask.cxx -) - -fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers) - list(APPEND headers - baseMQtools/baseMQtools.h devices/FairMQLmdSampler.h - devices/FairMQProcessor.h - devices/FairMQSampler.h devices/FairMQUnpacker.h - policies/Sampler/FairMQFileSource.h - policies/Sampler/FairSourceMQInterface.h - policies/Sampler/SimpleTreeReader.h - policies/Serialization/BinaryBaseClassSerializer.h policies/Serialization/BoostSerializer.h - policies/Serialization/IOPolicy.h policies/Serialization/RootSerializer.h - policies/Storage/BinaryOutFileManager.h - policies/Storage/BoostDataSaver.h - policies/Storage/RootOutFileManager.h - policies/Storage/TriviallyCopyableDataSaver.h FairBoostSerializationSupport.h FairHitBoostSerializationSupport.h FairMCPointBoostSerializationSupport.h FairTimeStampBoostSerializationSupport.h ) -add_library(${target} SHARED ${sources} ${headers}) +add_library(${target} INTERFACE) fairroot_library_settings(${target}) -target_include_directories(${target} PUBLIC +target_include_directories(${target} INTERFACE $ $ - $ - $ - $ $ - $ $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} # TClonesArray, TMessage, etc -) - target_link_libraries(${target} - PUBLIC + INTERFACE FairRoot::Base # FairTask, FairRunAna, FairRootFileSink, FairFileSource FairRoot::FairMQ diff --git a/basemq/FairBoostSerializationSupport.h b/fairroot/basemq/FairBoostSerializationSupport.h similarity index 100% rename from basemq/FairBoostSerializationSupport.h rename to fairroot/basemq/FairBoostSerializationSupport.h diff --git a/basemq/FairHitBoostSerializationSupport.h b/fairroot/basemq/FairHitBoostSerializationSupport.h similarity index 100% rename from basemq/FairHitBoostSerializationSupport.h rename to fairroot/basemq/FairHitBoostSerializationSupport.h diff --git a/basemq/FairMCPointBoostSerializationSupport.h b/fairroot/basemq/FairMCPointBoostSerializationSupport.h similarity index 100% rename from basemq/FairMCPointBoostSerializationSupport.h rename to fairroot/basemq/FairMCPointBoostSerializationSupport.h diff --git a/basemq/FairTimeStampBoostSerializationSupport.h b/fairroot/basemq/FairTimeStampBoostSerializationSupport.h similarity index 100% rename from basemq/FairTimeStampBoostSerializationSupport.h rename to fairroot/basemq/FairTimeStampBoostSerializationSupport.h diff --git a/basemq/README.dox b/fairroot/basemq/README.dox similarity index 100% rename from basemq/README.dox rename to fairroot/basemq/README.dox diff --git a/basemq/devices/FairMQLmdSampler.h b/fairroot/basemq/devices/FairMQLmdSampler.h similarity index 98% rename from basemq/devices/FairMQLmdSampler.h rename to fairroot/basemq/devices/FairMQLmdSampler.h index 251481e0f3..06a6f5b8a6 100644 --- a/basemq/devices/FairMQLmdSampler.h +++ b/fairroot/basemq/devices/FairMQLmdSampler.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -245,8 +245,8 @@ class FairMQLmdSampler : public fair::mq::Device fair::mq::Parts parts; // send header - // auto header(fTransportFactory->CreateMessage(fSubEvent, sizeof(fSubEvent), - // free_buffer, nullptr)); fChannels.at(chanName).at(0).SendPart(header); + // auto header(fTransportFactory->CreateMessage(fSubEvent, sizeof(fSubEvent), free_buffer, nullptr)); + // GetChannel(chanName, 0).SendPart(header); int* arraySize = new int(sebuflength); diff --git a/basemq/devices/FairMQUnpacker.h b/fairroot/basemq/devices/FairMQUnpacker.h similarity index 95% rename from basemq/devices/FairMQUnpacker.h rename to fairroot/basemq/devices/FairMQUnpacker.h index 89480e523c..a6eb8e30ef 100644 --- a/basemq/devices/FairMQUnpacker.h +++ b/fairroot/basemq/devices/FairMQUnpacker.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -88,7 +88,9 @@ class FairMQUnpacker : public fair::mq::Device } // check if given channel exist - if (!fChannels.count(fInputChannelName)) { + try { + GetChannel(fInputChannelName); + } catch (const std::out_of_range&) { throw std::runtime_error(std::string("MQ-channel name '") + fInputChannelName + "' does not exist. Check the MQ-channel configuration"); } @@ -105,7 +107,7 @@ class FairMQUnpacker : public fair::mq::Device void Run() { - fair::mq::Channel& inputChannel = fChannels.at(fInputChannelName).at(0); + auto& inputChannel = GetChannel(fInputChannelName); while (!NewStatePending()) { auto msgSize(NewMessage()); diff --git a/basemq/policies/Serialization/BoostSerializer.h b/fairroot/basemq/policies/Serialization/BoostSerializer.h similarity index 100% rename from basemq/policies/Serialization/BoostSerializer.h rename to fairroot/basemq/policies/Serialization/BoostSerializer.h diff --git a/basemq/policies/Serialization/RootSerializer.h b/fairroot/basemq/policies/Serialization/RootSerializer.h similarity index 100% rename from basemq/policies/Serialization/RootSerializer.h rename to fairroot/basemq/policies/Serialization/RootSerializer.h diff --git a/datamatch/CMakeLists.txt b/fairroot/datamatch/CMakeLists.txt similarity index 89% rename from datamatch/CMakeLists.txt rename to fairroot/datamatch/CMakeLists.txt index 081ed07dac..e85aa91963 100644 --- a/datamatch/CMakeLists.txt +++ b/fairroot/datamatch/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -33,11 +33,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairMultiLinkedData, FairRootManager, FairLink diff --git a/datamatch/FairMCDataCrawler.cxx b/fairroot/datamatch/FairMCDataCrawler.cxx similarity index 98% rename from datamatch/FairMCDataCrawler.cxx rename to fairroot/datamatch/FairMCDataCrawler.cxx index 8a5f3633e0..09e00e6b8a 100644 --- a/datamatch/FairMCDataCrawler.cxx +++ b/fairroot/datamatch/FairMCDataCrawler.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,8 +19,6 @@ #include // for operator<<, ostream, cout, etc -ClassImp(FairMCDataCrawler); - FairMCDataCrawler::FairMCDataCrawler() : fIoman(FairRootManager::Instance()) , fFinalStage() diff --git a/datamatch/FairMCDataCrawler.h b/fairroot/datamatch/FairMCDataCrawler.h similarity index 100% rename from datamatch/FairMCDataCrawler.h rename to fairroot/datamatch/FairMCDataCrawler.h diff --git a/datamatch/FairMCEntry.cxx b/fairroot/datamatch/FairMCEntry.cxx similarity index 91% rename from datamatch/FairMCEntry.cxx rename to fairroot/datamatch/FairMCEntry.cxx index e8e50433bd..f3b52a88e4 100644 --- a/datamatch/FairMCEntry.cxx +++ b/fairroot/datamatch/FairMCEntry.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include "FairMCEntry.h" -ClassImp(FairMCEntry); - FairMCEntry::FairMCEntry() : FairMultiLinkedData() , fSource(-1) diff --git a/datamatch/FairMCEntry.h b/fairroot/datamatch/FairMCEntry.h similarity index 100% rename from datamatch/FairMCEntry.h rename to fairroot/datamatch/FairMCEntry.h diff --git a/datamatch/FairMCList.cxx b/fairroot/datamatch/FairMCList.cxx similarity index 87% rename from datamatch/FairMCList.cxx rename to fairroot/datamatch/FairMCList.cxx index 46b7498fb7..25dc2ef97d 100644 --- a/datamatch/FairMCList.cxx +++ b/fairroot/datamatch/FairMCList.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include "FairMCList.h" -ClassImp(FairMCList); - FairMCList::FairMCList() : TObject() , fList() diff --git a/datamatch/FairMCList.h b/fairroot/datamatch/FairMCList.h similarity index 100% rename from datamatch/FairMCList.h rename to fairroot/datamatch/FairMCList.h diff --git a/datamatch/FairMCMatch.cxx b/fairroot/datamatch/FairMCMatch.cxx similarity index 99% rename from datamatch/FairMCMatch.cxx rename to fairroot/datamatch/FairMCMatch.cxx index 9eb775ac67..75930558c7 100644 --- a/datamatch/FairMCMatch.cxx +++ b/fairroot/datamatch/FairMCMatch.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,8 +20,6 @@ #include // for TClonesArray #include // for operator<<, basic_ostream, etc -ClassImp(FairMCMatch); - FairMCMatch::FairMCMatch() : TNamed() , fUltimateStage(0) diff --git a/datamatch/FairMCMatch.h b/fairroot/datamatch/FairMCMatch.h similarity index 100% rename from datamatch/FairMCMatch.h rename to fairroot/datamatch/FairMCMatch.h diff --git a/datamatch/FairMCMatchCreatorTask.cxx b/fairroot/datamatch/FairMCMatchCreatorTask.cxx similarity index 97% rename from datamatch/FairMCMatchCreatorTask.cxx rename to fairroot/datamatch/FairMCMatchCreatorTask.cxx index 4579dc4b65..979f2b5015 100644 --- a/datamatch/FairMCMatchCreatorTask.cxx +++ b/fairroot/datamatch/FairMCMatchCreatorTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -131,5 +131,3 @@ void FairMCMatchCreatorTask::Exec(Option_t* /*opt*/) } void FairMCMatchCreatorTask::Finish() {} - -ClassImp(FairMCMatchCreatorTask); diff --git a/datamatch/FairMCMatchCreatorTask.h b/fairroot/datamatch/FairMCMatchCreatorTask.h similarity index 100% rename from datamatch/FairMCMatchCreatorTask.h rename to fairroot/datamatch/FairMCMatchCreatorTask.h diff --git a/datamatch/FairMCMatchLoaderTask.cxx b/fairroot/datamatch/FairMCMatchLoaderTask.cxx similarity index 97% rename from datamatch/FairMCMatchLoaderTask.cxx rename to fairroot/datamatch/FairMCMatchLoaderTask.cxx index 61eb207808..dad700ec6c 100644 --- a/datamatch/FairMCMatchLoaderTask.cxx +++ b/fairroot/datamatch/FairMCMatchLoaderTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -117,5 +117,3 @@ void FairMCMatchLoaderTask::Exec(Option_t* /*opt*/) } void FairMCMatchLoaderTask::Finish() {} - -ClassImp(FairMCMatchLoaderTask); diff --git a/datamatch/FairMCMatchLoaderTask.h b/fairroot/datamatch/FairMCMatchLoaderTask.h similarity index 100% rename from datamatch/FairMCMatchLoaderTask.h rename to fairroot/datamatch/FairMCMatchLoaderTask.h diff --git a/datamatch/FairMCMatchSelectorTask.cxx b/fairroot/datamatch/FairMCMatchSelectorTask.cxx similarity index 97% rename from datamatch/FairMCMatchSelectorTask.cxx rename to fairroot/datamatch/FairMCMatchSelectorTask.cxx index 6d5c3e044a..94331afc5e 100644 --- a/datamatch/FairMCMatchSelectorTask.cxx +++ b/fairroot/datamatch/FairMCMatchSelectorTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -98,5 +98,3 @@ void FairMCMatchSelectorTask::SetWeights() } void FairMCMatchSelectorTask::Finish() {} - -ClassImp(FairMCMatchSelectorTask); diff --git a/datamatch/FairMCMatchSelectorTask.h b/fairroot/datamatch/FairMCMatchSelectorTask.h similarity index 100% rename from datamatch/FairMCMatchSelectorTask.h rename to fairroot/datamatch/FairMCMatchSelectorTask.h diff --git a/datamatch/FairMCObject.cxx b/fairroot/datamatch/FairMCObject.cxx similarity index 94% rename from datamatch/FairMCObject.cxx rename to fairroot/datamatch/FairMCObject.cxx index edbb0c4d59..e2eab031b7 100644 --- a/datamatch/FairMCObject.cxx +++ b/fairroot/datamatch/FairMCObject.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include "FairMCObject.h" -ClassImp(FairMCObject); - FairMCObject::FairMCObject() : TObject() , fStage(0) @@ -67,14 +65,12 @@ void FairMCObject::AddLink(FairLink link, int index) void FairMCObject::AdoptSize(int index) { - int start = fStage.size(); while (static_cast(fStage.size()) < index + 1) { FairMCEntry myVec; myVec.SetPos(fStage.size()); myVec.SetSource(GetStageId()); myVec.SetPersistanceCheck(kFALSE); fStage.push_back(myVec); - start++; } } diff --git a/datamatch/FairMCObject.h b/fairroot/datamatch/FairMCObject.h similarity index 96% rename from datamatch/FairMCObject.h rename to fairroot/datamatch/FairMCObject.h index 07472af42e..79cdeea744 100644 --- a/datamatch/FairMCObject.h +++ b/fairroot/datamatch/FairMCObject.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -77,7 +77,7 @@ class FairMCObject : public TObject FairMCEntry GetEntry(int index) const { return fStage[index]; } FairLink GetSingleLink(int entryIndex, int linkIndex) const { return fStage.at(entryIndex).GetLink(linkIndex); } - Int_t GetStageId(void) const { return fStageId; } + Int_t GetStageId() const { return fStageId; } FairMCEntry GetMCLink(Int_t index) { return fStage.at(index); } diff --git a/datamatch/FairMCResult.cxx b/fairroot/datamatch/FairMCResult.cxx similarity index 88% rename from datamatch/FairMCResult.cxx rename to fairroot/datamatch/FairMCResult.cxx index 2fca65868c..0f06edeee9 100644 --- a/datamatch/FairMCResult.cxx +++ b/fairroot/datamatch/FairMCResult.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include "FairMCResult.h" -ClassImp(FairMCResult); - FairMCResult::FairMCResult() : FairMCObject() , fStartType(-1) diff --git a/datamatch/FairMCResult.h b/fairroot/datamatch/FairMCResult.h similarity index 91% rename from datamatch/FairMCResult.h rename to fairroot/datamatch/FairMCResult.h index fd8866d3d9..93afa892d4 100644 --- a/datamatch/FairMCResult.h +++ b/fairroot/datamatch/FairMCResult.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -56,8 +56,8 @@ class FairMCResult : public FairMCObject void SetStartType(Int_t start) { fStartType = start; } void SetStopType(Int_t stop) { fStopType = stop; } - Int_t GetStartType(void) const { return fStartType; } - Int_t GetStopType(void) const { return fStopType; } + Int_t GetStartType() const { return fStartType; } + Int_t GetStopType() const { return fStopType; } virtual void PrintInfo(std::ostream& out = std::cout) { out << *this; } diff --git a/datamatch/FairMCStage.cxx b/fairroot/datamatch/FairMCStage.cxx similarity index 90% rename from datamatch/FairMCStage.cxx rename to fairroot/datamatch/FairMCStage.cxx index a2b1329ec5..f2dc07acd6 100644 --- a/datamatch/FairMCStage.cxx +++ b/fairroot/datamatch/FairMCStage.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,8 +14,6 @@ #include "FairMCStage.h" -ClassImp(FairMCStage); - FairMCStage::FairMCStage() : FairMCObject() , fBranchName("") diff --git a/datamatch/FairMCStage.h b/fairroot/datamatch/FairMCStage.h similarity index 89% rename from datamatch/FairMCStage.h rename to fairroot/datamatch/FairMCStage.h index dd63f70729..329e0ac2cd 100644 --- a/datamatch/FairMCStage.h +++ b/fairroot/datamatch/FairMCStage.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -65,11 +65,11 @@ class FairMCStage : public FairMCObject void SetLoaded(Bool_t loaded) { fLoaded = loaded; } void SetFill(Bool_t fill) { fFill = fill; } - std::string GetBranchName(void) const { return fBranchName; } - std::string GetFileName(void) const { return fFileName; } - Double_t GetWeight(void) const { return fWeight; } - Bool_t GetLoaded(void) const { return fLoaded; } - Bool_t GetFill(void) const { return fFill; } + std::string GetBranchName() const { return fBranchName; } + std::string GetFileName() const { return fFileName; } + Double_t GetWeight() const { return fWeight; } + Bool_t GetLoaded() const { return fLoaded; } + Bool_t GetFill() const { return fFill; } virtual void ClearEntries() { diff --git a/datamatch/LinkDef.h b/fairroot/datamatch/LinkDef.h similarity index 100% rename from datamatch/LinkDef.h rename to fairroot/datamatch/LinkDef.h diff --git a/datamatch/README.dox b/fairroot/datamatch/README.dox similarity index 100% rename from datamatch/README.dox rename to fairroot/datamatch/README.dox diff --git a/eventdisplay/CMakeLists.txt b/fairroot/eventdisplay/CMakeLists.txt similarity index 94% rename from eventdisplay/CMakeLists.txt rename to fairroot/eventdisplay/CMakeLists.txt index d7fb6c3254..429ac118df 100644 --- a/eventdisplay/CMakeLists.txt +++ b/fairroot/eventdisplay/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -39,6 +39,8 @@ set(sources tracks/FairEveTracks.cxx tracks/FairGeoTracksDraw.cxx tracks/FairGeoTrackHandler.cxx + xml/FairXMLEveConf.cxx + xml/FairXMLPdgColor.cxx ) fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers) @@ -51,14 +53,10 @@ target_include_directories(${target} PUBLIC $ $ $ + $ $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairRootManager, FairRunAna, FairTSBufferFunctional, FairTimeStamp, FairEventManager diff --git a/eventdisplay/FairBoxSet.cxx b/fairroot/eventdisplay/FairBoxSet.cxx similarity index 90% rename from eventdisplay/FairBoxSet.cxx rename to fairroot/eventdisplay/FairBoxSet.cxx index cc62e1044f..9d87204c89 100644 --- a/eventdisplay/FairBoxSet.cxx +++ b/fairroot/eventdisplay/FairBoxSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,5 +16,3 @@ FairBoxSet::FairBoxSet(FairBoxSetDraw* drawer, const char* name, const char* t) : TEveBoxSet(name, t) , fDraw(drawer) {} - -ClassImp(FairBoxSet); diff --git a/eventdisplay/FairBoxSet.h b/fairroot/eventdisplay/FairBoxSet.h similarity index 100% rename from eventdisplay/FairBoxSet.h rename to fairroot/eventdisplay/FairBoxSet.h diff --git a/eventdisplay/FairBoxSetDraw.cxx b/fairroot/eventdisplay/FairBoxSetDraw.cxx similarity index 98% rename from eventdisplay/FairBoxSetDraw.cxx rename to fairroot/eventdisplay/FairBoxSetDraw.cxx index 3c75f3795c..26db97d3c5 100644 --- a/eventdisplay/FairBoxSetDraw.cxx +++ b/fairroot/eventdisplay/FairBoxSetDraw.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -140,5 +140,3 @@ void FairBoxSetDraw::Reset() gEve->RemoveElement(fq, fEventManager); } } - -ClassImp(FairBoxSetDraw); diff --git a/eventdisplay/FairBoxSetDraw.h b/fairroot/eventdisplay/FairBoxSetDraw.h similarity index 100% rename from eventdisplay/FairBoxSetDraw.h rename to fairroot/eventdisplay/FairBoxSetDraw.h diff --git a/eventdisplay/FairBoxSetEditor.cxx b/fairroot/eventdisplay/FairBoxSetEditor.cxx similarity index 96% rename from eventdisplay/FairBoxSetEditor.cxx rename to fairroot/eventdisplay/FairBoxSetEditor.cxx index eadac15135..a01e6a58cb 100644 --- a/eventdisplay/FairBoxSetEditor.cxx +++ b/fairroot/eventdisplay/FairBoxSetEditor.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,9 +13,6 @@ #include // for TGLayoutHints, etc #include // for TGNumberEntry, etc #include - -class TGWindow; - #include // for operator<<, basic_ostream, etc // FairBoxSetEditor @@ -23,8 +20,6 @@ class TGWindow; // Specialization of TGedEditor for proper update propagation to // TEveManager. -ClassImp(FairBoxSetEditor); - FairBoxSetEditor::FairBoxSetEditor(const TGWindow* p, Int_t width, Int_t height, UInt_t options, Pixel_t back) : TGedFrame(p, width, height, options | kVerticalFrame, back) , fInfoFrame(nullptr) diff --git a/eventdisplay/FairBoxSetEditor.h b/fairroot/eventdisplay/FairBoxSetEditor.h similarity index 100% rename from eventdisplay/FairBoxSetEditor.h rename to fairroot/eventdisplay/FairBoxSetEditor.h diff --git a/eventdisplay/FairEventManager.cxx b/fairroot/eventdisplay/FairEventManager.cxx similarity index 71% rename from eventdisplay/FairEventManager.cxx rename to fairroot/eventdisplay/FairEventManager.cxx index c4b33003b5..afd6da4e06 100644 --- a/eventdisplay/FairEventManager.cxx +++ b/fairroot/eventdisplay/FairEventManager.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -39,11 +39,12 @@ #include // for TGeoVolume #include -ClassImp(FairEventManager); +FairEventManager* FairEventManager::fgRinstance = nullptr; -FairEventManager *FairEventManager::fgRinstance = nullptr; - -FairEventManager *FairEventManager::Instance() { return fgRinstance; } +FairEventManager* FairEventManager::Instance() +{ + return fgRinstance; +} FairEventManager::FairEventManager() : TEveEventManager("FairEventManager", "") @@ -59,75 +60,14 @@ FairEventManager::FairEventManager() , fTimeEvent(-1.) , fAnimatedTracks(kFALSE) , fClearHandler(kTRUE) - , fEvent(0) , fRPhiPlane{0, 0, 10, 0} , fRhoZPlane{-1, 0, 0, 0} , fRphiCam(TGLViewer::kCameraOrthoXOY) , fRhoCam(TGLViewer::kCameraOrthoZOY) - , fRPhiView(nullptr) - , fRhoZView(nullptr) - , fMultiView(nullptr) - , fMultiRPhiView(nullptr) - , fMultiRhoZView(nullptr) - , fRPhiScene(nullptr) - , fRhoZScene(nullptr) - , fRPhiProjManager(nullptr) - , fRhoZProjManager(nullptr) - , fAxesPhi(nullptr) - , fAxesRho(nullptr) , fXMLConfig("") { fgRinstance = this; AddParticlesToPdgDataBase(); - fPDGToColor[22] = 623; // photon - fPDGToColor[-2112] = 2; // anti-neutron - fPDGToColor[-11] = 3; // e+ - fPDGToColor[-3122] = 4; // anti-lambda - fPDGToColor[11] = 5; // e- - fPDGToColor[-3222] = 6; // Sigma - - fPDGToColor[12] = 7; // e-neutrino - fPDGToColor[-3212] = 8; // Sigma0 - fPDGToColor[-13] = 9; // mu+ - fPDGToColor[-3112] = 10; // Sigma+ (PB - fPDGToColor[13] = 11; // mu- - fPDGToColor[-3322] = 12; // Xi0 - fPDGToColor[111] = 13; // pi0 - fPDGToColor[-3312] = 14; // Xi+ - fPDGToColor[211] = 15; // pi+ - fPDGToColor[-3334] = 16; // Omega+ (PB) - fPDGToColor[-211] = 17; // pi- - fPDGToColor[-15] = 18; // tau+ - fPDGToColor[130] = 19; // K long - fPDGToColor[15] = 20; // tau - - fPDGToColor[321] = 21; // K+ - fPDGToColor[411] = 22; // D+ - fPDGToColor[-321] = 23; // K- - fPDGToColor[-411] = 24; // D- - fPDGToColor[2112] = 25; // n - fPDGToColor[421] = 26; // D0 - fPDGToColor[2212] = 27; // p - fPDGToColor[-421] = 28; // D0 - fPDGToColor[-2212] = 29; // anti-proton - fPDGToColor[431] = 30; // Ds+ - fPDGToColor[310] = 31; // K short - fPDGToColor[-431] = 32; // anti Ds- - fPDGToColor[221] = 33; // eta - fPDGToColor[4122] = 34; // Lambda_C+ - fPDGToColor[3122] = 35; // Lambda - fPDGToColor[24] = 36; // W+ - fPDGToColor[3222] = 37; // Sigma+ - fPDGToColor[-24] = 38; // W- - fPDGToColor[3212] = 39; // Sigma0 - fPDGToColor[23] = 40; // Z - fPDGToColor[3112] = 41; // Sigma - - fPDGToColor[3322] = 42; // Xi0 - fPDGToColor[3312] = 43; // Xi- - fPDGToColor[3334] = 44; // Omega- (PB) - fPDGToColor[50000050] = 801; // Cerenkov - fPDGToColor[1000010020] = 45; - fPDGToColor[1000010030] = 48; - fPDGToColor[1000020040] = 50; - fPDGToColor[1000020030] = 55; } void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds) @@ -136,9 +76,9 @@ void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds) fRunAna->Init(); if (gGeoManager == nullptr) return; - TGeoNode *N = gGeoManager->GetTopNode(); - TEveGeoTopNode *TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds); - TGeoBBox *box = dynamic_cast(gGeoManager->GetTopNode()->GetVolume()->GetShape()); + TGeoNode* N = gGeoManager->GetTopNode(); + auto TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds); + auto box = dynamic_cast(gGeoManager->GetTopNode()->GetVolume()->GetShape()); if (box) { fWorldSizeX = box->GetDX(); fWorldSizeY = box->GetDY(); @@ -167,8 +107,8 @@ void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds) SetViewers(fRPhiView, fRhoZView); - TEveWindowSlot *MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); - TEveWindowPack *MultiPack = MultiSlot->MakePack(); + TEveWindowSlot* MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight()); + TEveWindowPack* MultiPack = MultiSlot->MakePack(); MultiPack->SetElementName("Multi View"); MultiPack->SetHorizontal(); MultiPack->SetShowTitleBar(kFALSE); @@ -239,7 +179,7 @@ void FairEventManager::GotoEvent(Int_t event) fEntry = event; fTimeMin = 0; fTimeMax = DBL_MAX; - fRunAna->Run(static_cast(event)); + fRunAna->RunSingleEntry(fEntry); } void FairEventManager::NextEvent() @@ -247,7 +187,7 @@ void FairEventManager::NextEvent() fEntry += 1; fTimeMin = 0; fTimeMax = DBL_MAX; - fRunAna->Run(static_cast(fEntry)); + fRunAna->RunSingleEntry(fEntry); } void FairEventManager::PrevEvent() @@ -255,26 +195,18 @@ void FairEventManager::PrevEvent() fEntry -= 1; fTimeMin = 0; fTimeMax = DBL_MAX; - fRunAna->Run(static_cast(fEntry)); + fRunAna->RunSingleEntry(fEntry); } void FairEventManager::Close() {} void FairEventManager::DisplaySettings() {} -Int_t FairEventManager::Color(int pdg) -{ - if (fPDGToColor.find(pdg) != fPDGToColor.end()) { - return fPDGToColor[pdg]; - } - return 0; -} - void FairEventManager::AddParticlesToPdgDataBase(Int_t /*pdg*/) { // Add particles to the PDG data base - TDatabasePDG *pdgDB = TDatabasePDG::Instance(); + TDatabasePDG* pdgDB = TDatabasePDG::Instance(); const Double_t kAu2Gev = 0.9314943228; const Double_t khSlash = 1.0545726663e-27; @@ -307,9 +239,12 @@ void FairEventManager::AddParticlesToPdgDataBase(Int_t /*pdg*/) pdgDB->AddParticle("FeedbackPhoton", "FeedbackPhoton", 0, kFALSE, 0, 0, "Special", 50000051); } -TVector3 FairEventManager::GetWorldSize() const { return TVector3(fWorldSizeX, fWorldSizeY, fWorldSizeZ); } +TVector3 FairEventManager::GetWorldSize() const +{ + return TVector3(fWorldSizeX, fWorldSizeY, fWorldSizeZ); +} -void FairEventManager::SetViewers(TEveViewer *RPhi, TEveViewer *RhoZ) +void FairEventManager::SetViewers(TEveViewer* RPhi, TEveViewer* RhoZ) { RPhi->GetGLViewer()->SetCurrentCamera(fRphiCam); // set clip plane and camera parameters @@ -377,14 +312,14 @@ void FairEventManager::LoadXMLSettings() FairXMLNode *color = colors->GetChild(j); TString pgd_code = color->GetAttrib("pdg")->GetValue(); TString color_code = color->GetAttrib("color")->GetValue(); - fPDGToColor[pgd_code.Atoi()] = StringToColor(color_code); + fPDGColor.SetColor(pgd_code.Atoi(), FairXMLPdgColor::StringToColor(color_code)); } } } gEve->Redraw3D(); } -void FairEventManager::LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t depth) +void FairEventManager::LoadXMLDetector(TGeoNode* node, FairXMLNode* xml, Int_t depth) { TString name = xml->GetAttrib("name")->GetValue(); TString node_name = node->GetName(); @@ -394,8 +329,8 @@ void FairEventManager::LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t d TString transparency = xml->GetAttrib("transparency")->GetValue(); TString color = xml->GetAttrib("color")->GetValue(); if (!color.EqualTo("")) { - node->GetVolume()->SetFillColor(StringToColor(color)); - node->GetVolume()->SetLineColor(StringToColor(color)); + node->GetVolume()->SetFillColor(FairXMLPdgColor::StringToColor(color)); + node->GetVolume()->SetLineColor(FairXMLPdgColor::StringToColor(color)); } if (!transparency.EqualTo("")) { node->GetVolume()->SetTransparency((Char_t)(transparency.Atoi())); @@ -425,75 +360,18 @@ void FairEventManager::LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t d } } -Int_t FairEventManager::StringToColor(TString color) const -{ - if (color.Contains("k")) { - Int_t plus_index = color.First('+'); - Int_t minus_index = color.First('-'); - Int_t cut = plus_index; - if (cut == -1) - cut = minus_index; - if (cut == -1) - cut = color.Length(); - TString col_name(color(0, cut)); - Int_t col_val = 0; - if (col_name.EqualTo("kWhite")) { - col_val = 0; - } else if (col_name.EqualTo("kBlack")) { - col_val = 1; - } else if (col_name.EqualTo("kGray")) { - col_val = 920; - } else if (col_name.EqualTo("kRed")) { - col_val = 632; - } else if (col_name.EqualTo("kGreen")) { - col_val = 416; - } else if (col_name.EqualTo("kBlue")) { - col_val = 600; - } else if (col_name.EqualTo("kYellow")) { - col_val = 400; - } else if (col_name.EqualTo("kMagenta")) { - col_val = 616; - } else if (col_name.EqualTo("kCyan")) { - col_val = 432; - } else if (col_name.EqualTo("kOrange")) { - col_val = 800; - } else if (col_name.EqualTo("kSpring")) { - col_val = 820; - } else if (col_name.EqualTo("kTeal")) { - col_val = 840; - } else if (col_name.EqualTo("kAzure")) { - col_val = 860; - } else if (col_name.EqualTo("kViolet")) { - col_val = 880; - } else if (col_name.EqualTo("kPink")) { - col_val = 900; - } - TString col_num(color(cut + 1, color.Length())); - if (col_num.Length() > 0) { - if (color.Contains("+")) { - col_val += col_num.Atoi(); - } else { - col_val -= col_num.Atoi(); - } - } - return col_val; - } else { - return color.Atoi(); - } -} - void FairEventManager::SetTransparency(Bool_t use_xml, Int_t trans) { if (!use_xml) { // high transparency Int_t vis_level = gGeoManager->GetVisLevel(); - TGeoNode *top = gGeoManager->GetTopNode(); + TGeoNode* top = gGeoManager->GetTopNode(); SetTransparencyForLayer(top, vis_level, trans); } else { // normal transparency if (fXMLConfig != "") { LoadXMLSettings(); } else { Int_t vis_level = gGeoManager->GetVisLevel(); - TGeoNode *top = gGeoManager->GetTopNode(); + TGeoNode* top = gGeoManager->GetTopNode(); SetTransparencyForLayer(top, vis_level, 0); } } @@ -504,15 +382,18 @@ void FairEventManager::SetTransparency(Bool_t use_xml, Int_t trans) } } -void FairEventManager::SwitchBackground(Bool_t light) { gEve->GetViewers()->SwitchColorSet(); } +void FairEventManager::SwitchBackground(Bool_t /*light*/) +{ + gEve->GetViewers()->SwitchColorSet(); +} -void FairEventManager::SetTransparencyForLayer(TGeoNode *node, Int_t depth, Char_t transparency) +void FairEventManager::SetTransparencyForLayer(TGeoNode* node, Int_t depth, Char_t transparency) { node->GetVolume()->SetTransparency(transparency); if (depth <= 0) return; for (int i = 0; i < node->GetNdaughters(); i++) { - TGeoNode *dau = node->GetDaughter(i); + TGeoNode* dau = node->GetDaughter(i); SetTransparencyForLayer(dau, depth - 1, transparency); } } @@ -521,7 +402,7 @@ void FairEventManager::MakeScreenshot(FairEveAnimationControl::eScreenshotType p { TString filename; if (path == "") { - const char *filetypes[] = {"PNG", "*.png", "JPG", "*.jpg", 0, 0}; + const char* filetypes[] = {"PNG", "*.png", "JPG", "*.jpg", nullptr, nullptr}; TGFileInfo fi; fi.fFileTypes = filetypes; fi.fIniDir = StrDup("."); @@ -537,13 +418,13 @@ void FairEventManager::MakeScreenshot(FairEveAnimationControl::eScreenshotType p gEve->GetDefaultGLViewer()->SavePicture(filename); } break; case FairEveAnimationControl::eScreenshotType::kXY: { - TEveViewer *view = GetRPhiView(); - TGLViewer *gl = view->GetGLViewer(); + TEveViewer* view = GetRPhiView(); + TGLViewer* gl = view->GetGLViewer(); gl->SavePicture(filename); } break; case FairEveAnimationControl::eScreenshotType::kZ: { - TEveViewer *view = GetRhoZView(); - TGLViewer *gl = view->GetGLViewer(); + TEveViewer* view = GetRhoZView(); + TGLViewer* gl = view->GetGLViewer(); gl->SavePicture(filename); } break; case FairEveAnimationControl::eScreenshotType::kAll: { @@ -553,8 +434,8 @@ void FairEventManager::MakeScreenshot(FairEveAnimationControl::eScreenshotType p TString filenameRphi = Form("%s_XY.%s", filename_path.Data(), filename_ext.Data()); TString filenameRhoz = Form("%s_Z.%s", filename_path.Data(), filename_ext.Data()); gEve->GetDefaultGLViewer()->SavePicture(filename3d); - TEveViewer *view = GetRPhiView(); - TGLViewer *gl = view->GetGLViewer(); + TEveViewer* view = GetRPhiView(); + TGLViewer* gl = view->GetGLViewer(); gl->SavePicture(filenameRphi); view = GetRhoZView(); gl = view->GetGLViewer(); diff --git a/eventdisplay/FairEventManager.h b/fairroot/eventdisplay/FairEventManager.h similarity index 59% rename from eventdisplay/FairEventManager.h rename to fairroot/eventdisplay/FairEventManager.h index 9e2d532303..f4b8004628 100644 --- a/eventdisplay/FairEventManager.h +++ b/fairroot/eventdisplay/FairEventManager.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,6 +14,7 @@ #include "FairEveAnimationControl.h" #include "FairRunAna.h" // for FairRunAna +#include "FairXMLPdgColor.h" #include // for Float_t, Int_t, Bool_t, etc #include // for TEveEventManager @@ -34,10 +35,13 @@ class TEveText; class TGeoNode; class TGListTreeItem; +/** + * \ingroup eventdisplay fairroot_singleton + */ class FairEventManager : public TEveEventManager { public: - static FairEventManager *Instance(); + static FairEventManager* Instance(); FairEventManager(); virtual ~FairEventManager(); virtual void SetXMLConfig(TString xml_config) { fXMLConfig = xml_config; }; @@ -47,8 +51,8 @@ class FairEventManager : public TEveEventManager virtual void PrevEvent(); // *MENU* virtual void Close(); virtual void DisplaySettings(); // *Menu* - virtual Int_t Color(Int_t pdg); - void AddTask(FairTask *t) { fRunAna->AddTask(t); } + virtual Int_t Color(Int_t pdg) { return fPDGColor.GetColor(pdg); } + void AddTask(FairTask* t) { fRunAna->AddTask(t); } virtual void Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000); virtual Int_t GetCurrentEvent() { return fEntry; } /** @@ -80,7 +84,7 @@ class FairEventManager : public TEveEventManager fTimeMin = min; fTimeMax = max; }; - void GetTimeLimits(Double_t &min, Double_t &max) + void GetTimeLimits(Double_t& min, Double_t& max) { min = fTimeMin; max = fTimeMax; @@ -117,7 +121,8 @@ class FairEventManager : public TEveEventManager virtual Float_t GetMaxEnergy() { return 1E+9; } virtual Float_t GetMinEnergy() { return 0; } TVector3 GetWorldSize() const; - Float_t GetEvtTime(); ///< current time in ns to display in the event display. Either set value or event time taken from FairRootManager. Controlled via fUseTimeOfEvent + Float_t GetEvtTime(); ///< current time in ns to display in the event display. Either set value or event time + ///< taken from FairRootManager. Controlled via fUseTimeOfEvent Bool_t GetUseTimeOfEvent() const { return fUseTimeOfEvent; } Bool_t GetDrawAnimatedTracks() const { return fAnimatedTracks; } Bool_t GetClearHandler() const { return fClearHandler; } @@ -134,56 +139,59 @@ class FairEventManager : public TEveEventManager ClassDef(FairEventManager, 1); protected: - TEveViewer *GetRPhiView() const { return fRPhiView; }; - TEveViewer *GetRhoZView() const { return fRhoZView; }; - TEveViewer *GetMultiView() const { return fMultiView; }; - TEveViewer *GetMultiRPhiView() const { return fMultiRPhiView; }; - TEveViewer *GetMultiRhoZView() const { return fMultiRhoZView; }; - TEveScene *GetRhoZScene() const { return fRhoZScene; }; - TEveScene *GetRPhiScene() const { return fRPhiScene; }; - TEveProjectionManager *GetRhoZProjManager() const { return fRhoZProjManager; }; - TEveProjectionManager *GetRPhiProjManager() const { return fRPhiProjManager; }; - TEveProjectionAxes *GetRPhiAxes() const { return fAxesPhi; }; - TEveProjectionAxes *GetRhoZAxes() const { return fAxesRho; }; + TEveViewer* GetRPhiView() const { return fRPhiView; }; + TEveViewer* GetRhoZView() const { return fRhoZView; }; + TEveViewer* GetMultiView() const { return fMultiView; }; + TEveViewer* GetMultiRPhiView() const { return fMultiRPhiView; }; + TEveViewer* GetMultiRhoZView() const { return fMultiRhoZView; }; + TEveScene* GetRhoZScene() const { return fRhoZScene; }; + TEveScene* GetRPhiScene() const { return fRPhiScene; }; + TEveProjectionManager* GetRhoZProjManager() const { return fRhoZProjManager; }; + TEveProjectionManager* GetRPhiProjManager() const { return fRPhiProjManager; }; + TEveProjectionAxes* GetRPhiAxes() const { return fAxesPhi; }; + TEveProjectionAxes* GetRhoZAxes() const { return fAxesRho; }; virtual void LoadXMLSettings(); - void LoadXMLDetector(TGeoNode *node, FairXMLNode *xml, Int_t depth = 0); - Int_t StringToColor(TString color) const; + void LoadXMLDetector(TGeoNode* node, FairXMLNode* xml, Int_t depth = 0); + [[deprecated("Use FairXMLPdgColor::StringToColor")]] Int_t StringToColor(const TString& color) const + { + return FairXMLPdgColor::StringToColor(color); + } private: - FairRunAna* fRunAna; //! - FairRootManager& fRootManager; //! - Int_t fEntry; //! - Double_t fWorldSizeX, fWorldSizeY, fWorldSizeZ; //! - Double_t fTimeMin, fTimeMax; //! - Bool_t fUseTimeOfEvent; //! - Double_t fTimeEvent; //! - Bool_t fAnimatedTracks; //! - Bool_t fClearHandler; //! - TGListTreeItem *fEvent; //! - Double_t fRPhiPlane[4]; //! - Double_t fRhoZPlane[4]; //! - TGLViewer::ECameraType fRphiCam; //! - TGLViewer::ECameraType fRhoCam; //! - TEveViewer *fRPhiView; //! - TEveViewer *fRhoZView; //! - TEveViewer *fMultiView; //! - TEveViewer *fMultiRPhiView; //! - TEveViewer *fMultiRhoZView; //! - TEveScene *fRPhiScene; //! - TEveScene *fRhoZScene; //! - TEveProjectionManager *fRPhiProjManager; //! - TEveProjectionManager *fRhoZProjManager; //! - TEveProjectionAxes *fAxesPhi; //! - TEveProjectionAxes *fAxesRho; //! - TEveText* fEventTimeText{nullptr}; //! - TEveText* fEventNumberText{nullptr}; //! + FairRunAna* fRunAna; //! + FairRootManager& fRootManager; //! + Int_t fEntry; //! + Double_t fWorldSizeX, fWorldSizeY, fWorldSizeZ; //! + Double_t fTimeMin, fTimeMax; //! + Bool_t fUseTimeOfEvent; //! + Double_t fTimeEvent; //! + Bool_t fAnimatedTracks; //! + Bool_t fClearHandler; //! + TGListTreeItem* fEvent{nullptr}; //! + Double_t fRPhiPlane[4]; //! + Double_t fRhoZPlane[4]; //! + TGLViewer::ECameraType fRphiCam; //! + TGLViewer::ECameraType fRhoCam; //! + TEveViewer* fRPhiView{nullptr}; //! + TEveViewer* fRhoZView{nullptr}; //! + TEveViewer* fMultiView{nullptr}; //! + TEveViewer* fMultiRPhiView{nullptr}; //! + TEveViewer* fMultiRhoZView{nullptr}; //! + TEveScene* fRPhiScene{nullptr}; //! + TEveScene* fRhoZScene{nullptr}; //! + TEveProjectionManager* fRPhiProjManager{nullptr}; //! + TEveProjectionManager* fRhoZProjManager{nullptr}; //! + TEveProjectionAxes* fAxesPhi{nullptr}; //! + TEveProjectionAxes* fAxesRho{nullptr}; //! + TEveText* fEventTimeText{nullptr}; //! + TEveText* fEventNumberText{nullptr}; //! + FairXMLPdgColor fPDGColor{}; //! TString fXMLConfig; - std::map fPDGToColor; - void SetTransparencyForLayer(TGeoNode *node, Int_t depth, Char_t transparency); - static FairEventManager *fgRinstance; //! - FairEventManager(const FairEventManager &); - FairEventManager &operator=(const FairEventManager &); - void SetViewers(TEveViewer *RPhi, TEveViewer *RhoZ); + void SetTransparencyForLayer(TGeoNode* node, Int_t depth, Char_t transparency); + static FairEventManager* fgRinstance; //! + FairEventManager(const FairEventManager&); + FairEventManager& operator=(const FairEventManager&); + void SetViewers(TEveViewer* RPhi, TEveViewer* RhoZ); }; #endif diff --git a/eventdisplay/FairEventManagerEditor.cxx b/fairroot/eventdisplay/FairEventManagerEditor.cxx similarity index 98% rename from eventdisplay/FairEventManagerEditor.cxx rename to fairroot/eventdisplay/FairEventManagerEditor.cxx index 6deaae1053..b9ca87a96e 100644 --- a/eventdisplay/FairEventManagerEditor.cxx +++ b/fairroot/eventdisplay/FairEventManagerEditor.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,8 +30,6 @@ #include // for TSystem, gSystem #include #include // for unique_ptr -class TGWindow; // lines 36-36 -class TObject; // lines 37-37 #define MAXE 5000 @@ -40,8 +38,6 @@ class TObject; // lines 37-37 // Specialization of TGedEditor for proper update propagation to // TEveManager. -ClassImp(FairEventManagerEditor); - FairEventManagerEditor::FairEventManagerEditor(const TGWindow* p, Int_t width, Int_t height, diff --git a/eventdisplay/FairEventManagerEditor.h b/fairroot/eventdisplay/FairEventManagerEditor.h similarity index 95% rename from eventdisplay/FairEventManagerEditor.h rename to fairroot/eventdisplay/FairEventManagerEditor.h index 27dbf8cd38..08fddb57aa 100644 --- a/eventdisplay/FairEventManagerEditor.h +++ b/fairroot/eventdisplay/FairEventManagerEditor.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,8 +23,7 @@ class TClass; class TGComboBox; // lines 22-22 class TGLabel; // lines 27-27 class TGNumberEntry; // lines 28-28 -class TGWindow; // lines 29-29 -class TMemberInspector; +class TGWindow; class TObject; // lines 30-30 class FairEventManagerEditor : public TGedFrame diff --git a/eventdisplay/FairGetEventTime.cxx b/fairroot/eventdisplay/FairGetEventTime.cxx similarity index 98% rename from eventdisplay/FairGetEventTime.cxx rename to fairroot/eventdisplay/FairGetEventTime.cxx index cedd562d1f..d99e45ae77 100644 --- a/eventdisplay/FairGetEventTime.cxx +++ b/fairroot/eventdisplay/FairGetEventTime.cxx @@ -53,5 +53,3 @@ std::pair FairGetEventTime::GetEvent(double simTime) const } return std::make_pair(evtIndex, evtTime); } - -ClassImp(FairGetEventTime); diff --git a/eventdisplay/FairGetEventTime.h b/fairroot/eventdisplay/FairGetEventTime.h similarity index 100% rename from eventdisplay/FairGetEventTime.h rename to fairroot/eventdisplay/FairGetEventTime.h diff --git a/eventdisplay/FairHitDraw.cxx b/fairroot/eventdisplay/FairHitDraw.cxx similarity index 89% rename from eventdisplay/FairHitDraw.cxx rename to fairroot/eventdisplay/FairHitDraw.cxx index 2a51fb9cb9..635fc76fde 100644 --- a/eventdisplay/FairHitDraw.cxx +++ b/fairroot/eventdisplay/FairHitDraw.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,8 +16,6 @@ #include "FairHit.h" // for FairHit -class TObject; - FairHitDraw::FairHitDraw() {} FairHitDraw::FairHitDraw(const char* name, FairDataSourceI* dataSource, Int_t iVerbose) @@ -33,5 +31,3 @@ TVector3 FairHitDraw::GetVector(TObject* obj) FairHit* hit = static_cast(obj); return TVector3(hit->GetX(), hit->GetY(), hit->GetZ()); } - -ClassImp(FairHitDraw); diff --git a/eventdisplay/FairHitDraw.h b/fairroot/eventdisplay/FairHitDraw.h similarity index 90% rename from eventdisplay/FairHitDraw.h rename to fairroot/eventdisplay/FairHitDraw.h index b9639bafef..b25e7e244f 100644 --- a/eventdisplay/FairHitDraw.h +++ b/fairroot/eventdisplay/FairHitDraw.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +22,6 @@ #include // for FairHitDraw::Class, etc #include // for TVector3 -class TObject; - class FairHitDraw : public FairBoxSetDraw { public: @@ -38,7 +36,6 @@ class FairHitDraw : public FairBoxSetDraw /** Legacy constructor *@param name Name of task - *@param dataSource Input container for data to be displayed *@param iVerbose Verbosity level **/ FairHitDraw(const char* name, Int_t iVerbose = 1); diff --git a/eventdisplay/FairHitPointSetDraw.cxx b/fairroot/eventdisplay/FairHitPointSetDraw.cxx similarity index 91% rename from eventdisplay/FairHitPointSetDraw.cxx rename to fairroot/eventdisplay/FairHitPointSetDraw.cxx index 130e1bd225..8cff092fee 100644 --- a/eventdisplay/FairHitPointSetDraw.cxx +++ b/fairroot/eventdisplay/FairHitPointSetDraw.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -38,5 +38,3 @@ TVector3 FairHitPointSetDraw::GetVector(TObject* obj) return TVector3(p->GetX(), p->GetY(), p->GetZ()); } - -ClassImp(FairHitPointSetDraw); diff --git a/eventdisplay/FairHitPointSetDraw.h b/fairroot/eventdisplay/FairHitPointSetDraw.h similarity index 100% rename from eventdisplay/FairHitPointSetDraw.h rename to fairroot/eventdisplay/FairHitPointSetDraw.h diff --git a/eventdisplay/FairMCPointDraw.cxx b/fairroot/eventdisplay/FairMCPointDraw.cxx similarity index 90% rename from eventdisplay/FairMCPointDraw.cxx rename to fairroot/eventdisplay/FairMCPointDraw.cxx index aa3e485108..bcbdb2c3b0 100644 --- a/eventdisplay/FairMCPointDraw.cxx +++ b/fairroot/eventdisplay/FairMCPointDraw.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,5 +35,3 @@ TVector3 FairMCPointDraw::GetVector(TObject* obj) FairMCPoint* p = static_cast(obj); return TVector3(p->GetX(), p->GetY(), p->GetZ()); } - -ClassImp(FairMCPointDraw); diff --git a/eventdisplay/FairMCPointDraw.h b/fairroot/eventdisplay/FairMCPointDraw.h similarity index 100% rename from eventdisplay/FairMCPointDraw.h rename to fairroot/eventdisplay/FairMCPointDraw.h diff --git a/eventdisplay/FairPointSetDraw.cxx b/fairroot/eventdisplay/FairPointSetDraw.cxx similarity index 97% rename from eventdisplay/FairPointSetDraw.cxx rename to fairroot/eventdisplay/FairPointSetDraw.cxx index 7f7985b9a2..8e8ac26a80 100644 --- a/eventdisplay/FairPointSetDraw.cxx +++ b/fairroot/eventdisplay/FairPointSetDraw.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,6 @@ #include // for TVector3 #include // for operator<<, basic_ostream, etc -class TObject; - FairPointSetDraw::FairPointSetDraw() : FairTask("FairPointSetDraw", 0) , fVerbose(0) @@ -129,5 +127,3 @@ void FairPointSetDraw::Reset() gEve->RemoveElement(fq, FairEventManager::Instance()); } } - -ClassImp(FairPointSetDraw); diff --git a/eventdisplay/FairPointSetDraw.h b/fairroot/eventdisplay/FairPointSetDraw.h similarity index 100% rename from eventdisplay/FairPointSetDraw.h rename to fairroot/eventdisplay/FairPointSetDraw.h diff --git a/eventdisplay/FairXMLNode.cxx b/fairroot/eventdisplay/FairXMLNode.cxx similarity index 100% rename from eventdisplay/FairXMLNode.cxx rename to fairroot/eventdisplay/FairXMLNode.cxx diff --git a/eventdisplay/FairXMLNode.h b/fairroot/eventdisplay/FairXMLNode.h similarity index 100% rename from eventdisplay/FairXMLNode.h rename to fairroot/eventdisplay/FairXMLNode.h diff --git a/eventdisplay/LinkDef.h b/fairroot/eventdisplay/LinkDef.h similarity index 100% rename from eventdisplay/LinkDef.h rename to fairroot/eventdisplay/LinkDef.h diff --git a/eventdisplay/README.dox b/fairroot/eventdisplay/README.dox similarity index 100% rename from eventdisplay/README.dox rename to fairroot/eventdisplay/README.dox diff --git a/eventdisplay/datasource/FairDataSourceI.cxx b/fairroot/eventdisplay/datasource/FairDataSourceI.cxx similarity index 96% rename from eventdisplay/datasource/FairDataSourceI.cxx rename to fairroot/eventdisplay/datasource/FairDataSourceI.cxx index 5e743bf687..8ce5d9a642 100644 --- a/eventdisplay/datasource/FairDataSourceI.cxx +++ b/fairroot/eventdisplay/datasource/FairDataSourceI.cxx @@ -11,8 +11,6 @@ #include #include -ClassImp(FairDataSourceI); - FairDataSourceI::FairDataSourceI() { // TODO Auto-generated constructor stub diff --git a/eventdisplay/datasource/FairDataSourceI.h b/fairroot/eventdisplay/datasource/FairDataSourceI.h similarity index 100% rename from eventdisplay/datasource/FairDataSourceI.h rename to fairroot/eventdisplay/datasource/FairDataSourceI.h diff --git a/eventdisplay/datasource/FairTCASource.cxx b/fairroot/eventdisplay/datasource/FairTCASource.cxx similarity index 76% rename from eventdisplay/datasource/FairTCASource.cxx rename to fairroot/eventdisplay/datasource/FairTCASource.cxx index 1dcc50e759..5f749859f6 100644 --- a/eventdisplay/datasource/FairTCASource.cxx +++ b/fairroot/eventdisplay/datasource/FairTCASource.cxx @@ -5,10 +5,7 @@ * \author Tobias Stockmanns */ -#include -#include - -ClassImp(FairTCASource); +#include "FairTCASource.h" FairTCASource::FairTCASource() { diff --git a/eventdisplay/datasource/FairTCASource.h b/fairroot/eventdisplay/datasource/FairTCASource.h similarity index 100% rename from eventdisplay/datasource/FairTCASource.h rename to fairroot/eventdisplay/datasource/FairTCASource.h diff --git a/eventdisplay/datasource/FairTimebasedDataHandlerT.cxx b/fairroot/eventdisplay/datasource/FairTimebasedDataHandlerT.cxx similarity index 100% rename from eventdisplay/datasource/FairTimebasedDataHandlerT.cxx rename to fairroot/eventdisplay/datasource/FairTimebasedDataHandlerT.cxx diff --git a/eventdisplay/datasource/FairTimebasedDataHandlerT.h b/fairroot/eventdisplay/datasource/FairTimebasedDataHandlerT.h similarity index 100% rename from eventdisplay/datasource/FairTimebasedDataHandlerT.h rename to fairroot/eventdisplay/datasource/FairTimebasedDataHandlerT.h diff --git a/eventdisplay/datasource/FairTimebasedMCHitSource.cxx b/fairroot/eventdisplay/datasource/FairTimebasedMCHitSource.cxx similarity index 97% rename from eventdisplay/datasource/FairTimebasedMCHitSource.cxx rename to fairroot/eventdisplay/datasource/FairTimebasedMCHitSource.cxx index 9a9969cbe0..99d647be9d 100644 --- a/eventdisplay/datasource/FairTimebasedMCHitSource.cxx +++ b/fairroot/eventdisplay/datasource/FairTimebasedMCHitSource.cxx @@ -9,8 +9,6 @@ #include #include -ClassImp(FairTimebasedMCHitSource); - FairTimebasedMCHitSource::FairTimebasedMCHitSource() { // TODO Auto-generated constructor stub diff --git a/eventdisplay/datasource/FairTimebasedMCHitSource.h b/fairroot/eventdisplay/datasource/FairTimebasedMCHitSource.h similarity index 100% rename from eventdisplay/datasource/FairTimebasedMCHitSource.h rename to fairroot/eventdisplay/datasource/FairTimebasedMCHitSource.h diff --git a/eventdisplay/datasource/FairTimebasedMCSource.cxx b/fairroot/eventdisplay/datasource/FairTimebasedMCSource.cxx similarity index 97% rename from eventdisplay/datasource/FairTimebasedMCSource.cxx rename to fairroot/eventdisplay/datasource/FairTimebasedMCSource.cxx index bef7af5094..a03488a70b 100644 --- a/eventdisplay/datasource/FairTimebasedMCSource.cxx +++ b/fairroot/eventdisplay/datasource/FairTimebasedMCSource.cxx @@ -9,8 +9,6 @@ #include #include -ClassImp(FairTimebasedMCSource); - FairTimebasedMCSource::FairTimebasedMCSource() { // TODO Auto-generated constructor stub diff --git a/eventdisplay/datasource/FairTimebasedMCSource.h b/fairroot/eventdisplay/datasource/FairTimebasedMCSource.h similarity index 100% rename from eventdisplay/datasource/FairTimebasedMCSource.h rename to fairroot/eventdisplay/datasource/FairTimebasedMCSource.h diff --git a/eventdisplay/datasource/FairTimebasedSource.cxx b/fairroot/eventdisplay/datasource/FairTimebasedSource.cxx similarity index 95% rename from eventdisplay/datasource/FairTimebasedSource.cxx rename to fairroot/eventdisplay/datasource/FairTimebasedSource.cxx index d5c7c9e1b8..11227cfda8 100644 --- a/eventdisplay/datasource/FairTimebasedSource.cxx +++ b/fairroot/eventdisplay/datasource/FairTimebasedSource.cxx @@ -8,8 +8,6 @@ #include #include -ClassImp(FairTimebasedSource); - FairTimebasedSource::FairTimebasedSource() { // TODO Auto-generated constructor stub diff --git a/eventdisplay/datasource/FairTimebasedSource.h b/fairroot/eventdisplay/datasource/FairTimebasedSource.h similarity index 100% rename from eventdisplay/datasource/FairTimebasedSource.h rename to fairroot/eventdisplay/datasource/FairTimebasedSource.h diff --git a/eventdisplay/gui/FairEveAnimationControl.cxx b/fairroot/eventdisplay/gui/FairEveAnimationControl.cxx similarity index 100% rename from eventdisplay/gui/FairEveAnimationControl.cxx rename to fairroot/eventdisplay/gui/FairEveAnimationControl.cxx diff --git a/eventdisplay/gui/FairEveAnimationControl.h b/fairroot/eventdisplay/gui/FairEveAnimationControl.h similarity index 100% rename from eventdisplay/gui/FairEveAnimationControl.h rename to fairroot/eventdisplay/gui/FairEveAnimationControl.h diff --git a/eventdisplay/gui/FairEveCut.cxx b/fairroot/eventdisplay/gui/FairEveCut.cxx similarity index 100% rename from eventdisplay/gui/FairEveCut.cxx rename to fairroot/eventdisplay/gui/FairEveCut.cxx diff --git a/eventdisplay/gui/FairEveCut.h b/fairroot/eventdisplay/gui/FairEveCut.h similarity index 95% rename from eventdisplay/gui/FairEveCut.h rename to fairroot/eventdisplay/gui/FairEveCut.h index eb3dad04c2..394793d1c8 100644 --- a/eventdisplay/gui/FairEveCut.h +++ b/fairroot/eventdisplay/gui/FairEveCut.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,8 +24,7 @@ class TBuffer; class TClass; class TGCompositeFrame; class TGNumberEntry; // lines 25-25 -class TGedFrame; // lines 24-24 -class TMemberInspector; +class TGedFrame; /** * base class for graphics cuts diff --git a/eventdisplay/gui/FairEveTransparencyControl.cxx b/fairroot/eventdisplay/gui/FairEveTransparencyControl.cxx similarity index 100% rename from eventdisplay/gui/FairEveTransparencyControl.cxx rename to fairroot/eventdisplay/gui/FairEveTransparencyControl.cxx diff --git a/eventdisplay/gui/FairEveTransparencyControl.h b/fairroot/eventdisplay/gui/FairEveTransparencyControl.h similarity index 90% rename from eventdisplay/gui/FairEveTransparencyControl.h rename to fairroot/eventdisplay/gui/FairEveTransparencyControl.h index adf6fc5391..c84315f274 100644 --- a/eventdisplay/gui/FairEveTransparencyControl.h +++ b/fairroot/eventdisplay/gui/FairEveTransparencyControl.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,8 +15,7 @@ class TBuffer; class TClass; class TGCheckButton; -class TGNumberEntry; // lines 16-16 -class TMemberInspector; +class TGNumberEntry; class FairEveTransparencyControl : public TGHorizontalFrame { diff --git a/eventdisplay/tracks/FairEveGeoTracks.cxx b/fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx similarity index 84% rename from eventdisplay/tracks/FairEveGeoTracks.cxx rename to fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx index 59d2ab8775..a245b6a798 100644 --- a/eventdisplay/tracks/FairEveGeoTracks.cxx +++ b/fairroot/eventdisplay/tracks/FairEveGeoTracks.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -50,27 +50,28 @@ InitStatus FairEveGeoTracks::Init() auto status = FairEveTracks::Init(); if (status != kSUCCESS) return status; - FairRootManager *mngr = FairRootManager::Instance(); - fContainer = dynamic_cast(mngr->GetObject("GeoTracks")); + FairEventManager* eveManager = GetEventManager(); + auto& mngr = eveManager->GetRootManager(); + fContainer = dynamic_cast(mngr.GetObject("GeoTracks")); if (!fContainer) { LOG(warning) << "Geo tracks not found ! FairGeoTracksDraw will be deactivated."; return kERROR; } - fBranch = mngr->GetInTree()->GetBranch("GeoTracks"); + fBranch = mngr.GetInTree()->GetBranch("GeoTracks"); FairGetEventTime::Instance().Init(); return kSUCCESS; } void FairEveGeoTracks::DrawTrack(Int_t id) { - TGeoTrack *tr = (TGeoTrack *)fContainer->UncheckedAt(id); + auto tr = static_cast(fContainer->UncheckedAt(id)); if (!CheckCuts(tr)) return; - TParticle *p = (TParticle *)tr->GetParticle(); + auto p = static_cast(tr->GetParticle()); Color_t color = GetEventManager()->Color(p->GetPdgCode()); - TEveTrackList *trList = FindTrackGroup(p->GetName(), color); + TEveTrackList* trList = FindTrackGroup(p->GetName(), color); - FairEveTrack *track = new FairEveTrack(p, p->GetPdgCode(), trList->GetPropagator()); + auto track = new FairEveTrack(p, p->GetPdgCode(), trList->GetPropagator()); track->SetElementTitle(Form("p={%4.3f,%4.3f,%4.3f}", p->Px(), p->Py(), p->Pz())); track->SetMainColor(color); Double_t x, y, z, t; @@ -87,7 +88,7 @@ void FairEveGeoTracks::DrawTrack(Int_t id) trList->AddElement(track); } -void FairEveGeoTracks::DrawAnimatedTrack(TGeoTrack *tr, double t0) +void FairEveGeoTracks::DrawAnimatedTrack(TGeoTrack* tr, double t0) { const Double_t timeScale = 1E+9; if (!CheckCuts(tr)) @@ -98,10 +99,10 @@ void FairEveGeoTracks::DrawAnimatedTrack(TGeoTrack *tr, double t0) return; // last point before tmin if (tr->GetPoint(0)[3] * timeScale + t0 > fTMax) return; // first point after tmax - TParticle *p = (TParticle *)tr->GetParticle(); + auto p = static_cast(tr->GetParticle()); Color_t color = GetEventManager()->Color(p->GetPdgCode()); - TEveTrackList *trList = FindTrackGroup(p->GetName(), color); - FairEveTrack *track = new FairEveTrack(p, p->GetPdgCode(), trList->GetPropagator()); + TEveTrackList* trList = FindTrackGroup(p->GetName(), color); + auto track = new FairEveTrack(p, p->GetPdgCode(), trList->GetPropagator()); track->SetElementTitle(Form("p={%4.3f,%4.3f,%4.3f}", p->Px(), p->Py(), p->Pz())); track->SetMainColor(color); Double_t x, y, z, t; // currentPoint @@ -156,7 +157,7 @@ void FairEveGeoTracks::Repaint() { bool useGeoTrackHandler = false; if (FairRunAna::Instance()->IsTimeStamp() && fBranch != nullptr) { - Double_t simTime = FairEventManager::Instance()->GetEvtTime(); + Double_t simTime = GetEventManager()->GetEvtTime(); std::pair evt = FairGetEventTime::Instance().GetEvent(simTime); if (evt.first < 0) { @@ -164,7 +165,7 @@ void FairEveGeoTracks::Repaint() } else { fBranch->GetEvent(evt.first); } - if (FairEventManager::Instance()->GetClearHandler()) { + if (GetEventManager()->GetClearHandler()) { fGeoTrackHandler.Reset(); } if (evt.first > -1) @@ -178,20 +179,20 @@ void FairEveGeoTracks::Repaint() nTracks = fContainer->GetEntriesFast(); } RemoveElements(); - FairEventManager::Instance()->GetTimeLimits(fTMin, fTMax); + GetEventManager()->GetTimeLimits(fTMin, fTMax); if (fTMin > fTMax) { // wrong time limits draw entire tracks for (int iTrack = 0; iTrack < nTracks; iTrack++) { DrawTrack(iTrack); } } else { for (int iTrack = 0; iTrack < nTracks; iTrack++) { - TGeoTrack *track; + TGeoTrack* track; double t0 = .0; if (useGeoTrackHandler) { track = fGeoTrackHandler.GetData()[iTrack].first; t0 = fGeoTrackHandler.GetData()[iTrack].second; } else { - track = (TGeoTrack *)fContainer->At(iTrack); + track = static_cast(fContainer->At(iTrack)); } DrawAnimatedTrack(track, t0); } @@ -199,9 +200,9 @@ void FairEveGeoTracks::Repaint() gEve->Redraw3D(kFALSE); } -Bool_t FairEveGeoTracks::CheckCuts(TGeoTrack *tr) +Bool_t FairEveGeoTracks::CheckCuts(TGeoTrack* tr) { - TParticle *p = (TParticle *)tr->GetParticle(); + auto p = static_cast(tr->GetParticle()); if (UsePtCut()) { if (p->Pt() < GetPtMin()) return kFALSE; diff --git a/eventdisplay/tracks/FairEveGeoTracks.h b/fairroot/eventdisplay/tracks/FairEveGeoTracks.h similarity index 94% rename from eventdisplay/tracks/FairEveGeoTracks.h rename to fairroot/eventdisplay/tracks/FairEveGeoTracks.h index 563a3171aa..0735dbb2ee 100644 --- a/eventdisplay/tracks/FairEveGeoTracks.h +++ b/fairroot/eventdisplay/tracks/FairEveGeoTracks.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,7 +26,6 @@ class TBuffer; class TClass; class TClonesArray; class TGeoTrack; // lines 22-22 -class TMemberInspector; class TBranch; /** diff --git a/eventdisplay/tracks/FairEveGeoTracksEditor.cxx b/fairroot/eventdisplay/tracks/FairEveGeoTracksEditor.cxx similarity index 100% rename from eventdisplay/tracks/FairEveGeoTracksEditor.cxx rename to fairroot/eventdisplay/tracks/FairEveGeoTracksEditor.cxx diff --git a/eventdisplay/tracks/FairEveGeoTracksEditor.h b/fairroot/eventdisplay/tracks/FairEveGeoTracksEditor.h similarity index 95% rename from eventdisplay/tracks/FairEveGeoTracksEditor.h rename to fairroot/eventdisplay/tracks/FairEveGeoTracksEditor.h index 6acc9dac2d..cbe663027f 100644 --- a/eventdisplay/tracks/FairEveGeoTracksEditor.h +++ b/fairroot/eventdisplay/tracks/FairEveGeoTracksEditor.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,14 +29,11 @@ class FairEveMinMaxCut; // lines 27-27 class TBuffer; class TClass; class TGWindow; -class TMemberInspector; class TObject; - /** * editor of TGeoTracks in event display */ - class FairEveGeoTracksEditor : public TGedFrame { std::unique_ptr fPtCut; diff --git a/eventdisplay/tracks/FairEveRecoTrack.cxx b/fairroot/eventdisplay/tracks/FairEveRecoTrack.cxx similarity index 100% rename from eventdisplay/tracks/FairEveRecoTrack.cxx rename to fairroot/eventdisplay/tracks/FairEveRecoTrack.cxx diff --git a/eventdisplay/tracks/FairEveRecoTrack.h b/fairroot/eventdisplay/tracks/FairEveRecoTrack.h similarity index 93% rename from eventdisplay/tracks/FairEveRecoTrack.h rename to fairroot/eventdisplay/tracks/FairEveRecoTrack.h index c405ee993b..aa6ad67371 100644 --- a/eventdisplay/tracks/FairEveRecoTrack.h +++ b/fairroot/eventdisplay/tracks/FairEveRecoTrack.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,7 @@ class TBuffer; class TClass; class TEvePointSet; // lines 23-23 class TEveTrackPropagator; // lines 24-24 -class TGeoTrack; // lines 25-25 -class TMemberInspector; +class TGeoTrack; class TParticle; // lines 26-26 class FairEveRecoTrack : public TEveCompound diff --git a/eventdisplay/tracks/FairEveRecoTrackList.cxx b/fairroot/eventdisplay/tracks/FairEveRecoTrackList.cxx similarity index 100% rename from eventdisplay/tracks/FairEveRecoTrackList.cxx rename to fairroot/eventdisplay/tracks/FairEveRecoTrackList.cxx diff --git a/eventdisplay/tracks/FairEveRecoTrackList.h b/fairroot/eventdisplay/tracks/FairEveRecoTrackList.h similarity index 93% rename from eventdisplay/tracks/FairEveRecoTrackList.h rename to fairroot/eventdisplay/tracks/FairEveRecoTrackList.h index 6e9877cea9..26f1a10d0a 100644 --- a/eventdisplay/tracks/FairEveRecoTrackList.h +++ b/fairroot/eventdisplay/tracks/FairEveRecoTrackList.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,6 @@ class TBuffer; class TClass; class TEveTrackPropagator; -class TMemberInspector; class FairEveRecoTrackList : public TEveTrackList { diff --git a/eventdisplay/tracks/FairEveTrack.cxx b/fairroot/eventdisplay/tracks/FairEveTrack.cxx similarity index 100% rename from eventdisplay/tracks/FairEveTrack.cxx rename to fairroot/eventdisplay/tracks/FairEveTrack.cxx diff --git a/eventdisplay/tracks/FairEveTrack.h b/fairroot/eventdisplay/tracks/FairEveTrack.h similarity index 93% rename from eventdisplay/tracks/FairEveTrack.h rename to fairroot/eventdisplay/tracks/FairEveTrack.h index da7ade9a96..1effc6594b 100644 --- a/eventdisplay/tracks/FairEveTrack.h +++ b/fairroot/eventdisplay/tracks/FairEveTrack.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,10 +23,8 @@ class TBuffer; class TClass; class TEveTrackPropagator; -class TMemberInspector; class TParticle; - class FairEveTrack : public TEveTrack { diff --git a/eventdisplay/tracks/FairEveTracks.cxx b/fairroot/eventdisplay/tracks/FairEveTracks.cxx similarity index 72% rename from eventdisplay/tracks/FairEveTracks.cxx rename to fairroot/eventdisplay/tracks/FairEveTracks.cxx index 414bd1aeda..95a568d630 100644 --- a/eventdisplay/tracks/FairEveTracks.cxx +++ b/fairroot/eventdisplay/tracks/FairEveTracks.cxx @@ -1,12 +1,12 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ /* - * FairTracks.cxx + * FairEveTracks.cxx * * Created on: 4 maj 2020 * Author: Daniel Wielanek @@ -14,27 +14,20 @@ * Warsaw University of Technology, Faculty of Physics */ - #include "FairEveTracks.h" - #include // for kFALSE, kTRUE, Bool_t, Color_t - #include // for TEveManager, gEve - #include // for TEveTrackList - #include // for TEveTrackPropagator - #include // for TString - #include // for for_each - #include // for __list_iterator, operator!= - #include "FairEveRecoTrackList.h" // for FairEveRecoTrackList - #include "FairEventManager.h" // for FairEventManager +#include "FairEveTracks.h" +#include "FairEveRecoTrackList.h" // for FairEveRecoTrackList +#include "FairEventManager.h" // for FairEventManager + +#include // for kFALSE, kTRUE, Bool_t, Color_t +#include // for TEveManager, gEve +#include // for TEveTrackPropagator +#include // for TString +#include // for for_each +#include // for __list_iterator, operator!= FairEveTracks::FairEveTracks(Bool_t acceptCompound) - : fEventManager(nullptr) - , fPt{0, 10} - , fEta{-10, 10} - , fEnergy{0, 10} - , fUsePt(kFALSE) - , fUseEta(kFALSE) - , fUseEnergy(kFALSE) - , fAcceptCompound(acceptCompound) + : fAcceptCompound(acceptCompound) {} void FairEveTracks::ToggleTracks() diff --git a/eventdisplay/tracks/FairEveTracks.h b/fairroot/eventdisplay/tracks/FairEveTracks.h similarity index 78% rename from eventdisplay/tracks/FairEveTracks.h rename to fairroot/eventdisplay/tracks/FairEveTracks.h index ae443493cf..8e17cc1c79 100644 --- a/eventdisplay/tracks/FairEveTracks.h +++ b/fairroot/eventdisplay/tracks/FairEveTracks.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,18 +16,16 @@ #ifndef FAIRTEVERACKS_H_ #define FAIRTEVERACKS_H_ -#include // for THashConsistencyHolder, ClassDef -#include // for Double_t, Bool_t, kFALSE, Color_t -#include // for TEveElement -#include // for TNamed -#include // for TString -#include "FairTask.h" // for InitStatus -class FairEventManager; // lines 23-23 -class TBuffer; -class TClass; -class TEveTrackList; // lines 24-24 -class TMemberInspector; +#include "FairTask.h" // for InitStatus +#include // for THashConsistencyHolder, ClassDef +#include // for Double_t, Bool_t, kFALSE, Color_t +#include // for TEveElement +#include // for TEveTrackList +#include // for TNamed +#include // for TString + +class FairEventManager; /** * base evelement that represents tracks @@ -36,13 +34,13 @@ class FairEveTracks : public TEveElement , public TNamed { - FairEventManager *fEventManager; //! - Double_t fPt[2]; - Double_t fEta[2]; - Double_t fEnergy[2]; - Bool_t fUsePt; - Bool_t fUseEta; - Bool_t fUseEnergy; + FairEventManager* fEventManager{nullptr}; //! + Double_t fPt[2]{0, 10}; + Double_t fEta[2]{-10, 10}; + Double_t fEnergy[2]{0, 10}; + Bool_t fUsePt{kFALSE}; + Bool_t fUseEta{kFALSE}; + Bool_t fUseEnergy{kFALSE}; const Bool_t fAcceptCompound; protected: @@ -69,7 +67,7 @@ class FairEveTracks * * @param acceptCompound use compound tracks in track list */ - FairEveTracks(Bool_t acceptCompound = kFALSE); + explicit FairEveTracks(Bool_t acceptCompound = kFALSE); /** * makes visible tracks not visible, hidden tracks become visible */ @@ -119,8 +117,8 @@ class FairEveTracks */ virtual void Repaint() = 0; virtual InitStatus Init(); - virtual ~FairEveTracks(); - ClassDef(FairEveTracks, 0) + ~FairEveTracks() override; + ClassDefOverride(FairEveTracks, 0) }; #endif /* FAIRTEVERACKS_H_ */ diff --git a/eventdisplay/tracks/FairGeoTrackHandler.cxx b/fairroot/eventdisplay/tracks/FairGeoTrackHandler.cxx similarity index 100% rename from eventdisplay/tracks/FairGeoTrackHandler.cxx rename to fairroot/eventdisplay/tracks/FairGeoTrackHandler.cxx diff --git a/eventdisplay/tracks/FairGeoTrackHandler.h b/fairroot/eventdisplay/tracks/FairGeoTrackHandler.h similarity index 100% rename from eventdisplay/tracks/FairGeoTrackHandler.h rename to fairroot/eventdisplay/tracks/FairGeoTrackHandler.h diff --git a/eventdisplay/tracks/FairGeoTracksDraw.cxx b/fairroot/eventdisplay/tracks/FairGeoTracksDraw.cxx similarity index 100% rename from eventdisplay/tracks/FairGeoTracksDraw.cxx rename to fairroot/eventdisplay/tracks/FairGeoTracksDraw.cxx diff --git a/eventdisplay/tracks/FairGeoTracksDraw.h b/fairroot/eventdisplay/tracks/FairGeoTracksDraw.h similarity index 93% rename from eventdisplay/tracks/FairGeoTracksDraw.h rename to fairroot/eventdisplay/tracks/FairGeoTracksDraw.h index 3bea4ef1fc..b22909e9b3 100644 --- a/eventdisplay/tracks/FairGeoTracksDraw.h +++ b/fairroot/eventdisplay/tracks/FairGeoTracksDraw.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,7 +23,6 @@ class FairEveGeoTracks; // lines 21-21 class FairEventManager; // lines 22-22 class TBuffer; class TClass; -class TMemberInspector; /** * task that draws the TGeoTracks diff --git a/fairroot/eventdisplay/xml/FairXMLEveConf.cxx b/fairroot/eventdisplay/xml/FairXMLEveConf.cxx new file mode 100644 index 0000000000..cb2324a0a4 --- /dev/null +++ b/fairroot/eventdisplay/xml/FairXMLEveConf.cxx @@ -0,0 +1,74 @@ +/******************************************************************************** + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +/* + * FairXMLEveConf.cxx + * + * Created on: 21 paź 2021 + * Author: Daniel Wielanek + * E-mail: daniel.wielanek@gmail.com + * Warsaw University of Technology, Faculty of Physics + */ +#include "FairXMLEveConf.h" + +Int_t FairXMLEveConf::StringToColor(const TString& color) +{ + if (color.Contains("k")) { + Int_t plus_index = color.First('+'); + Int_t minus_index = color.First('-'); + Int_t cut = plus_index; + if (cut == -1) + cut = minus_index; + if (cut == -1) + cut = color.Length(); + TString col_name(color(0, cut)); + Int_t col_val = 0; + if (col_name.EqualTo("kWhite")) { + col_val = 0; + } else if (col_name.EqualTo("kBlack")) { + col_val = 1; + } else if (col_name.EqualTo("kGray")) { + col_val = 920; + } else if (col_name.EqualTo("kRed")) { + col_val = 632; + } else if (col_name.EqualTo("kGreen")) { + col_val = 416; + } else if (col_name.EqualTo("kBlue")) { + col_val = 600; + } else if (col_name.EqualTo("kYellow")) { + col_val = 400; + } else if (col_name.EqualTo("kMagenta")) { + col_val = 616; + } else if (col_name.EqualTo("kCyan")) { + col_val = 432; + } else if (col_name.EqualTo("kOrange")) { + col_val = 800; + } else if (col_name.EqualTo("kSpring")) { + col_val = 820; + } else if (col_name.EqualTo("kTeal")) { + col_val = 840; + } else if (col_name.EqualTo("kAzure")) { + col_val = 860; + } else if (col_name.EqualTo("kViolet")) { + col_val = 880; + } else if (col_name.EqualTo("kPink")) { + col_val = 900; + } + TString col_num(color(cut + 1, color.Length())); + if (col_num.Length() > 0) { + if (color.Contains("+")) { + col_val += col_num.Atoi(); + } else { + col_val -= col_num.Atoi(); + } + } + return col_val; + } else { + return color.Atoi(); + } +} diff --git a/fairroot/eventdisplay/xml/FairXMLEveConf.h b/fairroot/eventdisplay/xml/FairXMLEveConf.h new file mode 100644 index 0000000000..62868c6061 --- /dev/null +++ b/fairroot/eventdisplay/xml/FairXMLEveConf.h @@ -0,0 +1,29 @@ +/******************************************************************************** + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +/* + * FairXMLEveConf.h + * + * Created on: 21 paź 2021 + * Author: Daniel Wielanek + * E-mail: daniel.wielanek@gmail.com + * Warsaw University of Technology, Faculty of Physics + */ +#ifndef FAIRROOT_EVENTDISPLAY_XML_FAIRXMLEVECONF_H_ +#define FAIRROOT_EVENTDISPLAY_XML_FAIRXMLEVECONF_H_ + +#include + +struct FairXMLEveConf +{ + FairXMLEveConf() = default; + virtual ~FairXMLEveConf() = default; + static Int_t StringToColor(const TString& color); +}; + +#endif /* FAIRROOT_EVENTDISPLAY_XML_FAIRXMLEVECONF_H_ */ diff --git a/fairroot/eventdisplay/xml/FairXMLPdgColor.cxx b/fairroot/eventdisplay/xml/FairXMLPdgColor.cxx new file mode 100644 index 0000000000..f35724f1de --- /dev/null +++ b/fairroot/eventdisplay/xml/FairXMLPdgColor.cxx @@ -0,0 +1,102 @@ +/******************************************************************************** + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ +/* + * FairXMLPdgColor.cxx + * + * Created on: 21 paź 2021 + * Author: Daniel Wielanek + * E-mail: daniel.wielanek@gmail.com + * Warsaw University of Technology, Faculty of Physics + */ + +#include "FairXMLPdgColor.h" + +#include "FairXMLNode.h" + +#include + +FairXMLPdgColor::FairXMLPdgColor(FairXMLNode* node) +{ + if (!node) { + SetDefColor(); + return; + } + + if (!node->GetNChildren()) { + SetDefColor(); + return; + } + + for (int i = 0; i < node->GetNChildren(); i++) { + FairXMLNode* colors = node->GetChild(i); + TString pgd_code = colors->GetAttrib("pdg")->GetValue(); + TString color_code = colors->GetAttrib("color")->GetValue(); + fPDGToColor[pgd_code.Atoi()] = StringToColor(color_code); + } +} + +Int_t FairXMLPdgColor::GetColor(Int_t pdg) const +{ + if (fPDGToColor.find(pdg) != fPDGToColor.end()) { + return fPDGToColor.at(pdg); + } + return 0; +} + +void FairXMLPdgColor::SetDefColor() +{ + fPDGToColor[22] = 623; // photon + fPDGToColor[-2112] = 2; // anti-neutron + fPDGToColor[-11] = 3; // e+ + fPDGToColor[-3122] = 4; // anti-lambda + fPDGToColor[11] = 5; // e- + fPDGToColor[-3222] = 6; // Sigma - + fPDGToColor[12] = 7; // e-neutrino + fPDGToColor[-3212] = 8; // Sigma0 + fPDGToColor[-13] = 9; // mu+ + fPDGToColor[-3112] = 10; // Sigma+ (PB + fPDGToColor[13] = 11; // mu- + fPDGToColor[-3322] = 12; // Xi0 + fPDGToColor[111] = 13; // pi0 + fPDGToColor[-3312] = 14; // Xi+ + fPDGToColor[211] = 15; // pi+ + fPDGToColor[-3334] = 16; // Omega+ (PB) + fPDGToColor[-211] = 17; // pi- + fPDGToColor[-15] = 18; // tau+ + fPDGToColor[130] = 19; // K long + fPDGToColor[15] = 20; // tau - + fPDGToColor[321] = 21; // K+ + fPDGToColor[411] = 22; // D+ + fPDGToColor[-321] = 23; // K- + fPDGToColor[-411] = 24; // D- + fPDGToColor[2112] = 25; // n + fPDGToColor[421] = 26; // D0 + fPDGToColor[2212] = 27; // p + fPDGToColor[-421] = 28; // D0 + fPDGToColor[-2212] = 29; // anti-proton + fPDGToColor[431] = 30; // Ds+ + fPDGToColor[310] = 31; // K short + fPDGToColor[-431] = 32; // anti Ds- + fPDGToColor[221] = 33; // eta + fPDGToColor[4122] = 34; // Lambda_C+ + fPDGToColor[3122] = 35; // Lambda + fPDGToColor[24] = 36; // W+ + fPDGToColor[3222] = 37; // Sigma+ + fPDGToColor[-24] = 38; // W- + fPDGToColor[3212] = 39; // Sigma0 + fPDGToColor[23] = 40; // Z + fPDGToColor[3112] = 41; // Sigma - + fPDGToColor[3322] = 42; // Xi0 + fPDGToColor[3312] = 43; // Xi- + fPDGToColor[3334] = 44; // Omega- (PB) + fPDGToColor[50000050] = 801; // Cerenkov + fPDGToColor[1000010020] = 45; + fPDGToColor[1000010030] = 48; + fPDGToColor[1000020040] = 50; + fPDGToColor[1000020030] = 55; +} diff --git a/fairroot/eventdisplay/xml/FairXMLPdgColor.h b/fairroot/eventdisplay/xml/FairXMLPdgColor.h new file mode 100644 index 0000000000..ff90800383 --- /dev/null +++ b/fairroot/eventdisplay/xml/FairXMLPdgColor.h @@ -0,0 +1,37 @@ +/******************************************************************************** + * Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ +/* + * FairXMLPdgColor.h + * + * Created on: 21 paź 2021 + * Author: Daniel Wielanek + * E-mail: daniel.wielanek@gmail.com + * Warsaw University of Technology, Faculty of Physics + */ +#ifndef FAIRROOT_EVENTDISPLAY_XML_FAIRXMLPDGCOLOR_H_ +#define FAIRROOT_EVENTDISPLAY_XML_FAIRXMLPDGCOLOR_H_ + +#include "FairXMLEveConf.h" + +#include + +class FairXMLNode; + +class FairXMLPdgColor : public FairXMLEveConf +{ + std::map fPDGToColor; + void SetDefColor(); + + public: + explicit FairXMLPdgColor(FairXMLNode* node = nullptr); + ~FairXMLPdgColor() override = default; + void SetColor(Int_t pdg, Int_t color) { fPDGToColor[pdg] = color; } + Int_t GetColor(Int_t pdg) const; +}; + +#endif /* FAIRROOT_EVENTDISPLAY_XML_FAIRXMLPDGCOLOR_H_ */ diff --git a/fairmq/CMakeLists.txt b/fairroot/fairmq/CMakeLists.txt similarity index 100% rename from fairmq/CMakeLists.txt rename to fairroot/fairmq/CMakeLists.txt diff --git a/fairmq/FairMQ.h b/fairroot/fairmq/FairMQ.h similarity index 77% rename from fairmq/FairMQ.h rename to fairroot/fairmq/FairMQ.h index dc013859bb..47e8b081cd 100644 --- a/fairmq/FairMQ.h +++ b/fairroot/fairmq/FairMQ.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2022-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,7 +14,8 @@ #undef FAIRMQ_VERSION_DEC // bugged #endif #if defined FAIRMQ_VERSION_MAJOR && defined FAIRMQ_VERSION_MINOR && defined FAIRMQ_VERSION_PATCH -#define FAIRMQ_VERSION_DEC (FAIRMQ_VERSION_MAJOR * 100000) + (FAIRMQ_VERSION_MINOR * 1000) + (FAIRMQ_VERSION_PATCH * 10) +#define FAIRMQ_VERSION_DEC \ + ((FAIRMQ_VERSION_MAJOR * 100000) + (FAIRMQ_VERSION_MINOR * 1000) + (FAIRMQ_VERSION_PATCH * 10)) #else #define FAIRMQ_VERSION_DEC 9999999 #endif @@ -52,4 +53,19 @@ using TransportFactory = ::FairMQTransportFactory; #endif +namespace fairroot +{ + +// see https://github.com/FairRootGroup/FairMQ/commit/5ef17fddbb6a957867cd6aca978176bc95c63508 +inline auto& GetFairMQDeviceChannels(fair::mq::Device& device) +{ +#if FAIRMQ_VERSION_DEC < 105000 + return device.fChannels; +#else + return device.GetChannels(); +#endif +} + +} // namespace fairroot + #endif // FAIRROOT_FAIRMQ_H diff --git a/fairmq/FairRunFairMQDevice.h b/fairroot/fairmq/FairRunFairMQDevice.h similarity index 87% rename from fairmq/FairRunFairMQDevice.h rename to fairroot/fairmq/FairRunFairMQDevice.h index 315cef8af4..fe449fb918 100644 --- a/fairmq/FairRunFairMQDevice.h +++ b/fairroot/fairmq/FairRunFairMQDevice.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,7 +14,8 @@ #undef FAIRMQ_VERSION_DEC // bugged #endif #if defined FAIRMQ_VERSION_MAJOR && defined FAIRMQ_VERSION_MINOR && defined FAIRMQ_VERSION_PATCH -#define FAIRMQ_VERSION_DEC (FAIRMQ_VERSION_MAJOR * 100000) + (FAIRMQ_VERSION_MINOR * 1000) + (FAIRMQ_VERSION_PATCH * 10) +#define FAIRMQ_VERSION_DEC \ + ((FAIRMQ_VERSION_MAJOR * 100000) + (FAIRMQ_VERSION_MINOR * 1000) + (FAIRMQ_VERSION_PATCH * 10)) #else #define FAIRMQ_VERSION_DEC 9999999 #endif diff --git a/base/sim/fastsim/CMakeLists.txt b/fairroot/fastsim/CMakeLists.txt similarity index 90% rename from base/sim/fastsim/CMakeLists.txt rename to fairroot/fastsim/CMakeLists.txt index e29bcd69cd..0d002dabb9 100644 --- a/base/sim/fastsim/CMakeLists.txt +++ b/fairroot/fastsim/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -27,11 +27,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - # Geant4 uses namespace since 10.5 if(${Geant4_VERSION} VERSION_LESS "10.6") set(targetG4processes G4processes) diff --git a/base/sim/fastsim/FairFastSimDetector.cxx b/fairroot/fastsim/FairFastSimDetector.cxx similarity index 95% rename from base/sim/fastsim/FairFastSimDetector.cxx rename to fairroot/fastsim/FairFastSimDetector.cxx index f574d92e77..310dc73557 100644 --- a/base/sim/fastsim/FairFastSimDetector.cxx +++ b/fairroot/fastsim/FairFastSimDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -65,5 +65,3 @@ Bool_t FairFastSimDetector::ProcessHits(FairVolume*) return kTRUE; } - -ClassImp(FairFastSimDetector); diff --git a/base/sim/fastsim/FairFastSimDetector.h b/fairroot/fastsim/FairFastSimDetector.h similarity index 92% rename from base/sim/fastsim/FairFastSimDetector.h rename to fairroot/fastsim/FairFastSimDetector.h index e9049fe7b3..187c48b9d5 100644 --- a/base/sim/fastsim/FairFastSimDetector.h +++ b/fairroot/fastsim/FairFastSimDetector.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,6 @@ class FairFastSimDetector : public FairDetector ~FairFastSimDetector() override; - void Initialize() override = 0; - Bool_t ProcessHits(FairVolume* vol = 0) override final; void EndOfEvent() override {} diff --git a/base/sim/fastsim/FairFastSimModel.cxx b/fairroot/fastsim/FairFastSimModel.cxx similarity index 91% rename from base/sim/fastsim/FairFastSimModel.cxx rename to fairroot/fastsim/FairFastSimModel.cxx index edb24dcc07..986c41b18c 100644 --- a/base/sim/fastsim/FairFastSimModel.cxx +++ b/fairroot/fastsim/FairFastSimModel.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -53,13 +53,18 @@ FairFastSimModel::~FairFastSimModel() {} // delete parser; // } -G4bool FairFastSimModel::IsApplicable([[gnu::unused]] const G4ParticleDefinition& particleType) { return true; } +G4bool FairFastSimModel::IsApplicable([[gnu::unused]] const G4ParticleDefinition& particleType) +{ + return true; +} -G4bool FairFastSimModel::ModelTrigger([[gnu::unused]] const G4FastTrack& fastTrack) { return true; } +G4bool FairFastSimModel::ModelTrigger([[gnu::unused]] const G4FastTrack& fastTrack) +{ + return true; +} void FairFastSimModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep) { - LOG(debug) << "FairFastSimModel::DoIt() called"; // G4TouchableHandle theTouchable = // fastTrack.GetPrimaryTrack()->GetTouchableHandle(); @@ -121,15 +126,15 @@ void FairFastSimModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep) G4double len = 0.; G4double ek = particle->Ek() * 1000.; - fastStep.SetPrimaryTrackFinalPosition(pos, false); - fastStep.SetPrimaryTrackFinalTime(tim); - fastStep.SetPrimaryTrackFinalProperTime(tim); - fastStep.SetPrimaryTrackFinalMomentum(mom, false); - fastStep.SetPrimaryTrackFinalKineticEnergy(ek); + fastStep.ProposePrimaryTrackFinalPosition(pos, false); + fastStep.ProposePrimaryTrackFinalTime(tim); + fastStep.ProposePrimaryTrackFinalProperTime(tim); + fastStep.ProposePrimaryTrackFinalMomentumDirection(mom, false); + fastStep.ProposePrimaryTrackFinalKineticEnergy(ek); // fastStep.SetPrimaryTrackFinalKineticEnergyAndDirection (G4double, const G4ThreeVector &, G4bool // localCoordinates=true); - fastStep.SetPrimaryTrackFinalPolarization(pol, false); - fastStep.SetPrimaryTrackPathLength(len); + fastStep.ProposePrimaryTrackFinalPolarization(pol, false); + fastStep.ProposePrimaryTrackPathLength(len); if (FairTrajFilter::Instance()->IsAccepted(particle)) { FairTrajFilter::Instance()->GetCurrentTrk()->AddPoint( diff --git a/base/sim/fastsim/FairFastSimModel.h b/fairroot/fastsim/FairFastSimModel.h similarity index 66% rename from base/sim/fastsim/FairFastSimModel.h rename to fairroot/fastsim/FairFastSimModel.h index aa6e07fa5b..e709dc81c5 100644 --- a/base/sim/fastsim/FairFastSimModel.h +++ b/fairroot/fastsim/FairFastSimModel.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,13 +12,9 @@ #ifndef FAIR_FASTSIM_MODEL_H_ #define FAIR_FASTSIM_MODEL_H_ -#include "G4String.hh" // for G4String -#include "G4Types.hh" // for G4bool -#include "G4VFastSimulationModel.hh" -class G4FastStep; -class G4FastTrack; -class G4ParticleDefinition; -class G4Region; +#include // for G4String +#include // for G4bool +#include class FairFastSimModel : public G4VFastSimulationModel { @@ -26,13 +22,13 @@ class FairFastSimModel : public G4VFastSimulationModel //------------------------- // Constructor, destructor //------------------------- - FairFastSimModel(G4String, G4Region *); + FairFastSimModel(G4String, G4Region*); FairFastSimModel(G4String); - ~FairFastSimModel(); + ~FairFastSimModel() override; - virtual G4bool IsApplicable([[gnu::unused]] const G4ParticleDefinition &); - virtual G4bool ModelTrigger([[gnu::unused]] const G4FastTrack &); - virtual void DoIt(const G4FastTrack &, G4FastStep &); + G4bool IsApplicable([[gnu::unused]] const G4ParticleDefinition&) override; + G4bool ModelTrigger([[gnu::unused]] const G4FastTrack&) override; + void DoIt(const G4FastTrack&, G4FastStep&) override; }; #endif /* FAIR_FASTSIM_MODEL_H_ */ diff --git a/base/sim/fastsim/FairFastSimRunConfiguration.cxx b/fairroot/fastsim/FairFastSimRunConfiguration.cxx similarity index 100% rename from base/sim/fastsim/FairFastSimRunConfiguration.cxx rename to fairroot/fastsim/FairFastSimRunConfiguration.cxx diff --git a/base/sim/fastsim/FairFastSimRunConfiguration.h b/fairroot/fastsim/FairFastSimRunConfiguration.h similarity index 88% rename from base/sim/fastsim/FairFastSimRunConfiguration.h rename to fairroot/fastsim/FairFastSimRunConfiguration.h index 247b099683..8b1cbc8d0f 100644 --- a/base/sim/fastsim/FairFastSimRunConfiguration.h +++ b/fairroot/fastsim/FairFastSimRunConfiguration.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,10 +23,10 @@ class FairFastSimRunConfiguration : public TG4RunConfiguration const TString& specialProcess = "stepLimiter", const bool specialStacking = false, const bool isMT = false); - virtual ~FairFastSimRunConfiguration(); + ~FairFastSimRunConfiguration() override; // methods - virtual TG4VUserFastSimulation* CreateUserFastSimulation(); + TG4VUserFastSimulation* CreateUserFastSimulation() override; }; #endif // FAIR_FASTSIM_RUN_CONFIGURATION_H diff --git a/base/sim/fastsim/FairFastSimulation.cxx b/fairroot/fastsim/FairFastSimulation.cxx similarity index 100% rename from base/sim/fastsim/FairFastSimulation.cxx rename to fairroot/fastsim/FairFastSimulation.cxx diff --git a/base/sim/fastsim/FairFastSimulation.h b/fairroot/fastsim/FairFastSimulation.h similarity index 87% rename from base/sim/fastsim/FairFastSimulation.h rename to fairroot/fastsim/FairFastSimulation.h index 758726a675..cc937d5c73 100644 --- a/base/sim/fastsim/FairFastSimulation.h +++ b/fairroot/fastsim/FairFastSimulation.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,10 +18,10 @@ class FairFastSimulation : public TG4VUserFastSimulation { public: FairFastSimulation(); - virtual ~FairFastSimulation(); + ~FairFastSimulation() override; // methods - virtual void Construct(); + void Construct() override; }; #endif // FAIR_FAST_SIMULATION_H diff --git a/base/sim/fastsim/LinkDef.h b/fairroot/fastsim/LinkDef.h similarity index 100% rename from base/sim/fastsim/LinkDef.h rename to fairroot/fastsim/LinkDef.h diff --git a/geane/CMakeLists.txt b/fairroot/geane/CMakeLists.txt similarity index 88% rename from geane/CMakeLists.txt rename to fairroot/geane/CMakeLists.txt index cc359fb418..ce85053377 100644 --- a/geane/CMakeLists.txt +++ b/fairroot/geane/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -23,11 +23,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairField, FairTask, FairPropagator diff --git a/geane/FairGeane.cxx b/fairroot/geane/FairGeane.cxx similarity index 97% rename from geane/FairGeane.cxx rename to fairroot/geane/FairGeane.cxx index 3ee1832bc5..237c7d6cf7 100644 --- a/geane/FairGeane.cxx +++ b/fairroot/geane/FairGeane.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -143,5 +143,3 @@ void FairGeane::SetField(FairField* /*field*/) "instead \033[0m " << endl; } - -ClassImp(FairGeane); diff --git a/geane/FairGeane.h b/fairroot/geane/FairGeane.h similarity index 100% rename from geane/FairGeane.h rename to fairroot/geane/FairGeane.h diff --git a/geane/FairGeanePro.cxx b/fairroot/geane/FairGeanePro.cxx similarity index 99% rename from geane/FairGeanePro.cxx rename to fairroot/geane/FairGeanePro.cxx index 96036b708c..1d01046ac0 100644 --- a/geane/FairGeanePro.cxx +++ b/fairroot/geane/FairGeanePro.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -1550,5 +1550,3 @@ void FairGeanePro::GetTransportMatrix(double trm[5][5]) } } } - -ClassImp(FairGeanePro); diff --git a/geane/FairGeanePro.h b/fairroot/geane/FairGeanePro.h similarity index 100% rename from geane/FairGeanePro.h rename to fairroot/geane/FairGeanePro.h diff --git a/geane/LinkDef.h b/fairroot/geane/LinkDef.h similarity index 100% rename from geane/LinkDef.h rename to fairroot/geane/LinkDef.h diff --git a/geane/README.dox b/fairroot/geane/README.dox similarity index 100% rename from geane/README.dox rename to fairroot/geane/README.dox diff --git a/generators/CMakeLists.txt b/fairroot/generators/CMakeLists.txt similarity index 90% rename from generators/CMakeLists.txt rename to fairroot/generators/CMakeLists.txt index a26a662edd..77b480969e 100644 --- a/generators/CMakeLists.txt +++ b/fairroot/generators/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -32,11 +32,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairPrimaryGenerator, FairGenerator, FairIon, FairParticle, FairRunSim diff --git a/generators/FairAsciiGenerator.cxx b/fairroot/generators/FairAsciiGenerator.cxx similarity index 96% rename from generators/FairAsciiGenerator.cxx rename to fairroot/generators/FairAsciiGenerator.cxx index 7795b4f3df..315a9fcd9a 100644 --- a/generators/FairAsciiGenerator.cxx +++ b/fairroot/generators/FairAsciiGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,10 +11,10 @@ // ------------------------------------------------------------------------- #include "FairAsciiGenerator.h" -#include "FairLogger.h" #include "FairPrimaryGenerator.h" // for FairPrimaryGenerator #include // for INT_MAX +#include #include FairAsciiGenerator::FairAsciiGenerator() @@ -99,5 +99,3 @@ void FairAsciiGenerator::CloseInput() fInputFile = nullptr; } } - -ClassImp(FairAsciiGenerator); diff --git a/generators/FairAsciiGenerator.h b/fairroot/generators/FairAsciiGenerator.h similarity index 100% rename from generators/FairAsciiGenerator.h rename to fairroot/generators/FairAsciiGenerator.h diff --git a/generators/FairBaseMCGenerator.cxx b/fairroot/generators/FairBaseMCGenerator.cxx similarity index 100% rename from generators/FairBaseMCGenerator.cxx rename to fairroot/generators/FairBaseMCGenerator.cxx diff --git a/generators/FairBaseMCGenerator.h b/fairroot/generators/FairBaseMCGenerator.h similarity index 100% rename from generators/FairBaseMCGenerator.h rename to fairroot/generators/FairBaseMCGenerator.h diff --git a/generators/FairBoxGenerator.cxx b/fairroot/generators/FairBoxGenerator.cxx similarity index 98% rename from generators/FairBoxGenerator.cxx rename to fairroot/generators/FairBoxGenerator.cxx index 302ee0597d..c8785ad4d0 100644 --- a/generators/FairBoxGenerator.cxx +++ b/fairroot/generators/FairBoxGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -210,5 +210,3 @@ FairGenerator* FairBoxGenerator::CloneGenerator() const return new FairBoxGenerator(*this); } - -ClassImp(FairBoxGenerator); diff --git a/generators/FairBoxGenerator.h b/fairroot/generators/FairBoxGenerator.h similarity index 100% rename from generators/FairBoxGenerator.h rename to fairroot/generators/FairBoxGenerator.h diff --git a/generators/FairEvtGenGenerator.cxx b/fairroot/generators/FairEvtGenGenerator.cxx similarity index 96% rename from generators/FairEvtGenGenerator.cxx rename to fairroot/generators/FairEvtGenGenerator.cxx index caea273e51..004fa4c50f 100644 --- a/generators/FairEvtGenGenerator.cxx +++ b/fairroot/generators/FairEvtGenGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,12 +11,12 @@ // ------------------------------------------------------------------------- #include "FairEvtGenGenerator.h" -#include "FairLogger.h" #include "FairPrimaryGenerator.h" // for FairPrimaryGenerator #include // for TF1 #include // for TRandom, gRandom #include // max +#include FairEvtGenGenerator::FairEvtGenGenerator() : FairGenerator() @@ -36,7 +36,8 @@ FairEvtGenGenerator::FairEvtGenGenerator(const char* fileName) , fDensityFunction(0) { LOG(info) << "FairEvtGenGenerator: Opening input file " << fileName; - if ((fInputFile = fopen(fFileName, "r")) == nullptr) + fInputFile = fopen(fFileName, "r"); + if (!fInputFile) // fInputFile = new ifstream(fFileName); // if ( ! fInputFile->is_open() ) { @@ -55,7 +56,8 @@ FairEvtGenGenerator::FairEvtGenGenerator(const char* fileName, Double_t Rsigma, , fDensityFunction(DensityFunction) { LOG(info) << "FairEvtGenGenerator: Opening input file " << fileName; - if ((fInputFile = fopen(fFileName, "r")) == nullptr) { + fInputFile = fopen(fFileName, "r"); + if (!fInputFile) { LOG(fatal) << "Cannot open input file."; } } @@ -183,5 +185,3 @@ void FairEvtGenGenerator::CloseInput() fInputFile = nullptr; } } - -ClassImp(FairEvtGenGenerator); diff --git a/generators/FairEvtGenGenerator.h b/fairroot/generators/FairEvtGenGenerator.h similarity index 100% rename from generators/FairEvtGenGenerator.h rename to fairroot/generators/FairEvtGenGenerator.h diff --git a/generators/FairIonGenerator.cxx b/fairroot/generators/FairIonGenerator.cxx similarity index 92% rename from generators/FairIonGenerator.cxx rename to fairroot/generators/FairIonGenerator.cxx index 83807bd039..4b432e9f86 100644 --- a/generators/FairIonGenerator.cxx +++ b/fairroot/generators/FairIonGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,7 +12,6 @@ #include "FairIonGenerator.h" #include "FairIon.h" // for FairIon -#include "FairLogger.h" // for logging #include "FairParticle.h" // for FairParticle #include "FairPrimaryGenerator.h" // for FairPrimaryGenerator #include "FairRunSim.h" // for FairRunSim @@ -21,7 +20,8 @@ #include // for TObjArray #include // for TParticle #include // for TParticlePDG -#include // for sprintf +#include +#include // for format Int_t FairIonGenerator::fgNIon = 0; @@ -107,9 +107,7 @@ FairIonGenerator::FairIonGenerator(Int_t z, fVy = vy; fVz = vz; */ - char buffer[20]; - sprintf(buffer, "FairIon%d", fgNIon); - fIon = new FairIon(buffer, z, a, q); + fIon = new FairIon(fmt::format("FairIon{}", fgNIon).c_str(), z, a, q); FairRunSim* run = FairRunSim::Instance(); if (!run) { LOG(error) << "No FairRun instantised!"; @@ -141,9 +139,15 @@ FairIonGenerator::~FairIonGenerator() // if (fIon) delete fIon; } -void FairIonGenerator::SetExcitationEnergy(Double_t eExc) { fIon->SetExcEnergy(eExc); } +void FairIonGenerator::SetExcitationEnergy(Double_t eExc) +{ + fIon->SetExcEnergy(eExc); +} -void FairIonGenerator::SetMass(Double_t mass) { fIon->SetMass(mass); } +void FairIonGenerator::SetMass(Double_t mass) +{ + fIon->SetMass(mass); +} Bool_t FairIonGenerator::ReadEvent(FairPrimaryGenerator* primGen) { @@ -175,5 +179,3 @@ FairGenerator* FairIonGenerator::CloneGenerator() const return new FairIonGenerator(*this); } - -ClassImp(FairIonGenerator); diff --git a/generators/FairIonGenerator.h b/fairroot/generators/FairIonGenerator.h similarity index 100% rename from generators/FairIonGenerator.h rename to fairroot/generators/FairIonGenerator.h diff --git a/generators/FairParticleGenerator.cxx b/fairroot/generators/FairParticleGenerator.cxx similarity index 94% rename from generators/FairParticleGenerator.cxx rename to fairroot/generators/FairParticleGenerator.cxx index a0254702c1..e1a01e8dc3 100644 --- a/generators/FairParticleGenerator.cxx +++ b/fairroot/generators/FairParticleGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,9 +11,10 @@ // ------------------------------------------------------------------------- #include "FairParticleGenerator.h" -#include "FairLogger.h" #include "FairPrimaryGenerator.h" // for FairPrimaryGenerator +#include + FairParticleGenerator::FairParticleGenerator() : FairBaseMCGenerator() , fPx(0) @@ -65,5 +66,3 @@ Bool_t FairParticleGenerator::ReadEvent(FairPrimaryGenerator* primGen) return kTRUE; } - -ClassImp(FairParticleGenerator); diff --git a/generators/FairParticleGenerator.h b/fairroot/generators/FairParticleGenerator.h similarity index 100% rename from generators/FairParticleGenerator.h rename to fairroot/generators/FairParticleGenerator.h diff --git a/generators/FairShieldGenerator.cxx b/fairroot/generators/FairShieldGenerator.cxx similarity index 67% rename from generators/FairShieldGenerator.cxx rename to fairroot/generators/FairShieldGenerator.cxx index f36b338f96..409ccf317f 100644 --- a/generators/FairShieldGenerator.cxx +++ b/fairroot/generators/FairShieldGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,31 +16,24 @@ #include "FairPrimaryGenerator.h" // for FairPrimaryGenerator #include "FairRunSim.h" // for FairRunSim -#include // for TDatabasePDG #include // for TParticlePDG #include // for INT_MAX -#include // for sprintf -#include // for ifstream -#include // for pair +#include // for format +#include FairShieldGenerator::FairShieldGenerator() : FairGenerator() - , fInputFile(nullptr) - , fFileName(nullptr) , fPDG(nullptr) - , fIonMap() {} FairShieldGenerator::FairShieldGenerator(const char* fileName) : FairGenerator() - , fInputFile(nullptr) , fFileName(fileName) , fPDG(TDatabasePDG::Instance()) - , fIonMap() { LOG(info) << "FairShieldGenerator: Opening input file " << fileName; - fInputFile = new std::ifstream(fFileName); - if (!fInputFile->is_open()) { + fInputFile.open(fFileName); + if (!fInputFile.is_open()) { LOG(fatal) << "Cannot open input file."; } LOG(info) << "FairShieldGenerator: Looking for ions..."; @@ -48,15 +41,15 @@ FairShieldGenerator::FairShieldGenerator(const char* fileName) LOG(info) << "FairShieldGenerator: " << nIons << " ions registered."; CloseInput(); LOG(info) << "FairShieldGenerator: Reopening input file " << fileName; - fInputFile = new std::ifstream(fFileName); + fInputFile.open(fFileName); } -FairShieldGenerator::~FairShieldGenerator() { CloseInput(); } +FairShieldGenerator::~FairShieldGenerator() = default; Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen) { // Check for input file - if (!fInputFile->is_open()) { + if (!fInputFile.is_open()) { LOG(error) << "FairShieldGenerator: Input file not open!"; return kFALSE; } @@ -77,14 +70,14 @@ Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen) Int_t pdgType = 0; // Read event header line from input file - *fInputFile >> eventId; - *fInputFile >> nTracks; + fInputFile >> eventId; + fInputFile >> nTracks; if (nTracks < 0 || nTracks > (INT_MAX - 1)) LOG(fatal) << "Error reading the number of events from event header."; - *fInputFile >> pBeam >> b; + fInputFile >> pBeam >> b; // If end of input file is reached : close it and abort run - if (fInputFile->eof()) { + if (fInputFile.eof()) { LOG(info) << "FairShieldGenerator: End of input file reached "; CloseInput(); return kFALSE; @@ -97,13 +90,12 @@ Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen) for (Int_t itrack = 0; itrack < nTracks; itrack++) { // Read PID and momentum from file - *fInputFile >> iPid >> iMass >> iCharge >> px >> py >> pz; + fInputFile >> iPid >> iMass >> iCharge >> px >> py >> pz; // Case ion if (iPid == 1000) { - char ionName[20]; - sprintf(ionName, "Ion_%d_%d", iMass, iCharge); - TParticlePDG* part = fPDG->GetParticle(ionName); + const auto ionName = fmt::format("Ion_{}_{}", iMass, iCharge); + TParticlePDG* part = fPDG->GetParticle(ionName.c_str()); if (!part) { LOG(warn) << "FairShieldGenerator::ReadEvent: Cannot find " << ionName << " in database!"; continue; @@ -122,55 +114,46 @@ Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen) void FairShieldGenerator::CloseInput() { - if (fInputFile) { - if (fInputFile->is_open()) { - LOG(info) << "FairShieldGenerator: Closing input file " << fFileName; - fInputFile->close(); - } - delete fInputFile; - fInputFile = nullptr; + if (fInputFile.is_open()) { + LOG(info) << "FairShieldGenerator: Closing input file " << fFileName; + fInputFile.close(); } } Int_t FairShieldGenerator::RegisterIons() { + FairRunSim* run = FairRunSim::Instance(); Int_t nIons = 0; - Int_t eventId, nTracks, iPid, iMass, iCharge; - Double_t pBeam, b, px, py, pz; - fIonMap.clear(); + std::set duplicatecheck; - while (!fInputFile->eof()) { + while (!fInputFile.eof()) { + Int_t eventId, nTracks; - *fInputFile >> eventId; - *fInputFile >> nTracks; + fInputFile >> eventId; + fInputFile >> nTracks; if (nTracks < 0 || nTracks > (INT_MAX - 1)) LOG(fatal) << "Error reading the number of events from event header."; - *fInputFile >> pBeam >> b; - if (fInputFile->eof()) { + Double_t pBeam, b; + fInputFile >> pBeam >> b; + if (fInputFile.eof()) { continue; } for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) { - *fInputFile >> iPid >> iMass >> iCharge >> px >> py >> pz; + Int_t iPid, iMass, iCharge; + Double_t px, py, pz; + fInputFile >> iPid >> iMass >> iCharge >> px >> py >> pz; if (iPid == 1000) { // ion - char buffer[20]; - sprintf(buffer, "Ion_%d_%d", iMass, iCharge); - TString ionName(buffer); - if (fIonMap.find(ionName) == fIonMap.end()) { // new ion - FairIon* ion = new FairIon(ionName, iCharge, iMass, iCharge); - fIonMap[ionName] = ion; + const auto ionName = fmt::format("Ion_{}_{}", iMass, iCharge); + if (duplicatecheck.count(ionName) == 0) { + // new ion + auto ion = new FairIon(ionName.c_str(), iCharge, iMass, iCharge); + duplicatecheck.emplace(ionName); + run->AddNewIon(ion); nIons++; } // new ion } // ion } // track loop } // event loop - FairRunSim* run = FairRunSim::Instance(); - for (const auto& mi : fIonMap) { - FairIon* ion = mi.second; - run->AddNewIon(ion); - } - return nIons; } - -ClassImp(FairShieldGenerator); diff --git a/generators/FairShieldGenerator.h b/fairroot/generators/FairShieldGenerator.h similarity index 63% rename from generators/FairShieldGenerator.h rename to fairroot/generators/FairShieldGenerator.h index d31c1836fc..296bcd8912 100644 --- a/generators/FairShieldGenerator.h +++ b/fairroot/generators/FairShieldGenerator.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,35 +10,32 @@ // ----- Created 15/09/06 by V. Friese ----- // ------------------------------------------------------------------------- -/** FairShieldGenerator - *@author V.Friese - *@since 15.09.06 - *@version 1.0 - * - ** The FairShieldGenerator is similar to the FairAsciiGenerator. It uses the - ** ASCII output of the SHIELD code as input for simulation. - ** The format of the event header is: - ** event nr.; number of particles; beam momentum; impact parameter - ** followed by a line for each particle of the format - ** PID; A; Z; px; py; pz - ** The PID must be given as for Geant3. For ions, it is 1000. The total - ** momentum is required, not momentum per nucleon. - **/ - #ifndef FAIRSHIELDGENERATOR_H #define FAIRSHIELDGENERATOR_H 1 #include "FairGenerator.h" // for FairGenerator -#include // for FairShieldGenerator::Class, etc -#include // for TString -#include // for ifstream -#include // for map +#include // for FairShieldGenerator::Class, etc +#include +#include // for ifstream +#include -class TDatabasePDG; class FairPrimaryGenerator; -class FairIon; +/** + *@author V.Friese + *@since 15.09.06 + *@version 1.0 + * + * The FairShieldGenerator is similar to the FairAsciiGenerator. It uses the + * ASCII output of the SHIELD code as input for simulation. + * The format of the event header is: + * event nr.; number of particles; beam momentum; impact parameter + * followed by a line for each particle of the format + * PID; A; Z; px; py; pz + * The PID must be given as for Geant3. For ions, it is 1000. The total + * momentum is required, not momentum per nucleon. + **/ class FairShieldGenerator : public FairGenerator { public: @@ -51,18 +48,18 @@ class FairShieldGenerator : public FairGenerator FairShieldGenerator(const char* fileName); /** Destructor. **/ - virtual ~FairShieldGenerator(); + ~FairShieldGenerator() override; /** Reads on event from the input file and pushes the tracks onto ** the stack. Abstract method in base class. ** @param primGen pointer to the FairPrimaryGenerator **/ - virtual Bool_t ReadEvent(FairPrimaryGenerator* primGen); + Bool_t ReadEvent(FairPrimaryGenerator* primGen) override; private: - std::ifstream* fInputFile; //! Input file stream - const Char_t* fFileName; //! Input file Name - TDatabasePDG* fPDG; //! PDG database + std::ifstream fInputFile; //! Input file stream + std::string fFileName; //! Input file Name + TDatabasePDG* fPDG; //! PDG database /** Private method CloseInput. Just for convenience. Closes the ** input file properly. Called from destructor and from ReadEvent. **/ @@ -72,13 +69,10 @@ class FairShieldGenerator : public FairGenerator ** any ion needed. **/ Int_t RegisterIons(); - /** STL map from ion name to FairIon **/ - std::map fIonMap; //! - FairShieldGenerator(const FairShieldGenerator&); FairShieldGenerator& operator=(const FairShieldGenerator&); - ClassDef(FairShieldGenerator, 1); + ClassDefOverride(FairShieldGenerator, 1); }; #endif diff --git a/generators/FairUrqmdGenerator.cxx b/fairroot/generators/FairUrqmdGenerator.cxx similarity index 99% rename from generators/FairUrqmdGenerator.cxx rename to fairroot/generators/FairUrqmdGenerator.cxx index 7343c8d2a8..0300e13d80 100644 --- a/generators/FairUrqmdGenerator.cxx +++ b/fairroot/generators/FairUrqmdGenerator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -360,5 +360,3 @@ void FairUrqmdGenerator::CheckReturnValue(Int_t retval) LOG(error) << "Error when reading variable from input file"; } } - -ClassImp(FairUrqmdGenerator); diff --git a/generators/FairUrqmdGenerator.h b/fairroot/generators/FairUrqmdGenerator.h similarity index 94% rename from generators/FairUrqmdGenerator.h rename to fairroot/generators/FairUrqmdGenerator.h index 5f39e1e18f..b6b9ac72a6 100644 --- a/generators/FairUrqmdGenerator.h +++ b/fairroot/generators/FairUrqmdGenerator.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -55,8 +55,6 @@ class FairUrqmdGenerator : public FairGenerator /** Reads on event from the input file and pushes the tracks onto ** the stack. Abstract method in base class. - ** @param pStack pointer to the stack - ** @param ver not used **/ Bool_t ReadEvent(FairPrimaryGenerator* primGen); diff --git a/generators/FairYPtGenerator.cxx b/fairroot/generators/FairYPtGenerator.cxx similarity index 100% rename from generators/FairYPtGenerator.cxx rename to fairroot/generators/FairYPtGenerator.cxx diff --git a/generators/FairYPtGenerator.h b/fairroot/generators/FairYPtGenerator.h similarity index 100% rename from generators/FairYPtGenerator.h rename to fairroot/generators/FairYPtGenerator.h diff --git a/generators/LinkDef.h b/fairroot/generators/LinkDef.h similarity index 100% rename from generators/LinkDef.h rename to fairroot/generators/LinkDef.h diff --git a/generators/README.dox b/fairroot/generators/README.dox similarity index 100% rename from generators/README.dox rename to fairroot/generators/README.dox diff --git a/geobase/CMakeLists.txt b/fairroot/geobase/CMakeLists.txt similarity index 91% rename from geobase/CMakeLists.txt rename to fairroot/geobase/CMakeLists.txt index fd2cdae2f2..a087f60160 100644 --- a/geobase/CMakeLists.txt +++ b/fairroot/geobase/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -53,11 +53,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC ROOT::Core diff --git a/geobase/FairGeoAsciiIo.cxx b/fairroot/geobase/FairGeoAsciiIo.cxx similarity index 98% rename from geobase/FairGeoAsciiIo.cxx rename to fairroot/geobase/FairGeoAsciiIo.cxx index 491354e287..ab6d240e04 100644 --- a/geobase/FairGeoAsciiIo.cxx +++ b/fairroot/geobase/FairGeoAsciiIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,8 +30,6 @@ using std::cout; using std::endl; using std::ios; -ClassImp(FairGeoAsciiIo); - FairGeoAsciiIo::FairGeoAsciiIo() : FairGeoIo() , filename("") diff --git a/geobase/FairGeoAsciiIo.h b/fairroot/geobase/FairGeoAsciiIo.h similarity index 94% rename from geobase/FairGeoAsciiIo.h rename to fairroot/geobase/FairGeoAsciiIo.h index ff1af2ec88..073c91436c 100644 --- a/geobase/FairGeoAsciiIo.h +++ b/fairroot/geobase/FairGeoAsciiIo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,7 +31,7 @@ class FairGeoAsciiIo : public FairGeoIo public: FairGeoAsciiIo(); - virtual ~FairGeoAsciiIo(); + ~FairGeoAsciiIo() override; void setDirectory(const char* fDir) { filedir = fDir; } const char* getDirectory() { return filedir.Data(); } const char* getFilename() { return filename.Data(); } diff --git a/geobase/FairGeoAssembly.cxx b/fairroot/geobase/FairGeoAssembly.cxx similarity index 85% rename from geobase/FairGeoAssembly.cxx rename to fairroot/geobase/FairGeoAssembly.cxx index c60402f902..2af68ddc1b 100644 --- a/geobase/FairGeoAssembly.cxx +++ b/fairroot/geobase/FairGeoAssembly.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,14 +19,11 @@ #include "FairGeoVector.h" // for FairGeoVector #include "FairGeoVolume.h" // for FairGeoVolume -#include // for TArrayD -#include // for TString -#include -#include // for fstream, etc -#include // for printf, sprintf -#include // for strlen - -ClassImp(FairGeoAssembly); +#include // for TArrayD +#include // for TString +#include // for printf +#include // for format +#include // for fstream, etc FairGeoAssembly::FairGeoAssembly() : FairGeoBasicShape() @@ -75,11 +72,9 @@ Bool_t FairGeoAssembly::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); - sprintf(buf, "%9.3f\n", v(0)); - pFile->write(buf, strlen(buf)); + *pFile << fmt::format("{:9.3f}\n", v(0)); } return kTRUE; } diff --git a/geobase/FairGeoAssembly.h b/fairroot/geobase/FairGeoAssembly.h similarity index 91% rename from geobase/FairGeoAssembly.h rename to fairroot/geobase/FairGeoAssembly.h index a94a81820e..d8a449d21b 100644 --- a/geobase/FairGeoAssembly.h +++ b/fairroot/geobase/FairGeoAssembly.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,7 +21,7 @@ class FairGeoAssembly : public FairGeoBasicShape { public: FairGeoAssembly(); - ~FairGeoAssembly(); + ~FairGeoAssembly() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream* pFile, FairGeoVolume* volu) override; diff --git a/geobase/FairGeoBasicShape.cxx b/fairroot/geobase/FairGeoBasicShape.cxx similarity index 90% rename from geobase/FairGeoBasicShape.cxx rename to fairroot/geobase/FairGeoBasicShape.cxx index d467c261f1..c87a5c7104 100644 --- a/geobase/FairGeoBasicShape.cxx +++ b/fairroot/geobase/FairGeoBasicShape.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,16 +22,14 @@ #include "FairGeoVector.h" // for FairGeoVector #include "FairGeoVolume.h" // for FairGeoVolume -#include // for TArrayD -#include // for fstream -#include // for cout -#include // for printf, sprintf, sscanf -#include // for strlen +#include // for TArrayD +#include // for printf, sscanf +#include // for format +#include // for fstream +#include // for cout using std::cout; -ClassImp(FairGeoBasicShape); - FairGeoBasicShape::FairGeoBasicShape() : TNamed() , nPoints(0) @@ -89,11 +87,9 @@ Bool_t FairGeoBasicShape::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < volu->getNumPoints(); i++) { FairGeoVector& v = *(volu->getPoint(i)); - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); - pFile->write(buf, strlen(buf)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } return kTRUE; } diff --git a/geobase/FairGeoBasicShape.h b/fairroot/geobase/FairGeoBasicShape.h similarity index 90% rename from geobase/FairGeoBasicShape.h rename to fairroot/geobase/FairGeoBasicShape.h index d6d8745bcf..bd316d1120 100644 --- a/geobase/FairGeoBasicShape.h +++ b/fairroot/geobase/FairGeoBasicShape.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,7 +29,7 @@ class FairGeoBasicShape : public TNamed FairGeoTransform* position; // position of the ROOT volume in its ROOT mother public: FairGeoBasicShape(); - virtual ~FairGeoBasicShape(); + ~FairGeoBasicShape() override; Int_t getNumPoints() { return nPoints; } Int_t getNumParam() { return nParam; } TArrayD* getParam() { return param; } @@ -40,12 +40,12 @@ class FairGeoBasicShape : public TNamed virtual void printPoints(FairGeoVolume* volu); virtual TArrayD* calcVoluParam(FairGeoVolume*) { return 0; } virtual void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&); - virtual void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) { return; } + virtual void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) {} void printParam(); protected: void posInMother(const FairGeoTransform&, const FairGeoTransform&); - ClassDef(FairGeoBasicShape, 0); // base class for all shapes + ClassDefOverride(FairGeoBasicShape, 0); // base class for all shapes private: FairGeoBasicShape(const FairGeoBasicShape&); FairGeoBasicShape& operator=(const FairGeoBasicShape&); diff --git a/geobase/FairGeoBrik.cxx b/fairroot/geobase/FairGeoBrik.cxx similarity index 95% rename from geobase/FairGeoBrik.cxx rename to fairroot/geobase/FairGeoBrik.cxx index 063b8c36d1..5f96a591de 100644 --- a/geobase/FairGeoBrik.cxx +++ b/fairroot/geobase/FairGeoBrik.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,8 +29,6 @@ #include // for TArrayD #include // for TString -ClassImp(FairGeoBrik); - FairGeoBrik::FairGeoBrik() : FairGeoBasicShape() { diff --git a/geobase/FairGeoBrik.h b/fairroot/geobase/FairGeoBrik.h similarity index 90% rename from geobase/FairGeoBrik.h rename to fairroot/geobase/FairGeoBrik.h index 3bc0bfc87f..01d203fd12 100644 --- a/geobase/FairGeoBrik.h +++ b/fairroot/geobase/FairGeoBrik.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,7 +20,7 @@ class FairGeoBrik : public FairGeoBasicShape { public: FairGeoBrik(); - ~FairGeoBrik(); + ~FairGeoBrik() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; ClassDefOverride(FairGeoBrik, 0); // class for geometry shape BOX or BRIK diff --git a/geobase/FairGeoBuilder.cxx b/fairroot/geobase/FairGeoBuilder.cxx similarity index 90% rename from geobase/FairGeoBuilder.cxx rename to fairroot/geobase/FairGeoBuilder.cxx index 28ddcc5994..5b882db4ab 100644 --- a/geobase/FairGeoBuilder.cxx +++ b/fairroot/geobase/FairGeoBuilder.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,8 +17,6 @@ #include "FairGeoBuilder.h" -ClassImp(FairGeoBuilder); - FairGeoBuilder::FairGeoBuilder() : TNamed() , nRot(0) diff --git a/geobase/FairGeoBuilder.h b/fairroot/geobase/FairGeoBuilder.h similarity index 88% rename from geobase/FairGeoBuilder.h rename to fairroot/geobase/FairGeoBuilder.h index 38b77c165d..b60e072ff2 100644 --- a/geobase/FairGeoBuilder.h +++ b/fairroot/geobase/FairGeoBuilder.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,13 +28,13 @@ class FairGeoBuilder : public TNamed FairGeoBuilder(const char* name, const char* title); public: - virtual ~FairGeoBuilder() {} + ~FairGeoBuilder() override = default; virtual Bool_t createNode(FairGeoNode*, Int_t hadFormat = 0) = 0; virtual Int_t createMedium(FairGeoMedium*) = 0; virtual void finalize() {} inline const Int_t& GetNMedia() const { return nMed; } inline void SetNMedia(const Int_t& nmed) { nMed = nmed; } - ClassDef(FairGeoBuilder, 0); + ClassDefOverride(FairGeoBuilder, 0); }; #endif /* !FAIRGEOBUILDER_H */ diff --git a/geobase/FairGeoCompositeVolume.cxx b/fairroot/geobase/FairGeoCompositeVolume.cxx similarity index 95% rename from geobase/FairGeoCompositeVolume.cxx rename to fairroot/geobase/FairGeoCompositeVolume.cxx index 2f717bd251..ef73e13d21 100644 --- a/geobase/FairGeoCompositeVolume.cxx +++ b/fairroot/geobase/FairGeoCompositeVolume.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,8 +17,6 @@ #include // for TObjArray -ClassImp(FairGeoCompositeVolume); - FairGeoCompositeVolume::FairGeoCompositeVolume(Int_t nComp) : FairGeoVolume() , components(nullptr) diff --git a/geobase/FairGeoCompositeVolume.h b/fairroot/geobase/FairGeoCompositeVolume.h similarity index 91% rename from geobase/FairGeoCompositeVolume.h rename to fairroot/geobase/FairGeoCompositeVolume.h index ca63fe2fd9..145cabbee6 100644 --- a/geobase/FairGeoCompositeVolume.h +++ b/fairroot/geobase/FairGeoCompositeVolume.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,7 @@ class FairGeoCompositeVolume : public FairGeoVolume public: FairGeoCompositeVolume(Int_t nComp = 0); - ~FairGeoCompositeVolume(); + ~FairGeoCompositeVolume() override; Int_t getNumComponents(); FairGeoVolume* getComponent(const Int_t); void createComponents(const Int_t); diff --git a/geobase/FairGeoCone.cxx b/fairroot/geobase/FairGeoCone.cxx similarity index 91% rename from geobase/FairGeoCone.cxx rename to fairroot/geobase/FairGeoCone.cxx index b5ab571f4f..fc128c3b68 100644 --- a/geobase/FairGeoCone.cxx +++ b/fairroot/geobase/FairGeoCone.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -40,12 +40,9 @@ #include // for TArrayD #include // for Abs #include // for TString -#include -#include // for fstream, etc -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoCone); +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoCone::FairGeoCone() : FairGeoBasicShape() @@ -107,15 +104,13 @@ Bool_t FairGeoCone::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); if (i == 0 || i == 2) { - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } else { - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoCone.h b/fairroot/geobase/FairGeoCone.h similarity index 92% rename from geobase/FairGeoCone.h rename to fairroot/geobase/FairGeoCone.h index 4e2f3a6b85..4b9ca5df02 100644 --- a/geobase/FairGeoCone.h +++ b/fairroot/geobase/FairGeoCone.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,7 @@ class FairGeoCone : public FairGeoBasicShape { public: FairGeoCone(); - ~FairGeoCone(); + ~FairGeoCone() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoCons.cxx b/fairroot/geobase/FairGeoCons.cxx similarity index 92% rename from geobase/FairGeoCons.cxx rename to fairroot/geobase/FairGeoCons.cxx index 44fd490108..e6417eaa54 100644 --- a/geobase/FairGeoCons.cxx +++ b/fairroot/geobase/FairGeoCons.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -43,12 +43,9 @@ #include // for TArrayD #include // for Abs #include // for TString -#include -#include // for fstream, etc -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoCons); +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoCons::FairGeoCons() : FairGeoBasicShape() @@ -111,15 +108,13 @@ Bool_t FairGeoCons::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); if (i == 0 || i == 2) { - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } else { - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoCons.h b/fairroot/geobase/FairGeoCons.h similarity index 92% rename from geobase/FairGeoCons.h rename to fairroot/geobase/FairGeoCons.h index b495359f46..1f701e42ba 100644 --- a/geobase/FairGeoCons.h +++ b/fairroot/geobase/FairGeoCons.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,7 @@ class FairGeoCons : public FairGeoBasicShape { public: FairGeoCons(); - ~FairGeoCons(); + ~FairGeoCons() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoEltu.cxx b/fairroot/geobase/FairGeoEltu.cxx similarity index 91% rename from geobase/FairGeoEltu.cxx rename to fairroot/geobase/FairGeoEltu.cxx index a37be52ef7..95f19eb0a8 100644 --- a/geobase/FairGeoEltu.cxx +++ b/fairroot/geobase/FairGeoEltu.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -37,12 +37,9 @@ #include // for TArrayD #include // for Abs #include // for TString -#include -#include // for fstream, etc -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoEltu); +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoEltu::FairGeoEltu() : FairGeoBasicShape() @@ -105,15 +102,13 @@ Bool_t FairGeoEltu::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); if (i != 1) { - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } else { - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoEltu.h b/fairroot/geobase/FairGeoEltu.h similarity index 92% rename from geobase/FairGeoEltu.h rename to fairroot/geobase/FairGeoEltu.h index d57674c222..6c532180c2 100644 --- a/geobase/FairGeoEltu.h +++ b/fairroot/geobase/FairGeoEltu.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,7 +25,7 @@ class FairGeoEltu : public FairGeoBasicShape { public: FairGeoEltu(); - ~FairGeoEltu(); + ~FairGeoEltu() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoInterface.cxx b/fairroot/geobase/FairGeoInterface.cxx similarity index 89% rename from geobase/FairGeoInterface.cxx rename to fairroot/geobase/FairGeoInterface.cxx index 81f7673447..38c8ec7302 100644 --- a/geobase/FairGeoInterface.cxx +++ b/fairroot/geobase/FairGeoInterface.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,17 +33,15 @@ #include // for TClass #include // for TList #include // for TObjArray +#include // for printf, sscanf +#include // for format #include // for operator<<, basic_ostream, etc -#include // for sprintf -#include // for strcmp #include // for time_t #include // for tm, localtime, time using std::cout; using std::endl; -ClassImp(FairGeoInterface); - FairGeoInterface::FairGeoInterface() : TObject() , fileInput(nullptr) @@ -102,7 +100,10 @@ void FairGeoInterface::addGeoModule(FairGeoSet* pSet) pSet->setMasterNodes(masterNodes); nActualSets++; } -void FairGeoInterface::setMediaFile(const char* file) { media->setInputFile(file); } +void FairGeoInterface::setMediaFile(const char* file) +{ + media->setInputFile(file); +} void FairGeoInterface::addInputFile(const char* file) { @@ -429,50 +430,19 @@ Bool_t FairGeoInterface::connectOutput(const char* name) // Connects the output (ASCII or Oracle) if (output) { if (strcmp(output->IsA()->GetName(), "FairGeoAsciiIo") == 0) { - TString fName(name); - char buf[80]; struct tm* newtime; time_t t; time(&t); newtime = localtime(&t); - if (newtime->tm_mday < 10) { - sprintf(buf, "_0%i", newtime->tm_mday); - } else { - sprintf(buf, "_%i", newtime->tm_mday); - } - fName = fName + buf; - if (newtime->tm_mon < 9) { - sprintf(buf, "0%i", newtime->tm_mon + 1); - } else { - sprintf(buf, "%i", newtime->tm_mon + 1); - } - fName = fName + buf; - Int_t y = newtime->tm_year - 100; - if (y < 10) { - sprintf(buf, "0%i", y); - } else { - sprintf(buf, "%i", y); - } - fName = fName + buf; - if (newtime->tm_hour < 10) { - sprintf(buf, "0%i", newtime->tm_hour); - } else { - sprintf(buf, "%i", newtime->tm_hour); - } - fName = fName + buf; - if (newtime->tm_min < 10) { - sprintf(buf, "0%i", newtime->tm_min); - } else { - sprintf(buf, "%i", newtime->tm_min); - } - fName = fName + buf; - if (newtime->tm_sec < 10) { - sprintf(buf, "0%i", newtime->tm_sec); - } else { - sprintf(buf, "%i", newtime->tm_sec); - } - fName = fName + buf + ".geo"; - output->open(fName, "out"); + const auto fullName = fmt::format("{}_{:02d}{:02d}{:02d}{:02d}{:02d}{:02d}.geo", + name, + newtime->tm_mday, + newtime->tm_mon + 1, + newtime->tm_year - 100, + newtime->tm_hour, + newtime->tm_min, + newtime->tm_sec); + output->open(fullName.c_str(), "out"); cout << "Output file for " << name << ": " << (static_cast(output))->getFilename() << endl; } diff --git a/geobase/FairGeoInterface.h b/fairroot/geobase/FairGeoInterface.h similarity index 95% rename from geobase/FairGeoInterface.h rename to fairroot/geobase/FairGeoInterface.h index 189bce4def..107e50cd92 100644 --- a/geobase/FairGeoInterface.h +++ b/fairroot/geobase/FairGeoInterface.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -54,7 +54,7 @@ class FairGeoInterface : public TObject public: FairGeoInterface(); - ~FairGeoInterface(); + ~FairGeoInterface() override; void setOracleInput(FairGeoIo* p) { oraInput = p; } void setOutput(FairGeoIo* p) { output = p; } void setGeomBuilder(FairGeoBuilder* p) { geoBuilder = p; } @@ -93,7 +93,7 @@ class FairGeoInterface : public TObject FairGeoIo* connectInput(const char*); Bool_t connectOutput(const char*); - ClassDef(FairGeoInterface, 0); + ClassDefOverride(FairGeoInterface, 0); }; #endif /* !FAIRGEOINTERFACE_H */ diff --git a/geobase/FairGeoIo.cxx b/fairroot/geobase/FairGeoIo.cxx similarity index 97% rename from geobase/FairGeoIo.cxx rename to fairroot/geobase/FairGeoIo.cxx index 91ad83b9d7..1011624285 100644 --- a/geobase/FairGeoIo.cxx +++ b/fairroot/geobase/FairGeoIo.cxx @@ -16,5 +16,3 @@ /////////////////////////////////////////////////////////////////////////////// #include "FairGeoIo.h" - -ClassImp(FairGeoIo); diff --git a/geobase/FairGeoIo.h b/fairroot/geobase/FairGeoIo.h similarity index 92% rename from geobase/FairGeoIo.h rename to fairroot/geobase/FairGeoIo.h index 4aeb9dadcf..d2ad376f1d 100644 --- a/geobase/FairGeoIo.h +++ b/fairroot/geobase/FairGeoIo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -36,7 +36,7 @@ class FairGeoIo : public TObject virtual Bool_t setHistoryDate(const char*) = 0; private: - ClassDef(FairGeoIo, 0); + ClassDefOverride(FairGeoIo, 0); }; #endif /* !FAIRGEOIO_H */ diff --git a/geobase/FairGeoLoader.cxx b/fairroot/geobase/FairGeoLoader.cxx similarity index 79% rename from geobase/FairGeoLoader.cxx rename to fairroot/geobase/FairGeoLoader.cxx index 137cd1ec3b..987bab818c 100644 --- a/geobase/FairGeoLoader.cxx +++ b/fairroot/geobase/FairGeoLoader.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,46 +29,46 @@ FairGeoLoader* FairGeoLoader::fgInstance = nullptr; FairGeoLoader* FairGeoLoader::Instance() { return fgInstance; } +static std::unique_ptr MakeGeoBuilder(const char* Name) +{ + if (strncmp(Name, "TGeo", 4) == 0) { + auto geom = std::make_unique("FAIRGeom", "FAIR geometry"); + return std::make_unique("TGeo builder", "geometry builder", std::move(geom)); + } + + if (strncmp(Name, "G3Native", 8) == 0) { + cout << "-I- FairGeoLoader() : Native G3 Geometry is used: This option is not supported any more!" << endl; + exit(0); + // gGeoManager = NULL; + // fGeoBuilder=new FairGeoG3Builder("G3 builder","geometry builder"); + } + + return {}; +} + FairGeoLoader::FairGeoLoader() : TNamed() - , fInterface(NULL) - , fGeoBuilder(NULL) { fgInstance = this; } FairGeoLoader::FairGeoLoader(const char* Name, const char* title) : TNamed(Name, title) - , fInterface(NULL) - , fGeoBuilder(NULL) + , fGeoBuilder(MakeGeoBuilder(Name)) { if (fgInstance) { Fatal("FairGeoLoader", "Singleton instance already exists."); return; } fgInstance = this; - fInterface = new FairGeoInterface; - if (strncmp(Name, "TGeo", 4) == 0) { - TGeoManager* geom = new TGeoManager("FAIRGeom", "FAIR geometry"); - fGeoBuilder = new FairGeoRootBuilder("TGeo builder", "geometry builder"); - (static_cast(fGeoBuilder))->setGeoManager(geom); - } else if (strncmp(Name, "G3Native", 8) == 0) { - cout << "-I- FairGeoLoader() : Native G3 Geometry is used: This option is not supported any more!" << endl; - exit(0); - // gGeoManager = NULL; - // fGeoBuilder=new FairGeoG3Builder("G3 builder","geometry builder"); - } - fInterface->setGeomBuilder(fGeoBuilder); + fInterface.setGeomBuilder(fGeoBuilder.get()); } FairGeoLoader::~FairGeoLoader() { - delete fInterface; if (fgInstance == this) { // Do not point to a destructed object! fgInstance = nullptr; } } - -ClassImp(FairGeoLoader); diff --git a/geobase/FairGeoLoader.h b/fairroot/geobase/FairGeoLoader.h similarity index 66% rename from geobase/FairGeoLoader.h rename to fairroot/geobase/FairGeoLoader.h index e23ad327e6..4126b7f34d 100644 --- a/geobase/FairGeoLoader.h +++ b/fairroot/geobase/FairGeoLoader.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,23 +16,28 @@ #ifndef FairGeoLOADER_H #define FairGeoLOADER_H +#include "FairGeoInterface.h" + #include // for FairGeoLoader::Class, etc #include // for TNamed +#include -class FairGeoInterface; class FairGeoBuilder; -/**New Geometry Loader, this loader handel the Hades geometry description - * @author Ilse koenig - * @author M. Al-Turany*/ +/** + * New Geometry Loader, this loader handel the Hades geometry description + * \ingroup geobase fairroot_singleton + * @author Ilse koenig + * @author M. Al-Turany + */ class FairGeoLoader : public TNamed { public: FairGeoLoader(const char* Name, const char* title); FairGeoLoader(); - virtual ~FairGeoLoader(); - FairGeoInterface* getGeoInterface() { return fInterface; } - FairGeoBuilder* getGeoBuilder() { return fGeoBuilder; } + ~FairGeoLoader() override; + FairGeoInterface* getGeoInterface() { return &fInterface; } + FairGeoBuilder* getGeoBuilder() { return fGeoBuilder.get(); } /** static access method*/ static FairGeoLoader* Instance(); @@ -40,10 +45,16 @@ class FairGeoLoader : public TNamed FairGeoLoader(const FairGeoLoader&); FairGeoLoader& operator=(const FairGeoLoader&); static FairGeoLoader* fgInstance; //! /**Singleton instance*/ - FairGeoInterface* fInterface; //! /** Hades Geometry Interface*/ - FairGeoBuilder* fGeoBuilder; //! /**Geometry builder*/ - ClassDef(FairGeoLoader, 1); + std::unique_ptr fGeoBuilder; //!< Geometry builder + /** + * \brief Geometry Interface + * \note Must be destructed before `fGeoBuilder`, + * so must be after that member variable. + */ + FairGeoInterface fInterface{}; //! + + ClassDefOverride(FairGeoLoader, 0); }; #endif diff --git a/geobase/FairGeoMatrix.cxx b/fairroot/geobase/FairGeoMatrix.cxx similarity index 89% rename from geobase/FairGeoMatrix.cxx rename to fairroot/geobase/FairGeoMatrix.cxx index 7e11183184..fd90631849 100644 --- a/geobase/FairGeoMatrix.cxx +++ b/fairroot/geobase/FairGeoMatrix.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,7 +20,7 @@ // added as needed ///////////////////////////////////////////////////////// -FairGeoMatrix::FairGeoMatrix(void) +FairGeoMatrix::FairGeoMatrix() : TObject() { // Initializes the matrix to 0 @@ -29,9 +29,9 @@ FairGeoMatrix::FairGeoMatrix(void) } } -FairGeoMatrix::~FairGeoMatrix(void) {} +FairGeoMatrix::~FairGeoMatrix() {} -Double_t FairGeoMatrix::det(void) +Double_t FairGeoMatrix::det() { // Computes de determinat of the 3D matrix return (fM[0] * fM[4] * fM[8] + fM[1] * fM[5] * fM[6] + fM[3] * fM[7] * fM[2] - fM[2] * fM[4] * fM[6] @@ -57,5 +57,3 @@ FairGeoMatrix& FairGeoMatrix::operator/=(Double_t d) } return *this; } - -ClassImp(FairGeoMatrix); diff --git a/geobase/FairGeoMatrix.h b/fairroot/geobase/FairGeoMatrix.h similarity index 83% rename from geobase/FairGeoMatrix.h rename to fairroot/geobase/FairGeoMatrix.h index d8fbfae26c..ed33b09513 100644 --- a/geobase/FairGeoMatrix.h +++ b/fairroot/geobase/FairGeoMatrix.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,13 +22,13 @@ class FairGeoMatrix : public TObject Double_t fM[9]; public: - FairGeoMatrix(void); - ~FairGeoMatrix(void); + FairGeoMatrix(); + ~FairGeoMatrix() override; Double_t& operator()(Int_t i, Int_t j) { return fM[i * 3 + j]; } - Double_t det(void); + Double_t det(); FairGeoVector operator*(FairGeoVector& v); FairGeoMatrix& operator/=(Double_t d); - ClassDef(FairGeoMatrix, 0); + ClassDefOverride(FairGeoMatrix, 0); }; #endif diff --git a/geobase/FairGeoMedia.cxx b/fairroot/geobase/FairGeoMedia.cxx similarity index 97% rename from geobase/FairGeoMedia.cxx rename to fairroot/geobase/FairGeoMedia.cxx index bb1e912942..f75e4d16a5 100644 --- a/geobase/FairGeoMedia.cxx +++ b/fairroot/geobase/FairGeoMedia.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,8 +26,6 @@ using std::cout; using std::endl; -ClassImp(FairGeoMedia); - FairGeoMedia::FairGeoMedia() : TNamed() , media(new TList()) diff --git a/geobase/FairGeoMedia.h b/fairroot/geobase/FairGeoMedia.h similarity index 92% rename from geobase/FairGeoMedia.h rename to fairroot/geobase/FairGeoMedia.h index c057c899ed..d8f5666c30 100644 --- a/geobase/FairGeoMedia.h +++ b/fairroot/geobase/FairGeoMedia.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -29,7 +29,7 @@ class FairGeoMedia : public TNamed TString description; /** description of the version */ public: FairGeoMedia(); - ~FairGeoMedia(); + ~FairGeoMedia() override; void setInputFile(const char* file) { inputFile = file; } const char* getInputFile() { return inputFile; } void addMedium(FairGeoMedium* m); @@ -48,7 +48,7 @@ class FairGeoMedia : public TNamed FairGeoMedia(const FairGeoMedia&); FairGeoMedia& operator=(const FairGeoMedia&); - ClassDef(FairGeoMedia, 0); + ClassDefOverride(FairGeoMedia, 0); }; #endif /* !FAIRGEOMEDIA_H */ diff --git a/geobase/FairGeoMedium.cxx b/fairroot/geobase/FairGeoMedium.cxx similarity index 98% rename from geobase/FairGeoMedium.cxx rename to fairroot/geobase/FairGeoMedium.cxx index 2f51ff30a0..d954f601a1 100644 --- a/geobase/FairGeoMedium.cxx +++ b/fairroot/geobase/FairGeoMedium.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,8 +27,6 @@ using std::cout; using std::log; using std::pow; -ClassImp(FairGeoMedium); - FairGeoMedium::FairGeoMedium(const char* name) : TNamed(name, "") , medId(0) @@ -101,7 +99,7 @@ void FairGeoMedium::setNComponents(Int_t n) cz = new Double_t[k]; cw = new Double_t[k]; } - weightFac = static_cast(n / nComponents); + weightFac = n / nComponents; } Bool_t FairGeoMedium::setComponent(Int_t i, Double_t a, Double_t z, Double_t weight) diff --git a/geobase/FairGeoMedium.h b/fairroot/geobase/FairGeoMedium.h similarity index 96% rename from geobase/FairGeoMedium.h rename to fairroot/geobase/FairGeoMedium.h index 0b4f5aa047..b871554a0c 100644 --- a/geobase/FairGeoMedium.h +++ b/fairroot/geobase/FairGeoMedium.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -44,7 +44,7 @@ class FairGeoMedium : public TNamed public: FairGeoMedium(const char* name = ""); FairGeoMedium& operator=(const FairGeoMedium&) { return *this; } - ~FairGeoMedium(); + ~FairGeoMedium() override; void setMediumIndex(Int_t i) { medId = i; } Int_t getMediumIndex() { return medId; } void setAutoFlag(Int_t i) { autoflag = i; } @@ -86,7 +86,7 @@ class FairGeoMedium : public TNamed // TODO: correct copy constructor for FairGeoMedium // FairGeoMedium& operator=(const FairGeoMedium&); - ClassDef(FairGeoMedium, 1); // + ClassDefOverride(FairGeoMedium, 1); // }; inline Bool_t FairGeoMedium::isSensitive() diff --git a/geobase/FairGeoNode.cxx b/fairroot/geobase/FairGeoNode.cxx similarity index 97% rename from geobase/FairGeoNode.cxx rename to fairroot/geobase/FairGeoNode.cxx index 00093757e3..ab2cda1b68 100644 --- a/geobase/FairGeoNode.cxx +++ b/fairroot/geobase/FairGeoNode.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,8 +30,6 @@ using std::cout; using std::endl; -ClassImp(FairGeoNode); - FairGeoNode::FairGeoNode() : FairGeoVolume() , active(kFALSE) @@ -46,10 +44,7 @@ FairGeoNode::FairGeoNode() , labTransform(nullptr) , fDaughterList(new TObjArray(5)) , fTruncName("") -{ - // Constructor - clear(); -} +{} FairGeoNode::FairGeoNode(FairGeoNode& r) : FairGeoVolume(r) @@ -207,14 +202,14 @@ Bool_t FairGeoNode::write(std::fstream& fout) // Writes all parameters of a volume to file fout << fName.Data() << '\n'; if (pMother) { - fout << (const_cast(mother.Data())) << '\n'; + fout << mother.Data() << '\n'; } else { Error("write", "Unknown mother for %s\n", fName.Data()); return kFALSE; } if (!copyNode) { if (pShape) { - fout << (const_cast(shape.Data())) << '\n'; + fout << shape.Data() << '\n'; } else { Error("write", "Unknown shape for %s\n", fName.Data()); return kFALSE; diff --git a/geobase/FairGeoNode.h b/fairroot/geobase/FairGeoNode.h similarity index 91% rename from geobase/FairGeoNode.h rename to fairroot/geobase/FairGeoNode.h index 8b4496de02..78783a775e 100644 --- a/geobase/FairGeoNode.h +++ b/fairroot/geobase/FairGeoNode.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -60,14 +60,14 @@ class FairGeoNode : public FairGeoVolume public: FairGeoNode(); FairGeoNode(FairGeoNode&); - virtual ~FairGeoNode(); + ~FairGeoNode() override; void AddDaughter(FairGeoNode* fNode) { fDaughterList->AddLast(fNode); } TObjArray* GetListOfDaughters() { return fDaughterList; } EFairGeoNodeType getVolumeType() { return volumeType; } - Bool_t isTopNode() { return static_cast((volumeType == kFairGeoTopNode)); } - Bool_t isRefNode() { return static_cast((volumeType == kFairGeoRefNode)); } - Bool_t isKeepin() { return static_cast((volumeType == kFairGeoKeepin)); } - Bool_t isModule() { return static_cast((volumeType == kFairGeoModule)); } + Bool_t isTopNode() { return volumeType == kFairGeoTopNode; } + Bool_t isRefNode() { return volumeType == kFairGeoRefNode; } + Bool_t isKeepin() { return volumeType == kFairGeoKeepin; } + Bool_t isModule() { return volumeType == kFairGeoModule; } Int_t getCopyNo(); FairGeoBasicShape* getShapePointer() { return pShape; } FairGeoNode* getMotherNode() { return pMother; } diff --git a/geobase/FairGeoOldAsciiIo.cxx b/fairroot/geobase/FairGeoOldAsciiIo.cxx similarity index 98% rename from geobase/FairGeoOldAsciiIo.cxx rename to fairroot/geobase/FairGeoOldAsciiIo.cxx index 8349f8f8d3..10c9b4cb8e 100644 --- a/geobase/FairGeoOldAsciiIo.cxx +++ b/fairroot/geobase/FairGeoOldAsciiIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,8 +35,6 @@ using std::cout; using std::endl; using std::ios; -ClassImp(FairGeoOldAsciiIo); - FairGeoOldAsciiIo::FairGeoOldAsciiIo() : FairGeoIo() , filename("") diff --git a/geobase/FairGeoOldAsciiIo.h b/fairroot/geobase/FairGeoOldAsciiIo.h similarity index 94% rename from geobase/FairGeoOldAsciiIo.h rename to fairroot/geobase/FairGeoOldAsciiIo.h index 7b33b108ff..07fccf17a9 100644 --- a/geobase/FairGeoOldAsciiIo.h +++ b/fairroot/geobase/FairGeoOldAsciiIo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -32,7 +32,7 @@ class FairGeoOldAsciiIo : public FairGeoIo public: FairGeoOldAsciiIo(); - ~FairGeoOldAsciiIo(); + ~FairGeoOldAsciiIo() override; void setDirectory(const char* fDir) { filedir = fDir; } const char* getDirectory() { return filedir.Data(); } const char* getFilename() { return filename.Data(); } diff --git a/geobase/FairGeoPcon.cxx b/fairroot/geobase/FairGeoPcon.cxx similarity index 89% rename from geobase/FairGeoPcon.cxx rename to fairroot/geobase/FairGeoPcon.cxx index 842b650829..f1b9b50432 100644 --- a/geobase/FairGeoPcon.cxx +++ b/fairroot/geobase/FairGeoPcon.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,14 +35,11 @@ #include "FairGeoVector.h" // for FairGeoVector #include "FairGeoVolume.h" // for FairGeoVolume -#include // for TArrayD -#include // for TString -#include -#include // for fstream, etc -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoPcon); +#include // for TArrayD +#include // for TString +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoPcon::FairGeoPcon() : FairGeoBasicShape() @@ -105,20 +102,18 @@ Bool_t FairGeoPcon::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < volu->getNumPoints(); i++) { FairGeoVector& v = *(volu->getPoint(i)); switch (i) { case 0: - sprintf(buf, "%3i\n", static_cast(v(0))); + *pFile << fmt::format("{:3d}\n", static_cast(v(0))); break; case 1: - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); break; default: - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoPcon.h b/fairroot/geobase/FairGeoPcon.h similarity index 92% rename from geobase/FairGeoPcon.h rename to fairroot/geobase/FairGeoPcon.h index 0b0b0da62a..81edc2533a 100644 --- a/geobase/FairGeoPcon.h +++ b/fairroot/geobase/FairGeoPcon.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,7 +25,7 @@ class FairGeoPcon : public FairGeoBasicShape { public: FairGeoPcon(); - ~FairGeoPcon(); + ~FairGeoPcon() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoPgon.cxx b/fairroot/geobase/FairGeoPgon.cxx similarity index 89% rename from geobase/FairGeoPgon.cxx rename to fairroot/geobase/FairGeoPgon.cxx index 567eb325e7..8a1da21d29 100644 --- a/geobase/FairGeoPgon.cxx +++ b/fairroot/geobase/FairGeoPgon.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,14 +35,11 @@ #include "FairGeoVector.h" // for FairGeoVector #include "FairGeoVolume.h" // for FairGeoVolume -#include // for TArrayD -#include // for TString -#include -#include // for basic_ostream::write -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoPgon); +#include // for TArrayD +#include // for TString +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoPgon::FairGeoPgon() : FairGeoBasicShape() @@ -100,15 +97,13 @@ Bool_t FairGeoPgon::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < volu->getNumPoints(); i++) { FairGeoVector& v = *(volu->getPoint(i)); if (i != 0) { - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } else { - sprintf(buf, "%3i\n", static_cast(v(0))); + *pFile << fmt::format("{:3d}\n", static_cast(v(0))); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoPgon.h b/fairroot/geobase/FairGeoPgon.h similarity index 92% rename from geobase/FairGeoPgon.h rename to fairroot/geobase/FairGeoPgon.h index 4ccba2ac98..a5385b45bd 100644 --- a/geobase/FairGeoPgon.h +++ b/fairroot/geobase/FairGeoPgon.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,7 +25,7 @@ class FairGeoPgon : public FairGeoBasicShape { public: FairGeoPgon(); - ~FairGeoPgon(); + ~FairGeoPgon() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoRootBuilder.cxx b/fairroot/geobase/FairGeoRootBuilder.cxx similarity index 96% rename from geobase/FairGeoRootBuilder.cxx rename to fairroot/geobase/FairGeoRootBuilder.cxx index 7fef0ac41a..6b37f0b534 100644 --- a/geobase/FairGeoRootBuilder.cxx +++ b/fairroot/geobase/FairGeoRootBuilder.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,7 +23,6 @@ #include "FairGeoVector.h" // for FairGeoVector #include // for TArrayD -#include // for TGeoManager #include // for TGeoMixture, TGeoMaterial #include // for TGeoCombiTrans, etc #include // for TGeoMedium @@ -32,21 +31,18 @@ #include // for sprintf #include -ClassImp(FairGeoRootBuilder); - FairGeoRootBuilder::FairGeoRootBuilder() : FairGeoBuilder() - , geoManager(nullptr) -{ - // Default constructor -} +{} FairGeoRootBuilder::FairGeoRootBuilder(const char* name, const char* title) : FairGeoBuilder(name, title) - , geoManager(nullptr) -{ - // Constructor -} +{} + +FairGeoRootBuilder::FairGeoRootBuilder(const char* name, const char* title, std::unique_ptr geom) + : FairGeoBuilder(name, title) + , geoManager(std::move(geom)) +{} Bool_t FairGeoRootBuilder::createNode(FairGeoNode* volu, Int_t hadFormat) { diff --git a/geobase/FairGeoRootBuilder.h b/fairroot/geobase/FairGeoRootBuilder.h similarity index 75% rename from geobase/FairGeoRootBuilder.h rename to fairroot/geobase/FairGeoRootBuilder.h index 37926564b6..e889c714ed 100644 --- a/geobase/FairGeoRootBuilder.h +++ b/fairroot/geobase/FairGeoRootBuilder.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,14 +10,14 @@ #include "FairGeoBuilder.h" // for FairGeoBuilder -#include // for FairGeoRootBuilder::Class, etc +#include class FairGeoMedium; class FairGeoNode; -class TGeoManager; /** * class to create geometry in ROOT + * \ingroup geobase * @author M. Al-Turany */ class FairGeoRootBuilder : public FairGeoBuilder @@ -25,15 +25,14 @@ class FairGeoRootBuilder : public FairGeoBuilder private: FairGeoRootBuilder(const FairGeoRootBuilder&); FairGeoRootBuilder& operator=(const FairGeoRootBuilder&); - - protected: - TGeoManager* geoManager; // ROOT geometry manager + std::unique_ptr geoManager; //!< ROOT geometry manager public: FairGeoRootBuilder(); FairGeoRootBuilder(const char*, const char*); - ~FairGeoRootBuilder() {} - void setGeoManager(TGeoManager* me) { geoManager = me; } + FairGeoRootBuilder(const char*, const char*, std::unique_ptr); + ~FairGeoRootBuilder() override = default; + [[deprecated]] void setGeoManager(TGeoManager* me) { geoManager.reset(me); } Bool_t createNode(FairGeoNode*, Int_t hadFormat = 0) override; Int_t createMedium(FairGeoMedium*) override; void finalize() override; diff --git a/geobase/FairGeoRotation.cxx b/fairroot/geobase/FairGeoRotation.cxx similarity index 97% rename from geobase/FairGeoRotation.cxx rename to fairroot/geobase/FairGeoRotation.cxx index 6ed5446548..6787acd923 100644 --- a/geobase/FairGeoRotation.cxx +++ b/fairroot/geobase/FairGeoRotation.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -77,8 +77,6 @@ #include // for Cos, Sin #include // for TRotMatrix -ClassImp(FairGeoRotation); - FairGeoRotation::FairGeoRotation(const Double_t a, const Double_t b, const Double_t c) : TObject() { diff --git a/geobase/FairGeoRotation.h b/fairroot/geobase/FairGeoRotation.h similarity index 90% rename from geobase/FairGeoRotation.h rename to fairroot/geobase/FairGeoRotation.h index 6162d34d3f..4e476bb4b1 100644 --- a/geobase/FairGeoRotation.h +++ b/fairroot/geobase/FairGeoRotation.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,7 +30,7 @@ class FairGeoRotation : public TObject inline FairGeoRotation(const FairGeoRotation&); inline FairGeoRotation(const Double_t*); FairGeoRotation(const Double_t, const Double_t, const Double_t); - ~FairGeoRotation() {} + ~FairGeoRotation() override = default; inline void setMatrix(const Double_t*); inline void setMatrix(const Float_t*); void setEulerAngles(const Double_t, const Double_t, const Double_t); @@ -39,11 +39,11 @@ class FairGeoRotation : public TObject inline FairGeoRotation& operator=(const FairGeoRotation&); inline Bool_t operator==(const FairGeoRotation&); inline Bool_t operator!=(const FairGeoRotation&); - inline FairGeoVector operator*(const FairGeoVector&)const; - inline FairGeoRotation operator*(const FairGeoRotation&)const; + inline FairGeoVector operator*(const FairGeoVector&) const; + inline FairGeoRotation operator*(const FairGeoRotation&) const; inline FairGeoRotation& operator*=(const FairGeoRotation&); inline FairGeoRotation& transform(const FairGeoRotation&); - inline Bool_t isUnitMatrix(); + inline Bool_t isUnitMatrix() const; inline FairGeoRotation inverse() const; inline FairGeoRotation& invert(); inline Double_t determinant() const; @@ -54,7 +54,7 @@ class FairGeoRotation : public TObject inline void print() const; TRotMatrix* createTRotMatrix(const Text_t* name = "", const Text_t* title = ""); - ClassDef(FairGeoRotation, 1); // + ClassDefOverride(FairGeoRotation, 1); // }; // -------------------- inlines --------------------------- @@ -112,7 +112,10 @@ inline void FairGeoRotation::setElement(const Double_t a, const Int_t i) } } -inline Double_t FairGeoRotation::getElement(Int_t i, Int_t j) const { return rot[i * 3 + j]; } +inline Double_t FairGeoRotation::getElement(Int_t i, Int_t j) const +{ + return rot[i * 3 + j]; +} inline FairGeoRotation& FairGeoRotation::operator=(const FairGeoRotation& r) { @@ -170,11 +173,17 @@ inline FairGeoRotation FairGeoRotation::operator*(const FairGeoRotation& r) cons return FairGeoRotation(&a[0]); } -inline FairGeoRotation& FairGeoRotation::operator*=(const FairGeoRotation& r) { return *this = operator*(r); } +inline FairGeoRotation& FairGeoRotation::operator*=(const FairGeoRotation& r) +{ + return *this = operator*(r); +} -inline FairGeoRotation& FairGeoRotation::transform(const FairGeoRotation& r) { return *this = r * (*this); } +inline FairGeoRotation& FairGeoRotation::transform(const FairGeoRotation& r) +{ + return *this = r * (*this); +} -inline Bool_t FairGeoRotation::isUnitMatrix() +inline Bool_t FairGeoRotation::isUnitMatrix() const { return rot[0] == 1. && rot[1] == 0. && rot[2] == 0. && rot[3] == 0. && rot[4] == 1. && rot[5] == 0. && rot[6] == 0. && rot[7] == 0. && rot[8] == 1.; @@ -191,7 +200,10 @@ inline FairGeoRotation FairGeoRotation::inverse() const return FairGeoRotation(a); } -inline FairGeoRotation& FairGeoRotation::invert() { return *this = inverse(); } +inline FairGeoRotation& FairGeoRotation::invert() +{ + return *this = inverse(); +} inline Double_t FairGeoRotation::determinant() const { diff --git a/geobase/FairGeoSet.cxx b/fairroot/geobase/FairGeoSet.cxx similarity index 86% rename from geobase/FairGeoSet.cxx rename to fairroot/geobase/FairGeoSet.cxx index 8429589ad8..d1045c4257 100644 --- a/geobase/FairGeoSet.cxx +++ b/fairroot/geobase/FairGeoSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,9 +26,11 @@ #include // for TArrayI #include // for TString, operator<< #include // for isalpha -#include // for fstream -#include // for cout -#include // for strcmp +#include +#include +#include // for fstream +#include // for cout +#include // for strcmp class FairGeoMedium; @@ -36,25 +38,6 @@ using std::cout; using std::endl; using std::ios; -ClassImp(FairGeoSet); - -FairGeoSet::FairGeoSet() - : TNamed() - , hadesGeo(0) - , volumes(new TList()) - , masterNodes(nullptr) - , maxSectors(0) - , maxKeepinVolumes(0) - , maxModules(0) - , modules(nullptr) - , pShapes(nullptr) - , geoFile("") - , author("") - , description("") -{ - // Constructor -} - FairGeoSet::~FairGeoSet() { // Destructor @@ -155,7 +138,6 @@ void FairGeoSet::readInout(std::fstream& fin) do { fin.get(c); } while (c != '\n'); - return; } void FairGeoSet::readTransform(std::fstream& fin, FairGeoTransform& tf) @@ -521,3 +503,61 @@ void FairGeoSet::compare(FairGeoSet& rset) } cout << "Number of additional volumes in second list: " << nnf << '\n'; } + +Int_t FairGeoSet::getModNumInMod(const TString& name) +{ + const auto& prefix = fName; + const auto prefixLength = prefix.Length(); + const auto length = name.Length(); + + // check if the naming is correct. All modules in a geometry file must start with + // the generic module name followed by a number. + if ((!name.BeginsWith(prefix)) || (length <= prefixLength)) { + LOG(fatal) << "Naming conventions violated. The element name must start with " << prefix + << " followed by a unique number.\n" + << "The passed value was " << name; + } + + // construct TString starting after the end of the detector name + // which contains the detector number + TString modNumber(name(prefixLength, (length - prefixLength))); + + // check if the conversion worked as expected. Atoi internally calls the c function + // atoi which returns in case of failure the value 0. Since in our case a value of + // 0 is an error anyway (Natural counting starts at 1 as well as the counting of elements + // in the module) a value of 0 indicates an error + int retVal = modNumber.Atoi(); + if (0 == retVal) { + LOG(fatal) << "Naming conventions violated. The element name must start with " << prefix + << " followed by a unique number." + << "The passed value was " << name; + } + return (retVal - 1); +} + +const char* FairGeoSet::getModuleName(Int_t m) +{ + /** Returns the module name of the detector with array index m + Since the name uses natuaral counting the index has to be + increased by 1. All module names in the ASCII file needs to + start with the name saved in fName since otherwise they are + not constructed. + */ + LOG_IF(fatal, m < 0) << "Negative array index not allowed"; + + fModNameSet.clear(); + fModNameSet = fmt::format("{}{}", fName.View(), m + 1); + + return fModNameSet.data(); +} + +const char* FairGeoSet::getEleName(Int_t m) +{ + /** Returns the element name of Det number m */ + LOG_IF(fatal, m < 0) << "Negative array index not allowed"; + + fEleNameSet.clear(); + fEleNameSet = fmt::format("{}{}", fName.View(), m + 1); + + return fEleNameSet.data(); +} diff --git a/geobase/FairGeoSet.h b/fairroot/geobase/FairGeoSet.h similarity index 61% rename from geobase/FairGeoSet.h rename to fairroot/geobase/FairGeoSet.h index cd36eda767..e3b9aa9e26 100644 --- a/geobase/FairGeoSet.h +++ b/fairroot/geobase/FairGeoSet.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,6 +15,7 @@ #include // for TNamed #include // for TString #include // for fstream +#include // for std::string // class FairGeoNode; class FairGeoShapes; @@ -30,7 +31,7 @@ class TArrayI; class FairGeoSet : public TNamed { protected: - Int_t hadesGeo; + Int_t hadesGeo{0}; class FairGeoCopyNode : public TNamed { @@ -43,25 +44,31 @@ class FairGeoSet : public TNamed // SetName(name); // // } - ~FairGeoCopyNode() {} + ~FairGeoCopyNode() override = default; private: FairGeoCopyNode(const FairGeoCopyNode&); FairGeoCopyNode& operator=(const FairGeoCopyNode&); }; - TList* volumes; /** list of volumes */ - TList* masterNodes; /** pointer to list of mother volumes from other detector parts*/ - Int_t maxSectors; /** maximum number of sectors (-1 for detectors outside any sector)*/ - Int_t maxKeepinVolumes; /** maximum number of keepin volumes per sector*/ - Int_t maxModules; /** maximum number of modules per sector*/ - TArrayI* modules; /** Module's array.*/ - FairGeoShapes* pShapes; /** pointer to the class FairGeoShapes*/ - TString geoFile; /** name of geometry input file or Oracle*/ - TString author; /** author of the media version*/ - TString description; /** description of the version*/ + TList* volumes{new TList()}; /** list of volumes */ + TList* masterNodes{nullptr}; /** pointer to list of mother volumes from other detector parts*/ + Int_t maxSectors{0}; /** maximum number of sectors (-1 for detectors outside any sector)*/ + Int_t maxKeepinVolumes{0}; /** maximum number of keepin volumes per sector*/ + Int_t maxModules{0}; /** maximum number of modules per sector*/ + TArrayI* modules{nullptr}; /** Module's array.*/ + FairGeoShapes* pShapes{nullptr}; /** pointer to the class FairGeoShapes*/ + TString geoFile{""}; /** name of geometry input file or Oracle*/ + TString author{""}; /** author of the media version*/ + TString description{""}; /** description of the version*/ + + FairGeoSet() = default; + FairGeoSet(const char* name, Int_t maxMods, Int_t maxSecs = 0) + : TNamed{name, ""} + , maxSectors{maxSecs} + , maxModules{maxMods} + {} - FairGeoSet(); void readInout(std::fstream&); void readTransform(std::fstream&, FairGeoTransform&); Bool_t readVolumeParams(std::fstream&, FairGeoMedia*, FairGeoNode*, TList* l = 0); @@ -69,16 +76,16 @@ class FairGeoSet : public TNamed Bool_t readModule(std::fstream&, FairGeoMedia*, TString&, TString&, Bool_t a = kFALSE); public: - virtual ~FairGeoSet(); + ~FairGeoSet() override; void setShapes(FairGeoShapes* s) { pShapes = s; } void setMasterNodes(TList* m) { masterNodes = m; } void setGeomFile(const char* filename) { geoFile = filename; } const char* getGeomFile() { return geoFile.Data(); } - Int_t getMaxSectors(void) { return maxSectors; } - Int_t getMaxModules(void) { return maxModules; } - Int_t getMaxKeepinVolumes(void) { return maxKeepinVolumes; } + Int_t getMaxSectors() { return maxSectors; } + Int_t getMaxModules() { return maxModules; } + Int_t getMaxKeepinVolumes() { return maxKeepinVolumes; } void setModules(Int_t, Int_t*); - Int_t* getModules(void); + Int_t* getModules(); Int_t getModule(Int_t, Int_t); FairGeoNode* getVolume(const char* name) { return dynamic_cast(volumes->FindObject(name)); } FairGeoNode* getMasterNode(const char* name) { return dynamic_cast(masterNodes->FindObject(name)); } @@ -89,21 +96,30 @@ class FairGeoSet : public TNamed TString& getAuthor() { return author; } TString& getDescription() { return description; } virtual const char* getKeepinName(Int_t, Int_t) { return 0; } - virtual const char* getModuleName(Int_t) { return 0; } - virtual const char* getEleName(Int_t) { return 0; } + virtual const char* getModuleName(Int_t); + virtual const char* getEleName(Int_t); virtual Int_t getSecNumInMod(const TString&) { return -1; } - virtual Int_t getModNumInMod(const TString&) { return 0; } + + /** returns the module index in the modules array from the module name. + The module number is counted starting at 1, so to get the array index + one has to substract 1 from the module number. + */ + virtual Int_t getModNumInMod(const TString& name); + virtual Bool_t read(std::fstream&, FairGeoMedia*); virtual void addRefNodes() {} virtual void write(std::fstream&); virtual void print(); virtual Bool_t create(FairGeoBuilder*); void compare(FairGeoSet&); - ClassDef(FairGeoSet, 0); // + ClassDefOverride(FairGeoSet, 0); // private: FairGeoSet(const FairGeoSet&); FairGeoSet& operator=(const FairGeoSet&); + + std::string fModNameSet{""}; //! name of module + std::string fEleNameSet{""}; //! substring for elements in module }; #endif /* !FAIRGEOSET_H */ diff --git a/geobase/FairGeoShapes.cxx b/fairroot/geobase/FairGeoShapes.cxx similarity index 98% rename from geobase/FairGeoShapes.cxx rename to fairroot/geobase/FairGeoShapes.cxx index d7157d43b1..818e89062e 100644 --- a/geobase/FairGeoShapes.cxx +++ b/fairroot/geobase/FairGeoShapes.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -53,8 +53,6 @@ #include #include // for fstream -ClassImp(FairGeoShapes); - FairGeoShapes::FairGeoShapes() : TObject() , shapes(new TList()) diff --git a/geobase/FairGeoShapes.h b/fairroot/geobase/FairGeoShapes.h similarity index 89% rename from geobase/FairGeoShapes.h rename to fairroot/geobase/FairGeoShapes.h index 51625efb7a..a527fab5fc 100644 --- a/geobase/FairGeoShapes.h +++ b/fairroot/geobase/FairGeoShapes.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,13 +31,13 @@ class FairGeoShapes : public TObject public: FairGeoShapes(); - ~FairGeoShapes(); + ~FairGeoShapes() override; FairGeoBasicShape* selectShape(FairGeoVolume*); FairGeoBasicShape* selectShape(const TString&); Int_t readPoints(std::fstream*, FairGeoVolume*); Bool_t writePoints(std::fstream*, FairGeoVolume*); void printPoints(FairGeoVolume* volu); - ClassDef(FairGeoShapes, 0); // + ClassDefOverride(FairGeoShapes, 0); // }; #endif /* !FAIRGEOSHAPES_H */ diff --git a/geobase/FairGeoSphe.cxx b/fairroot/geobase/FairGeoSphe.cxx similarity index 89% rename from geobase/FairGeoSphe.cxx rename to fairroot/geobase/FairGeoSphe.cxx index e58d32d3c0..ef6a2ff15a 100644 --- a/geobase/FairGeoSphe.cxx +++ b/fairroot/geobase/FairGeoSphe.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,14 +33,11 @@ #include "FairGeoVector.h" // for FairGeoVector #include "FairGeoVolume.h" // for FairGeoVolume -#include // for TArrayD -#include // for TString -#include -#include // for basic_ostream::write -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoSphe); +#include // for TArrayD +#include // for TString +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoSphe::FairGeoSphe() : FairGeoBasicShape() @@ -92,11 +89,9 @@ Bool_t FairGeoSphe::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } else { - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); - pFile->write(buf, strlen(buf)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); } return kTRUE; } diff --git a/geobase/FairGeoSphe.h b/fairroot/geobase/FairGeoSphe.h similarity index 92% rename from geobase/FairGeoSphe.h rename to fairroot/geobase/FairGeoSphe.h index e6f5913da2..6fa060f2c6 100644 --- a/geobase/FairGeoSphe.h +++ b/fairroot/geobase/FairGeoSphe.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,7 +25,7 @@ class FairGeoSphe : public FairGeoBasicShape { public: FairGeoSphe(); - ~FairGeoSphe(); + ~FairGeoSphe() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoTorus.cxx b/fairroot/geobase/FairGeoTorus.cxx similarity index 88% rename from geobase/FairGeoTorus.cxx rename to fairroot/geobase/FairGeoTorus.cxx index 8b22e20f3d..101f330895 100644 --- a/geobase/FairGeoTorus.cxx +++ b/fairroot/geobase/FairGeoTorus.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,14 +25,11 @@ #include "FairGeoVector.h" // for FairGeoVector #include "FairGeoVolume.h" // for FairGeoVolume -#include // for TArrayD -#include // for TString -#include -#include // for basic_ostream::write -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoTorus); +#include // for TArrayD +#include // for TString +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoTorus::FairGeoTorus() : FairGeoBasicShape() @@ -108,11 +105,9 @@ Bool_t FairGeoTorus::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); - sprintf(buf, "%9.3f\n", v(0)); - pFile->write(buf, strlen(buf)); + *pFile << fmt::format("{:9.3f}\n", v(0)); } return kTRUE; } diff --git a/geobase/FairGeoTorus.h b/fairroot/geobase/FairGeoTorus.h similarity index 92% rename from geobase/FairGeoTorus.h rename to fairroot/geobase/FairGeoTorus.h index 2ec13203df..c995b0bfab 100644 --- a/geobase/FairGeoTorus.h +++ b/fairroot/geobase/FairGeoTorus.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,7 +21,7 @@ class FairGeoTorus : public FairGeoBasicShape { public: FairGeoTorus(); - ~FairGeoTorus(); + ~FairGeoTorus() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream* pFile, FairGeoVolume* volu) override; diff --git a/geobase/FairGeoTransform.cxx b/fairroot/geobase/FairGeoTransform.cxx similarity index 97% rename from geobase/FairGeoTransform.cxx rename to fairroot/geobase/FairGeoTransform.cxx index 2e366c612f..8156437b84 100644 --- a/geobase/FairGeoTransform.cxx +++ b/fairroot/geobase/FairGeoTransform.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -51,8 +51,6 @@ //#include //#include "math.h" -ClassImp(FairGeoTransform); - FairGeoTransform::FairGeoTransform() : TObject() , rot(FairGeoRotation(0, 0, 0)) @@ -135,7 +133,7 @@ void FairGeoTransform::print() trans.print(); } -void FairGeoTransform::invert(void) +void FairGeoTransform::invert() { rot.invert(); trans = rot * trans; diff --git a/geobase/FairGeoTransform.h b/fairroot/geobase/FairGeoTransform.h similarity index 93% rename from geobase/FairGeoTransform.h rename to fairroot/geobase/FairGeoTransform.h index 609317e0db..8ee1d7426d 100644 --- a/geobase/FairGeoTransform.h +++ b/fairroot/geobase/FairGeoTransform.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,7 +27,7 @@ class FairGeoTransform : public TObject public: FairGeoTransform(); inline FairGeoTransform(const FairGeoTransform& t); - ~FairGeoTransform() {} + ~FairGeoTransform() override = default; FairGeoTransform& operator=(const FairGeoTransform& t); const FairGeoRotation& getRotMatrix() const { return rot; } const FairGeoVector& getTransVector() const { return trans; } @@ -41,7 +41,7 @@ class FairGeoTransform : public TObject FairGeoVector transTo(const FairGeoVector& p) const; void transFrom(const FairGeoTransform&); void transTo(const FairGeoTransform&); - void invert(void); + void invert(); void clear(); void print(); const FairGeoVector& getTranslation() @@ -54,7 +54,7 @@ class FairGeoTransform : public TObject const FairGeoRotation& getRotation() const { return rot; } inline void setTransform(const FairGeoTransform& t); - ClassDef(FairGeoTransform, 1); // + ClassDefOverride(FairGeoTransform, 1); // }; inline FairGeoTransform::FairGeoTransform(const FairGeoTransform& t) diff --git a/geobase/FairGeoTrap.cxx b/fairroot/geobase/FairGeoTrap.cxx similarity index 98% rename from geobase/FairGeoTrap.cxx rename to fairroot/geobase/FairGeoTrap.cxx index cff559e8d8..c7741ae3b7 100644 --- a/geobase/FairGeoTrap.cxx +++ b/fairroot/geobase/FairGeoTrap.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -42,8 +42,6 @@ using std::cout; -ClassImp(FairGeoTrap); - FairGeoTrap::FairGeoTrap() : FairGeoBasicShape() , intrinsicRot(FairGeoRotation()) diff --git a/geobase/FairGeoTrap.h b/fairroot/geobase/FairGeoTrap.h similarity index 91% rename from geobase/FairGeoTrap.h rename to fairroot/geobase/FairGeoTrap.h index c516efa1f8..bfe6b7c170 100644 --- a/geobase/FairGeoTrap.h +++ b/fairroot/geobase/FairGeoTrap.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,7 @@ class FairGeoTrap : public FairGeoBasicShape public: FairGeoTrap(); - ~FairGeoTrap(); + ~FairGeoTrap() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; ClassDefOverride(FairGeoTrap, 0); // class for geometry shape TRAP diff --git a/geobase/FairGeoTrd1.cxx b/fairroot/geobase/FairGeoTrd1.cxx similarity index 96% rename from geobase/FairGeoTrd1.cxx rename to fairroot/geobase/FairGeoTrd1.cxx index 4dc63e7647..0fa10933ef 100644 --- a/geobase/FairGeoTrd1.cxx +++ b/fairroot/geobase/FairGeoTrd1.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -38,8 +38,6 @@ #include // for Abs #include // for TString -ClassImp(FairGeoTrd1); - FairGeoTrd1::FairGeoTrd1() : FairGeoBasicShape() , intrinsicRot(FairGeoRotation()) diff --git a/geobase/FairGeoTrd1.h b/fairroot/geobase/FairGeoTrd1.h similarity index 91% rename from geobase/FairGeoTrd1.h rename to fairroot/geobase/FairGeoTrd1.h index 77e70b6a9c..e05d7f15b0 100644 --- a/geobase/FairGeoTrd1.h +++ b/fairroot/geobase/FairGeoTrd1.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,7 @@ class FairGeoTrd1 : public FairGeoBasicShape public: FairGeoTrd1(); - ~FairGeoTrd1(); + ~FairGeoTrd1() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; diff --git a/geobase/FairGeoTube.cxx b/fairroot/geobase/FairGeoTube.cxx similarity index 91% rename from geobase/FairGeoTube.cxx rename to fairroot/geobase/FairGeoTube.cxx index 8744b6e3a7..63de002f88 100644 --- a/geobase/FairGeoTube.cxx +++ b/fairroot/geobase/FairGeoTube.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -37,12 +37,9 @@ #include // for TArrayD #include // for Abs #include // for TString -#include -#include // for basic_ostream::write -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoTube); +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoTube::FairGeoTube() : FairGeoBasicShape() @@ -99,15 +96,13 @@ Bool_t FairGeoTube::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); if (i != 1) { - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } else { - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoTube.h b/fairroot/geobase/FairGeoTube.h similarity index 91% rename from geobase/FairGeoTube.h rename to fairroot/geobase/FairGeoTube.h index fec7fd86ce..9d35a5e035 100644 --- a/geobase/FairGeoTube.h +++ b/fairroot/geobase/FairGeoTube.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,7 +21,7 @@ class FairGeoTube : public FairGeoBasicShape { public: FairGeoTube(); - ~FairGeoTube(); + ~FairGeoTube() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoTubs.cxx b/fairroot/geobase/FairGeoTubs.cxx similarity index 91% rename from geobase/FairGeoTubs.cxx rename to fairroot/geobase/FairGeoTubs.cxx index 553f7a00a6..98cca89fdd 100644 --- a/geobase/FairGeoTubs.cxx +++ b/fairroot/geobase/FairGeoTubs.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -40,12 +40,9 @@ #include // for TArrayD #include // for Abs #include // for TString -#include -#include // for basic_ostream::write -#include // for printf, sprintf, sscanf -#include // for strlen - -ClassImp(FairGeoTubs); +#include // for printf, sscanf +#include // for format +#include // for fstream, etc FairGeoTubs::FairGeoTubs() : FairGeoBasicShape() @@ -101,15 +98,13 @@ Bool_t FairGeoTubs::writePoints(std::fstream* pFile, FairGeoVolume* volu) if (!pFile) { return kFALSE; } - Text_t buf[155]; for (Int_t i = 0; i < nPoints; i++) { FairGeoVector& v = *(volu->getPoint(i)); if (i == 0 || i == 2) { - sprintf(buf, "%9.3f%10.3f%10.3f\n", v(0), v(1), v(2)); + *pFile << fmt::format("{:9.3f}{:10.3f}{:10.3f}\n", v(0), v(1), v(2)); } else { - sprintf(buf, "%9.3f%10.3f\n", v(0), v(1)); + *pFile << fmt::format("{:9.3f}{:10.3f}\n", v(0), v(1)); } - pFile->write(buf, strlen(buf)); } return kTRUE; } diff --git a/geobase/FairGeoTubs.h b/fairroot/geobase/FairGeoTubs.h similarity index 91% rename from geobase/FairGeoTubs.h rename to fairroot/geobase/FairGeoTubs.h index 1d1ebf73f0..a9392a9e1e 100644 --- a/geobase/FairGeoTubs.h +++ b/fairroot/geobase/FairGeoTubs.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,7 +21,7 @@ class FairGeoTubs : public FairGeoBasicShape { public: FairGeoTubs(); - ~FairGeoTubs(); + ~FairGeoTubs() override; TArrayD* calcVoluParam(FairGeoVolume*) override; void calcVoluPosition(FairGeoVolume*, const FairGeoTransform&, const FairGeoTransform&) override; Int_t readPoints(std::fstream*, FairGeoVolume*) override; diff --git a/geobase/FairGeoVector.cxx b/fairroot/geobase/FairGeoVector.cxx similarity index 96% rename from geobase/FairGeoVector.cxx rename to fairroot/geobase/FairGeoVector.cxx index f0ae32517b..7dc335b652 100644 --- a/geobase/FairGeoVector.cxx +++ b/fairroot/geobase/FairGeoVector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -91,5 +91,3 @@ /////////////////////////////////////////////////////////////////////////////// #include "FairGeoVector.h" - -ClassImp(FairGeoVector); diff --git a/geobase/FairGeoVector.h b/fairroot/geobase/FairGeoVector.h similarity index 95% rename from geobase/FairGeoVector.h rename to fairroot/geobase/FairGeoVector.h index 4e65f4b7c4..e878e06ac6 100644 --- a/geobase/FairGeoVector.h +++ b/fairroot/geobase/FairGeoVector.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -48,7 +48,7 @@ class FairGeoVector : public TObject Double_t getY() const { return y; } Double_t getZ() const { return z; } - Double_t getValues(Int_t i) + Double_t getValues(Int_t i) const { if (i < 0 || i > 2) { std::cout << " -E- Vector index is 0 1 2 only ! " << std::endl; @@ -155,7 +155,7 @@ inline FairGeoVector& FairGeoVector::operator=(const FairGeoVector& v) inline Bool_t FairGeoVector::operator==(const FairGeoVector& v) const { - return (!(v.getX() != x || v.getY() != y || v.getZ() != z)); + return (v.x == x) && (v.y == y) && (v.z == z); } inline Bool_t FairGeoVector::operator!=(const FairGeoVector& v) const @@ -165,22 +165,22 @@ inline Bool_t FairGeoVector::operator!=(const FairGeoVector& v) const /// check with ilse inline Bool_t FairGeoVector::operator<(const Double_t a) { - return !(x >= a || y >= a || z >= a); + return (x < a) && (y < a) && (z < a); } inline Bool_t FairGeoVector::operator<=(const Double_t a) { - return !(x > a || y > a || z > a); + return (x <= a) && (y <= a) && (z <= a); } inline Bool_t FairGeoVector::operator>(const Double_t a) { - return !(x <= a || y <= a || z <= a); + return (x > a) && (y > a) && (z > a); } inline Bool_t FairGeoVector::operator>=(const Double_t a) { - return !(x < a || y < a || z < a); + return (x >= a) & (y >= a) && (z >= a); } inline FairGeoVector& FairGeoVector::operator+=(const Double_t a) diff --git a/geobase/FairGeoVolume.cxx b/fairroot/geobase/FairGeoVolume.cxx similarity index 93% rename from geobase/FairGeoVolume.cxx rename to fairroot/geobase/FairGeoVolume.cxx index 85b57fad81..1f5cc55a12 100644 --- a/geobase/FairGeoVolume.cxx +++ b/fairroot/geobase/FairGeoVolume.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,8 +33,6 @@ using std::cout; using std::endl; -ClassImp(FairGeoVolume); - FairGeoVolume::FairGeoVolume(FairGeoVolume& r) : TNamed(r) , shape("") @@ -130,9 +128,7 @@ void FairGeoVolume::clear() void FairGeoVolume::print() { // prints all parameters of a volume - cout << "Volume: " << (const_cast(fName.Data())) - << " Shape: " << (const_cast(shape.Data())) - << " Mother: " << (const_cast(mother.Data())) << '\n'; + cout << "Volume: " << fName.Data() << " Shape: " << shape.Data() << " Mother: " << mother.Data() << '\n'; cout << "Points definition " << endl; if (points) { for (Int_t i = 0; i < nPoints; i++) { diff --git a/geobase/FairGeoVolume.h b/fairroot/geobase/FairGeoVolume.h similarity index 95% rename from geobase/FairGeoVolume.h rename to fairroot/geobase/FairGeoVolume.h index 696e9528c8..4e9c13487e 100644 --- a/geobase/FairGeoVolume.h +++ b/fairroot/geobase/FairGeoVolume.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -41,7 +41,7 @@ class FairGeoVolume : public TNamed public: inline FairGeoVolume(); FairGeoVolume(FairGeoVolume&); - virtual ~FairGeoVolume(); + ~FairGeoVolume() override; const TString& getName() const { return fName; } const TString& getShape() const { return shape; } const TString& getMother() const { return mother; } @@ -64,7 +64,7 @@ class FairGeoVolume : public TNamed Int_t getMCid() { return fgMCid; } void setMCid(Int_t MCid) { fgMCid = MCid; } - ClassDef(FairGeoVolume, 1); // + ClassDefOverride(FairGeoVolume, 1); // }; // -------------------- inlines -------------------------- diff --git a/geobase/LinkDef.h b/fairroot/geobase/LinkDef.h similarity index 100% rename from geobase/LinkDef.h rename to fairroot/geobase/LinkDef.h diff --git a/geobase/README.dox b/fairroot/geobase/README.dox similarity index 100% rename from geobase/README.dox rename to fairroot/geobase/README.dox diff --git a/MbsAPI/CMakeLists.txt b/fairroot/mbsapi/CMakeLists.txt similarity index 82% rename from MbsAPI/CMakeLists.txt rename to fairroot/mbsapi/CMakeLists.txt index ac3ccd9c6a..f0337ada27 100644 --- a/MbsAPI/CMakeLists.txt +++ b/fairroot/mbsapi/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -37,8 +37,16 @@ list(APPEND headers add_library(${target} SHARED ${sources} ${headers}) fairroot_library_settings(${target}) -if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "9") - target_compile_options(${target} PRIVATE "-Wno-stringop-overflow") +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") + target_compile_options(${target} PRIVATE + "-Wno-stringop-overflow" + "-Wno-deprecated-declarations" + ) +endif() +if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang") + target_compile_options(${target} PRIVATE + "-Wno-deprecated-non-prototype" + ) endif() target_include_directories(${target} PUBLIC diff --git a/MbsAPI/README.dox b/fairroot/mbsapi/README.dox similarity index 100% rename from MbsAPI/README.dox rename to fairroot/mbsapi/README.dox diff --git a/MbsAPI/fLmd.c b/fairroot/mbsapi/fLmd.c similarity index 100% rename from MbsAPI/fLmd.c rename to fairroot/mbsapi/fLmd.c diff --git a/MbsAPI/fLmd.h b/fairroot/mbsapi/fLmd.h similarity index 100% rename from MbsAPI/fLmd.h rename to fairroot/mbsapi/fLmd.h diff --git a/MbsAPI/f_evt.c b/fairroot/mbsapi/f_evt.c similarity index 100% rename from MbsAPI/f_evt.c rename to fairroot/mbsapi/f_evt.c diff --git a/MbsAPI/f_evt.h b/fairroot/mbsapi/f_evt.h similarity index 100% rename from MbsAPI/f_evt.h rename to fairroot/mbsapi/f_evt.h diff --git a/MbsAPI/f_stccomm.c b/fairroot/mbsapi/f_stccomm.c similarity index 100% rename from MbsAPI/f_stccomm.c rename to fairroot/mbsapi/f_stccomm.c diff --git a/MbsAPI/f_stccomm.h b/fairroot/mbsapi/f_stccomm.h similarity index 100% rename from MbsAPI/f_stccomm.h rename to fairroot/mbsapi/f_stccomm.h diff --git a/MbsAPI/f_ut_utime.c b/fairroot/mbsapi/f_ut_utime.c similarity index 100% rename from MbsAPI/f_ut_utime.c rename to fairroot/mbsapi/f_ut_utime.c diff --git a/MbsAPI/f_ut_utime.h b/fairroot/mbsapi/f_ut_utime.h similarity index 100% rename from MbsAPI/f_ut_utime.h rename to fairroot/mbsapi/f_ut_utime.h diff --git a/MbsAPI/portnum_def.h b/fairroot/mbsapi/portnum_def.h similarity index 100% rename from MbsAPI/portnum_def.h rename to fairroot/mbsapi/portnum_def.h diff --git a/MbsAPI/sMbs.h b/fairroot/mbsapi/sMbs.h similarity index 100% rename from MbsAPI/sMbs.h rename to fairroot/mbsapi/sMbs.h diff --git a/MbsAPI/s_bufhe.h b/fairroot/mbsapi/s_bufhe.h similarity index 100% rename from MbsAPI/s_bufhe.h rename to fairroot/mbsapi/s_bufhe.h diff --git a/MbsAPI/s_bufhe_swap.h b/fairroot/mbsapi/s_bufhe_swap.h similarity index 100% rename from MbsAPI/s_bufhe_swap.h rename to fairroot/mbsapi/s_bufhe_swap.h diff --git a/MbsAPI/s_evhe.h b/fairroot/mbsapi/s_evhe.h similarity index 100% rename from MbsAPI/s_evhe.h rename to fairroot/mbsapi/s_evhe.h diff --git a/MbsAPI/s_evhe_swap.h b/fairroot/mbsapi/s_evhe_swap.h similarity index 100% rename from MbsAPI/s_evhe_swap.h rename to fairroot/mbsapi/s_evhe_swap.h diff --git a/MbsAPI/s_filhe.h b/fairroot/mbsapi/s_filhe.h similarity index 100% rename from MbsAPI/s_filhe.h rename to fairroot/mbsapi/s_filhe.h diff --git a/MbsAPI/s_filhe_swap.h b/fairroot/mbsapi/s_filhe_swap.h similarity index 100% rename from MbsAPI/s_filhe_swap.h rename to fairroot/mbsapi/s_filhe_swap.h diff --git a/MbsAPI/s_stdint.h b/fairroot/mbsapi/s_stdint.h similarity index 100% rename from MbsAPI/s_stdint.h rename to fairroot/mbsapi/s_stdint.h diff --git a/MbsAPI/s_ve10_1.h b/fairroot/mbsapi/s_ve10_1.h similarity index 100% rename from MbsAPI/s_ve10_1.h rename to fairroot/mbsapi/s_ve10_1.h diff --git a/MbsAPI/s_ve10_1_swap.h b/fairroot/mbsapi/s_ve10_1_swap.h similarity index 100% rename from MbsAPI/s_ve10_1_swap.h rename to fairroot/mbsapi/s_ve10_1_swap.h diff --git a/MbsAPI/s_ves10_1.h b/fairroot/mbsapi/s_ves10_1.h similarity index 100% rename from MbsAPI/s_ves10_1.h rename to fairroot/mbsapi/s_ves10_1.h diff --git a/MbsAPI/s_ves10_1_swap.h b/fairroot/mbsapi/s_ves10_1_swap.h similarity index 100% rename from MbsAPI/s_ves10_1_swap.h rename to fairroot/mbsapi/s_ves10_1_swap.h diff --git a/MbsAPI/typedefs.h b/fairroot/mbsapi/typedefs.h similarity index 100% rename from MbsAPI/typedefs.h rename to fairroot/mbsapi/typedefs.h diff --git a/fairtools/MCConfigurator/CMakeLists.txt b/fairroot/mcconfigurator/CMakeLists.txt similarity index 87% rename from fairtools/MCConfigurator/CMakeLists.txt rename to fairroot/mcconfigurator/CMakeLists.txt index 508e4a7499..951a67c091 100644 --- a/fairtools/MCConfigurator/CMakeLists.txt +++ b/fairroot/mcconfigurator/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -22,15 +22,10 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::Base # FairGenericVMCConfig - ${YAMLCPPLIB} + yaml-cpp::yaml-cpp PRIVATE FairRoot::Tools diff --git a/fairtools/MCConfigurator/FairYamlVMCConfig.cxx b/fairroot/mcconfigurator/FairYamlVMCConfig.cxx similarity index 98% rename from fairtools/MCConfigurator/FairYamlVMCConfig.cxx rename to fairroot/mcconfigurator/FairYamlVMCConfig.cxx index fab232a311..2f76edc453 100644 --- a/fairtools/MCConfigurator/FairYamlVMCConfig.cxx +++ b/fairroot/mcconfigurator/FairYamlVMCConfig.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -41,7 +41,7 @@ FairYamlVMCConfig::FairYamlVMCConfig() void FairYamlVMCConfig::Setup(const char* mcEngine) { fMCEngine = mcEngine; - if (!((strcmp(mcEngine, "TGeant4") == 0) || (strcmp(mcEngine, "TGeant3") == 0))) { + if ((strcmp(mcEngine, "TGeant4") != 0) && (strcmp(mcEngine, "TGeant3") != 0)) { LOG(fatal) << "FairYamlVMCConfig::Setup() Engine \"" << mcEngine << "\" unknown!"; } @@ -295,5 +295,3 @@ void FairYamlVMCConfig::StoreYamlInfo() LOG(info) << "FairYamlVMCConfig::StoreYamlInfo() done."; } - -ClassImp(FairYamlVMCConfig); diff --git a/fairtools/MCConfigurator/FairYamlVMCConfig.h b/fairroot/mcconfigurator/FairYamlVMCConfig.h similarity index 100% rename from fairtools/MCConfigurator/FairYamlVMCConfig.h rename to fairroot/mcconfigurator/FairYamlVMCConfig.h diff --git a/fairtools/MCConfigurator/LinkDef.h b/fairroot/mcconfigurator/LinkDef.h similarity index 100% rename from fairtools/MCConfigurator/LinkDef.h rename to fairroot/mcconfigurator/LinkDef.h diff --git a/fairtools/MCStepLogger/CMakeLists.txt b/fairroot/mcsteplogger/CMakeLists.txt similarity index 86% rename from fairtools/MCStepLogger/CMakeLists.txt rename to fairroot/mcsteplogger/CMakeLists.txt index a06fd43795..f75892e875 100644 --- a/fairtools/MCStepLogger/CMakeLists.txt +++ b/fairroot/mcsteplogger/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -25,11 +25,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PRIVATE FairRoot::Base diff --git a/fairtools/MCStepLogger/MCStepInterceptor.cxx b/fairroot/mcsteplogger/MCStepInterceptor.cxx similarity index 98% rename from fairtools/MCStepLogger/MCStepInterceptor.cxx rename to fairroot/mcsteplogger/MCStepInterceptor.cxx index 09895c8fbc..65b1740cd0 100644 --- a/fairtools/MCStepLogger/MCStepInterceptor.cxx +++ b/fairroot/mcsteplogger/MCStepInterceptor.cxx @@ -28,6 +28,7 @@ // @since 2018-10-22 // @brief Modified for FairRoot +// NOLINTBEGIN(bugprone-macro-parentheses) false positive // (re)declare symbols to be able to hook into them #define DECLARE_INTERCEPT_SYMBOLS(APP) \ class APP \ @@ -37,6 +38,7 @@ void FinishEvent(); \ void FinishRun(); \ }; +// NOLINTEND(bugprone-macro-parentheses) DECLARE_INTERCEPT_SYMBOLS(FairMCApplication) diff --git a/fairtools/MCStepLogger/MCStepLoggerImpl.cxx b/fairroot/mcsteplogger/MCStepLoggerImpl.cxx similarity index 100% rename from fairtools/MCStepLogger/MCStepLoggerImpl.cxx rename to fairroot/mcsteplogger/MCStepLoggerImpl.cxx diff --git a/fairtools/MCStepLogger/README.dox b/fairroot/mcsteplogger/README.dox similarity index 100% rename from fairtools/MCStepLogger/README.dox rename to fairroot/mcsteplogger/README.dox diff --git a/online/CMakeLists.txt b/fairroot/online/CMakeLists.txt similarity index 100% rename from online/CMakeLists.txt rename to fairroot/online/CMakeLists.txt diff --git a/online/LinkDef.h b/fairroot/online/LinkDef.h similarity index 100% rename from online/LinkDef.h rename to fairroot/online/LinkDef.h diff --git a/online/README.dox b/fairroot/online/README.dox similarity index 100% rename from online/README.dox rename to fairroot/online/README.dox diff --git a/online/source/FairLmdSource.cxx b/fairroot/online/source/FairLmdSource.cxx similarity index 94% rename from online/source/FairLmdSource.cxx rename to fairroot/online/source/FairLmdSource.cxx index b8ff342946..51a10787db 100644 --- a/online/source/FairLmdSource.cxx +++ b/fairroot/online/source/FairLmdSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,8 +13,6 @@ #include "FairLmdSource.h" -#include "FairLogger.h" - #include #include #include @@ -22,6 +20,7 @@ #include #include #include +#include FairLmdSource::FairLmdSource() : FairMbsSource() @@ -55,6 +54,7 @@ FairLmdSource::FairLmdSource(const FairLmdSource& source) FairLmdSource::~FairLmdSource() { + CloseLmd(); fFileNames->Delete(); delete fFileNames; } @@ -122,6 +122,8 @@ Bool_t FairLmdSource::Init() Bool_t FairLmdSource::OpenNextFile(TString fileName) { + CloseLmd(); + Int_t inputMode = GETEVT__FILE; fxInputChannel = new s_evt_channel; void* headptr = &fxInfoHeader; @@ -134,6 +136,8 @@ Bool_t FairLmdSource::OpenNextFile(TString fileName) if (status) { LOG(error) << "File " << fileName << " opening failed."; + delete fxInputChannel; + fxInputChannel = nullptr; return kFALSE; } @@ -167,7 +171,7 @@ Int_t FairLmdSource::ReadEvent(UInt_t) } if (GETEVT__NOMORE == status) { - Close(); + CloseLmd(); } TString name = (static_cast(fFileNames->At(fCurrentFile)))->GetString(); @@ -237,9 +241,17 @@ Int_t FairLmdSource::ReadEvent(UInt_t) void FairLmdSource::Close() { + CloseLmd(); +} + +void FairLmdSource::CloseLmd() +{ + if (!fxInputChannel) { + return; + } f_evt_get_close(fxInputChannel); + delete fxInputChannel; + fxInputChannel = nullptr; Unpack(reinterpret_cast(fxBuffer), sizeof(s_bufhe), -4, -4, -4, -4, -4); fCurrentEvent = 0; } - -ClassImp(FairLmdSource); diff --git a/online/source/FairLmdSource.h b/fairroot/online/source/FairLmdSource.h similarity index 85% rename from online/source/FairLmdSource.h rename to fairroot/online/source/FairLmdSource.h index ff0929d4d1..d8b77943eb 100644 --- a/online/source/FairLmdSource.h +++ b/fairroot/online/source/FairLmdSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -33,17 +33,17 @@ class FairLmdSource : public FairMbsSource public: FairLmdSource(); FairLmdSource(const FairLmdSource& source); - virtual ~FairLmdSource(); + ~FairLmdSource() override; void AddFile(TString fileName); void AddPath(TString dir, TString wildCard); inline Int_t GetCurrentFile() const { return fCurrentFile; } inline const TList* GetFileNames() const { return fFileNames; } - virtual Bool_t Init(); - virtual Int_t ReadEvent(UInt_t = 0); - virtual void Close(); - Bool_t SpecifyRunId() + Bool_t Init() override; + Int_t ReadEvent(UInt_t = 0) override; + void Close() override; + Bool_t SpecifyRunId() override { ReadEvent(0); return true; @@ -65,7 +65,10 @@ class FairLmdSource : public FairMbsSource FairLmdSource& operator=(const FairLmdSource&); - ClassDef(FairLmdSource, 0); + private: + void CloseLmd(); + + ClassDefOverride(FairLmdSource, 0); }; #endif diff --git a/online/source/FairMbsSource.cxx b/fairroot/online/source/FairMbsSource.cxx similarity index 87% rename from online/source/FairMbsSource.cxx rename to fairroot/online/source/FairMbsSource.cxx index 8c8e569d7b..c02322c264 100644 --- a/online/source/FairMbsSource.cxx +++ b/fairroot/online/source/FairMbsSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,21 +15,9 @@ #include "FairMbsSource.h" -#include "FairLogger.h" +#include -FairMbsSource::FairMbsSource() - : FairOnlineSource() -{ -} - -FairMbsSource::FairMbsSource(const FairMbsSource &source) - : FairOnlineSource(source) -{ -} - -FairMbsSource::~FairMbsSource() {} - -Bool_t FairMbsSource::Unpack(Int_t *data, +Bool_t FairMbsSource::Unpack(Int_t* data, Int_t size, Short_t type, Short_t subType, @@ -67,5 +55,3 @@ Bool_t FairMbsSource::Unpack(Int_t *data, return seen; } - -ClassImp(FairMbsSource); diff --git a/online/source/FairMbsSource.h b/fairroot/online/source/FairMbsSource.h similarity index 80% rename from online/source/FairMbsSource.h rename to fairroot/online/source/FairMbsSource.h index f80b520365..6d69c3f9e3 100644 --- a/online/source/FairMbsSource.h +++ b/fairroot/online/source/FairMbsSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,13 +23,13 @@ class FairMbsSource : public FairOnlineSource { public: - FairMbsSource(); - FairMbsSource(const FairMbsSource& source); - virtual ~FairMbsSource(); + FairMbsSource() = default; + FairMbsSource(const FairMbsSource& source) = default; + ~FairMbsSource() override = default; - virtual Bool_t Init() = 0; - virtual Int_t ReadEvent(UInt_t = 0) = 0; - virtual void Close() = 0; + Bool_t Init() override = 0; + Int_t ReadEvent(UInt_t = 0) override = 0; + void Close() override = 0; protected: Bool_t Unpack(Int_t* data, @@ -40,7 +40,7 @@ class FairMbsSource : public FairOnlineSource Short_t subCrate, Short_t control); - ClassDef(FairMbsSource, 0); + ClassDefOverride(FairMbsSource, 0); }; #endif diff --git a/online/source/FairMbsStreamSource.cxx b/fairroot/online/source/FairMbsStreamSource.cxx similarity index 97% rename from online/source/FairMbsStreamSource.cxx rename to fairroot/online/source/FairMbsStreamSource.cxx index dd84d65031..f8ebf0ed64 100644 --- a/online/source/FairMbsStreamSource.cxx +++ b/fairroot/online/source/FairMbsStreamSource.cxx @@ -10,7 +10,7 @@ #include "FairMbsStreamSource.h" -#include "FairLogger.h" +#include FairMbsStreamSource::FairMbsStreamSource(TString tServerName) : FairMbsSource() @@ -34,8 +34,6 @@ FairMbsStreamSource::FairMbsStreamSource(const FairMbsStreamSource& source) { } -FairMbsStreamSource::~FairMbsStreamSource() {} - Bool_t FairMbsStreamSource::Init() { return ConnectToServer(); @@ -130,5 +128,3 @@ void FairMbsStreamSource::Close() CHARS* sErrorString = nullptr; f_evt_error(status, sErrorString, 0); } - -ClassImp(FairMbsStreamSource); diff --git a/online/source/FairMbsStreamSource.h b/fairroot/online/source/FairMbsStreamSource.h similarity index 87% rename from online/source/FairMbsStreamSource.h rename to fairroot/online/source/FairMbsStreamSource.h index 74f2e14d43..af15842ff9 100644 --- a/online/source/FairMbsStreamSource.h +++ b/fairroot/online/source/FairMbsStreamSource.h @@ -28,12 +28,12 @@ class FairMbsStreamSource : public FairMbsSource public: FairMbsStreamSource(TString tServerName); FairMbsStreamSource(const FairMbsStreamSource& source); - virtual ~FairMbsStreamSource(); + ~FairMbsStreamSource() override = default; - virtual Bool_t Init(); - virtual Int_t ReadEvent(UInt_t = 0); - virtual void Close(); - Bool_t SpecifyRunId() + Bool_t Init() override; + Int_t ReadEvent(UInt_t = 0) override; + void Close() override; + Bool_t SpecifyRunId() override { ReadEvent(0); return true; @@ -55,7 +55,7 @@ class FairMbsStreamSource : public FairMbsSource FairMbsStreamSource& operator=(const FairMbsStreamSource&); public: - ClassDef(FairMbsStreamSource, 0); + ClassDefOverride(FairMbsStreamSource, 0); }; #endif diff --git a/online/source/FairOnlineSource.cxx b/fairroot/online/source/FairOnlineSource.cxx similarity index 94% rename from online/source/FairOnlineSource.cxx rename to fairroot/online/source/FairOnlineSource.cxx index 7a0f0b3cf9..90789d057f 100644 --- a/online/source/FairOnlineSource.cxx +++ b/fairroot/online/source/FairOnlineSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,7 +15,7 @@ #include "FairOnlineSource.h" -#include "FairLogger.h" +#include FairOnlineSource::FairOnlineSource() : FairSource() @@ -68,5 +68,3 @@ void FairOnlineSource::Reset() ((FairUnpack *)fUnpackers->At(i))->Reset(); } } - -ClassImp(FairOnlineSource); diff --git a/online/source/FairOnlineSource.h b/fairroot/online/source/FairOnlineSource.h similarity index 94% rename from online/source/FairOnlineSource.h rename to fairroot/online/source/FairOnlineSource.h index 04f31b0eb8..e40f59a15b 100644 --- a/online/source/FairOnlineSource.h +++ b/fairroot/online/source/FairOnlineSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,7 +27,7 @@ class FairOnlineSource : public FairSource public: FairOnlineSource(); FairOnlineSource(const FairOnlineSource& source); - virtual ~FairOnlineSource(); + ~FairOnlineSource() override; inline void AddUnpacker(FairUnpack* unpacker) { fUnpackers->Add(unpacker); } inline const TObjArray* GetUnpackers() const { return fUnpackers; } diff --git a/online/source/FairRemoteSource.cxx b/fairroot/online/source/FairRemoteSource.cxx similarity index 95% rename from online/source/FairRemoteSource.cxx rename to fairroot/online/source/FairRemoteSource.cxx index 4501e74369..f54290108a 100644 --- a/online/source/FairRemoteSource.cxx +++ b/fairroot/online/source/FairRemoteSource.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -82,5 +82,3 @@ void FairRemoteSource::Close() fBuffer->RevClose(fSocket); fBuffer->RevStatus(0); } - -ClassImp(FairRemoteSource); diff --git a/online/source/FairRemoteSource.h b/fairroot/online/source/FairRemoteSource.h similarity index 84% rename from online/source/FairRemoteSource.h rename to fairroot/online/source/FairRemoteSource.h index ecf1ada482..5f17abd924 100644 --- a/online/source/FairRemoteSource.h +++ b/fairroot/online/source/FairRemoteSource.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,11 +26,11 @@ class FairRemoteSource : public FairMbsSource public: FairRemoteSource(char* node); FairRemoteSource(const FairRemoteSource& source); - virtual ~FairRemoteSource(); + ~FairRemoteSource() override; - virtual Bool_t Init(); - virtual Int_t ReadEvent(UInt_t = 0); - virtual void Close(); + Bool_t Init() override; + Int_t ReadEvent(UInt_t = 0) override; + void Close() override; inline const char* GetNode() const { return fNode; } @@ -43,7 +43,7 @@ class FairRemoteSource : public FairMbsSource FairRemoteSource& operator=(const FairRemoteSource&); public: - ClassDef(FairRemoteSource, 0); + ClassDefOverride(FairRemoteSource, 0); }; #endif diff --git a/online/source/FairUnpack.cxx b/fairroot/online/source/FairUnpack.cxx similarity index 89% rename from online/source/FairUnpack.cxx rename to fairroot/online/source/FairUnpack.cxx index cb50418526..c0f37f8f16 100644 --- a/online/source/FairUnpack.cxx +++ b/fairroot/online/source/FairUnpack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,9 +20,4 @@ FairUnpack::FairUnpack(Short_t type, Short_t subType, Short_t procId, Short_t su , fProcId(procId) , fSubCrate(subCrate) , fControl(control) -{ -} - -FairUnpack::~FairUnpack() {} - -ClassImp(FairUnpack); +{} diff --git a/online/source/FairUnpack.h b/fairroot/online/source/FairUnpack.h similarity index 92% rename from online/source/FairUnpack.h rename to fairroot/online/source/FairUnpack.h index 59f1020875..5e61c6ee5f 100644 --- a/online/source/FairUnpack.h +++ b/fairroot/online/source/FairUnpack.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -21,7 +21,7 @@ class FairUnpack : public TObject { public: FairUnpack(Short_t type, Short_t subType, Short_t procId, Short_t subCrate, Short_t control); - virtual ~FairUnpack(); + ~FairUnpack() override = default; virtual Bool_t Init() = 0; virtual Bool_t ReInit() { return kTRUE; } @@ -46,7 +46,7 @@ class FairUnpack : public TObject virtual void Register() = 0; public: - ClassDef(FairUnpack, 0); + ClassDefOverride(FairUnpack, 0); }; #endif diff --git a/online/source/MRevBuffer.cxx b/fairroot/online/source/MRevBuffer.cxx similarity index 99% rename from online/source/MRevBuffer.cxx rename to fairroot/online/source/MRevBuffer.cxx index 4b5428575c..cac0ecc3d2 100644 --- a/online/source/MRevBuffer.cxx +++ b/fairroot/online/source/MRevBuffer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -48,10 +48,7 @@ // IWYU pragma: no_include // IWYU pragma: no_include -#include "FairLogger.h" - -ClassImp(MRevBuffer); -ClassImp(REvent); +#include extern "C" { @@ -910,11 +907,6 @@ REvent::REvent() // piData = 0; } -REvent::~REvent() -{ - // LOG(info) << " ~REvent() ..."; -} - void REvent::ReFillHead(Int_t* pHead) { iSize = pHead[0]; // event size without header in 2-byte-words diff --git a/online/source/MRevBuffer.h b/fairroot/online/source/MRevBuffer.h similarity index 95% rename from online/source/MRevBuffer.h rename to fairroot/online/source/MRevBuffer.h index 30ecd57a3a..3440f1a352 100644 --- a/online/source/MRevBuffer.h +++ b/fairroot/online/source/MRevBuffer.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -40,8 +40,8 @@ class REvent : public TObject REvent& operator=(const REvent&); public: - REvent(); // constructor - ~REvent(); // destructor + REvent(); + ~REvent() override = default; void ReFillHead(Int_t* pHead); // unpack and fill event header void ReFillData(Int_t* pData); // unpack and fill event data @@ -60,7 +60,7 @@ class REvent : public TObject Short_t subEvtControl[100]; Int_t* pSubEvt[100]; - ClassDef(REvent, 0); + ClassDefOverride(REvent, 0); }; class MRevBuffer : public TObject @@ -97,7 +97,7 @@ class MRevBuffer : public TObject public: MRevBuffer(Int_t iMode); // constructor - ~MRevBuffer(); // destructor + ~MRevBuffer() override; TSocket* RevOpen(char* pNode, Int_t iPort, Int_t iEvent); // input: node name and port number server, req. no. of events @@ -132,7 +132,7 @@ class MRevBuffer : public TObject void RevClose(TSocket* pSocket); // input Socket ptr - ClassDef(MRevBuffer, 0); + ClassDefOverride(MRevBuffer, 0); }; #endif // !MRevBuffer_H diff --git a/online/source/exitCli.c b/fairroot/online/source/exitCli.c similarity index 100% rename from online/source/exitCli.c rename to fairroot/online/source/exitCli.c diff --git a/online/source/ptrevcomm.h b/fairroot/online/source/ptrevcomm.h similarity index 100% rename from online/source/ptrevcomm.h rename to fairroot/online/source/ptrevcomm.h diff --git a/online/source/ptrevmbsdef.h b/fairroot/online/source/ptrevmbsdef.h similarity index 100% rename from online/source/ptrevmbsdef.h rename to fairroot/online/source/ptrevmbsdef.h diff --git a/online/source/rclose.c b/fairroot/online/source/rclose.c similarity index 100% rename from online/source/rclose.c rename to fairroot/online/source/rclose.c diff --git a/online/source/swaplw.c b/fairroot/online/source/swaplw.c similarity index 100% rename from online/source/swaplw.c rename to fairroot/online/source/swaplw.c diff --git a/online/steer/FairRunOnline.cxx b/fairroot/online/steer/FairRunOnline.cxx similarity index 81% rename from online/steer/FairRunOnline.cxx rename to fairroot/online/steer/FairRunOnline.cxx index 41fcee90ff..4346a10669 100644 --- a/online/steer/FairRunOnline.cxx +++ b/fairroot/online/steer/FairRunOnline.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -17,7 +17,6 @@ #include "FairField.h" #include "FairFileHeader.h" #include "FairGeoParSet.h" -#include "FairLogger.h" #include "FairParSet.h" // for FairParSet #include "FairRootManager.h" #include "FairRunIdGenerator.h" @@ -34,6 +33,7 @@ #include // for TObject #include #include +#include #include #include #include @@ -43,7 +43,10 @@ using std::endl; FairRunOnline* FairRunOnline::fgRinstance = nullptr; -FairRunOnline* FairRunOnline::Instance() { return fgRinstance; } +FairRunOnline* FairRunOnline::Instance() +{ + return fgRinstance; +} FairRunOnline::FairRunOnline() : FairRun() @@ -94,9 +97,12 @@ FairRunOnline::~FairRunOnline() } } -Bool_t gIsInterrupted; +static Bool_t gIsInterrupted; -void handler_ctrlc(int) { gIsInterrupted = kTRUE; } +static void handler_ctrlc(int) +{ + gIsInterrupted = kTRUE; +} void FairRunOnline::Init() { @@ -124,10 +130,9 @@ void FairRunOnline::Init() fRootManager->ReadEvent(0); } - GetEventHeader(); - + // --- Get event header from Run + auto* evtHeader = GetEventHeader(); FillEventHeader(); - if (0 == fRunId) // Run ID was not set in run manager { if (0 == GetEvtHeaderRunId()) // Run ID was not set in source @@ -177,19 +182,18 @@ void FairRunOnline::Init() GetSource()->SetParUnpackers(); fTask->SetParTask(); - fRtdb->initContainers(fRunId); + if (!fRtdb->initContainers(fRunId)) { + LOG(error) << "FairRunOnline::Init: fRtdb->initContainers failed"; + } - // InitContainers(); - // --- Get event header from Run - if (!fEvtHeader) { - LOG(fatal) << "FairRunOnline::InitContainers:No event header in run!"; + LOG(info) << "FairRunOnline::Init() Event header at " << evtHeader; + fRootManager->Register("EventHeader.", "Event", evtHeader, (nullptr != GetSink())); + evtHeader->SetRunId(fRunId); + + if (!GetSource()->InitUnpackers()) { + LOG(fatal) << "FairRunOnline->Init() InitUnpackers() failed!"; return; } - LOG(info) << "FairRunOnline::InitContainers: event header at " << fEvtHeader; - fRootManager->Register("EventHeader.", "Event", fEvtHeader, (nullptr != GetSink())); - fEvtHeader->SetRunId(fRunId); - - GetSource()->InitUnpackers(); // Now call the User initialize for Tasks fTask->InitTask(); @@ -200,61 +204,19 @@ void FairRunOnline::Init() fRootManager->WriteFileHeader(fFileHeader); } -void FairRunOnline::InitContainers() -{ - fRtdb = GetRuntimeDb(); - FairBaseParSet* par = static_cast(fRtdb->getContainer("FairBaseParSet")); - LOG(info) << "FairRunOnline::InitContainers: par = " << par; - if (nullptr == par) - LOG(warn) << "FairRunOnline::InitContainers: no 'FairBaseParSet' container !"; - - if (par) { - fEvtHeader = static_cast(fRootManager->GetObject("EventHeader.")); - - fRunId = GetEvtHeaderRunId(); - - // Copy the Event Header Info to Output - fEvtHeader->Register(); - - // Init the containers in Tasks - fRtdb->initContainers(fRunId); - fTask->ReInitTask(); - // fTask->SetParTask(); - fRtdb->initContainers(fRunId); - // if (gGeoManager==0) { - // par->GetGeometry(); - // } - } else { - // --- Get event header from Run - // fEvtHeader = dynamic_cast (FairRunOnline::Instance()->GetEventHeade - GetEventHeader(); - if (!fEvtHeader) { - LOG(fatal) << "FairRunOnline::InitContainers:No event header in run!"; - return; - } - LOG(info) << "FairRunOnline::InitContainers: event header at " << fEvtHeader; - fRootManager->Register("EventHeader.", "Event", fEvtHeader, kTRUE); - } -} - Int_t FairRunOnline::EventLoop() { gSystem->IgnoreInterrupt(); signal(SIGINT, handler_ctrlc); FillEventHeader(); - auto const tmpId = GetEvtHeaderRunId(); - - if (tmpId != fRunId) { - LOG(info) << "FairRunOnline::EventLoop() Call Reinit due to changed RunID (from " << fRunId << " to " << tmpId; - fRunId = tmpId; - Reinit(fRunId); - GetSource()->ReInitUnpackers(); - fTask->ReInitTask(); + if (!CheckRunIdChanged()) { + return 1; } fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime()); fTask->ExecuteTask(""); + // TODO: Fill the event header again? Is this necessary? FillEventHeader(); Fill(); fRootManager->DeleteOldWriteoutBufferData(); @@ -368,10 +330,38 @@ void FairRunOnline::RegisterHttpCommand(TString name, TString command) } } +/** + * \sa FairRunAna::CheckRunIdChanged + */ +bool FairRunOnline::CheckRunIdChanged() +{ + auto const tmpId = GetEvtHeaderRunId(); + if (tmpId == fRunId) { + return true; + } + + LOG(info) << "FairRunOnline::CheckRunIdChanged: Detected changed RunID from " << fRunId << " to " << tmpId; + fRunId = tmpId; + if (fStatic) { + LOG(info) << "FairRunOnline::CheckRunIdChanged: ReInit not called because initialisation is static."; + return true; + } + LOG(info) << "FairRunOnline::CheckRunIdChanged: Call Reinit."; + Reinit(fRunId); + if (!GetSource()->ReInitUnpackers()) { + LOG(fatal) << "FairRunOnline::CheckRunIdChanged: ReInitUnpackers() failed!"; + return false; + } + fTask->ReInitTask(); + return true; +} + void FairRunOnline::Reinit(UInt_t runId) { // reinit procedure - fRtdb->initContainers(runId); + if (!fRtdb->initContainers(runId)) { + LOG(error) << "FairRunOnline::Reinit: fRtdb->initContainers failed"; + } } void FairRunOnline::SetContainerStatic(Bool_t tempBool) @@ -411,5 +401,3 @@ void FairRunOnline::Fill() fMarkFill = kTRUE; } } - -ClassImp(FairRunOnline); diff --git a/online/steer/FairRunOnline.h b/fairroot/online/steer/FairRunOnline.h similarity index 92% rename from online/steer/FairRunOnline.h rename to fairroot/online/steer/FairRunOnline.h index 075efad0e4..ff40df2437 100644 --- a/online/steer/FairRunOnline.h +++ b/fairroot/online/steer/FairRunOnline.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -8,13 +8,6 @@ #ifndef FAIRRUNONLINE_H #define FAIRRUNONLINE_H -/** - * Configure and manage the Analysis - * @author M. Al-Turany D. Bertini - * @version 0.1 - * @since 28.02.05 - */ - #include "FairField.h" #include "FairRootManager.h" #include "FairRun.h" @@ -25,13 +18,19 @@ class FairField; class FairSource; class THttpServer; -class TObject; +/** + * Configure and manage the Analysis + * \ingroup online fairroot_singleton + * @author M. Al-Turany D. Bertini + * @version 0.1 + * @since 28.02.05 + */ class FairRunOnline : public FairRun { public: static FairRunOnline* Instance(); - virtual ~FairRunOnline(); + ~FairRunOnline() override; FairRunOnline(); FairRunOnline(FairSource* source); @@ -56,8 +55,6 @@ class FairRunOnline : public FairRun * is not checked anymore after initialization */ - /** Init containers executed on PROOF, which is part of Init when running locally*/ - void InitContainers(); void SetContainerStatic(Bool_t tempBool = kTRUE); Bool_t GetContainerStatic() { return fStatic; }; @@ -91,6 +88,12 @@ class FairRunOnline : public FairRun /** Main Event loop **/ Int_t EventLoop(); + /** + * \brief Internal facade: Handle RunID changes + * \return false on error + */ + bool CheckRunIdChanged(); + protected: /** This variable became true after Init is called*/ Bool_t fIsInitialized; diff --git a/parbase/CMakeLists.txt b/fairroot/parbase/CMakeLists.txt similarity index 89% rename from parbase/CMakeLists.txt rename to fairroot/parbase/CMakeLists.txt index 1ff3afcc71..6ec97e655c 100644 --- a/parbase/CMakeLists.txt +++ b/fairroot/parbase/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -35,11 +35,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC ROOT::Core diff --git a/parbase/FairContFact.cxx b/fairroot/parbase/FairContFact.cxx similarity index 89% rename from parbase/FairContFact.cxx rename to fairroot/parbase/FairContFact.cxx index ea8d79f457..ff53a1df1b 100644 --- a/parbase/FairContFact.cxx +++ b/fairroot/parbase/FairContFact.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,15 +22,13 @@ #include // for TIter #include +#include #include // for strlen #include #include // for operator<<, ostream, cout, etc using std::cout; -ClassImp(FairContainer); -ClassImp(FairContFact); - FairContainer::FairContainer() : TNamed() , contexts(nullptr) @@ -148,11 +146,14 @@ const char* FairContainer::getContext() FairContFact::FairContFact() : TNamed() -{} +{ + containers->SetName("containers"); +} FairContFact::FairContFact(const char* name, const char* title) : TNamed(name, title) { + containers->SetName("containers"); FairRuntimeDb::instance()->addContFactory(this); } @@ -185,22 +186,25 @@ FairParSet* FairContFact::getContainer(const char* name) // createContainer(FairContainer*), which is implemented in the derived classes // and calls the corresponding constructor. Then the pointer it added in the // runtime database. - auto c = static_cast((containers->FindObject(name))); - - FairParSet* cont = nullptr; - if (c) { - TString cn = c->getConcatName(); - FairRuntimeDb* rtdb = FairRuntimeDb::instance(); - if (!(cont = rtdb->findContainer(c->getConcatName().Data()))) { - if (strlen(c->getActualContext()) == 0) { - c->setActualContext(c->getDefaultContext()); - } - cont = createContainer(c); - if (cont) { - rtdb->addContainer(cont); - } - } + auto c = static_cast(containers->FindObject(name)); + if (!c) { + return nullptr; + } + + FairRuntimeDb* rtdb = FairRuntimeDb::instance(); + FairParSet* cont = rtdb->findContainer(c->getConcatName().Data()); + if (cont) { + return cont; + } + + if (strlen(c->getActualContext()) == 0) { + c->setActualContext(c->getDefaultContext()); + } + cont = createContainer(c); + if (cont) { + rtdb->addContainer(cont); } + return cont; } @@ -234,3 +238,11 @@ Bool_t FairContFact::AddContainer(FairContainer* cont) containers->Add(cont); return kTRUE; } + +void FairContFact::ls(Option_t* option) const +{ + TNamed::ls(option); + TROOT::IncreaseDirLevel(); + containers->ls(); + TROOT::DecreaseDirLevel(); +} diff --git a/parbase/FairContFact.h b/fairroot/parbase/FairContFact.h similarity index 95% rename from parbase/FairContFact.h rename to fairroot/parbase/FairContFact.h index 55224baecb..a39f865fe1 100644 --- a/parbase/FairContFact.h +++ b/fairroot/parbase/FairContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -56,6 +56,8 @@ class FairContFact : public TNamed /// @param[in] container Transfers ownership if return value is true Bool_t AddContainer(FairContainer*); + void ls(Option_t* option = "") const override; + protected: TList* containers{new TList}; // all parameter containers managed by this factory const char* getActualContext(const char* name) diff --git a/parbase/FairDetParAsciiFileIo.cxx b/fairroot/parbase/FairDetParAsciiFileIo.cxx similarity index 87% rename from parbase/FairDetParAsciiFileIo.cxx rename to fairroot/parbase/FairDetParAsciiFileIo.cxx index cf6a4bd966..6ea1c17b1a 100644 --- a/parbase/FairDetParAsciiFileIo.cxx +++ b/fairroot/parbase/FairDetParAsciiFileIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -20,9 +20,12 @@ #include "FairParSet.h" // for FairParSet -#include // for fstream -#include // for printf, sprintf -#include // for strlen, strncmp +#include // for printf +#include // for strlen, strncmp +#include // for format +#include // for fstream +#include // for std::string +#include // for std::string_view using std::ios; @@ -42,24 +45,28 @@ FairDetParAsciiFileIo::FairDetParAsciiFileIo(std::fstream* f) Bool_t FairDetParAsciiFileIo::findContainer(const Text_t* name) { // searches the container in the file - const Int_t maxbuf = 4000; - Text_t buf[maxbuf]; - Text_t buf2[maxbuf]; - sprintf(buf2, "%s%s%s", "[", name, "]"); - // cout << " buf2 " << buf2 << endl; + const auto searchValue = fmt::format("[{}]", name); + const auto searchValueLength = searchValue.size(); pFile->clear(); pFile->seekg(0, ios::beg); - while (!pFile->eof()) { - pFile->getline(buf, maxbuf); - if (buf[0] != '[') { + // looking for lines that start with searchValue + for (std::string line; std::getline(*pFile, line);) { + // TODO: C++20 + // if (line.starts_with(searchValue)) { + // return true; + // } + // clang-format off + + if (line.size() < searchValueLength) { continue; } - // cout << " buf: " << buf << endl; - if (!strncmp(buf, buf2, strlen(buf2))) { - break; + if (const auto linePrefix = std::string_view(line).substr(0, searchValueLength); + linePrefix == searchValue) { + return true; } + // clang-format on } - return !pFile->eof(); + return false; } Bool_t FairDetParAsciiFileIo::checkAllFound(Int_t* set, Int_t setSize) @@ -154,7 +161,6 @@ void FairDetParAsciiFileIo::writeComment(FairParSet* pPar) } } -ClassImp(FairDetParAsciiFileIo); /* FairDetParAsciiFileIo::FairDetParAsciiFileIo(std::fstream* f) { // constructor diff --git a/parbase/FairDetParAsciiFileIo.h b/fairroot/parbase/FairDetParAsciiFileIo.h similarity index 100% rename from parbase/FairDetParAsciiFileIo.h rename to fairroot/parbase/FairDetParAsciiFileIo.h diff --git a/parbase/FairDetParIo.cxx b/fairroot/parbase/FairDetParIo.cxx similarity index 88% rename from parbase/FairDetParIo.cxx rename to fairroot/parbase/FairDetParIo.cxx index 3087ec0747..424c1abb3f 100644 --- a/parbase/FairDetParIo.cxx +++ b/fairroot/parbase/FairDetParIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,5 +18,3 @@ FairDetParIo::FairDetParIo() : TNamed() , inputNumber(0) {} - -ClassImp(FairDetParIo); diff --git a/parbase/FairDetParIo.h b/fairroot/parbase/FairDetParIo.h similarity index 100% rename from parbase/FairDetParIo.h rename to fairroot/parbase/FairDetParIo.h diff --git a/parbase/FairDetParRootFileIo.cxx b/fairroot/parbase/FairDetParRootFileIo.cxx similarity index 84% rename from parbase/FairDetParRootFileIo.cxx rename to fairroot/parbase/FairDetParRootFileIo.cxx index 367cb1d357..a32522ae8a 100644 --- a/parbase/FairDetParRootFileIo.cxx +++ b/fairroot/parbase/FairDetParRootFileIo.cxx @@ -1,9 +1,9 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * - * This software is distributed under the terms of the * + * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * + * copied verbatim in the file "LICENSE" * ********************************************************************************/ //*-- AUTHOR : Ilse Koenig //*-- Created : 21/10/2004 @@ -30,17 +30,13 @@ #include // for TDirectory, gDirectory #include // for TKey #include // for TROOT, gROOT +#include // for format #include // for operator<<, basic_ostream, etc -#include // for sprintf - -class TObject; using std::cout; using std::endl; -ClassImp(FairDetParRootFileIo); - -FairDetParRootFileIo::FairDetParRootFileIo(FairParRootFile *f) +FairDetParRootFileIo::FairDetParRootFileIo(FairParRootFile* f) : FairDetParIo() , pFile(f) { @@ -48,7 +44,7 @@ FairDetParRootFileIo::FairDetParRootFileIo(FairParRootFile *f) // pFile=f; } -Bool_t FairDetParRootFileIo::read(FairParSet *pPar) +Bool_t FairDetParRootFileIo::read(FairParSet* pPar) { // generic read function for parameter containers auto name = pPar->GetName(); @@ -65,7 +61,7 @@ Bool_t FairDetParRootFileIo::read(FairParSet *pPar) return kTRUE; } - TKey *key = dynamic_cast(gDirectory->GetKey(name, version)); + TKey* key = gDirectory->GetKey(name, version); if (key) { pPar->clear(); key->Read(pPar); @@ -78,7 +74,7 @@ Bool_t FairDetParRootFileIo::read(FairParSet *pPar) return kFALSE; } -Int_t FairDetParRootFileIo::write(FairParSet *pPar) +Int_t FairDetParRootFileIo::write(FairParSet* pPar) { // writes a parameter container to the ROOT file and returns the new version // number (returns -1 if the file is not writable) @@ -102,7 +98,7 @@ Int_t FairDetParRootFileIo::getMaxVersion(const char* name) { // returns the maximum version of the container given by name in the ROOT // file (return -1 if not found) - TKey *key = pFile->GetKey(name); + TKey* key = pFile->GetKey(name); if (key) { return key->GetCycle(); } else { @@ -114,33 +110,31 @@ Int_t FairDetParRootFileIo::findInputVersion(const char* name) { // finds the input version to initialize the container given by name; // returns -1 if the version cannot be determined - FairParVersion *currVers = FairRuntimeDb::instance()->getCurrentRun()->getParVersion(name); + FairParVersion* currVers = FairRuntimeDb::instance()->getCurrentRun()->getParVersion(name); Int_t v = currVers->getInputVersion(inputNumber); if (v > 0) { return v; } // predefined - FairRtdbRun *r = pFile->getRun(); + FairRtdbRun* r = pFile->getRun(); // cout << "-I- FairDetParRootFileIo::findInputVersion " << r << endl; if (!r) { return -1; } // run not in ROOT file - FairParVersion *vers = r->getParVersion(name); + FairParVersion* vers = r->getParVersion(name); if (!vers) { return -1; } // container not in ROOT file return vers->getRootVersion(); } -TObject *FairDetParRootFileIo::findContainer(Text_t *name, Int_t vers) +TObject* FairDetParRootFileIo::findContainer(Text_t* name, Int_t vers) { // finds the parameter container given by its name with a special version in // the ROOT file (returns 0 if not successful) // This funtion uses internally the ROOT function FindObject(Text_t*), which // creates a new object. The calling function must therefore delete the // object after usage! - Text_t cn[80]; - sprintf(cn, "%s;%i", name, vers); pFile->cd(); - TObject *p = gROOT->FindObject(cn); + TObject* p = gROOT->FindObject(fmt::format("{};{}", name, vers).c_str()); return p; } diff --git a/parbase/FairDetParRootFileIo.h b/fairroot/parbase/FairDetParRootFileIo.h similarity index 100% rename from parbase/FairDetParRootFileIo.h rename to fairroot/parbase/FairDetParRootFileIo.h diff --git a/parbase/FairGenericParAsciiFileIo.cxx b/fairroot/parbase/FairGenericParAsciiFileIo.cxx similarity index 99% rename from parbase/FairGenericParAsciiFileIo.cxx rename to fairroot/parbase/FairGenericParAsciiFileIo.cxx index e4fe144a58..e1a60f9db0 100644 --- a/parbase/FairGenericParAsciiFileIo.cxx +++ b/fairroot/parbase/FairGenericParAsciiFileIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -31,8 +31,6 @@ using std::ios; -ClassImp(FairGenericParAsciiFileIo); - FairGenericParAsciiFileIo::FairGenericParAsciiFileIo(std::fstream *f) : FairDetParAsciiFileIo(f) { diff --git a/parbase/FairGenericParAsciiFileIo.h b/fairroot/parbase/FairGenericParAsciiFileIo.h similarity index 100% rename from parbase/FairGenericParAsciiFileIo.h rename to fairroot/parbase/FairGenericParAsciiFileIo.h diff --git a/parbase/FairGenericParRootFileIo.cxx b/fairroot/parbase/FairGenericParRootFileIo.cxx similarity index 90% rename from parbase/FairGenericParRootFileIo.cxx rename to fairroot/parbase/FairGenericParRootFileIo.cxx index fc6303815a..0435d8e733 100644 --- a/parbase/FairGenericParRootFileIo.cxx +++ b/fairroot/parbase/FairGenericParRootFileIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,10 +19,6 @@ #include // for TString -class FairParSet; - -ClassImp(FairGenericParRootFileIo); - FairGenericParRootFileIo::FairGenericParRootFileIo(FairParRootFile* f) : FairDetParRootFileIo(f) { diff --git a/parbase/FairGenericParRootFileIo.h b/fairroot/parbase/FairGenericParRootFileIo.h similarity index 100% rename from parbase/FairGenericParRootFileIo.h rename to fairroot/parbase/FairGenericParRootFileIo.h diff --git a/parbase/FairParAsciiFileIo.cxx b/fairroot/parbase/FairParAsciiFileIo.cxx similarity index 69% rename from parbase/FairParAsciiFileIo.cxx rename to fairroot/parbase/FairParAsciiFileIo.cxx index 00f92210d4..396dbfc2d4 100644 --- a/parbase/FairParAsciiFileIo.cxx +++ b/fairroot/parbase/FairParAsciiFileIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -19,8 +19,7 @@ /////////////////////////////////////////////////////////////////////////////// #include "FairParAsciiFileIo.h" -#include "FairDetParIo.h" // for FairDetParIo -#include "FairLogger.h" +#include "FairGenericParAsciiFileIo.h" #include "FairRuntimeDb.h" // for FairRuntimeDb #include // for TIter @@ -28,29 +27,21 @@ #include // for TObjString #include // for TString, operator<< #include // for TSystem, gSystem -#include // for cout, cerr -#include // for strcmp +#include // for strcmp +#include +#include using std::cerr; using std::cout; using std::endl; -using std::filebuf; -using std::ios; -ClassImp(FairParAsciiFileIo); - -FairParAsciiFileIo::FairParAsciiFileIo() - : FairParIo() - , file(nullptr) +void FairParAsciiFileIo::ActivateSelf() { - // default destructor - // file=0; -} - -FairParAsciiFileIo::~FairParAsciiFileIo() -{ - // default destructor closes an open file and deletes list of I/Os - close(); + if (getDetParIo("FairGenericParIo")) { + return; + } + auto pn = new FairGenericParAsciiFileIo(getFile()); + setDetParIo(pn); } Bool_t FairParAsciiFileIo::open(const Text_t* fname, const Text_t* status) @@ -59,21 +50,20 @@ Bool_t FairParAsciiFileIo::open(const Text_t* fname, const Text_t* status) // if a file is already open, this file will be closed // activates detector I/Os close(); - if (!((strcmp(status, "in") == 0) || (strcmp(status, "out") == 0))) { + if ((strcmp(status, "in") != 0) && (strcmp(status, "out") != 0)) { cout << "Put the right stream option for file " << fname << "\n writing state : out\n reading state : in \nopen aborted \n"; return kFALSE; } - file = new std::fstream(); if (strcmp(status, "in") == 0) { - file->open(fname, ios::in); + file.open(fname, std::ios::in); }; if (strcmp(status, "out") == 0) { - file->open(fname, ios::out); + file.open(fname, std::ios::out); }; - filebuf* buf = file->rdbuf(); - if (file && (buf->is_open() == 1)) { + if (file.is_open()) { filename = fname; + ActivateSelf(); FairRuntimeDb::instance()->activateParIo(this); return kTRUE; } @@ -95,6 +85,14 @@ Bool_t FairParAsciiFileIo::open(const TList* fnamelist, const Text_t* status) Int_t pid = gSystem->GetPid(); outFileName += pid; outFileName += ".par"; + + MergeFiles(outFileName, fnamelist); + + return open(outFileName, status); +} + +void FairParAsciiFileIo::MergeFiles(const char* fname, const TList* fnamelist) +{ TString catCommand = "cat "; TObjString* string; TListIter myIter(fnamelist); @@ -105,32 +103,19 @@ Bool_t FairParAsciiFileIo::open(const TList* fnamelist, const Text_t* status) gSystem->ExpandPathName(strParPath); if (gSystem->AccessPathName(strParPath)) LOG(fatal) << "Parameter file " << strParPath << " does not exist."; - // cout << string->GetString() <GetString(); catCommand += " "; } catCommand += "> "; - catCommand += outFileName; - - // cout <<"CAT: "<Exec(catCommand); - - return open(outFileName, status); } void FairParAsciiFileIo::close() { - // closes the file and deletes the detector I/Os - if (file) { - file->close(); - delete file; - file = 0; - filename = ""; - } - if (detParIoList) { - detParIoList->Delete(); - } + file.close(); + FairParIo::close(); } void FairParAsciiFileIo::print() @@ -138,20 +123,8 @@ void FairParAsciiFileIo::print() // prints information about the file and the detector I/Os if (check()) { cout << "Ascii I/O " << filename << " is open\n"; - TIter next(detParIoList); - FairDetParIo* io; - cout << "detector I/Os: "; - while ((io = static_cast(next()))) { - cout << " " << io->GetName(); - } - cout << '\n'; + FairParIo::print(); } else { cout << "No file open\n"; } } - -std::fstream* FairParAsciiFileIo::getFile() -{ - // returns the file pointer - return file; -} diff --git a/fairroot/parbase/FairParAsciiFileIo.h b/fairroot/parbase/FairParAsciiFileIo.h new file mode 100644 index 0000000000..4123c5afef --- /dev/null +++ b/fairroot/parbase/FairParAsciiFileIo.h @@ -0,0 +1,78 @@ +/******************************************************************************** + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ +#ifndef FAIRPARASCIFILEIIO_H +#define FAIRPARASCIFILEIIO_H + +#include "FairParIo.h" // for FairParIo + +#include // for Bool_t, Text_t, etc +#include // for fstream, etc + +class FairParAsciiFileIo : public FairParIo +{ + public: + FairParAsciiFileIo() = default; + FairParAsciiFileIo(const FairParAsciiFileIo&) = delete; + FairParAsciiFileIo& operator=(const FairParAsciiFileIo&) = delete; + + /** + * default destructor closes an open file and deletes list of I/Os + */ + ~FairParAsciiFileIo() override = default; + + /** + * \brief Opens file + * + * If a file is already open, this file will be closed, + * activates detector I/Os. + * \param fname name of the parameter file + * \param status reading with "in" or writing with "out" + */ + Bool_t open(const Text_t* fname, const Text_t* status = "in"); + + /** + * \brief Opens TList of files + * + * Concatenates files whose names are stored in the TList, + * TList holds list of TObjStrings. + * Calls MergeFiles with all_$pid.par in local working directory, + * calls open to open the generated file all_$pid.par. + * \param fnamelist TList of file names to be merged + * \param status reading with "in" or writing with "out" + */ + Bool_t open(const TList* fnamelist, const Text_t* status = "in"); + + /** + * \brief Merges files + * + * \param fname the merged file name, f.e. "all.par" + * \param fnamelist TList of file names to be merged + * + * Users should call standard open (f.e. open("all.par")) after calling this function. + */ + static void MergeFiles(const char* fname, const TList* fnamelist); + + // closes file + void close() override; + + // returns kTRUE if file is open + Bool_t check() override { return file.is_open(); } + + // prints information about the file and the detector I/Os + void print() override; + + std::fstream* getFile() { return &file; } + + private: + std::fstream file{}; + void ActivateSelf(); + + ClassDefOverride(FairParAsciiFileIo, 0); // Parameter I/O from ASCII files +}; + +#endif /* !FAIRPARASCIIFILEIO_H */ diff --git a/parbase/FairParGenericSet.cxx b/fairroot/parbase/FairParGenericSet.cxx similarity index 96% rename from parbase/FairParGenericSet.cxx rename to fairroot/parbase/FairParGenericSet.cxx index 5d2f53e183..b651bd42b4 100644 --- a/parbase/FairParGenericSet.cxx +++ b/fairroot/parbase/FairParGenericSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -35,8 +35,6 @@ #include // for operator<<, TString #include // for operator<<, ostream, cout, etc -ClassImp(FairParGenericSet); - Bool_t FairParGenericSet::init(FairParIo* inp) { // intitializes the container from an input diff --git a/parbase/FairParGenericSet.h b/fairroot/parbase/FairParGenericSet.h similarity index 100% rename from parbase/FairParGenericSet.h rename to fairroot/parbase/FairParGenericSet.h diff --git a/parbase/FairParIo.cxx b/fairroot/parbase/FairParIo.cxx similarity index 84% rename from parbase/FairParIo.cxx rename to fairroot/parbase/FairParIo.cxx index 67b01b93e9..7fdbfba7fa 100644 --- a/parbase/FairParIo.cxx +++ b/fairroot/parbase/FairParIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +22,7 @@ #include // for TIter #include // for TList - -ClassImp(FairParIo); +#include FairParIo::FairParIo() : TObject() @@ -42,7 +41,6 @@ FairParIo::~FairParIo() if (detParIoList) { detParIoList->Delete(); delete detParIoList; - detParIoList = 0; } } @@ -78,5 +76,23 @@ void FairParIo::removeDetParIo(Text_t* detName) // removes input/output class for a detector TObject* p = detParIoList->FindObject(detName); delete p; - p = 0; +} + +void FairParIo::close() +{ + filename = ""; + if (detParIoList) { + detParIoList->Delete(); + } +} + +void FairParIo::print() +{ + TIter next(detParIoList); + FairDetParIo* io; + std::cout << "detector I/Os: "; + while ((io = static_cast(next()))) { + std::cout << " " << io->GetName(); + } + std::cout << '\n'; } diff --git a/parbase/FairParIo.h b/fairroot/parbase/FairParIo.h similarity index 87% rename from parbase/FairParIo.h rename to fairroot/parbase/FairParIo.h index dcd50299c6..91ea45e0e2 100644 --- a/parbase/FairParIo.h +++ b/fairroot/parbase/FairParIo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,12 +9,12 @@ #define FAIRPARIO_H #include // for Bool_t, Text_t, etc +#include // for TList #include // for TObject #include // for TString class FairDetParIo; class FairRtdbRun; -class TList; class FairParIo : public TObject { @@ -25,12 +25,14 @@ class FairParIo : public TObject public: FairParIo(); - virtual ~FairParIo(); + FairParIo(const FairParIo&) = delete; + FairParIo& operator=(const FairParIo&) = delete; + ~FairParIo() override; virtual FairDetParIo* getDetParIo(const Text_t*); virtual void setDetParIo(FairDetParIo*); virtual void removeDetParIo(Text_t*); void setInputNumber(Int_t); - virtual void close() { ; } + virtual void close(); // returns the filename const char* getFilename() { return filename.Data(); } @@ -41,7 +43,7 @@ class FairParIo : public TObject virtual void setDetParIo(Text_t*) { ; } // prints information about input/output - virtual void print() { ; } + virtual void print(); // checks if the input/output is open virtual Bool_t check() { return kFALSE; } @@ -51,16 +53,12 @@ class FairParIo : public TObject // sets global file pointer in ROOT if input/output is a ROOT-file // (code in FairParRootFileIo) - virtual void cd() { ; } + virtual void cd() {} // set and get for flag autoWritable void setAutoWritable(Bool_t f = kTRUE) { autoWritable = f; } Bool_t isAutoWritable() const { return autoWritable; } - private: - FairParIo(const FairParIo&); - FairParIo& operator=(const FairParIo&); - ClassDefOverride(FairParIo, 0); // Base class for all parameter I/Os }; diff --git a/parbase/FairParRootFileIo.cxx b/fairroot/parbase/FairParRootFileIo.cxx similarity index 89% rename from parbase/FairParRootFileIo.cxx rename to fairroot/parbase/FairParRootFileIo.cxx index 6121df9c42..0d6a514f03 100644 --- a/parbase/FairParRootFileIo.cxx +++ b/fairroot/parbase/FairParRootFileIo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "FairParRootFileIo.h" -#include "FairDetParIo.h" // for FairDetParIo +#include "FairGenericParRootFileIo.h" #include "FairRtdbRun.h" // for FairRtdbRun #include "FairRuntimeDb.h" // for FairRuntimeDb @@ -38,53 +38,37 @@ #include // for TString, Form #include // for LOG #include // for operator<<, basic_ostream, etc -#include // for std::unique_ptr using std::cerr; using std::cout; using std::endl; -ClassImp(FairParRootFile); -ClassImp(FairParRootFileIo); - FairParRootFile::FairParRootFile(const Text_t* fname, Option_t* option, const Text_t* ftitle, Int_t compress) : TNamed(fname, ftitle) - , run(nullptr) , RootFile(TFile::Open(fname, option, ftitle, compress)) { // : TFile(fname,option,ftitle,compress) { // constructor opens a ROOT file // RootFile=TFile::Open(fname,option,ftitle,compress); - // run=0; } FairParRootFile::FairParRootFile(TFile* f) : TNamed(f->GetName(), f->GetTitle()) - , run(nullptr) , RootFile(f) { // :TFile(f->GetName(),"UPDATE"){ // constructor opens a ROOT file // RootFile=TFile::Open(f->GetName(),"UPDATE"); // RootFile=f; - // run=0; } -FairParRootFile::~FairParRootFile() -{ - // destructor - delete run; - run = 0; - // TODO: What about the file? Should it be closed or not -} +FairParRootFile::~FairParRootFile() = default; void FairParRootFile::readVersions(FairRtdbRun* currentRun) { // finds the current run containing the parameter container versions // in the ROOT file - delete run; - - run = RootFile->Get(currentRun->GetName()); + run.reset(RootFile->Get(currentRun->GetName())); if (!run) { LOG(warning) << "FairParRootFile::readVersions(" << RootFile->GetName() << "): Reading run " << currentRun->GetName() << " failed"; @@ -118,6 +102,15 @@ FairParRootFileIo::~FairParRootFileIo() close(); } +void FairParRootFileIo::ActivateSelf() +{ + if (getDetParIo("FairGenericParIo")) { + return; + } + auto pn = new FairGenericParRootFileIo(getParRootFile()); + setDetParIo(pn); +} + Bool_t FairParRootFileIo::open(const Text_t* fname, Option_t* option, const Text_t* ftitle, Int_t compress) { // It opens a ROOT file (default option "READ"). An open file will be closed. @@ -144,6 +137,7 @@ Bool_t FairParRootFileIo::open(const Text_t* fname, Option_t* option, const Text if (file && file->IsOpen()) { filename = fname; + ActivateSelf(); FairRuntimeDb::instance()->activateParIo(this); return kTRUE; } @@ -217,14 +211,14 @@ void FairParRootFileIo::MergeFiles(TFile* newParFile, const TList* fnamelist) continue; } - TList* inputKeys = static_cast(inFile->GetListOfKeys()); + TList* inputKeys = inFile->GetListOfKeys(); TListIter keyIter(inputKeys); TKey* inpKey; while ((inpKey = static_cast(keyIter.Next()))) { - TObject* tempObj = inFile->Get(inpKey->GetName()); + std::unique_ptr tempObj{inFile->Get(inpKey->GetName())}; - newParFile->WriteTObject(tempObj); + newParFile->WriteTObject(tempObj.get()); } } } @@ -237,6 +231,7 @@ Bool_t FairParRootFileIo::open(TFile* f) file = new FairParRootFile(f); if (file && file->IsOpen()) { filename = file->GetName(); + ActivateSelf(); FairRuntimeDb::instance()->activateParIo(this); return kTRUE; } @@ -251,9 +246,7 @@ void FairParRootFileIo::close() delete file; file = 0; } - if (detParIoList) { - detParIoList->Delete(); - } + FairParIo::close(); } void FairParRootFileIo::print() @@ -261,14 +254,8 @@ void FairParRootFileIo::print() // prints the content of a open ROOT file and the list of detector I/Os if (file) { file->ls(); - TIter next(detParIoList); - FairDetParIo* io; cout << "Root file I/O " << file->GetName() << " is open\n"; - cout << "detector I/Os: "; - while ((io = static_cast(next()))) { - cout << " " << io->GetName(); - } - cout << '\n'; + FairParIo::print(); } else { cout << "No ROOT file open\n"; } diff --git a/parbase/FairParRootFileIo.h b/fairroot/parbase/FairParRootFileIo.h similarity index 90% rename from parbase/FairParRootFileIo.h rename to fairroot/parbase/FairParRootFileIo.h index 4e9fe51db8..833ae8bd57 100644 --- a/parbase/FairParRootFileIo.h +++ b/fairroot/parbase/FairParRootFileIo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,20 +14,17 @@ #include // for TFile #include // for TNamed #include -using std::fstream; +#include class FairRtdbRun; -class TKey; -class TList; class FairParRootFile : public TNamed { public: - FairRtdbRun* run; //! pointer to current run in ROOT file FairParRootFile(const Text_t* fname, Option_t* option = "READ", const Text_t* ftitle = "", Int_t compress = 1); FairParRootFile(TFile* f); - ~FairParRootFile(); - FairRtdbRun* getRun() { return run; } + ~FairParRootFile() override; + FairRtdbRun* getRun() { return run.get(); } void readVersions(FairRtdbRun*); Bool_t IsOpen() { return RootFile && (RootFile->IsOpen()); } @@ -66,6 +63,8 @@ class FairParRootFile : public TNamed TFile* RootFile; private: + std::unique_ptr run; //! pointer to current run in ROOT file + FairParRootFile(const FairParRootFile&); FairParRootFile& operator=(const FairParRootFile&); @@ -81,7 +80,7 @@ class FairParRootFileIo : public FairParIo public: FairParRootFileIo(); FairParRootFileIo(Bool_t merged); - ~FairParRootFileIo(); + ~FairParRootFileIo() override; Bool_t open(const Text_t* fname, Option_t* option = "READ", const Text_t* ftitle = "", Int_t compress = 1); Bool_t open(const TList* fnamelist, Option_t* option = "READ", const Text_t* ftitle = "", Int_t compress = 1); static void MergeFiles(TFile* newParFile, const TList* fnamelist); @@ -115,6 +114,7 @@ class FairParRootFileIo : public FairParIo private: FairParRootFileIo(const FairParRootFileIo&); FairParRootFileIo& operator=(const FairParRootFileIo&); + void ActivateSelf(); ClassDefOverride(FairParRootFileIo, 0); // Parameter I/O from ROOT files }; diff --git a/parbase/FairParSet.cxx b/fairroot/parbase/FairParSet.cxx similarity index 94% rename from parbase/FairParSet.cxx rename to fairroot/parbase/FairParSet.cxx index 2a7909cb17..091a104bc5 100644 --- a/parbase/FairParSet.cxx +++ b/fairroot/parbase/FairParSet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -15,15 +15,13 @@ ///////////////////////////////////////////////////////////// #include "FairParSet.h" -#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN #include "FairRuntimeDb.h" // for FairRuntimeDb +#include #include // for operator<<, ostream, etc using std::cout; -ClassImp(FairParSet); - FairParSet::FairParSet(const char* name, const char* title, const char* context, Bool_t owner) : TObject() , fName(name) @@ -36,7 +34,6 @@ FairParSet::FairParSet(const char* name, const char* title, const char* context, , paramContext(context) , author("") , description("") - , fLogger(FairLogger::GetLogger()) { for (Int_t i = 0; i < 3; i++) { versions[i] = -1; @@ -118,6 +115,12 @@ void FairParSet::print() } } +void FairParSet::clear() +{ + status = kFALSE; + resetInputVersions(); +} + void FairParSet::resetInputVersions() { // resets the input versions if the container is not static @@ -141,7 +144,6 @@ FairParSet::FairParSet(const FairParSet& from) , paramContext(from.paramContext) , author(from.author) , description(from.description) - , fLogger(FairLogger::GetLogger()) { /* fName = from.fName; @@ -157,7 +159,6 @@ FairParSet::FairParSet(const FairParSet& from) paramContext = from.paramContext; author = from.author; description = from.description; - fLogger = from.fLogger; */ } @@ -179,7 +180,6 @@ FairParSet& FairParSet::operator=(const FairParSet& from) paramContext = from.paramContext; author = from.author; description = from.description; - fLogger = from.fLogger; return *this; } diff --git a/parbase/FairParSet.h b/fairroot/parbase/FairParSet.h similarity index 89% rename from parbase/FairParSet.h rename to fairroot/parbase/FairParSet.h index 4fe2bee1e4..02fd00f9f8 100644 --- a/parbase/FairParSet.h +++ b/fairroot/parbase/FairParSet.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,7 +12,6 @@ #include #include // for TString -class FairLogger; class FairParIo; class FairParSet : public TObject @@ -28,21 +27,19 @@ class FairParSet : public TObject TString paramContext; // Context/purpose for parameters and conditions TString author; // Author of parameters TString description; // Description of parameters - /** Fair Logger */ - FairLogger* fLogger; //! public: FairParSet(const char* name = "", const char* title = "", const char* context = "", Bool_t owner = kFALSE); virtual ~FairParSet() {} - const char* GetName() const override { return static_cast(fName.Data()); } - const char* GetTitle() const override { return static_cast(fTitle.Data()); } + const char* GetName() const override { return fName.Data(); } + const char* GetTitle() const override { return fTitle.Data(); } virtual Bool_t init(); virtual Bool_t init(FairParIo*) { return kFALSE; } virtual Int_t write(); virtual Int_t write(FairParIo*) { return kFALSE; } - virtual void clear() {} + virtual void clear(); virtual void print(); const char* getDetectorName() { return detName.Data(); } diff --git a/parbase/FairParamList.cxx b/fairroot/parbase/FairParamList.cxx similarity index 99% rename from parbase/FairParamList.cxx rename to fairroot/parbase/FairParamList.cxx index 7c8acde656..3ec32e5331 100644 --- a/parbase/FairParamList.cxx +++ b/fairroot/parbase/FairParamList.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -90,9 +90,6 @@ // ////////////////////////////////////////////////////////////////////////////////////// -ClassImp(FairParamObj); -ClassImp(FairParamList); - FairParamObj::FairParamObj(const Text_t* name) : TNamed(name, "") , paramValue(nullptr) diff --git a/parbase/FairParamList.h b/fairroot/parbase/FairParamList.h similarity index 100% rename from parbase/FairParamList.h rename to fairroot/parbase/FairParamList.h diff --git a/parbase/FairRtdbRun.cxx b/fairroot/parbase/FairRtdbRun.cxx similarity index 90% rename from parbase/FairRtdbRun.cxx rename to fairroot/parbase/FairRtdbRun.cxx index e877b1f8dc..3e4c3b825e 100644 --- a/parbase/FairRtdbRun.cxx +++ b/fairroot/parbase/FairRtdbRun.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,6 +27,8 @@ #include // for TIter #include // for TList +#include // for TROOT +#include // for format #include // for fstream #include // for setw, operator<< #include // for cout @@ -35,9 +37,6 @@ using std::cout; using std::ios; using std::setw; -ClassImp(FairParVersion); -ClassImp(FairRtdbRun); - FairParVersion::FairParVersion(const char* name) : TNamed(name, "version info") , rootVersion(0) @@ -57,6 +56,7 @@ FairRtdbRun::FairRtdbRun(const Text_t* name, const Text_t* refName) // constructor with the run id and reference run as strings // parVersions=new TList(); // refRun=refName; + parVersions->SetName("parVersions"); } FairRtdbRun::FairRtdbRun(Int_t r, Int_t rr) @@ -65,9 +65,8 @@ FairRtdbRun::FairRtdbRun(Int_t r, Int_t rr) , parVersions(new TList()) , refRun("") { - char name[255]; - sprintf(name, "%i", r); - SetName(name); + parVersions->SetName("parVersions"); + SetName(fmt::format("{}", r).c_str()); setRefRun(rr); } @@ -77,6 +76,7 @@ FairRtdbRun::FairRtdbRun(FairRtdbRun& run) , refRun(run.refRun) { // copy constructor + parVersions->SetName("parVersions"); TList* lv = run.getParVersions(); TIter next(lv); FairParVersion* pv; @@ -165,3 +165,13 @@ void FairRtdbRun::write(std::fstream& fout) << v->getRootVersion() << '\n'; } } + +void FairRtdbRun::ls(Option_t* option) const +{ + TNamed::ls(option); + TROOT::IncreaseDirLevel(); + if (parVersions) { + parVersions->ls(); + } + TROOT::DecreaseDirLevel(); +} diff --git a/parbase/FairRtdbRun.h b/fairroot/parbase/FairRtdbRun.h similarity index 93% rename from parbase/FairRtdbRun.h rename to fairroot/parbase/FairRtdbRun.h index 17ed2933fa..425b282f67 100644 --- a/parbase/FairRtdbRun.h +++ b/fairroot/parbase/FairRtdbRun.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -67,7 +67,7 @@ class FairRtdbRun : public TNamed FairRtdbRun(Int_t r, Int_t rr = -1); FairRtdbRun(FairRtdbRun& run); ~FairRtdbRun(); - inline UInt_t getRunId(void); + inline UInt_t getRunId(); void addParVersion(FairParVersion* pv); FairParVersion* getParVersion(const Text_t* name); TList* getParVersions() { return parVersions; } @@ -79,6 +79,8 @@ class FairRtdbRun : public TNamed void print(); void write(std::fstream&); + void ls(Option_t* option = "") const override; + private: FairRtdbRun& operator=(const FairRtdbRun&); @@ -87,7 +89,7 @@ class FairRtdbRun : public TNamed // -------------------- inlines --------------------------- -inline UInt_t FairRtdbRun::getRunId(void) +inline UInt_t FairRtdbRun::getRunId() { UInt_t r; sscanf(GetName(), "%i", &r); @@ -99,9 +101,7 @@ inline void FairRtdbRun::setRefRun(Int_t r) if (r == -1) { refRun = ""; } else { - char name[255]; - sprintf(name, "%i", r); - refRun = name; + refRun.Form("%i", r); } } diff --git a/parbase/FairRuntimeDb.cxx b/fairroot/parbase/FairRuntimeDb.cxx similarity index 92% rename from parbase/FairRuntimeDb.cxx rename to fairroot/parbase/FairRuntimeDb.cxx index dd53f844a2..feb98734ce 100644 --- a/parbase/FairRuntimeDb.cxx +++ b/fairroot/parbase/FairRuntimeDb.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -42,12 +42,7 @@ ///////////////////////////////////////////////////////////// #include "FairRuntimeDb.h" -#include "FairContFact.h" // for FairContFact -#include "FairDetParAsciiFileIo.h" // for FairDetParAsciiFileIo -#include "FairDetParRootFileIo.h" // for FairDetParRootFileIo -#include "FairGenericParAsciiFileIo.h" // for FairGenericParAsciiFileIo -#include "FairGenericParRootFileIo.h" // for FairGenericParRootFileIo -#include "FairLogger.h" // for FairLogger, MESSAGE_ORIGIN +#include "FairContFact.h" // for FairContFact #include "FairParAsciiFileIo.h" // for FairParAsciiFileIo #include "FairParIo.h" // for FairParIo #include "FairParRootFileIo.h" // for FairParRootFileIo @@ -57,23 +52,24 @@ #include // for TClass #include // for TIter #include // for TFile, gFile +#include // #include // for sprintf #include // for strcmp, strlen -#include // for setw, operator<< -#include // for operator<<, basic_ostream, etc - -class FairDetParIo; +#include +#include // for format +#include // for setw, operator<< +#include // for operator<<, basic_ostream, etc using std::cout; using std::endl; using std::ios; using std::setw; -ClassImp(FairRuntimeDb); +static TList contFactories; //! list of container factories FairRuntimeDb* FairRuntimeDb::gRtdb = 0; -FairRuntimeDb* FairRuntimeDb::instance(void) +FairRuntimeDb* FairRuntimeDb::instance() { // Singleton instance if (gRtdb == 0) { @@ -82,7 +78,7 @@ FairRuntimeDb* FairRuntimeDb::instance(void) return gRtdb; } -FairRuntimeDb::FairRuntimeDb(void) +FairRuntimeDb::FairRuntimeDb() : TObject() , containerList(new TList()) , runs(new TList()) @@ -93,10 +89,11 @@ FairRuntimeDb::FairRuntimeDb(void) , currentFileName("") , versionsChanged(kFALSE) , isRootFileOutput(kFALSE) - , fLogger(FairLogger::GetLogger()) , ioType(UNKNOWN_Type) { gRtdb = this; + containerList->SetName("containerList"); + runs->SetName("runs"); } FairRuntimeDb::~FairRuntimeDb() @@ -238,7 +235,7 @@ void FairRuntimeDb::removeContainer(const char* name) } } -void FairRuntimeDb::removeAllContainers(void) +void FairRuntimeDb::removeAllContainers() { // removes all containers from the list and deletes them containerList->Delete(); @@ -276,9 +273,7 @@ FairRtdbRun* FairRuntimeDb::addRun(Int_t runId, Int_t refId) FairRtdbRun* FairRuntimeDb::getRun(Int_t id) { // returns a pointer to the run called by the run id - char name[255]; - sprintf(name, "%i", id); - return static_cast((runs->FindObject(name))); + return static_cast((runs->FindObject(fmt::format("{}", id).c_str()))); } FairRtdbRun* FairRuntimeDb::getRun(const char* name) @@ -300,7 +295,10 @@ void FairRuntimeDb::removeRun(Text_t* name) } } -void FairRuntimeDb::clearRunList() { runs->Delete(); } +void FairRuntimeDb::clearRunList() +{ + runs->Delete(); +} void FairRuntimeDb::writeVersions() { @@ -357,7 +355,8 @@ Int_t FairRuntimeDb::findOutputVersion(FairParSet* cont) run = static_cast(runs->At(i)); vers = run->getParVersion(name); if (vers->getInputVersion(1) == in1 && vers->getInputVersion(2) == in2) { - if ((v = vers->getRootVersion()) != 0) { + v = vers->getRootVersion(); + if (v != 0) { return v; } } @@ -374,7 +373,8 @@ Int_t FairRuntimeDb::findOutputVersion(FairParSet* cont) while ((run = static_cast(next()))) { vers = run->getParVersion(name); if (vers->getInputVersion(1) == in1 && vers->getInputVersion(2) == in2) { - if ((v = vers->getRootVersion()) != 0) { + v = vers->getRootVersion(); + if (v != 0) { return v; } } @@ -461,7 +461,7 @@ Bool_t FairRuntimeDb::writeContainer(FairParSet* cont, FairRtdbRun* run, FairRtd return kTRUE; } -Bool_t FairRuntimeDb::initContainers(UInt_t runId, Int_t refId, const Text_t* fileName) +bool FairRuntimeDb::initContainers(UInt_t runId, Int_t refId, const char* fileName) { // loops over the list of containers and calls the init() function of each // container if it is not static @@ -505,7 +505,7 @@ Bool_t FairRuntimeDb::readAll() return kTRUE; } -Bool_t FairRuntimeDb::initContainers(void) +Bool_t FairRuntimeDb::initContainers() { // private function auto refRunName = currentRun->getRefRun(); @@ -647,6 +647,25 @@ void FairRuntimeDb::print() } } +void FairRuntimeDb::ls(Option_t* option) const +{ + TObject::ls(option); + TROOT::IncreaseDirLevel(); + if (firstInput) { + firstInput->ls(option); + } + if (secondInput) { + secondInput->ls(option); + } + if (output) { + output->ls(option); + } + contFactories.ls(); + containerList->ls(); + runs->ls(); + TROOT::DecreaseDirLevel(); +} + void FairRuntimeDb::resetInputVersions() { // resets all input versions in the list of runs and in all containers which are not static @@ -816,24 +835,6 @@ void FairRuntimeDb::closeOutput() void FairRuntimeDb::activateParIo(FairParIo* io) { // activates the detector I/O - const char* ioName = io->IsA()->GetName(); - FairDetParIo* po = io->getDetParIo("FairGenericParIo"); - if (!po) { - if (strcmp(ioName, "FairParRootFileIo") == 0) { - FairDetParRootFileIo* pn = - new FairGenericParRootFileIo((static_cast(io))->getParRootFile()); - io->setDetParIo(pn); - } else if (strcmp(ioName, "FairParAsciiFileIo") == 0) { - FairDetParAsciiFileIo* pn = - new FairGenericParAsciiFileIo((static_cast(io))->getFile()); - io->setDetParIo(pn); - } - // else if(strcmp(ioName,"FairParTSQLIo") == 0) { - // std::cout << "\n\n\n\t TSQL versie is called en nu de rest \n\n"; - // FairDetParTSQLIo* pn = new FairGenericParTSQLIo(); - // io->setDetParIo(pn); - //} - } TIter next(&contFactories); FairContFact* fact; while ((fact = static_cast(next()))) { diff --git a/parbase/FairRuntimeDb.h b/fairroot/parbase/FairRuntimeDb.h similarity index 78% rename from parbase/FairRuntimeDb.h rename to fairroot/parbase/FairRuntimeDb.h index 5373a9e988..2809d89fd0 100644 --- a/parbase/FairRuntimeDb.h +++ b/fairroot/parbase/FairRuntimeDb.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -14,13 +14,10 @@ #include // for TString class FairContFact; -class FairLogger; class FairParIo; class FairParSet; class FairRtdbRun; -static TList contFactories; //! list of container factories - /** * \ingroup parbase * @@ -32,7 +29,7 @@ class FairRuntimeDb : public TObject static FairRuntimeDb* gRtdb; //! protected: - FairRuntimeDb(void); + FairRuntimeDb(); TList* containerList; // list of parameter containers TList* runs; // list of runs FairParIo* firstInput; // first (prefered) input for parameters @@ -42,8 +39,6 @@ class FairRuntimeDb : public TObject TString currentFileName; // Name of current event file Bool_t versionsChanged; // flag for write of list of runs (set kTRUE by each write) Bool_t isRootFileOutput; // flag indicating that the output is a ROOT file - /** Fair Logger */ - FairLogger* fLogger; //! /** * Select which IO type to use. @@ -58,7 +53,7 @@ class FairRuntimeDb : public TObject ParamIOType ioType; // IO Type public: - static FairRuntimeDb* instance(void); + static FairRuntimeDb* instance(); ~FairRuntimeDb() override; Bool_t addParamContext(const char*); @@ -72,50 +67,51 @@ class FairRuntimeDb : public TObject FairParSet* findContainer(const char*); void removeContainer(const char*); void removeAllContainers(); - Bool_t initContainers(UInt_t runId, Int_t refId = -1, const Text_t* fileName = ""); + [[nodiscard]] bool initContainers(UInt_t runId, Int_t refId = -1, const char* fileName = ""); void setContainersStatic(Bool_t f = kTRUE); - Bool_t writeContainers(void); + Bool_t writeContainers(); Bool_t writeContainer(FairParSet*, FairRtdbRun*, FairRtdbRun* refRun = 0); FairRtdbRun* addRun(Int_t runId, Int_t refId = -1); FairRtdbRun* getRun(Int_t); FairRtdbRun* getRun(const char*); - FairRtdbRun* getCurrentRun(void) { return currentRun; } + FairRtdbRun* getCurrentRun() { return currentRun; } Text_t const* getCurrentFileName() { return currentFileName.Data(); } - void clearRunList(void); + void clearRunList(); void removeRun(Text_t*); Bool_t setInputVersion(Int_t run, Text_t* container, Int_t version, Int_t inputNumber); Bool_t setRootOutputVersion(Int_t run, Text_t* container, Int_t version); void setVersionsChanged(Bool_t f = kTRUE) { versionsChanged = f; } - void resetInputVersions(void); - void resetOutputVersions(void); - void resetAllVersions(void); + void resetInputVersions(); + void resetOutputVersions(); + void resetAllVersions(); - Bool_t readAll(void); - void writeVersions(void); - void saveOutput(void); + Bool_t readAll(); + void writeVersions(); + void saveOutput(); Bool_t setFirstInput(FairParIo*); Bool_t setSecondInput(FairParIo*); Bool_t setOutput(FairParIo*); - FairParIo* getFirstInput(void); - FairParIo* getSecondInput(void); - FairParIo* getOutput(void); - void closeFirstInput(void); - void closeSecondInput(void); - void closeOutput(void); + FairParIo* getFirstInput(); + FairParIo* getSecondInput(); + FairParIo* getOutput(); + void closeFirstInput(); + void closeSecondInput(); + void closeOutput(); void activateParIo(FairParIo*); TList* getListOfContainers() { return containerList; } - void print(void); + void print(); + void ls(Option_t* option = "") const override; Int_t findOutputVersion(FairParSet*); private: FairRuntimeDb(const FairRuntimeDb& M); FairRuntimeDb& operator=(const FairRuntimeDb&) { return *this; } - Bool_t initContainers(void); + Bool_t initContainers(); ClassDefOverride(FairRuntimeDb, 0); // Class for runtime database }; diff --git a/parbase/LinkDef.h b/fairroot/parbase/LinkDef.h similarity index 100% rename from parbase/LinkDef.h rename to fairroot/parbase/LinkDef.h diff --git a/parbase/README.dox b/fairroot/parbase/README.dox similarity index 100% rename from parbase/README.dox rename to fairroot/parbase/README.dox diff --git a/parmq/CMakeLists.txt b/fairroot/parmq/CMakeLists.txt similarity index 89% rename from parmq/CMakeLists.txt rename to fairroot/parmq/CMakeLists.txt index 4854f62f6c..a984ca29ff 100644 --- a/parmq/CMakeLists.txt +++ b/fairroot/parmq/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -22,11 +22,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairRoot::FairMQ diff --git a/parmq/ParameterMQServer.cxx b/fairroot/parmq/ParameterMQServer.cxx similarity index 93% rename from parmq/ParameterMQServer.cxx rename to fairroot/parmq/ParameterMQServer.cxx index 9c7cfd2bee..d011e22598 100644 --- a/parmq/ParameterMQServer.cxx +++ b/fairroot/parmq/ParameterMQServer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -64,8 +64,8 @@ void ParameterMQServer::InitTask() fOutputName = fConfig->GetValue("output-name"); fOutputType = fConfig->GetValue("output-type"); - if (::getenv("DDS_SESSION_ID")) { - std::string ddsSessionId = ::getenv("DDS_SESSION_ID"); + if (const char* dds_session_env = ::getenv("DDS_SESSION_ID")) { + std::string ddsSessionId{dds_session_env}; if (fOutputName.length() > 5) { ddsSessionId = "." + ddsSessionId + ".root"; fOutputName.replace(fOutputName.length() - 5, 5, ddsSessionId.c_str()); @@ -134,7 +134,10 @@ bool ParameterMQServer::ProcessRequest(fair::mq::MessagePtr& req, int /*index*/) parameterName = newParameterName; par = static_cast(fRtdb->getContainer(parameterName.c_str())); } - fRtdb->initContainers(runId); + if (!fRtdb->initContainers(runId)) { + LOG(error) << "ParameterMQServer::ProcessRequest: fRtdb->initContainers failed"; + return false; + } LOG(info) << "Sending following parameter to the client:"; if (par) { @@ -192,7 +195,10 @@ bool ParameterMQServer::ProcessUpdate(fair::mq::MessagePtr& update, int /*index* parDescr.erase(0, parDescr.find("RUNID") + 5); } } - fRtdb->initContainers(runId); + if (!fRtdb->initContainers(runId)) { + LOG(error) << "ParameterMQServer::ProcessRequest: fRtdb->initContainers failed"; + return false; + } newPar->setChanged(true); // trigger writing to file newPar->setStatic(true); // to get rid of error diff --git a/parmq/ParameterMQServer.h b/fairroot/parmq/ParameterMQServer.h similarity index 100% rename from parmq/ParameterMQServer.h rename to fairroot/parmq/ParameterMQServer.h diff --git a/parmq/README.md b/fairroot/parmq/README.md similarity index 100% rename from parmq/README.md rename to fairroot/parmq/README.md diff --git a/parmq/runParameterMQServer.cxx b/fairroot/parmq/runParameterMQServer.cxx similarity index 100% rename from parmq/runParameterMQServer.cxx rename to fairroot/parmq/runParameterMQServer.cxx diff --git a/fairtools/CMakeLists.txt b/fairroot/tools/CMakeLists.txt similarity index 81% rename from fairtools/CMakeLists.txt rename to fairroot/tools/CMakeLists.txt index 440f406ff4..541009eb7c 100644 --- a/fairtools/CMakeLists.txt +++ b/fairroot/tools/CMakeLists.txt @@ -6,14 +6,12 @@ # copied verbatim in the file "LICENSE" # ################################################################################ -add_subdirectory(MCStepLogger) - -if(Geant3_FOUND AND Geant4VMC_FOUND AND yaml-cpp_FOUND) - add_subdirectory(MCConfigurator) -endif() - set(target Tools) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/FairVersion.h.in ${CMAKE_BINARY_DIR}/FairVersion.h @ONLY) +list(APPEND extra_headers + ${CMAKE_BINARY_DIR}/FairVersion.h) + set(sources FairLogger.cxx FairMonitor.cxx @@ -22,6 +20,10 @@ set(sources fair_change_extensions_if_exists(.cxx .h FILES "${sources}" OUTVAR headers) +list(APPEND headers + FairMemory.h +) + add_library(${target} SHARED ${sources} ${headers}) fairroot_library_settings(${target}) # Keep old filesystem name @@ -32,11 +34,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC FairLogger::FairLogger @@ -57,4 +54,6 @@ fairroot_target_root_dictionary(${target} ) fairroot_install_exported(TARGETS ${target}) -install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${headers} ${extra_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +add_subdirectory(tests) diff --git a/fairtools/FairLogger.cxx b/fairroot/tools/FairLogger.cxx similarity index 98% rename from fairtools/FairLogger.cxx rename to fairroot/tools/FairLogger.cxx index 8322c3d85d..3caa8ef357 100644 --- a/fairtools/FairLogger.cxx +++ b/fairroot/tools/FairLogger.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -200,5 +200,3 @@ void FairLogger::LogFatalMessage() throw fair::FatalException("Fatal error occured. Exiting..."); } - -ClassImp(FairLogger); diff --git a/fairtools/FairLogger.h b/fairroot/tools/FairLogger.h similarity index 100% rename from fairtools/FairLogger.h rename to fairroot/tools/FairLogger.h diff --git a/fairroot/tools/FairMemory.h b/fairroot/tools/FairMemory.h new file mode 100644 index 0000000000..d20b310a2b --- /dev/null +++ b/fairroot/tools/FairMemory.h @@ -0,0 +1,75 @@ +/******************************************************************************** + * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIRROOT_MEMORY_H_ +#define FAIRROOT_MEMORY_H_ + +#include +#include + +/** + * \brief Internal implementation details + * + * Any declarations in here are strictly for internal usage. + * They may never enter public APIs. + * + * \note Anything in here can change at any time without notice! + */ +namespace fairroot::detail +{ + +template> +struct optional_deleter +{ + std::optional deleter{std::in_place}; + + optional_deleter() = default; + optional_deleter(const Deleter& x) + : deleter(std::in_place, x) + {} + optional_deleter(std::nullopt_t) + : deleter() + {} + + void operator()(T* ptr) const + { + if (deleter) { + (*deleter)(ptr); + } + } +}; + +/** + * \brief unique_ptr that alternatively can hold a reference + * + * In rare cases we need a unique_ptr that can alternatively + * contain a reference (and thus not delete its content + * on destruction). + * + * The default is an owning pointer, so that it can be used + * just like a plain std::unique_ptr. It should be trivial to + * switch to a plain one later, if the non-owning part is not + * used any longer. + * + * \note Think twice before using this! + * + * It's mostly meant for cases, where FairRoot has a public API + * that enforces this behaviour. This should be deprecated and + * removed sooner than later. + * + * \note Avoid `reset(T*)` as it does not change the Deleter's setting + * and thus can have surprising effects. + */ +template> +using maybe_owning_ptr = std::unique_ptr>; + +inline constexpr auto non_owning = std::nullopt; + +} // namespace fairroot::detail + +#endif diff --git a/fairtools/FairMonitor.cxx b/fairroot/tools/FairMonitor.cxx similarity index 99% rename from fairtools/FairMonitor.cxx rename to fairroot/tools/FairMonitor.cxx index 07c4a6a49f..5a16707a9b 100644 --- a/fairtools/FairMonitor.cxx +++ b/fairroot/tools/FairMonitor.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -745,5 +745,3 @@ void FairMonitor::AnalyzeObjectMap(TTask* tempTask) AnalyzeObjectMap(subTask); } } - -ClassImp(FairMonitor); diff --git a/fairtools/FairMonitor.h b/fairroot/tools/FairMonitor.h similarity index 100% rename from fairtools/FairMonitor.h rename to fairroot/tools/FairMonitor.h diff --git a/fairtools/FairSystemInfo.cxx b/fairroot/tools/FairSystemInfo.cxx similarity index 95% rename from fairtools/FairSystemInfo.cxx rename to fairroot/tools/FairSystemInfo.cxx index c8fa41fc39..736e46d6ef 100644 --- a/fairtools/FairSystemInfo.cxx +++ b/fairroot/tools/FairSystemInfo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -62,8 +62,8 @@ size_t FairSystemInfo::GetCurrentMemory() /* Linux ---------------------------------------------------- */ unsigned long rss = 0L; unsigned long pagesize = static_cast(sysconf(_SC_PAGESIZE)); - FILE* fp = NULL; - if ((fp = fopen("/proc/self/statm", "r")) == NULL) + FILE* fp = fopen("/proc/self/statm", "r"); + if (!fp) return (size_t)0L; /* Can't open? */ if (fscanf(fp, "%*s%ld", &rss) != 1) { fclose(fp); diff --git a/fairtools/FairSystemInfo.h b/fairroot/tools/FairSystemInfo.h similarity index 84% rename from fairtools/FairSystemInfo.h rename to fairroot/tools/FairSystemInfo.h index f0c590238a..7b187c4479 100644 --- a/fairtools/FairSystemInfo.h +++ b/fairroot/tools/FairSystemInfo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +22,8 @@ class FairSystemInfo { public: - FairSystemInfo() {} - virtual ~FairSystemInfo() {} + FairSystemInfo() = default; + virtual ~FairSystemInfo() = default; Float_t GetMaxMemory(); size_t GetCurrentMemory(); diff --git a/cmake/scripts/FairVersion.h.default b/fairroot/tools/FairVersion.h.in similarity index 59% rename from cmake/scripts/FairVersion.h.default rename to fairroot/tools/FairVersion.h.in index 76af862fb8..f07f7ddb53 100644 --- a/cmake/scripts/FairVersion.h.default +++ b/fairroot/tools/FairVersion.h.in @@ -1,5 +1,4 @@ #ifndef FAIRROOT_VERSION #define FAIRROOT_VERSION "@PROJECT_VERSION@" -#define FAIRROOT_GIT_DATE "Sun Jan 1 00:00:00 0" +#define FAIRROOT_GIT_VERSION "@PROJECT_GIT_VERSION@" #endif - diff --git a/fairtools/LinkDef.h b/fairroot/tools/LinkDef.h similarity index 100% rename from fairtools/LinkDef.h rename to fairroot/tools/LinkDef.h diff --git a/fairtools/README.dox b/fairroot/tools/README.dox similarity index 100% rename from fairtools/README.dox rename to fairroot/tools/README.dox diff --git a/fairroot/tools/tests/CMakeLists.txt b/fairroot/tools/tests/CMakeLists.txt new file mode 100644 index 0000000000..2605284f1d --- /dev/null +++ b/fairroot/tools/tests/CMakeLists.txt @@ -0,0 +1,19 @@ +################################################################################ +# Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +set(suite "${target}") +set(exe "${test_prefix}_${suite}") +add_executable(${exe} + maybe_owning.cxx +) +target_link_libraries(${exe} + PRIVATE + FairRoot::Tools + Catch2::Catch2WithMain +) +catch_discover_tests(${exe} TEST_PREFIX "${suite}::") diff --git a/fairroot/tools/tests/maybe_owning.cxx b/fairroot/tools/tests/maybe_owning.cxx new file mode 100644 index 0000000000..a7ba2084c8 --- /dev/null +++ b/fairroot/tools/tests/maybe_owning.cxx @@ -0,0 +1,119 @@ +/******************************************************************************** + * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "FairMemory.h" + +#include +#include + +using fairroot::detail::maybe_owning_ptr; +using fairroot::detail::non_owning; + +struct DestructAnalyzer +{ + unsigned int destructed = 0; + std::set whatwasdestructed; + + struct DestructMe + { + DestructAnalyzer& parent; + char id; + + DestructMe(DestructAnalyzer& p, char aid) + : parent(p) + , id(aid) + {} + ~DestructMe() + { + parent.destructed++; + parent.whatwasdestructed.insert(id); + } + }; + + std::unique_ptr create_one(char aid) { return std::make_unique(*this, aid); } + bool was_destructed(char aid) { return whatwasdestructed.count(aid) == 1; } +}; + +using MaybeOwning = maybe_owning_ptr; + +TEST_CASE("maybe_owning_ptr") +{ + DestructAnalyzer analyzer; + + auto item_a = analyzer.create_one('A'); + + SECTION("DestructAnalyzer") + { + REQUIRE(analyzer.destructed == 0); + item_a.reset(); + REQUIRE(analyzer.destructed == 1); + REQUIRE(analyzer.was_destructed('A')); + } + SECTION("unique_ptr style initialize and go out of scope") + { + { + MaybeOwning other{item_a.release()}; + REQUIRE(!item_a); + REQUIRE(other); + REQUIRE(analyzer.destructed == 0); + } + REQUIRE(analyzer.destructed == 1); + REQUIRE(analyzer.was_destructed('A')); + } + SECTION("Pass ownership and go out of scope") + { + { + MaybeOwning other; + other = std::move(item_a); + REQUIRE(!item_a); + REQUIRE(other); + REQUIRE(analyzer.destructed == 0); + } + REQUIRE(analyzer.destructed == 1); + REQUIRE(analyzer.was_destructed('A')); + } + SECTION("Pass ownership and replace with reference") + { + auto item_b = analyzer.create_one('B'); + { + MaybeOwning other; + other = std::move(item_a); + REQUIRE(!item_a); + REQUIRE(other); + other = MaybeOwning{item_b.get(), non_owning}; + REQUIRE(analyzer.destructed == 1); + REQUIRE(analyzer.was_destructed('A')); + } + REQUIRE(analyzer.destructed == 1); + } + SECTION("Pass a reference and go out of scope") + { + { + MaybeOwning other; + other = MaybeOwning{item_a.get(), non_owning}; + REQUIRE(item_a); + REQUIRE(other); + } + REQUIRE(analyzer.destructed == 0); + REQUIRE(item_a); + } + SECTION("Pass a reference and replace with owning") + { + { + MaybeOwning other; + other = MaybeOwning{item_a.get(), non_owning}; + REQUIRE(item_a); + REQUIRE(other); + other = analyzer.create_one('B'); + REQUIRE(analyzer.destructed == 0); + } + REQUIRE(analyzer.destructed == 1); + REQUIRE(analyzer.was_destructed('B')); + REQUIRE(item_a); + } +} diff --git a/trackbase/CMakeLists.txt b/fairroot/trackbase/CMakeLists.txt similarity index 89% rename from trackbase/CMakeLists.txt rename to fairroot/trackbase/CMakeLists.txt index 30baafb84c..4bd62e8d74 100644 --- a/trackbase/CMakeLists.txt +++ b/fairroot/trackbase/CMakeLists.txt @@ -1,5 +1,5 @@ ################################################################################ -# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -30,11 +30,6 @@ target_include_directories(${target} PUBLIC $ ) -# TODO: DELETE ME ONCE USING root targets -target_include_directories(${target} SYSTEM PUBLIC - ${ROOT_INCLUDE_DIR} -) - target_link_libraries(${target} PUBLIC ROOT::Core diff --git a/trackbase/FairGeaneUtil.cxx b/fairroot/trackbase/FairGeaneUtil.cxx similarity index 99% rename from trackbase/FairGeaneUtil.cxx rename to fairroot/trackbase/FairGeaneUtil.cxx index df4b4ef859..3b820da589 100644 --- a/trackbase/FairGeaneUtil.cxx +++ b/fairroot/trackbase/FairGeaneUtil.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -1917,5 +1917,3 @@ TVector3 FairGeaneUtil::FromSDToMARSCoord(TVector3 uvw, TVector3 o, TVector3 di, return xyz; } - -ClassImp(FairGeaneUtil); diff --git a/trackbase/FairGeaneUtil.h b/fairroot/trackbase/FairGeaneUtil.h similarity index 97% rename from trackbase/FairGeaneUtil.h rename to fairroot/trackbase/FairGeaneUtil.h index 987f703881..84d7338874 100644 --- a/trackbase/FairGeaneUtil.h +++ b/fairroot/trackbase/FairGeaneUtil.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,7 +13,6 @@ #include // for TVector3 class TBuffer; class TClass; -class TMemberInspector; class FairGeaneUtil : public TObject { diff --git a/trackbase/FairPropagator.cxx b/fairroot/trackbase/FairPropagator.cxx similarity index 78% rename from trackbase/FairPropagator.cxx rename to fairroot/trackbase/FairPropagator.cxx index 6b1fde4509..1e9b31ff0a 100644 --- a/trackbase/FairPropagator.cxx +++ b/fairroot/trackbase/FairPropagator.cxx @@ -1,14 +1,12 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ - #include "FairPropagator.h" - #include // for TGenericClassInfo - +#include "FairPropagator.h" FairPropagator::FairPropagator() : TNamed("FairPropagator", "Base class for propagators") @@ -19,5 +17,3 @@ FairPropagator::FairPropagator(const TString& name, const TString& title) {} FairPropagator::~FairPropagator() {} - -ClassImp(FairPropagator); diff --git a/trackbase/FairPropagator.h b/fairroot/trackbase/FairPropagator.h similarity index 98% rename from trackbase/FairPropagator.h rename to fairroot/trackbase/FairPropagator.h index d5ae753a66..c38609252e 100644 --- a/trackbase/FairPropagator.h +++ b/fairroot/trackbase/FairPropagator.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,7 +26,6 @@ class FairTrackParH; // lines 23-23 class FairTrackParP; // lines 24-24 class TBuffer; class TClass; -class TMemberInspector; struct PCAOutputStruct { diff --git a/trackbase/FairRKPropagator.cxx b/fairroot/trackbase/FairRKPropagator.cxx similarity index 99% rename from trackbase/FairRKPropagator.cxx rename to fairroot/trackbase/FairRKPropagator.cxx index 00d9442e99..dd1f29e48f 100644 --- a/trackbase/FairRKPropagator.cxx +++ b/fairroot/trackbase/FairRKPropagator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -23,8 +23,6 @@ #include // for printf #include // for abs -ClassImp(FairRKPropagator); - //______________________________________________________________________________ FairRKPropagator::FairRKPropagator(FairField* field) : FairPropagator("FairRKPropagator", "Runge-Kutta propagator") diff --git a/trackbase/FairRKPropagator.h b/fairroot/trackbase/FairRKPropagator.h similarity index 97% rename from trackbase/FairRKPropagator.h rename to fairroot/trackbase/FairRKPropagator.h index 63b63ae9a7..ca6260d132 100644 --- a/trackbase/FairRKPropagator.h +++ b/fairroot/trackbase/FairRKPropagator.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,7 +24,6 @@ class FairTrackParH; class FairTrackParP; // lines 21-21 class TBuffer; class TClass; -class TMemberInspector; enum PropagationFlag { diff --git a/trackbase/FairTrackPar.cxx b/fairroot/trackbase/FairTrackPar.cxx similarity index 96% rename from trackbase/FairTrackPar.cxx rename to fairroot/trackbase/FairTrackPar.cxx index b428626ecd..8e46689122 100644 --- a/trackbase/FairTrackPar.cxx +++ b/fairroot/trackbase/FairTrackPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -116,5 +116,3 @@ void FairTrackPar::GetFieldValue(const Double_t point[3], Double_t* bField) bField[2] = .0; } } - -ClassImp(FairTrackPar); diff --git a/trackbase/FairTrackPar.h b/fairroot/trackbase/FairTrackPar.h similarity index 97% rename from trackbase/FairTrackPar.h rename to fairroot/trackbase/FairTrackPar.h index 5122092faf..560c30f222 100644 --- a/trackbase/FairTrackPar.h +++ b/fairroot/trackbase/FairTrackPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -13,7 +13,6 @@ #include // for TVector3 class TBuffer; class TClass; -class TMemberInspector; class FairTrackPar : public TObject { diff --git a/trackbase/FairTrackParH.cxx b/fairroot/trackbase/FairTrackParH.cxx similarity index 99% rename from trackbase/FairTrackParH.cxx rename to fairroot/trackbase/FairTrackParH.cxx index a73a781d0d..85acb0170f 100644 --- a/trackbase/FairTrackParH.cxx +++ b/fairroot/trackbase/FairTrackParH.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,8 +28,6 @@ using std::cout; using std::endl; -ClassImp(FairTrackParH); - FairTrackParH::FairTrackParH() : FairTrackPar() , fLm(0.) @@ -182,7 +180,7 @@ FairTrackParH::FairTrackParH(TVector3 pos, TVector3 Mom, TVector3 posErr, TVecto SetY(pos.y()); // y (lab) SetZ(pos.z()); // z (lab) - fq = int(q / TMath::Abs(q)); + fq = q / TMath::Abs(q); Double_t P = TMath::Sqrt(fPx * fPx + fPy * fPy + fPz * fPz); fLm = TMath::ASin(fPz / P); @@ -319,7 +317,7 @@ void FairTrackParH::SetTrackPar(Double_t X, fPhi = TMath::ATan2(Py, Px); if (Q != 0) { - fq = int(TMath::Abs(Q) / Q); + fq = TMath::Abs(Q) / Q; } fQp = fq / P; diff --git a/trackbase/FairTrackParH.h b/fairroot/trackbase/FairTrackParH.h similarity index 98% rename from trackbase/FairTrackParH.h rename to fairroot/trackbase/FairTrackParH.h index 947de947aa..033e192073 100644 --- a/trackbase/FairTrackParH.h +++ b/fairroot/trackbase/FairTrackParH.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,8 +24,6 @@ class FairTrackParP; // lines 25-25 class TBuffer; class TClass; -class TMemberInspector; - class FairTrackParH : public FairTrackPar { diff --git a/trackbase/FairTrackParP.cxx b/fairroot/trackbase/FairTrackParP.cxx similarity index 99% rename from trackbase/FairTrackParP.cxx rename to fairroot/trackbase/FairTrackParP.cxx index e89dee63b9..b03c6fed7b 100644 --- a/trackbase/FairTrackParP.cxx +++ b/fairroot/trackbase/FairTrackParP.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -28,8 +28,6 @@ using std::cout; using std::endl; -ClassImp(FairTrackParP); - FairTrackParP::FairTrackParP() : FairTrackPar() , fU(0.) diff --git a/trackbase/FairTrackParP.h b/fairroot/trackbase/FairTrackParP.h similarity index 98% rename from trackbase/FairTrackParP.h rename to fairroot/trackbase/FairTrackParP.h index 4641ec365c..109b4a5e9d 100644 --- a/trackbase/FairTrackParP.h +++ b/fairroot/trackbase/FairTrackParP.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -24,12 +24,9 @@ class FairTrackParH; // lines 25-25 class TBuffer; class TClass; -class TMemberInspector; - class FairTrackParP : public FairTrackPar { - public: /** Constructor **/ FairTrackParP(); diff --git a/trackbase/LinkDef.h b/fairroot/trackbase/LinkDef.h similarity index 100% rename from trackbase/LinkDef.h rename to fairroot/trackbase/LinkDef.h diff --git a/trackbase/README.dox b/fairroot/trackbase/README.dox similarity index 100% rename from trackbase/README.dox rename to fairroot/trackbase/README.dox diff --git a/parbase/FairParAsciiFileIo.h b/parbase/FairParAsciiFileIo.h deleted file mode 100644 index a48cd0ad49..0000000000 --- a/parbase/FairParAsciiFileIo.h +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * - * * - * This software is distributed under the terms of the * - * GNU Lesser General Public Licence (LGPL) version 3, * - * copied verbatim in the file "LICENSE" * - ********************************************************************************/ -#ifndef FAIRPARASCIFILEIIO_H -#define FAIRPARASCIFILEIIO_H - -#include "FairParIo.h" // for FairParIo - -#include // for Bool_t, Text_t, etc -#include // for fstream, etc - -class TList; - -class FairParAsciiFileIo : public FairParIo -{ - protected: - std::fstream* file; // pointer to a file - - public: - FairParAsciiFileIo(); - - // default destructor closes an open file and deletes list of I/Os - ~FairParAsciiFileIo(); - - // opens file - // if a file is already open, this file will be closed - // activates detector I/Os - Bool_t open(const Text_t* fname, const Text_t* status = "in"); - - // concatenate files whose names are stored in the TList - // TList holds list od TObjStrings - // create file all.par in local working directory - // calls open to open the generated file all.par - Bool_t open(const TList* fnamelist, const Text_t* status = "in"); - - // closes file - void close() override; - - // returns kTRUE if file is open - Bool_t check() override - { - if (file) { - return (file->rdbuf()->is_open() == 1); - } else { - return kFALSE; - } - } - - // prints information about the file and the detector I/Os - void print() override; - - std::fstream* getFile(); - - private: - FairParAsciiFileIo(const FairParAsciiFileIo&); - FairParAsciiFileIo& operator=(const FairParAsciiFileIo&); - - ClassDefOverride(FairParAsciiFileIo, 0); // Parameter I/O from ASCII files -}; - -#endif /* !FAIRPARASCIIFILEIO_H */ diff --git a/templates/NewDetector_root_containers/CMakeLists.txt b/templates/NewDetector_root_containers/CMakeLists.txt index f7c16261f5..abbc4548d6 100644 --- a/templates/NewDetector_root_containers/CMakeLists.txt +++ b/templates/NewDetector_root_containers/CMakeLists.txt @@ -10,7 +10,6 @@ # The extension is already found. Any number of sources could be listed here. set(INCLUDE_DIRECTORIES -${ROOT_INCLUDE_DIR} #put here all directories where header files are located ${BASE_INCLUDE_DIRECTORIES} #${CMAKE_SOURCE_DIR}/ diff --git a/templates/NewDetector_root_containers/NewDetector.cxx b/templates/NewDetector_root_containers/NewDetector.cxx index e667e2cef0..2cad86e1ba 100644 --- a/templates/NewDetector_root_containers/NewDetector.cxx +++ b/templates/NewDetector_root_containers/NewDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -81,8 +81,6 @@ void NewDetector::Initialize() { /** * WORKAROUND needed for Geant4 in MT mode - * Call AddSensitiveVolume for sensitive volumes in order to fill - * thread-local FairModule::svList. */ DefineSensitiveVolumes(); @@ -256,5 +254,3 @@ Bool_t NewDetector::IsSensitive(const std::string& name) } return kFALSE; } - -ClassImp(NewDetector); diff --git a/templates/NewDetector_root_containers/NewDetectorContFact.cxx b/templates/NewDetector_root_containers/NewDetectorContFact.cxx index 49cfdd7ebc..00d266362e 100644 --- a/templates/NewDetector_root_containers/NewDetectorContFact.cxx +++ b/templates/NewDetector_root_containers/NewDetectorContFact.cxx @@ -11,8 +11,6 @@ #include -ClassImp(NewDetectorContFact); - static NewDetectorContFact gNewDetectorContFact; NewDetectorContFact::NewDetectorContFact() diff --git a/templates/NewDetector_root_containers/NewDetectorContFact.h b/templates/NewDetector_root_containers/NewDetectorContFact.h index 2332115ce7..adb2fbac85 100644 --- a/templates/NewDetector_root_containers/NewDetectorContFact.h +++ b/templates/NewDetector_root_containers/NewDetectorContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,15 +10,13 @@ #include "FairContFact.h" -class FairContainer; - class NewDetectorContFact : public FairContFact { public: NewDetectorContFact(); - ~NewDetectorContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers + ~NewDetectorContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers }; #endif diff --git a/templates/NewDetector_root_containers/NewDetectorGeo.cxx b/templates/NewDetector_root_containers/NewDetectorGeo.cxx index 6be8463ab2..c88e424d9c 100644 --- a/templates/NewDetector_root_containers/NewDetectorGeo.cxx +++ b/templates/NewDetector_root_containers/NewDetectorGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,21 +9,10 @@ #include "FairGeoNode.h" -ClassImp(NewDetectorGeo); - // ----- Default constructor ------------------------------------------- NewDetectorGeo::NewDetectorGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "newdetector"; - strcpy(modName, "NewDetector"); - strcpy(eleName, "NewDetector"); - maxSectors = 0; - maxModules = 10; -} + : FairGeoSet("newdetector", 10) +{} // ------------------------------------------------------------------------- diff --git a/templates/NewDetector_root_containers/NewDetectorGeo.h b/templates/NewDetector_root_containers/NewDetectorGeo.h index 40149293a1..b040b7749b 100644 --- a/templates/NewDetector_root_containers/NewDetectorGeo.h +++ b/templates/NewDetector_root_containers/NewDetectorGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,16 @@ class NewDetectorGeo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module + char modName[20]{"NewDetector"}; // name of module + char eleName[20]{"NewDetector"}; // substring for elements in module public: NewDetectorGeo(); - ~NewDetectorGeo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(NewDetectorGeo, 1); + ~NewDetectorGeo() override = default; + const char* getModuleName(Int_t) override; + const char* getEleName(Int_t) override; + inline Int_t getModNumInMod(const TString&) override; + ClassDefOverride(NewDetectorGeo, 1); }; inline Int_t NewDetectorGeo::getModNumInMod(const TString& name) diff --git a/templates/NewDetector_root_containers/NewDetectorGeoPar.cxx b/templates/NewDetector_root_containers/NewDetectorGeoPar.cxx index a40fd67e7f..e77971e4fd 100644 --- a/templates/NewDetector_root_containers/NewDetectorGeoPar.cxx +++ b/templates/NewDetector_root_containers/NewDetectorGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,15 @@ #include #include -ClassImp(NewDetectorGeoPar); - NewDetectorGeoPar ::NewDetectorGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -NewDetectorGeoPar::~NewDetectorGeoPar(void) {} +NewDetectorGeoPar::~NewDetectorGeoPar() {} -void NewDetectorGeoPar::clear(void) +void NewDetectorGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/templates/NewDetector_root_containers/NewDetectorGeoPar.h b/templates/NewDetector_root_containers/NewDetectorGeoPar.h index 4ace7ba933..f16d1603fd 100644 --- a/templates/NewDetector_root_containers/NewDetectorGeoPar.h +++ b/templates/NewDetector_root_containers/NewDetectorGeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,8 @@ class NewDetectorGeoPar : public FairParGenericSet NewDetectorGeoPar(const char* name = "NewDetectorGeoPar", const char* title = "NewDetector Geometry Parameters", const char* context = "TestDefaultContext"); - ~NewDetectorGeoPar(void); - void clear(void); + ~NewDetectorGeoPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/templates/NewDetector_root_containers/NewDetectorPoint.cxx b/templates/NewDetector_root_containers/NewDetectorPoint.cxx index 7a74f497b7..83a0b03783 100644 --- a/templates/NewDetector_root_containers/NewDetectorPoint.cxx +++ b/templates/NewDetector_root_containers/NewDetectorPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -43,5 +43,3 @@ void NewDetectorPoint::Print(const Option_t* /*opt*/) const << endl; } // ------------------------------------------------------------------------- - -ClassImp(NewDetectorPoint); diff --git a/templates/NewDetector_stl_containers/CMakeLists.txt b/templates/NewDetector_stl_containers/CMakeLists.txt index 462e4dad0e..a1be484f64 100644 --- a/templates/NewDetector_stl_containers/CMakeLists.txt +++ b/templates/NewDetector_stl_containers/CMakeLists.txt @@ -10,7 +10,6 @@ # The extension is already found. Any number of sources could be listed here. set(INCLUDE_DIRECTORIES -${ROOT_INCLUDE_DIR} #put here all directories where header files are located ${BASE_INCLUDE_DIRECTORIES} #${CMAKE_SOURCE_DIR}/ diff --git a/templates/NewDetector_stl_containers/NewDetector.cxx b/templates/NewDetector_stl_containers/NewDetector.cxx index 03a14a34f4..19d3ad6cba 100644 --- a/templates/NewDetector_stl_containers/NewDetector.cxx +++ b/templates/NewDetector_stl_containers/NewDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -80,8 +80,6 @@ void NewDetector::Initialize() { /** * WORKAROUND needed for Geant4 in MT mode - * Call AddSensitiveVolume for sensitive volumes in order to fill - * thread-local FairModule::svList. */ DefineSensitiveVolumes(); @@ -248,5 +246,3 @@ Bool_t NewDetector::IsSensitive(const std::string& name) } return kFALSE; } - -ClassImp(NewDetector); diff --git a/templates/NewDetector_stl_containers/NewDetectorContFact.cxx b/templates/NewDetector_stl_containers/NewDetectorContFact.cxx index 49cfdd7ebc..00d266362e 100644 --- a/templates/NewDetector_stl_containers/NewDetectorContFact.cxx +++ b/templates/NewDetector_stl_containers/NewDetectorContFact.cxx @@ -11,8 +11,6 @@ #include -ClassImp(NewDetectorContFact); - static NewDetectorContFact gNewDetectorContFact; NewDetectorContFact::NewDetectorContFact() diff --git a/templates/NewDetector_stl_containers/NewDetectorContFact.h b/templates/NewDetector_stl_containers/NewDetectorContFact.h index 2332115ce7..adb2fbac85 100644 --- a/templates/NewDetector_stl_containers/NewDetectorContFact.h +++ b/templates/NewDetector_stl_containers/NewDetectorContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,15 +10,13 @@ #include "FairContFact.h" -class FairContainer; - class NewDetectorContFact : public FairContFact { public: NewDetectorContFact(); - ~NewDetectorContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers + ~NewDetectorContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers }; #endif diff --git a/templates/NewDetector_stl_containers/NewDetectorGeo.cxx b/templates/NewDetector_stl_containers/NewDetectorGeo.cxx index 6be8463ab2..c88e424d9c 100644 --- a/templates/NewDetector_stl_containers/NewDetectorGeo.cxx +++ b/templates/NewDetector_stl_containers/NewDetectorGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,21 +9,10 @@ #include "FairGeoNode.h" -ClassImp(NewDetectorGeo); - // ----- Default constructor ------------------------------------------- NewDetectorGeo::NewDetectorGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "newdetector"; - strcpy(modName, "NewDetector"); - strcpy(eleName, "NewDetector"); - maxSectors = 0; - maxModules = 10; -} + : FairGeoSet("newdetector", 10) +{} // ------------------------------------------------------------------------- diff --git a/templates/NewDetector_stl_containers/NewDetectorGeo.h b/templates/NewDetector_stl_containers/NewDetectorGeo.h index 40149293a1..b040b7749b 100644 --- a/templates/NewDetector_stl_containers/NewDetectorGeo.h +++ b/templates/NewDetector_stl_containers/NewDetectorGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,16 @@ class NewDetectorGeo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module + char modName[20]{"NewDetector"}; // name of module + char eleName[20]{"NewDetector"}; // substring for elements in module public: NewDetectorGeo(); - ~NewDetectorGeo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(NewDetectorGeo, 1); + ~NewDetectorGeo() override = default; + const char* getModuleName(Int_t) override; + const char* getEleName(Int_t) override; + inline Int_t getModNumInMod(const TString&) override; + ClassDefOverride(NewDetectorGeo, 1); }; inline Int_t NewDetectorGeo::getModNumInMod(const TString& name) diff --git a/templates/NewDetector_stl_containers/NewDetectorGeoPar.cxx b/templates/NewDetector_stl_containers/NewDetectorGeoPar.cxx index a40fd67e7f..e77971e4fd 100644 --- a/templates/NewDetector_stl_containers/NewDetectorGeoPar.cxx +++ b/templates/NewDetector_stl_containers/NewDetectorGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,15 @@ #include #include -ClassImp(NewDetectorGeoPar); - NewDetectorGeoPar ::NewDetectorGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -NewDetectorGeoPar::~NewDetectorGeoPar(void) {} +NewDetectorGeoPar::~NewDetectorGeoPar() {} -void NewDetectorGeoPar::clear(void) +void NewDetectorGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/templates/NewDetector_stl_containers/NewDetectorGeoPar.h b/templates/NewDetector_stl_containers/NewDetectorGeoPar.h index 4ace7ba933..f16d1603fd 100644 --- a/templates/NewDetector_stl_containers/NewDetectorGeoPar.h +++ b/templates/NewDetector_stl_containers/NewDetectorGeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,8 @@ class NewDetectorGeoPar : public FairParGenericSet NewDetectorGeoPar(const char* name = "NewDetectorGeoPar", const char* title = "NewDetector Geometry Parameters", const char* context = "TestDefaultContext"); - ~NewDetectorGeoPar(void); - void clear(void); + ~NewDetectorGeoPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/templates/NewDetector_stl_containers/NewDetectorPoint.cxx b/templates/NewDetector_stl_containers/NewDetectorPoint.cxx index 1dcc74ad5a..4428c971b4 100644 --- a/templates/NewDetector_stl_containers/NewDetectorPoint.cxx +++ b/templates/NewDetector_stl_containers/NewDetectorPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -66,5 +66,3 @@ void NewDetectorPoint::Print(const Option_t* /*opt*/) const << endl; } // ------------------------------------------------------------------------- - -ClassImp(NewDetectorPoint); diff --git a/templates/NewParameterContainer/NewParameterContainer.cxx b/templates/NewParameterContainer/NewParameterContainer.cxx index 13c4cef9a5..718bac50a1 100644 --- a/templates/NewParameterContainer/NewParameterContainer.cxx +++ b/templates/NewParameterContainer/NewParameterContainer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -11,15 +11,13 @@ #include -ClassImp(NewParameterContainer); - NewParameterContainer ::NewParameterContainer(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) {} -NewParameterContainer::~NewParameterContainer(void) {} +NewParameterContainer::~NewParameterContainer() {} -void NewParameterContainer::clear(void) {} +void NewParameterContainer::clear() {} void NewParameterContainer::putParams(FairParamList* l) { diff --git a/templates/NewParameterContainer/NewParameterContainer.h b/templates/NewParameterContainer/NewParameterContainer.h index fae7c1e771..8c0ce7d692 100644 --- a/templates/NewParameterContainer/NewParameterContainer.h +++ b/templates/NewParameterContainer/NewParameterContainer.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,8 +18,8 @@ class NewParameterContainer : public FairParGenericSet NewParameterContainer(const char* name = "NewParameterContainer", const char* title = "NewParameterContainer Parameters", const char* context = "TestDefaultContext"); - ~NewParameterContainer(void); - void clear(void); + ~NewParameterContainer(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); diff --git a/templates/NewTask/NewTask.cxx b/templates/NewTask/NewTask.cxx index 0eb0420404..37ea91de3a 100644 --- a/templates/NewTask/NewTask.cxx +++ b/templates/NewTask/NewTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -7,6 +7,9 @@ ********************************************************************************/ #include "NewTask.h" +#include +#include + // ---- Default constructor ------------------------------------------- NewTask::NewTask() : FairTask("NewTask") @@ -43,7 +46,7 @@ InitStatus NewTask::Init() /* = (TClonesArray*) ioman->GetObject("InputDataLevelName"); if ( ! ) { - fLogger->Error(MESSAGE_ORIGIN,"No InputDataLevelName array!\n NewTask will be inactive"); + LOG(error) << "No InputDataLevelName array!\n NewTask will be inactive"; return kERROR; } */ @@ -73,6 +76,7 @@ InitStatus NewTask::ReInit() void NewTask::Exec(Option_t* /*option*/) { LOG(debug) << "Exec of NewTask"; } // ---- Finish -------------------------------------------------------- -void NewTask::Finish() { LOG(debug) << "Finish of NewTask"; } - -ClassImp(NewTask); +void NewTask::Finish() +{ + LOG(debug) << "Finish of NewTask"; +} diff --git a/templates/TimeBased/MyRingSorter.cxx b/templates/TimeBased/MyRingSorter.cxx index c4ced3443a..63535ee9d9 100644 --- a/templates/TimeBased/MyRingSorter.cxx +++ b/templates/TimeBased/MyRingSorter.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -18,6 +18,7 @@ MyRingSorter::~MyRingSorter() {} -FairTimeStamp* MyRingSorter::CreateElement(FairTimeStamp* data) { return new MyDataClass(*(MyDataClass*)data); } - -ClassImp(MyRingSorter); +FairTimeStamp* MyRingSorter::CreateElement(FairTimeStamp* data) +{ + return new MyDataClass(*(MyDataClass*)data); +} diff --git a/templates/TimeBased/MySorterTask.cxx b/templates/TimeBased/MySorterTask.cxx index 1578ab654c..d05ab77d2b 100644 --- a/templates/TimeBased/MySorterTask.cxx +++ b/templates/TimeBased/MySorterTask.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -38,5 +38,3 @@ FairRingSorter* MySorterTask::InitSorter(Int_t numberOfCells, Double_t widthOfCe { return new MyRingSorter(numberOfCells, widthOfCells); } - -ClassImp(MySorterTask); diff --git a/templates/TimeBased/MyWriteoutBuffer.cxx b/templates/TimeBased/MyWriteoutBuffer.cxx index c62f7e61ba..e06121076b 100644 --- a/templates/TimeBased/MyWriteoutBuffer.cxx +++ b/templates/TimeBased/MyWriteoutBuffer.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -84,5 +84,3 @@ void MyWriteoutBuffer::EraseDataFromDataMap(FairTimeStamp* data) fData_map.erase(fData_map.find(myData)); } } - -ClassImp(MyWriteoutBuffer); diff --git a/templates/project_root_containers/CMakeLists.txt b/templates/project_root_containers/CMakeLists.txt index b091107521..fedbcb5817 100644 --- a/templates/project_root_containers/CMakeLists.txt +++ b/templates/project_root_containers/CMakeLists.txt @@ -27,10 +27,16 @@ SET(FAIRROOTPATH $ENV{FAIRROOTPATH}) # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ # is checked set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules" ${CMAKE_MODULE_PATH}) - set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules_old" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) +if(SIMPATH) + set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH}) +endif() + +find_package(FairCMakeModules 0.2 QUIET REQUIRED) +include(FairFindPackage2) +include(FairSummary) -find_package(FairRoot REQUIRED) +find_package2(PUBLIC FairRoot VERSION 19.0 REQUIRED) # Load some basic macros which are needed later on include(FairMacros) @@ -69,12 +75,12 @@ ENDIF(NOT UNIX) # mandatory if(SIMPATH) - set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH}) set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${SIMPATH}/lib) endif() find_package2(PUBLIC ROOT REQUIRED) include(ROOTMacros) +fairroot_check_root_cxxstd_compatibility() if(ROOT_vmc_FOUND) set(VMCLIB ROOT::VMC) else() @@ -82,19 +88,13 @@ else() set(VMCLIB VMCLibrary) endif() find_package2(PUBLIC FairLogger VERSION 1.2.0 REQUIRED) -foreach(dep IN LISTS FairLogger_PACKAGE_DEPENDENCIES) - if(NOT dep STREQUAL "Boost") - find_package2(PUBLIC ${dep} REQUIRED VERSION ${FairLogger_${dep}_VERSION}) - set(PROJECT_${dep}_VERSION ${FairLogger_${dep}_VERSION}) - endif() -endforeach() find_package2(PUBLIC Pythia6) find_package2(PUBLIC Pythia8) find_package2(PUBLIC Geant3) find_package2(PUBLIC Geant4) Find_Package2(PUBLIC VGM) find_package2(PUBLIC Geant4VMC) -find_package(HEPMC) +find_package2(PUBLIC HEPMC) if(NOT DEFINED Boost_NO_SYSTEM_PATHS) Set(Boost_NO_SYSTEM_PATHS TRUE) @@ -114,7 +114,6 @@ endif() find_package2(PUBLIC Boost VERSION 1.67 - ADD_REQUIREMENTS_OF FairRoot FairMQ FairLogger ) If (Boost_FOUND) @@ -123,6 +122,8 @@ Else (Boost_FOUND) Set(Boost_Avail 0) EndIf (Boost_FOUND) +find_package2_implicit_dependencies() + # set a variable which should be used in all CMakeLists.txt # Defines all basic include directories from fairbase SetBasicVariables() @@ -151,28 +152,8 @@ configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake ) # Summary ###################################################################### -if(CMAKE_CXX_FLAGS) - message(STATUS " ") - message(STATUS " ${Cyan}GLOBAL CXX FLAGS${CR} ${BGreen}${CMAKE_CXX_FLAGS}${CR}") -endif() -if(CMAKE_CONFIGURATION_TYPES) - message(STATUS " ") - message(STATUS " ${Cyan}BUILD TYPE CXX FLAGS${CR}") - string(TOUPPER "${CMAKE_BUILD_TYPE}" selected_type) - foreach(type IN LISTS CMAKE_CONFIGURATION_TYPES) - string(TOUPPER "${type}" type_upper) - if(type_upper STREQUAL selected_type) - pad("${type}" 18 " " type_padded) - message(STATUS "${BGreen}* ${type_padded}${CMAKE_CXX_FLAGS_${type_upper}}${CR}") - else() - pad("${type}" 18 " " type_padded) - message(STATUS " ${BWhite}${type_padded}${CR}${CMAKE_CXX_FLAGS_${type_upper}}") - endif() - unset(type_padded) - unset(type_upper) - endforeach() -message(STATUS " ") -message(STATUS " (Change the build type with ${BMagenta}-DCMAKE_BUILD_TYPE=...${CR})") -endif() +fair_summary_global_cxx_flags_standard() +fair_summary_build_types() +fair_summary_package_dependencies() ################################################################################ diff --git a/templates/project_root_containers/CTestCustom.cmake b/templates/project_root_containers/CTestCustom.cmake index 8440f90b34..23ab2e0d6d 100644 --- a/templates/project_root_containers/CTestCustom.cmake +++ b/templates/project_root_containers/CTestCustom.cmake @@ -1,5 +1,5 @@ ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -81,7 +81,6 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "/include/TMap.h:" "/include/TMatrixT.h:" "/include/TMatrixTSym.h:" - "/include/TMemberInspector.h:" "/include/TObjArray.h:" "/include/TRefArray.h:" "/include/TString.h:" @@ -134,4 +133,4 @@ Set (CTEST_CUSTOM_COVERAGE_EXCLUDE Set(CTEST_CUSTOM_ERROR_EXCEPTION ${CTEST_CUSTOM_ERROR_EXCEPTION} "/include/boost/" -) \ No newline at end of file +) diff --git a/templates/project_root_containers/MyProjData/MyProjMCTrack.cxx b/templates/project_root_containers/MyProjData/MyProjMCTrack.cxx index 31835c7658..d330f89bc8 100644 --- a/templates/project_root_containers/MyProjData/MyProjMCTrack.cxx +++ b/templates/project_root_containers/MyProjData/MyProjMCTrack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -177,5 +177,3 @@ void MyProjMCTrack::SetNPoints(Int_t iDet, Int_t nPoints) */ } // ------------------------------------------------------------------------- - -ClassImp(MyProjMCTrack); diff --git a/templates/project_root_containers/MyProjData/MyProjStack.cxx b/templates/project_root_containers/MyProjData/MyProjStack.cxx index cabff5698d..9f6ac9daf1 100644 --- a/templates/project_root_containers/MyProjData/MyProjStack.cxx +++ b/templates/project_root_containers/MyProjData/MyProjStack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -494,5 +494,3 @@ void MyProjStack::SelectTracks() } } // ------------------------------------------------------------------------- - -ClassImp(MyProjStack); diff --git a/templates/project_root_containers/MyProjGenerators/Pythia6Generator.cxx b/templates/project_root_containers/MyProjGenerators/Pythia6Generator.cxx index 112a56cf70..d2d81672fe 100644 --- a/templates/project_root_containers/MyProjGenerators/Pythia6Generator.cxx +++ b/templates/project_root_containers/MyProjGenerators/Pythia6Generator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -142,5 +142,3 @@ void Pythia6Generator::CloseInput() } } // ------------------------------------------------------------------------ - -ClassImp(Pythia6Generator); diff --git a/templates/project_root_containers/MyProjGenerators/Pythia8Generator.cxx b/templates/project_root_containers/MyProjGenerators/Pythia8Generator.cxx index c1bf4674bb..e281a9ef41 100644 --- a/templates/project_root_containers/MyProjGenerators/Pythia8Generator.cxx +++ b/templates/project_root_containers/MyProjGenerators/Pythia8Generator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -168,5 +168,3 @@ void Pythia8Generator::GetPythiaInstance(int arg) cout << "canDecay " << fPythia.particleData.canDecay(arg) << " " << fPythia.particleData.mayDecay(arg) << endl; } // ------------------------------------------------------------------------- - -ClassImp(Pythia8Generator); diff --git a/templates/project_root_containers/NewDetector/NewDetector.cxx b/templates/project_root_containers/NewDetector/NewDetector.cxx index 1454fd5715..1d5189e052 100644 --- a/templates/project_root_containers/NewDetector/NewDetector.cxx +++ b/templates/project_root_containers/NewDetector/NewDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -81,8 +81,6 @@ void NewDetector::Initialize() { /** * WORKAROUND needed for Geant4 in MT mode - * Call AddSensitiveVolume for sensitive volumes in order to fill - * thread-local FairModule::svList. */ DefineSensitiveVolumes(); @@ -257,5 +255,3 @@ Bool_t NewDetector::IsSensitive(const std::string& name) } return kFALSE; } - -ClassImp(NewDetector); diff --git a/templates/project_root_containers/NewDetector/NewDetectorContFact.cxx b/templates/project_root_containers/NewDetector/NewDetectorContFact.cxx index 49cfdd7ebc..00d266362e 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorContFact.cxx +++ b/templates/project_root_containers/NewDetector/NewDetectorContFact.cxx @@ -11,8 +11,6 @@ #include -ClassImp(NewDetectorContFact); - static NewDetectorContFact gNewDetectorContFact; NewDetectorContFact::NewDetectorContFact() diff --git a/templates/project_root_containers/NewDetector/NewDetectorContFact.h b/templates/project_root_containers/NewDetector/NewDetectorContFact.h index 2332115ce7..adb2fbac85 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorContFact.h +++ b/templates/project_root_containers/NewDetector/NewDetectorContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,15 +10,13 @@ #include "FairContFact.h" -class FairContainer; - class NewDetectorContFact : public FairContFact { public: NewDetectorContFact(); - ~NewDetectorContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers + ~NewDetectorContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers }; #endif diff --git a/templates/project_root_containers/NewDetector/NewDetectorGeo.cxx b/templates/project_root_containers/NewDetector/NewDetectorGeo.cxx index 6be8463ab2..c88e424d9c 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorGeo.cxx +++ b/templates/project_root_containers/NewDetector/NewDetectorGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,21 +9,10 @@ #include "FairGeoNode.h" -ClassImp(NewDetectorGeo); - // ----- Default constructor ------------------------------------------- NewDetectorGeo::NewDetectorGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "newdetector"; - strcpy(modName, "NewDetector"); - strcpy(eleName, "NewDetector"); - maxSectors = 0; - maxModules = 10; -} + : FairGeoSet("newdetector", 10) +{} // ------------------------------------------------------------------------- diff --git a/templates/project_root_containers/NewDetector/NewDetectorGeo.h b/templates/project_root_containers/NewDetector/NewDetectorGeo.h index 40149293a1..b040b7749b 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorGeo.h +++ b/templates/project_root_containers/NewDetector/NewDetectorGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,16 @@ class NewDetectorGeo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module + char modName[20]{"NewDetector"}; // name of module + char eleName[20]{"NewDetector"}; // substring for elements in module public: NewDetectorGeo(); - ~NewDetectorGeo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(NewDetectorGeo, 1); + ~NewDetectorGeo() override = default; + const char* getModuleName(Int_t) override; + const char* getEleName(Int_t) override; + inline Int_t getModNumInMod(const TString&) override; + ClassDefOverride(NewDetectorGeo, 1); }; inline Int_t NewDetectorGeo::getModNumInMod(const TString& name) diff --git a/templates/project_root_containers/NewDetector/NewDetectorGeoPar.cxx b/templates/project_root_containers/NewDetector/NewDetectorGeoPar.cxx index a40fd67e7f..e77971e4fd 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorGeoPar.cxx +++ b/templates/project_root_containers/NewDetector/NewDetectorGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,15 @@ #include #include -ClassImp(NewDetectorGeoPar); - NewDetectorGeoPar ::NewDetectorGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -NewDetectorGeoPar::~NewDetectorGeoPar(void) {} +NewDetectorGeoPar::~NewDetectorGeoPar() {} -void NewDetectorGeoPar::clear(void) +void NewDetectorGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/templates/project_root_containers/NewDetector/NewDetectorGeoPar.h b/templates/project_root_containers/NewDetector/NewDetectorGeoPar.h index 4ace7ba933..f16d1603fd 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorGeoPar.h +++ b/templates/project_root_containers/NewDetector/NewDetectorGeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,8 @@ class NewDetectorGeoPar : public FairParGenericSet NewDetectorGeoPar(const char* name = "NewDetectorGeoPar", const char* title = "NewDetector Geometry Parameters", const char* context = "TestDefaultContext"); - ~NewDetectorGeoPar(void); - void clear(void); + ~NewDetectorGeoPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/templates/project_root_containers/NewDetector/NewDetectorPoint.cxx b/templates/project_root_containers/NewDetector/NewDetectorPoint.cxx index 7a74f497b7..83a0b03783 100644 --- a/templates/project_root_containers/NewDetector/NewDetectorPoint.cxx +++ b/templates/project_root_containers/NewDetector/NewDetectorPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -43,5 +43,3 @@ void NewDetectorPoint::Print(const Option_t* /*opt*/) const << endl; } // ------------------------------------------------------------------------- - -ClassImp(NewDetectorPoint); diff --git a/templates/project_root_containers/field/MyConstField.cxx b/templates/project_root_containers/field/MyConstField.cxx index 258e751354..8b6e2be87a 100644 --- a/templates/project_root_containers/field/MyConstField.cxx +++ b/templates/project_root_containers/field/MyConstField.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -171,5 +171,3 @@ void MyConstField::Print() cout << "======================================================" << endl; } // ------------------------------------------------------------------------- - -ClassImp(MyConstField); diff --git a/templates/project_root_containers/field/MyFieldCreator.cxx b/templates/project_root_containers/field/MyFieldCreator.cxx index 4e0ad03d4f..21969395bf 100644 --- a/templates/project_root_containers/field/MyFieldCreator.cxx +++ b/templates/project_root_containers/field/MyFieldCreator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -62,5 +62,3 @@ FairField *MyFieldCreator::createFairField() } return fMagneticField; } - -ClassImp(MyFieldCreator); diff --git a/templates/project_root_containers/field/MyFieldPar.cxx b/templates/project_root_containers/field/MyFieldPar.cxx index a19e65f995..c194cac623 100644 --- a/templates/project_root_containers/field/MyFieldPar.cxx +++ b/templates/project_root_containers/field/MyFieldPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -192,9 +192,5 @@ void MyFieldPar::SetParameters(FairField* field) fMapName = ""; fPosX = fPosY = fPosZ = fScale = 0.; } - - return; } // ------------------------------------------------------------------------- - -ClassImp(MyFieldPar); diff --git a/templates/project_root_containers/passive/MyCave.cxx b/templates/project_root_containers/passive/MyCave.cxx index 06fbc0df86..6cb4b9eb67 100644 --- a/templates/project_root_containers/passive/MyCave.cxx +++ b/templates/project_root_containers/passive/MyCave.cxx @@ -1,6 +1,5 @@ - /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,8 +25,6 @@ #include // for TString #include // for NULL -ClassImp(MyCave); - void MyCave::ConstructGeometry() { FairGeoLoader* loader = FairGeoLoader::Instance(); diff --git a/templates/project_root_containers/passive/MyGeoCave.cxx b/templates/project_root_containers/passive/MyGeoCave.cxx index 5ccdbefcbf..e06d609c48 100644 --- a/templates/project_root_containers/passive/MyGeoCave.cxx +++ b/templates/project_root_containers/passive/MyGeoCave.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,16 +30,10 @@ #include // for cout #include // for strcmp -ClassImp(MyGeoCave); - MyGeoCave::MyGeoCave() - : FairGeoSet() + : FairGeoSet("cave", 1) , name("cave") -{ - // Constructor - fName = "cave"; - maxModules = 1; -} +{} Bool_t MyGeoCave::read(std::fstream& fin, FairGeoMedia* media) { diff --git a/templates/project_root_containers/passive/MyGeoCave.h b/templates/project_root_containers/passive/MyGeoCave.h index 1829a6dc1b..2fca2694b8 100644 --- a/templates/project_root_containers/passive/MyGeoCave.h +++ b/templates/project_root_containers/passive/MyGeoCave.h @@ -1,6 +1,5 @@ - /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +21,6 @@ #include // for fstream #include // for fstream -class FairGeoMedia; - class MyGeoCave : public FairGeoSet { protected: @@ -31,13 +28,13 @@ class MyGeoCave : public FairGeoSet public: MyGeoCave(); - ~MyGeoCave() {} - const char* getModuleName(Int_t) { return name.Data(); } - Bool_t read(std::fstream&, FairGeoMedia*); - void addRefNodes(); - void write(std::fstream&); - void print(); - ClassDef(MyGeoCave, 0); // Class for the geometry of CAVE + ~MyGeoCave() override = default; + const char* getModuleName(Int_t) override { return name.Data(); } + Bool_t read(std::fstream&, FairGeoMedia*) override; + void addRefNodes() override; + void write(std::fstream&) override; + void print() override; + ClassDefOverride(MyGeoCave, 0); // Class for the geometry of CAVE }; #endif /* !MyGEOCAVE_H */ diff --git a/templates/project_root_containers/passive/MyMagnet.cxx b/templates/project_root_containers/passive/MyMagnet.cxx index 65225e5124..792f5829a0 100644 --- a/templates/project_root_containers/passive/MyMagnet.cxx +++ b/templates/project_root_containers/passive/MyMagnet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -91,6 +91,7 @@ void MyMagnet::ConstructGeometry() top->AddNode(magnet1, 2, m6); } -FairModule *MyMagnet::CloneModule() const { return new MyMagnet(*this); } - -ClassImp(MyMagnet); +FairModule* MyMagnet::CloneModule() const +{ + return new MyMagnet(*this); +} diff --git a/templates/project_root_containers/passive/MyPassiveContFact.cxx b/templates/project_root_containers/passive/MyPassiveContFact.cxx index 96cdad8c6b..074b9ea6ce 100644 --- a/templates/project_root_containers/passive/MyPassiveContFact.cxx +++ b/templates/project_root_containers/passive/MyPassiveContFact.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,10 +27,6 @@ #include // for TString #include // for strcmp, NULL -class FairParSet; - -ClassImp(MyPassiveContFact); - static MyPassiveContFact gMyPassiveContFact; MyPassiveContFact::MyPassiveContFact() diff --git a/templates/project_root_containers/passive/MyPassiveContFact.h b/templates/project_root_containers/passive/MyPassiveContFact.h index 8830057460..44afad75fd 100644 --- a/templates/project_root_containers/passive/MyPassiveContFact.h +++ b/templates/project_root_containers/passive/MyPassiveContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,17 +16,13 @@ #include "FairContFact.h" // for FairContFact, etc -#include // for MyPassiveContFact::Class, etc - -class FairParSet; - class MyPassiveContFact : public FairContFact { public: MyPassiveContFact(); - ~MyPassiveContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(MyPassiveContFact, 0); // Factory for all Passive parameter containers + ~MyPassiveContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(MyPassiveContFact, 0); // Factory for all Passive parameter containers }; #endif /* !My_PASSIVECONTFACT_H */ diff --git a/templates/project_root_containers/passive/MyPipe.cxx b/templates/project_root_containers/passive/MyPipe.cxx index 6a4632e22d..a56eb2e236 100644 --- a/templates/project_root_containers/passive/MyPipe.cxx +++ b/templates/project_root_containers/passive/MyPipe.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -74,6 +74,7 @@ void MyPipe::ConstructGeometry() } // ---------------------------------------------------------------------------- -FairModule* MyPipe::CloneModule() const { return new MyPipe(*this); } - -ClassImp(MyPipe); +FairModule* MyPipe::CloneModule() const +{ + return new MyPipe(*this); +} diff --git a/templates/project_stl_containers/CMakeLists.txt b/templates/project_stl_containers/CMakeLists.txt index b091107521..fedbcb5817 100644 --- a/templates/project_stl_containers/CMakeLists.txt +++ b/templates/project_stl_containers/CMakeLists.txt @@ -27,10 +27,16 @@ SET(FAIRROOTPATH $ENV{FAIRROOTPATH}) # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ # is checked set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules" ${CMAKE_MODULE_PATH}) - set(CMAKE_MODULE_PATH "${FAIRROOTPATH}/share/fairbase/cmake/modules_old" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) +if(SIMPATH) + set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH}) +endif() + +find_package(FairCMakeModules 0.2 QUIET REQUIRED) +include(FairFindPackage2) +include(FairSummary) -find_package(FairRoot REQUIRED) +find_package2(PUBLIC FairRoot VERSION 19.0 REQUIRED) # Load some basic macros which are needed later on include(FairMacros) @@ -69,12 +75,12 @@ ENDIF(NOT UNIX) # mandatory if(SIMPATH) - set(CMAKE_PREFIX_PATH ${SIMPATH} ${CMAKE_PREFIX_PATH}) set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${SIMPATH}/lib) endif() find_package2(PUBLIC ROOT REQUIRED) include(ROOTMacros) +fairroot_check_root_cxxstd_compatibility() if(ROOT_vmc_FOUND) set(VMCLIB ROOT::VMC) else() @@ -82,19 +88,13 @@ else() set(VMCLIB VMCLibrary) endif() find_package2(PUBLIC FairLogger VERSION 1.2.0 REQUIRED) -foreach(dep IN LISTS FairLogger_PACKAGE_DEPENDENCIES) - if(NOT dep STREQUAL "Boost") - find_package2(PUBLIC ${dep} REQUIRED VERSION ${FairLogger_${dep}_VERSION}) - set(PROJECT_${dep}_VERSION ${FairLogger_${dep}_VERSION}) - endif() -endforeach() find_package2(PUBLIC Pythia6) find_package2(PUBLIC Pythia8) find_package2(PUBLIC Geant3) find_package2(PUBLIC Geant4) Find_Package2(PUBLIC VGM) find_package2(PUBLIC Geant4VMC) -find_package(HEPMC) +find_package2(PUBLIC HEPMC) if(NOT DEFINED Boost_NO_SYSTEM_PATHS) Set(Boost_NO_SYSTEM_PATHS TRUE) @@ -114,7 +114,6 @@ endif() find_package2(PUBLIC Boost VERSION 1.67 - ADD_REQUIREMENTS_OF FairRoot FairMQ FairLogger ) If (Boost_FOUND) @@ -123,6 +122,8 @@ Else (Boost_FOUND) Set(Boost_Avail 0) EndIf (Boost_FOUND) +find_package2_implicit_dependencies() + # set a variable which should be used in all CMakeLists.txt # Defines all basic include directories from fairbase SetBasicVariables() @@ -151,28 +152,8 @@ configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake ) # Summary ###################################################################### -if(CMAKE_CXX_FLAGS) - message(STATUS " ") - message(STATUS " ${Cyan}GLOBAL CXX FLAGS${CR} ${BGreen}${CMAKE_CXX_FLAGS}${CR}") -endif() -if(CMAKE_CONFIGURATION_TYPES) - message(STATUS " ") - message(STATUS " ${Cyan}BUILD TYPE CXX FLAGS${CR}") - string(TOUPPER "${CMAKE_BUILD_TYPE}" selected_type) - foreach(type IN LISTS CMAKE_CONFIGURATION_TYPES) - string(TOUPPER "${type}" type_upper) - if(type_upper STREQUAL selected_type) - pad("${type}" 18 " " type_padded) - message(STATUS "${BGreen}* ${type_padded}${CMAKE_CXX_FLAGS_${type_upper}}${CR}") - else() - pad("${type}" 18 " " type_padded) - message(STATUS " ${BWhite}${type_padded}${CR}${CMAKE_CXX_FLAGS_${type_upper}}") - endif() - unset(type_padded) - unset(type_upper) - endforeach() -message(STATUS " ") -message(STATUS " (Change the build type with ${BMagenta}-DCMAKE_BUILD_TYPE=...${CR})") -endif() +fair_summary_global_cxx_flags_standard() +fair_summary_build_types() +fair_summary_package_dependencies() ################################################################################ diff --git a/templates/project_stl_containers/CTestCustom.cmake b/templates/project_stl_containers/CTestCustom.cmake index 8440f90b34..23ab2e0d6d 100644 --- a/templates/project_stl_containers/CTestCustom.cmake +++ b/templates/project_stl_containers/CTestCustom.cmake @@ -1,5 +1,5 @@ ################################################################################ - # Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # + # Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # @@ -81,7 +81,6 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION "/include/TMap.h:" "/include/TMatrixT.h:" "/include/TMatrixTSym.h:" - "/include/TMemberInspector.h:" "/include/TObjArray.h:" "/include/TRefArray.h:" "/include/TString.h:" @@ -134,4 +133,4 @@ Set (CTEST_CUSTOM_COVERAGE_EXCLUDE Set(CTEST_CUSTOM_ERROR_EXCEPTION ${CTEST_CUSTOM_ERROR_EXCEPTION} "/include/boost/" -) \ No newline at end of file +) diff --git a/templates/project_stl_containers/MyProjData/MyProjMCTrack.cxx b/templates/project_stl_containers/MyProjData/MyProjMCTrack.cxx index 31835c7658..d330f89bc8 100644 --- a/templates/project_stl_containers/MyProjData/MyProjMCTrack.cxx +++ b/templates/project_stl_containers/MyProjData/MyProjMCTrack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -177,5 +177,3 @@ void MyProjMCTrack::SetNPoints(Int_t iDet, Int_t nPoints) */ } // ------------------------------------------------------------------------- - -ClassImp(MyProjMCTrack); diff --git a/templates/project_stl_containers/MyProjData/MyProjStack.cxx b/templates/project_stl_containers/MyProjData/MyProjStack.cxx index ca13a5ce80..81335d733b 100644 --- a/templates/project_stl_containers/MyProjData/MyProjStack.cxx +++ b/templates/project_stl_containers/MyProjData/MyProjStack.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -499,5 +499,3 @@ void MyProjStack::SelectTracks() } } // ------------------------------------------------------------------------- - -ClassImp(MyProjStack); diff --git a/templates/project_stl_containers/MyProjGenerators/Pythia6Generator.cxx b/templates/project_stl_containers/MyProjGenerators/Pythia6Generator.cxx index 112a56cf70..d2d81672fe 100644 --- a/templates/project_stl_containers/MyProjGenerators/Pythia6Generator.cxx +++ b/templates/project_stl_containers/MyProjGenerators/Pythia6Generator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -142,5 +142,3 @@ void Pythia6Generator::CloseInput() } } // ------------------------------------------------------------------------ - -ClassImp(Pythia6Generator); diff --git a/templates/project_stl_containers/MyProjGenerators/Pythia8Generator.cxx b/templates/project_stl_containers/MyProjGenerators/Pythia8Generator.cxx index c1bf4674bb..e281a9ef41 100644 --- a/templates/project_stl_containers/MyProjGenerators/Pythia8Generator.cxx +++ b/templates/project_stl_containers/MyProjGenerators/Pythia8Generator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -168,5 +168,3 @@ void Pythia8Generator::GetPythiaInstance(int arg) cout << "canDecay " << fPythia.particleData.canDecay(arg) << " " << fPythia.particleData.mayDecay(arg) << endl; } // ------------------------------------------------------------------------- - -ClassImp(Pythia8Generator); diff --git a/templates/project_stl_containers/NewDetector/NewDetector.cxx b/templates/project_stl_containers/NewDetector/NewDetector.cxx index fdb28440d7..fcd48dbb5d 100644 --- a/templates/project_stl_containers/NewDetector/NewDetector.cxx +++ b/templates/project_stl_containers/NewDetector/NewDetector.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -80,8 +80,6 @@ void NewDetector::Initialize() { /** * WORKAROUND needed for Geant4 in MT mode - * Call AddSensitiveVolume for sensitive volumes in order to fill - * thread-local FairModule::svList. */ DefineSensitiveVolumes(); @@ -249,5 +247,3 @@ Bool_t NewDetector::IsSensitive(const std::string& name) } return kFALSE; } - -ClassImp(NewDetector); diff --git a/templates/project_stl_containers/NewDetector/NewDetectorContFact.cxx b/templates/project_stl_containers/NewDetector/NewDetectorContFact.cxx index 49cfdd7ebc..00d266362e 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorContFact.cxx +++ b/templates/project_stl_containers/NewDetector/NewDetectorContFact.cxx @@ -11,8 +11,6 @@ #include -ClassImp(NewDetectorContFact); - static NewDetectorContFact gNewDetectorContFact; NewDetectorContFact::NewDetectorContFact() diff --git a/templates/project_stl_containers/NewDetector/NewDetectorContFact.h b/templates/project_stl_containers/NewDetector/NewDetectorContFact.h index 2332115ce7..adb2fbac85 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorContFact.h +++ b/templates/project_stl_containers/NewDetector/NewDetectorContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -10,15 +10,13 @@ #include "FairContFact.h" -class FairContainer; - class NewDetectorContFact : public FairContFact { public: NewDetectorContFact(); - ~NewDetectorContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers + ~NewDetectorContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(NewDetectorContFact, 0); // Factory for all NewDetector parameter containers }; #endif diff --git a/templates/project_stl_containers/NewDetector/NewDetectorGeo.cxx b/templates/project_stl_containers/NewDetector/NewDetectorGeo.cxx index 6be8463ab2..c88e424d9c 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorGeo.cxx +++ b/templates/project_stl_containers/NewDetector/NewDetectorGeo.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -9,21 +9,10 @@ #include "FairGeoNode.h" -ClassImp(NewDetectorGeo); - // ----- Default constructor ------------------------------------------- NewDetectorGeo::NewDetectorGeo() - : FairGeoSet() -{ - // Constructor - // fName has to be the name used in the geometry for all volumes. - // If there is a mismatch the geometry cannot be build. - fName = "newdetector"; - strcpy(modName, "NewDetector"); - strcpy(eleName, "NewDetector"); - maxSectors = 0; - maxModules = 10; -} + : FairGeoSet("newdetector", 10) +{} // ------------------------------------------------------------------------- diff --git a/templates/project_stl_containers/NewDetector/NewDetectorGeo.h b/templates/project_stl_containers/NewDetector/NewDetectorGeo.h index 40149293a1..b040b7749b 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorGeo.h +++ b/templates/project_stl_containers/NewDetector/NewDetectorGeo.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,16 @@ class NewDetectorGeo : public FairGeoSet { - protected: - char modName[20]; // name of module - char eleName[20]; // substring for elements in module + char modName[20]{"NewDetector"}; // name of module + char eleName[20]{"NewDetector"}; // substring for elements in module public: NewDetectorGeo(); - ~NewDetectorGeo() {} - const char* getModuleName(Int_t); - const char* getEleName(Int_t); - inline Int_t getModNumInMod(const TString&); - ClassDef(NewDetectorGeo, 1); + ~NewDetectorGeo() override = default; + const char* getModuleName(Int_t) override; + const char* getEleName(Int_t) override; + inline Int_t getModNumInMod(const TString&) override; + ClassDefOverride(NewDetectorGeo, 1); }; inline Int_t NewDetectorGeo::getModNumInMod(const TString& name) diff --git a/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.cxx b/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.cxx index a40fd67e7f..e77971e4fd 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.cxx +++ b/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -12,17 +12,15 @@ #include #include -ClassImp(NewDetectorGeoPar); - NewDetectorGeoPar ::NewDetectorGeoPar(const char* name, const char* title, const char* context) : FairParGenericSet(name, title, context) , fGeoSensNodes(new TObjArray()) , fGeoPassNodes(new TObjArray()) {} -NewDetectorGeoPar::~NewDetectorGeoPar(void) {} +NewDetectorGeoPar::~NewDetectorGeoPar() {} -void NewDetectorGeoPar::clear(void) +void NewDetectorGeoPar::clear() { delete fGeoSensNodes; delete fGeoPassNodes; diff --git a/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.h b/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.h index 4ace7ba933..f16d1603fd 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.h +++ b/templates/project_stl_containers/NewDetector/NewDetectorGeoPar.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -25,8 +25,8 @@ class NewDetectorGeoPar : public FairParGenericSet NewDetectorGeoPar(const char* name = "NewDetectorGeoPar", const char* title = "NewDetector Geometry Parameters", const char* context = "TestDefaultContext"); - ~NewDetectorGeoPar(void); - void clear(void); + ~NewDetectorGeoPar(); + void clear(); void putParams(FairParamList*); Bool_t getParams(FairParamList*); TObjArray* GetGeoSensitiveNodes() { return fGeoSensNodes; } diff --git a/templates/project_stl_containers/NewDetector/NewDetectorPoint.cxx b/templates/project_stl_containers/NewDetector/NewDetectorPoint.cxx index 59393dc8a3..207d681ef2 100644 --- a/templates/project_stl_containers/NewDetector/NewDetectorPoint.cxx +++ b/templates/project_stl_containers/NewDetector/NewDetectorPoint.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -63,5 +63,3 @@ void NewDetectorPoint::Print(const Option_t* /*opt*/) const << endl; } // ------------------------------------------------------------------------- - -ClassImp(NewDetectorPoint); diff --git a/templates/project_stl_containers/field/MyConstField.cxx b/templates/project_stl_containers/field/MyConstField.cxx index 258e751354..8b6e2be87a 100644 --- a/templates/project_stl_containers/field/MyConstField.cxx +++ b/templates/project_stl_containers/field/MyConstField.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -171,5 +171,3 @@ void MyConstField::Print() cout << "======================================================" << endl; } // ------------------------------------------------------------------------- - -ClassImp(MyConstField); diff --git a/templates/project_stl_containers/field/MyFieldCreator.cxx b/templates/project_stl_containers/field/MyFieldCreator.cxx index 4e0ad03d4f..21969395bf 100644 --- a/templates/project_stl_containers/field/MyFieldCreator.cxx +++ b/templates/project_stl_containers/field/MyFieldCreator.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -62,5 +62,3 @@ FairField *MyFieldCreator::createFairField() } return fMagneticField; } - -ClassImp(MyFieldCreator); diff --git a/templates/project_stl_containers/field/MyFieldPar.cxx b/templates/project_stl_containers/field/MyFieldPar.cxx index a19e65f995..c194cac623 100644 --- a/templates/project_stl_containers/field/MyFieldPar.cxx +++ b/templates/project_stl_containers/field/MyFieldPar.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -192,9 +192,5 @@ void MyFieldPar::SetParameters(FairField* field) fMapName = ""; fPosX = fPosY = fPosZ = fScale = 0.; } - - return; } // ------------------------------------------------------------------------- - -ClassImp(MyFieldPar); diff --git a/templates/project_stl_containers/passive/MyCave.cxx b/templates/project_stl_containers/passive/MyCave.cxx index 06fbc0df86..6cb4b9eb67 100644 --- a/templates/project_stl_containers/passive/MyCave.cxx +++ b/templates/project_stl_containers/passive/MyCave.cxx @@ -1,6 +1,5 @@ - /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -26,8 +25,6 @@ #include // for TString #include // for NULL -ClassImp(MyCave); - void MyCave::ConstructGeometry() { FairGeoLoader* loader = FairGeoLoader::Instance(); diff --git a/templates/project_stl_containers/passive/MyGeoCave.cxx b/templates/project_stl_containers/passive/MyGeoCave.cxx index 5ccdbefcbf..e06d609c48 100644 --- a/templates/project_stl_containers/passive/MyGeoCave.cxx +++ b/templates/project_stl_containers/passive/MyGeoCave.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -30,16 +30,10 @@ #include // for cout #include // for strcmp -ClassImp(MyGeoCave); - MyGeoCave::MyGeoCave() - : FairGeoSet() + : FairGeoSet("cave", 1) , name("cave") -{ - // Constructor - fName = "cave"; - maxModules = 1; -} +{} Bool_t MyGeoCave::read(std::fstream& fin, FairGeoMedia* media) { diff --git a/templates/project_stl_containers/passive/MyGeoCave.h b/templates/project_stl_containers/passive/MyGeoCave.h index 2f27ffeedb..700a13940a 100644 --- a/templates/project_stl_containers/passive/MyGeoCave.h +++ b/templates/project_stl_containers/passive/MyGeoCave.h @@ -1,6 +1,5 @@ - /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -22,8 +21,6 @@ #include // for fstream #include // for fstream -class FairGeoMedia; - class MyGeoCave : public FairGeoSet { protected: @@ -31,13 +28,13 @@ class MyGeoCave : public FairGeoSet public: MyGeoCave(); - ~MyGeoCave() {} - const char* getModuleName(Int_t) { return name.Data(); } - Bool_t read(std::fstream&, FairGeoMedia*); - void addRefNodes(); - void write(std::fstream&); - void print(); - ClassDef(MyGeoCave, 0); // Class for the geometry of CAVE + ~MyGeoCave() override = default; + const char* getModuleName(Int_t) override { return name.Data(); } + Bool_t read(std::fstream&, FairGeoMedia*) override; + void addRefNodes() override; + void write(std::fstream&) override; + void print() override; + ClassDefOverride(MyGeoCave, 0); // Class for the geometry of CAVE }; #endif /* !MYGEOCAVE_H */ diff --git a/templates/project_stl_containers/passive/MyMagnet.cxx b/templates/project_stl_containers/passive/MyMagnet.cxx index 65225e5124..792f5829a0 100644 --- a/templates/project_stl_containers/passive/MyMagnet.cxx +++ b/templates/project_stl_containers/passive/MyMagnet.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -91,6 +91,7 @@ void MyMagnet::ConstructGeometry() top->AddNode(magnet1, 2, m6); } -FairModule *MyMagnet::CloneModule() const { return new MyMagnet(*this); } - -ClassImp(MyMagnet); +FairModule* MyMagnet::CloneModule() const +{ + return new MyMagnet(*this); +} diff --git a/templates/project_stl_containers/passive/MyPassiveContFact.cxx b/templates/project_stl_containers/passive/MyPassiveContFact.cxx index 96cdad8c6b..074b9ea6ce 100644 --- a/templates/project_stl_containers/passive/MyPassiveContFact.cxx +++ b/templates/project_stl_containers/passive/MyPassiveContFact.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -27,10 +27,6 @@ #include // for TString #include // for strcmp, NULL -class FairParSet; - -ClassImp(MyPassiveContFact); - static MyPassiveContFact gMyPassiveContFact; MyPassiveContFact::MyPassiveContFact() diff --git a/templates/project_stl_containers/passive/MyPassiveContFact.h b/templates/project_stl_containers/passive/MyPassiveContFact.h index 8830057460..44afad75fd 100644 --- a/templates/project_stl_containers/passive/MyPassiveContFact.h +++ b/templates/project_stl_containers/passive/MyPassiveContFact.h @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -16,17 +16,13 @@ #include "FairContFact.h" // for FairContFact, etc -#include // for MyPassiveContFact::Class, etc - -class FairParSet; - class MyPassiveContFact : public FairContFact { public: MyPassiveContFact(); - ~MyPassiveContFact() {} - FairParSet* createContainer(FairContainer*); - ClassDef(MyPassiveContFact, 0); // Factory for all Passive parameter containers + ~MyPassiveContFact() override = default; + FairParSet* createContainer(FairContainer*) override; + ClassDefOverride(MyPassiveContFact, 0); // Factory for all Passive parameter containers }; #endif /* !My_PASSIVECONTFACT_H */ diff --git a/templates/project_stl_containers/passive/MyPipe.cxx b/templates/project_stl_containers/passive/MyPipe.cxx index 6a4632e22d..a56eb2e236 100644 --- a/templates/project_stl_containers/passive/MyPipe.cxx +++ b/templates/project_stl_containers/passive/MyPipe.cxx @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * @@ -74,6 +74,7 @@ void MyPipe::ConstructGeometry() } // ---------------------------------------------------------------------------- -FairModule* MyPipe::CloneModule() const { return new MyPipe(*this); } - -ClassImp(MyPipe); +FairModule* MyPipe::CloneModule() const +{ + return new MyPipe(*this); +} diff --git a/templates/test_project_root_containers.sh.in b/templates/test_project_root_containers.sh.in index 0e766108c0..ced5da6166 100755 --- a/templates/test_project_root_containers.sh.in +++ b/templates/test_project_root_containers.sh.in @@ -14,7 +14,7 @@ mkdir build cd build export SIMPATH=@SIMPATH@ export FAIRROOTPATH=@CMAKE_INSTALL_PREFIX@ -cmake -DUSE_DIFFERENT_COMPILER=true -DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@ .. +cmake -DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@ .. if [ "$1" = "--double-configure" ] then diff --git a/templates/test_project_stl_containers.sh.in b/templates/test_project_stl_containers.sh.in index 96e4f6be2d..289ad597a5 100755 --- a/templates/test_project_stl_containers.sh.in +++ b/templates/test_project_stl_containers.sh.in @@ -14,7 +14,7 @@ mkdir build cd build export CMAKE_PREFIX_PATH="@SIMPATH@${CMAKE_PREFIX_PATH:+:$CMAKE_PREFIX_PATH}" export FAIRROOTPATH=@CMAKE_INSTALL_PREFIX@ -cmake -DUSE_DIFFERENT_COMPILER=true -DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@ .. +cmake -DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@ .. if [ "$1" = "--double-configure" ] then diff --git a/test/FairLoggerFatal.cxx b/test/FairLoggerFatal.cxx deleted file mode 100644 index b89737c61a..0000000000 --- a/test/FairLoggerFatal.cxx +++ /dev/null @@ -1,10 +0,0 @@ -#include "FairLogger.h" - -#include "gtest/gtest.h" - -TEST(FairLoggerTest, TestFatalError) -{ - FairLogger::GetLogger(); - ASSERT_THROW(LOG(fatal) << "This is a fatal problem", fair::FatalException); - // TODO: check if cored dump is written to file -} diff --git a/test/CMakeLists.txt b/tests/CMakeLists.txt similarity index 61% rename from test/CMakeLists.txt rename to tests/CMakeLists.txt index c0d6ee5b4e..45abf56b68 100644 --- a/test/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,17 +1,14 @@ ################################################################################ -# Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # # # # This software is distributed under the terms of the # # GNU Lesser General Public Licence (LGPL) version 3, # # copied verbatim in the file "LICENSE" # ################################################################################ -set(dependencies - FairRoot::Tools - GTest::GTest - GTest::Main -) +add_subdirectory(base) +add_subdirectory(geobase) -add_executable(FairLoggerFatal FairLoggerFatal.cxx) -target_link_libraries(FairLoggerFatal ${dependencies}) -add_test(NAME FairLoggerFatal COMMAND ${CMAKE_CURRENT_BINARY_DIR}/FairLoggerFatal) +add_subdirectory(examples) + +add_subdirectory(tgeo) diff --git a/tests/base/CMakeLists.txt b/tests/base/CMakeLists.txt new file mode 100644 index 0000000000..ce505ec031 --- /dev/null +++ b/tests/base/CMakeLists.txt @@ -0,0 +1,17 @@ +################################################################################ +# Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(Base + SOURCES + dummy_example.cxx # remove me once first real tests are added + # add more test files if appropriate + + # DEPENDENCIES + # FairRoot::Base + # list all the targets to build the test suite here +) diff --git a/tests/base/dummy_example.cxx b/tests/base/dummy_example.cxx new file mode 100644 index 0000000000..da797787a9 --- /dev/null +++ b/tests/base/dummy_example.cxx @@ -0,0 +1,49 @@ +/******************************************************************************** + * Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include +#include + +// shamelessly stolen from https://github.com/catchorg/Catch2/blob/devel/docs/tutorial.md#test-cases-and-sections +TEST_CASE("vectors can be sized and resized") +{ + + std::vector v(5); + + REQUIRE(v.size() == 5); + REQUIRE(v.capacity() >= 5); + + SECTION("resizing bigger changes size and capacity") + { + v.resize(10); + + REQUIRE(v.size() == 10); + REQUIRE(v.capacity() >= 10); + } + SECTION("resizing smaller changes size but not capacity") + { + v.resize(0); + + REQUIRE(v.size() == 0); + REQUIRE(v.capacity() >= 5); + } + SECTION("reserving bigger changes capacity but not size") + { + v.reserve(10); + + REQUIRE(v.size() == 5); + REQUIRE(v.capacity() >= 10); + } + SECTION("reserving smaller does not change size or capacity") + { + v.reserve(0); + + REQUIRE(v.size() == 5); + REQUIRE(v.capacity() >= 5); + } +} diff --git a/test/ci/container/debian.11.def b/tests/ci/container/debian.11.def similarity index 100% rename from test/ci/container/debian.11.def rename to tests/ci/container/debian.11.def diff --git a/test/ci/container/fairsoft-install.py b/tests/ci/container/fairsoft-install.py similarity index 100% rename from test/ci/container/fairsoft-install.py rename to tests/ci/container/fairsoft-install.py diff --git a/test/ci/container/ubuntu.rolling.def b/tests/ci/container/ubuntu.rolling.def similarity index 91% rename from test/ci/container/ubuntu.rolling.def rename to tests/ci/container/ubuntu.rolling.def index fd9f421cb3..df3d2d45fa 100644 --- a/test/ci/container/ubuntu.rolling.def +++ b/tests/ci/container/ubuntu.rolling.def @@ -20,7 +20,8 @@ From: ubuntu:rolling doxygen graphviz clang-format clang-tidy apt-get -y --no-install-recommends install \ - liblzma-dev liblz4-dev nlohmann-json3-dev libzstd-dev libftgl-dev + liblzma-dev liblz4-dev libzstd-dev libftgl-dev + # nlohmann-json3-dev chmod a+x /opt/fairsoft/fairsoft-install.py ln -s /opt/fairsoft /fairsoft diff --git a/test/ci/slurm-create-jobscript.sh b/tests/ci/slurm-create-jobscript.sh similarity index 100% rename from test/ci/slurm-create-jobscript.sh rename to tests/ci/slurm-create-jobscript.sh diff --git a/test/ci/slurm-submit.sh b/tests/ci/slurm-submit.sh similarity index 91% rename from test/ci/slurm-submit.sh rename to tests/ci/slurm-submit.sh index 2012ac546b..c9c30acbe1 100755 --- a/test/ci/slurm-submit.sh +++ b/tests/ci/slurm-submit.sh @@ -1,13 +1,14 @@ #! /bin/bash -if [ $# != 2 ] +if [ $# != 3 ] then - echo "*** Please call like: $0 LABEL JOBSH" + echo "*** Please call like: $0 TYPE LABEL JOBSH" exit 1 fi -label="$1" -jobsh="$2" +type="$1" +label="$2" +jobsh="$3" if [ -z "$ALFACI_SLURM_CPUS" ] then @@ -26,8 +27,8 @@ if [ -z "$ALFACI_SLURM_QUEUE" ] then ALFACI_SLURM_QUEUE=main fi -case "${label}" in - *check/*) +case "${type}" in + *check*) slurm_requested_features=localworkspace ;; esac diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt new file mode 100644 index 0000000000..3b8fa40fb6 --- /dev/null +++ b/tests/examples/CMakeLists.txt @@ -0,0 +1,31 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +if(TARGET FairRoot::ExSimulation1) + add_subdirectory(simulation/Tutorial1) +endif() +if(TARGET FairRoot::ExSimulation2) + add_subdirectory(simulation/Tutorial2) +endif() +if(TARGET FairRoot::ExSimulation4) + add_subdirectory(simulation/Tutorial4) +endif() +if(TARGET FairRoot::ExRutherford) + add_subdirectory(simulation/rutherford) +endif() + +if(TARGET FairRoot::ExTestDetector) + add_subdirectory(advanced/Tutorial3) +endif() +if(TARGET FairRoot::ExPropagator) + add_subdirectory(advanced/propagator) +endif() + +if(TARGET FairRoot::ExPixel) + add_subdirectory(MQ/pixelDetector) +endif() diff --git a/tests/examples/MQ/pixelDetector/CMakeLists.txt b/tests/examples/MQ/pixelDetector/CMakeLists.txt new file mode 100644 index 0000000000..eaa4a7931e --- /dev/null +++ b/tests/examples/MQ/pixelDetector/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(ExPixel + SOURCES + test_PixelGeo.cxx + + DEPENDENCIES + FairRoot::ExPixel + FairRoot::GeoBase_checks +) diff --git a/basemq/policies/Sampler/FairMQFileSource.h b/tests/examples/MQ/pixelDetector/test_PixelGeo.cxx similarity index 61% rename from basemq/policies/Sampler/FairMQFileSource.h rename to tests/examples/MQ/pixelDetector/test_PixelGeo.cxx index c14459985f..6596173243 100644 --- a/basemq/policies/Sampler/FairMQFileSource.h +++ b/tests/examples/MQ/pixelDetector/test_PixelGeo.cxx @@ -1,11 +1,19 @@ /******************************************************************************** - * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * * * * This software is distributed under the terms of the * * GNU Lesser General Public Licence (LGPL) version 3, * * copied verbatim in the file "LICENSE" * ********************************************************************************/ -#include "FairSourceMQInterface.h" +#include "tests/geobase/checks_FairGeoSet.h" -using FairMQFileSource_t = FairSourceMQInterface; +#include +#include + +TEST_CASE("PixelGeo") +{ + PixelGeo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "Pixel", 10); +} diff --git a/tests/examples/advanced/Tutorial3/CMakeLists.txt b/tests/examples/advanced/Tutorial3/CMakeLists.txt new file mode 100644 index 0000000000..7ea241efb5 --- /dev/null +++ b/tests/examples/advanced/Tutorial3/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(ExTestDetector + SOURCES + test_FairTestDetectorGeo.cxx + + DEPENDENCIES + FairRoot::ExTestDetector + FairRoot::GeoBase_checks +) diff --git a/tests/examples/advanced/Tutorial3/test_FairTestDetectorGeo.cxx b/tests/examples/advanced/Tutorial3/test_FairTestDetectorGeo.cxx new file mode 100644 index 0000000000..b851fec3db --- /dev/null +++ b/tests/examples/advanced/Tutorial3/test_FairTestDetectorGeo.cxx @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "tests/geobase/checks_FairGeoSet.h" + +#include +#include + +TEST_CASE("FairTestDetectorGeo") +{ + FairTestDetectorGeo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "torino", 10); +} diff --git a/tests/examples/advanced/propagator/CMakeLists.txt b/tests/examples/advanced/propagator/CMakeLists.txt new file mode 100644 index 0000000000..b8e0322e67 --- /dev/null +++ b/tests/examples/advanced/propagator/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(ExPropagator + SOURCES + test_FairTutPropGeo.cxx + + DEPENDENCIES + FairRoot::ExPropagator + FairRoot::GeoBase_checks +) diff --git a/tests/examples/advanced/propagator/test_FairTutPropGeo.cxx b/tests/examples/advanced/propagator/test_FairTutPropGeo.cxx new file mode 100644 index 0000000000..168c0b445e --- /dev/null +++ b/tests/examples/advanced/propagator/test_FairTutPropGeo.cxx @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "tests/geobase/checks_FairGeoSet.h" + +#include +#include + +TEST_CASE("FairTutPropGeo") +{ + FairTutPropGeo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "Pixel", 10); +} diff --git a/tests/examples/simulation/Tutorial1/CMakeLists.txt b/tests/examples/simulation/Tutorial1/CMakeLists.txt new file mode 100644 index 0000000000..a3473333d1 --- /dev/null +++ b/tests/examples/simulation/Tutorial1/CMakeLists.txt @@ -0,0 +1,27 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +# Linking transitively against FairRoot::FastSim fails on some Linux systems due +# to missing RUNPATH entries in various dependencies, workaround by setting +# $LD_LIBRARY_PATH, see https://github.com/FairRootGroup/FairRoot/issues/1523 +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(workaround ENABLE_LD_LIBRARY_PATH_WORKAROUND) +else() + set(workaround) +endif() + +fairroot_add_catch2_test_suite(ExSimulation1 + SOURCES + test_FairTutorialDet1Geo.cxx + + DEPENDENCIES + FairRoot::ExSimulation1 + FairRoot::GeoBase_checks + + ${workaround} +) diff --git a/tests/examples/simulation/Tutorial1/test_FairTutorialDet1Geo.cxx b/tests/examples/simulation/Tutorial1/test_FairTutorialDet1Geo.cxx new file mode 100644 index 0000000000..81d56fcaca --- /dev/null +++ b/tests/examples/simulation/Tutorial1/test_FairTutorialDet1Geo.cxx @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "tests/geobase/checks_FairGeoSet.h" + +#include +#include + +TEST_CASE("FairTutorialDet1Geo") +{ + FairTutorialDet1Geo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "tutdet", 10); +} diff --git a/tests/examples/simulation/Tutorial2/CMakeLists.txt b/tests/examples/simulation/Tutorial2/CMakeLists.txt new file mode 100644 index 0000000000..2305339a2b --- /dev/null +++ b/tests/examples/simulation/Tutorial2/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(ExSimulation2 + SOURCES + test_FairTutorialDet2Geo.cxx + + DEPENDENCIES + FairRoot::ExSimulation2 + FairRoot::GeoBase_checks +) diff --git a/tests/examples/simulation/Tutorial2/test_FairTutorialDet2Geo.cxx b/tests/examples/simulation/Tutorial2/test_FairTutorialDet2Geo.cxx new file mode 100644 index 0000000000..878ed02d2a --- /dev/null +++ b/tests/examples/simulation/Tutorial2/test_FairTutorialDet2Geo.cxx @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "tests/geobase/checks_FairGeoSet.h" + +#include +#include + +TEST_CASE("FairTutorialDet2Geo") +{ + FairTutorialDet2Geo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "tutdet", 10); +} diff --git a/tests/examples/simulation/Tutorial4/CMakeLists.txt b/tests/examples/simulation/Tutorial4/CMakeLists.txt new file mode 100644 index 0000000000..6c78c9a0e1 --- /dev/null +++ b/tests/examples/simulation/Tutorial4/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(ExSimulation4 + SOURCES + test_FairTutorialDet4Geo.cxx + + DEPENDENCIES + FairRoot::ExSimulation4 + FairRoot::GeoBase_checks +) diff --git a/tests/examples/simulation/Tutorial4/test_FairTutorialDet4Geo.cxx b/tests/examples/simulation/Tutorial4/test_FairTutorialDet4Geo.cxx new file mode 100644 index 0000000000..c389c27b12 --- /dev/null +++ b/tests/examples/simulation/Tutorial4/test_FairTutorialDet4Geo.cxx @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "tests/geobase/checks_FairGeoSet.h" + +#include +#include + +TEST_CASE("FairTutorialDet4Geo") +{ + FairTutorialDet4Geo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "tutdet", 100); +} diff --git a/tests/examples/simulation/rutherford/CMakeLists.txt b/tests/examples/simulation/rutherford/CMakeLists.txt new file mode 100644 index 0000000000..d6204d7ac1 --- /dev/null +++ b/tests/examples/simulation/rutherford/CMakeLists.txt @@ -0,0 +1,16 @@ +################################################################################ +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +fairroot_add_catch2_test_suite(ExRutherford + SOURCES + test_FairRutherfordGeo.cxx + + DEPENDENCIES + FairRoot::ExRutherford + FairRoot::GeoBase_checks +) diff --git a/tests/examples/simulation/rutherford/test_FairRutherfordGeo.cxx b/tests/examples/simulation/rutherford/test_FairRutherfordGeo.cxx new file mode 100644 index 0000000000..77662fba1d --- /dev/null +++ b/tests/examples/simulation/rutherford/test_FairRutherfordGeo.cxx @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "tests/geobase/checks_FairGeoSet.h" + +#include +#include + +TEST_CASE("FairRutherfordGeo") +{ + FairRutherfordGeo geo; + + fairroot::tests::checkGeoSetNamingConventions(geo, "rutherford", 10); +} diff --git a/tests/geobase/CMakeLists.txt b/tests/geobase/CMakeLists.txt new file mode 100644 index 0000000000..ab197af0f4 --- /dev/null +++ b/tests/geobase/CMakeLists.txt @@ -0,0 +1,34 @@ +############################################################################### +# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +# Test suite for the `FairRoot::GeoBase` library + +set(suite GeoBase) + +set(checks_lib "${suite}_checks") +add_library(${checks_lib} INTERFACE) +target_link_libraries(${checks_lib} INTERFACE FairRoot::GeoBase Catch2::Catch2 fmt::fmt Boost::filesystem) +target_include_directories(${checks_lib} INTERFACE ${CMAKE_SOURCE_DIR}) +fairroot_library_settings(${checks_lib}) + +fairroot_add_catch2_test_suite(${suite} + SOURCES + tests_FairGeoShapes.cxx + +# Compilation works but when running the test doesn't finish +# Disable for the time being +# FairTestGeo.cxx +# tests_FairGeoSet.cxx + + DEPENDENCIES + FairRoot::GeoBase + FairRoot::GeoBase_checks +) + +configure_File(${CMAKE_CURRENT_SOURCE_DIR}/data/testmedia.geo ${CMAKE_CURRENT_BINARY_DIR}/data/testmedia.geo @ONLY) +configure_File(${CMAKE_CURRENT_SOURCE_DIR}/data/testdet_brick.geo ${CMAKE_CURRENT_BINARY_DIR}/data/testdet_brick.geo @ONLY) diff --git a/tests/geobase/FairTestGeo.cxx b/tests/geobase/FairTestGeo.cxx new file mode 100644 index 0000000000..a4a194ae48 --- /dev/null +++ b/tests/geobase/FairTestGeo.cxx @@ -0,0 +1,12 @@ +/*************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ***************************************************************************/ +#include "FairTestGeo.h" + +FairTestGeo::FairTestGeo() + : FairGeoSet("testdet", 10) +{} diff --git a/tests/geobase/FairTestGeo.h b/tests/geobase/FairTestGeo.h new file mode 100644 index 0000000000..cb1f23661c --- /dev/null +++ b/tests/geobase/FairTestGeo.h @@ -0,0 +1,20 @@ +/*************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ***************************************************************************/ +#ifndef FAIRTESTGEO_H +#define FAIRTESTGEO_H + +#include "FairGeoSet.h" // for FairGeoSet + +class FairTestGeo : public FairGeoSet +{ + public: + FairTestGeo(); + ~FairTestGeo() override = default; +}; + +#endif diff --git a/tests/geobase/checks_FairGeoBasicShape.h b/tests/geobase/checks_FairGeoBasicShape.h new file mode 100644 index 0000000000..0f2fa1d876 --- /dev/null +++ b/tests/geobase/checks_FairGeoBasicShape.h @@ -0,0 +1,169 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "FairGeoBasicShape.h" +#include "FairGeoRotation.h" +#include "FairGeoTransform.h" +#include "FairGeoVector.h" +#include "FairGeoVolume.h" +#include "generate_TestInput.h" + +#include +#include +#include +#include +#include + +using Catch::Matchers::WithinRel; + +#ifndef TESTS_GEOBASE_CHECKS_FAIRGEOBASICSHAPE_H +#define TESTS_GEOBASE_CHECKS_FAIRGEOBASICSHAPE_H + +namespace fairroot::tests +{ + +auto check_FairGeoTransform(FairGeoTransform& _trans) +{ + const FairGeoRotation& rot = _trans.getRotMatrix(); + CHECK(rot.isUnitMatrix()); + + const FairGeoVector& vec = _trans.getTransVector(); + CHECK_THAT(vec.getValues(0), WithinRel(0., 0.001)); + CHECK_THAT(vec.getValues(1), WithinRel(0., 0.001)); + CHECK_THAT(vec.getValues(2), WithinRel(0., 0.001)); + + const FairGeoVector& vec_cm = _trans.getTranslation(); + CHECK_THAT(vec_cm.getValues(0), WithinRel(0., 0.001)); + CHECK_THAT(vec_cm.getValues(1), WithinRel(0., 0.001)); + CHECK_THAT(vec_cm.getValues(2), WithinRel(0., 0.001)); +} + +auto check_FairGeoShape_Construction(FairGeoBasicShape& shape, + std::string name, + int numPoints, + // int numParams, + const TArrayD* _param) +{ + + const int numParams = (_param ? _param->GetSize() : 0); + + SECTION("construction") + { + // Check that members are correctly set by constructor + CHECK(shape.GetName() == name); + CHECK(shape.getNumPoints() == numPoints); + CHECK(shape.getNumParam() == numParams); + + TArrayD* param = shape.getParam(); + if (!_param) { + CHECK(param == _param); + } else { + REQUIRE(param->GetSize() == _param->GetSize()); + for (int i = 0; i < numParams; ++i) { + CHECK(param->GetAt(i) == _param->GetAt(i)); + } + } + + FairGeoTransform* centerPos = shape.getCenterPosition(); + REQUIRE(centerPos); + check_FairGeoTransform(*centerPos); + + FairGeoTransform* voluPos = shape.getVoluPosition(); + REQUIRE(voluPos); + check_FairGeoTransform(*voluPos); + } +} + +auto check_FairGeoShape_ReadWrite(FairGeoBasicShape& shape, + FairGeoVolume& volume, + std::string shapeName, + int numPoints, + std::vector>& parameters) +{ + // generate temporary file with parameters below describing the shape defined by the shapeName + // with the respective coordinates + // The name of the temporary file is returned + std::string fileName = fairroot::tests::generateVolumeParameter(shapeName, parameters); + + // open the file with the shape/volume parameters + // read the content from file and close the file + std::fstream geoFile(fileName, std::ios::in); + shape.readPoints(&geoFile, &volume); + geoFile.close(); + + CHECK(volume.getNumPoints() == numPoints); + for (int i = 0; i < numPoints; ++i) { + FairGeoVector* test = volume.getPoint(i); + REQUIRE(test); + if ("BOX" == shapeName || "TRAP" == shapeName || "TRD1" == shapeName) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + CHECK_THAT(test->Z(), Catch::Matchers::WithinRel(parameters.at(2).at(i), 0.001f)); + } else if ("CONE" == shapeName || "CONS" == shapeName || "ELTU" == shapeName || "TUBE" == shapeName + || "TUBS" == shapeName) { + if (0 == i || 2 == i) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + CHECK_THAT(test->Z(), Catch::Matchers::WithinRel(parameters.at(2).at(i), 0.001f)); + } else { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + } + } else if ("TORUS" == shapeName) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + } else if ("SPHE" == shapeName) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + } else if ("PCON" == shapeName) { + if (0 == i) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + } else if (1 == i) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + } else { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + CHECK_THAT(test->Z(), Catch::Matchers::WithinRel(parameters.at(2).at(i), 0.001f)); + } + } else if ("PGON" == shapeName) { + if (0 == i) { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + } else { + CHECK_THAT(test->X(), Catch::Matchers::WithinRel(parameters.at(0).at(i), 0.001f)); + CHECK_THAT(test->Y(), Catch::Matchers::WithinRel(parameters.at(1).at(i), 0.001f)); + CHECK_THAT(test->Z(), Catch::Matchers::WithinRel(parameters.at(2).at(i), 0.001f)); + } + } + } + + // Use the print function to generate the screen output + // Currently I don't know how to test this + // Probably not very important since the functionality isn't + // really used + shape.printPoints(&volume); + shape.printParam(); + + // Write the parmaters to an output file + std::string testFileName = fairroot::tests::generateTempFileName(); + std::fstream testFile{}; + testFile.open(testFileName, std::ios::out); + shape.writePoints(&testFile, &volume); + testFile.close(); + + // Check if the two files are identical + CHECK(fairroot::tests::compareFiles(fileName, testFileName)); + + // Remove the temporary files + // std::cout << shapeName << ": " << fileName.c_str() << "\n"; + CHECK(std::remove(fileName.c_str()) == 0); + CHECK(std::remove(testFileName.c_str()) == 0); +} + +} // namespace fairroot::tests + +#endif diff --git a/tests/geobase/checks_FairGeoSet.h b/tests/geobase/checks_FairGeoSet.h new file mode 100644 index 0000000000..3be6da1dfe --- /dev/null +++ b/tests/geobase/checks_FairGeoSet.h @@ -0,0 +1,51 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "FairGeoSet.h" + +#include +#include +#include +#include + +#ifndef TESTS_GEOBASE_CHECKS_FAIRGEOSET_H +#define TESTS_GEOBASE_CHECKS_FAIRGEOSET_H + +namespace fairroot::tests +{ + +auto checkGeoSetNamingConventions(FairGeoSet& geo, const std::string& prefix, int modules) +{ + SECTION("construction") + { + // Check that members are correctly set by constructor + CHECK(geo.GetName() == prefix); + CHECK(geo.getMaxModules() == modules); + } + + SECTION("name generation") + { + auto index = GENERATE(take(100, random(1, 1000))); + const auto name = fmt::format("{}{}", prefix, index + 1); + + CHECK(geo.getModuleName(index) == name); + CHECK(geo.getEleName(index) == name); + } + + SECTION("name parsing") + { + auto index = GENERATE(take(100, random(1, 1000))); + const auto name = fmt::format("{}{}", prefix, index + 1); + + CHECK(geo.getModNumInMod(name) == index); + } +} + +} // namespace fairroot::tests + +#endif diff --git a/tests/geobase/data/testdet_brick.geo b/tests/geobase/data/testdet_brick.geo new file mode 100644 index 0000000000..a8a8b87364 --- /dev/null +++ b/tests/geobase/data/testdet_brick.geo @@ -0,0 +1,14 @@ +testdet1 +cave +BOX +silicon +400.000 -400.000 -0.200 +400.000 400.000 -0.200 +-400.000 400.000 -0.200 +-400.000 -400.000 -0.200 +400.000 -400.000 0.200 +400.000 400.000 0.200 +-400.000 400.000 0.200 +-400.000 -400.000 0.200 +0. 0. 300.000 +1. 0. 0. 0. 1. 0. 0. 0. 1. diff --git a/tests/geobase/data/testmedia.geo b/tests/geobase/data/testmedia.geo new file mode 100644 index 0000000000..3406bee8a4 --- /dev/null +++ b/tests/geobase/data/testmedia.geo @@ -0,0 +1,6 @@ +//---------------------------------------------------------- +air 3 14.01 16. 39.95 7. 8. 18. 1.205e-3 .755 .231 .014 + 0 1 30. .001 +silicon 1 28.0855 14.0 2.33 + 1 1 20. .001 + 0 diff --git a/tests/geobase/generate_TestInput.h b/tests/geobase/generate_TestInput.h new file mode 100644 index 0000000000..9d42fca161 --- /dev/null +++ b/tests/geobase/generate_TestInput.h @@ -0,0 +1,172 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ +#include +#include +#include +#include +#include +#include + +#ifndef TESTS_GEOBASE_CHECKS_FAIRGEOSET_H +#define TESTS_GEOBASE_CHECKS_FAIRGEOSET_H + +namespace fairroot::tests +{ + +void getVolumeParameter(std::string shape, const std::vector>& parameters, std::stringstream& os) +{ + + if (shape == "BOX" || shape == "TRAP" || shape == "TRD1") { + constexpr int points{8}; + for (int cornerPoints = 0; cornerPoints < points; ++cornerPoints) { + os << std::setw(9) << parameters.at(0).at(cornerPoints) << std::setw(10) + << parameters.at(1).at(cornerPoints) << std::setw(10) << parameters.at(2).at(cornerPoints) << "\n"; + } + } else if (shape == "CONE") { + constexpr int points{4}; + for (int iPoint = 0; iPoint < points; ++iPoint) { + if (iPoint == 0 || iPoint == 2) { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << std::setw(10) << parameters.at(2).at(iPoint) << "\n"; + } else { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << "\n"; + } + } + } else if (shape == "CONS") { + constexpr int points{5}; + for (int iPoint = 0; iPoint < points; ++iPoint) { + if (iPoint == 0 || iPoint == 2) { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << std::setw(10) << parameters.at(2).at(iPoint) << "\n"; + } else { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << "\n"; + } + } + } else if (shape == "ELTU" || shape == "TUBE") { + constexpr int points{3}; + for (int iPoint = 0; iPoint < points; ++iPoint) { + if (iPoint == 0 || iPoint == 2) { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << std::setw(10) << parameters.at(2).at(iPoint) << "\n"; + } else { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << "\n"; + } + } + } else if (shape == "TUBS") { + constexpr int points{4}; + for (int iPoint = 0; iPoint < points; ++iPoint) { + if (iPoint == 0 || iPoint == 2) { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << std::setw(10) << parameters.at(2).at(iPoint) << "\n"; + } else { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << "\n"; + } + } + } else if (shape == "TORUS") { + constexpr int points{5}; + for (int iPoint = 0; iPoint < points; ++iPoint) { + os << std::setw(9) << parameters.at(0).at(iPoint) << "\n"; + } + } else if (shape == "SPHE") { + constexpr int points{3}; + for (int iPoint = 0; iPoint < points; ++iPoint) { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) << "\n"; + } + } else if (shape == "PCON") { + int points = parameters.at(0).size(); + for (int iPoint = 0; iPoint < points; ++iPoint) { + if (iPoint == 0) { + os << std::setw(3) << static_cast(parameters.at(0).at(iPoint)) << "\n"; + } else if (iPoint == 1) { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << "\n"; + } else { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << std::setw(10) << parameters.at(2).at(iPoint) << "\n"; + } + } + } else if (shape == "PGON") { + int points = parameters.at(0).size(); + for (int iPoint = 0; iPoint < points; ++iPoint) { + if (iPoint == 0) { + os << std::setw(3) << static_cast(parameters.at(0).at(iPoint)) << "\n"; + } else { + os << std::setw(9) << parameters.at(0).at(iPoint) << std::setw(10) << parameters.at(1).at(iPoint) + << std::setw(10) << parameters.at(2).at(iPoint) << "\n"; + } + } + } +} + +auto generateTempFileName() +{ + // generate a temporary file in an appropriate folder + // there is no good solution available from C and C++ standards + boost::filesystem::path tempDir = boost::filesystem::temp_directory_path(); + boost::filesystem::path tempFile = boost::filesystem::unique_path(); + return ((tempDir / tempFile).native()); +} + +auto generateVolumeParameter(std::string shape, const std::vector>& parameters) +{ + + // stringstream which is used to collect all information added + // The stringstream is finally written to file + std::stringstream os; + os << std::fixed << std::setprecision(3); + + getVolumeParameter(shape, parameters, os); + + std::string outFileName = generateTempFileName(); + + std::ofstream outFile{}; + outFile.open(outFileName); + outFile << os.rdbuf(); + outFile.close(); + + return outFileName; +} + +bool compareFiles(std::string file1, std::string file2) +{ + std::fstream f1{file1.c_str(), std::ios::in}; + if (!f1) { + std::cout << "File " << file1 << " can't be opened\n"; + return false; + } + + std::fstream f2{file2.c_str(), std::ios::in}; + if (!f2) { + f1.close(); + std::cout << "File " << file2 << " can't be opened\n"; + return false; + } + + while (1) { + auto c1 = f1.get(); + auto c2 = f2.get(); + if (c1 != c2) { + f1.close(); + f2.close(); + return false; + } + if ((c1 == decltype(f1)::traits_type::eof()) || (c2 == decltype(f2)::traits_type::eof())) + break; + } + f1.close(); + f2.close(); + return true; +} + +} // namespace fairroot::tests + +#endif diff --git a/tests/geobase/tests_FairGeoSet.cxx b/tests/geobase/tests_FairGeoSet.cxx new file mode 100644 index 0000000000..d1c7f7c1e4 --- /dev/null +++ b/tests/geobase/tests_FairGeoSet.cxx @@ -0,0 +1,97 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "FairGeoBrik.h" +#include "FairGeoMedia.h" +#include "FairGeoMedium.h" +#include "FairGeoShapes.h" +#include "FairTestGeo.h" +#include "checks_FairGeoSet.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifndef TESTS_GEOBASE_FAIRGEOSET_H +#define TESTS_GEOBASE_FAIRGEOSET_H + +TEST_CASE("FairTestGeo") +{ + /* + std::ostringstream os; + + os << "//----------------------------------------------------------\n"; + os << "air 3 14.01 16. 39.95 7. 8. 18. 1.205e-3 .755 .231.014\n"; + os << " 0 1 30. .001\n"; + os << "silicon 1 28.0855 14.0 2.33\n"; + os << " 1 1 20. .001\n"; + os << " 0"; + std::istringstream mediafile( os.str() ); + */ + + std::fstream mediafile{"data/testmedia.geo", std::ios::in}; + + std::fstream geofile{"data/testdet_brick.geo", std::ios::in}; + + REQUIRE(geofile.is_open()); + REQUIRE(mediafile.is_open()); + + INFO("Media and geo files open"); + + FairGeoMedia media; + media.read(mediafile); + + INFO("Media file read"); + + auto volu = std::make_unique(); + // FairGeoNode* volu = new FairGeoNode(); + volu->SetName("cave"); + volu->setVolumeType(kFairGeoTopNode); + volu->setActive(); + volu->setShape(new FairGeoBrik()); + + if (auto air = media.getMedium("air"); air) { + volu->setMedium(air); + } else { + auto generic = std::make_unique(); + volu->setMedium(generic.get()); + media.addMedium(generic.release()); + } + + volu->setPoint(0, 20000., -20000., -20000.); + volu->setPoint(1, 20000., 20000., -20000.); + volu->setPoint(2, -20000., 20000., -20000.); + volu->setPoint(3, -20000., -20000., -20000.); + volu->setPoint(4, 20000., -20000., 20000.); + volu->setPoint(5, 20000., 20000., 20000.); + volu->setPoint(6, -20000., 20000., 20000.); + volu->setPoint(7, -20000., -20000., 20000.); + + auto masterNodes = std::make_unique(); + masterNodes->Add(new FairGeoNode(*volu)); + + INFO("Master volume created"); + + FairTestGeo geo; + geo.setMasterNodes(masterNodes.get()); + geo.setShapes(new FairGeoShapes()); + + // fairroot::tests::checkGeoSetNamingConventions(geo, "testdet", 10); + + geo.read(geofile, &media); + + geo.print(); + + geofile.close(); + mediafile.close(); +} +#endif diff --git a/tests/geobase/tests_FairGeoShapes.cxx b/tests/geobase/tests_FairGeoShapes.cxx new file mode 100644 index 0000000000..5cd2559b7b --- /dev/null +++ b/tests/geobase/tests_FairGeoShapes.cxx @@ -0,0 +1,396 @@ +/******************************************************************************** + * Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "FairGeoAssembly.h" +#include "FairGeoBasicShape.h" +#include "FairGeoBrik.h" +#include "FairGeoCone.h" +#include "FairGeoCons.h" +#include "FairGeoEltu.h" +#include "FairGeoPcon.h" +#include "FairGeoPgon.h" +#include "FairGeoSphe.h" +#include "FairGeoTorus.h" +#include "FairGeoTrap.h" +#include "FairGeoTrd1.h" +#include "FairGeoTube.h" +#include "FairGeoTubs.h" +#include "FairGeoVolume.h" +#include "checks_FairGeoBasicShape.h" +#include "generate_TestInput.h" + +#include +#include + +using fairroot::tests::check_FairGeoShape_Construction; +using fairroot::tests::check_FairGeoShape_ReadWrite; + +TEST_CASE("FairGeoBasicShape") +{ + FairGeoBasicShape shape; + + check_FairGeoShape_Construction(shape, std::string{""}, 0, nullptr); +} + +TEST_CASE("FairGeoAssembly") +{ + FairGeoAssembly shape; + std::unique_ptr paramArray(new TArrayD(0)); + check_FairGeoShape_Construction(shape, std::string{"ASSEMBLY"}, 0, paramArray.get()); +} + +TEST_CASE("FairGeoBrik") +{ + // The box is defined by 3 parameters (cartesian coordinates) for each of + // the 8 corners of the box + // The data to generate the necessary input file is organized in three + // parameter vectors with 8 values each. All parameter vectors are stored + // into another vector + Int_t numPoints{8}; + Int_t numParams{3}; + std::vector x{1., 1., -1., -1., 1., 1., -1., -1.}; + std::vector y{-1., 1., 1., -1., -1., 1., 1., -1.}; + std::vector z{-1., -1., -1., -1., 1., 1., 1., 1.}; + std::vector> parameters{x, y, z}; + + FairGeoBrik shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"BOX "}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"BOX"}, numPoints, parameters); +} + +TEST_CASE("FairGeoCone") +{ + // The cone is defined by by the coordinates (x,y,z) where + // the cone begins and the inner and outer radius at that point, + // as well as the same information for the point where the cone ends. + // The parameters are groups as four points + // Point 1: x, y, z coordinate of the center of the circle at the beginning of the cone + // Point 2: inner and outer radius at the beginning of the cone + // Point 3: x, y, z coordinate of the center of the circle at the end of the cone + // Point 4: inner and outer radius at the end of the cone + // The third values of point 2 and 4 are not used and exist for technical + // reasons + Int_t numPoints{4}; + Int_t numParams{5}; + std::vector x{0., 1., 0., 2.}; + std::vector y{0., 2., 0., 3.}; + std::vector z{0., 654., 20., -765.}; + std::vector> parameters{x, y, z}; + + FairGeoCone shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"CONE"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"CONE"}, numPoints, parameters); +} + +TEST_CASE("FairGeoCons") +{ + // A cons is a cone having only a range in phi (from phi1 to phi2). + // The parameters are grouped as five points + // Point 1: x, y, z coordinate of the center of the circle at the beginning of the cons + // Point 2: inner and outer radius at the beginning of the cons + // Point 3: x, y, z coordinate of the center of the circle at the end of the cons + // Point 4: inner and outer radius at the end of the cons + // Point 5: starting angle PHI1 and ending angle PHI2 of the segment + // The third values of point 2, 4 nad 5 are not used and exist for technical + // reasons + Int_t numPoints{5}; + Int_t numParams{7}; + std::vector x{0., 1., 0., 2., 0.}; + std::vector y{0., 2., 0., 3., 180.}; + std::vector z{0., 654., 20., -765., -111.}; + std::vector> parameters{x, y, z}; + + FairGeoCons shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"CONS"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"CONS"}, numPoints, parameters); +} + +TEST_CASE("FairGeoEltu") +{ + // An eltu is an elliptical tube defined by coordinates at the beginning + // and the end of the eltu and the the two semi-axes P1 and P2. + // Point 1: x, y, z coordinate of the center of the ellipsoid at the beginning of the eltu + // Point 2: semi-axis P1 along x and semi-axis P2 along y + // point 3: x, y, z coordinate of the center of the ellipsoid at the end of the eltu + // The third values of point 1 is not used and exist for technical reasons + Int_t numPoints{3}; + Int_t numParams{3}; + std::vector x{0., 1., 0.}; + std::vector y{0., 2., 0.}; + std::vector z{0., 654., 20.}; + std::vector> parameters{x, y, z}; + + FairGeoEltu shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"ELTU"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"ELTU"}, numPoints, parameters); +} + +TEST_CASE("FairGeoPcon") +{ + // A polycone (PCON) is represented by a sequence of tubes/cones, + // glued together at defined Z planes. + // Point 1: number of planes perpendicular to the z-axis where the section is given + // Point 2: azimuthal angleat which the volume begins and opening angle of the volume + // Point 2-(2+Point 1) : z coordinate of the section + // inner radius at position z + // outer radius at position z + // The second and third value of point 1 and the third value of point 2 + // are not needed + // e.g + // 4 // number of values + // 0. 360. // unsegmented tube or cone + // -2000.000 0.000 80.000 + // -300.000 0.000 80.000 + // 0.000 0.000 11.000 + // 200.000 0.000 11.000 + Int_t numPoints{6}; + std::vector x{4., 0., -2000., -300., 0., 200.}; + std::vector y{0., 360., 0., 0., 0., 0.}; + std::vector z{0., -1., 80., 80., 11., 11.}; + std::vector> parameters{x, y, z}; + + FairGeoPcon shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + // At construction the number of points and parameters are 0 + // The values are updated when reading the shape information + std::unique_ptr paramArray(nullptr); + check_FairGeoShape_Construction(shape, std::string{"PCON"}, 0, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"PCON"}, numPoints, parameters); +} + +TEST_CASE("FairGeoPgon") +{ + // PGON are defined in the same way as PCON, the difference being just that the segments + // between consecutive Z planes are regular polygons. + // Point 1: number of planes perpendicular to the z-axis where the section is given + // Point 2: azimuthal angle at which the volume begins + // opening angle of the volume + // number of sides of the cross section between the phi limits + // (in how many sides the opening angle is subdiveded) + // Point 2-(2+Point 1) : z coordinate of the section + // inner radius at position z + // outer radius at position z + // he second and third value of point 1 are not needed + // e.g. + // 3 + // 11.25 360. 16 + // 0. 480. 880. + // 400. 480. 880. + // 800. 480. 497. + Int_t numPoints{5}; + std::vector x{3., 11.25, 0., 400., 800.}; + std::vector y{0., 360., 480., 480., 480.}; + std::vector z{0., 16., 880., 880., 497.}; + std::vector> parameters{x, y, z}; + + FairGeoPgon shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + // At construction the number of points and parameters are 0 + // The values are updated when reading the shape information + std::unique_ptr paramArray(nullptr); + check_FairGeoShape_Construction(shape, std::string{"PGON"}, 0, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"PGON"}, numPoints, parameters); +} + +TEST_CASE("FairGeoSphe") +{ + // A Sphere (SPHE) are not just balls having internal and external radii, + // but also sectors of a sphere having defined theta and phi ranges. + // Point 1: inner and outer radius of the shell + // Point2: starting and ending polar angles of the shell + // Point 3: starting and ending azimuthal angles of the shell + Int_t numPoints{3}; + Int_t numParams{6}; + std::vector val1{2., 0., 0.}; + std::vector val2{3., 180., 180.}; + std::vector> parameters{val1, val2}; + + FairGeoSphe shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"SPHE"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"SPHE"}, numPoints, parameters); +} + +TEST_CASE("FairGeoTorus") +{ + // The torus is defined by its axial radius, its inner and outer radius. + // It also can have only a range in phi. + // Point 1: axial radius + // Point 2: inner radius + // Point 3: outer radius + // Point 4: starting phi + // Point 5: phi extent + Int_t numPoints{5}; + Int_t numParams{5}; + std::vector val{10., 1., 2., 0., 180.}; + std::vector> parameters{val}; + + FairGeoTorus shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"TORUS"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"TORUS"}, numPoints, parameters); +} + +TEST_CASE("FairGeoTrap") +{ + // A trap is a general trapezoid. + // A general trapezoid is one for which the faces perpendicular to z are trapezes + // but their centers are not necessary at the same x, y coordinates. + // This shapes has 8 corners described by the x, y, z coordinates. + // The corners are counted clockwise starting at the lower left corner of + // the bottom plane. The intrinsic coordinate system of a TRAP is different + // from the one in Geant. The y-axis points from the smaller side in x-direction + // to the larger one. A TRAP not rotated in a Box has the same intrinsic coordinate + // system as the BOX. In Geant the y- and x-axis point in the opposite directions. + Int_t numPoints{8}; + Int_t numParams{11}; + std::vector x{700., 700., -700., -700., 700., 700., -700., -700.}; + std::vector y{-540., 190., 190., -540., -540., 860., 860., -540.}; + std::vector z{160., 160., 160., 160., 272., 272., 272., 272.}; + std::vector> parameters{x, y, z}; + + FairGeoTrap shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"TRAP"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"TRAP"}, numPoints, parameters); +} + +TEST_CASE("FairGeoTrd1") +{ + // A trd1 is a trapezoid with only X varying with Z. + // This shapes has 8 corners described by the x, y, z coordinates. + // The intrinsic coordinate system of a TRD1 is the same as for a TRAP. + // That's different from the definition in Geant. + // e.g. + // 60.490 -302.500 2.474 + // 372.600 470.000 2.474 + // -372.600 470.000 2.474 + // -60.490 -302.500 2.474 + // 60.490 -302.500 2.550 + // 372.600 470.000 2.550 + // -372.600 470.000 2.550 + // -60.490 -302.500 2.550 + Int_t numPoints{8}; + Int_t numParams{4}; + + std::vector x{60.49, 372.6, -372.6, -60.49, 60.49, 372.6, -372.6, -60.49}; + std::vector y{-302.5, 470., 470., -302.5, -302.5, 470., 470., -302.5}; + std::vector z{2.474, 2.474, 2.474, 2.474, 2.55, 2.55, 2.55, 2.55}; + std::vector> parameters{x, y, z}; + + FairGeoTrd1 shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"TRD1"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"TRD1"}, numPoints, parameters); +} + +TEST_CASE("FairGeoTube") +{ + // A tube is a cylindrical tube defined by coordinates at the beginning + // and the end of the tube, and the inner and outer radius of the tube. + // Point 1: x, y, z coordinate of the center of the tube at the beginning of the eltu + // Point 2: inner and outer radius of the tube + // Point 3: x, y, z coordinate of the center of the tube at the end of the tube + // The third value of point 1 is not used and exist for technical reasons + Int_t numPoints{3}; + Int_t numParams{3}; + std::vector x{0., 1., 0.}; + std::vector y{0., 2., 0.}; + std::vector z{0., 654., 20.}; + std::vector> parameters{x, y, z}; + + FairGeoTube shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"TUBE"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"TUBE"}, numPoints, parameters); +} + +TEST_CASE("FairGeoTubs") +{ + // A tubs is a tube having a range in phi. It is defined by coordinates at the beginning + // and the end of the tubs, the inner and outer radius and the starting + // and ending angles of the segment. + // Point 1: x, y, z coordinate of the center of the circle at the beginning of the tubs + // Point 2: inner and outer radius of the tubs + // point 3: x, y, z coordinate of the center of the circle at the end of the tubs + // Point 4: starting and ending angle of the segment + // The third values of point 2 and point 4 are not used and exist for technical reasons + Int_t numPoints{4}; + Int_t numParams{5}; + std::vector x{0., 1., 0., 0.}; + std::vector y{0., 2., 0., 180.}; + std::vector z{0., 654., 20., -357.}; + std::vector> parameters{x, y, z}; + + FairGeoTubs shape; + FairGeoVolume volume; + + // Check if the constructor works as expected + std::unique_ptr paramArray{new TArrayD(numParams)}; + check_FairGeoShape_Construction(shape, std::string{"TUBS"}, numPoints, paramArray.get()); + + // Check reading and writing from volume/shape parameters + check_FairGeoShape_ReadWrite(shape, volume, std::string{"TUBS"}, numPoints, parameters); +} diff --git a/test/tgeo/CMakeLists.txt b/tests/tgeo/CMakeLists.txt similarity index 100% rename from test/tgeo/CMakeLists.txt rename to tests/tgeo/CMakeLists.txt diff --git a/test/tgeo/test_tgeo_units.C b/tests/tgeo/test_tgeo_units.C similarity index 100% rename from test/tgeo/test_tgeo_units.C rename to tests/tgeo/test_tgeo_units.C diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 0000000000..4d52ac297e --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################################ +# Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH # +# # +# This software is distributed under the terms of the # +# GNU Lesser General Public Licence (LGPL) version 3, # +# copied verbatim in the file "LICENSE" # +################################################################################ + +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25) + set(declare_with_system "SYSTEM") +else() + set(declare_with_system "") +endif() + +if(BUILD_TESTING) + Include(FetchContent) + + FetchContent_Declare( + Catch2 + SOURCE_DIR ${CMAKE_SOURCE_DIR}/third_party/Catch2_v3.5.4 + # GIT_REPOSITORY https://github.com/catchorg/Catch2.git + # GIT_TAG v3.5.4 + ${declare_with_system} + ) + + FetchContent_MakeAvailable(Catch2) + + # Include `Catch` module for the `catch_discover_tests` command, see + # https://github.com/catchorg/Catch2/blob/devel/docs/cmake-integration.md#customization + list(PREPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) + include(Catch) +endif() diff --git a/third_party/Catch2_v3.5.4/.bazelrc b/third_party/Catch2_v3.5.4/.bazelrc new file mode 100644 index 0000000000..9cb0aa1b8d --- /dev/null +++ b/third_party/Catch2_v3.5.4/.bazelrc @@ -0,0 +1,11 @@ +build --enable_platform_specific_config + +build:gcc9 --cxxopt=-std=c++2a +build:gcc11 --cxxopt=-std=c++2a +build:clang13 --cxxopt=-std=c++17 +build:vs2019 --cxxopt=/std:c++17 +build:vs2022 --cxxopt=/std:c++17 + +build:windows --config=vs2022 +build:linux --config=gcc11 +build:macos --cxxopt=-std=c++2b diff --git a/third_party/Catch2_v3.5.4/.clang-format b/third_party/Catch2_v3.5.4/.clang-format new file mode 100644 index 0000000000..9efb854dd2 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.clang-format @@ -0,0 +1,45 @@ +--- +Language: Cpp +Standard: c++14 + +# Note that we cannot use IncludeIsMainRegex functionality, because it +# does not support includes in angle brackets (<>) +SortIncludes: true +IncludeBlocks: Regroup +IncludeCategories: + - Regex: + Priority: 1 + - Regex: <.*/.*\.hpp> + Priority: 2 + - Regex: <.*> + Priority: 3 + +AllowShortBlocksOnASingleLine: Always +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLambdasOnASingleLine: Inline + +AccessModifierOffset: "-4" +AlignEscapedNewlines: Left +AllowAllConstructorInitializersOnNextLine: "true" +BinPackArguments: "false" +BinPackParameters: "false" +BreakConstructorInitializers: AfterColon +ConstructorInitializerAllOnOneLineOrOnePerLine: "true" +DerivePointerAlignment: "false" +FixNamespaceComments: "true" +IndentCaseLabels: "false" +IndentPPDirectives: AfterHash +IndentWidth: "4" +NamespaceIndentation: All +PointerAlignment: Left +SpaceBeforeCtorInitializerColon: "false" +SpaceInEmptyParentheses: "false" +SpacesInParentheses: "true" +TabWidth: "4" +UseTab: Never +AlwaysBreakTemplateDeclarations: Yes +SpaceAfterTemplateKeyword: true +SortUsingDeclarations: true +ReflowComments: true diff --git a/third_party/Catch2_v3.5.4/.clang-tidy b/third_party/Catch2_v3.5.4/.clang-tidy new file mode 100644 index 0000000000..539010d95e --- /dev/null +++ b/third_party/Catch2_v3.5.4/.clang-tidy @@ -0,0 +1,81 @@ +--- +# Note: Alas, `Checks` is a string, not an array. +# Comments in the block string are not parsed and are passed in the value. +# They must thus be delimited by ',' from either side - then they are +# harmless. It's terrible, but it works. +Checks: >- + clang-diagnostic-*, + clang-analyzer-*, + -clang-analyzer-optin.core.EnumCastOutOfRange, + + bugprone-*, + -bugprone-unchecked-optional-access, + ,# This is ridiculous, as it triggers on constants, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-easily-swappable-parameters, + ,# Is not really useful, has false positives, triggers for no-noexcept move constructors ..., + -bugprone-exception-escape, + -bugprone-narrowing-conversions, + -bugprone-chained-comparison,# RIP decomposers, + + modernize-*, + -modernize-avoid-c-arrays, + -modernize-use-auto, + -modernize-use-emplace, + -modernize-use-nullptr,# it went crazy with three-way comparison operators, + -modernize-use-trailing-return-type, + -modernize-return-braced-init-list, + -modernize-concat-nested-namespaces, + -modernize-use-nodiscard, + -modernize-use-default-member-init, + -modernize-type-traits,# we need to support C++14, + -modernize-deprecated-headers, + ,# There's a lot of these and most of them are probably not useful, + -modernize-pass-by-value, + + performance-*, + -performance-enum-size, + + portability-*, + + readability-*, + -readability-braces-around-statements, + -readability-container-size-empty, + -readability-convert-member-functions-to-static, + -readability-else-after-return, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-named-parameter, + -readability-qualified-auto, + -readability-redundant-access-specifiers, + -readability-simplify-boolean-expr, + -readability-static-definition-in-anonymous-namespace, + -readability-uppercase-literal-suffix, + -readability-use-anyofallof, + -readability-avoid-return-with-void-value, + + ,# time hogs, + -bugprone-throw-keyword-missing, + -modernize-replace-auto-ptr, + -readability-identifier-naming, + + ,# We cannot use this until clang-tidy supports custom unique_ptr, + -bugprone-use-after-move, + ,# Doesn't recognize unevaluated context in CATCH_MOVE and CATCH_FORWARD, + -bugprone-macro-repeated-side-effects, +WarningsAsErrors: >- + clang-analyzer-core.*, + clang-analyzer-cplusplus.*, + clang-analyzer-security.*, + clang-analyzer-unix.*, + performance-move-const-arg, + performance-unnecessary-value-param, + readability-duplicate-include, +HeaderFilterRegex: '.*\.(c|cxx|cpp)$' +FormatStyle: none +CheckOptions: {} +... diff --git a/third_party/Catch2_v3.5.4/.conan/build.py b/third_party/Catch2_v3.5.4/.conan/build.py new file mode 100644 index 0000000000..e163d5f46d --- /dev/null +++ b/third_party/Catch2_v3.5.4/.conan/build.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os +import re +from cpt.packager import ConanMultiPackager +from cpt.ci_manager import CIManager +from cpt.printer import Printer + + +class BuilderSettings(object): + @property + def username(self): + """ Set catchorg as package's owner + """ + return os.getenv("CONAN_USERNAME", "catchorg") + + @property + def login_username(self): + """ Set Bintray login username + """ + return os.getenv("CONAN_LOGIN_USERNAME", "horenmar") + + @property + def upload(self): + """ Set Catch2 repository to be used on upload. + The upload server address could be customized by env var + CONAN_UPLOAD. If not defined, the method will check the branch name. + Only devel or CONAN_STABLE_BRANCH_PATTERN will be accepted. + The devel branch will be pushed to testing channel, because it does + not match the stable pattern. Otherwise it will upload to stable + channel. + """ + return os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/catchorg/catch2") + + @property + def upload_only_when_stable(self): + """ Force to upload when running over tag branch + """ + return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", "True").lower() in ["true", "1", "yes"] + + @property + def stable_branch_pattern(self): + """ Only upload the package the branch name is like a tag + """ + return os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+") + + @property + def reference(self): + """ Read project version from branch create Conan reference + """ + return os.getenv("CONAN_REFERENCE", "catch2/{}".format(self._version)) + + @property + def channel(self): + """ Default Conan package channel when not stable + """ + return os.getenv("CONAN_CHANNEL", "testing") + + @property + def _version(self): + """ Get version name from cmake file + """ + pattern = re.compile(r"project\(Catch2 LANGUAGES CXX VERSION (\d+\.\d+\.\d+)\)") + version = "latest" + with open("CMakeLists.txt") as file: + for line in file: + result = pattern.search(line) + if result: + version = result.group(1) + return version + + @property + def _branch(self): + """ Get branch name from CI manager + """ + printer = Printer(None) + ci_manager = CIManager(printer) + return ci_manager.get_branch() + + +if __name__ == "__main__": + settings = BuilderSettings() + builder = ConanMultiPackager( + reference=settings.reference, + channel=settings.channel, + upload=settings.upload, + upload_only_when_stable=False, + stable_branch_pattern=settings.stable_branch_pattern, + login_username=settings.login_username, + username=settings.username, + test_folder=os.path.join(".conan", "test_package")) + builder.add() + builder.run() diff --git a/third_party/Catch2_v3.5.4/.conan/test_package/CMakeLists.txt b/third_party/Catch2_v3.5.4/.conan/test_package/CMakeLists.txt new file mode 100644 index 0000000000..00a6af23df --- /dev/null +++ b/third_party/Catch2_v3.5.4/.conan/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) + +find_package(Catch2 CONFIG REQUIRED) + +add_executable(test_package test_package.cpp) +target_link_libraries(test_package Catch2::Catch2WithMain) +target_compile_features(test_package PRIVATE cxx_std_14) diff --git a/third_party/Catch2_v3.5.4/.conan/test_package/conanfile.py b/third_party/Catch2_v3.5.4/.conan/test_package/conanfile.py new file mode 100644 index 0000000000..dc03876433 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.conan/test_package/conanfile.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +from conan.tools.files import save, load +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + save(self, os.path.join(self.build_folder, "package_folder"), + self.dependencies[self.tested_reference_str].package_folder) + save(self, os.path.join(self.build_folder, "license"), + self.dependencies[self.tested_reference_str].license) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "test_package") + self.run(cmd, env="conanrun") + + package_folder = load(self, os.path.join(self.build_folder, "package_folder")) + license = load(self, os.path.join(self.build_folder, "license")) + assert os.path.isfile(os.path.join(package_folder, "licenses", "LICENSE.txt")) + assert license == 'BSL-1.0' diff --git a/third_party/Catch2_v3.5.4/.conan/test_package/test_package.cpp b/third_party/Catch2_v3.5.4/.conan/test_package/test_package.cpp new file mode 100644 index 0000000000..3c08090bf5 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.conan/test_package/test_package.cpp @@ -0,0 +1,13 @@ +#include + +int Factorial( int number ) { + return number <= 1 ? 1 : Factorial( number - 1 ) * number; +} + +TEST_CASE( "Factorial Tests", "[single-file]" ) { + REQUIRE( Factorial(0) == 1 ); + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} \ No newline at end of file diff --git a/third_party/Catch2_v3.5.4/.gitattributes b/third_party/Catch2_v3.5.4/.gitattributes new file mode 100644 index 0000000000..23f98fffa3 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.gitattributes @@ -0,0 +1,22 @@ +# This sets the default behaviour, overriding core.autocrlf +* text=auto + +# All source files should have unix line-endings in the repository, +# but convert to native line-endings on checkout +*.cpp text +*.h text +*.hpp text + +# Windows specific files should retain windows line-endings +*.sln text eol=crlf + +# Keep executable scripts with LFs so they can be run after being +# checked out on Windows +*.py text eol=lf + + +# Keep the single include header with LFs to make sure it is uploaded, +# hashed etc with LF +single_include/**/*.hpp eol=lf +# Also keep the LICENCE file with LFs for the same reason +LICENCE.txt eol=lf diff --git a/third_party/Catch2_v3.5.4/.github/FUNDING.yml b/third_party/Catch2_v3.5.4/.github/FUNDING.yml new file mode 100644 index 0000000000..9122aa8ae3 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: "horenmar" +custom: "https://www.paypal.me/horenmar" diff --git a/third_party/Catch2_v3.5.4/.github/ISSUE_TEMPLATE/bug_report.md b/third_party/Catch2_v3.5.4/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..dbeff1152f --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create an issue that documents a bug +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Reproduction steps** +Steps to reproduce the bug. + + + +**Platform information:** + + - OS: **Windows NT** + - Compiler+version: **GCC v2.9.5** + - Catch version: **v1.2.3** + + +**Additional context** +Add any other context about the problem here. diff --git a/third_party/Catch2_v3.5.4/.github/ISSUE_TEMPLATE/feature_request.md b/third_party/Catch2_v3.5.4/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..be9b9eeaec --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,14 @@ +--- +name: Feature request +about: Create an issue that requests a feature or other improvement +title: '' +labels: '' +assignees: '' + +--- + +**Description** +Describe the feature/change you request and why do you want it. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/third_party/Catch2_v3.5.4/.github/pull_request_template.md b/third_party/Catch2_v3.5.4/.github/pull_request_template.md new file mode 100644 index 0000000000..ea2b7bb5fa --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/pull_request_template.md @@ -0,0 +1,28 @@ + + + +## Description + + +## GitHub Issues + diff --git a/third_party/Catch2_v3.5.4/.github/workflows/linux-bazel-builds.yml b/third_party/Catch2_v3.5.4/.github/workflows/linux-bazel-builds.yml new file mode 100644 index 0000000000..dc826ac0d9 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/linux-bazel-builds.yml @@ -0,0 +1,24 @@ +name: Bazel build + +on: [push, pull_request] + +jobs: + build_and_test_ubuntu: + name: Linux Ubuntu 22.04 Bazel build + runs-on: ubuntu-22.04 + strategy: + matrix: + compilation_mode: [fastbuild, dbg, opt] + + steps: + - uses: actions/checkout@v4 + + - name: Mount bazel cache + uses: actions/cache@v3 + with: + path: "/home/runner/.cache/bazel" + key: bazel-ubuntu22-gcc11 + + - name: Build Catch2 + run: | + bazelisk build --compilation_mode=${{matrix.compilation_mode}} //... diff --git a/third_party/Catch2_v3.5.4/.github/workflows/linux-meson-builds.yml b/third_party/Catch2_v3.5.4/.github/workflows/linux-meson-builds.yml new file mode 100644 index 0000000000..4a6cfd5bbb --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/linux-meson-builds.yml @@ -0,0 +1,44 @@ +name: Linux builds (meson) + +on: [push, pull_request] + +jobs: + build: + name: meson ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + runs-on: ubuntu-22.04 + strategy: + matrix: + cxx: + - g++-11 + - clang++-11 + build_type: [debug, release] + std: [14, 17] + include: + - cxx: clang++-11 + other_pkgs: clang-11 + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}} + + - name: Configure build + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: -std=c++${{matrix.std}} ${{matrix.cxxflags}} + # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. + # This is important + run: | + meson -Dbuildtype=${{matrix.build_type}} ${{runner.workspace}}/meson-build + + - name: Build tests + lib + working-directory: ${{runner.workspace}}/meson-build + run: ninja + + - name: Run tests + working-directory: ${{runner.workspace}}/meson-build + run: | + meson test --verbose diff --git a/third_party/Catch2_v3.5.4/.github/workflows/linux-other-builds.yml b/third_party/Catch2_v3.5.4/.github/workflows/linux-other-builds.yml new file mode 100644 index 0000000000..6993c8159c --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/linux-other-builds.yml @@ -0,0 +1,154 @@ +# The builds in this file are more complex (e.g. they need custom CMake +# configuration) and thus are unsuitable to the simple build matrix +# approach used in simple-builds +name: Linux builds (complex) + +on: [push, pull_request] + +jobs: + build: + name: ${{matrix.build_description}}, ${{matrix.cxx}}, C++${{matrix.std}} ${{matrix.build_type}} + runs-on: ubuntu-20.04 + strategy: + matrix: + # We add builds one by one in this case, because there are no + # dimensions that are shared across the builds + include: + + # Single surrogate header build + - cxx: clang++-10 + build_description: Surrogates build + build_type: Debug + std: 14 + other_pkgs: clang-10 + cmake_configurations: -DCATCH_BUILD_SURROGATES=ON + + # Extras and examples with gcc-7 + - cxx: g++-7 + build_description: Extras + Examples + build_type: Debug + std: 14 + other_pkgs: g++-7 + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON + - cxx: g++-7 + build_description: Extras + Examples + build_type: Release + std: 14 + other_pkgs: g++-7 + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON + + # Extras and examples with Clang-10 + - cxx: clang++-10 + build_description: Extras + Examples + build_type: Debug + std: 17 + other_pkgs: clang-10 + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON + - cxx: clang++-10 + build_description: Extras + Examples + build_type: Release + std: 17 + other_pkgs: clang-10 + cmake_configurations: -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON + + # Configure tests with Clang-10 + - cxx: clang++-10 + build_description: CMake configuration tests + build_type: Debug + std: 14 + other_pkgs: clang-10 + cmake_configurations: -DCATCH_ENABLE_CONFIGURE_TESTS=ON + + # Valgrind test Clang-10 + - cxx: clang++-10 + build_description: Valgrind tests + build_type: Debug + std: 14 + other_pkgs: clang-10 valgrind + cmake_configurations: -DMEMORYCHECK_COMMAND=`which valgrind` -DMEMORYCHECK_COMMAND_OPTIONS="-q --track-origins=yes --leak-check=full --num-callers=50 --show-leak-kinds=definite --error-exitcode=1" + other_ctest_args: -T memcheck -LE uses-python + + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{matrix.cxxflags}} + # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. + # This is important + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + ${{matrix.cmake_configurations}} \ + -G Ninja + + - name: Build tests + lib + working-directory: ${{runner.workspace}}/build + run: ninja + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}}/build + run: ctest -C ${{matrix.build_type}} -j `nproc` ${{matrix.other_ctest_args}} + clang-tidy: + name: clang-tidy ${{matrix.version}}, ${{matrix.build_description}}, C++${{matrix.std}} ${{matrix.build_type}} + runs-on: ubuntu-22.04 + strategy: + matrix: + include: + - version: "15" + build_description: all + build_type: Debug + std: 17 + other_pkgs: '' + cmake_configurations: -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y ninja-build clang-${{matrix.version}} clang-tidy-${{matrix.version}} ${{matrix.other_pkgs}} + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: clang++-${{matrix.version}} + CXXFLAGS: ${{matrix.cxxflags}} + # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. + # This is important + run: | + clangtidy="clang-tidy-${{matrix.version}};-use-color" + # Use a dummy compiler/linker/ar/ranlib to effectively disable the + # compilation and only run clang-tidy. + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + -DCMAKE_CXX_CLANG_TIDY="$clangtidy" \ + -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/true \ + -DCMAKE_AR=/usr/bin/true \ + -DCMAKE_CXX_COMPILER_AR=/usr/bin/true \ + -DCMAKE_RANLIB=/usr/bin/true \ + -DCMAKE_CXX_LINK_EXECUTABLE=/usr/bin/true \ + ${{matrix.cmake_configurations}} \ + -G Ninja + + - name: Run clang-tidy + working-directory: ${{runner.workspace}}/build + run: ninja diff --git a/third_party/Catch2_v3.5.4/.github/workflows/linux-simple-builds.yml b/third_party/Catch2_v3.5.4/.github/workflows/linux-simple-builds.yml new file mode 100644 index 0000000000..4cca31619e --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/linux-simple-builds.yml @@ -0,0 +1,123 @@ +name: Linux builds (basic) + +on: [push, pull_request] + +jobs: + build: + name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + runs-on: ubuntu-20.04 + strategy: + matrix: + cxx: + - g++-5 + - g++-6 + - g++-7 + - g++-8 + - g++-9 + - g++-10 + - clang++-6.0 + - clang++-7 + - clang++-8 + - clang++-9 + - clang++-10 + build_type: [Debug, Release] + std: [14] + include: + - cxx: g++-5 + other_pkgs: g++-5 + - cxx: g++-6 + other_pkgs: g++-6 + - cxx: g++-7 + other_pkgs: g++-7 + - cxx: g++-8 + other_pkgs: g++-8 + - cxx: g++-9 + other_pkgs: g++-9 + - cxx: g++-10 + other_pkgs: g++-10 + - cxx: clang++-6.0 + other_pkgs: clang-6.0 + - cxx: clang++-7 + other_pkgs: clang-7 + - cxx: clang++-8 + other_pkgs: clang-8 + - cxx: clang++-9 + other_pkgs: clang-9 + - cxx: clang++-10 + other_pkgs: clang-10 + # Clang 6 + C++17 + # does not work with the default libstdc++ version thanks + # to a disagreement on variant implementation. + # - cxx: clang++-6.0 + # build_type: Debug + # std: 17 + # other_pkgs: clang-6.0 + # - cxx: clang++-6.0 + # build_type: Release + # std: 17 + # other_pkgs: clang-6.0 + # Clang 10 + C++17 + - cxx: clang++-10 + build_type: Debug + std: 17 + other_pkgs: clang-10 + - cxx: clang++-10 + build_type: Release + std: 17 + other_pkgs: clang-10 + - cxx: clang++-10 + build_type: Debug + std: 20 + other_pkgs: clang-10 + - cxx: clang++-10 + build_type: Release + std: 20 + other_pkgs: clang-10 + - cxx: g++-10 + build_type: Debug + std: 20 + other_pkgs: g++-10 + - cxx: g++-10 + build_type: Release + std: 20 + other_pkgs: g++-10 + + steps: + - uses: actions/checkout@v4 + + - name: Add repositories for older GCC + run: | + sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic main' + sudo apt-add-repository 'deb http://azure.archive.ubuntu.com/ubuntu/ bionic universe' + if: ${{ matrix.cxx == 'g++-5' || matrix.cxx == 'g++-6' }} + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{matrix.cxxflags}} + # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. + # This is important + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + -G Ninja + + - name: Build tests + lib + working-directory: ${{runner.workspace}}/build + run: ninja + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}}/build + run: ctest -C ${{matrix.build_type}} -j `nproc` diff --git a/third_party/Catch2_v3.5.4/.github/workflows/mac-builds-m1.yml b/third_party/Catch2_v3.5.4/.github/workflows/mac-builds-m1.yml new file mode 100644 index 0000000000..4820466d40 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/mac-builds-m1.yml @@ -0,0 +1,44 @@ +name: M1 Mac builds + +on: [push, pull_request] + +jobs: + build: + runs-on: macos-14 + strategy: + matrix: + cxx: + - clang++ + build_type: [Debug, Release] + std: [14, 17] + include: + - build_type: Debug + examples: ON + extra_tests: ON + + steps: + - uses: actions/checkout@v4 + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{matrix.cxxflags}} + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \ + -DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}} + + - name: Build tests + lib + working-directory: ${{runner.workspace}}/build + run: make -j `sysctl -n hw.ncpu` + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}}/build + run: ctest -C ${{matrix.build_type}} -j `sysctl -n hw.ncpu` diff --git a/third_party/Catch2_v3.5.4/.github/workflows/mac-builds.yml b/third_party/Catch2_v3.5.4/.github/workflows/mac-builds.yml new file mode 100644 index 0000000000..259d8b367b --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/mac-builds.yml @@ -0,0 +1,51 @@ +name: Mac builds + +on: [push, pull_request] + +jobs: + build: + # macos-12 updated to a toolchain that crashes when linking the + # test binary. This seems to be a known bug in that version, + # and will eventually get fixed in an update. After that, we can go + # back to newer macos images. + runs-on: macos-11 + strategy: + matrix: + cxx: + - g++-11 + - clang++ + build_type: [Debug, Release] + std: [14, 17] + include: + - build_type: Debug + examples: ON + extra_tests: ON + + steps: + - uses: actions/checkout@v4 + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{matrix.cxxflags}} + # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. + # This is important + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \ + -DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}} + + - name: Build tests + lib + working-directory: ${{runner.workspace}}/build + run: make -j `sysctl -n hw.ncpu` + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}}/build + run: ctest -C ${{matrix.build_type}} -j `sysctl -n hw.ncpu` diff --git a/third_party/Catch2_v3.5.4/.github/workflows/package-manager-builds.yaml b/third_party/Catch2_v3.5.4/.github/workflows/package-manager-builds.yaml new file mode 100644 index 0000000000..6d90d14054 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/package-manager-builds.yaml @@ -0,0 +1,31 @@ +name: Package Manager Builds + +on: [push, pull_request] + +jobs: + conan_builds: + name: Conan ${{matrix.conan_version}} + runs-on: ubuntu-20.04 + strategy: + matrix: + conan_version: + - '1.63' + - '2.1' + + include: + # Conan 1 has default profiles installed + - conan_version: '1.63' + profile_generate: 'false' + + steps: + - uses: actions/checkout@v4 + + - name: Install conan + run: pip install conan==${{matrix.conan_version}} + + - name: Setup conan profiles + if: matrix.profile_generate != 'false' + run: conan profile detect + + - name: Run conan package create + run: conan create . -tf .conan/test_package diff --git a/third_party/Catch2_v3.5.4/.github/workflows/validate-header-guards.yml b/third_party/Catch2_v3.5.4/.github/workflows/validate-header-guards.yml new file mode 100644 index 0000000000..fa9d1574ba --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/validate-header-guards.yml @@ -0,0 +1,36 @@ +name: Check header guards + +on: [push, pull_request] + +jobs: + build: + # Set the type of machine to run on + runs-on: ubuntu-20.04 + steps: + + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Setup Dependencies + uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install checkguard + run: pip install guardonce + + - name: Check that include guards are properly named + run: | + wrong_files=$(checkguard -r src/catch2/ -p "name | append _INCLUDED | upper") + if [[ $wrong_files ]]; then + echo "Files with wrong header guard:" + echo $wrong_files + exit 1 + fi + + - name: Check that there are no duplicated filenames + run: | + ./tools/scripts/checkDuplicateFilenames.py + + - name: Check that all source files have the correct license header + run: | + ./tools/scripts/checkLicense.py diff --git a/third_party/Catch2_v3.5.4/.github/workflows/windows-simple-builds.yml b/third_party/Catch2_v3.5.4/.github/workflows/windows-simple-builds.yml new file mode 100644 index 0000000000..5fb7b8fe79 --- /dev/null +++ b/third_party/Catch2_v3.5.4/.github/workflows/windows-simple-builds.yml @@ -0,0 +1,37 @@ +name: Windows builds (basic) + +on: [push, pull_request] + +jobs: + build: + name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}} + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [windows-2019, windows-2022] + platform: [Win32, x64] + build_type: [Debug, Release] + std: [14, 17] + steps: + - uses: actions/checkout@v4 + + - name: Configure build + working-directory: ${{runner.workspace}} + run: | + cmake -S $Env:GITHUB_WORKSPACE ` + -B ${{runner.workspace}}/build ` + -DCMAKE_CXX_STANDARD=${{matrix.std}} ` + -A ${{matrix.platform}} ` + --preset all-tests + + - name: Build tests + working-directory: ${{runner.workspace}} + run: cmake --build build --config ${{matrix.build_type}} --parallel %NUMBER_OF_PROCESSORS% + shell: cmd + + - name: Run tests + working-directory: ${{runner.workspace}}/build + env: + CTEST_OUTPUT_ON_FAILURE: 1 + run: ctest -C ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS% + shell: cmd diff --git a/third_party/Catch2_v3.5.4/.gitignore b/third_party/Catch2_v3.5.4/.gitignore new file mode 100644 index 0000000000..4ed76b0b3f --- /dev/null +++ b/third_party/Catch2_v3.5.4/.gitignore @@ -0,0 +1,38 @@ +*.build +!meson.build +*.pbxuser +*.mode1v3 +*.ncb +*.suo +Debug +Release +*.user +*.xcuserstate +.DS_Store +xcuserdata +CatchSelfTest.xcscheme +Breakpoints.xcbkptlist +UpgradeLog.XML +Resources/DWARF +projects/Generated +*.pyc +DerivedData +*.xccheckout +Build +.idea +.vs +.vscode +cmake-build-* +benchmark-dir +.conan/test_package/build +.conan/test_package/CMakeUserPresets.json +bazel-* +build-fuzzers +debug-build +.vscode +msvc-sln* +# Currently we use Doxygen for dep graphs and the full docs are only slowly +# being filled in, so we definitely do not want git to deal with the docs. +docs/doxygen +*.cache +compile_commands.json diff --git a/third_party/Catch2_v3.5.4/BUILD.bazel b/third_party/Catch2_v3.5.4/BUILD.bazel new file mode 100644 index 0000000000..c51bf57e70 --- /dev/null +++ b/third_party/Catch2_v3.5.4/BUILD.bazel @@ -0,0 +1,95 @@ +load("@bazel_skylib//rules:expand_template.bzl", "expand_template") + +expand_template( + name = "catch_user_config", + out = "catch2/catch_user_config.hpp", + substitutions = { + "@CATCH_CONFIG_CONSOLE_WIDTH@": "80", + "@CATCH_CONFIG_DEFAULT_REPORTER@": "console", + "#cmakedefine CATCH_CONFIG_ANDROID_LOGWRITE": "", + "#cmakedefine CATCH_CONFIG_BAZEL_SUPPORT": "#define CATCH_CONFIG_BAZEL_SUPPORT", + "#cmakedefine CATCH_CONFIG_COLOUR_WIN32": "", + "#cmakedefine CATCH_CONFIG_COUNTER": "", + "#cmakedefine CATCH_CONFIG_CPP11_TO_STRING": "", + "#cmakedefine CATCH_CONFIG_CPP17_BYTE": "", + "#cmakedefine CATCH_CONFIG_CPP17_OPTIONAL": "", + "#cmakedefine CATCH_CONFIG_CPP17_STRING_VIEW": "", + "#cmakedefine CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS": "", + "#cmakedefine CATCH_CONFIG_CPP17_VARIANT": "", + "#cmakedefine CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER": "", + "#cmakedefine CATCH_CONFIG_DISABLE_EXCEPTIONS": "", + "#cmakedefine CATCH_CONFIG_DISABLE_STRINGIFICATION": "", + "#cmakedefine CATCH_CONFIG_DISABLE": "", + "#cmakedefine CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS": "", + "#cmakedefine CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER": "", + "#cmakedefine CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER": "", + "#cmakedefine CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER": "", + "#cmakedefine CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER": "", + "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_REDIRECT": "", + "#cmakedefine CATCH_CONFIG_FALLBACK_STRINGIFIER @CATCH_CONFIG_FALLBACK_STRINGIFIER@": "", + "#cmakedefine CATCH_CONFIG_FAST_COMPILE": "", + "#cmakedefine CATCH_CONFIG_GETENV": "", + "#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER": "", + "#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "", + "#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "", + "#cmakedefine CATCH_CONFIG_NO_COUNTER": "", + "#cmakedefine CATCH_CONFIG_NO_CPP11_TO_STRING": "", + "#cmakedefine CATCH_CONFIG_NO_CPP17_BYTE": "", + "#cmakedefine CATCH_CONFIG_NO_CPP17_OPTIONAL": "", + "#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW": "", + "#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS": "", + "#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT": "", + "#cmakedefine CATCH_CONFIG_NO_GETENV": "", + "#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "", + "#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "", + "#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "", + "#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "", + "#cmakedefine CATCH_CONFIG_NO_WCHAR": "", + "#cmakedefine CATCH_CONFIG_NO_WINDOWS_SEH": "", + "#cmakedefine CATCH_CONFIG_NOSTDOUT": "", + "#cmakedefine CATCH_CONFIG_POSIX_SIGNALS": "", + "#cmakedefine CATCH_CONFIG_PREFIX_ALL": "", + "#cmakedefine CATCH_CONFIG_PREFIX_MESSAGES": "", + "#cmakedefine CATCH_CONFIG_SHARED_LIBRARY": "", + "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "", + "#cmakedefine CATCH_CONFIG_USE_ASYNC": "", + "#cmakedefine CATCH_CONFIG_WCHAR": "", + "#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG": "", + "#cmakedefine CATCH_CONFIG_WINDOWS_SEH": "", + }, + template = "src/catch2/catch_user_config.hpp.in", +) + +# Generated header library, modifies the include prefix to account for +# generation path so that we can include +# correctly. +cc_library( + name = "catch2_generated", + hdrs = ["catch2/catch_user_config.hpp"], + include_prefix = ".", # to manipulate -I of dependenices + visibility = ["//visibility:public"], +) + +# Static library, without main. +cc_library( + name = "catch2", + srcs = glob( + ["src/catch2/**/*.cpp"], + exclude = ["src/catch2/internal/catch_main.cpp"], + ), + hdrs = glob(["src/catch2/**/*.hpp"]), + includes = ["src/"], + linkstatic = True, + visibility = ["//visibility:public"], + deps = [":catch2_generated"], +) + +# Static library, with main. +cc_library( + name = "catch2_main", + srcs = ["src/catch2/internal/catch_main.cpp"], + includes = ["src/"], + linkstatic = True, + visibility = ["//visibility:public"], + deps = [":catch2"], +) diff --git a/third_party/Catch2_v3.5.4/CMake/Catch2Config.cmake.in b/third_party/Catch2_v3.5.4/CMake/Catch2Config.cmake.in new file mode 100644 index 0000000000..c485219cdb --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/Catch2Config.cmake.in @@ -0,0 +1,10 @@ +@PACKAGE_INIT@ + + +# Avoid repeatedly including the targets +if(NOT TARGET Catch2::Catch2) + # Provide path for scripts + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + + include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake) +endif() diff --git a/third_party/Catch2_v3.5.4/CMake/CatchConfigOptions.cmake b/third_party/Catch2_v3.5.4/CMake/CatchConfigOptions.cmake new file mode 100644 index 0000000000..6eae220dfc --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/CatchConfigOptions.cmake @@ -0,0 +1,89 @@ + +# Copyright Catch2 Authors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# SPDX-License-Identifier: BSL-1.0 + +## +# This file contains options that are materialized into the Catch2 +# compiled library. All of them default to OFF, as even the positive +# forms correspond to the user _forcing_ them to ON, while being OFF +# means that Catch2 can use its own autodetection. +# +# For detailed docs look into docs/configuration.md + + +macro(AddOverridableConfigOption OptionBaseName) + option(CATCH_CONFIG_${OptionBaseName} "Read docs/configuration.md for details" OFF) + option(CATCH_CONFIG_NO_${OptionBaseName} "Read docs/configuration.md for details" OFF) + mark_as_advanced(CATCH_CONFIG_${OptionBaseName} CATCH_CONFIG_NO_${OptionBaseName}) +endmacro() + +macro(AddConfigOption OptionBaseName) + option(CATCH_CONFIG_${OptionBaseName} "Read docs/configuration.md for details" OFF) + mark_as_advanced(CATCH_CONFIG_${OptionBaseName}) +endmacro() + +set(_OverridableOptions + "ANDROID_LOGWRITE" + "BAZEL_SUPPORT" + "COLOUR_WIN32" + "COUNTER" + "CPP11_TO_STRING" + "CPP17_BYTE" + "CPP17_OPTIONAL" + "CPP17_STRING_VIEW" + "CPP17_UNCAUGHT_EXCEPTIONS" + "CPP17_VARIANT" + "GLOBAL_NEXTAFTER" + "POSIX_SIGNALS" + "USE_ASYNC" + "WCHAR" + "WINDOWS_SEH" + "GETENV" + "EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT" +) + +foreach(OptionName ${_OverridableOptions}) + AddOverridableConfigOption(${OptionName}) +endforeach() + +set(_OtherConfigOptions + "DISABLE_EXCEPTIONS" + "DISABLE_EXCEPTIONS_CUSTOM_HANDLER" + "DISABLE" + "DISABLE_STRINGIFICATION" + "ENABLE_ALL_STRINGMAKERS" + "ENABLE_OPTIONAL_STRINGMAKER" + "ENABLE_PAIR_STRINGMAKER" + "ENABLE_TUPLE_STRINGMAKER" + "ENABLE_VARIANT_STRINGMAKER" + "EXPERIMENTAL_REDIRECT" + "FAST_COMPILE" + "NOSTDOUT" + "PREFIX_ALL" + "PREFIX_MESSAGES" + "WINDOWS_CRTDBG" +) + + +foreach(OptionName ${_OtherConfigOptions}) + AddConfigOption(${OptionName}) +endforeach() +if(DEFINED BUILD_SHARED_LIBS) + set(CATCH_CONFIG_SHARED_LIBRARY ${BUILD_SHARED_LIBS}) +else() + set(CATCH_CONFIG_SHARED_LIBRARY "") +endif() + +set(CATCH_CONFIG_DEFAULT_REPORTER "console" CACHE STRING "Read docs/configuration.md for details. The name of the reporter should be without quotes.") +set(CATCH_CONFIG_CONSOLE_WIDTH "80" CACHE STRING "Read docs/configuration.md for details. Must form a valid integer literal.") + +mark_as_advanced(CATCH_CONFIG_SHARED_LIBRARY CATCH_CONFIG_DEFAULT_REPORTER CATCH_CONFIG_CONSOLE_WIDTH) + +# There is no good way to both turn this into a CMake cache variable, +# and keep reasonable default semantics inside the project. Thus we do +# not define it and users have to provide it as an outside variable. +#set(CATCH_CONFIG_FALLBACK_STRINGIFIER "" CACHE STRING "Read docs/configuration.md for details.") diff --git a/third_party/Catch2_v3.5.4/CMake/CatchMiscFunctions.cmake b/third_party/Catch2_v3.5.4/CMake/CatchMiscFunctions.cmake new file mode 100644 index 0000000000..84bd7cc79f --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/CatchMiscFunctions.cmake @@ -0,0 +1,121 @@ + +# Copyright Catch2 Authors +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +# SPDX-License-Identifier: BSL-1.0 + +include(CheckCXXCompilerFlag) +function(add_cxx_flag_if_supported_to_targets flagname targets) + string(MAKE_C_IDENTIFIER ${flagname} flag_identifier ) + check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flag_identifier}) + + if (HAVE_FLAG_${flag_identifier}) + foreach(target ${targets}) + target_compile_options(${target} PRIVATE ${flagname}) + endforeach() + endif() +endfunction() + +# Assumes that it is only called for development builds, where warnings +# and Werror is desired, so it also enables Werror. +function(add_warnings_to_targets targets) + LIST(LENGTH targets TARGETS_LEN) + # For now we just assume 2 possibilities: msvc and msvc-like compilers, + # and other. + if (MSVC) + foreach(target ${targets}) + # Force MSVC to consider everything as encoded in utf-8 + target_compile_options( ${target} PRIVATE /utf-8 ) + # Enable Werror equivalent + if (CATCH_ENABLE_WERROR) + target_compile_options( ${target} PRIVATE /WX ) + endif() + + # MSVC is currently handled specially + if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) + STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level + target_compile_options( ${target} PRIVATE /w44265 /w44061 /w44062 /w45038 ) + endif() + endforeach() + + endif() + + if (NOT MSVC) + set(CHECKED_WARNING_FLAGS + "-Wabsolute-value" + "-Wall" + "-Wcall-to-pure-virtual-from-ctor-dtor" + "-Wcast-align" + "-Wcatch-value" + "-Wdangling" + "-Wdeprecated" + "-Wdeprecated-register" + "-Wexceptions" + "-Wexit-time-destructors" + "-Wextra" + "-Wextra-semi" + "-Wfloat-equal" + "-Wglobal-constructors" + "-Winit-self" + "-Wmisleading-indentation" + "-Wmismatched-new-delete" + "-Wmismatched-return-types" + "-Wmismatched-tags" + "-Wmissing-braces" + "-Wmissing-declarations" + "-Wmissing-noreturn" + "-Wmissing-prototypes" + "-Wmissing-variable-declarations" + "-Wnull-dereference" + "-Wold-style-cast" + "-Woverloaded-virtual" + "-Wparentheses" + "-Wpedantic" + "-Wredundant-decls" + "-Wreorder" + "-Wreturn-std-move" + "-Wshadow" + "-Wstrict-aliasing" + "-Wsubobject-linkage" + "-Wsuggest-destructor-override" + "-Wsuggest-override" + "-Wundef" + "-Wuninitialized" + "-Wunneeded-internal-declaration" + "-Wunreachable-code-aggressive" + "-Wunused" + "-Wunused-function" + "-Wunused-parameter" + "-Wvla" + "-Wweak-vtables" + + # This is a useful warning, but our tests sometimes rely on + # functions being present, but not picked (e.g. various checks + # for stringification implementation ordering). + # Ergo, we should use it every now and then, but we cannot + # enable it by default. + # "-Wunused-member-function" + ) + foreach(warning ${CHECKED_WARNING_FLAGS}) + add_cxx_flag_if_supported_to_targets(${warning} "${targets}") + endforeach() + + if (CATCH_ENABLE_WERROR) + foreach(target ${targets}) + # Enable Werror equivalent + target_compile_options( ${target} PRIVATE -Werror ) + endforeach() + endif() + endif() +endfunction() + +# Adds flags required for reproducible build to the target +# Currently only supports GCC and Clang +function(add_build_reproducibility_settings target) + # Make the build reproducible on versions of g++ and clang that supports -ffile-prefix-map + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + add_cxx_flag_if_supported_to_targets("-ffile-prefix-map=${CATCH_DIR}/=" "${target}") + endif() +endfunction() diff --git a/third_party/Catch2_v3.5.4/CMake/FindGcov.cmake b/third_party/Catch2_v3.5.4/CMake/FindGcov.cmake new file mode 100644 index 0000000000..414171134c --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/FindGcov.cmake @@ -0,0 +1,157 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# include required Modules +include(FindPackageHandleStandardArgs) + + +# Search for gcov binary. +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY}) + +get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach (LANG ${ENABLED_LANGUAGES}) + # Gcov evaluation is dependent on the used compiler. Check gcov support for + # each compiler that is used. If gcov binary was already found for this + # compiler, do not try to find it again. + if (NOT GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN) + get_filename_component(COMPILER_PATH "${CMAKE_${LANG}_COMPILER}" PATH) + + if ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "GNU") + # Some distributions like OSX (homebrew) ship gcov with the compiler + # version appended as gcov-x. To find this binary we'll build the + # suggested binary name with the compiler version. + string(REGEX MATCH "^[0-9]+" GCC_VERSION + "${CMAKE_${LANG}_COMPILER_VERSION}") + + find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov + HINTS ${COMPILER_PATH}) + + elseif ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Clang") + # Some distributions like Debian ship llvm-cov with the compiler + # version appended as llvm-cov-x.y. To find this binary we'll build + # the suggested binary name with the compiler version. + string(REGEX MATCH "^[0-9]+.[0-9]+" LLVM_VERSION + "${CMAKE_${LANG}_COMPILER_VERSION}") + + # llvm-cov prior version 3.5 seems to be not working with coverage + # evaluation tools, but these versions are compatible with the gcc + # gcov tool. + if(LLVM_VERSION VERSION_GREATER 3.4) + find_program(LLVM_COV_BIN NAMES "llvm-cov-${LLVM_VERSION}" + "llvm-cov" HINTS ${COMPILER_PATH}) + mark_as_advanced(LLVM_COV_BIN) + + if (LLVM_COV_BIN) + find_program(LLVM_COV_WRAPPER "llvm-cov-wrapper" PATHS + ${CMAKE_MODULE_PATH}) + if (LLVM_COV_WRAPPER) + set(GCOV_BIN "${LLVM_COV_WRAPPER}" CACHE FILEPATH "") + + # set additional parameters + set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV + "LLVM_COV_BIN=${LLVM_COV_BIN}" CACHE STRING + "Environment variables for llvm-cov-wrapper.") + mark_as_advanced(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV) + endif () + endif () + endif () + + if (NOT GCOV_BIN) + # Fall back to gcov binary if llvm-cov was not found or is + # incompatible. This is the default on OSX, but may crash on + # recent Linux versions. + find_program(GCOV_BIN gcov HINTS ${COMPILER_PATH}) + endif () + endif () + + + if (GCOV_BIN) + set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN "${GCOV_BIN}" CACHE STRING + "${LANG} gcov binary.") + + if (NOT CMAKE_REQUIRED_QUIET) + message("-- Found gcov evaluation for " + "${CMAKE_${LANG}_COMPILER_ID}: ${GCOV_BIN}") + endif() + + unset(GCOV_BIN CACHE) + endif () + endif () +endforeach () + + + + +# Add a new global target for all gcov targets. This target could be used to +# generate the gcov files for the whole project instead of calling -gcov +# for each target. +if (NOT TARGET gcov) + add_custom_target(gcov) +endif (NOT TARGET gcov) + + + +# This function will add gcov evaluation for target . Only sources of +# this target will be evaluated and no dependencies will be added. It will call +# Gcov on any source file of once and store the gcov file in the same +# directory. +function (add_gcov_target TNAME) + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(BUFFER "") + foreach(FILE ${SOURCES}) + get_filename_component(FILE_PATH "${TDIR}/${FILE}" PATH) + + # call gcov + add_custom_command(OUTPUT ${TDIR}/${FILE}.gcov + COMMAND ${GCOV_ENV} ${GCOV_BIN} ${TDIR}/${FILE}.gcno > /dev/null + DEPENDS ${TNAME} ${TDIR}/${FILE}.gcno + WORKING_DIRECTORY ${FILE_PATH} + ) + + list(APPEND BUFFER ${TDIR}/${FILE}.gcov) + endforeach() + + + # add target for gcov evaluation of + add_custom_target(${TNAME}-gcov DEPENDS ${BUFFER}) + + # add evaluation target to the global gcov target. + add_dependencies(gcov ${TNAME}-gcov) +endfunction (add_gcov_target) diff --git a/third_party/Catch2_v3.5.4/CMake/FindLcov.cmake b/third_party/Catch2_v3.5.4/CMake/FindLcov.cmake new file mode 100644 index 0000000000..beb925ae06 --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/FindLcov.cmake @@ -0,0 +1,354 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# configuration +set(LCOV_DATA_PATH "${CMAKE_BINARY_DIR}/lcov/data") +set(LCOV_DATA_PATH_INIT "${LCOV_DATA_PATH}/init") +set(LCOV_DATA_PATH_CAPTURE "${LCOV_DATA_PATH}/capture") +set(LCOV_HTML_PATH "${CMAKE_BINARY_DIR}/lcov/html") + + + + +# Search for Gcov which is used by Lcov. +find_package(Gcov) + + + + +# This function will add lcov evaluation for target . Only sources of +# this target will be evaluated and no dependencies will be added. It will call +# geninfo on any source file of once and store the info file in the same +# directory. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (add_lcov_target TNAME) + if (LCOV_FOUND) + # capture initial coverage data + lcov_capture_initial_tgt(${TNAME}) + + # capture coverage data after execution + lcov_capture_tgt(${TNAME}) + endif () +endfunction (add_lcov_target) + + + + +# include required Modules +include(FindPackageHandleStandardArgs) + +# Search for required lcov binaries. +find_program(LCOV_BIN lcov) +find_program(GENINFO_BIN geninfo) +find_program(GENHTML_BIN genhtml) +find_package_handle_standard_args(lcov + REQUIRED_VARS LCOV_BIN GENINFO_BIN GENHTML_BIN +) + +# enable genhtml C++ demangeling, if c++filt is found. +set(GENHTML_CPPFILT_FLAG "") +find_program(CPPFILT_BIN c++filt) +if (NOT CPPFILT_BIN STREQUAL "") + set(GENHTML_CPPFILT_FLAG "--demangle-cpp") +endif (NOT CPPFILT_BIN STREQUAL "") + +# enable no-external flag for lcov, if available. +if (GENINFO_BIN AND NOT DEFINED GENINFO_EXTERN_FLAG) + set(FLAG "") + execute_process(COMMAND ${GENINFO_BIN} --help OUTPUT_VARIABLE GENINFO_HELP) + string(REGEX MATCH "external" GENINFO_RES "${GENINFO_HELP}") + if (GENINFO_RES) + set(FLAG "--no-external") + endif () + + set(GENINFO_EXTERN_FLAG "${FLAG}" + CACHE STRING "Geninfo flag to exclude system sources.") +endif () + +# If Lcov was not found, exit module now. +if (NOT LCOV_FOUND) + return() +endif (NOT LCOV_FOUND) + + + + +# Create directories to be used. +file(MAKE_DIRECTORY ${LCOV_DATA_PATH_INIT}) +file(MAKE_DIRECTORY ${LCOV_DATA_PATH_CAPTURE}) + +set(LCOV_REMOVE_PATTERNS "") + +# This function will merge lcov files to a single target file. Additional lcov +# flags may be set with setting LCOV_EXTRA_FLAGS before calling this function. +function (lcov_merge_files OUTFILE ...) + # Remove ${OUTFILE} from ${ARGV} and generate lcov parameters with files. + list(REMOVE_AT ARGV 0) + + # Generate merged file. + string(REPLACE "${CMAKE_BINARY_DIR}/" "" FILE_REL "${OUTFILE}") + add_custom_command(OUTPUT "${OUTFILE}.raw" + COMMAND cat ${ARGV} > ${OUTFILE}.raw + DEPENDS ${ARGV} + COMMENT "Generating ${FILE_REL}" + ) + + add_custom_command(OUTPUT "${OUTFILE}" + COMMAND ${LCOV_BIN} --quiet -a ${OUTFILE}.raw --output-file ${OUTFILE} + --base-directory ${PROJECT_SOURCE_DIR} ${LCOV_EXTRA_FLAGS} + COMMAND ${LCOV_BIN} --quiet -r ${OUTFILE} ${LCOV_REMOVE_PATTERNS} + --output-file ${OUTFILE} ${LCOV_EXTRA_FLAGS} + DEPENDS ${OUTFILE}.raw + COMMENT "Post-processing ${FILE_REL}" + ) +endfunction () + + + + +# Add a new global target to generate initial coverage reports for all targets. +# This target will be used to generate the global initial info file, which is +# used to gather even empty report data. +if (NOT TARGET lcov-capture-init) + add_custom_target(lcov-capture-init) + set(LCOV_CAPTURE_INIT_FILES "" CACHE INTERNAL "") +endif (NOT TARGET lcov-capture-init) + + +# This function will add initial capture of coverage data for target , +# which is needed to get also data for objects, which were not loaded at +# execution time. It will call geninfo for every source file of once and +# store the info file in the same directory. +function (lcov_capture_initial_tgt TNAME) + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + set(GENINFO_FILES "") + foreach(FILE ${SOURCES}) + # generate empty coverage files + set(OUTFILE "${TDIR}/${FILE}.info.init") + list(APPEND GENINFO_FILES ${OUTFILE}) + + add_custom_command(OUTPUT ${OUTFILE} COMMAND ${GCOV_ENV} ${GENINFO_BIN} + --quiet --base-directory ${PROJECT_SOURCE_DIR} --initial + --gcov-tool ${GCOV_BIN} --output-filename ${OUTFILE} + ${GENINFO_EXTERN_FLAG} ${TDIR}/${FILE}.gcno + DEPENDS ${TNAME} + COMMENT "Capturing initial coverage data for ${FILE}" + ) + endforeach() + + # Concatenate all files generated by geninfo to a single file per target. + set(OUTFILE "${LCOV_DATA_PATH_INIT}/${TNAME}.info") + set(LCOV_EXTRA_FLAGS "--initial") + lcov_merge_files("${OUTFILE}" ${GENINFO_FILES}) + add_custom_target(${TNAME}-capture-init ALL DEPENDS ${OUTFILE}) + + # add geninfo file generation to global lcov-geninfo target + add_dependencies(lcov-capture-init ${TNAME}-capture-init) + set(LCOV_CAPTURE_INIT_FILES "${LCOV_CAPTURE_INIT_FILES}" + "${OUTFILE}" CACHE INTERNAL "" + ) +endfunction (lcov_capture_initial_tgt) + + +# This function will generate the global info file for all targets. It has to be +# called after all other CMake functions in the root CMakeLists.txt file, to get +# a full list of all targets that generate coverage data. +function (lcov_capture_initial) + # Skip this function (and do not create the following targets), if there are + # no input files. + if ("${LCOV_CAPTURE_INIT_FILES}" STREQUAL "") + return() + endif () + + # Add a new target to merge the files of all targets. + set(OUTFILE "${LCOV_DATA_PATH_INIT}/all_targets.info") + lcov_merge_files("${OUTFILE}" ${LCOV_CAPTURE_INIT_FILES}) + add_custom_target(lcov-geninfo-init ALL DEPENDS ${OUTFILE} + lcov-capture-init + ) +endfunction (lcov_capture_initial) + + + + +# Add a new global target to generate coverage reports for all targets. This +# target will be used to generate the global info file. +if (NOT TARGET lcov-capture) + add_custom_target(lcov-capture) + set(LCOV_CAPTURE_FILES "" CACHE INTERNAL "") +endif (NOT TARGET lcov-capture) + + +# This function will add capture of coverage data for target , which is +# needed to get also data for objects, which were not loaded at execution time. +# It will call geninfo for every source file of once and store the info +# file in the same directory. +function (lcov_capture_tgt TNAME) + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + set(GENINFO_FILES "") + foreach(FILE ${SOURCES}) + # Generate coverage files. If no .gcda file was generated during + # execution, the empty coverage file will be used instead. + set(OUTFILE "${TDIR}/${FILE}.info") + list(APPEND GENINFO_FILES ${OUTFILE}) + + add_custom_command(OUTPUT ${OUTFILE} + COMMAND test -f "${TDIR}/${FILE}.gcda" + && ${GCOV_ENV} ${GENINFO_BIN} --quiet --base-directory + ${PROJECT_SOURCE_DIR} --gcov-tool ${GCOV_BIN} + --output-filename ${OUTFILE} ${GENINFO_EXTERN_FLAG} + ${TDIR}/${FILE}.gcda + || cp ${OUTFILE}.init ${OUTFILE} + DEPENDS ${TNAME} ${TNAME}-capture-init + COMMENT "Capturing coverage data for ${FILE}" + ) + endforeach() + + # Concatenate all files generated by geninfo to a single file per target. + set(OUTFILE "${LCOV_DATA_PATH_CAPTURE}/${TNAME}.info") + lcov_merge_files("${OUTFILE}" ${GENINFO_FILES}) + add_custom_target(${TNAME}-geninfo DEPENDS ${OUTFILE}) + + # add geninfo file generation to global lcov-capture target + add_dependencies(lcov-capture ${TNAME}-geninfo) + set(LCOV_CAPTURE_FILES "${LCOV_CAPTURE_FILES}" "${OUTFILE}" CACHE INTERNAL + "" + ) + + # Add target for generating html output for this target only. + file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/${TNAME}) + add_custom_target(${TNAME}-genhtml + COMMAND ${GENHTML_BIN} --quiet --sort --prefix ${PROJECT_SOURCE_DIR} + --baseline-file ${LCOV_DATA_PATH_INIT}/${TNAME}.info + --output-directory ${LCOV_HTML_PATH}/${TNAME} + --title "${CMAKE_PROJECT_NAME} - target ${TNAME}" + ${GENHTML_CPPFILT_FLAG} ${OUTFILE} + DEPENDS ${TNAME}-geninfo ${TNAME}-capture-init + ) +endfunction (lcov_capture_tgt) + + +# This function will generate the global info file for all targets. It has to be +# called after all other CMake functions in the root CMakeLists.txt file, to get +# a full list of all targets that generate coverage data. +function (lcov_capture) + # Skip this function (and do not create the following targets), if there are + # no input files. + if ("${LCOV_CAPTURE_FILES}" STREQUAL "") + return() + endif () + + # Add a new target to merge the files of all targets. + set(OUTFILE "${LCOV_DATA_PATH_CAPTURE}/all_targets.info") + lcov_merge_files("${OUTFILE}" ${LCOV_CAPTURE_FILES}) + add_custom_target(lcov-geninfo DEPENDS ${OUTFILE} lcov-capture) + + # Add a new global target for all lcov targets. This target could be used to + # generate the lcov html output for the whole project instead of calling + # -geninfo and -genhtml for each target. It will also be + # used to generate a html site for all project data together instead of one + # for each target. + if (NOT TARGET lcov) + file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/all_targets) + add_custom_target(lcov + COMMAND ${GENHTML_BIN} --quiet --sort + --baseline-file ${LCOV_DATA_PATH_INIT}/all_targets.info + --output-directory ${LCOV_HTML_PATH}/all_targets + --title "${CMAKE_PROJECT_NAME}" --prefix "${PROJECT_SOURCE_DIR}" + ${GENHTML_CPPFILT_FLAG} ${OUTFILE} + DEPENDS lcov-geninfo-init lcov-geninfo + ) + endif () +endfunction (lcov_capture) + + + + +# Add a new global target to generate the lcov html report for the whole project +# instead of calling -genhtml for each target (to create an own report +# for each target). Instead of the lcov target it does not require geninfo for +# all targets, so you have to call -geninfo to generate the info files +# the targets you'd like to have in your report or lcov-geninfo for generating +# info files for all targets before calling lcov-genhtml. +file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/selected_targets) +if (NOT TARGET lcov-genhtml) + add_custom_target(lcov-genhtml + COMMAND ${GENHTML_BIN} + --quiet + --output-directory ${LCOV_HTML_PATH}/selected_targets + --title \"${CMAKE_PROJECT_NAME} - targets `find + ${LCOV_DATA_PATH_CAPTURE} -name \"*.info\" ! -name + \"all_targets.info\" -exec basename {} .info \\\;`\" + --prefix ${PROJECT_SOURCE_DIR} + --sort + ${GENHTML_CPPFILT_FLAG} + `find ${LCOV_DATA_PATH_CAPTURE} -name \"*.info\" ! -name + \"all_targets.info\"` + ) +endif (NOT TARGET lcov-genhtml) diff --git a/third_party/Catch2_v3.5.4/CMake/Findcodecov.cmake b/third_party/Catch2_v3.5.4/CMake/Findcodecov.cmake new file mode 100644 index 0000000000..2c0f2fee5f --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/Findcodecov.cmake @@ -0,0 +1,258 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# Add an option to choose, if coverage should be enabled or not. If enabled +# marked targets will be build with coverage support and appropriate targets +# will be added. If disabled coverage will be ignored for *ALL* targets. +option(ENABLE_COVERAGE "Enable coverage build." OFF) + +set(COVERAGE_FLAG_CANDIDATES + # gcc and clang + "-O0 -g -fprofile-arcs -ftest-coverage" + + # gcc and clang fallback + "-O0 -g --coverage" +) + + +# Add coverage support for target ${TNAME} and register target for coverage +# evaluation. If coverage is disabled or not supported, this function will +# simply do nothing. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (add_coverage TNAME) + # only add coverage for target, if coverage is support and enabled. + if (ENABLE_COVERAGE) + foreach (TNAME ${ARGV}) + add_coverage_target(${TNAME}) + endforeach () + endif () +endfunction (add_coverage) + + +# Add global target to gather coverage information after all targets have been +# added. Other evaluation functions could be added here, after checks for the +# specific module have been passed. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (coverage_evaluate) + # add lcov evaluation + if (LCOV_FOUND) + lcov_capture_initial() + lcov_capture() + endif (LCOV_FOUND) +endfunction () + + +# Exit this module, if coverage is disabled. add_coverage is defined before this +# return, so this module can be exited now safely without breaking any build- +# scripts. +if (NOT ENABLE_COVERAGE) + return() +endif () + + + + +# Find the reuired flags foreach language. +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY}) + +get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach (LANG ${ENABLED_LANGUAGES}) + # Coverage flags are not dependent on language, but the used compiler. So + # instead of searching flags foreach language, search flags foreach compiler + # used. + set(COMPILER ${CMAKE_${LANG}_COMPILER_ID}) + if (NOT COVERAGE_${COMPILER}_FLAGS) + foreach (FLAG ${COVERAGE_FLAG_CANDIDATES}) + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try ${COMPILER} code coverage flag = [${FLAG}]") + endif() + + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + unset(COVERAGE_FLAG_DETECTED CACHE) + + if (${LANG} STREQUAL "C") + include(CheckCCompilerFlag) + check_c_compiler_flag("${FLAG}" COVERAGE_FLAG_DETECTED) + + elseif (${LANG} STREQUAL "CXX") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("${FLAG}" COVERAGE_FLAG_DETECTED) + + elseif (${LANG} STREQUAL "Fortran") + # CheckFortranCompilerFlag was introduced in CMake 3.x. To be + # compatible with older Cmake versions, we will check if this + # module is present before we use it. Otherwise we will define + # Fortran coverage support as not available. + include(CheckFortranCompilerFlag OPTIONAL + RESULT_VARIABLE INCLUDED) + if (INCLUDED) + check_fortran_compiler_flag("${FLAG}" + COVERAGE_FLAG_DETECTED) + elseif (NOT CMAKE_REQUIRED_QUIET) + message("-- Performing Test COVERAGE_FLAG_DETECTED") + message("-- Performing Test COVERAGE_FLAG_DETECTED - Failed" + " (Check not supported)") + endif () + endif() + + if (COVERAGE_FLAG_DETECTED) + set(COVERAGE_${COMPILER}_FLAGS "${FLAG}" + CACHE STRING "${COMPILER} flags for code coverage.") + mark_as_advanced(COVERAGE_${COMPILER}_FLAGS) + break() + else () + message(WARNING "Code coverage is not available for ${COMPILER}" + " compiler. Targets using this compiler will be " + "compiled without it.") + endif () + endforeach () + endif () +endforeach () + +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) + + + + +# Helper function to get the language of a source file. +function (codecov_lang_of_source FILE RETURN_VAR) + get_filename_component(FILE_EXT "${FILE}" EXT) + string(TOLOWER "${FILE_EXT}" FILE_EXT) + string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT) + + get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + foreach (LANG ${ENABLED_LANGUAGES}) + list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP) + if (NOT ${TEMP} EQUAL -1) + set(${RETURN_VAR} "${LANG}" PARENT_SCOPE) + return() + endif () + endforeach() + + set(${RETURN_VAR} "" PARENT_SCOPE) +endfunction () + + +# Helper function to get the relative path of the source file destination path. +# This path is needed by FindGcov and FindLcov cmake files to locate the +# captured data. +function (codecov_path_of_source FILE RETURN_VAR) + string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _source ${FILE}) + + # If expression was found, SOURCEFILE is a generator-expression for an + # object library. Currently we found no way to call this function automatic + # for the referenced target, so it must be called in the directoryso of the + # object library definition. + if (NOT "${_source}" STREQUAL "") + set(${RETURN_VAR} "" PARENT_SCOPE) + return() + endif () + + + string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" FILE "${FILE}") + if(IS_ABSOLUTE ${FILE}) + file(RELATIVE_PATH FILE ${CMAKE_CURRENT_SOURCE_DIR} ${FILE}) + endif() + + # get the right path for file + string(REPLACE ".." "__" PATH "${FILE}") + + set(${RETURN_VAR} "${PATH}" PARENT_SCOPE) +endfunction() + + + + +# Add coverage support for target ${TNAME} and register target for coverage +# evaluation. +function(add_coverage_target TNAME) + # Check if all sources for target use the same compiler. If a target uses + # e.g. C and Fortran mixed and uses different compilers (e.g. clang and + # gfortran) this can trigger huge problems, because different compilers may + # use different implementations for code coverage. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(TARGET_COMPILER "") + set(ADDITIONAL_FILES "") + foreach (FILE ${TSOURCES}) + # If expression was found, FILE is a generator-expression for an object + # library. Object libraries will be ignored. + string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE}) + if ("${_file}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (LANG) + list(APPEND TARGET_COMPILER ${CMAKE_${LANG}_COMPILER_ID}) + + list(APPEND ADDITIONAL_FILES "${FILE}.gcno") + list(APPEND ADDITIONAL_FILES "${FILE}.gcda") + endif () + endif () + endforeach () + + list(REMOVE_DUPLICATES TARGET_COMPILER) + list(LENGTH TARGET_COMPILER NUM_COMPILERS) + + if (NUM_COMPILERS GREATER 1) + message(WARNING "Can't use code coverage for target ${TNAME}, because " + "it will be compiled by incompatible compilers. Target will be " + "compiled without code coverage.") + return() + + elseif (NUM_COMPILERS EQUAL 0) + message(WARNING "Can't use code coverage for target ${TNAME}, because " + "it uses an unknown compiler. Target will be compiled without " + "code coverage.") + return() + + elseif (NOT DEFINED "COVERAGE_${TARGET_COMPILER}_FLAGS") + # A warning has been printed before, so just return if flags for this + # compiler aren't available. + return() + endif() + + + # enable coverage for target + set_property(TARGET ${TNAME} APPEND_STRING + PROPERTY COMPILE_FLAGS " ${COVERAGE_${TARGET_COMPILER}_FLAGS}") + set_property(TARGET ${TNAME} APPEND_STRING + PROPERTY LINK_FLAGS " ${COVERAGE_${TARGET_COMPILER}_FLAGS}") + + + # Add gcov files generated by compiler to clean target. + set(CLEAN_FILES "") + foreach (FILE ${ADDITIONAL_FILES}) + codecov_path_of_source(${FILE} FILE) + list(APPEND CLEAN_FILES "CMakeFiles/${TNAME}.dir/${FILE}") + endforeach() + + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES + "${CLEAN_FILES}") + + + add_gcov_target(${TNAME}) + add_lcov_target(${TNAME}) +endfunction(add_coverage_target) + + + + +# Include modules for parsing the collected data and output it in a readable +# format (like gcov and lcov). +find_package(Gcov) +find_package(Lcov) diff --git a/third_party/Catch2_v3.5.4/CMake/catch2-with-main.pc.in b/third_party/Catch2_v3.5.4/CMake/catch2-with-main.pc.in new file mode 100644 index 0000000000..69a790bbdb --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/catch2-with-main.pc.in @@ -0,0 +1,10 @@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +pkg_version=@Catch2_VERSION@ + +Name: Catch2-With-Main +Description: A modern, C++-native test framework for C++14 and above (links in default main) +Version: ${pkg_version} +Requires: catch2 = ${pkg_version} +Cflags: -I${includedir} +Libs: -L${libdir} -lCatch2Main diff --git a/third_party/Catch2_v3.5.4/CMake/catch2.pc.in b/third_party/Catch2_v3.5.4/CMake/catch2.pc.in new file mode 100644 index 0000000000..bd1c95a1af --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/catch2.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ + +Name: Catch2 +Description: A modern, C++-native, test framework for C++14 and above +URL: https://github.com/catchorg/Catch2 +Version: @Catch2_VERSION@ +Cflags: -I${includedir} +Libs: -L${libdir} -lCatch2 diff --git a/third_party/Catch2_v3.5.4/CMake/llvm-cov-wrapper b/third_party/Catch2_v3.5.4/CMake/llvm-cov-wrapper new file mode 100755 index 0000000000..2ac3310248 --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMake/llvm-cov-wrapper @@ -0,0 +1,56 @@ +#!/bin/sh + +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + +if [ -z "$LLVM_COV_BIN" ] +then + echo "LLVM_COV_BIN not set!" >& 2 + exit 1 +fi + + +# Get LLVM version to find out. +LLVM_VERSION=$($LLVM_COV_BIN -version | grep -i "LLVM version" \ + | sed "s/^\([A-Za-z ]*\)\([0-9]\).\([0-9]\).*$/\2.\3/g") + +if [ "$1" = "-v" ] +then + echo "llvm-cov-wrapper $LLVM_VERSION" + exit 0 +fi + + +if [ -n "$LLVM_VERSION" ] +then + MAJOR=$(echo $LLVM_VERSION | cut -d'.' -f1) + MINOR=$(echo $LLVM_VERSION | cut -d'.' -f2) + + if [ $MAJOR -eq 3 ] && [ $MINOR -le 4 ] + then + if [ -f "$1" ] + then + filename=$(basename "$1") + extension="${filename##*.}" + + case "$extension" in + "gcno") exec $LLVM_COV_BIN --gcno="$1" ;; + "gcda") exec $LLVM_COV_BIN --gcda="$1" ;; + esac + fi + fi + + if [ $MAJOR -eq 3 ] && [ $MINOR -le 5 ] + then + exec $LLVM_COV_BIN $@ + fi +fi + +exec $LLVM_COV_BIN gcov $@ diff --git a/third_party/Catch2_v3.5.4/CMakeLists.txt b/third_party/Catch2_v3.5.4/CMakeLists.txt new file mode 100644 index 0000000000..7c3e855a44 --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMakeLists.txt @@ -0,0 +1,203 @@ +cmake_minimum_required(VERSION 3.10) + +# detect if Catch is being bundled, +# disable testsuite in that case +if(NOT DEFINED PROJECT_NAME) + set(NOT_SUBPROJECT ON) +else() + set(NOT_SUBPROJECT OFF) +endif() + +option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON) +option(CATCH_INSTALL_EXTRAS "Install extras (CMake scripts, debugger helpers) alongside library" ON) +option(CATCH_DEVELOPMENT_BUILD "Build tests, enable warnings, enable Werror, etc" OFF) +option(CATCH_ENABLE_REPRODUCIBLE_BUILD "Add compiler flags for improving build reproducibility" ON) + +include(CMakeDependentOption) +cmake_dependent_option(CATCH_BUILD_TESTING "Build the SelfTest project" ON "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_BUILD_EXAMPLES "Build code examples" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_BUILD_EXTRA_TESTS "Build extra tests" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_BUILD_FUZZERS "Build fuzzers" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_ENABLE_WERROR "Enables Werror during build" ON "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_BUILD_SURROGATES "Enable generating and building surrogate TUs for the main headers" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_ENABLE_CONFIGURE_TESTS "Enable CMake configuration tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF) +cmake_dependent_option(CATCH_ENABLE_CMAKE_HELPER_TESTS "Enable CMake helper tests. WARNING: VERY EXPENSIVE" OFF "CATCH_DEVELOPMENT_BUILD" OFF) + + +# Catch2's build breaks if done in-tree. You probably should not build +# things in tree anyway, but we can allow projects that include Catch2 +# as a subproject to build in-tree as long as it is not in our tree. +if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt") +endif() + +project(Catch2 + VERSION 3.5.4 # CML version placeholder, don't delete + LANGUAGES CXX + # HOMEPAGE_URL is not supported until CMake version 3.12, which + # we do not target yet. + # HOMEPAGE_URL "https://github.com/catchorg/Catch2" + DESCRIPTION "A modern, C++-native, unit test framework." +) + + +# Provide path for scripts. We first add path to the scripts we don't use, +# but projects including us might, and set the path up to parent scope. +# Then we also add path that we use to configure the project, but is of +# no use to top level projects. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/extras") +if (NOT NOT_SUBPROJECT) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) +endif() +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) +include(CatchConfigOptions) +if(CATCH_DEVELOPMENT_BUILD) + include(CTest) +endif() + +# This variable is used in some subdirectories, so we need it here, rather +# than later in the install block +set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2") + +# We have some Windows builds that test `wmain` entry point, +# and we need this change to be present in all binaries that +# are built during these tests, so this is required here, before +# the subdirectories are added. +if(CATCH_TEST_USE_WMAIN) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup") +endif() + + +# Basic paths +set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(SOURCES_DIR ${CATCH_DIR}/src/catch2) +set(SELF_TEST_DIR ${CATCH_DIR}/tests/SelfTest) +set(BENCHMARK_DIR ${CATCH_DIR}/tests/Benchmark) +set(EXAMPLES_DIR ${CATCH_DIR}/examples) + +# We need to bring-in the variables defined there to this scope +add_subdirectory(src) + +# Build tests only if requested +if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT) + find_package(PythonInterp 3 REQUIRED) + if (NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR "Python not found, but required for tests") + endif() + add_subdirectory(tests) +endif() + +if(CATCH_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + +if(CATCH_BUILD_EXTRA_TESTS) + add_subdirectory(tests/ExtraTests) +endif() + +if(CATCH_BUILD_FUZZERS) + add_subdirectory(fuzzing) +endif() + +if (CATCH_DEVELOPMENT_BUILD) + add_warnings_to_targets("${CATCH_WARNING_TARGETS}") +endif() + +# Only perform the installation steps when Catch is not being used as +# a subproject via `add_subdirectory`, or the destinations will break, +# see https://github.com/catchorg/Catch2/issues/1373 +if (NOT_SUBPROJECT) + configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake + INSTALL_DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake" + COMPATIBILITY + SameMajorVersion + ) + + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake" + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + # Install documentation + if(CATCH_INSTALL_DOCS) + install( + DIRECTORY + docs/ + DESTINATION + "${CMAKE_INSTALL_DOCDIR}" + PATTERN "doxygen" EXCLUDE + ) + endif() + + if(CATCH_INSTALL_EXTRAS) + # Install CMake scripts + install( + FILES + "extras/ParseAndAddCatchTests.cmake" + "extras/Catch.cmake" + "extras/CatchAddTests.cmake" + "extras/CatchShardTests.cmake" + "extras/CatchShardTestsImpl.cmake" + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} + ) + + # Install debugger helpers + install( + FILES + "extras/gdbinit" + "extras/lldbinit" + DESTINATION + ${CMAKE_INSTALL_DATAROOTDIR}/Catch2 + ) + endif() + + ## Provide some pkg-config integration + set(PKGCONFIG_INSTALL_DIR + "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" + CACHE PATH "Path where catch2.pc is installed" + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/catch2.pc + @ONLY + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2-with-main.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/catch2-with-main.pc + @ONLY + ) + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/catch2.pc" + "${CMAKE_CURRENT_BINARY_DIR}/catch2-with-main.pc" + DESTINATION + ${PKGCONFIG_INSTALL_DIR} + ) + + # CPack/CMake started taking the package version from project version 3.12 + # So we need to set the version manually for older CMake versions + if(${CMAKE_VERSION} VERSION_LESS "3.12.0") + set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) + endif() + + set(CPACK_PACKAGE_CONTACT "https://github.com/catchorg/Catch2/") + + + include( CPack ) + +endif() diff --git a/third_party/Catch2_v3.5.4/CMakePresets.json b/third_party/Catch2_v3.5.4/CMakePresets.json new file mode 100644 index 0000000000..885412850d --- /dev/null +++ b/third_party/Catch2_v3.5.4/CMakePresets.json @@ -0,0 +1,26 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "basic-tests", + "displayName": "Basic development build", + "description": "Enables development build with basic tests that are cheap to build and run", + "cacheVariables": { + "CATCH_DEVELOPMENT_BUILD": "ON" + } + }, + { + "name": "all-tests", + "inherits": "basic-tests", + "displayName": "Full development build", + "description": "Enables development build with examples and ALL tests", + "cacheVariables": { + "CATCH_BUILD_EXAMPLES": "ON", + "CATCH_BUILD_EXTRA_TESTS": "ON", + "CATCH_BUILD_SURROGATES": "ON", + "CATCH_ENABLE_CONFIGURE_TESTS": "ON", + "CATCH_ENABLE_CMAKE_HELPER_TESTS": "ON" + } + } + ] +} diff --git a/third_party/Catch2_v3.5.4/CODE_OF_CONDUCT.md b/third_party/Catch2_v3.5.4/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..be1a688e01 --- /dev/null +++ b/third_party/Catch2_v3.5.4/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@philnash.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/third_party/Catch2_v3.5.4/Doxyfile b/third_party/Catch2_v3.5.4/Doxyfile new file mode 100644 index 0000000000..914e598481 --- /dev/null +++ b/third_party/Catch2_v3.5.4/Doxyfile @@ -0,0 +1,2650 @@ +# Doxyfile 1.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = Catch2 + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Popular C++ unit testing framework" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs/doxygen + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# The OUTPUT_TEXT_DIRECTION tag is used to specify the direction in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all generated output in the proper direction. +# Possible values are: None, LTR, RTL and Context. +# The default value is: None. + +OUTPUT_TEXT_DIRECTION = None + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = YES + +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = YES + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines (in the resulting output). You can put ^^ in the value part of an +# alias to insert a newline as if a physical newline was in the original file. +# When you need a literal { or } or , in the value part of an alias you have to +# escape them by means of a backslash (\), this can lead to conflicts with the +# commands \{ and \} for these it is advised to use the version @{ and @} or use +# a double escape (\\{ and \\}) + +ALIASES = "complexity=@par Complexity:" \ + noexcept=**Noexcept** + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, +# Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See https://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = YES + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = YES + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = YES + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# declarations. If set to NO, these declarations will be included in the +# documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = YES + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = YES + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. If +# EXTRACT_ALL is set to YES then this flag will automatically be disabled. +# The default value is: NO. + +WARN_NO_PARAMDOC = YES + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = doxygen.errors + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING +# Note: If this tag is empty the current directory is searched. + +INPUT = src/catch2 + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# read by doxygen. +# +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# +# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, +# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, +# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = */lib/* + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. +# +# Note that for custom extensions or not directly supported extensions you also +# need to set EXTENSION_MAPPING for the extension otherwise the files are not +# properly processed by doxygen. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# entity all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = NO + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see https://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to YES can help to show when doxygen was last run and thus if the +# documentation is up to date. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = NO + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the main .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANSPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# https://www.mathjax.org) which uses client side JavaScript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = YES + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = TeX/AMSmath \ + TeX/AMSsymbols + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /