18#ifndef O2_TOF_PARAMCONTAINER_H
19#define O2_TOF_PARAMCONTAINER_H
37 Parameters(std::array<std::string, nPar> parNames, std::string
name) : mName{
name}, mPar{}, mParNames{parNames} {};
55 for (
int i = 0;
i < nPar;
i++) {
71 LOG(info) <<
"Parameters '" << mName <<
"'";
72 for (
int i = 0;
i < nPar;
i++) {
73 LOG(info) <<
"Parameter " <<
i <<
"/" << nPar - 1 <<
" " << mParNames[
i] <<
" is " << mPar[
i];
80 for (
int i = 0;
i < nPar;
i++) {
81 metadata[Form(
"p%i",
i)] = Form(
"%f", mPar[
i]);
90 TFile
f(FileName,
"READ");
92 LOG(fatal) <<
"Could not open file " << FileName;
94 if (!
f.Get(ParamName)) {
96 LOG(fatal) <<
"Did not find parameters " << ParamName <<
" in file " << FileName;
98 LOG(info) <<
"Loading parameters " << ParamName <<
" from TFile " << FileName;
100 f.GetObject(ParamName, p);
102 LOG(fatal) <<
"Could not get parameters " << ParamName <<
" from file";
124 const std::string
getName()
const {
return mName; }
128 static int size() {
return nPar; }
137 std::array<paramvar_t, nPar> mPar;
138 const std::array<std::string, nPar> mParNames;
154 bool hasKey(
const std::string&
key)
const {
return (mParameters.find(
key) != mParameters.end()); }
162 template <
typename ParType>
169 const auto& toGet = mParameters.at(
key);
170 for (
int i = 0;
i < p.size();
i++) {
171 const auto&
name = p.getParameterName(
i);
172 if (toGet.find(
name) == toGet.end()) {
173 LOG(
debug) <<
"Did not find parameter '" <<
name <<
"' in collection, keeping preexisting";
176 LOG(
debug) <<
"Found parameter '" <<
name <<
"' in collection, updating from " << p[
i] <<
" to " << toGet.at(
name);
177 p.setParameter(
i, toGet.at(
name));
186 bool addParameter(
const std::string& pass,
const std::string& parName,
float value);
189 int getSize(
const std::string& pass)
const;
196 template <
typename ParType>
200 if (alreadyPresent) {
201 LOG(
debug) <<
"Changing parametrization corresponding to key " <<
key <<
" from size " << mParameters[
key].size() <<
" to " << p.getName() <<
" of size " << p.size();
203 mParameters[
key] = std::unordered_map<std::string, paramvar_t>{};
204 LOG(
debug) <<
"Adding new parametrization corresponding to key " <<
key <<
": " << p.getName() <<
" of size " << p.size();
206 for (
int i = 0;
i < p.size();
i++) {
207 mParameters[
key][p.getParameterName(
i)] = p[
i];
209 return alreadyPresent;
213 const auto&
getPars(
const std::string& pass)
const {
return mParameters.at(pass); }
217 void print(
const std::string& pass)
const;
231 TFile
f(FileName,
"READ");
233 LOG(fatal) <<
"Could not open file " << FileName;
235 if (!
f.Get(ParamName)) {
237 LOG(fatal) <<
"Did not find parameters " << ParamName <<
" in file " << FileName;
239 LOG(info) <<
"Loading parameters " << ParamName <<
" from TFile " << FileName;
241 f.GetObject(ParamName, p);
243 LOG(fatal) <<
"Could not get parameters " << ParamName <<
" from file";
248 for (
const auto& pass : p->mParameters) {
249 for (
const auto& par : pass.second) {
258 std::unordered_map<std::string, std::unordered_map<std::string, paramvar_t>> mParameters;
Class container to hold different parameters meant to be stored on the CCDB.
const auto & getPars(const std::string &pass) const
getter for the parameters stored in the container matching to a pass
const auto & getFullMap()
Getter of the full map of parameters stored in the container.
bool hasKey(const std::string &key) const
Checks if the container has a particular key e.g. a pass.
bool retrieveParameters(ParType &p, const std::string &key) const
Function to load the parameters from the this container into the array based for the asked key,...
ParameterCollection(TString name="DefaultParameters")
Default constructor.
int getSize(const std::string &pass) const
~ParameterCollection() override=default
Default destructor.
void loadParamFromFile(const TString FileName, const TString ParamName)
void print() const
printing function for the full content of the container
bool storeParameters(const ParType &p, const std::string &key)
Function to push the parameters from the sub container into the collection and store it under a given...
bool addParameter(const std::string &pass, const std::string &parName, float value)
Function to add a single parameter conatiner based on the asked key, e.g. pass or version.
void setParameter(const unsigned int iparam, const paramvar_t value)
void loadParamFromFile(const TString FileName, const TString ParamName)
~Parameters()=default
Default destructor.
const std::string getName() const
const std::string getParameterName(int i) const
void setParameters(const Parameters< nPar > *params)
void setParameters(const Parameters< nPar > params)
void setParameters(const paramvar_t *params)
void addToMetadata(std::map< std::string, std::string > &metadata) const
Adds the parameters to the metadata.
const paramvar_t getParameter(int i) const
const paramvar_t * getParameters() const
void setParameters(const std::array< paramvar_t, nPar > params)
paramvar_t operator[](const unsigned int i) const
void print() const
Printer of the parameter values.
Parameters(std::array< std::string, nPar > parNames, std::string name)
Default constructor.
GLuint const GLchar * name
GLsizei const GLfloat * value
GLenum const GLfloat * params
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"