Loading src/core/utils/exceptions.h +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ namespace allpix { * Problems that could also have been detected at compile time by specialized software */ class LogicError : public Exception { public: /** * @brief Creates exception with the given logical problem * @param what_arg Text describing the problem Loading src/core/utils/unit.tpp +19 −0 Original line number Diff line number Diff line Loading @@ -11,9 +11,12 @@ #include "text.h" #include <cmath> namespace allpix { /** * @throws std::overflow_error If the converted unit overflows the requested type * @throws allpix::LogicError If the resulting product of an input integer value and unit is not an integral value * * The unit type is internally converted to the type \ref Units::UnitType. After multiplying the unit, the output is * checked for overflow problems before the type is converted back to the original type. Loading @@ -24,6 +27,13 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { // If the input is an integral value: check so that it doesn't have decimals after applying the unit if(out != static_cast<T>(out)) { throw LogicError("Cannot use integer value with non-integer internal unit; the combination " + std::to_string(inp) + " " + str + " is invalid."); } } return static_cast<T>(out); } Loading @@ -34,6 +44,9 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getSingleInverse(T inp, std::string str) { Loading @@ -42,6 +55,9 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getInverse(T inp, const std::string& str) { Loading @@ -50,6 +66,9 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); } return static_cast<T>(out); } Loading src/modules/CapacitiveTransfer/CapacitiveTransferModule.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ CapacitiveTransferModule::CapacitiveTransferModule(Configuration& config, config_.setDefault("output_plots", 0); config_.setDefault("cross_coupling", true); config_.setDefault("nominal_gap", 0.0); config_.setDefault("max_depth_distance", Units::get(5, "um")); config_.setDefault("max_depth_distance", Units::get<double>(5, "um")); config_.setDefault("minimum_gap", config_.get<double>("nominal_gap")); cross_coupling_ = config_.get<bool>("cross_coupling"); Loading src/modules/DefaultDigitizer/DefaultDigitizerModule.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ DefaultDigitizerModule::DefaultDigitizerModule(Configuration& config, // TDC configuration config_.setDefault<int>("tdc_resolution", 0); config_.setDefault<int>("tdc_smearing", Units::get(50, "ps")); config_.setDefault<double>("tdc_smearing", Units::get(50.0, "ps")); config_.setDefault<double>("tdc_offset", Units::get(0, "ns")); config_.setDefault<double>("tdc_slope", Units::get(10, "ns")); config_.setDefault<bool>("allow_zero_tdc", false); Loading Loading @@ -118,7 +118,7 @@ DefaultDigitizerModule::DefaultDigitizerModule(Configuration& config, allow_zero_qdc_ = config_.get<bool>("allow_zero_qdc"); tdc_resolution_ = config_.get<int>("tdc_resolution"); tdc_smearing_ = config_.get<unsigned int>("tdc_smearing"); tdc_smearing_ = config_.get<double>("tdc_smearing"); tdc_offset_ = config_.get<double>("tdc_offset"); tdc_slope_ = config_.get<double>("tdc_slope"); allow_zero_tdc_ = config_.get<bool>("allow_zero_tdc"); Loading src/modules/DefaultDigitizer/DefaultDigitizerModule.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ namespace allpix { bool allow_zero_qdc_{}; int tdc_resolution_{}; unsigned int tdc_smearing_{}; double tdc_smearing_{}; double tdc_offset_{}; double tdc_slope_{}; bool allow_zero_tdc_{}; Loading Loading
src/core/utils/exceptions.h +1 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,7 @@ namespace allpix { * Problems that could also have been detected at compile time by specialized software */ class LogicError : public Exception { public: /** * @brief Creates exception with the given logical problem * @param what_arg Text describing the problem Loading
src/core/utils/unit.tpp +19 −0 Original line number Diff line number Diff line Loading @@ -11,9 +11,12 @@ #include "text.h" #include <cmath> namespace allpix { /** * @throws std::overflow_error If the converted unit overflows the requested type * @throws allpix::LogicError If the resulting product of an input integer value and unit is not an integral value * * The unit type is internally converted to the type \ref Units::UnitType. After multiplying the unit, the output is * checked for overflow problems before the type is converted back to the original type. Loading @@ -24,6 +27,13 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { // If the input is an integral value: check so that it doesn't have decimals after applying the unit if(out != static_cast<T>(out)) { throw LogicError("Cannot use integer value with non-integer internal unit; the combination " + std::to_string(inp) + " " + str + " is invalid."); } } return static_cast<T>(out); } Loading @@ -34,6 +44,9 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getSingleInverse(T inp, std::string str) { Loading @@ -42,6 +55,9 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); } return static_cast<T>(out); } template <typename T> T Units::getInverse(T inp, const std::string& str) { Loading @@ -50,6 +66,9 @@ namespace allpix { out < static_cast<UnitType>(std::numeric_limits<T>::lowest())) { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); } return static_cast<T>(out); } Loading
src/modules/CapacitiveTransfer/CapacitiveTransferModule.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ CapacitiveTransferModule::CapacitiveTransferModule(Configuration& config, config_.setDefault("output_plots", 0); config_.setDefault("cross_coupling", true); config_.setDefault("nominal_gap", 0.0); config_.setDefault("max_depth_distance", Units::get(5, "um")); config_.setDefault("max_depth_distance", Units::get<double>(5, "um")); config_.setDefault("minimum_gap", config_.get<double>("nominal_gap")); cross_coupling_ = config_.get<bool>("cross_coupling"); Loading
src/modules/DefaultDigitizer/DefaultDigitizerModule.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ DefaultDigitizerModule::DefaultDigitizerModule(Configuration& config, // TDC configuration config_.setDefault<int>("tdc_resolution", 0); config_.setDefault<int>("tdc_smearing", Units::get(50, "ps")); config_.setDefault<double>("tdc_smearing", Units::get(50.0, "ps")); config_.setDefault<double>("tdc_offset", Units::get(0, "ns")); config_.setDefault<double>("tdc_slope", Units::get(10, "ns")); config_.setDefault<bool>("allow_zero_tdc", false); Loading Loading @@ -118,7 +118,7 @@ DefaultDigitizerModule::DefaultDigitizerModule(Configuration& config, allow_zero_qdc_ = config_.get<bool>("allow_zero_qdc"); tdc_resolution_ = config_.get<int>("tdc_resolution"); tdc_smearing_ = config_.get<unsigned int>("tdc_smearing"); tdc_smearing_ = config_.get<double>("tdc_smearing"); tdc_offset_ = config_.get<double>("tdc_offset"); tdc_slope_ = config_.get<double>("tdc_slope"); allow_zero_tdc_ = config_.get<bool>("allow_zero_tdc"); Loading
src/modules/DefaultDigitizer/DefaultDigitizerModule.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ namespace allpix { bool allow_zero_qdc_{}; int tdc_resolution_{}; unsigned int tdc_smearing_{}; double tdc_smearing_{}; double tdc_offset_{}; double tdc_slope_{}; bool allow_zero_tdc_{}; Loading