Commit af2709ec authored by Jens Kroeger's avatar Jens Kroeger
Browse files

Merge branch 'aliases_reso' into 'master'

Create Aliases for old Config Keys for Backwards Compatibility

See merge request !214
parents 7af64c09 2284d720
Pipeline #1260526 failed with stages
in 4 minutes and 46 seconds
......@@ -15,6 +15,7 @@
#include <string>
#include "core/utils/file.h"
#include "core/utils/log.h"
#include "exceptions.h"
using namespace corryvreckan;
......@@ -121,7 +122,7 @@ void Configuration::setText(const std::string& key, const std::string& val) {
/**
* The alias is only used if new key does not exist but old key does
*/
void Configuration::setAlias(const std::string& new_key, const std::string& old_key) {
void Configuration::setAlias(const std::string& new_key, const std::string& old_key, bool warn) {
if(!has(old_key) || has(new_key)) {
return;
}
......@@ -130,6 +131,10 @@ void Configuration::setAlias(const std::string& new_key, const std::string& old_
} catch(std::out_of_range& e) {
throw MissingKeyError(old_key, getName());
}
if(warn) {
LOG(WARNING) << "Parameter \"" << old_key << "\" is deprecated and superseded by \"" << new_key << "\"";
}
}
unsigned int Configuration::countSettings() const {
......
......@@ -203,8 +203,9 @@ namespace corryvreckan {
* @brief Set alias name for an already existing key
* @param new_key New alias to be created
* @param old_key Key the alias is created for
* @param warn Optionally print a warning message to notify of deprecation
*/
void setAlias(const std::string& new_key, const std::string& old_key);
void setAlias(const std::string& new_key, const std::string& old_key, bool warn = false);
/**
* @brief Return total number of key / value pairs
......
......@@ -21,6 +21,9 @@ using namespace corryvreckan;
AnalysisTimingATLASpix::AnalysisTimingATLASpix(Configuration config, std::shared_ptr<Detector> detector)
: Module(std::move(config), detector) {
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
using namespace ROOT::Math;
m_detector = detector;
if(config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
......
......@@ -6,7 +6,10 @@ using namespace std;
Clustering4D::Clustering4D(Configuration config, std::shared_ptr<Detector> detector)
: Module(std::move(config), detector), m_detector(detector) {
if(config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
if(m_config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
throw InvalidCombinationError(
m_config, {"time_cut_rel", "time_cut_abs"}, "Absolute and relative time cuts are mutually exclusive.");
} else if(m_config.has("time_cut_abs")) {
......
......@@ -6,6 +6,10 @@ using namespace std;
Correlations::Correlations(Configuration config, std::shared_ptr<Detector> detector)
: Module(std::move(config), detector), m_detector(detector) {
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
m_config.setAlias("do_time_cut", "do_timing_cut", true);
do_time_cut_ = m_config.get<bool>("do_time_cut", false);
if(m_config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
throw InvalidCombinationError(
......
......@@ -6,6 +6,10 @@ using namespace std;
DUTAssociation::DUTAssociation(Configuration config, std::shared_ptr<Detector> detector)
: Module(std::move(config), detector), m_detector(detector) {
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs and spatial_cut for spatial_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
m_config.setAlias("spatial_cut_abs", "spatial_cut", true);
// timing cut, relative (x * time_resolution) or absolute:
if(m_config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
throw InvalidCombinationError(
......
......@@ -8,6 +8,10 @@ Prealignment::Prealignment(Configuration config, std::shared_ptr<Detector> detec
max_correlation_rms = m_config.get<double>("max_correlation_rms", Units::get<double>(6, "mm"));
damping_factor = m_config.get<double>("damping_factor", 1.0);
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
if(m_config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
throw InvalidCombinationError(
m_config, {"time_cut_rel", "time_cut_abs"}, "Absolute and relative time cuts are mutually exclusive.");
......
......@@ -9,6 +9,10 @@ using namespace std;
Tracking4D::Tracking4D(Configuration config, std::vector<std::shared_ptr<Detector>> detectors)
: Module(std::move(config), std::move(detectors)) {
// Backwards compatibilty: also allow timing_cut to be used for time_cut_abs and spatial_cut for spatial_cut_abs
m_config.setAlias("time_cut_abs", "timing_cut", true);
m_config.setAlias("spatial_cut_abs", "spatial_cut", true);
// timing cut, relative (x * time_resolution) or absolute:
if(m_config.count({"time_cut_rel", "time_cut_abs"}) > 1) {
throw InvalidCombinationError(
......
......@@ -20,6 +20,9 @@ TrackingSpatial::TrackingSpatial(Configuration config, std::vector<std::shared_p
minHitsOnTrack = m_config.get<size_t>("min_hits_on_track", 6);
excludeDUT = m_config.get<bool>("exclude_dut", true);
// Backwards compatibilty: also allow spatial_cut to be used for spatial_cut_abs
m_config.setAlias("spatial_cut_abs", "spatial_cut", true);
// spatial cut, relative (x * spatial_resolution) or absolute:
if(m_config.count({"spatial_cut_rel", "spatial_cut_abs"}) > 1) {
throw InvalidCombinationError(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment