Loading src/core/geometry/DetectorField.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ namespace allpix { /** * @brief Field instance of a detector * * Contains the a pointer to the field dat along with the field sizes, binning and potential field distortions such as * Contains the a pointer to the field data along with the field sizes, binning and potential field distortions such as * scaling or offset parameters. */ template <typename T, size_t N = 3> class DetectorField { Loading src/core/geometry/DetectorField.tpp +57 −38 Original line number Diff line number Diff line Loading @@ -28,6 +28,25 @@ namespace allpix { return {}; } auto z = pos.z(); if(type_ == FieldType::CONSTANT) { // Constant field - return value return function_(pos); } else if(type_ == FieldType::LINEAR) { // Linear field - return value at given depth // Check if we need to extrapolate along the z axis or if is inside thickness domain: if(extrapolate_z) { z = std::clamp(z, thickness_domain_.first, thickness_domain_.second); } else if(z < thickness_domain_.first || thickness_domain_.second < z) { return {}; } // Calculate the field from the configured function: return function_(ROOT::Math::XYZPoint(0, 0, z)); } else { // For per-pixel fields, resort to getRelativeTo with current pixel as reference: if(mapping_ != FieldMapping::SENSOR) { // Calculate center of current pixel from index as reference point: Loading @@ -41,7 +60,6 @@ namespace allpix { // Shift the coordinates by the offset configured for the field: auto x = pos.x() + offset_[0]; auto y = pos.y() + offset_[1]; auto z = pos.z(); auto pitch = model_->getPixelSize(); Loading @@ -58,8 +76,8 @@ namespace allpix { x *= ((replica_x % 2) == 1 ? -1 : 1); y *= ((replica_y % 2) == 1 ? -1 : 1); // Compute using the grid or a function depending on the setting T ret_val; // Compute using the grid or a function depending on the setting if(type_ == FieldType::GRID) { ret_val = get_field_from_grid( ROOT::Math::XYZPoint(x * normalization_[0] + 0.5, y * normalization_[1] + 0.5, pos.z()), extrapolate_z); Loading @@ -79,6 +97,7 @@ namespace allpix { flip_vector_components(ret_val, replica_x % 2, replica_y % 2); return ret_val; } } /** * Get a value from the field assigned to a specific pixel. This means, we cannot wrap around at the pixel edges and Loading src/tools/field_parser.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ namespace allpix { * @brief Field quantities */ enum class FieldQuantity : size_t { UNKNOWN = 0, ///< Unknown fiield quantity UNKNOWN = 0, ///< Unknown field quantity SCALAR = 1, ///< Scalar field, i.e. one entry per field position VECTOR = 3, ///< Vector field, i.e. three entries per field position }; Loading Loading
src/core/geometry/DetectorField.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ namespace allpix { /** * @brief Field instance of a detector * * Contains the a pointer to the field dat along with the field sizes, binning and potential field distortions such as * Contains the a pointer to the field data along with the field sizes, binning and potential field distortions such as * scaling or offset parameters. */ template <typename T, size_t N = 3> class DetectorField { Loading
src/core/geometry/DetectorField.tpp +57 −38 Original line number Diff line number Diff line Loading @@ -28,6 +28,25 @@ namespace allpix { return {}; } auto z = pos.z(); if(type_ == FieldType::CONSTANT) { // Constant field - return value return function_(pos); } else if(type_ == FieldType::LINEAR) { // Linear field - return value at given depth // Check if we need to extrapolate along the z axis or if is inside thickness domain: if(extrapolate_z) { z = std::clamp(z, thickness_domain_.first, thickness_domain_.second); } else if(z < thickness_domain_.first || thickness_domain_.second < z) { return {}; } // Calculate the field from the configured function: return function_(ROOT::Math::XYZPoint(0, 0, z)); } else { // For per-pixel fields, resort to getRelativeTo with current pixel as reference: if(mapping_ != FieldMapping::SENSOR) { // Calculate center of current pixel from index as reference point: Loading @@ -41,7 +60,6 @@ namespace allpix { // Shift the coordinates by the offset configured for the field: auto x = pos.x() + offset_[0]; auto y = pos.y() + offset_[1]; auto z = pos.z(); auto pitch = model_->getPixelSize(); Loading @@ -58,8 +76,8 @@ namespace allpix { x *= ((replica_x % 2) == 1 ? -1 : 1); y *= ((replica_y % 2) == 1 ? -1 : 1); // Compute using the grid or a function depending on the setting T ret_val; // Compute using the grid or a function depending on the setting if(type_ == FieldType::GRID) { ret_val = get_field_from_grid( ROOT::Math::XYZPoint(x * normalization_[0] + 0.5, y * normalization_[1] + 0.5, pos.z()), extrapolate_z); Loading @@ -79,6 +97,7 @@ namespace allpix { flip_vector_components(ret_val, replica_x % 2, replica_y % 2); return ret_val; } } /** * Get a value from the field assigned to a specific pixel. This means, we cannot wrap around at the pixel edges and Loading
src/tools/field_parser.h +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ namespace allpix { * @brief Field quantities */ enum class FieldQuantity : size_t { UNKNOWN = 0, ///< Unknown fiield quantity UNKNOWN = 0, ///< Unknown field quantity SCALAR = 1, ///< Scalar field, i.e. one entry per field position VECTOR = 3, ///< Vector field, i.e. three entries per field position }; Loading