From 5efd4c2861a0d14eafe0d40b02be99b7ece98753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Jacazio?= Date: Tue, 15 Jul 2025 19:18:09 +0200 Subject: [PATCH] TOF Param container: move to header only --- DataFormats/Detectors/TOF/CMakeLists.txt | 1 - .../DataFormatsTOF/ParameterContainers.h | 43 +++++++++++-- .../Detectors/TOF/src/ParameterContainers.cxx | 62 ------------------- 3 files changed, 38 insertions(+), 68 deletions(-) delete mode 100644 DataFormats/Detectors/TOF/src/ParameterContainers.cxx diff --git a/DataFormats/Detectors/TOF/CMakeLists.txt b/DataFormats/Detectors/TOF/CMakeLists.txt index 03dbd9275edf9..8a55e531287e1 100644 --- a/DataFormats/Detectors/TOF/CMakeLists.txt +++ b/DataFormats/Detectors/TOF/CMakeLists.txt @@ -16,7 +16,6 @@ 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 9029c06d503c8..c9d910d8345e5 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 - ~Parameters() = default; + virtual ~Parameters() = default; // Ensure proper cleanup in derived classes /// Setter for the parameter at position iparam /// \param iparam index in the array of the parameters @@ -183,10 +183,27 @@ 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); + 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; + } /// @return the size of the container i.e. the number of stored keys (or passes) - int getSize(const std::string& pass) const; + int getSize(const std::string& pass) const + { + if (!hasKey(pass)) { + return -1; + } + return mParameters.at(pass).size(); + } /// @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 @@ -214,10 +231,26 @@ 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; + 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; + } + } /// @brief printing function for the full content of the container - void print() const; + void print() const + { + for (const auto& [pass, pars] : mParameters) { + print(pass); + } + } /// @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 deleted file mode 100644 index 91f723873e9cd..0000000000000 --- a/DataFormats/Detectors/TOF/src/ParameterContainers.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// 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; - } -}