Skip to content

Commit 350124a

Browse files
authored
[QC-1006] Add method to interface to custom parameters (#1945)
1 parent bf6b8a5 commit 350124a

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Framework/include/QualityControl/CustomParameters.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class CustomParameters
105105
*/
106106
std::string atOrDefaultValue(const std::string& key, std::string defaultValue = "", const std::string& runType = "default", const std::string& beamType = "default");
107107

108+
std::string atOrDefaultValue(const std::string& key, std::string defaultValue, const Activity& activity) const;
109+
108110
/**
109111
* Returns the number of items found for the provided key, beamType and runType. It can only be either 0 or 1.
110112
* @param key

Framework/src/CustomParameters.cxx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ std::string CustomParameters::atOrDefaultValue(const std::string& key, std::stri
8686
}
8787
}
8888

89+
std::string CustomParameters::atOrDefaultValue(const std::string& key, std::string defaultValue, const Activity& activity) const
90+
{
91+
try {
92+
// Get the proper parameter for the given activity
93+
const int runType = activity.mType; // get the type for this run as an int
94+
// convert it to a string (via a string_view as this is what we get from O2)
95+
const std::string_view runTypeStringView = o2::parameters::GRPECS::RunTypeNames[runType];
96+
const std::string runTypeString{ runTypeStringView };
97+
return mCustomParameters.at(runTypeString).at(activity.mBeamType).at(key);
98+
} catch (const std::out_of_range& exc) {
99+
return defaultValue;
100+
}
101+
}
102+
89103
int CustomParameters::count(const std::string& key, const std::string& runType, const std::string& beamType) const
90104
{
91105
try {

0 commit comments

Comments
 (0)