Skip to content

Commit 528a5a5

Browse files
authored
Refine parameter getter methods with error handling (#14794)
Updated getter functions to specify return types and added error logging for missing parameters.
1 parent 1bcfeed commit 528a5a5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,13 @@ class ParameterCollection : public TNamed
210210
}
211211

212212
/// @brief getter for the parameters stored in the container matching to a pass
213-
const auto& getPars(const std::string& pass) const { return mParameters.at(pass); }
213+
const std::unordered_map<std::string, paramvar_t>& getPars(const std::string& pass) const
214+
{
215+
if (!hasKey(pass)) {
216+
LOG(fatal) << "Parameters for pass " << pass << " not found!";
217+
}
218+
return mParameters.at(pass);
219+
}
214220

215221
/// @brief printing function for the content of the pass
216222
/// @param pass pass to print
@@ -221,7 +227,7 @@ class ParameterCollection : public TNamed
221227

222228
/// @brief Getter of the full map of parameters stored in the container
223229
/// @return returns the full map of parameters
224-
const auto& getFullMap() { return mParameters; }
230+
const std::unordered_map<std::string, std::unordered_map<std::string, paramvar_t>>& getFullMap() const { return mParameters; }
225231

226232
/// Loader from file
227233
/// \param FileName name of the input file

0 commit comments

Comments
 (0)