Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion DataFormats/Detectors/TOF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
# 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
PUBLIC_LINK_LIBRARIES O2::FrameworkLogger)


o2_target_root_dictionary(DataFormatsParamTOF
HEADERS include/DataFormatsTOF/ParameterContainers.h)

o2_add_library(DataFormatsTOF
SOURCES src/Cluster.cxx
src/CalibInfoTOFshort.cxx
Expand All @@ -22,6 +30,7 @@ o2_add_library(DataFormatsTOF
src/TOFFEElightInfo.cxx
PUBLIC_LINK_LIBRARIES O2::ReconstructionDataFormats
O2::GPUCommon
O2::DataFormatsParamTOF
Boost::serialization)

o2_target_root_dictionary(DataFormatsTOF
Expand All @@ -33,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TNamed.h>
#include <TFile.h>
#include <Framework/Logger.h>
#include <map>

namespace o2
{
Expand All @@ -37,7 +37,7 @@ class Parameters
Parameters(std::array<std::string, nPar> 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
Expand Down Expand Up @@ -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<std::string, paramvar_t>{};
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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions DataFormats/Detectors/TOF/src/DataFormatsParamTOFLinkDef.h
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions DataFormats/Detectors/TOF/src/DataFormatsTOFLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ;
Expand Down
62 changes: 62 additions & 0 deletions DataFormats/Detectors/TOF/src/ParameterContainers.cxx
Original file line number Diff line number Diff line change
@@ -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<std::string, paramvar_t>{};
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;
}
}
2 changes: 1 addition & 1 deletion Detectors/TOF/workflow/src/make-parameter-collection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ParamExample : public Parameters<5>
public:
ParamExample() : Parameters(std::array<std::string, 5>{"p0", "p1", "p2", "p3", "p4"},
"ParamExample") { setParameters(std::array<paramvar_t, 5>{0, 1, 2, 3, 4}); }; // Default constructor with default parameters
~ParamExample() override = default;
~ParamExample() = default;
};

int main(int argc, char* argv[])
Expand Down