Template class allowing to store parameters and their covariances using enums to address them with a general interface. More...
#include "utl/ParameterStorage.h"
Public Types | |
typedef std::vector< IndexEnum > | EnumVector |
typedef std::map< std::pair < IndexEnum, IndexEnum > , std::pair < ParameterCovarianceType, bool > > | ParameterCovarianceMap |
typedef std::map< IndexEnum, std::pair< ParameterType, bool > > | ParameterMap |
Public Member Functions | |
bool | HasParameter (const IndexEnum param) const |
determine whether a parameter has been set More... | |
ParameterStorage (const std::string &storagename="Unnamed") | |
Constructor that sets a name for the storage, helpful to get useful exception messages. More... | |
enumVector | push_back (pv.first) |
enumVector | push_back (pc.first) |
enumVector | reserve (fParameterMap.size()) |
enumVector | reserve (fParameterCovarianceMap.size()) |
Public Attributes | |
const ParameterType & | const |
get the value of a parameter, throw exception if parameter has not been set More... | |
err<< "Tried to get locking status of unset parameter covariance (" << covarianceKey.first << ", "<< covarianceKey.second << ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw NonExistentComponentException(err.str().c_str());}}void SetParameterCovariance(const IndexEnum param1, const IndexEnum param2, const ParameterCovarianceType value, const bool lock, const std::string &origin="unknown"){const auto covarianceKey=GenCovarianceKey(param1, param2);if(!HasParameter(param1)||!HasParameter(param2)){std::ostringstream err;err<< "Tried to set parameter covariance (" << covarianceKey.first << ", "<< covarianceKey.second << ") in ParameterStorage " << fParameterStorageName << " without beforehand setting parameter(s) ";err << '('<< param1<< ") ";err << '('<< param2<< ") ";err << "with call from \"" << origin<< "\" origin.";throw InvalidConfigurationException(err.str().c_str());}const auto it=fParameterCovarianceMap.find(covarianceKey);if(it!=fParameterCovarianceMap.end()){if(it-> second.second){std::ostringstream err;err<< "Tried to re-set locked parameter covariance (" << covarianceKey.first << ", "<< covarianceKey.second << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw InvalidConfigurationException(err.str().c_str());}}fParameterCovarianceMap[covarianceKey]=std::make_pair(value, lock);}void DeleteParameterCovariance(const IndexEnum param1, const IndexEnum param2, const std::string &origin="unknown"){const auto covarianceKey=GenCovarianceKey(param1, param2);if(HasParameterCovariance(param1, param2)){if(fParameterCovarianceMap[covarianceKey].second){std::ostringstream err;err<< "Tried to delete locked parameter covariance (" << covarianceKey.first << ", "<< covarianceKey.second << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw InvalidConfigurationException(err.str().c_str());}fParameterCovarianceMap.erase(covarianceKey);}}std::vector < IndexEnum > | const |
std::vector< std::pair < IndexEnum, IndexEnum > > | const |
get a std::vector containing the enum-pairs for which covariances have been set More... | |
else | |
return | enumVector |
return it second | first |
err<< "Tried to get locking status of unset parameter (" << param<< ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw NonExistentComponentException(err.str().c_str());}}void SetParameter(const IndexEnum param, const ParameterType value, const bool lock, const std::string &origin="unknown"){const auto it=fParameterMap.find(param);if(it!=fParameterMap.end()){if(it-> second.second){std::ostringstream err;err<< "Tried to re-set locked parameter ("<< param << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw InvalidConfigurationException(err.str().c_str());}}fParameterMap[param]=std::make_pair(value, lock);}void DeleteParameter(const IndexEnum param, const std::string &origin="unknown"){DeleteParameterCovariance(param, pv.first);const auto it=fParameterMap.find(param);if(it!=fParameterMap.end()){if(it-> second.second){std::ostringstream err;err<< "Tried to delete locked parameter ("<< param << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw InvalidConfigurationException(err.str().c_str());}fParameterMap.erase(it);}}bool const {const auto covarianceKey=GenCovarianceKey(param1, param2);return fParameterCovarianceMap.find(covarianceKey)!=fParameterCovarianceMap.end();}const ParameterCovarianceType &const {const auto covarianceKey=GenCovarianceKey(param1, param2);const auto it=fParameterCovarianceMap.find(covarianceKey);return it-> second | first |
err<< "Tried to get unset parameter ("<< param<< ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw NonExistentComponentException(err.str().c_str());}}bool const {const auto it=fParameterMap.find(param);return it-> second | second |
err<< "Tried to get unset parameter covariance (" << covarianceKey.first << ", "<< covarianceKey.second << ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin<< "\" origin.";throw NonExistentComponentException(err.str().c_str());}}bool const {const auto covarianceKey=GenCovarianceKey(param1, param2);const auto it=fParameterCovarianceMap.find(covarianceKey);return it-> second | second |
Private Member Functions | |
std::pair< IndexEnum, IndexEnum > | GenCovarianceKey (const IndexEnum param1, const IndexEnum param2) const |
helper function to create the key for the covariance map from the parameters using sorting More... | |
Private Attributes | |
ParameterCovarianceMap | fParameterCovarianceMap |
the map containing the stored parameter covariances of type ParameterCovarianceType More... | |
ParameterMap | fParameterMap |
the map containing the stored parameters of type ParameterType More... | |
std::string | fParameterStorageName |
Template class allowing to store parameters and their covariances using enums to address them with a general interface.
IndexEnum | The enum class defining the list of allowed parameters. |
ParameterType | The data type of the parameters to be stored, usually double. |
ParameterCovarianceType | The data type of the covariances to be stored, usually double. |
Definition at line 30 of file ParameterStorage.h.
typedef std::vector<IndexEnum> utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::EnumVector |
Definition at line 35 of file ParameterStorage.h.
typedef std::map<std::pair<IndexEnum, IndexEnum>, std::pair<ParameterCovarianceType, bool> > utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::ParameterCovarianceMap |
Definition at line 34 of file ParameterStorage.h.
typedef std::map<IndexEnum, std::pair<ParameterType, bool> > utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::ParameterMap |
Definition at line 33 of file ParameterStorage.h.
|
inline |
Constructor that sets a name for the storage, helpful to get useful exception messages.
Definition at line 38 of file ParameterStorage.h.
|
inlineprivate |
helper function to create the key for the covariance map from the parameters using sorting
Definition at line 231 of file ParameterStorage.h.
|
inline |
determine whether a parameter has been set
Definition at line 41 of file ParameterStorage.h.
Referenced by revt::ChannelRecData::HasParameter(), revt::StationRecData::HasParameter(), revt::StationSimData::HasParameter(), sevt::SdFootprintData::HasParameter(), evt::ShowerRRecData::HasParameter(), and evt::ShowerSRecData::HasParameter().
enumVector utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::push_back | ( | pv. | first | ) |
enumVector utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::push_back | ( | pc. | first | ) |
enumVector utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::reserve | ( | fParameterMap. | size() | ) |
enumVector utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::reserve | ( | fParameterCovarianceMap. | size() | ) |
const ParameterType& utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::const |
get the value of a parameter, throw exception if parameter has not been set
Definition at line 48 of file ParameterStorage.h.
err<< "Tried to get locking status of unset parameter covariance (" << covarianceKey.first << ", " << covarianceKey.second << ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw NonExistentComponentException(err.str().c_str()); } } void SetParameterCovariance(const IndexEnum param1, const IndexEnum param2, const ParameterCovarianceType value, const bool lock, const std::string& origin = "unknown") { const auto covarianceKey = GenCovarianceKey(param1, param2); if (!HasParameter(param1) || !HasParameter(param2)) { std::ostringstream err; err << "Tried to set parameter covariance (" << covarianceKey.first << ", " << covarianceKey.second << ") in ParameterStorage " << fParameterStorageName << " without beforehand setting parameter(s) "; err << '(' << param1 << ") "; err << '(' << param2 << ") "; err << "with call from \"" << origin << "\" origin."; throw InvalidConfigurationException(err.str().c_str()); } const auto it = fParameterCovarianceMap.find(covarianceKey); if (it != fParameterCovarianceMap.end()) { if (it->second.second) { std::ostringstream err; err << "Tried to re-set locked parameter covariance (" << covarianceKey.first << ", " << covarianceKey.second << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw InvalidConfigurationException(err.str().c_str()); } } fParameterCovarianceMap[covarianceKey] = std::make_pair(value, lock); } void DeleteParameterCovariance(const IndexEnum param1, const IndexEnum param2, const std::string& origin = "unknown") { const auto covarianceKey = GenCovarianceKey(param1, param2); if (HasParameterCovariance(param1, param2)) { if (fParameterCovarianceMap[covarianceKey].second) { std::ostringstream err; err << "Tried to delete locked parameter covariance (" << covarianceKey.first << ", " << covarianceKey.second << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw InvalidConfigurationException(err.str().c_str()); } fParameterCovarianceMap.erase(covarianceKey); } } std::vector<IndexEnum> utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::const |
Definition at line 209 of file ParameterStorage.h.
std::vector<std::pair<IndexEnum, IndexEnum> > utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::const |
get a std::vector containing the enum-pairs for which covariances have been set
Definition at line 221 of file ParameterStorage.h.
utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::else |
Definition at line 52 of file ParameterStorage.h.
return utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::enumVector |
Definition at line 214 of file ParameterStorage.h.
return it second utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::first |
Definition at line 51 of file ParameterStorage.h.
err<< "Tried to get locking status of unset parameter (" << param << ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw NonExistentComponentException(err.str().c_str()); } } void SetParameter(const IndexEnum param, const ParameterType value, const bool lock, const std::string& origin = "unknown") { const auto it = fParameterMap.find(param); if (it != fParameterMap.end()) { if (it->second.second) { std::ostringstream err; err << "Tried to re-set locked parameter (" << param << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw InvalidConfigurationException(err.str().c_str()); } } fParameterMap[param] = std::make_pair(value, lock); } void DeleteParameter(const IndexEnum param, const std::string& origin = "unknown") { DeleteParameterCovariance(param, pv.first); const auto it = fParameterMap.find(param); if (it != fParameterMap.end()) { if (it->second.second) { std::ostringstream err; err << "Tried to delete locked parameter (" << param << ") in ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw InvalidConfigurationException(err.str().c_str()); } fParameterMap.erase(it); } } bool const { const auto covarianceKey = GenCovarianceKey(param1, param2); return fParameterCovarianceMap.find(covarianceKey) != fParameterCovarianceMap.end(); } const ParameterCovarianceType& const { const auto covarianceKey = GenCovarianceKey(param1, param2); const auto it = fParameterCovarianceMap.find(covarianceKey); return it-> second utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::first |
Definition at line 127 of file ParameterStorage.h.
|
private |
the map containing the stored parameter covariances of type ParameterCovarianceType
Definition at line 238 of file ParameterStorage.h.
|
private |
the map containing the stored parameters of type ParameterType
Definition at line 235 of file ParameterStorage.h.
Referenced by utl::ParameterStorage< Parameter >::HasParameter().
|
private |
Definition at line 240 of file ParameterStorage.h.
err<< "Tried to get unset parameter (" << param << ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw NonExistentComponentException(err.str().c_str()); } } bool const { const auto it = fParameterMap.find(param); return it-> second utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::second |
Definition at line 67 of file ParameterStorage.h.
err<< "Tried to get unset parameter covariance (" << covarianceKey.first << ", " << covarianceKey.second << ") from ParameterStorage " << fParameterStorageName << " with call from \"" << origin << "\" origin."; throw NonExistentComponentException(err.str().c_str()); } } bool const { const auto covarianceKey = GenCovarianceKey(param1, param2); const auto it = fParameterCovarianceMap.find(covarianceKey); return it-> second utl::ParameterStorage< IndexEnum, ParameterType, ParameterCovarianceType >::second |
Definition at line 145 of file ParameterStorage.h.