From cbd562d8924f7b57bf4cc2379535356386239df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Fri, 10 Oct 2025 15:34:17 +0200 Subject: [PATCH 1/6] Revert "TOF Param container: move to header only" This reverts commit 1aa2c1409988e1054730c7cccdc987fbe1db7506. --- DataFormats/Detectors/TOF/CMakeLists.txt | 1 + .../DataFormatsTOF/ParameterContainers.h | 43 ++----------- .../Detectors/TOF/src/ParameterContainers.cxx | 62 +++++++++++++++++++ 3 files changed, 68 insertions(+), 38 deletions(-) create mode 100644 DataFormats/Detectors/TOF/src/ParameterContainers.cxx diff --git a/DataFormats/Detectors/TOF/CMakeLists.txt b/DataFormats/Detectors/TOF/CMakeLists.txt index 8a55e531287e1..03dbd9275edf9 100644 --- a/DataFormats/Detectors/TOF/CMakeLists.txt +++ b/DataFormats/Detectors/TOF/CMakeLists.txt @@ -16,6 +16,7 @@ o2_add_library(DataFormatsTOF src/CalibLHCphaseTOF.cxx src/CalibTimeSlewingParamTOF.cxx src/CTF.cxx + src/ParameterContainers.cxx src/CalibInfoCluster.cxx src/CosmicInfo.cxx src/Diagnostic.cxx diff --git a/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h b/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h index c9d910d8345e5..9029c06d503c8 100644 --- a/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h +++ b/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h @@ -37,7 +37,7 @@ class Parameters Parameters(std::array parNames, std::string name) : mName{name}, mPar{}, mParNames{parNames} {}; /// Default destructor - virtual ~Parameters() = default; // Ensure proper cleanup in derived classes + ~Parameters() = default; /// Setter for the parameter at position iparam /// \param iparam index in the array of the parameters @@ -183,27 +183,10 @@ class ParameterCollection : public TNamed /// @param value parameter to add to the stored information /// @param pass key to look for in the stored information e.g. pass /// @return true if found and configured false if not fully configured - bool addParameter(const std::string& pass, const std::string& parName, float value) - { - const bool alreadyPresent = hasKey(pass); - if (alreadyPresent) { - LOG(debug) << "Changing parametrization corresponding to key " << pass << " from size " << mParameters[pass].size() << " to " << parName; - } else { - mParameters[pass] = std::unordered_map{}; - LOG(debug) << "Adding new parametrization corresponding to key " << pass << ": " << parName; - } - mParameters[pass][parName] = value; - return true; - } + bool addParameter(const std::string& pass, const std::string& parName, float value); /// @return the size of the container i.e. the number of stored keys (or passes) - int getSize(const std::string& pass) const - { - if (!hasKey(pass)) { - return -1; - } - return mParameters.at(pass).size(); - } + int getSize(const std::string& pass) const; /// @brief Function to push the parameters from the sub container into the collection and store it under a given key /// @tparam ParType type of the parameter container @@ -231,26 +214,10 @@ class ParameterCollection : public TNamed /// @brief printing function for the content of the pass /// @param pass pass to print - void print(const std::string& pass) const - { - const auto& size = getSize(pass); - if (size < 0) { - LOG(info) << "empty pass: " << pass; - return; - } - LOG(info) << "Pass \"" << pass << "\" with size " << size; - for (const auto& [par, value] : mParameters.at(pass)) { - LOG(info) << "par name = " << par << ", value = " << value; - } - } + void print(const std::string& pass) const; /// @brief printing function for the full content of the container - void print() const - { - for (const auto& [pass, pars] : mParameters) { - print(pass); - } - } + void print() const; /// @brief Getter of the full map of parameters stored in the container /// @return returns the full map of parameters diff --git a/DataFormats/Detectors/TOF/src/ParameterContainers.cxx b/DataFormats/Detectors/TOF/src/ParameterContainers.cxx new file mode 100644 index 0000000000000..91f723873e9cd --- /dev/null +++ b/DataFormats/Detectors/TOF/src/ParameterContainers.cxx @@ -0,0 +1,62 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file ParameterContainers.h +/// \author Francesco Noferini +/// \author Nicolò Jacazio nicolo.jacazio@cern.ch +/// @since 2022-11-08 +/// \brief Implementation of the containers for the general parameters + +#include "DataFormatsTOF/ParameterContainers.h" + +// ClassImp(o2::tof::Parameters); +using namespace o2::tof; + +bool ParameterCollection::addParameter(const std::string& pass, const std::string& parName, float value) +{ + const bool alreadyPresent = hasKey(pass); + if (alreadyPresent) { + LOG(debug) << "Changing parametrization corresponding to key " << pass << " from size " << mParameters[pass].size() << " to " << parName; + } else { + mParameters[pass] = std::unordered_map{}; + LOG(debug) << "Adding new parametrization corresponding to key " << pass << ": " << parName; + } + mParameters[pass][parName] = value; + return true; +} + +int ParameterCollection::getSize(const std::string& pass) const +{ + if (!hasKey(pass)) { + return -1; + } + return mParameters.at(pass).size(); +} + +void ParameterCollection::print() const +{ + for (const auto& [pass, pars] : mParameters) { + print(pass); + } +} + +void ParameterCollection::print(const std::string& pass) const +{ + const auto& size = getSize(pass); + if (size < 0) { + LOG(info) << "empty pass: " << pass; + return; + } + LOG(info) << "Pass \"" << pass << "\" with size " << size; + for (const auto& [par, value] : mParameters.at(pass)) { + LOG(info) << "par name = " << par << ", value = " << value; + } +} From 331b04aad45265dd672477c7babac6c3563e907a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Fri, 10 Oct 2025 15:36:14 +0200 Subject: [PATCH 2/6] Add DataFormatsParamTOF library to CMakeLists --- DataFormats/Detectors/TOF/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/DataFormats/Detectors/TOF/CMakeLists.txt b/DataFormats/Detectors/TOF/CMakeLists.txt index 03dbd9275edf9..89c1da8159ffb 100644 --- a/DataFormats/Detectors/TOF/CMakeLists.txt +++ b/DataFormats/Detectors/TOF/CMakeLists.txt @@ -9,6 +9,13 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. +o2_add_library(DataFormatsParamTOF + SOURCES src/ParameterContainers.cxx) + + +o2_target_root_dictionary(DataFormatsParamTOF + HEADERS include/DataFormatsTOF/ParameterContainers.h) + o2_add_library(DataFormatsTOF SOURCES src/Cluster.cxx src/CalibInfoTOFshort.cxx @@ -16,13 +23,13 @@ o2_add_library(DataFormatsTOF src/CalibLHCphaseTOF.cxx src/CalibTimeSlewingParamTOF.cxx src/CTF.cxx - src/ParameterContainers.cxx src/CalibInfoCluster.cxx src/CosmicInfo.cxx src/Diagnostic.cxx src/TOFFEElightInfo.cxx PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats O2::GPUCommon + O2::DataFormatsParamTOF Boost::serialization) o2_target_root_dictionary(DataFormatsTOF From da12fe5bbf7ae08ba809c43d387679cb0d41a8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Fri, 10 Oct 2025 15:39:35 +0200 Subject: [PATCH 3/6] Add separate lib --- .../TOF/src/DataFormatsParamTOFLinkDef.h | 17 +++++++++++++++++ .../Detectors/TOF/src/DataFormatsTOFLinkDef.h | 2 -- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 DataFormats/Detectors/TOF/src/DataFormatsParamTOFLinkDef.h diff --git a/DataFormats/Detectors/TOF/src/DataFormatsParamTOFLinkDef.h b/DataFormats/Detectors/TOF/src/DataFormatsParamTOFLinkDef.h new file mode 100644 index 0000000000000..2d6ee84bedb92 --- /dev/null +++ b/DataFormats/Detectors/TOF/src/DataFormatsParamTOFLinkDef.h @@ -0,0 +1,17 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifdef __CLING__ + +#pragma link C++ class o2::tof::Parameters < 5> + ; +#pragma link C++ class o2::tof::ParameterCollection + ; + +#endif diff --git a/DataFormats/Detectors/TOF/src/DataFormatsTOFLinkDef.h b/DataFormats/Detectors/TOF/src/DataFormatsTOFLinkDef.h index 55d1fd3973e70..03004e4c22afa 100644 --- a/DataFormats/Detectors/TOF/src/DataFormatsTOFLinkDef.h +++ b/DataFormats/Detectors/TOF/src/DataFormatsTOFLinkDef.h @@ -33,8 +33,6 @@ #pragma link C++ class std::vector < o2::dataformats::CalibInfoTOFshort> + ; #pragma link C++ class std::vector < o2::dataformats::CalibInfoTOF> + ; -#pragma link C++ class o2::tof::Parameters < 5> + ; -#pragma link C++ class o2::tof::ParameterCollection + ; #pragma link C++ class o2::tof::CTFHeader + ; #pragma link C++ class o2::tof::CompressedInfos + ; From 9f148ec4e8f54c03d91f351b8c63ec17613acf08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sat, 11 Oct 2025 15:02:54 +0200 Subject: [PATCH 4/6] Update CMakeLists.txt --- DataFormats/Detectors/TOF/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DataFormats/Detectors/TOF/CMakeLists.txt b/DataFormats/Detectors/TOF/CMakeLists.txt index 89c1da8159ffb..4d41167f7bf1d 100644 --- a/DataFormats/Detectors/TOF/CMakeLists.txt +++ b/DataFormats/Detectors/TOF/CMakeLists.txt @@ -10,7 +10,8 @@ # or submit itself to any jurisdiction. o2_add_library(DataFormatsParamTOF - SOURCES src/ParameterContainers.cxx) + SOURCES src/ParameterContainers.cxx + PUBLIC_LINK_LIBRARIES O2::FrameworkLogger) o2_target_root_dictionary(DataFormatsParamTOF @@ -41,7 +42,6 @@ o2_target_root_dictionary(DataFormatsTOF include/DataFormatsTOF/RawDataFormat.h include/DataFormatsTOF/CompressedDataFormat.h include/DataFormatsTOF/CTF.h - include/DataFormatsTOF/ParameterContainers.h include/DataFormatsTOF/CalibInfoCluster.h include/DataFormatsTOF/CosmicInfo.h include/DataFormatsTOF/TOFFEElightInfo.h From 1df1b850cdd6b5685b0f664fc29869649d140184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sat, 11 Oct 2025 15:03:24 +0200 Subject: [PATCH 5/6] Fix include directives to use angle brackets --- .../TOF/include/DataFormatsTOF/ParameterContainers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h b/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h index 9029c06d503c8..e64bf8aa3e276 100644 --- a/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h +++ b/DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h @@ -18,10 +18,10 @@ #ifndef O2_TOF_PARAMCONTAINER_H #define O2_TOF_PARAMCONTAINER_H -#include "TNamed.h" -#include "TFile.h" -#include "Framework/Logger.h" -#include "map" +#include +#include +#include +#include namespace o2 { From 64ded1eaa4c4be96b4fb27c550bd2df6e98e27a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Sat, 11 Oct 2025 19:54:01 +0200 Subject: [PATCH 6/6] Change destructor to non-override in ParamExample --- Detectors/TOF/workflow/src/make-parameter-collection.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/TOF/workflow/src/make-parameter-collection.cxx b/Detectors/TOF/workflow/src/make-parameter-collection.cxx index c90f417639212..3a210df3fcad8 100644 --- a/Detectors/TOF/workflow/src/make-parameter-collection.cxx +++ b/Detectors/TOF/workflow/src/make-parameter-collection.cxx @@ -63,7 +63,7 @@ class ParamExample : public Parameters<5> public: ParamExample() : Parameters(std::array{"p0", "p1", "p2", "p3", "p4"}, "ParamExample") { setParameters(std::array{0, 1, 2, 3, 4}); }; // Default constructor with default parameters - ~ParamExample() override = default; + ~ParamExample() = default; }; int main(int argc, char* argv[])