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 +6 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ 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 @@ -27,7 +28,11 @@ namespace allpix { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); // 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 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 src/modules/DepositionPointCharge/DepositionPointChargeModule.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -84,8 +84,8 @@ void DepositionPointChargeModule::initialize() { step_size_ = sqrt((end_local - start_local).Mag2()) / granularity; // We should deposit the equivalent of about 80 e/h pairs per micro meter (80`000 per mm): auto eh_per_um = config_.get<unsigned int>("number_of_charges"); carriers_ = static_cast<unsigned int>(eh_per_um * step_size_); auto eh_per_um = config_.get<double>("number_of_charges"); carriers_ = static_cast<unsigned int>(std::round(eh_per_um * step_size_)); LOG(INFO) << "Step size for MIP energy deposition: " << Units::display(step_size_, {"um", "mm"}) << ", depositing " << carriers_ << " e/h pairs per step (" << Units::display(eh_per_um, "/um") << ")"; Loading @@ -99,7 +99,7 @@ void DepositionPointChargeModule::initialize() { } else { config_.setDefault("number_of_charges", 1); carriers_ = config_.get<unsigned int>("number_of_charges"); carriers_ = static_cast<unsigned int>(std::round(config_.get<double>("number_of_charges"))); } // Set up the different scan methods 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 +6 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ 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 @@ -27,7 +28,11 @@ namespace allpix { throw std::overflow_error("unit conversion overflows the type"); } if constexpr(std::is_integral_v<T>) { out = std::round(out); // 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
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
src/modules/DepositionPointCharge/DepositionPointChargeModule.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -84,8 +84,8 @@ void DepositionPointChargeModule::initialize() { step_size_ = sqrt((end_local - start_local).Mag2()) / granularity; // We should deposit the equivalent of about 80 e/h pairs per micro meter (80`000 per mm): auto eh_per_um = config_.get<unsigned int>("number_of_charges"); carriers_ = static_cast<unsigned int>(eh_per_um * step_size_); auto eh_per_um = config_.get<double>("number_of_charges"); carriers_ = static_cast<unsigned int>(std::round(eh_per_um * step_size_)); LOG(INFO) << "Step size for MIP energy deposition: " << Units::display(step_size_, {"um", "mm"}) << ", depositing " << carriers_ << " e/h pairs per step (" << Units::display(eh_per_um, "/um") << ")"; Loading @@ -99,7 +99,7 @@ void DepositionPointChargeModule::initialize() { } else { config_.setDefault("number_of_charges", 1); carriers_ = config_.get<unsigned int>("number_of_charges"); carriers_ = static_cast<unsigned int>(std::round(config_.get<double>("number_of_charges"))); } // Set up the different scan methods Loading