From 2b475bbf4f0447b639a7d727487ca988b26c4dba Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:47:06 +0530 Subject: [PATCH 01/11] Added Fastor to the CMakeLists.txt files. --- core/CMakeLists.txt | 8 ++++++++ plugins/algebra/CMakeLists.txt | 3 +++ tests/benchmarks/cpu/CMakeLists.txt | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 9a8804d674..dfeb5ac0b5 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -98,6 +98,14 @@ if(DETRAY_VC_SOA_PLUGIN) ) endif() +if(DETRAY_FASTOR_PLUGIN) + detray_add_library( detray_core_fastor core_fastor ) + target_link_libraries( + detray_core_fastor + INTERFACE detray::core detray::algebra_fastor + ) +endif() + # Test the public headers of the detray core libraries. if(BUILD_TESTING AND DETRAY_BUILD_TESTING) string( diff --git a/plugins/algebra/CMakeLists.txt b/plugins/algebra/CMakeLists.txt index 3a025e43e3..8eb1a057cf 100644 --- a/plugins/algebra/CMakeLists.txt +++ b/plugins/algebra/CMakeLists.txt @@ -25,3 +25,6 @@ endif() if(DETRAY_VC_SOA_PLUGIN) add_subdirectory(vc_soa) endif() +if(DETRAY_FASTOR_PLUGIN) + add_subdirectory(fastor) +endif() diff --git a/tests/benchmarks/cpu/CMakeLists.txt b/tests/benchmarks/cpu/CMakeLists.txt index c72bb07244..7bd98ed2fc 100644 --- a/tests/benchmarks/cpu/CMakeLists.txt +++ b/tests/benchmarks/cpu/CMakeLists.txt @@ -125,3 +125,8 @@ if(DETRAY_VC_SOA_PLUGIN) # detray_add_soa_benchmark( eigen ) # detray_add_soa_benchmark( vc_aos ) endif() + +# Build the Fastor benchmark executable. +if(DETRAY_FASTOR_PLUGIN) + detray_add_cpu_benchmark( fastor ) +endif() From 4c08009bfdb1066b4f84c66a9bbf67c588ed0481 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:48:19 +0530 Subject: [PATCH 02/11] Added the Fastor backend. --- plugins/algebra/fastor/CMakeLists.txt | 36 ++++++++ .../plugins/algebra/fastor_definitions.hpp | 89 +++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 plugins/algebra/fastor/CMakeLists.txt create mode 100644 plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp diff --git a/plugins/algebra/fastor/CMakeLists.txt b/plugins/algebra/fastor/CMakeLists.txt new file mode 100644 index 0000000000..0b792ca1eb --- /dev/null +++ b/plugins/algebra/fastor/CMakeLists.txt @@ -0,0 +1,36 @@ +# Detray library, part of the ACTS project (R&D line) +# +# (c) 2025 CERN for the benefit of the ACTS project +# +# Mozilla Public License Version 2.0 + +message(STATUS "Building the 'detray::algebra_fastor' plugin") + +# A sanity check. +if(NOT ALGEBRA_PLUGINS_INCLUDE_FASTOR) + message( + WARNING + "Fastor not available from Algebra Plugins. " + "The configuration will likely fail." + ) +endif() + +# Set up the library. +detray_add_library( detray_algebra_fastor algebra_fastor + "include/detray/plugins/algebra/fastor_definitions.hpp" +) +target_link_libraries( + detray_algebra_fastor + INTERFACE algebra::utils algebra::fastor_fastor vecmem::core +) +target_compile_definitions( + detray_algebra_fastor + INTERFACE + DETRAY_CUSTOM_SCALARTYPE=${DETRAY_CUSTOM_SCALARTYPE} + DETRAY_ALGEBRA_FASTOR +) + +# Set up tests for the public header(s) of detray::algebra_fastor. +detray_test_public_headers( detray_algebra_fastor + "detray/plugins/algebra/fastor_definitions.hpp" +) diff --git a/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp b/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp new file mode 100644 index 0000000000..4049952e00 --- /dev/null +++ b/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp @@ -0,0 +1,89 @@ +// /** Detray library, part of the ACTS project (R&D line) +// * +// * (c) 2023 CERN for the benefit of the ACTS project +// * +// * Mozilla Public License Version 2.0 +// */ + +// #pragma once + +// // Algebra-Plugins include +// #include "algebra/fastor_fastor.hpp" + +// #define __plugin algebra::fastor +// #define ALGEBRA_PLUGIN fastor + +// namespace detray { + +// // Define scalar type +// using scalar = DETRAY_CUSTOM_SCALARTYPE; + +// // Define namespace(s) +// namespace getter = algebra::getter; +// namespace vector = algebra::vector; +// namespace matrix = algebra::matrix; + +// // Define matrix/vector operator +// template +// using standard_matrix_operator = +// matrix::actor, +// matrix::inverse::preset0>; + +// } // namespace detray + + +/** Detray library, part of the ACTS project (R&D line) + * + * (c) 2025 CERN for the benefit of the ACTS project + * + * Mozilla Public License Version 2.0 + */ + + #pragma once + + // Algebra-Plugins include + #include "algebra/fastor_fastor.hpp" + + namespace detray { + + /// The plugin definition + template + using fastor = algebra::plugin::fastor; + + namespace getter { + + using algebra::fastor::storage::block; + using algebra::fastor::storage::element; + using algebra::fastor::storage::set_block; + using algebra::fastor::storage::vector; + + } // namespace getter + + namespace vector { + + using algebra::fastor::math::cross; + using algebra::fastor::math::dot; + using algebra::fastor::math::eta; + using algebra::fastor::math::norm; + using algebra::fastor::math::normalize; + + using algebra::fastor::math::perp; + using algebra::fastor::math::phi; + using algebra::fastor::math::theta; + + } // namespace vector + + namespace matrix { + + using algebra::fastor::math::determinant; + using algebra::fastor::math::identity; + using algebra::fastor::math::inverse; + using algebra::fastor::math::set_identity; + using algebra::fastor::math::set_zero; + using algebra::fastor::math::transpose; + using algebra::fastor::math::zero; + + } // namespace matrix + + } // namespace detray + From bfbed3427c9fe08b484d9fe87f564e7db336169c Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:48:41 +0530 Subject: [PATCH 03/11] Added the Fastor backend to the algebra backends file. --- core/include/detray/definitions/algebra.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/include/detray/definitions/algebra.hpp b/core/include/detray/definitions/algebra.hpp index 2c084111bc..88b920e3eb 100644 --- a/core/include/detray/definitions/algebra.hpp +++ b/core/include/detray/definitions/algebra.hpp @@ -17,6 +17,8 @@ #include "detray/plugins/algebra/vc_aos_definitions.hpp" #elif DETRAY_ALGEBRA_VC_SOA #include "detray/plugins/algebra/vc_soa_definitions.hpp" +#elif DETRAY_ALGEBRA_FASTOR +#include "detray/plugins/algebra/fastor_definitions.hpp" #else #error "No algebra plugin selected! Please link to one of the algebra plugins." #endif From 3d28674ebc6793eeb3fc953da94d8cda05ba5982 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 24 Mar 2025 23:17:22 +0530 Subject: [PATCH 04/11] Added the files which needed special casing for Fastor. --- .../detray/geometry/coordinates/line2D.hpp | 9 +++- .../detray/geometry/shapes/annulus2D.hpp | 49 ++++++++++--------- .../intersection/ray_cylinder_intersector.hpp | 23 +++++---- .../intersection/ray_plane_intersector.hpp | 24 +++++---- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/core/include/detray/geometry/coordinates/line2D.hpp b/core/include/detray/geometry/coordinates/line2D.hpp index e676dae03d..4a72285341 100644 --- a/core/include/detray/geometry/coordinates/line2D.hpp +++ b/core/include/detray/geometry/coordinates/line2D.hpp @@ -49,7 +49,12 @@ struct line2D { // Assign the sign depending on the position w.r.t line // Right: -1 // Left: 1 - const scalar_type sign = vector::dot(r, t - p) > 0.f ? -1.f : 1.f; +#ifdef DETRAY_ALGEBRA_FASTOR + const vector3_type tmp = t - p; + const scalar_type sign = vector::dot(r, tmp) > 0. ? -1. : 1.; +#else + const scalar_type sign = vector::dot(r, t - p) > 0. ? -1. : 1.; +#endif return {sign * vector::perp(local3), local3[2], vector::phi(local3)}; } @@ -93,7 +98,7 @@ struct line2D { // Local Z poisition in global cartesian coordinate const point3_type locZ_in_global = - trf.point_to_global(point3_type{0.f, 0.f, p[1]}); + trf.point_to_global(point3_type{0., 0., p[1]}); return locZ_in_global + p[0] * vector::normalize(r); } diff --git a/core/include/detray/geometry/shapes/annulus2D.hpp b/core/include/detray/geometry/shapes/annulus2D.hpp index 5f39ff371c..247bae27d3 100644 --- a/core/include/detray/geometry/shapes/annulus2D.hpp +++ b/core/include/detray/geometry/shapes/annulus2D.hpp @@ -76,7 +76,7 @@ class annulus2D { DETRAY_HOST_DEVICE darray stereo_angle( const bounds_type &bounds) const { // Half stereo angle (phi_s / 2) (y points in the long strip direction) - return 2.f * math::atan(bounds[e_shift_y] / bounds[e_shift_x]); + return 2. * math::atan(bounds[e_shift_y] / bounds[e_shift_x]); } /// @returns The phi position in relative to the average phi of the annulus. @@ -95,12 +95,12 @@ class annulus2D { // Go to beam frame to check r boundaries. Use the origin // shift in polar coordinates for that // TODO: Put shift in r-phi into the bounds? - const point_t shift_xy = {-bounds[e_shift_x], -bounds[e_shift_y], 0.f}; + const point_t shift_xy = {-bounds[e_shift_x], -bounds[e_shift_y], 0.}; const scalar_t shift_r = vector::perp(shift_xy); const scalar_t shift_phi = vector::phi(shift_xy); return shift_r * shift_r + loc_p[0] * loc_p[0] + - 2.f * shift_r * loc_p[0] * + 2. * shift_r * loc_p[0] * math::cos(get_phi_rel(bounds, loc_p) - shift_phi); } @@ -135,7 +135,7 @@ class annulus2D { // Compare the radius with the chord return math::min(min_r_dist, - 2.f * loc_p[0] * math::sin(0.5f * min_phi_dist)); + 2. * loc_p[0] * math::sin(0.5 * min_phi_dist)); } /// @brief Check boundary values for a local point. @@ -170,7 +170,7 @@ class annulus2D { const scalar_t minR_tol = bounds[e_min_r] - tol; const scalar_t maxR_tol = bounds[e_max_r] + tol; - assert(detail::all_of(minR_tol >= scalar_t(0.f))); + assert(detail::all_of(minR_tol >= scalar_t(0.))); return ((r_beam2 >= (minR_tol * minR_tol)) && (r_beam2 <= (maxR_tol * maxR_tol))) && @@ -222,7 +222,7 @@ class annulus2D { using scalar_t = dscalar; using point_t = dpoint2D; - assert(env > 0.f); + assert(env > 0.); const auto c_pos = corners(bounds); @@ -237,7 +237,12 @@ class annulus2D { // bisector = 0.5 * (c + b). Scale to the length of the full circle to // get the outermost point +#ifdef DETRAY_ALGEBRA_FASTOR + const point_t tmp = c + b; + const point_t t = bounds[e_max_r] * vector::normalize(tmp); +#else const point_t t = bounds[e_max_r] * vector::normalize(c + b); +#endif // Find the min/max positions in x and y darray x_pos{c_pos[2] * math::cos(c_pos[3]) - o_x, b[0], @@ -326,10 +331,10 @@ class annulus2D { const auto crns = corners(bounds); // Coordinates of the centroid position in strip system - const scalar_t r{0.25f * (crns[0] + crns[2] + crns[4] + crns[6])}; + const scalar_t r{0.25 * (crns[0] + crns[2] + crns[4] + crns[6])}; const scalar_t phi{bounds[e_average_phi]}; - return r * dpoint3D{math::cos(phi), math::sin(phi), 0.f}; + return r * dpoint3D{math::cos(phi), math::sin(phi), 0.}; } /// Generate vertices in local cartesian frame @@ -372,21 +377,21 @@ class annulus2D { point2_t dir = {math::cos(phi), math::sin(phi)}; scalar_t x1 = (O_x + O_y * m - - math::sqrt(-math::pow(O_x, 2.f) * math::pow(m, 2.f) + - 2.f * O_x * O_y * m - math::pow(O_y, 2.f) + - math::pow(m, 2.f) * math::pow(r, 2.f) + - math::pow(r, 2.f))) / - (math::pow(m, 2.f) + 1.f); + math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + + 2. * O_x * O_y * m - math::pow(O_y, 2.) + + math::pow(m, 2.) * math::pow(r, 2.) + + math::pow(r, 2.))) / + (math::pow(m, 2.) + 1.); scalar_t x2 = (O_x + O_y * m + - math::sqrt(-math::pow(O_x, 2.f) * math::pow(m, 2.f) + - 2.f * O_x * O_y * m - math::pow(O_y, 2.f) + - math::pow(m, 2.f) * math::pow(r, 2.f) + - math::pow(r, 2.f))) / - (math::pow(m, 2.f) + 1.f); + math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + + 2. * O_x * O_y * m - math::pow(O_y, 2.) + + math::pow(m, 2.) * math::pow(r, 2.) + + math::pow(r, 2.))) / + (math::pow(m, 2.) + 1.); point2_t v1 = {x1, m * x1}; - if (vector::dot(v1, dir) > 0.f) + if (vector::dot(v1, dir) > 0.) return v1; return {x2, m * x2}; }; @@ -409,13 +414,13 @@ class annulus2D { for (scalar_t iphi : inner_phi) { annulus_vertices.push_back( point3_t{min_r * math::cos(iphi) + origin_x, - min_r * math::sin(iphi) + origin_y, 0.f}); + min_r * math::sin(iphi) + origin_y, 0.}); } for (scalar_t ophi : outer_phi) { annulus_vertices.push_back( point3_t{max_r * math::cos(ophi) + origin_x, - max_r * math::sin(ophi) + origin_y, 0.f}); + max_r * math::sin(ophi) + origin_y, 0.}); } return annulus_vertices; @@ -431,7 +436,7 @@ class annulus2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (math::signbit(bounds[e_min_r]) || bounds[e_max_r] < tol) { os << "ERROR: Radial bounds must be in the range [0, numeric_max)"; diff --git a/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp index 15e87d1ea4..3d28dd7799 100644 --- a/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp @@ -61,9 +61,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { operator()(const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 100.f * unit::um}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 100. * unit::um}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); @@ -102,8 +102,8 @@ struct ray_intersector_impl, algebra_t, do_debug> { operator()(const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.f) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, + const scalar_type overstep_tol = 0.) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., overstep_tol); } @@ -122,9 +122,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); @@ -156,10 +156,15 @@ struct ray_intersector_impl, algebra_t, do_debug> { const point3_type &ro = ray.pos(); const vector3_type &rd = ray.dir(); +#ifdef DETRAY_ALGEBRA_FASTOR + const vector3_type tmp = ro - sc; + const auto pc_cross_sz = vector::cross(tmp, sz); +#else const auto pc_cross_sz = vector::cross(ro - sc, sz); +#endif const auto rd_cross_sz = vector::cross(rd, sz); const scalar_type a{vector::dot(rd_cross_sz, rd_cross_sz)}; - const scalar_type b{2.f * vector::dot(rd_cross_sz, pc_cross_sz)}; + const scalar_type b{2. * vector::dot(rd_cross_sz, pc_cross_sz)}; const scalar_type c{vector::dot(pc_cross_sz, pc_cross_sz) - (r * r)}; return detail::quadratic_equation{a, b, c}; diff --git a/core/include/detray/navigation/intersection/ray_plane_intersector.hpp b/core/include/detray/navigation/intersection/ray_plane_intersector.hpp index 56c614a64a..6ff3bd23e1 100644 --- a/core/include/detray/navigation/intersection/ray_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_plane_intersector.hpp @@ -60,9 +60,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -75,9 +75,13 @@ struct ray_intersector_impl, algebra_t, do_debug> { const vector3_type &rd = ray.dir(); const scalar_type denom = vector::dot(rd, sn); // this is dangerous - if (denom != 0.f) { + if (denom != 0.) { +#ifdef DETRAY_ALGEBRA_FASTOR + const vector3_type tmp = st - ro; + is.path = vector::dot(sn, tmp) / denom; +#else is.path = vector::dot(sn, st - ro) / denom; - +#endif // Intersection is valid for navigation - continue if (is.path >= overstep_tol) { @@ -108,8 +112,8 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.f) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, + const scalar_type overstep_tol = 0.) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., overstep_tol); } @@ -129,9 +133,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } From 95cbb93f472832a86ae10741dfb50b12d2b63ab3 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Mon, 24 Mar 2025 23:18:22 +0530 Subject: [PATCH 05/11] Removed the trailing `f` in floating point numbers. --- core/include/detray/builders/bin_fillers.hpp | 2 +- .../builders/cuboid_portal_generator.hpp | 18 +-- .../builders/cylinder_portal_generator.hpp | 34 ++--- .../detray/builders/detail/associator.hpp | 12 +- .../builders/detail/bin_association.hpp | 4 +- .../builders/detail/portal_accessor.hpp | 4 +- .../detray/builders/detector_builder.hpp | 10 +- .../homogeneous_material_generator.hpp | 2 +- .../builders/material_map_generator.hpp | 6 +- .../geometry/coordinates/cartesian2D.hpp | 2 +- .../coordinates/concentric_cylindrical2D.hpp | 4 +- .../geometry/coordinates/cylindrical2D.hpp | 4 +- .../detray/geometry/coordinates/polar2D.hpp | 2 +- .../detray/geometry/detail/shape_utils.hpp | 2 +- .../geometry/shapes/concentric_cylinder2D.hpp | 8 +- .../detray/geometry/shapes/cuboid3D.hpp | 6 +- .../detray/geometry/shapes/cylinder2D.hpp | 8 +- .../detray/geometry/shapes/cylinder3D.hpp | 10 +- core/include/detray/geometry/shapes/line.hpp | 18 +-- .../detray/geometry/shapes/rectangle2D.hpp | 16 +-- .../include/detray/geometry/shapes/ring2D.hpp | 6 +- .../detray/geometry/shapes/single3D.hpp | 6 +- .../detray/geometry/shapes/trapezoid2D.hpp | 24 ++-- .../detray/geometry/shapes/unmasked.hpp | 2 +- core/include/detray/grids/axis.hpp | 4 +- .../materials/detail/density_effect_data.hpp | 14 +- .../detail/relativistic_quantities.hpp | 84 ++++++------ core/include/detray/materials/interaction.hpp | 50 +++---- core/include/detray/materials/material.hpp | 16 +-- .../include/detray/materials/material_rod.hpp | 6 +- .../detray/materials/material_slab.hpp | 10 +- core/include/detray/materials/mixture.hpp | 4 +- .../detray/materials/predefined_materials.hpp | 128 +++++++++--------- .../detray/navigation/direct_navigator.hpp | 2 +- .../bounding_box/cuboid_intersector.hpp | 8 +- .../helix_cylinder_intersector.hpp | 26 ++-- .../intersection/helix_line_intersector.hpp | 34 ++--- .../intersection/helix_plane_intersector.hpp | 28 ++-- .../ray_concentric_cylinder_intersector.hpp | 22 +-- .../ray_cylinder_portal_intersector.hpp | 16 +-- .../intersection/ray_line_intersector.hpp | 22 +-- .../soa/ray_cylinder_intersector.hpp | 22 +-- .../soa/ray_cylinder_portal_intersector.hpp | 14 +- .../intersection/soa/ray_line_intersector.hpp | 16 +-- .../soa/ray_plane_intersector.hpp | 12 +- .../detray/navigation/intersection_kernel.hpp | 16 +-- .../include/detray/navigation/intersector.hpp | 10 +- core/include/detray/navigation/navigator.hpp | 16 +-- core/include/detray/navigation/policies.hpp | 4 +- .../detray/propagator/actors/aborters.hpp | 4 +- .../actors/pointwise_material_interactor.hpp | 22 +-- .../detray/propagator/base_stepper.hpp | 8 +- .../propagator/detail/jacobian_cartesian.hpp | 2 +- .../detail/jacobian_cylindrical.hpp | 2 +- .../propagator/detail/jacobian_engine.hpp | 8 +- .../propagator/detail/jacobian_line.hpp | 4 +- .../propagator/detail/jacobian_polar.hpp | 4 +- .../detray/propagator/line_stepper.hpp | 4 +- core/include/detray/propagator/rk_stepper.hpp | 8 +- core/include/detray/propagator/rk_stepper.ipp | 72 +++++----- .../detray/tracks/bound_track_parameters.hpp | 18 +-- .../detray/tracks/free_track_parameters.hpp | 14 +- core/include/detray/tracks/helix.hpp | 18 +-- core/include/detray/tracks/ray.hpp | 6 +- core/include/detray/utils/axis_rotation.hpp | 12 +- core/include/detray/utils/bounding_volume.hpp | 12 +- .../detray/utils/grid/detail/axis_binning.hpp | 2 +- core/include/detray/utils/matrix_helper.hpp | 4 +- .../detray/utils/quadratic_equation.hpp | 28 ++-- core/include/detray/utils/root_finding.hpp | 34 ++--- core/include/detray/utils/string_helpers.hpp | 5 +- core/include/detray/utils/unit_vectors.hpp | 6 +- tests/benchmarks/cpu/find_volume.cpp | 2 +- tests/benchmarks/cpu/propagation.cpp | 4 +- .../test/common/detector_scan_config.hpp | 2 +- .../common/material_validation_config.hpp | 2 +- .../common/navigation_validation_config.hpp | 2 +- .../include/detray/test/cpu/detector_scan.hpp | 2 +- .../include/detray/test/cpu/material_scan.hpp | 10 +- .../detray/test/cpu/material_validation.hpp | 2 +- .../detray/test/cpu/navigation_validation.hpp | 4 +- .../device/cuda/navigation_validation.hpp | 4 +- .../detray/test/device/propagator_test.hpp | 4 +- .../detectors/build_telescope_detector.hpp | 8 +- .../utils/detectors/build_toy_detector.hpp | 36 ++--- .../utils/detectors/build_wire_chamber.hpp | 2 +- .../detectors/factories/barrel_generator.hpp | 4 +- .../detectors/factories/endcap_generator.hpp | 20 +-- .../factories/telescope_generator.hpp | 4 +- .../factories/wire_layer_generator.hpp | 6 +- .../include/detray/test/utils/inspectors.hpp | 2 +- .../test/utils/planes_along_direction.hpp | 2 +- .../detray/test/utils/prefill_detector.hpp | 8 +- .../random_track_generator.hpp | 2 +- .../random_track_generator_config.hpp | 18 +-- .../uniform_track_generator.hpp | 10 +- .../uniform_track_generator_config.hpp | 14 +- .../utils/simulation/random_scatterer.hpp | 6 +- .../utils/simulation/scattering_helper.hpp | 4 +- .../include/detray/test/utils/statistics.hpp | 2 +- tests/include/detray/test/utils/types.hpp | 4 + .../test/validation/detector_scanner.hpp | 14 +- .../validation/material_validation_utils.hpp | 18 +-- .../navigation_validation_utils.hpp | 4 +- .../detray/test/validation/step_tracer.hpp | 4 +- .../detray/test/validation/svg_display.hpp | 2 +- 106 files changed, 664 insertions(+), 659 deletions(-) diff --git a/core/include/detray/builders/bin_fillers.hpp b/core/include/detray/builders/bin_fillers.hpp index 82a19a1cfa..952e0df22d 100644 --- a/core/include/detray/builders/bin_fillers.hpp +++ b/core/include/detray/builders/bin_fillers.hpp @@ -128,7 +128,7 @@ struct bin_associator { // Fill the surfaces into the grid by matching their contour onto the // grid bins bin_association(ctx, surfaces, transforms, masks, grid, - darray{0.1f, 0.1f}, false); + darray{0.1, 0.1}, false); } }; diff --git a/core/include/detray/builders/cuboid_portal_generator.hpp b/core/include/detray/builders/cuboid_portal_generator.hpp index fc83982c6f..9235fa0680 100644 --- a/core/include/detray/builders/cuboid_portal_generator.hpp +++ b/core/include/detray/builders/cuboid_portal_generator.hpp @@ -117,7 +117,7 @@ class cuboid_portal_generator final // Max distance in case of infinite bounds constexpr scalar_type max_shift{ - 0.01f * std::numeric_limits::max()}; + 0.01 * std::numeric_limits::max()}; // The bounding boxes around the module surfaces std::vector boxes; @@ -139,7 +139,7 @@ class cuboid_portal_generator final const point3_t box_max = world_box.template loc_max(); // Get the half lengths for the rectangle sides and translation - const point3_t h_lengths = 0.5f * (box_max - box_min); + const point3_t h_lengths = 0.5 * (box_max - box_min); const scalar_type h_x{math::fabs(h_lengths[0])}; const scalar_type h_y{math::fabs(h_lengths[1])}; const scalar_type h_z{math::fabs(h_lengths[2])}; @@ -160,7 +160,7 @@ class cuboid_portal_generator final h_x, h_y); // No rotation, but shift in z for both faces - vector3_t shift{0.f, 0.f, + vector3_t shift{0., 0., detail::is_invalid_value(h_z) ? max_shift : h_z}; transforms.emplace_back(ctx, static_cast(center + shift)); transforms.emplace_back(ctx, static_cast(center - shift)); @@ -183,9 +183,9 @@ class cuboid_portal_generator final h_x, h_z); // Rotate by 90deg around x-axis, plus shift in y - shift = {0.f, detail::is_invalid_value(h_y) ? max_shift : h_y, 0.f}; - vector3_t new_x{1.f, 0.f, 0.f}; - vector3_t new_z{0.f, -1.f, 0.f}; + shift = {0., detail::is_invalid_value(h_y) ? max_shift : h_y, 0.}; + vector3_t new_x{1., 0., 0.}; + vector3_t new_z{0., -1., 0.}; transforms.emplace_back(ctx, static_cast(center + shift), new_z, new_x); transforms.emplace_back(ctx, static_cast(center - shift), @@ -207,9 +207,9 @@ class cuboid_portal_generator final h_z, h_y); // Rotate by 90deg around y-axis, plus shift in x - shift = {detail::is_invalid_value(h_x) ? max_shift : h_x, 0.f, 0.f}; - new_x = {0.f, 0.f, -1.f}; - new_z = {1.f, 0.f, 0.f}; + shift = {detail::is_invalid_value(h_x) ? max_shift : h_x, 0., 0.}; + new_x = {0., 0., -1.}; + new_z = {1., 0., 0.}; transforms.emplace_back(ctx, static_cast(center + shift), new_z, new_x); transforms.emplace_back(ctx, static_cast(center - shift), diff --git a/core/include/detray/builders/cylinder_portal_generator.hpp b/core/include/detray/builders/cylinder_portal_generator.hpp index 07011c8bdb..3942367487 100644 --- a/core/include/detray/builders/cylinder_portal_generator.hpp +++ b/core/include/detray/builders/cylinder_portal_generator.hpp @@ -33,13 +33,13 @@ struct cylinder_portal_config { /// Autofit the lower/upper z extend and inner/outer radii bool m_do_autofit{true}; /// Minimal envelope for the portals (used in autofitting) - scalar_t m_envelope{100.f * unit::um}; + scalar_t m_envelope{100. * unit::um}; /// Fixed inner radius during autofit - scalar_t m_fixed_inner_r{0.f}; + scalar_t m_fixed_inner_r{0.}; /// Fixed outer radius during autofit - scalar_t m_fixed_outer_r{0.f}; + scalar_t m_fixed_outer_r{0.}; /// Fixed length of the cylinder - scalar_t m_fixed_z{0.f}; + scalar_t m_fixed_z{0.}; /// The portal volumes links (north, south, east, west) std::vector m_volume_links{dindex_invalid, dindex_invalid, dindex_invalid, dindex_invalid}; @@ -137,10 +137,10 @@ class cylinder_portal_generator final public: /// Save the boundaries of the cylinder after autofitting the portals struct boundaries { - scalar_t inner_radius{0.f}; - scalar_t outer_radius{0.f}; - scalar_t lower_z{0.f}; - scalar_t upper_z{0.f}; + scalar_t inner_radius{0.}; + scalar_t outer_radius{0.}; + scalar_t lower_z{0.}; + scalar_t upper_z{0.}; }; /// Construct from configuration @param cfg @@ -194,9 +194,9 @@ class cylinder_portal_generator final if (!m_cfg.do_autofit()) { // Without autofit, the portal bounds have to be given explicitly - assert(!(m_cfg.fixed_inner_radius() == 0.f && - m_cfg.fixed_outer_radius() == 0.f) || - m_cfg.fixed_half_length() != 0.f); + assert(!(m_cfg.fixed_inner_radius() == 0. && + m_cfg.fixed_outer_radius() == 0.) || + m_cfg.fixed_half_length() != 0.); } else { // Need surfaces in volume to do autofit assert(n_surfaces != 0u); @@ -228,7 +228,7 @@ class cylinder_portal_generator final const point3_t box_max = world_box.template loc_max(); // Get the half lengths for the cylinder height and disc translation - const point3_t h_lengths = 0.5f * (box_max - box_min); + const point3_t h_lengths = 0.5 * (box_max - box_min); const scalar_t h_x{math::fabs(h_lengths[0])}; const scalar_t h_y{math::fabs(h_lengths[1])}; const scalar_t h_z{math::fabs(h_lengths[2])}; @@ -243,13 +243,13 @@ class cylinder_portal_generator final } // Observe boundary conditions - if (m_cfg.fixed_inner_radius() > 0.f) { + if (m_cfg.fixed_inner_radius() > 0.) { inner_r = m_cfg.fixed_inner_radius(); } - if (m_cfg.fixed_outer_radius() > 0.f) { + if (m_cfg.fixed_outer_radius() > 0.) { outer_r = m_cfg.fixed_outer_radius(); } - if (m_cfg.fixed_half_length() > 0.f) { + if (m_cfg.fixed_half_length() > 0.) { lower_z = -m_cfg.fixed_half_length(); upper_z = m_cfg.fixed_half_length(); } @@ -295,7 +295,7 @@ class cylinder_portal_generator final const scalar_t max_z{math::max(lower_z, upper_z)}; // translation - const point3_t tsl{0.f, 0.f, 0.f}; + const point3_t tsl{0., 0., 0.}; // Add transform and mask data transforms.emplace_back(ctx, tsl); @@ -335,7 +335,7 @@ class cylinder_portal_generator final const scalar_t max_r{math::max(inner_r, outer_r)}; // translation - point3_t tsl{0.f, 0.f, z}; + point3_t tsl{0., 0., z}; // Add transform and mask data transforms.emplace_back(ctx, tsl); diff --git a/core/include/detray/builders/detail/associator.hpp b/core/include/detray/builders/detail/associator.hpp index 6abcfa2326..cc7faf87de 100644 --- a/core/include/detray/builders/detail/associator.hpp +++ b/core/include/detray/builders/detail/associator.hpp @@ -38,11 +38,11 @@ struct center_of_gravity_rectangle { using point2_t = dpoint2D; // Check if centre of gravity is inside bin - point2_t cgs = {0.f, 0.f}; + point2_t cgs = {0., 0.}; for (const auto &svtx : surface_contour) { cgs = cgs + svtx; } - cgs = 1.f / static_cast(surface_contour.size()) * cgs; + cgs = 1. / static_cast(surface_contour.size()) * cgs; scalar_t min_l0 = std::numeric_limits::max(); scalar_t max_l0 = -std::numeric_limits::max(); scalar_t min_l1 = std::numeric_limits::max(); @@ -80,11 +80,11 @@ struct center_of_gravity_generic { using point2_t = dpoint2D; // Check if centre of gravity is inside bin - point2_t cgs = {0.f, 0.f}; + point2_t cgs = {0., 0.}; for (const auto &svtx : surface_contour) { cgs = cgs + svtx; } - cgs = 1.f / static_cast(surface_contour.size()) * cgs; + cgs = 1. / static_cast(surface_contour.size()) * cgs; std::size_t i = 0u; std::size_t j = 0u; @@ -126,14 +126,14 @@ struct edges_intersect_generic { scalar_t d = (pj[0] - pi[0]) * (pl[1] - pk[1]) - (pj[1] - pi[1]) * (pl[0] - pk[0]); - if (d != 0.f) { + if (d != 0.) { double r = ((pi[1] - pk[1]) * (pl[0] - pk[0]) - (pi[0] - pk[0]) * (pl[1] - pk[1])) / d; double s = ((pi[1] - pk[1]) * (pj[0] - pi[0]) - (pi[0] - pk[0]) * (pj[1] - pi[1])) / d; - if (r >= 0.f && r <= 1.f && s >= 0.f && s <= 1.f) { + if (r >= 0. && r <= 1. && s >= 0. && s <= 1.) { return true; } } diff --git a/core/include/detray/builders/detail/bin_association.hpp b/core/include/detray/builders/detail/bin_association.hpp index ceb56dae2d..63659e801a 100644 --- a/core/include/detray/builders/detail/bin_association.hpp +++ b/core/include/detray/builders/detail/bin_association.hpp @@ -200,7 +200,7 @@ static inline void bin_association(const context_t & /*context*/, phi_min = math::min(phi, phi_min); phi_max = math::max(phi, phi_max); surface_contour.push_back({vg[2], phi}); - if (phi < 0.f) { + if (phi < 0.) { s_c_neg.push_back({vg[2], phi}); z_min_neg = math::min(vg[2], z_min_neg); z_max_neg = math::max(vg[2], z_max_neg); @@ -214,7 +214,7 @@ static inline void bin_association(const context_t & /*context*/, std::vector> surface_contours{}; if (phi_max - phi_min > constant::pi && - phi_max * phi_min < 0.f) { + phi_max * phi_min < 0.) { s_c_neg.push_back( {z_max_neg, -constant::pi}); s_c_neg.push_back( diff --git a/core/include/detray/builders/detail/portal_accessor.hpp b/core/include/detray/builders/detail/portal_accessor.hpp index 6ee6e1ab76..d127b307b0 100644 --- a/core/include/detray/builders/detail/portal_accessor.hpp +++ b/core/include/detray/builders/detail/portal_accessor.hpp @@ -32,8 +32,8 @@ auto get_cylinder_portals(const tracking_volume &vol) { std::vector inner_pt{}, outer_pt{}, lower_pt{}, upper_pr{}; - std::map radii{0.f}; - std::map z_pos{0.f}; + std::map radii{0.}; + std::map z_pos{0.}; // Loop over all portals for (const auto &pt_desc : vol.portals()) { diff --git a/core/include/detray/builders/detector_builder.hpp b/core/include/detray/builders/detector_builder.hpp index 7ab28a5f9f..6e1e4773a6 100644 --- a/core/include/detray/builders/detector_builder.hpp +++ b/core/include/detray/builders/detector_builder.hpp @@ -123,16 +123,16 @@ class detector_builder { // TODO: Construct it correctly with the grid builder mask vgrid_dims{ - 0u, 0.f, -constant::pi, - -2000.f, 180.f, constant::pi, - 2000.f}; + 0u, 0., -constant::pi, + -2000., 180., constant::pi, + 2000.}; darray n_vgrid_bins{1u, 1u, 1u}; darray, 3UL> bin_edges{ - std::vector{0.f, 180.f}, + std::vector{0., 180.}, std::vector{-constant::pi, constant::pi}, - std::vector{-2000.f, 2000.f}}; + std::vector{-2000., 2000.}}; grid_factory_type vgrid_factory{}; m_vol_finder = vgrid_factory.template new_grid< diff --git a/core/include/detray/builders/homogeneous_material_generator.hpp b/core/include/detray/builders/homogeneous_material_generator.hpp index 9679f25a2e..46dc639fb1 100644 --- a/core/include/detray/builders/homogeneous_material_generator.hpp +++ b/core/include/detray/builders/homogeneous_material_generator.hpp @@ -33,7 +33,7 @@ struct hom_material_config { /// Type of material to put on the portal surfaces material m_portal_material{vacuum{}}; /// Minimal envelope for the portals (used in autofitting) - scalar_t m_thickness{1.5f * unit::mm}; + scalar_t m_thickness{1.5 * unit::mm}; /// Setters /// @{ diff --git a/core/include/detray/builders/material_map_generator.hpp b/core/include/detray/builders/material_map_generator.hpp index b39af926bc..cb13d7c77f 100644 --- a/core/include/detray/builders/material_map_generator.hpp +++ b/core/include/detray/builders/material_map_generator.hpp @@ -44,7 +44,7 @@ inline std::vector> generate_cyl_mat( // Make sure the cylinder bounds are centered around zero const scalar_t length{math::fabs(bounds[cylinder2D::e_upper_z] - bounds[cylinder2D::e_lower_z])}; - scalar_t z{-0.5f * length}; + scalar_t z{-0.5 * length}; const scalar_t z_step{length / static_cast(nbins - 1u)}; for (std::size_t n = 0u; n < nbins; ++n) { ts.emplace_back(mat, static_cast(scalor * z * z) + t); @@ -92,9 +92,9 @@ struct material_map_config { /// Material to be filled into the maps material mapped_material{silicon_tml()}; /// Minimal thickness of the material slabs in the material maps - scalar_t thickness{0.15f * unit::mm}; + scalar_t thickness{0.15 * unit::mm}; /// Scale factor for the material thickness calculation - scalar_t scalor{1.f}; + scalar_t scalor{1.}; /// How to vary the material thickness along the bins std::function>( const std::vector &, const std::size_t, diff --git a/core/include/detray/geometry/coordinates/cartesian2D.hpp b/core/include/detray/geometry/coordinates/cartesian2D.hpp index 332f849915..a47040853d 100644 --- a/core/include/detray/geometry/coordinates/cartesian2D.hpp +++ b/core/include/detray/geometry/coordinates/cartesian2D.hpp @@ -59,7 +59,7 @@ struct cartesian2D { DETRAY_HOST_DEVICE static inline point3_type local_to_global( const transform3_type &trf, const mask_t & /*mask*/, const loc_point &p, const vector3_type & /*dir*/) { - return trf.point_to_global(point3_type{p[0], p[1], 0.f}); + return trf.point_to_global(point3_type{p[0], p[1], 0.}); } /// @returns the normal vector in global coordinates diff --git a/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp b/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp index 1ea9c65d62..0359050f7a 100644 --- a/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp +++ b/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp @@ -81,7 +81,7 @@ struct concentric_cylindrical2D { const mask_t & /*mask*/) { // normal vector in global coordinates (concentric cylinders have no // rotation) - return {math::cos(p[0]), math::sin(p[0]), 0.f}; + return {math::cos(p[0]), math::sin(p[0]), 0.}; } /// @returns the normal vector given a local position @param p @@ -89,7 +89,7 @@ struct concentric_cylindrical2D { const transform3_type &, const point3_type &p) { // normal vector in global coordinates (concentric cylinders have no // rotation) - return {math::cos(p[0]), math::sin(p[0]), 0.f}; + return {math::cos(p[0]), math::sin(p[0]), 0.}; } }; // struct concentric_cylindrical2D diff --git a/core/include/detray/geometry/coordinates/cylindrical2D.hpp b/core/include/detray/geometry/coordinates/cylindrical2D.hpp index 4fad1e04bd..347c7f41db 100644 --- a/core/include/detray/geometry/coordinates/cylindrical2D.hpp +++ b/core/include/detray/geometry/coordinates/cylindrical2D.hpp @@ -81,7 +81,7 @@ struct cylindrical2D { DETRAY_HOST_DEVICE static inline vector3_type normal( const transform3_type &trf, const point2_type &p, const mask_t &mask) { const scalar_type phi{p[0] / mask[mask_t::shape::e_r]}; - const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.f}; + const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.}; // normal vector in global coordinate return trf.vector_to_global(local_normal); @@ -92,7 +92,7 @@ struct cylindrical2D { DETRAY_HOST_DEVICE static inline vector3_type normal( const transform3_type &trf, const point3_type &p) { const scalar_type phi{p[0] / p[2]}; - const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.f}; + const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.}; // normal vector in global coordinate return trf.vector_to_global(local_normal); diff --git a/core/include/detray/geometry/coordinates/polar2D.hpp b/core/include/detray/geometry/coordinates/polar2D.hpp index 1aef0b8cf5..ce345ddb67 100644 --- a/core/include/detray/geometry/coordinates/polar2D.hpp +++ b/core/include/detray/geometry/coordinates/polar2D.hpp @@ -65,7 +65,7 @@ struct polar2D { const transform3_type &trf, const mask_t & /*mask*/, const loc_point &p, const vector3_type & /*dir*/) { - return polar2D::local_to_global(trf, {p[0], p[1], 0.f}); + return polar2D::local_to_global(trf, {p[0], p[1], 0.}); } /// @returns the normal vector in global coordinates diff --git a/core/include/detray/geometry/detail/shape_utils.hpp b/core/include/detray/geometry/detail/shape_utils.hpp index 1f3a51829f..eba2290d5d 100644 --- a/core/include/detray/geometry/detail/shape_utils.hpp +++ b/core/include/detray/geometry/detail/shape_utils.hpp @@ -21,7 +21,7 @@ namespace detray::detail { /// using a small angle approximation template constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) { - return radius > 0.f ? tol / radius : tol; + return radius > 0. ? tol / radius : tol; } } // namespace detray::detail diff --git a/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp b/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp index e45f7e9255..137f1189a5 100644 --- a/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp +++ b/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp @@ -109,7 +109,7 @@ class concentric_cylinder2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 2.f * constant::pi * bounds[e_r] * + return 2. * constant::pi * bounds[e_r] * (bounds[e_upper_z] - bounds[e_lower_z]); } @@ -128,7 +128,7 @@ class concentric_cylinder2D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.f); + assert(env > 0.); const dscalar xy_bound{bounds[e_r] + env}; return {-xy_bound, -xy_bound, bounds[e_lower_z] - env, xy_bound, xy_bound, bounds[e_upper_z] + env}; @@ -139,7 +139,7 @@ class concentric_cylinder2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return {0.f, 0.f, 0.5f * (bounds[e_lower_z] + bounds[e_upper_z])}; + return {0., 0., 0.5 * (bounds[e_lower_z] + bounds[e_upper_z])}; } /// Generate vertices in local cartesian frame @@ -166,7 +166,7 @@ class concentric_cylinder2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (bounds[e_r] < tol) { os << "ERROR: Radius must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/cuboid3D.hpp b/core/include/detray/geometry/shapes/cuboid3D.hpp index 147ad990ee..d01a0870ba 100644 --- a/core/include/detray/geometry/shapes/cuboid3D.hpp +++ b/core/include/detray/geometry/shapes/cuboid3D.hpp @@ -142,7 +142,7 @@ class cuboid3D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.f); + assert(env > 0.); bounds_type> o_bounds{bounds}; for (unsigned int i{0}; i < 3u; ++i) { o_bounds[i] -= env; @@ -156,7 +156,7 @@ class cuboid3D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return 0.5f * dpoint3D{bounds[e_min_x] + bounds[e_max_x], + return 0.5 * dpoint3D{bounds[e_min_x] + bounds[e_max_x], bounds[e_min_y] + bounds[e_max_y], bounds[e_min_z] + bounds[e_max_z]}; } @@ -185,7 +185,7 @@ class cuboid3D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (bounds[e_min_x] >= bounds[e_max_x] || math::fabs(bounds[e_min_x] - bounds[e_max_x]) < tol) { diff --git a/core/include/detray/geometry/shapes/cylinder2D.hpp b/core/include/detray/geometry/shapes/cylinder2D.hpp index 569d6b85f1..22139c21a1 100644 --- a/core/include/detray/geometry/shapes/cylinder2D.hpp +++ b/core/include/detray/geometry/shapes/cylinder2D.hpp @@ -109,7 +109,7 @@ class cylinder2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 2.f * constant::pi * bounds[e_r] * + return 2. * constant::pi * bounds[e_r] * (bounds[e_upper_z] - bounds[e_lower_z]); } @@ -127,7 +127,7 @@ class cylinder2D { const bounds_type> &bounds, const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.f); + assert(env > 0.); const dscalar xy_bound{bounds[e_r] + env}; return {-xy_bound, -xy_bound, bounds[e_lower_z] - env, @@ -139,7 +139,7 @@ class cylinder2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return {0.f, 0.f, 0.5f * (bounds[e_lower_z] + bounds[e_upper_z])}; + return {0., 0., 0.5 * (bounds[e_lower_z] + bounds[e_upper_z])}; } /// Generate vertices in local cartesian frame @@ -166,7 +166,7 @@ class cylinder2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (bounds[e_r] < tol) { os << "ERROR: Radius must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/cylinder3D.hpp b/core/include/detray/geometry/shapes/cylinder3D.hpp index f36214bdce..34a0292731 100644 --- a/core/include/detray/geometry/shapes/cylinder3D.hpp +++ b/core/include/detray/geometry/shapes/cylinder3D.hpp @@ -79,7 +79,7 @@ class cylinder3D { // Use the chord for the phi distance return math::min( math::min(min_r_dist, - 2.f * loc_p[0] * math::sin(0.5f * min_phi_dist)), + 2. * loc_p[0] * math::sin(0.5 * min_phi_dist)), min_z_dist); } @@ -150,7 +150,7 @@ class cylinder3D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.f); + assert(env > 0.); const dscalar r_bound{bounds[e_max_r] + env}; return {-r_bound, -r_bound, bounds[e_min_z] - env, r_bound, r_bound, bounds[e_max_z] + env}; @@ -161,8 +161,8 @@ class cylinder3D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return 0.5f * - dpoint3D{0.f, (bounds[e_min_phi] + bounds[e_max_phi]), + return 0.5 * + dpoint3D{0., (bounds[e_min_phi] + bounds[e_max_phi]), (bounds[e_min_z] + bounds[e_max_z])}; } @@ -190,7 +190,7 @@ class cylinder3D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (bounds[e_min_r] < tol) { os << "ERROR: Radii must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/line.hpp b/core/include/detray/geometry/shapes/line.hpp index 58a31530d9..74a79211a6 100644 --- a/core/include/detray/geometry/shapes/line.hpp +++ b/core/include/detray/geometry/shapes/line.hpp @@ -144,10 +144,10 @@ class line { const bounds_type &bounds) const { if constexpr (square_cross_sect) { - return 8.f * bounds[e_half_z] * bounds[e_cross_section] * + return 8. * bounds[e_half_z] * bounds[e_cross_section] * bounds[e_cross_section]; } else { - return constant::pi * 2.f * bounds[e_half_z] * + return constant::pi * 2. * bounds[e_half_z] * bounds[e_cross_section] * bounds[e_cross_section]; } } @@ -162,9 +162,9 @@ class line { const bounds_type &bounds) const { if constexpr (square_cross_sect) { - return 16.f * bounds[e_half_z] * bounds[e_cross_section]; + return 16. * bounds[e_half_z] * bounds[e_cross_section]; } else { - return 4.f * constant::pi * bounds[e_cross_section] * + return 4. * constant::pi * bounds[e_cross_section] * bounds[e_half_z]; } } @@ -186,7 +186,7 @@ class line { using scalar_t = dscalar; - assert(env > 0.f); + assert(env > 0.); const scalar_t xy_bound{bounds[e_cross_section] + env}; const scalar_t z_bound{bounds[e_half_z] + env}; @@ -198,7 +198,7 @@ class line { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &) const { - return {0.f, 0.f, 0.f}; + return {0., 0., 0.}; } /// Generate vertices in local cartesian frame @@ -214,8 +214,8 @@ class line { using point3_t = dpoint3D; - point3_t lc = {0.f, 0.f, -bounds[e_half_z]}; - point3_t rc = {0.f, 0.f, bounds[e_half_z]}; + point3_t lc = {0., 0., -bounds[e_half_z]}; + point3_t rc = {0., 0., bounds[e_half_z]}; return {lc, rc}; } @@ -230,7 +230,7 @@ class line { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (bounds[e_cross_section] < tol) { os << "ERROR: Radius/sides must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/rectangle2D.hpp b/core/include/detray/geometry/shapes/rectangle2D.hpp index e17c43beb1..586935370a 100644 --- a/core/include/detray/geometry/shapes/rectangle2D.hpp +++ b/core/include/detray/geometry/shapes/rectangle2D.hpp @@ -102,7 +102,7 @@ class rectangle2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 4.f * bounds[e_half_x] * bounds[e_half_y]; + return 4. * bounds[e_half_x] * bounds[e_half_y]; } /// @brief Lower and upper point for minimal axis aligned bounding box. @@ -121,7 +121,7 @@ class rectangle2D { std::numeric_limits>::epsilon()) const { using scalar_t = dscalar; - assert(env > 0.f); + assert(env > 0.); const scalar_t x_bound{bounds[e_half_x] + env}; const scalar_t y_bound{bounds[e_half_y] + env}; return {-x_bound, -y_bound, -env, x_bound, y_bound, env}; @@ -132,7 +132,7 @@ class rectangle2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &) const { - return {0.f, 0.f, 0.f}; + return {0., 0., 0.}; } /// Generate vertices in local cartesian frame @@ -149,13 +149,13 @@ class rectangle2D { using point3_t = dpoint3D; // left hand lower corner - point3_t lh_lc{-bounds[e_half_x], -bounds[e_half_y], 0.f}; + point3_t lh_lc{-bounds[e_half_x], -bounds[e_half_y], 0.}; // right hand lower corner - point3_t rh_lc{bounds[e_half_x], -bounds[e_half_y], 0.f}; + point3_t rh_lc{bounds[e_half_x], -bounds[e_half_y], 0.}; // right hand upper corner - point3_t rh_uc{bounds[e_half_x], bounds[e_half_y], 0.f}; + point3_t rh_uc{bounds[e_half_x], bounds[e_half_y], 0.}; // left hand upper corner - point3_t lh_uc{-bounds[e_half_x], bounds[e_half_y], 0.f}; + point3_t lh_uc{-bounds[e_half_x], bounds[e_half_y], 0.}; // Return the confining vertices return {lh_lc, rh_lc, rh_uc, lh_uc}; @@ -171,7 +171,7 @@ class rectangle2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - if (constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + if (constexpr auto tol{10. * std::numeric_limits::epsilon()}; bounds[e_half_x] < tol || bounds[e_half_y] < tol) { os << "ERROR: Half lengths must be in the range (0, numeric_max)" << std::endl; diff --git a/core/include/detray/geometry/shapes/ring2D.hpp b/core/include/detray/geometry/shapes/ring2D.hpp index 575717da40..155d99b71c 100644 --- a/core/include/detray/geometry/shapes/ring2D.hpp +++ b/core/include/detray/geometry/shapes/ring2D.hpp @@ -125,7 +125,7 @@ class ring2D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.f); + assert(env > 0.); const dscalar r_bound{env + bounds[e_outer_r]}; return {-r_bound, -r_bound, -env, r_bound, r_bound, env}; } @@ -135,7 +135,7 @@ class ring2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &) const { - return {0.f, 0.f, 0.f}; + return {0., 0., 0.}; } /// Generate vertices in local cartesian frame @@ -162,7 +162,7 @@ class ring2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (math::signbit(bounds[e_inner_r]) || bounds[e_outer_r] < tol) { os << "ERROR: Radius must be in the range [0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/single3D.hpp b/core/include/detray/geometry/shapes/single3D.hpp index dd83a53f2a..327745921b 100644 --- a/core/include/detray/geometry/shapes/single3D.hpp +++ b/core/include/detray/geometry/shapes/single3D.hpp @@ -122,7 +122,7 @@ class single3D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.f); + assert(env > 0.); darray, 6> o_bounds{-env, -env, -env, env, env, env}; o_bounds[kCheckIndex] += bounds[e_lower]; o_bounds[3u + kCheckIndex] += bounds[e_upper]; @@ -136,8 +136,8 @@ class single3D { using point3_t = dpoint3D; - point3_t centr{0.f, 0.f, 0.f}; - centr[kCheckIndex] = 0.5f * (bounds[e_lower] + bounds[e_upper]); + point3_t centr{0., 0., 0.}; + centr[kCheckIndex] = 0.5 * (bounds[e_lower] + bounds[e_upper]); return centr; } diff --git a/core/include/detray/geometry/shapes/trapezoid2D.hpp b/core/include/detray/geometry/shapes/trapezoid2D.hpp index f8b548b169..6b51357689 100644 --- a/core/include/detray/geometry/shapes/trapezoid2D.hpp +++ b/core/include/detray/geometry/shapes/trapezoid2D.hpp @@ -66,7 +66,7 @@ class trapezoid2D { const bounds_type &bounds, const point_t &loc_p) const { // Minimum distance between loc point and line between corner points - const scalar_t d_y = -2.f * bounds[e_half_length_2]; + const scalar_t d_y = -2. * bounds[e_half_length_2]; const scalar_t d_x = bounds[e_half_length_1] - bounds[e_half_length_0]; const scalar_t denom = math::sqrt(d_y * d_y + d_x * d_x); @@ -123,7 +123,7 @@ class trapezoid2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 2.f * (bounds[e_half_length_0] + bounds[e_half_length_1]) * + return 2. * (bounds[e_half_length_0] + bounds[e_half_length_1]) * bounds[e_half_length_2]; } @@ -144,7 +144,7 @@ class trapezoid2D { using scalar_t = dscalar; - assert(env > 0.f); + assert(env > 0.); const scalar_t x_bound{ (bounds[e_half_length_0] > bounds[e_half_length_1] ? bounds[e_half_length_0] @@ -165,10 +165,10 @@ class trapezoid2D { const scalar_t a_2{bounds[e_half_length_1]}; const scalar_t b_2{bounds[e_half_length_0]}; - const scalar_t y{2.f * h_2 * (2.f * a_2 + b_2) * 1.f / - (3.f * (a_2 + b_2))}; + const scalar_t y{2. * h_2 * (2. * a_2 + b_2) * 1. / + (3. * (a_2 + b_2))}; - return {0.f, y - h_2, 0.f}; + return {0., y - h_2, 0.}; } /// Generate vertices in local cartesian frame @@ -184,13 +184,13 @@ class trapezoid2D { using point3_t = dpoint3D; // left hand lower corner - point3_t lh_lc{-bounds[e_half_length_0], -bounds[e_half_length_2], 0.f}; + point3_t lh_lc{-bounds[e_half_length_0], -bounds[e_half_length_2], 0.}; // right hand lower corner - point3_t rh_lc{bounds[e_half_length_0], -bounds[e_half_length_2], 0.f}; + point3_t rh_lc{bounds[e_half_length_0], -bounds[e_half_length_2], 0.}; // right hand upper corner - point3_t rh_uc{bounds[e_half_length_1], bounds[e_half_length_2], 0.f}; + point3_t rh_uc{bounds[e_half_length_1], bounds[e_half_length_2], 0.}; // left hand upper corner - point3_t lh_uc{-bounds[e_half_length_1], bounds[e_half_length_2], 0.f}; + point3_t lh_uc{-bounds[e_half_length_1], bounds[e_half_length_2], 0.}; // Return the confining vertices return {lh_lc, rh_lc, rh_uc, lh_uc}; @@ -206,7 +206,7 @@ class trapezoid2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10.f * std::numeric_limits::epsilon()}; + constexpr auto tol{10. * std::numeric_limits::epsilon()}; if (bounds[e_half_length_0] < tol || bounds[e_half_length_1] < tol) { os << "ERROR: Half length in x must be in the range (0, " @@ -221,7 +221,7 @@ class trapezoid2D { return false; } - if (const auto div{1.f / (2.f * bounds[e_half_length_2])}; + if (const auto div{1. / (2. * bounds[e_half_length_2])}; math::fabs(bounds[e_divisor] - div) > tol) { os << "ERROR: Divisor incorrect. Should be: " << div << std::endl; return false; diff --git a/core/include/detray/geometry/shapes/unmasked.hpp b/core/include/detray/geometry/shapes/unmasked.hpp index 8e70702d02..b42936831d 100644 --- a/core/include/detray/geometry/shapes/unmasked.hpp +++ b/core/include/detray/geometry/shapes/unmasked.hpp @@ -133,7 +133,7 @@ class unmasked { template DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type>&) const { - return {0.f, 0.f, 0.f}; + return {0., 0., 0.}; } /// Generate vertices in local cartesian frame diff --git a/core/include/detray/grids/axis.hpp b/core/include/detray/grids/axis.hpp index ca12b13972..1fff614e67 100644 --- a/core/include/detray/grids/axis.hpp +++ b/core/include/detray/grids/axis.hpp @@ -437,7 +437,7 @@ struct irregular { DETRAY_HOST_DEVICE irregular() : n_bins(detail::invalid_value()), - min(0.f), + min(0.), max(static_cast(n_bins)), boundaries({}) {} @@ -445,7 +445,7 @@ struct irregular { DETRAY_HOST explicit irregular(vecmem::memory_resource &resource) : n_bins(detail::invalid_value()), - min(0.f), + min(0.), max(static_cast(n_bins)), boundaries(&resource) {} diff --git a/core/include/detray/materials/detail/density_effect_data.hpp b/core/include/detray/materials/detail/density_effect_data.hpp index 1d1aa222f9..4c5f507855 100644 --- a/core/include/detray/materials/detail/density_effect_data.hpp +++ b/core/include/detray/materials/detail/density_effect_data.hpp @@ -70,17 +70,17 @@ struct density_effect_data { /// Fitting parameters of Eq. 33.7 of RPP 2018 /// @{ - scalar_type m_a = 0.f; - scalar_type m_m = 0.f; - scalar_type m_X0 = 0.f; - scalar_type m_X1 = 0.f; + scalar_type m_a = 0.; + scalar_type m_m = 0.; + scalar_type m_X0 = 0.; + scalar_type m_X1 = 0.; /// @} /// Mean excitation energy in eV - scalar_type m_I = 0.f; + scalar_type m_I = 0.; /// -C - scalar_type m_nC = 0.f; + scalar_type m_nC = 0.; /// Density-effect value delta(X_0) - scalar_type m_delta0 = 0.f; + scalar_type m_delta0 = 0.; }; } // namespace detray::detail diff --git a/core/include/detray/materials/detail/relativistic_quantities.hpp b/core/include/detray/materials/detail/relativistic_quantities.hpp index 10b4972a68..3e5900da28 100644 --- a/core/include/detray/materials/detail/relativistic_quantities.hpp +++ b/core/include/detray/materials/detail/relativistic_quantities.hpp @@ -33,15 +33,15 @@ struct relativistic_quantities { static constexpr auto PlasmaEnergyScale{ static_cast(28.816 * unit::eV)}; - scalar_type m_qOverP{0.f}; - scalar_type m_q2OverBeta2{0.f}; - scalar_type m_beta{0.f}; - scalar_type m_beta2{0.f}; - scalar_type m_betaGamma{0.f}; - scalar_type m_gamma{0.f}; - scalar_type m_gamma2{0.f}; - scalar_type m_E{0.f}; - scalar_type m_Wmax{0.f}; + scalar_type m_qOverP{0.}; + scalar_type m_q2OverBeta2{0.}; + scalar_type m_beta{0.}; + scalar_type m_beta2{0.}; + scalar_type m_betaGamma{0.}; + scalar_type m_gamma{0.}; + scalar_type m_gamma2{0.}; + scalar_type m_E{0.}; + scalar_type m_Wmax{0.}; DETRAY_HOST_DEVICE relativistic_quantities(const pdg_particle& ptc, @@ -56,20 +56,20 @@ struct relativistic_quantities { // q²/beta² = q² + m²(q/p)² m_q2OverBeta2{q * q + (mass * qOverP) * (mass * qOverP)} { - assert(m_qOverP != 0.f); - assert(mass != 0.f); + assert(m_qOverP != 0.); + assert(mass != 0.); // 1/p = q/(qp) = (q/p)/q const scalar_type mOverP{ - mass * ((q != 0.f) ? math::fabs(qOverP / q) : math::fabs(qOverP))}; - const scalar_type pOverM{1.f / mOverP}; + mass * ((q != 0.) ? math::fabs(qOverP / q) : math::fabs(qOverP))}; + const scalar_type pOverM{1. / mOverP}; // beta² = p²/E² = p²/(m² + p²) = 1/(1 + (m/p)²) - m_beta2 = 1.f / (1.f + mOverP * mOverP); + m_beta2 = 1. / (1. + mOverP * mOverP); m_beta = math::sqrt(m_beta2); // beta*gamma = (p/sqrt(m² + p²))*(sqrt(m² + p²)/m) = p/m m_betaGamma = pOverM; // gamma = sqrt(m² + p²)/m = sqrt(1 + (p/m)²) - m_gamma = math::sqrt(1.f + pOverM * pOverM); + m_gamma = math::sqrt(1. + pOverM * pOverM); m_gamma2 = m_gamma * m_gamma; // E = gamma * mass; m_E = m_gamma * mass; @@ -78,21 +78,21 @@ struct relativistic_quantities { // Wmax = 2m_e c^2 beta^2 gamma^2 / (1+2gamma*m_e/M + (m_e/M)^2) m_Wmax = - (2.f * constant::m_e * m_betaGamma * m_betaGamma) / - (1.f + 2.f * m_gamma * mfrac + mfrac * mfrac); + (2. * constant::m_e * m_betaGamma * m_betaGamma) / + (1. + 2. * m_gamma * mfrac + mfrac * mfrac); } /// @return 2 * mass * (beta * gamma)² mass term. DETRAY_HOST_DEVICE constexpr scalar_type compute_mass_term( const scalar_type mass) const { - return 2.f * mass * m_betaGamma * m_betaGamma; + return 2. * mass * m_betaGamma * m_betaGamma; } /// @return [(K/2) * (Z/A) * z^2 / beta^2 * density] in [energy/length] /// @brief defined in 34.12 of 2023 PDG review DETRAY_HOST_DEVICE constexpr scalar_type compute_epsilon_per_length( const material& mat) const { - return 0.5f * K * mat.molar_electron_density() * m_q2OverBeta2; + return 0.5 * K * mat.molar_electron_density() * m_q2OverBeta2; } /// @return (K/2) * (Z/A) * z^2 / beta^2 * density * path_length @@ -108,29 +108,29 @@ struct relativistic_quantities { compute_bethe_bloch_log_term(const material& mat) const { const scalar_type I = mat.mean_excitation_energy(); - assert(I != 0.f); + assert(I != 0.); // u = 2 * m_e c^2* beta^2 * gamma^2 const scalar_t u{compute_mass_term(constant::m_e)}; - const scalar_type A = 0.5f * math::log(u * m_Wmax / (I * I)); + const scalar_type A = 0.5 * math::log(u * m_Wmax / (I * I)); return A; } /// @return d(bethe_log_term)/dqop /// @brief dA/dqop = - 1 / (2 * qop) * [4 - W_max/ (gamma M c^2) ] DETRAY_HOST_DEVICE scalar_type derive_bethe_bloch_log_term() const { - assert(m_gamma != 0.f); - assert(m_E != 0.f); + assert(m_gamma != 0.); + assert(m_E != 0.); const scalar_type dAdqop = - -1.f / (2.f * m_qOverP) * (4.f - m_Wmax / m_E); + -1. / (2. * m_qOverP) * (4. - m_Wmax / m_E); return dAdqop; } /// @return d(beta^2)/dqop = - 2beta^2 / (qop * gamma^2) DETRAY_HOST_DEVICE scalar_type derive_beta2() const { - assert(m_qOverP != 0.f); - assert(m_gamma2 != 0.f); - return -2.f * m_beta2 / (m_qOverP * m_gamma2); + assert(m_qOverP != 0.); + assert(m_gamma2 != 0.); + return -2. * m_beta2 / (m_qOverP * m_gamma2); } /// @return the half of density correction factor (delta/2). @@ -148,18 +148,18 @@ struct relativistic_quantities { // // For further discussion, please follow the ATLAS JIRA Tickets: // ATLASRECTS-3144 and ATLASRECTS-7586 (ATLAS-restricted) - if (m_betaGamma < 10.f) { - return 0.f; + if (m_betaGamma < 10.) { + return 0.; } // Equation 34.6 of PDG2022 // @NOTE A factor of 1000 is required to convert the unit of density // (mm^-3 to cm^-3) const scalar_type plasmaEnergy{ PlasmaEnergyScale * - math::sqrt(1000.f * mat.molar_electron_density())}; + math::sqrt(1000. * mat.molar_electron_density())}; return math::log(m_betaGamma * plasmaEnergy / mat.mean_excitation_energy()) - - 0.5f; + 0.5; } else { const auto& density = mat.density_effect_data(); @@ -171,32 +171,32 @@ struct relativistic_quantities { const scalar_type x{math::log10(m_betaGamma)}; - scalar_type delta{0.f}; + scalar_type delta{0.}; // From Geant4 // processes/electromagnetic/lowenergy/src/G4hBetheBlochModel.cc if (x < x0den) { - delta = 0.f; + delta = 0.; // @TODO: Add a branch for conductors (Eq 34.7 of // https://pdg.lbl.gov/2023/reviews/rpp2023-rev-particle-detectors-accel.pdf) } else { - delta = 2.f * constant::ln10 * x - cden; + delta = 2. * constant::ln10 * x - cden; if (x < x1den) delta += aden * math::pow((x1den - x), mden); } - return 0.5f * delta; + return 0.5 * delta; } } /// @return the derivation of the density correction factor delta/2. DETRAY_HOST_DEVICE inline scalar_type derive_delta_half( const material& mat) const { - assert(m_qOverP != 0.f); + assert(m_qOverP != 0.); if (!mat.has_density_effect_data()) { // d(ln(betagamma))/dqop = -1/qop - return -1.f / m_qOverP; + return -1. / m_qOverP; } else { const auto& density = mat.density_effect_data(); @@ -208,24 +208,24 @@ struct relativistic_quantities { const scalar_type x{math::log10(m_betaGamma)}; - scalar_type delta{0.f}; + scalar_type delta{0.}; // From Geant4 // processes/electromagnetic/lowenergy/src/G4hBetheBlochModel.cc if (x < x0den) { - delta = 0.f; + delta = 0.; // @TODO: Add a branch for conductors (Eq 34.7 of // https://pdg.lbl.gov/2023/reviews/rpp2023-rev-particle-detectors-accel.pdf) } else { - delta = -2.f / m_qOverP; + delta = -2. / m_qOverP; if (x < x1den) { delta += aden * mden / (m_qOverP * constant::ln10) * - math::pow(x1den - x, mden - 1.f); + math::pow(x1den - x, mden - 1.); } } - return 0.5f * delta; + return 0.5 * delta; } } }; diff --git a/core/include/detray/materials/interaction.hpp b/core/include/detray/materials/interaction.hpp index 20ff02a899..6411a2b6bc 100644 --- a/core/include/detray/materials/interaction.hpp +++ b/core/include/detray/materials/interaction.hpp @@ -30,7 +30,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type stopping_power{0.f}; + scalar_type stopping_power{0.}; // Inelastic collisions with atomic electrons stopping_power += compute_bethe_bloch(mat, ptc, rq); @@ -47,14 +47,14 @@ struct interaction { const relativistic_quantities& rq) const { const scalar_type eps_per_length{rq.compute_epsilon_per_length(mat)}; - if (eps_per_length <= 0.f) { - return 0.f; + if (eps_per_length <= 0.) { + return 0.; } const scalar_type dhalf{rq.compute_delta_half(mat)}; const scalar_type A = rq.compute_bethe_bloch_log_term(mat); const scalar_type running{A - rq.m_beta2 - dhalf}; - return 2.f * eps_per_length * running; + return 2. * eps_per_length * running; } // Function to calculate the Bremsstrahlung energy loss of electron based on @@ -67,7 +67,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type stopping_power{0.f}; + scalar_type stopping_power{0.}; // Only consider electrons and positrons at the moment // For middle-heavy particles muons, the bremss is negligibe @@ -96,7 +96,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type derivative{0.f}; + scalar_type derivative{0.}; // Inelastic collisions with atomic electrons derivative += derive_bethe_bloch(mat, ptc, rq); @@ -117,8 +117,8 @@ struct interaction { // (K/2) * (Z/A) * z^2 / beta^2 * density const scalar_type eps_per_length{rq.compute_epsilon_per_length(mat)}; - if (eps_per_length <= 0.f) { - return 0.f; + if (eps_per_length <= 0.) { + return 0.; } /*----------------------------------------------------------------------- @@ -141,14 +141,14 @@ struct interaction { ------------------------------------------------------------------------*/ const scalar_type first_term = - 2.f / (rq.m_qOverP * rq.m_gamma2) * bethe_stopping_power; + 2. / (rq.m_qOverP * rq.m_gamma2) * bethe_stopping_power; const scalar_type dAdqop = rq.derive_bethe_bloch_log_term(); const scalar_type dBdqop = rq.derive_beta2(); const scalar_type dCdqop = rq.derive_delta_half(mat); const scalar_type second_term = - 2.f * eps_per_length * (dAdqop - dBdqop - dCdqop); + 2. * eps_per_length * (dAdqop - dBdqop - dCdqop); return first_term + second_term; } @@ -158,7 +158,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type derivative{0.f}; + scalar_type derivative{0.}; if (ptc.pdg_num() == electron().pdg_num() || ptc.pdg_num() == positron().pdg_num()) { @@ -189,15 +189,15 @@ struct interaction { const scalar_type I{mat.mean_excitation_energy()}; const scalar_type eps{rq.compute_epsilon(mat, path_segment)}; - if (eps <= 0.f) { - return 0.f; + if (eps <= 0.) { + return 0.; } const scalar_type dhalf{rq.compute_delta_half(mat)}; const scalar_type t{rq.compute_mass_term(constant::m_e)}; // uses RPP2018 eq. 33.11 - const scalar_type running{math::log(t / I) + math::log(eps / I) + 0.2f - - rq.m_beta2 - 2.f * dhalf}; + const scalar_type running{math::log(t / I) + math::log(eps / I) + 0.2 - + rq.m_beta2 - 2. * dhalf}; return eps * running; } @@ -207,7 +207,7 @@ struct interaction { const relativistic_quantities& rq) const { // the Landau-Vavilov fwhm is 4*eps (see RPP2018 fig. 33.7) - return 4.f * rq.compute_epsilon(mat, path_segment); + return 4. * rq.compute_epsilon(mat, path_segment); } DETRAY_HOST_DEVICE scalar_type compute_energy_loss_landau_sigma( @@ -267,30 +267,30 @@ struct interaction { DETRAY_HOST_DEVICE scalar_type theta0Highland(const scalar_type xOverX0, const scalar_type momentumInv, const scalar_type q2OverBeta2) const { - if (xOverX0 <= 0.f) { - return 0.f; + if (xOverX0 <= 0.) { + return 0.; } // RPP2018 eq. 33.15 (treats beta and q² consistenly) const scalar_type t{math::sqrt(xOverX0 * q2OverBeta2)}; // log((x/X0) * (q²/beta²)) = log((sqrt(x/X0) * (q/beta))²) // = 2 * log(sqrt(x/X0) * (q/beta)) - return 13.6f * unit::MeV * momentumInv * t * - (1.0f + 0.038f * 2.f * math::log(t)); + return 13.6 * unit::MeV * momentumInv * t * + (1.0 + 0.038 * 2. * math::log(t)); } /// Multiple scattering theta0 for electrons. DETRAY_HOST_DEVICE scalar_type theta0RossiGreisen(const scalar_type xOverX0, const scalar_type momentumInv, const scalar_type q2OverBeta2) const { - if (xOverX0 <= 0.f) { - return 0.f; + if (xOverX0 <= 0.) { + return 0.; } // TODO add source paper/ resource const scalar_type t{math::sqrt(xOverX0 * q2OverBeta2)}; - return 17.5f * unit::MeV * momentumInv * t * - (1.0f + 0.125f * math::log10(10.0f * xOverX0)); + return 17.5 * unit::MeV * momentumInv * t * + (1.0 + 0.125 * math::log10(10.0 * xOverX0)); } /// Convert Landau full-width-half-maximum to an equivalent Gaussian @@ -304,7 +304,7 @@ struct interaction { /// @todo: Add a unit test for this function DETRAY_HOST_DEVICE scalar_type convert_landau_fwhm_to_gaussian_sigma(const scalar_type fwhm) const { - return 0.5f * constant::inv_sqrt2 * fwhm / + return 0.5 * constant::inv_sqrt2 * fwhm / math::sqrt(constant::ln2); } }; diff --git a/core/include/detray/materials/material.hpp b/core/include/detray/materials/material.hpp index 88fb020d30..50af8a88ab 100644 --- a/core/include/detray/materials/material.hpp +++ b/core/include/detray/materials/material.hpp @@ -131,7 +131,7 @@ struct material { scalar_type mean_excitation_energy() const { if (!m_has_density_effect_data) { // use approximative computation as defined in ATL-SOFT-PUB-2008-003 - return 16.f * unit::eV * + return 16. * unit::eV * math::pow(m_z, static_cast(0.9)); } else { return m_density.get_mean_excitation_energy(); @@ -141,7 +141,7 @@ struct material { DETRAY_HOST_DEVICE constexpr scalar_type fraction() const { if constexpr (ratio::num == 0) { - return 0.f; + return 0.; } else if constexpr (ratio::den == 0) { return detail::invalid_value(); } else { @@ -154,7 +154,7 @@ struct material { DETRAY_HOST std::string to_string() const { std::stringstream strm; - if (m_ar <= 0.f) { + if (m_ar <= 0.) { strm << "vacuum"; return strm.str(); } @@ -225,7 +225,7 @@ struct material { /// @return [mass_density / A] constexpr scalar_type mass_to_molar_density(double ar, double mass_rho) { if (mass_rho == 0.) { - return 0.f; + return 0.; } const double molar_mass{ar * unit::g / unit::mol}; @@ -237,10 +237,10 @@ struct material { // Material properties scalar_type m_x0 = detail::invalid_value(); scalar_type m_l0 = detail::invalid_value(); - scalar_type m_ar = 0.f; - scalar_type m_z = 0.f; - scalar_type m_mass_rho = 0.f; - scalar_type m_molar_rho = 0.f; + scalar_type m_ar = 0.; + scalar_type m_z = 0.; + scalar_type m_mass_rho = 0.; + scalar_type m_molar_rho = 0.; material_state m_state = material_state::e_unknown; detail::density_effect_data m_density = {}; bool m_has_density_effect_data = false; diff --git a/core/include/detray/materials/material_rod.hpp b/core/include/detray/materials/material_rod.hpp index fa36020ffd..dbb2bad9cf 100644 --- a/core/include/detray/materials/material_rod.hpp +++ b/core/include/detray/materials/material_rod.hpp @@ -73,12 +73,12 @@ struct material_rod { const scalar_type cos_inc_angle, const scalar_type approach) const { // Assume that is.local[0] is radial distance of line intersector if (math::fabs(approach) > m_radius) { - return 0.f; + return 0.; } - const scalar_type sin_inc_angle_2{1.f - cos_inc_angle * cos_inc_angle}; + const scalar_type sin_inc_angle_2{1. - cos_inc_angle * cos_inc_angle}; - return 2.f * math::sqrt((m_radius * m_radius - approach * approach) / + return 2. * math::sqrt((m_radius * m_radius - approach * approach) / sin_inc_angle_2); } diff --git a/core/include/detray/materials/material_slab.hpp b/core/include/detray/materials/material_slab.hpp index 5d910d31cb..60700ad853 100644 --- a/core/include/detray/materials/material_slab.hpp +++ b/core/include/detray/materials/material_slab.hpp @@ -52,8 +52,8 @@ struct material_slab { if (m_thickness <= std::numeric_limits::epsilon() || m_thickness == std::numeric_limits::max() || m_material == vacuum() || - m_material.mass_density() == 0.f || - m_material.molar_density() == 0.f) { + m_material.mass_density() == 0. || + m_material.molar_density() == 0.) { return false; } return true; @@ -76,7 +76,7 @@ struct material_slab { /// /// @param cos_inc_angle cosine of the track incidence angle DETRAY_HOST_DEVICE constexpr scalar_type path_segment( - const scalar_type cos_inc_angle, const scalar_type = 0.f) const { + const scalar_type cos_inc_angle, const scalar_type = 0.) const { return m_thickness / cos_inc_angle; } @@ -84,7 +84,7 @@ struct material_slab { /// /// @param cos_inc_angle cosine of the track incidence angle DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_X0( - const scalar_type cos_inc_angle, const scalar_type = 0.f) const { + const scalar_type cos_inc_angle, const scalar_type = 0.) const { return m_thickness_in_X0 / cos_inc_angle; } @@ -92,7 +92,7 @@ struct material_slab { /// /// @param cos_inc_angle cosine of the track incidence angle DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_L0( - const scalar_type cos_inc_angle, const scalar_type = 0.f) const { + const scalar_type cos_inc_angle, const scalar_type = 0.) const { return m_thickness_in_L0 / cos_inc_angle; } diff --git a/core/include/detray/materials/mixture.hpp b/core/include/detray/materials/mixture.hpp index 7c7d7cd7c3..b1004e7dbf 100644 --- a/core/include/detray/materials/mixture.hpp +++ b/core/include/detray/materials/mixture.hpp @@ -67,7 +67,7 @@ struct mixture return ((M.fraction() / M.X0()) + ...); }; this->set_X0( - 1.f / std::apply(sum_rho_over_X0, std::tuple())); + 1. / std::apply(sum_rho_over_X0, std::tuple())); // Compute effective nuclear radiation length // Follow the same equation of effective X0 @@ -77,7 +77,7 @@ struct mixture }; this->set_L0( - 1.f / std::apply(sum_rho_over_L0, std::tuple())); + 1. / std::apply(sum_rho_over_L0, std::tuple())); // Compute molar density this->set_molar_density( diff --git a/core/include/detray/materials/predefined_materials.hpp b/core/include/detray/materials/predefined_materials.hpp index 6640e17129..ecff665afd 100644 --- a/core/include/detray/materials/predefined_materials.hpp +++ b/core/include/detray/materials/predefined_materials.hpp @@ -28,143 +28,143 @@ namespace detray { */ // Vacuum DETRAY_DECLARE_MATERIAL(vacuum, std::numeric_limits::max(), - std::numeric_limits::max(), 0.f, 0.f, 0.f, + std::numeric_limits::max(), 0., 0., 0., material_state::e_unknown); // H₂ (1): Hydrogen Gas DETRAY_DECLARE_MATERIAL(hydrogen_gas, 7.526E3f * unit::m, - 6.209E3f * unit::m, 2.f * 1.008f, 2.f * 1.f, + 6.209E3f * unit::m, 2. * 1.008, 2. * 1., static_cast(8.376E-5 * unit::g / unit::cm3), material_state::e_gas); // H₂ (1): Hydrogen Liquid -DETRAY_DECLARE_MATERIAL(hydrogen_liquid, 8.904f * unit::m, - 7.346f * unit::m, 2.f * 1.008f, 2.f * 1.f, - static_cast(0.07080f * unit::g / +DETRAY_DECLARE_MATERIAL(hydrogen_liquid, 8.904 * unit::m, + 7.346 * unit::m, 2. * 1.008, 2. * 1., + static_cast(0.07080 * unit::g / unit::cm3), material_state::e_liquid); // He (2): Helium Gas DETRAY_DECLARE_MATERIAL(helium_gas, 5.671E3f * unit::m, - 4.269E3f * unit::m, 4.003f, 2.f, + 4.269E3f * unit::m, 4.003, 2., static_cast(1.663E-4 * unit::g / unit::cm3), material_state::e_gas); // Be (4) -DETRAY_DECLARE_MATERIAL(beryllium, 352.8f * unit::mm, - 421.0f * unit::mm, 9.012f, 4.f, +DETRAY_DECLARE_MATERIAL(beryllium, 352.8 * unit::mm, + 421.0 * unit::mm, 9.012, 4., static_cast(1.848 * unit::g / unit::cm3), material_state::e_solid); // C (6): Carbon (amorphous) -DETRAY_DECLARE_MATERIAL(carbon_gas, 213.5f * unit::mm, - 429.0f * unit::mm, 12.01f, 6.f, +DETRAY_DECLARE_MATERIAL(carbon_gas, 213.5 * unit::mm, + 429.0 * unit::mm, 12.01, 6., static_cast(2.0 * unit::g / unit::cm3), material_state::e_gas); // N₂ (7): Nitrogen Gas -DETRAY_DECLARE_MATERIAL(nitrogen_gas, 3.260E+02f * unit::m, - 7.696E+02f * unit::m, 2.f * 14.007f, - 2.f * 7.f, +DETRAY_DECLARE_MATERIAL(nitrogen_gas, 3.260E+02 * unit::m, + 7.696E+02 * unit::m, 2. * 14.007, + 2. * 7., static_cast(1.165E-03 * unit::g / unit::cm3), material_state::e_gas); // O₂ (8): Oxygen Gas -DETRAY_DECLARE_MATERIAL(oxygen_gas, 2.571E+02f * unit::m, - 6.772E+02f * unit::m, 2.f * 15.999f, - 2.f * 8.f, +DETRAY_DECLARE_MATERIAL(oxygen_gas, 2.571E+02 * unit::m, + 6.772E+02 * unit::m, 2. * 15.999, + 2. * 8., static_cast(1.332E-3 * unit::g / unit::cm3), material_state::e_gas); // O₂ (8): Oxygen liquid -DETRAY_DECLARE_MATERIAL(oxygen_liquid, 300.1f * unit::mm, - 790.3f * unit::mm, 2.f * 15.999f, 2.f * 8.f, +DETRAY_DECLARE_MATERIAL(oxygen_liquid, 300.1 * unit::mm, + 790.3 * unit::mm, 2. * 15.999, 2. * 8., static_cast(1.141 * unit::g / unit::cm3), material_state::e_liquid); // Al (13) -DETRAY_DECLARE_MATERIAL(aluminium, 88.97f * unit::mm, - 397.0f * unit::mm, 26.98f, 13.f, +DETRAY_DECLARE_MATERIAL(aluminium, 88.97 * unit::mm, + 397.0 * unit::mm, 26.98, 13., static_cast(2.699 * unit::g / unit::cm3), material_state::e_solid); // Si (14) -DETRAY_DECLARE_MATERIAL(silicon, 93.7f * unit::mm, - 465.2f * unit::mm, 28.0855f, 14.f, +DETRAY_DECLARE_MATERIAL(silicon, 93.7 * unit::mm, + 465.2 * unit::mm, 28.0855, 14., static_cast(2.329 * unit::g / unit::cm3), material_state::e_solid); // Si (14) with density effect data -DETRAY_DECLARE_MATERIAL_WITH_DED(silicon_with_ded, 93.7f * unit::mm, - 465.2f * unit::mm, 28.0855f, 14.f, +DETRAY_DECLARE_MATERIAL_WITH_DED(silicon_with_ded, 93.7 * unit::mm, + 465.2 * unit::mm, 28.0855, 14., static_cast(2.329 * unit::g / unit::cm3), - material_state::e_solid, 0.1492f, 3.2546f, - 0.2015f, 2.8716f, 173.0f, 4.4355f, 0.14f); + material_state::e_solid, 0.1492, 3.2546, + 0.2015, 2.8716, 173.0, 4.4355, 0.14); // Ar (18): Argon gas -DETRAY_DECLARE_MATERIAL(argon_gas, 1.176E+02f * unit::m, - 7.204E+02f * unit::m, 39.948f, 18.f, +DETRAY_DECLARE_MATERIAL(argon_gas, 1.176E+02 * unit::m, + 7.204E+02 * unit::m, 39.948, 18., static_cast(1.662E-03 * unit::g / unit::cm3), material_state::e_gas); // Ar (18): Argon liquid -DETRAY_DECLARE_MATERIAL(argon_liquid, 14.f * unit::cm, - 85.77f * unit::cm, 39.948f, 18.f, +DETRAY_DECLARE_MATERIAL(argon_liquid, 14. * unit::cm, + 85.77 * unit::cm, 39.948, 18., static_cast(1.396 * unit::g / unit::cm3), material_state::e_liquid); // Fe (26) -DETRAY_DECLARE_MATERIAL(iron, 1.757f * unit::cm, - 16.77f * unit::cm, 55.845f, 26.f, +DETRAY_DECLARE_MATERIAL(iron, 1.757 * unit::cm, + 16.77 * unit::cm, 55.845, 26., static_cast(7.874 * unit::g / unit::cm3), material_state::e_solid); // Fe (26) with density effect data -DETRAY_DECLARE_MATERIAL_WITH_DED(iron_with_ded, 1.757f * unit::cm, - 16.77f * unit::cm, 55.845f, 26.f, +DETRAY_DECLARE_MATERIAL_WITH_DED(iron_with_ded, 1.757 * unit::cm, + 16.77 * unit::cm, 55.845, 26., static_cast(7.874 * unit::g / unit::cm3), - material_state::e_solid, 0.14680f, 2.9632f, - -0.0012f, 3.1531f, 286.0f, 4.2911f, 0.12f); + material_state::e_solid, 0.14680, 2.9632, + -0.0012, 3.1531, 286.0, 4.2911, 0.12); // Copper (29) -DETRAY_DECLARE_MATERIAL(copper, 1.436f * unit::cm, - 15.32f * unit::cm, 63.546f, 29.f, +DETRAY_DECLARE_MATERIAL(copper, 1.436 * unit::cm, + 15.32 * unit::cm, 63.546, 29., static_cast(8.960 * unit::g / unit::cm3), material_state::e_solid); // Copper (29) with density effect data -DETRAY_DECLARE_MATERIAL_WITH_DED(copper_with_ded, 1.436f * unit::cm, - 15.32f * unit::cm, 63.546f, 29.f, +DETRAY_DECLARE_MATERIAL_WITH_DED(copper_with_ded, 1.436 * unit::cm, + 15.32 * unit::cm, 63.546, 29., static_cast(8.960 * unit::g / unit::cm3), - material_state::e_solid, 0.14339f, 2.9044f, - -0.0254f, 3.2792f, 322.0f, 4.4190f, 0.08f); + material_state::e_solid, 0.14339, 2.9044, + -0.0254, 3.2792, 322.0, 4.4190, 0.08); // W (74) -DETRAY_DECLARE_MATERIAL(tungsten, 3.504f * unit::mm, - 99.46f * unit::mm, 183.84f, 74.f, +DETRAY_DECLARE_MATERIAL(tungsten, 3.504 * unit::mm, + 99.46 * unit::mm, 183.84, 74., static_cast(19.3 * unit::g / unit::cm3), material_state::e_solid); // Au (79) -DETRAY_DECLARE_MATERIAL(gold, 3.344f * unit::mm, - 101.6f * unit::mm, 196.97f, 79.f, +DETRAY_DECLARE_MATERIAL(gold, 3.344 * unit::mm, + 101.6 * unit::mm, 196.97, 79., static_cast(19.32 * unit::g / unit::cm3), material_state::e_solid); @@ -175,15 +175,15 @@ DETRAY_DECLARE_MATERIAL(gold, 3.344f * unit::mm, */ // Be (4) -DETRAY_DECLARE_MATERIAL(beryllium_tml, 352.8f * unit::mm, - 407.f * unit::mm, 9.012f, 4.f, +DETRAY_DECLARE_MATERIAL(beryllium_tml, 352.8 * unit::mm, + 407. * unit::mm, 9.012, 4., static_cast(1.848 * unit::g / unit::cm3), material_state::e_solid); // Si (14) -DETRAY_DECLARE_MATERIAL(silicon_tml, 95.7f * unit::mm, - 465.2f * unit::mm, 28.03f, 14.f, +DETRAY_DECLARE_MATERIAL(silicon_tml, 95.7 * unit::mm, + 465.2 * unit::mm, 28.03, 14., static_cast(2.32 * unit::g / unit::cm3), material_state::e_solid); @@ -196,8 +196,8 @@ DETRAY_DECLARE_MATERIAL(silicon_tml, 95.7f * unit::mm, // @note: // https://pdg.lbl.gov/2020/AtomicNuclearProperties/HTML/air_dry_1_atm.html // @note: Ar from Wikipedia (https://en.wikipedia.org/wiki/Molar_mass) -DETRAY_DECLARE_MATERIAL(air, 3.039E+02f * unit::m, - 7.477E+02f * unit::m, 28.97f, 14.46f, +DETRAY_DECLARE_MATERIAL(air, 3.039E+02 * unit::m, + 7.477E+02 * unit::m, 28.97, 14.46, static_cast(1.205E-03 * unit::g / unit::cm3), material_state::e_gas); @@ -208,8 +208,8 @@ DETRAY_DECLARE_MATERIAL(air, 3.039E+02f * unit::m, // @note: Z was caculated by simply summing the number of atoms. Surprisingly // it seems the right value because Z/A is 0.58496, which is the same with // in the pdg refernce -DETRAY_DECLARE_MATERIAL(isobutane, 1693E+02f * unit::mm, - 288.3f * unit::mm, 58.124f, 34.f, +DETRAY_DECLARE_MATERIAL(isobutane, 1693E+02 * unit::mm, + 288.3 * unit::mm, 58.124, 34., static_cast(2.67 * unit::g / unit::cm3), material_state::e_gas); @@ -218,25 +218,25 @@ DETRAY_DECLARE_MATERIAL(isobutane, 1693E+02f * unit::mm, // @note: (X0, L0, mass_rho) from // https://pdg.lbl.gov/2020/AtomicNuclearProperties/HTML/propane.html // @note: Ar from Wikipedia (https://en.wikipedia.org/wiki/Propane) -DETRAY_DECLARE_MATERIAL(propane, 2.429E+02f * unit::m, - 4.106E+02f * unit::m, 44.097f, 26.f, +DETRAY_DECLARE_MATERIAL(propane, 2.429E+02 * unit::m, + 4.106E+02 * unit::m, 44.097, 26., static_cast(1.868E-03 * unit::g / unit::cm3), material_state::e_gas); // Cesium Iodide (CsI) // https://pdg.lbl.gov/2023/AtomicNuclearProperties/HTML/cesium_iodide_CsI.html -DETRAY_DECLARE_MATERIAL(cesium_iodide, 1.86f * unit::cm, - 38.04f * unit::cm, 259.81f, 108.f, - static_cast(4.510f * unit::g / +DETRAY_DECLARE_MATERIAL(cesium_iodide, 1.86 * unit::cm, + 38.04 * unit::cm, 259.81, 108., + static_cast(4.510 * unit::g / unit::cm3), material_state::e_solid); DETRAY_DECLARE_MATERIAL_WITH_DED( - cesium_iodide_with_ded, 1.86f * unit::cm, - 38.04f * unit::cm, 259.81f, 108.f, - static_cast(4.510f * unit::g / unit::cm3), - material_state::e_solid, 0.25381f, 2.6657f, 0.0395f, 3.3353f, 553.1f, - 6.2807f, 0.00f); + cesium_iodide_with_ded, 1.86 * unit::cm, + 38.04 * unit::cm, 259.81, 108., + static_cast(4.510 * unit::g / unit::cm3), + material_state::e_solid, 0.25381, 2.6657, 0.0395, 3.3353, 553.1, + 6.2807, 0.00); } // namespace detray diff --git a/core/include/detray/navigation/direct_navigator.hpp b/core/include/detray/navigation/direct_navigator.hpp index 4db67b22d8..cc3938a5d5 100644 --- a/core/include/detray/navigation/direct_navigator.hpp +++ b/core/include/detray/navigation/direct_navigator.hpp @@ -278,7 +278,7 @@ class direct_navigator { navigation::status m_status{navigation::status::e_unknown}; /// Step size when the valid intersection is not found for the target - scalar_type safe_step_size = 10.f * unit::mm; + scalar_type safe_step_size = 10. * unit::mm; /// Heartbeat of this navigation flow signals navigation is alive bool m_heartbeat{false}; diff --git a/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp b/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp index 9c6c72b7e9..d06a6e32c8 100644 --- a/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp +++ b/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp @@ -37,7 +37,7 @@ struct cuboid_intersector { template DETRAY_HOST_DEVICE bool operator()( const detail::ray &ray, const mask_t &box, - const dscalar /*mask_tolerance*/ = 0.f) const { + const dscalar /*mask_tolerance*/ = 0.) const { using scalar_type = dscalar; using point3_type = dpoint3D; @@ -48,9 +48,9 @@ struct cuboid_intersector { const vector3_type &rd = ray.dir(); // @TODO: put vector-vector operator/ in algebra-plugins constexpr scalar_type inv{detail::invalid_value()}; - const vector3_type inv_dir{rd[0] == 0.f ? inv : 1.f / rd[0], - rd[1] == 0.f ? inv : 1.f / rd[1], - rd[2] == 0.f ? inv : 1.f / rd[2]}; + const vector3_type inv_dir{rd[0] == 0. ? inv : 1. / rd[0], + rd[1] == 0. ? inv : 1. / rd[1], + rd[2] == 0. ? inv : 1. / rd[2]}; // This is prob. slow -> @todo refactor masks to hold custom mask values const vector3_type min{box[boundaries::e_min_x], diff --git a/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp index 9c366e217c..4d168c3759 100644 --- a/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp @@ -67,7 +67,7 @@ struct helix_intersector_impl, algebra_t> const darray mask_tolerance = {detail::invalid_value(), detail::invalid_value()}, - const scalar_type = 0.f, const scalar_type = 0.f) const { + const scalar_type = 0., const scalar_type = 0.) const { assert((mask_tolerance[0] == mask_tolerance[1]) && "Helix intersectors use only one mask tolerance value"); @@ -89,7 +89,7 @@ struct helix_intersector_impl, algebra_t> // Try to guess the best starting positions for the iteration // Direction of the track at the helix origin - const auto h_dir = h.dir(0.f); + const auto h_dir = h.dir(0.); // Default starting path length for the Newton iteration (assumes // concentric cylinder) const scalar_type default_s{r * vector::perp(h_dir)}; @@ -135,7 +135,7 @@ struct helix_intersector_impl, algebra_t> intersection_type &sfi = ret[i]; // Path length in the previous iteration step - scalar_type s_prev{0.f}; + scalar_type s_prev{0.}; // f(s) = ((h.pos(s) - sc) x sz)^2 - r^2 == 0 // Run the iteration on s @@ -146,10 +146,10 @@ struct helix_intersector_impl, algebra_t> // f'(s) = 2 * ( (h.pos(s) - sc) x sz) * (h.dir(s) x sz) ) const vector3_type crp = vector::cross(h.pos(s) - sc, sz); const scalar_type denom{ - 2.f * vector::dot(crp, vector::cross(h.dir(s), sz))}; + 2. * vector::dot(crp, vector::cross(h.dir(s), sz))}; // No intersection can be found if dividing by zero - if (denom == 0.f) { + if (denom == 0.) { return ret; } @@ -176,7 +176,7 @@ struct helix_intersector_impl, algebra_t> // Due to floating point errors this can be negative if // cos ~ 1 const scalar_type sin_inc2{math::fabs( - 1.f - cos_incidence_angle * cos_incidence_angle)}; + 1. - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -201,7 +201,7 @@ struct helix_intersector_impl, algebra_t> // Try to guess the best starting positions for the iteration // Direction of the track at the helix origin - const auto h_dir = h.dir(0.5f * r); + const auto h_dir = h.dir(0.5 * r); // Default starting path length for the Newton iteration (assumes // concentric cylinder) const scalar_type default_s{r * vector::perp(h_dir)}; @@ -247,7 +247,7 @@ struct helix_intersector_impl, algebra_t> const scalar_type f_s{(vector::dot(crp, crp) - r * r)}; // f'(s) = 2 * ( (h.pos(s) - sc) x sz) * (h.dir(s) x sz) ) const scalar_type df_s{ - 2.f * vector::dot(crp, vector::cross(h.dir(x), sz))}; + 2. * vector::dot(crp, vector::cross(h.dir(x), sz))}; return std::make_tuple(f_s, df_s); }; @@ -276,18 +276,18 @@ struct helix_intersector_impl, algebra_t> DETRAY_HOST_DEVICE inline darray, 2> operator()(const helix_type &h, const surface_descr_t &sf_desc, const mask_t &mask, const transform3_type &trf, - const scalar_type mask_tolerance, const scalar_type = 0.f, - const scalar_type = 0.f) const { + const scalar_type mask_tolerance, const scalar_type = 0., + const scalar_type = 0.) const { return this->operator()(h, sf_desc, mask, trf, - {mask_tolerance, mask_tolerance}, 0.f); + {mask_tolerance, mask_tolerance}, 0.); } /// Tolerance for convergence - scalar_type convergence_tolerance{1.f * unit::um}; + scalar_type convergence_tolerance{1. * unit::um}; // Guard against inifinite loops std::size_t max_n_tries{1000u}; // Early exit, if the intersection is too far away - scalar_type max_path{5.f * unit::m}; + scalar_type max_path{5. * unit::m}; // Complement the Newton algorithm with Bisection steps bool run_rtsafe{true}; }; diff --git a/core/include/detray/navigation/intersection/helix_line_intersector.hpp b/core/include/detray/navigation/intersection/helix_line_intersector.hpp index 8bcffb7c28..da557504d1 100644 --- a/core/include/detray/navigation/intersection/helix_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_line_intersector.hpp @@ -61,7 +61,7 @@ struct helix_intersector_impl, algebra_t> { const darray mask_tolerance = {detail::invalid_value(), detail::invalid_value()}, - const scalar_type = 0.f, const scalar_type = 0.f) const { + const scalar_type = 0., const scalar_type = 0.) const { assert((mask_tolerance[0] == mask_tolerance[1]) && "Helix intersectors use only one mask tolerance value"); @@ -76,20 +76,20 @@ struct helix_intersector_impl, algebra_t> { const point3_type c = trf.translation(); // initial track direction - const vector3_type t0 = h.dir(0.f); + const vector3_type t0 = h.dir(0.); // initial track position - const point3_type r0 = h.pos(0.f); + const point3_type r0 = h.pos(0.); // Projection of line to track direction const scalar_type lt0{vector::dot(l, t0)}; - const scalar_type denom{1.f - (lt0 * lt0)}; + const scalar_type denom{1. - (lt0 * lt0)}; // Case for wire is parallel to track // @NOTE We might not have to call this which is meant to be for ray // intersection... - if (denom < 1e-5f) { + if (denom < 1e-5) { sfi.status = false; return sfi; } @@ -106,8 +106,8 @@ struct helix_intersector_impl, algebra_t> { // Path length to the point of closest approach on the track // @NOTE Ray intersection algorithm is used for the initial guess on // the path length - scalar_type s{1.f / denom * (Q - P * lt0)}; - scalar_type s_prev{0.f}; + scalar_type s{1. / denom * (Q - P * lt0)}; + scalar_type s_prev{0.}; // Run the iteration on s std::size_t n_tries{0u}; @@ -161,7 +161,7 @@ struct helix_intersector_impl, algebra_t> { if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 const scalar_type sin_inc2{math::fabs( - 1.f - cos_incidence_angle * cos_incidence_angle)}; + 1. - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -179,20 +179,20 @@ struct helix_intersector_impl, algebra_t> { const point3_type c = trf.translation(); // initial track direction - const vector3_type t0 = h.dir(0.f); + const vector3_type t0 = h.dir(0.); // initial track position - const point3_type r0 = h.pos(0.f); + const point3_type r0 = h.pos(0.); // Projection of line to track direction const scalar_type lt0{vector::dot(l, t0)}; - const scalar_type denom{1.f - (lt0 * lt0)}; + const scalar_type denom{1. - (lt0 * lt0)}; // Case for wire is parallel to track // @NOTE We might not have to call this which is meant to be for ray // intersection... - if (denom < 1e-5f) { + if (denom < 1e-5) { #ifndef NDEBUG std::cout << "ERROR: Helix line intersector encountered " "invalid value!" @@ -214,7 +214,7 @@ struct helix_intersector_impl, algebra_t> { // Path length to the point of closest approach on the track // @NOTE Ray intersection algorithm is used for the initial guess on // the path length - scalar_type s_ini{1.f / denom * (Q - P * lt0)}; + scalar_type s_ini{1. / denom * (Q - P * lt0)}; /// Evaluate the function and its derivative at the point @param x auto line_inters_func = [&h, &c, &l](const scalar_type x) { @@ -265,17 +265,17 @@ struct helix_intersector_impl, algebra_t> { DETRAY_HOST_DEVICE inline intersection_type operator()( const helix_type &h, const surface_descr_t &sf_desc, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type = 0.f, const scalar_type = 0.f) const { + const scalar_type = 0., const scalar_type = 0.) const { return this->operator()(h, sf_desc, mask, trf, - {mask_tolerance, mask_tolerance}, 0.f); + {mask_tolerance, mask_tolerance}, 0.); } /// Tolerance for convergence - scalar_type convergence_tolerance{1.f * unit::um}; + scalar_type convergence_tolerance{1. * unit::um}; // Guard against inifinite loops std::size_t max_n_tries{1000u}; // Early exit, if the intersection is too far away - scalar_type max_path{5.f * unit::m}; + scalar_type max_path{5. * unit::m}; // Complement the Newton algorithm with Bisection steps bool run_rtsafe{true}; }; diff --git a/core/include/detray/navigation/intersection/helix_plane_intersector.hpp b/core/include/detray/navigation/intersection/helix_plane_intersector.hpp index d81928dde9..7b4412c770 100644 --- a/core/include/detray/navigation/intersection/helix_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_plane_intersector.hpp @@ -63,7 +63,7 @@ struct helix_intersector_impl, algebra_t> { const darray mask_tolerance = {detail::invalid_value(), detail::invalid_value()}, - const scalar_type = 0.f, const scalar_type = 0.f) const { + const scalar_type = 0., const scalar_type = 0.) const { assert((mask_tolerance[0] == mask_tolerance[1]) && "Helix intersectors use only one mask tolerance value"); @@ -80,16 +80,16 @@ struct helix_intersector_impl, algebra_t> { // Starting point on the helix for the Newton iteration const vector3_type dist{trf.point_to_global(mask.centroid()) - - h.pos(0.f)}; - scalar_type denom{vector::dot(sn, h.dir(0.f))}; + h.pos(0.)}; + scalar_type denom{vector::dot(sn, h.dir(0.))}; scalar_type s; - if (denom == 0.f) { + if (denom == 0.) { s = vector::norm(dist); } s = math::fabs(vector::dot(sn, dist) / denom); - scalar_type s_prev{0.f}; + scalar_type s_prev{0.}; // f(s) = sn * (h.pos(s) - st) == 0 // Run the iteration on s @@ -99,7 +99,7 @@ struct helix_intersector_impl, algebra_t> { // f'(s) = sn * h.dir(s) denom = vector::dot(sn, h.dir(s)); // No intersection can be found if dividing by zero - if (denom == 0.f) { + if (denom == 0.) { return sfi; } // x_n+1 = x_n - f(s) / f'(s) @@ -122,7 +122,7 @@ struct helix_intersector_impl, algebra_t> { if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 const scalar_type sin_inc2{math::fabs( - 1.f - cos_incidence_angle * cos_incidence_angle)}; + 1. - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -140,11 +140,11 @@ struct helix_intersector_impl, algebra_t> { // Starting point on the helix for the Newton iteration const vector3_type dist{trf.point_to_global(mask.centroid()) - - h.pos(0.f)}; + h.pos(0.)}; scalar_type denom{ - vector::dot(sn, h.dir(0.5f * vector::norm(dist)))}; + vector::dot(sn, h.dir(0.5 * vector::norm(dist)))}; scalar_type s_ini; - if (denom == 0.f) { + if (denom == 0.) { s_ini = vector::norm(dist); } else { s_ini = vector::dot(sn, dist) / denom; @@ -178,17 +178,17 @@ struct helix_intersector_impl, algebra_t> { DETRAY_HOST_DEVICE inline intersection_type operator()( const helix_type &h, const surface_descr_t &sf_desc, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type = 0.f, const scalar_type = 0.f) const { + const scalar_type = 0., const scalar_type = 0.) const { return this->operator()(h, sf_desc, mask, trf, - {mask_tolerance, mask_tolerance}, 0.f); + {mask_tolerance, mask_tolerance}, 0.); } /// Tolerance for convergence - scalar_type convergence_tolerance{1.f * unit::um}; + scalar_type convergence_tolerance{1. * unit::um}; // Guard against inifinite loops std::size_t max_n_tries{1000u}; // Early exit, if the intersection is too far away - scalar_type max_path{5.f * unit::m}; + scalar_type max_path{5. * unit::m}; // Complement the Newton algorithm with Bisection steps bool run_rtsafe{true}; }; diff --git a/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp index 4ffeefffe2..c36d1f040b 100644 --- a/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp @@ -60,9 +60,9 @@ struct ray_concentric_cylinder_intersector { const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type & /*trf*/, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -74,20 +74,20 @@ struct ray_concentric_cylinder_intersector { const point3_type l1 = ro + rd; // swap coorinates x/y for numerical stability - const bool swap_x_y = math::fabs(rd[0]) < 1e-3f; + const bool swap_x_y = math::fabs(rd[0]) < 1e-3; unsigned int _x = swap_x_y ? 1u : 0u; unsigned int _y = swap_x_y ? 0u : 1u; const scalar_type k{(l0[_y] - l1[_y]) / (l0[_x] - l1[_x])}; const scalar_type d{l1[_y] - k * l1[_x]}; - detail::quadratic_equation qe{(1.f + k * k), 2.f * k * d, + detail::quadratic_equation qe{(1. + k * k), 2. * k * d, d * d - r * r}; if (qe.solutions() > 0) { const scalar_type overstep_tolerance{overstep_tol}; darray candidates; - darray t01 = {0.f, 0.f}; + darray t01 = {0., 0.}; candidates[0][_x] = qe.smaller(); candidates[0][_y] = k * qe.smaller() + d; @@ -138,8 +138,8 @@ struct ray_concentric_cylinder_intersector { DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.f) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, + const scalar_type overstep_tol = 0.) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., overstep_tol); } @@ -159,9 +159,9 @@ struct ray_concentric_cylinder_intersector { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol)[0]; } diff --git a/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp b/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp index daacbe698f..ff5544e756 100644 --- a/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp @@ -69,9 +69,9 @@ struct ray_intersector_impl, algebra_t, const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -105,8 +105,8 @@ struct ray_intersector_impl, algebra_t, DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.f) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, + const scalar_type overstep_tol = 0.) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., overstep_tol); } @@ -125,9 +125,9 @@ struct ray_intersector_impl, algebra_t, const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection/ray_line_intersector.hpp b/core/include/detray/navigation/intersection/ray_line_intersector.hpp index 0e37ec909e..d1f10dbe86 100644 --- a/core/include/detray/navigation/intersection/ray_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_line_intersector.hpp @@ -56,9 +56,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -77,10 +77,10 @@ struct ray_intersector_impl, algebra_t, do_debug> { // Projection of line to track direction const scalar_type zd{vector::dot(_z, _d)}; - const scalar_type denom{1.f - (zd * zd)}; + const scalar_type denom{1. - (zd * zd)}; // Case for wire is parallel to track - if (denom < 1e-5f) { + if (denom < 1e-5) { is.status = false; return is; } @@ -95,7 +95,7 @@ struct ray_intersector_impl, algebra_t, do_debug> { const scalar_type t2l_on_track{vector::dot(t2l, _d)}; // path length to the point of closest approach on the track - const scalar_type A{1.f / denom * (t2l_on_track - t2l_on_line * zd)}; + const scalar_type A{1. / denom * (t2l_on_track - t2l_on_line * zd)}; is.path = A; // Intersection is not valid for navigation - return early @@ -126,8 +126,8 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.f) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, + const scalar_type overstep_tol = 0.) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., overstep_tol); } @@ -146,9 +146,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); diff --git a/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp index f9df43d634..dcd6d7ae15 100644 --- a/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp @@ -59,9 +59,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { operator()(const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); @@ -98,15 +98,15 @@ struct ray_intersector_impl, algebra_t, do_debug> { const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); // Construct the candidate only when needed - sfi.status = (qe.solutions() > 0.f); + sfi.status = (qe.solutions() > 0.); if (detray::detail::none_of(sfi.status)) { return; @@ -141,7 +141,7 @@ struct ray_intersector_impl, algebra_t, do_debug> { const auto pc_cross_sz = vector::cross(tmp, sz); const auto rd_cross_sz = vector::cross(rd, sz); const scalar_type a = vector::dot(rd_cross_sz, rd_cross_sz); - const scalar_type b = 2.f * vector::dot(rd_cross_sz, pc_cross_sz); + const scalar_type b = 2. * vector::dot(rd_cross_sz, pc_cross_sz); const scalar_type c = vector::dot(pc_cross_sz, pc_cross_sz) - (r * r); return detail::quadratic_equation{a, b, c}; @@ -159,9 +159,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { build_candidate(const detail::ray &ray, const mask_t &mask, const transform3_type &trf, const scalar_type path, const darray &mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; diff --git a/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp index 544f06d20e..a34b383d24 100644 --- a/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp @@ -61,9 +61,9 @@ struct ray_intersector_impl, algebra_t, DETRAY_HOST_DEVICE inline intersection_type operator()( const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -81,7 +81,7 @@ struct ray_intersector_impl, algebra_t, // Only the closest intersection that is outside the overstepping // tolerance is needed const auto valid_smaller = (qe.smaller() > overstep_tol); - scalar_type t = 0.f; + scalar_type t = 0.; t(valid_smaller) = qe.smaller(); t(!valid_smaller) = qe.larger(); @@ -107,9 +107,9 @@ struct ray_intersector_impl, algebra_t, const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp index 6b26cfadd5..ecf84c7583 100644 --- a/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp @@ -56,9 +56,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -77,10 +77,10 @@ struct ray_intersector_impl, algebra_t, do_debug> { // Projection of line to track direction const scalar_type zd = vector::dot(sz, rd); - const scalar_type denom = 1.f - (zd * zd); + const scalar_type denom = 1. - (zd * zd); // Case for wire is parallel to track - if (detray::detail::all_of(denom < 1e-5f)) { + if (detray::detail::all_of(denom < 1e-5)) { is.status = decltype(is.status)(false); return is; } @@ -138,9 +138,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp index 41907f2c81..82363cc417 100644 --- a/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp @@ -57,9 +57,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { intersection_type is; @@ -126,9 +126,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0.f, 1.f}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., 1.}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection_kernel.hpp b/core/include/detray/navigation/intersection_kernel.hpp index b1d756d89d..ac0576202d 100644 --- a/core/include/detray/navigation/intersection_kernel.hpp +++ b/core/include/detray/navigation/intersection_kernel.hpp @@ -48,10 +48,10 @@ struct intersection_initialize { const surface_t &surface, const transform_container_t &contextual_transforms, const typename transform_container_t::context_type &ctx, - const darray &mask_tolerance = {0.f, - 1.f * unit::mm}, - const scalar_t mask_tol_scalor = 0.f, - const scalar_t overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., + 1. * unit::mm}, + const scalar_t mask_tol_scalor = 0., + const scalar_t overstep_tol = 0.) const { using mask_t = typename mask_group_t::value_type; using algebra_t = typename mask_t::algebra_type; @@ -140,10 +140,10 @@ struct intersection_update { const traj_t &traj, intersection_t &sfi, const transform_container_t &contextual_transforms, const typename transform_container_t::context_type &ctx, - const darray &mask_tolerance = {0.f, - 1.f * unit::mm}, - const scalar_t mask_tol_scalor = 0.f, - const scalar_t overstep_tol = 0.f) const { + const darray &mask_tolerance = {0., + 1. * unit::mm}, + const scalar_t mask_tol_scalor = 0., + const scalar_t overstep_tol = 0.) const { using mask_t = typename mask_group_t::value_type; using algebra_t = typename mask_t::algebra_type; diff --git a/core/include/detray/navigation/intersector.hpp b/core/include/detray/navigation/intersector.hpp index 400511071d..34dd2a7c39 100644 --- a/core/include/detray/navigation/intersector.hpp +++ b/core/include/detray/navigation/intersector.hpp @@ -43,9 +43,9 @@ struct intersector { const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type mask_tol_scalor = 0.f, - const scalar_type overstep_tol = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type mask_tol_scalor = 0., + const scalar_type overstep_tol = 0.) const { return ray_intersector_type{}(ray, sf, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); @@ -57,8 +57,8 @@ struct intersector { const detail::helix &h, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0.f, 1.f * unit::mm}, - const scalar_type = 0.f, const scalar_type = 0.f) const { + {0., 1. * unit::mm}, + const scalar_type = 0., const scalar_type = 0.) const { return helix_intersector_type{}(h, sf, mask, trf, mask_tolerance); } diff --git a/core/include/detray/navigation/navigator.hpp b/core/include/detray/navigation/navigator.hpp index ddb1a1657c..52bc91a31f 100644 --- a/core/include/detray/navigation/navigator.hpp +++ b/core/include/detray/navigation/navigator.hpp @@ -397,8 +397,8 @@ class navigator { m_heartbeat = false; // Don't do anything if aborted m_trust_level = navigation::trust_level::e_full; - run_inspector({}, point3_type{0.f, 0.f, 0.f}, - vector3_type{0.f, 0.f, 0.f}, "Aborted: "); + run_inspector({}, point3_type{0., 0., 0.}, + vector3_type{0., 0., 0.}, "Aborted: "); return m_heartbeat; } @@ -411,8 +411,8 @@ class navigator { m_status = navigation::status::e_on_target; m_heartbeat = false; m_trust_level = navigation::trust_level::e_full; - run_inspector({}, point3_type{0.f, 0.f, 0.f}, - vector3_type{0.f, 0.f, 0.f}, "Exited: "); + run_inspector({}, point3_type{0., 0., 0.}, + vector3_type{0., 0., 0.}, "Exited: "); this->clear(); return m_heartbeat; } @@ -622,7 +622,7 @@ class navigator { static_cast(nav_state.direction()) * track.dir()), sf_descr, det.transform_store(), ctx, - sf.is_portal() ? darray{0.f, 0.f} : mask_tol, + sf.is_portal() ? darray{0., 0.} : mask_tol, mask_tol_scalor, overstep_tol); } }; @@ -749,8 +749,8 @@ class navigator { // Use the max mask tolerance in case a track leaves the volume // when a sf is 'sticking' out of the portals due to the tol loose_cfg.overstep_tolerance = - math::min(100.f * cfg.overstep_tolerance, - -10.f * cfg.max_mask_tolerance); + math::min(100. * cfg.overstep_tolerance, + -10. * cfg.max_mask_tolerance); init(track, navigation, loose_cfg, ctx, use_path_tolerance_as_overstep_tolerance); @@ -936,7 +936,7 @@ class navigator { detail::ray( track.pos(), static_cast(nav_dir) * track.dir()), candidate, det.transform_store(), ctx, - sf.is_portal() ? darray{0.f, 0.f} + sf.is_portal() ? darray{0., 0.} : darray{cfg.min_mask_tolerance, cfg.max_mask_tolerance}, static_cast(cfg.mask_tolerance_scalor), diff --git a/core/include/detray/navigation/policies.hpp b/core/include/detray/navigation/policies.hpp index cb3079bdcb..fb2aa0a749 100644 --- a/core/include/detray/navigation/policies.hpp +++ b/core/include/detray/navigation/policies.hpp @@ -98,8 +98,8 @@ template struct stepper_rk_policy : actor { struct state { - scalar_t m_threshold_fair_trust{0.05f}; - scalar_t m_threshold_no_trust{0.1f}; + scalar_t m_threshold_fair_trust{0.05}; + scalar_t m_threshold_no_trust{0.1}; }; /// Sets the navigation trust level depending on the step size correction diff --git a/core/include/detray/propagator/actors/aborters.hpp b/core/include/detray/propagator/actors/aborters.hpp index e69f180320..7ac4c05193 100644 --- a/core/include/detray/propagator/actors/aborters.hpp +++ b/core/include/detray/propagator/actors/aborters.hpp @@ -56,7 +56,7 @@ struct pathlimit_aborter : actor { math::fabs(prop_state._stepping.abs_path_length()); // Check the path limit - if (step_limit <= 0.f) { + if (step_limit <= 0.) { // Stop navigation prop_state._heartbeat &= nav_state.abort(); } @@ -91,7 +91,7 @@ struct target_aborter : actor { // directly if (navigation.is_on_surface() && (navigation.barcode() == abrt_state._target_surface) && - (stepping.path_length() > 0.f)) { + (stepping.path_length() > 0.)) { prop_state._heartbeat &= navigation.abort(); } } diff --git a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp index 5643bad10d..3c8ae35fff 100644 --- a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp +++ b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp @@ -36,11 +36,11 @@ struct pointwise_material_interactor : actor { struct state { /// Evaluated energy loss - scalar_type e_loss{0.f}; + scalar_type e_loss{0.}; /// Evaluated projected scattering angle - scalar_type projected_scattering_angle{0.f}; + scalar_type projected_scattering_angle{0.}; /// Evaluated sigma of qoverp - scalar_type sigma_qop{0.f}; + scalar_type sigma_qop{0.}; bool do_covariance_transport = true; bool do_energy_loss = true; @@ -48,9 +48,9 @@ struct pointwise_material_interactor : actor { DETRAY_HOST_DEVICE void reset() { - e_loss = 0.f; - projected_scattering_angle = 0.f; - sigma_qop = 0.f; + e_loss = 0.; + projected_scattering_angle = 0.; + sigma_qop = 0.; } }; @@ -212,12 +212,12 @@ struct pointwise_material_interactor : actor { // Put particle at rest if energy loss is too large const scalar_type next_p{ - (m < next_e) ? math::sqrt(next_e * next_e - m * m) : 0.f}; + (m < next_e) ? math::sqrt(next_e * next_e - m * m) : 0.}; // For neutral particles, qoverp = 1/p constexpr auto inv{detail::invalid_value()}; - const scalar_type next_qop{(q != 0.f) ? q / next_p : 1.f / next_p}; - vector.set_qop((next_p == 0.f) ? inv : next_qop); + const scalar_type next_qop{(q != 0.) ? q / next_p : 1. / next_p}; + vector.set_qop((next_p == 0.) ? inv : next_qop); } /// @brief Update the variance of q over p of bound track parameter @@ -250,8 +250,8 @@ struct pointwise_material_interactor : actor { constexpr auto inv{detail::invalid_value()}; getter::element(covariance, e_bound_phi, e_bound_phi) += - (dir[2] == 1.f) ? inv - : var_scattering_angle / (1.f - dir[2] * dir[2]); + (dir[2] == 1.) ? inv + : var_scattering_angle / (1. - dir[2] * dir[2]); getter::element(covariance, e_bound_theta, e_bound_theta) += var_scattering_angle; diff --git a/core/include/detray/propagator/base_stepper.hpp b/core/include/detray/propagator/base_stepper.hpp index df90ebdd6e..fe1a1781c0 100644 --- a/core/include/detray/propagator/base_stepper.hpp +++ b/core/include/detray/propagator/base_stepper.hpp @@ -112,7 +112,7 @@ class base_stepper { /// Get stepping direction DETRAY_HOST_DEVICE inline step::direction direction() const { - return m_step_size >= 0.f ? step::direction::e_forward + return m_step_size >= 0. ? step::direction::e_forward : step::direction::e_backward; } @@ -247,13 +247,13 @@ class base_stepper { std::size_t m_n_total_trials{0u}; /// Current step size - scalar_type m_step_size{0.f}; + scalar_type m_step_size{0.}; /// Track path length (current position along track) - scalar_type m_path_length{0.f}; + scalar_type m_path_length{0.}; /// Absolute path length (total path length covered by the integration) - scalar_type m_abs_path_length{0.f}; + scalar_type m_abs_path_length{0.}; /// Step size constraints (optional) [[no_unique_address]] constraint_t m_constraint = {}; diff --git a/core/include/detray/propagator/detail/jacobian_cartesian.hpp b/core/include/detray/propagator/detail/jacobian_cartesian.hpp index 0ac10f45cc..6c88ab4abd 100644 --- a/core/include/detray/propagator/detail/jacobian_cartesian.hpp +++ b/core/include/detray/propagator/detail/jacobian_cartesian.hpp @@ -55,7 +55,7 @@ struct jacobian> { const vector3_type normal = coordinate_frame::normal(trf3); - const vector3_type pos_term = -1.f / vector::dot(normal, dir) * normal; + const vector3_type pos_term = -1. / vector::dot(normal, dir) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; diff --git a/core/include/detray/propagator/detail/jacobian_cylindrical.hpp b/core/include/detray/propagator/detail/jacobian_cylindrical.hpp index 5be2f12427..5c8737f16e 100644 --- a/core/include/detray/propagator/detail/jacobian_cylindrical.hpp +++ b/core/include/detray/propagator/detail/jacobian_cylindrical.hpp @@ -80,7 +80,7 @@ struct jacobian> { const vector3_type normal = coordinate_frame::normal(trf3, local); const vector3_type pos_term = - (-1.f / vector::dot(normal, dir)) * normal; + (-1. / vector::dot(normal, dir)) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; diff --git a/core/include/detray/propagator/detail/jacobian_engine.hpp b/core/include/detray/propagator/detail/jacobian_engine.hpp index 09bf9948e4..5dc989219e 100644 --- a/core/include/detray/propagator/detail/jacobian_engine.hpp +++ b/core/include/detray/propagator/detail/jacobian_engine.hpp @@ -73,7 +73,7 @@ requires std::is_object_v struct jacobian_engine { pos, dir); // Set d(bound time)/d(free time) - getter::element(jac_to_global, e_free_time, e_bound_time) = 1.f; + getter::element(jac_to_global, e_free_time, e_bound_time) = 1.; // Set d(n_x,n_y,n_z)/d(phi, theta) getter::element(jac_to_global, e_free_dir0, e_bound_phi) = @@ -85,7 +85,7 @@ requires std::is_object_v struct jacobian_engine { getter::element(jac_to_global, e_free_dir1, e_bound_theta) = cos_theta * sin_phi; getter::element(jac_to_global, e_free_dir2, e_bound_theta) = -sin_theta; - getter::element(jac_to_global, e_free_qoverp, e_bound_qoverp) = 1.f; + getter::element(jac_to_global, e_free_qoverp, e_bound_qoverp) = 1.; // Set d(x,y,z)/d(phi, theta) jacobian_t::set_bound_angle_to_free_pos_derivative(jac_to_global, trf3, @@ -120,7 +120,7 @@ requires std::is_object_v struct jacobian_engine { pos, dir); // Set d(free time)/d(bound time) - getter::element(jac_to_local, e_bound_time, e_free_time) = 1.f; + getter::element(jac_to_local, e_bound_time, e_free_time) = 1.; // Set d(phi, theta)/d(n_x, n_y, n_z) // @note This codes have a serious bug when theta is equal to zero... @@ -135,7 +135,7 @@ requires std::is_object_v struct jacobian_engine { getter::element(jac_to_local, e_bound_theta, e_free_dir2) = -sin_theta; // Set d(Free Qop)/d(Bound Qop) - getter::element(jac_to_local, e_bound_qoverp, e_free_qoverp) = 1.f; + getter::element(jac_to_local, e_bound_qoverp, e_free_qoverp) = 1.; return jac_to_local; } diff --git a/core/include/detray/propagator/detail/jacobian_line.hpp b/core/include/detray/propagator/detail/jacobian_line.hpp index 3de161ab6c..8dba2a7a0a 100644 --- a/core/include/detray/propagator/detail/jacobian_line.hpp +++ b/core/include/detray/propagator/detail/jacobian_line.hpp @@ -91,7 +91,7 @@ struct jacobian> { const vector3_type pc_x = pc - pz * local_zaxis; const scalar_type norm = - -1.f / (1.f - dz * dz + vector::dot(pc_x, dtds)); + -1. / (1. - dz * dz + vector::dot(pc_x, dtds)); const vector3_type pos_term = norm * (dir - dz * local_zaxis); const vector3_type dir_term = norm * pc_x; @@ -158,7 +158,7 @@ struct jacobian> { const vector3_type new_zaxis = getter::vector<3>(frame, 0u, 2u); // The projection of direction onto ref frame normal - const scalar_type ipdn{1.f / vector::dot(dir, new_zaxis)}; + const scalar_type ipdn{1. / vector::dot(dir, new_zaxis)}; // d(n_x,n_y,n_z)/dPhi const vector3_type dNdPhi = diff --git a/core/include/detray/propagator/detail/jacobian_polar.hpp b/core/include/detray/propagator/detail/jacobian_polar.hpp index 755878cfb2..eb29208482 100644 --- a/core/include/detray/propagator/detail/jacobian_polar.hpp +++ b/core/include/detray/propagator/detail/jacobian_polar.hpp @@ -58,7 +58,7 @@ struct jacobian> { const vector3_type normal = coordinate_frame::normal(trf3); - const vector3_type pos_term = -1.f / vector::dot(normal, dir) * normal; + const vector3_type pos_term = -1. / vector::dot(normal, dir) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; @@ -135,7 +135,7 @@ struct jacobian> { const matrix_type<1, 3> row0 = dudG * lcos_phi + dvdG * lsin_phi; const matrix_type<1, 3> row1 = - (1.f / lrad) * (lcos_phi * dvdG - lsin_phi * dudG); + (1. / lrad) * (lcos_phi * dvdG - lsin_phi * dudG); getter::set_block(free_pos_to_bound_pos_derivative, row0, e_bound_loc0, e_free_pos0); diff --git a/core/include/detray/propagator/line_stepper.hpp b/core/include/detray/propagator/line_stepper.hpp index 3d587c549d..05b7b2b617 100644 --- a/core/include/detray/propagator/line_stepper.hpp +++ b/core/include/detray/propagator/line_stepper.hpp @@ -75,11 +75,11 @@ class line_stepper final } DETRAY_HOST_DEVICE - constexpr vector3_type dtds() const { return {0.f, 0.f, 0.f}; } + constexpr vector3_type dtds() const { return {0., 0., 0.}; } DETRAY_HOST_DEVICE constexpr scalar_type dqopds(const material*) const { - return 0.f; + return 0.; } }; diff --git a/core/include/detray/propagator/rk_stepper.hpp b/core/include/detray/propagator/rk_stepper.hpp index 750a8971ef..97ef0d2de3 100644 --- a/core/include/detray/propagator/rk_stepper.hpp +++ b/core/include/detray/propagator/rk_stepper.hpp @@ -49,9 +49,9 @@ class rk_stepper final rk_stepper() = default; struct intermediate_state { - vector3_type b_first{0.f, 0.f, 0.f}; - vector3_type b_middle{0.f, 0.f, 0.f}; - vector3_type b_last{0.f, 0.f, 0.f}; + vector3_type b_first{0., 0., 0.}; + vector3_type b_middle{0., 0., 0.}; + vector3_type b_last{0., 0., 0.}; // t = tangential direction = dr/ds darray t; // q/p @@ -158,7 +158,7 @@ class rk_stepper final scalar_type m_dqopds_3; /// Next step size after adaptive step size scaling - scalar_type m_next_step_size{0.f}; + scalar_type m_next_step_size{0.}; /// Magnetic field view const magnetic_field_t m_magnetic_field; diff --git a/core/include/detray/propagator/rk_stepper.ipp b/core/include/detray/propagator/rk_stepper.ipp index 35f84748ad..7b5fbf09cd 100644 --- a/core/include/detray/propagator/rk_stepper.ipp +++ b/core/include/detray/propagator/rk_stepper.ipp @@ -33,7 +33,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // Reference: Eq (82) of https://doi.org/10.1016/0029-554X(81)90063-X dir = - dir + h_6 * (sd.dtds[0] + 2.f * (sd.dtds[1] + sd.dtds[2]) + sd.dtds[3]); + dir + h_6 * (sd.dtds[0] + 2. * (sd.dtds[1] + sd.dtds[2]) + sd.dtds[3]); dir = vector::normalize(dir); track.set_dir(dir); @@ -41,7 +41,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< if (vol_mat_ptr != nullptr) { // Reference: Eq (82) of https://doi.org/10.1016/0029-554X(81)90063-X qop = - qop + h_6 * (sd.dqopds[0u] + 2.f * (sd.dqopds[1u] + sd.dqopds[2u]) + + qop + h_6 * (sd.dqopds[0u] + 2. * (sd.dqopds[1u] + sd.dqopds[2u]) + sd.dqopds[3u]); } track.set_qop(qop); @@ -86,8 +86,8 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // Half step length const scalar_type h2{h * h}; - const scalar_type half_h{h * 0.5f}; - const scalar_type h_6{h * (1.f / 6.f)}; + const scalar_type half_h{h * 0.5}; + const scalar_type h_6{h * (1. / 6.)}; // 3X3 Identity matrix const auto I33 = matrix::identity>(); @@ -96,7 +96,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< darray, 4u> dkndt{I33, I33, I33, I33}; darray dkndqop; darray, 4u> dkndr; - darray dqopn_dqop{1.f, 1.f, 1.f, 1.f}; + darray dqopn_dqop{1., 1., 1., 1.}; /*--------------------------------------------------------------------------- * dk_n/dt1 @@ -188,22 +188,22 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< ---------------------------------------------------------------------------*/ if (!cfg.use_eloss_gradient) { - getter::element(D, e_free_qoverp, e_free_qoverp) = 1.f; + getter::element(D, e_free_qoverp, e_free_qoverp) = 1.; } else { // Pre-calculate dqop_n/dqop1 const scalar_type d2qop1dsdqop1 = this->d2qopdsdqop(sd.qop[0u], vol_mat_ptr); - dqopn_dqop[0u] = 1.f; - dqopn_dqop[1u] = 1.f + half_h * d2qop1dsdqop1; + dqopn_dqop[0u] = 1.; + dqopn_dqop[1u] = 1. + half_h * d2qop1dsdqop1; const scalar_type d2qop2dsdqop1 = this->d2qopdsdqop(sd.qop[1u], vol_mat_ptr) * dqopn_dqop[1u]; - dqopn_dqop[2u] = 1.f + half_h * d2qop2dsdqop1; + dqopn_dqop[2u] = 1. + half_h * d2qop2dsdqop1; const scalar_type d2qop3dsdqop1 = this->d2qopdsdqop(sd.qop[2u], vol_mat_ptr) * dqopn_dqop[2u]; - dqopn_dqop[3u] = 1.f + h * d2qop3dsdqop1; + dqopn_dqop[3u] = 1. + h * d2qop3dsdqop1; const scalar_type d2qop4dsdqop1 = this->d2qopdsdqop(sd.qop[3u], vol_mat_ptr) * dqopn_dqop[3u]; @@ -213,7 +213,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< -------------------------------------------------------------------*/ getter::element(D, e_free_qoverp, e_free_qoverp) = - 1.f + h_6 * (d2qop1dsdqop1 + 2.f * (d2qop2dsdqop1 + d2qop3dsdqop1) + + 1. + h_6 * (d2qop1dsdqop1 + 2. * (d2qop2dsdqop1 + d2qop3dsdqop1) + d2qop4dsdqop1); } @@ -265,8 +265,8 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // the fourth order RKN vector3_type r_ini = track.pos(); vector3_type r_mid = - r_ini + half_h * sd.t[0u] + h2 * 0.125f * sd.dtds[0u]; - vector3_type r_fin = r_ini + h * sd.t[0u] + h2 * 0.5f * sd.dtds[2u]; + r_ini + half_h * sd.t[0u] + h2 * 0.125 * sd.dtds[0u]; + vector3_type r_fin = r_ini + h * sd.t[0u] + h2 * 0.5 * sd.dtds[2u]; matrix_type<3, 3> dBdr_ini = evaluate_field_gradient(r_ini); matrix_type<3, 3> dBdr_mid = evaluate_field_gradient(r_mid); @@ -285,7 +285,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< half_h * dkndr[0u], sd.b_middle); dkndr[1u] = dkndr[1u] - sd.qop[1u] * mat_helper().column_wise_cross( - dBdr_mid * (I33 + h2 * 0.125f * dkndr[0u]), + dBdr_mid * (I33 + h2 * 0.125 * dkndr[0u]), sd.t[1u]); // dk3/dr1 @@ -293,7 +293,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< half_h * dkndr[1u], sd.b_middle); dkndr[2u] = dkndr[2u] - sd.qop[2u] * mat_helper().column_wise_cross( - dBdr_mid * (I33 + h2 * 0.125f * dkndr[0u]), + dBdr_mid * (I33 + h2 * 0.125 * dkndr[0u]), sd.t[2u]); // dk4/dr1 @@ -302,13 +302,13 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< dkndr[3u] = dkndr[3u] - sd.qop[3u] * mat_helper().column_wise_cross( - dBdr_fin * (I33 + h2 * 0.5f * dkndr[2u]), sd.t[3u]); + dBdr_fin * (I33 + h2 * 0.5 * dkndr[2u]), sd.t[3u]); // Set dF/dr1 and dG/dr1 auto dFdr = matrix::identity>(); auto dGdr = matrix::identity>(); dFdr = dFdr + h * h_6 * (dkndr[0u] + dkndr[1u] + dkndr[2u]); - dGdr = h_6 * (dkndr[0u] + 2.f * (dkndr[1u] + dkndr[2u]) + dkndr[3u]); + dGdr = h_6 * (dkndr[0u] + 2. * (dkndr[1u] + dkndr[2u]) + dkndr[3u]); getter::set_block(D, dFdr, 0u, 0u); getter::set_block(D, dGdr, 4u, 0u); @@ -319,7 +319,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< auto dGdt = matrix::identity>(); dFdt = dFdt + h_6 * (dkndt[0u] + dkndt[1u] + dkndt[2u]); dFdt = h * dFdt; - dGdt = dGdt + h_6 * (dkndt[0u] + 2.f * (dkndt[1u] + dkndt[2u]) + dkndt[3u]); + dGdt = dGdt + h_6 * (dkndt[0u] + 2. * (dkndt[1u] + dkndt[2u]) + dkndt[3u]); getter::set_block(D, dFdt, 0u, 4u); getter::set_block(D, dGdt, 4u, 4u); @@ -327,7 +327,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // Set dF/dqop1 and dG/dqop1 vector3_type dFdqop = h * h_6 * (dkndqop[0u] + dkndqop[1u] + dkndqop[2u]); vector3_type dGdqop = - h_6 * (dkndqop[0u] + 2.f * (dkndqop[1u] + dkndqop[2u]) + dkndqop[3u]); + h_6 * (dkndqop[0u] + 2. * (dkndqop[1u] + dkndqop[2u]) + dkndqop[3u]); getter::set_block(D, dFdqop, 0u, 7u); getter::set_block(D, dGdqop, 4u, 7u); @@ -348,7 +348,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< if (!vol_mat_ptr) { const scalar_type qop = track.qop(); - return detray::make_pair(scalar_type(0.f), qop); + return detray::make_pair(scalar_type(0.), qop); } else if (cfg.use_mean_loss && i != 0u) { // qop_n is calculated recursively like the direction of // evaluate_dtds. @@ -393,7 +393,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< auto dBdr = matrix::zero>(); - constexpr auto delta{1e-1f * unit::mm}; + constexpr auto delta{1e-1 * unit::mm}; for (unsigned int i = 0; i < 3; i++) { @@ -415,7 +415,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< bvec2[1u] = bvec2_tmp[1u]; bvec2[2u] = bvec2_tmp[2u]; - const vector3_type gradient = (bvec1 - bvec2) * (1.f / (2.f * delta)); + const vector3_type gradient = (bvec1 - bvec2) * (1. / (2. * delta)); getter::element(dBdr, 0u, i) = gradient[0u]; getter::element(dBdr, 1u, i) = gradient[1u]; @@ -432,7 +432,7 @@ detray::rk_stepper::state::dtds() const -> vector3_type { // In case there was no step before - if (this->path_length() == 0.f) { + if (this->path_length() == 0.) { const point3_type pos = (*this)().pos(); const auto bvec_tmp = this->m_magnetic_field.at(pos[0], pos[1], pos[2]); @@ -455,7 +455,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< -> scalar_type { // In case there was no step before - if (this->path_length() == 0.f) { + if (this->path_length() == 0.) { return this->dqopds((*this)().qop(), vol_mat_ptr); } @@ -472,7 +472,7 @@ DETRAY_HOST_DEVICE auto detray::rk_stepper< // d(qop)ds is zero for empty space if (!vol_mat_ptr) { - return 0.f; + return 0.; } const scalar_type q = this->particle_hypothesis().charge(); @@ -486,7 +486,7 @@ DETRAY_HOST_DEVICE auto detray::rk_stepper< *vol_mat_ptr, this->particle_hypothesis(), {mass, qop, q}); // Assert that a momentum is a positive value - assert(p >= 0.f); + assert(p >= 0.); // d(qop)ds, which is equal to (qop) * E * (-dE/ds) / p^2 // or equal to (qop)^3 * E * (-dE/ds) / q^2 @@ -503,7 +503,7 @@ detray::rk_stepper scalar_type { if (!vol_mat_ptr) { - return 0.f; + return 0.; } const scalar_type q = this->particle_hypothesis().charge(); @@ -519,12 +519,12 @@ detray::rk_stepper rq(mass, qop, q); const scalar_type g = - -1.f * + -1. * I.compute_stopping_power(*vol_mat_ptr, this->particle_hypothesis(), rq); // dg/d(qop) = -1 * derivation of stopping power const scalar_type dgdqop = - -1.f * + -1. * I.derive_stopping_power(*vol_mat_ptr, this->particle_hypothesis(), rq); // d(qop)/ds = - qop^3 * E * g / q^2 @@ -532,7 +532,7 @@ detray::rk_stepper break and advance track - if (error <= 4.f * cfg.rk_error_tol) { + if (error <= 4. * cfg.rk_error_tol) { break; } // Error estimate is too big diff --git a/core/include/detray/tracks/bound_track_parameters.hpp b/core/include/detray/tracks/bound_track_parameters.hpp index 448b750136..4af47fe1d3 100644 --- a/core/include/detray/tracks/bound_track_parameters.hpp +++ b/core/include/detray/tracks/bound_track_parameters.hpp @@ -135,7 +135,7 @@ struct bound_parameters_vector { /// Set the global theta angle DETRAY_HOST_DEVICE void set_theta(const scalar_type theta) { - assert(0.f < theta); + assert(0. < theta); assert(theta <= constant::pi); getter::element(m_vector, e_bound_theta, 0u) = theta; } @@ -180,7 +180,7 @@ struct bound_parameters_vector { scalar_type qopT() const { const scalar_type theta{getter::element(m_vector, e_bound_theta, 0u)}; const scalar_type sinTheta{math::sin(theta)}; - assert(sinTheta != 0.f); + assert(sinTheta != 0.); return getter::element(m_vector, e_bound_qoverp, 0u) / sinTheta; } @@ -189,15 +189,15 @@ struct bound_parameters_vector { scalar_type qopz() const { const scalar_type theta{getter::element(m_vector, e_bound_theta, 0u)}; const scalar_type cosTheta{math::cos(theta)}; - assert(cosTheta != 0.f); + assert(cosTheta != 0.); return getter::element(m_vector, e_bound_qoverp, 0u) / cosTheta; } /// @returns the absolute momentum DETRAY_HOST_DEVICE scalar_type p(const scalar_type q) const { - assert(qop() != 0.f); - assert(q * qop() > 0.f); + assert(qop() != 0.); + assert(q * qop() > 0.); return q / qop(); } @@ -208,16 +208,16 @@ struct bound_parameters_vector { /// @returns the transverse momentum DETRAY_HOST_DEVICE scalar_type pT(const scalar_type q) const { - assert(qop() != 0.f); - assert(q * qop() > 0.f); + assert(qop() != 0.); + assert(q * qop() > 0.); return math::fabs(q / qop() * vector::perp(dir())); } /// @returns the absolute momentum z-component DETRAY_HOST_DEVICE scalar_type pz(const scalar_type q) const { - assert(qop() != 0.f); - assert(q * qop() > 0.f); + assert(qop() != 0.); + assert(q * qop() > 0.); return math::fabs(q / qop() * dir()[2]); } diff --git a/core/include/detray/tracks/free_track_parameters.hpp b/core/include/detray/tracks/free_track_parameters.hpp index 81cf7b50ff..14b63d01c8 100644 --- a/core/include/detray/tracks/free_track_parameters.hpp +++ b/core/include/detray/tracks/free_track_parameters.hpp @@ -138,7 +138,7 @@ struct free_parameters_vector { DETRAY_HOST_DEVICE scalar_type qopT() const { const vector3_type dir = this->dir(); - assert(vector::perp(dir) != 0.f); + assert(vector::perp(dir) != 0.); return getter::element(m_vector, e_free_qoverp, 0u) / vector::perp(dir); } @@ -152,8 +152,8 @@ struct free_parameters_vector { /// @returns the absolute momentum DETRAY_HOST_DEVICE scalar_type p(const scalar_type q) const { - assert(qop() != 0.f); - assert(q * qop() > 0.f); + assert(qop() != 0.); + assert(q * qop() > 0.); return q / qop(); } @@ -164,16 +164,16 @@ struct free_parameters_vector { /// @returns the transverse momentum DETRAY_HOST_DEVICE scalar_type pT(const scalar_type q) const { - assert(this->qop() != 0.f); - assert(q * qop() > 0.f); + assert(this->qop() != 0.); + assert(q * qop() > 0.); return math::fabs(q / this->qop() * vector::perp(this->dir())); } /// @returns the absolute momentum z-component DETRAY_HOST_DEVICE scalar_type pz(const scalar_type q) const { - assert(this->qop() != 0.f); - assert(q * qop() > 0.f); + assert(this->qop() != 0.); + assert(q * qop() > 0.); return math::fabs(q / this->qop() * this->dir()[2]); } diff --git a/core/include/detray/tracks/helix.hpp b/core/include/detray/tracks/helix.hpp index c85377cf6d..b12da46459 100644 --- a/core/include/detray/tracks/helix.hpp +++ b/core/include/detray/tracks/helix.hpp @@ -66,12 +66,12 @@ class helix { // Normalized B field _h0 = vector::normalize(mag_field); - assert((math::fabs(vector::norm(_t0) - 1.f) < 1e-5f) && + assert((math::fabs(vector::norm(_t0) - 1.) < 1e-5) && "The helix direction must be normalized"); // Momentum const vector3_type mom = - (1.f / static_cast(math::fabs(qop))) * _t0; + (1. / static_cast(math::fabs(qop))) * _t0; // Normalized _h0 X _t0 _n0 = vector::normalize(vector::cross(_h0, _t0)); @@ -98,7 +98,7 @@ class helix { _R = vector::norm(pT) / _B; // Handle the case of pT ~ 0 - if (vector::norm(pT) < 1e-6f) { + if (vector::norm(pT) < 1e-6) { _vz_over_vt = detail::invalid_value(); } else { // Get vz over vt in new coordinate @@ -140,7 +140,7 @@ class helix { point3_type ret = _pos; ret = ret + _delta / _K * (_K * s - math::sin(_K * s)) * _h0; ret = ret + math::sin(_K * s) / _K * _t0; - ret = ret + _alpha / _K * (1.f - math::cos(_K * s)) * _n0; + ret = ret + _alpha / _K * (1. - math::cos(_K * s)) * _n0; return ret; } @@ -157,7 +157,7 @@ class helix { return _t0; } - vector3_type ret{0.f, 0.f, 0.f}; + vector3_type ret{0., 0., 0.}; ret = ret + _delta * (1 - math::cos(_K * s)) * _h0; ret = ret + math::cos(_K * s) * _t0; @@ -220,7 +220,7 @@ class helix { drdt = drdt + (_K * s - sin_ks) / _K * H0H0_T; drdt = drdt + - (cos_ks - 1.f) / _K * mat_helper().column_wise_cross(I33, _h0); + (cos_ks - 1.) / _K * mat_helper().column_wise_cross(I33, _h0); getter::set_block(ret, drdt, e_free_pos0, e_free_dir0); @@ -234,7 +234,7 @@ class helix { // Get drdl vector3_type drdl = - 1.f / _qop * (s * this->dir(s) + _pos - this->pos(s)); + 1. / _qop * (s * this->dir(s) + _pos - this->pos(s)); getter::set_block(ret, drdl, e_free_pos0, e_free_qoverp); @@ -246,8 +246,8 @@ class helix { getter::set_block(ret, dtdl, e_free_dir0, e_free_qoverp); // 3x3 and 7x7 element is 1 (Maybe?) - getter::element(ret, e_free_time, e_free_time) = 1.f; - getter::element(ret, e_free_qoverp, e_free_qoverp) = 1.f; + getter::element(ret, e_free_time, e_free_time) = 1.; + getter::element(ret, e_free_qoverp, e_free_qoverp) = 1.; return ret; } diff --git a/core/include/detray/tracks/ray.hpp b/core/include/detray/tracks/ray.hpp index 581286512e..89d1f68694 100644 --- a/core/include/detray/tracks/ray.hpp +++ b/core/include/detray/tracks/ray.hpp @@ -75,7 +75,7 @@ class ray { /// @returns the q over p value: Zero for ray DETRAY_HOST_DEVICE - constexpr scalar_type qop() const { return 0.f; } + constexpr scalar_type qop() const { return 0.; } /// Print DETRAY_HOST @@ -91,9 +91,9 @@ class ray { private: /// origin of ray - point3_type _pos{0.f, 0.f, 0.f}; + point3_type _pos{0., 0., 0.}; /// direction of ray - vector3_type _dir{0.f, 0.f, 1.f}; + vector3_type _dir{0., 0., 1.}; }; // Deduce the type of algebra from the track diff --git a/core/include/detray/utils/axis_rotation.hpp b/core/include/detray/utils/axis_rotation.hpp index 5e614fb7b8..fb995df4fe 100644 --- a/core/include/detray/utils/axis_rotation.hpp +++ b/core/include/detray/utils/axis_rotation.hpp @@ -44,7 +44,7 @@ struct axis_rotation { matrix_type<3, 3> axis_outer = mat_helper().outer_product(U, U); R = cos_theta * I + math::sin(theta) * axis_cross + - (1.f - cos_theta) * axis_outer; + (1. - cos_theta) * axis_outer; } /// @param v vector to be rotated @@ -72,11 +72,11 @@ struct euler_rotation { using vector3_type = dvector3D; // Following the z-x-z convention - vector3_type x{1.0f, 0.f, 0.f}; - vector3_type z{0.f, 0.f, 1.f}; - scalar_type alpha{0.f}; - scalar_type beta{0.f}; - scalar_type gamma{0.f}; + vector3_type x{1.0, 0., 0.}; + vector3_type z{0., 0., 1.}; + scalar_type alpha{0.}; + scalar_type beta{0.}; + scalar_type gamma{0.}; /// @returns Get the new x and z axis DETRAY_HOST_DEVICE std::pair operator()() diff --git a/core/include/detray/utils/bounding_volume.hpp b/core/include/detray/utils/bounding_volume.hpp index 92728b66f6..9beddddc08 100644 --- a/core/include/detray/utils/bounding_volume.hpp +++ b/core/include/detray/utils/bounding_volume.hpp @@ -212,15 +212,15 @@ class axis_aligned_bounding_volume { DETRAY_HOST_DEVICE constexpr auto center() const -> point3_t { const scalar_t center_x{ - 0.5f * (m_mask[cuboid3D::e_max_x] + m_mask[cuboid3D::e_min_x])}; + 0.5 * (m_mask[cuboid3D::e_max_x] + m_mask[cuboid3D::e_min_x])}; const scalar_t center_y{ - 0.5f * (m_mask[cuboid3D::e_max_y] + m_mask[cuboid3D::e_min_y])}; + 0.5 * (m_mask[cuboid3D::e_max_y] + m_mask[cuboid3D::e_min_y])}; const scalar_t center_z{ - 0.5f * (m_mask[cuboid3D::e_max_z] + m_mask[cuboid3D::e_min_z])}; + 0.5 * (m_mask[cuboid3D::e_max_z] + m_mask[cuboid3D::e_min_z])}; - return {detail::is_invalid_value(center_x) ? 0.f : center_x, - detail::is_invalid_value(center_y) ? 0.f : center_y, - detail::is_invalid_value(center_z) ? 0.f : center_z}; + return {detail::is_invalid_value(center_x) ? 0. : center_x, + detail::is_invalid_value(center_y) ? 0. : center_y, + detail::is_invalid_value(center_z) ? 0. : center_z}; } /// @brief Lower and upper point for minimum axis aligned bounding box of diff --git a/core/include/detray/utils/grid/detail/axis_binning.hpp b/core/include/detray/utils/grid/detail/axis_binning.hpp index a4a09fbe21..6a9024a9c5 100644 --- a/core/include/detray/utils/grid/detail/axis_binning.hpp +++ b/core/include/detray/utils/grid/detail/axis_binning.hpp @@ -77,7 +77,7 @@ struct regular { /// @returns the corresponding bin index DETRAY_HOST_DEVICE int bin(const scalar_type v) const { - return static_cast((v - span()[0]) / bin_width() + 1.f) - 1; + return static_cast((v - span()[0]) / bin_width() + 1.) - 1; } /// Access function to a range with binned neighborhood diff --git a/core/include/detray/utils/matrix_helper.hpp b/core/include/detray/utils/matrix_helper.hpp index a2f5073f52..96669dba4a 100644 --- a/core/include/detray/utils/matrix_helper.hpp +++ b/core/include/detray/utils/matrix_helper.hpp @@ -106,7 +106,7 @@ struct matrix_helper { // Cholesky–Banachiewicz algorithm for (size_type i = 0u; i < N; i++) { for (size_type j = 0u; j <= i; j++) { - scalar_type sum = 0.f; + scalar_type sum = 0.; for (size_type k = 0u; k < j; k++) sum += getter::element(L, i, k) * getter::element(L, j, k); @@ -115,7 +115,7 @@ struct matrix_helper { math::sqrt(getter::element(mat, i, i) - sum)); } else { getter::element(L, i, j) = - (1.f / getter::element(L, j, j) * + (1. / getter::element(L, j, j) * (getter::element(mat, i, j) - sum)); } } diff --git a/core/include/detray/utils/quadratic_equation.hpp b/core/include/detray/utils/quadratic_equation.hpp index f8be682088..c719f70bac 100644 --- a/core/include/detray/utils/quadratic_equation.hpp +++ b/core/include/detray/utils/quadratic_equation.hpp @@ -50,12 +50,12 @@ requires std::is_arithmetic_v class quadratic_equation { m_values[0] = -c / b; } } else { - const scalar_t discriminant{b * b - 4.f * a * c}; + const scalar_t discriminant{b * b - 4. * a * c}; // If there is more than one solution, then a != 0 and q != 0 if (discriminant > tolerance) { m_solutions = 2; const scalar_t q{ - -0.5f * + -0.5 * (b + detail::copysign(math::sqrt(discriminant), b))}; m_values = {q / a, c / q}; // Sort the two solutions @@ -64,9 +64,9 @@ requires std::is_arithmetic_v class quadratic_equation { } } // Only one solution and a != 0 - else if (discriminant >= 0.f) { + else if (discriminant >= 0.) { m_solutions = 1; - m_values[0] = -0.5f * b / a; + m_values[0] = -0.5 * b / a; } // discriminant < 0 is not allowed, since all solutions should be // real @@ -101,10 +101,10 @@ requires(!std::is_arithmetic_v) class quadratic_equation { DETRAY_HOST_DEVICE constexpr quadratic_equation(const scalar_t &a, const scalar_t &b, const scalar_t &c, - const scalar_t &tolerance = 1e-6f) { + const scalar_t &tolerance = 1e-6) { // Linear case auto one_sol = (math::fabs(a) <= tolerance); - m_solutions(one_sol) = 1.f; + m_solutions(one_sol) = 1.; m_values[0] = -c / b; // Early exit @@ -112,18 +112,18 @@ requires(!std::is_arithmetic_v) class quadratic_equation { return; } - const scalar_t discriminant = b * b - (4.f * a) * c; + const scalar_t discriminant = b * b - (4. * a) * c; const auto two_sol = (discriminant > tolerance); - one_sol = !two_sol && (discriminant >= 0.f); + one_sol = !two_sol && (discriminant >= 0.); // If there is more than one solution, then a != 0 and q != 0 if (detray::detail::any_of(two_sol)) { - m_solutions = 2.f; + m_solutions = 2.; m_solutions.setZeroInverted(two_sol); const scalar_t q = - -0.5f * (b + math::copysign(math::sqrt(discriminant), b)); + -0.5 * (b + math::copysign(math::sqrt(discriminant), b)); scalar_t first = q / a; scalar_t second = c / q; @@ -146,8 +146,8 @@ requires(!std::is_arithmetic_v) class quadratic_equation { // Only one solution and a != 0 if (detray::detail::any_of(one_sol)) { - scalar_t sol = 1.f; - scalar_t result = -0.5f * b / a; + scalar_t sol = 1.; + scalar_t result = -0.5 * b / a; sol.setZeroInverted(one_sol); result.setZeroInverted(one_sol); @@ -168,9 +168,9 @@ requires(!std::is_arithmetic_v) class quadratic_equation { private: /// Number of solutions of the equation (needs to be floating point to /// apply the masks correctly) - scalar_t m_solutions = 0.f; + scalar_t m_solutions = 0.; /// The solutions - darray m_values{scalar_t(0.f), scalar_t(0.f)}; + darray m_values{scalar_t(0.), scalar_t(0.)}; }; template diff --git a/core/include/detray/utils/root_finding.hpp b/core/include/detray/utils/root_finding.hpp index 11f9a4d496..8c9e18955d 100644 --- a/core/include/detray/utils/root_finding.hpp +++ b/core/include/detray/utils/root_finding.hpp @@ -39,7 +39,7 @@ template DETRAY_HOST_DEVICE inline bool expand_bracket(const scalar_t a, const scalar_t b, function_t &f, darray &bracket, - const scalar_t k = 1.f) { + const scalar_t k = 1.) { if (a == b) { throw std::invalid_argument( @@ -95,9 +95,9 @@ DETRAY_HOST_DEVICE inline bool expand_bracket(const scalar_t a, template DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( function_t &evaluate_func, scalar_t s, - const scalar_t convergence_tolerance = 1.f * unit::um, + const scalar_t convergence_tolerance = 1. * unit::um, const std::size_t max_n_tries = 1000u, - const scalar_t max_path = 5.f * unit::m) { + const scalar_t max_path = 5. * unit::m) { constexpr scalar_t inv{detail::invalid_value()}; constexpr scalar_t epsilon{std::numeric_limits::epsilon()}; @@ -110,13 +110,13 @@ DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( }; // Initial bracket - scalar_t a{math::fabs(s) == 0.f ? -0.1f : 0.9f * s}; - scalar_t b{math::fabs(s) == 0.f ? 0.1f : 1.1f * s}; + scalar_t a{math::fabs(s) == 0. ? -0.1 : 0.9 * s}; + scalar_t b{math::fabs(s) == 0. ? 0.1 : 1.1 * s}; darray br{}; bool is_bracketed = expand_bracket(a, b, f, br); // Update initial guess on the root after bracketing - s = is_bracketed ? 0.5f * (br[1] + br[0]) : s; + s = is_bracketed ? 0.5 * (br[1] + br[0]) : s; if (is_bracketed) { // Check bracket @@ -153,7 +153,7 @@ DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( } // Run the iteration on s - scalar_t s_prev{0.f}; + scalar_t s_prev{0.}; std::size_t n_tries{0u}; auto [f_s, df_s] = evaluate_func(s); if (math::fabs(f_s) < convergence_tolerance) { @@ -169,37 +169,37 @@ DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( // Does Newton step escape bracket? bool bracket_escape{true}; - scalar_t s_newton{0.f}; - if (math::fabs(df_s) != 0.f) { + scalar_t s_newton{0.}; + if (math::fabs(df_s) != 0.) { s_newton = s - f_s / df_s; bracket_escape = math::signbit((s_newton - a) * (b - s_newton)); } // This criterion from Numerical Recipes seems to work, but why? - /*const bool slow_convergence{math::fabs(2.f * f_s) > + /*const bool slow_convergence{math::fabs(2. * f_s) > math::fabs((s_prev - s) * df_s)};*/ // Take a bisection step if it converges faster than Newton // |f(next_newton_s)| > |f(next_bisection_s)| bool slow_convergence{true}; // The criterion is only well defined if the step lengths are small - if (const scalar_t ds_bisection{0.5f * (a + b) - s}; + if (const scalar_t ds_bisection{0.5 * (a + b) - s}; is_bracketed && - (math::fabs(ds_bisection) < 10.f * unit::mm)) { + (math::fabs(ds_bisection) < 10. * unit::mm)) { slow_convergence = - (2.f * math::fabs(f_s) > math::fabs(df_s * ds_bisection + f_s)); + (2. * math::fabs(f_s) > math::fabs(df_s * ds_bisection + f_s)); } s_prev = s; // Run bisection if Newton-Raphson would be poor if (is_bracketed && - (bracket_escape || slow_convergence || math::fabs(df_s) == 0.f)) { + (bracket_escape || slow_convergence || math::fabs(df_s) == 0.)) { // Test the function sign in the middle of the interval - s = 0.5f * (a + b); + s = 0.5 * (a + b); } else { // No intersection can be found if dividing by zero - if (!is_bracketed && math::fabs(df_s) == 0.f) { + if (!is_bracketed && math::fabs(df_s) == 0.) { std::cout << "WARNING: Encountered invalid derivative " << std::endl; @@ -282,7 +282,7 @@ DETRAY_HOST_DEVICE inline void build_intersection( if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 const scalar_t sin_inc2{ - math::fabs(1.f - cos_incidence_angle * cos_incidence_angle)}; + math::fabs(1. - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs(ds * math::sqrt(sin_inc2)); } diff --git a/core/include/detray/utils/string_helpers.hpp b/core/include/detray/utils/string_helpers.hpp index 0cb50c91b3..36bf26124c 100644 --- a/core/include/detray/utils/string_helpers.hpp +++ b/core/include/detray/utils/string_helpers.hpp @@ -27,12 +27,13 @@ struct string_view_concat2 { } }; -/// Split string @param input at every occurence of @param delim +/// Split string @param input at every occurrence of @param delim inline dvector split_at_delim(const std::string &input, const char delim) { dvector tokens{}; - for (const auto char_range : std::views::split(input, delim)) { + std::string delimm{delim}; + for (const auto char_range : std::views::split(input, delimm)) { std::string s{""}; // TODO: Remove when range constructor becomes available in c++23 for (const char c : char_range) { diff --git a/core/include/detray/utils/unit_vectors.hpp b/core/include/detray/utils/unit_vectors.hpp index 993dbce06a..5a8a6fae2d 100644 --- a/core/include/detray/utils/unit_vectors.hpp +++ b/core/include/detray/utils/unit_vectors.hpp @@ -28,7 +28,7 @@ struct unit_vectors { DETRAY_HOST_DEVICE inline vector3_t make_curvilinear_unit_u( const vector3_t& dir) { - vector3_t unit_u{0.f, 0.f, 0.f}; + vector3_t unit_u{0., 0., 0.}; // explicit version of U = Z x T unit_u[0] = -dir[1]; unit_u[1] = dir[0]; @@ -39,11 +39,11 @@ struct unit_vectors { // aligned with the z-axis. the ZxT product is ill-defined since any // vector in the x-y plane would be orthogonal to the direction. fix the // U unit vector along the x-axis to avoid this numerical instability. - if (scale < 1e-6f) { + if (scale < 1e-6) { unit_u[0] = 1; unit_u[1] = 0; } else { - unit_u = unit_u * (1.f / scale); + unit_u = unit_u * (1. / scale); } return unit_u; diff --git a/tests/benchmarks/cpu/find_volume.cpp b/tests/benchmarks/cpu/find_volume.cpp index 8f1ab15d77..acdd85028b 100644 --- a/tests/benchmarks/cpu/find_volume.cpp +++ b/tests/benchmarks/cpu/find_volume.cpp @@ -57,7 +57,7 @@ void BM_FIND_VOLUMES(benchmark::State &state) { for (auto _ : state) { for (unsigned int i1 = 0u; i1 < itest; ++i1) { for (unsigned int i0 = 0u; i0 < itest; ++i0) { - test::vector3 rz{static_cast(i0) * step0, 0.f, + test::vector3 rz{static_cast(i0) * step0, 0., static_cast(i1) * step1}; const auto &v = d.volume(rz); diff --git a/tests/benchmarks/cpu/propagation.cpp b/tests/benchmarks/cpu/propagation.cpp index c422726ed9..da9ff3bf35 100644 --- a/tests/benchmarks/cpu/propagation.cpp +++ b/tests/benchmarks/cpu/propagation.cpp @@ -58,7 +58,7 @@ int main(int argc, char** argv) { // // Constant magnetic field - vector3 B{0.f, 0.f, 2.f * unit::T}; + vector3 B{0., 0., 2. * unit::T}; // Configure toy detector toy_det_config toy_cfg{}; @@ -68,7 +68,7 @@ int main(int argc, char** argv) { // Configure wire chamber wire_chamber_config wire_chamber_cfg{}; - wire_chamber_cfg.half_z(500.f * unit::mm); + wire_chamber_cfg.half_z(500. * unit::mm); std::cout << wire_chamber_cfg << std::endl; diff --git a/tests/include/detray/test/common/detector_scan_config.hpp b/tests/include/detray/test/common/detector_scan_config.hpp index 5593f29a47..54f255d8af 100644 --- a/tests/include/detray/test/common/detector_scan_config.hpp +++ b/tests/include/detray/test/common/detector_scan_config.hpp @@ -42,7 +42,7 @@ struct detector_scan_config : public test::fixture_base<>::configuration { std::numeric_limits::epsilon(), std::numeric_limits::epsilon()}; /// B-field vector for helix - vector3_type m_B{0.f * unit::T, 0.f * unit::T, + vector3_type m_B{0. * unit::T, 0. * unit::T, 2.f * unit::T}; /// Configuration of the ray generator trk_gen_config_t m_trk_gen_cfg{}; diff --git a/tests/include/detray/test/common/material_validation_config.hpp b/tests/include/detray/test/common/material_validation_config.hpp index 14ea10262d..719f02d37f 100644 --- a/tests/include/detray/test/common/material_validation_config.hpp +++ b/tests/include/detray/test/common/material_validation_config.hpp @@ -82,7 +82,7 @@ struct material_validation_config : public test::fixture_base<>::configuration { return *this; } material_validation_config &relative_error(scalar_type re) { - assert(re > 0.f); + assert(re > 0.); m_rel_error = re; return *this; } diff --git a/tests/include/detray/test/common/navigation_validation_config.hpp b/tests/include/detray/test/common/navigation_validation_config.hpp index e8d974f0e5..c1962b3f99 100644 --- a/tests/include/detray/test/common/navigation_validation_config.hpp +++ b/tests/include/detray/test/common/navigation_validation_config.hpp @@ -45,7 +45,7 @@ struct navigation_validation_config detray::detail::invalid_value(), detray::detail::invalid_value()}; /// B-field vector for helix - vector3_type m_B{0.f * unit::T, 0.f * unit::T, + vector3_type m_B{0. * unit::T, 0. * unit::T, 2.f * unit::T}; /// Visualization style to be applied to the svgs detray::svgtools::styling::style m_style = diff --git a/tests/include/detray/test/cpu/detector_scan.hpp b/tests/include/detray/test/cpu/detector_scan.hpp index 84ac1c1736..7dfa5f8d56 100644 --- a/tests/include/detray/test/cpu/detector_scan.hpp +++ b/tests/include/detray/test/cpu/detector_scan.hpp @@ -215,7 +215,7 @@ class detector_scan : public test::fixture_base<> { // surfaces it encounters // @note: For rays, set the momentum to 1 GeV to keep the // direction vector normalized - const scalar p{q == 0.f ? 1.f * unit::GeV : trk.p(q)}; + const scalar p{q == 0. ? 1.f * unit::GeV : trk.p(q)}; auto trace = detector_scanner::run( m_gctx, m_det, test_traj, m_cfg.mask_tolerance(), p); diff --git a/tests/include/detray/test/cpu/material_scan.hpp b/tests/include/detray/test/cpu/material_scan.hpp index 3ba1d38506..ad08b12301 100644 --- a/tests/include/detray/test/cpu/material_scan.hpp +++ b/tests/include/detray/test/cpu/material_scan.hpp @@ -126,7 +126,7 @@ class material_scan : public test::fixture_base<> { } // Record track parameters - tracks.push_back({ray.pos(), 0.f, ray.dir(), 0.f}); + tracks.push_back({ray.pos(), 0., ray.dir(), 0.}); // New material record material_record_t mat_record{}; @@ -181,14 +181,14 @@ class material_scan : public test::fixture_base<> { const scalar_t mx0{mat_params.mat_X0}; const scalar_t ml0{mat_params.mat_L0}; - if (mx0 > 0.f) { + if (mx0 > 0.) { mat_record.sX0 += seg / mx0; mat_record.tX0 += t / mx0; } else { std::cout << "WARNING: Encountered invalid X_0: " << mx0 << "\nOn surface: " << sf << std::endl; } - if (ml0 > 0.f) { + if (ml0 > 0.) { mat_record.sL0 += seg / ml0; mat_record.tL0 += t / ml0; } else { @@ -197,8 +197,8 @@ class material_scan : public test::fixture_base<> { } } - if (mat_record.sX0 == 0.f || mat_record.sL0 == 0.f || - mat_record.tX0 == 0.f || mat_record.tL0 == 0.f) { + if (mat_record.sX0 == 0. || mat_record.sL0 == 0. || + mat_record.tX0 == 0. || mat_record.tL0 == 0.) { std::cout << "WARNING: No material recorded for ray " << n_tracks << "/" << ray_generator.size() << ": " << ray << std::endl; diff --git a/tests/include/detray/test/cpu/material_validation.hpp b/tests/include/detray/test/cpu/material_validation.hpp index 2953a7acc3..7e82af9510 100644 --- a/tests/include/detray/test/cpu/material_validation.hpp +++ b/tests/include/detray/test/cpu/material_validation.hpp @@ -163,7 +163,7 @@ class material_validation_impl : public test::fixture_base<> { if (truth <= e && rec <= e) { // No material for this ray => valid - return scalar_t{0.f}; + return scalar_t{0.}; } else if (truth <= e) { // Material found where none should be return detail::invalid_value(); diff --git a/tests/include/detray/test/cpu/navigation_validation.hpp b/tests/include/detray/test/cpu/navigation_validation.hpp index 57cd329f4c..ff099e2b1b 100644 --- a/tests/include/detray/test/cpu/navigation_validation.hpp +++ b/tests/include/detray/test/cpu/navigation_validation.hpp @@ -149,8 +149,8 @@ class navigation_validation : public test::fixture_base<> { trajectory_type test_traj = get_parametrized_trajectory(track); const scalar q = start.charge; - const scalar pT{q == 0.f ? 1.f * unit::GeV : track.pT(q)}; - const scalar p{q == 0.f ? 1.f * unit::GeV : track.p(q)}; + const scalar pT{q == 0. ? 1.f * unit::GeV : track.pT(q)}; + const scalar p{q == 0. ? 1.f * unit::GeV : track.p(q)}; // If the momentum is unknown, 1 GeV is the safest option to keep // the direction vector normalized diff --git a/tests/include/detray/test/device/cuda/navigation_validation.hpp b/tests/include/detray/test/device/cuda/navigation_validation.hpp index 5d6d478188..11f106686e 100644 --- a/tests/include/detray/test/device/cuda/navigation_validation.hpp +++ b/tests/include/detray/test/device/cuda/navigation_validation.hpp @@ -294,9 +294,9 @@ class navigation_validation : public test::fixture_base<> { trajectory_type test_traj = get_parametrized_trajectory(trck_param); const scalar q = start.charge; - const scalar pT{q == 0.f ? 1.f * unit::GeV + const scalar pT{q == 0. ? 1.f * unit::GeV : trck_param.pT(q)}; - const scalar p{q == 0.f ? 1.f * unit::GeV + const scalar p{q == 0. ? 1.f * unit::GeV : trck_param.p(q)}; if (detray::detail::is_invalid_value(m_cfg.p_range()[0])) { diff --git a/tests/include/detray/test/device/propagator_test.hpp b/tests/include/detray/test/device/propagator_test.hpp index 38c7d5f7d2..3066807962 100644 --- a/tests/include/detray/test/device/propagator_test.hpp +++ b/tests/include/detray/test/device/propagator_test.hpp @@ -196,7 +196,7 @@ inline void compare_propagation_results( auto relative_error = static_cast( 1.f / host_step.path_length * (host_pos - device_pos)); - EXPECT_NEAR(vector::norm(relative_error), 0.f, is_close) + EXPECT_NEAR(vector::norm(relative_error), 0., is_close) << "ERROR: Position at track " << i << " step " << j << ": [" << host_pos[0] << ", " << host_pos[1] << ", " << host_pos[2] << "] (host), [" << device_pos[0] << ", " << device_pos[1] @@ -214,7 +214,7 @@ inline void compare_propagation_results( scalar device_val = getter::element(device_J, row, col); ASSERT_NEAR((host_val - device_val) / host_step.path_length, - 0.f, is_close) + 0., is_close) << "ERROR: matrix element mismatch at row " << row << ", col " << col << std::endl; } diff --git a/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp b/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp index 4052612811..7e8e1ba52d 100644 --- a/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp +++ b/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp @@ -100,7 +100,7 @@ struct tel_det_config { return *this; } constexpr tel_det_config &length(const scalar_t l) { - assert((l > 0.f) && + assert((l > 0.) && "Telescope detector length must be greater than zero"); m_length = l; return *this; @@ -108,7 +108,7 @@ struct tel_det_config { constexpr tel_det_config &positions(const std::vector &dists) { m_positions.clear(); std::ranges::copy_if(dists, std::back_inserter(m_positions), - [](scalar_t d) { return (d >= 0.f); }); + [](scalar_t d) { return (d >= 0.); }); return *this; } constexpr tel_det_config &module_material(const material &mat) { @@ -120,7 +120,7 @@ struct tel_det_config { return *this; } constexpr tel_det_config &mat_thickness(const scalar_t t) { - assert(t >= 0.f && "Material thickness must be non-negative"); + assert(t >= 0. && "Material thickness must be non-negative"); m_material_config.thickness(t); return *this; } @@ -129,7 +129,7 @@ struct tel_det_config { return *this; } constexpr tel_det_config &envelope(const scalar_t e) { - assert(e > 0.f && "Portal envelope must be greater than zero"); + assert(e > 0. && "Portal envelope must be greater than zero"); m_envelope = e; return *this; } diff --git a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp index 744f7578dd..8314de244d 100644 --- a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp +++ b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp @@ -71,7 +71,7 @@ struct toy_det_config { .phi_stagger({4.f * unit::mm, 4.f * unit::mm}) .phi_sub_stagger( {0.5f * unit::mm, 0.5f * unit::mm}) - .module_tilt({0.f, 0.f}) + .module_tilt({0., 0.}) .binning({40u, 68u}); // Configure the material generation @@ -86,7 +86,7 @@ struct toy_det_config { m_beampipe_map_cfg.mapped_material = beryllium_tml(); m_beampipe_map_cfg.thickness = 0.8f * unit::mm; // Don't scale the generation of the material thickness - m_beampipe_map_cfg.scalor = 0.f; + m_beampipe_map_cfg.scalor = 0.; m_beampipe_map_cfg.mat_generator = detray::detail::generate_cyl_mat; @@ -185,18 +185,18 @@ struct toy_det_config { return *this; } constexpr toy_det_config &material_map_min_thickness(const scalar_t t) { - assert(t > 0.f); + assert(t > 0.); m_cyl_map_cfg.thickness = t; m_disc_map_cfg.thickness = t; return *this; } constexpr toy_det_config &beampipe_mat_thickness(const scalar_t t) { - assert(t > 0.f); + assert(t > 0.); m_beampipe_mat_thickness = t; return *this; } constexpr toy_det_config &module_mat_thickness(const scalar_t t) { - assert(t > 0.f); + assert(t > 0.); m_module_mat_thickness = t; return *this; } @@ -490,12 +490,12 @@ void add_cylinder_portals(volume_builder_interface *v_builder, // Left disc portal pt_disc_factory->push_back({surface_id::e_portal, - transform3_t{point3_t{0.f, 0.f, min_z}}, + transform3_t{point3_t{0., 0., min_z}}, static_cast(link_west), std::vector{min_r, max_r}}); // Right disc portal pt_disc_factory->push_back({surface_id::e_portal, - transform3_t{point3_t{0.f, 0.f, max_z}}, + transform3_t{point3_t{0., 0., max_z}}, static_cast(link_east), std::vector{min_r, max_r}}); @@ -863,7 +863,7 @@ inline auto add_endcap_detector( std::min(std::abs(vol_bounds.upper_z), std::abs(vol_bounds.lower_z))}; - const point3_t gap_center{0.f, 0.f, + const point3_t gap_center{0., 0., 0.5f * (gap_east_z + gap_west_z)}; vm_builder->add_volume_placement({gap_center}); @@ -901,7 +901,7 @@ inline auto add_endcap_detector( // Position the volume at the respective endcap layer position const scalar_t center_z{sign * cfg.endcap_layer_positions().at(j)}; - const point3_t vol_center{0.f, 0.f, center_z}; + const point3_t vol_center{0., 0., center_z}; vm_builder->add_volume_placement({vol_center}); // Configure the module factory for this layer @@ -1021,7 +1021,7 @@ inline void add_connector_portals( const scalar_t gap_west_z{connector_gap_data.second.upper}; const scalar_t min_z{math::min(gap_east_z, gap_west_z)}; const scalar_t max_z{math::max(gap_east_z, gap_west_z)}; - const point3_t gap_center{0.f, 0.f, 0.5f * (gap_east_z + gap_west_z)}; + const point3_t gap_center{0., 0., 0.5f * (gap_east_z + gap_west_z)}; // Check that the volume under construction is really the connector gap assert(std::abs(gap_east_z) == cfg.barrel_config().half_length() || @@ -1041,7 +1041,7 @@ inline void add_connector_portals( // Barrel-facing disc portal pt_disc_factory->push_back( {surface_id::e_portal, - transform3_t{point3_t{0.f, 0.f, (side < 0.f) ? max_z : min_z}}, + transform3_t{point3_t{0., 0., (side < 0.) ? max_z : min_z}}, static_cast(e.first), std::vector{min_r, max_r}}); } @@ -1049,7 +1049,7 @@ inline void add_connector_portals( // Outward-facing disc portal pt_disc_factory->push_back( {surface_id::e_portal, - transform3_t{point3_t{0.f, 0.f, (side < 0.f) ? min_z : max_z}}, + transform3_t{point3_t{0., 0., (side < 0.) ? min_z : max_z}}, static_cast(connector_gap_idx - 1u), std::vector{inner_r, outer_r}}); @@ -1099,7 +1099,7 @@ inline void add_beampipe_portals( constexpr auto end_of_world{detail::invalid_value()}; const scalar_t h_z{cfg.barrel_config().half_length()}; - const scalar_t inner_r{0.f}; + const scalar_t inner_r{0.}; const scalar_t outer_r{cfg.beampipe_vol_radius()}; // If there are no endcaps, add the beampipe disc portals at the boundaries @@ -1116,12 +1116,12 @@ inline void add_beampipe_portals( // Lower dics portal pt_disc_factory->push_back( - {surface_id::e_portal, transform3_t{point3_t{0.f, 0.f, -h_z}}, + {surface_id::e_portal, transform3_t{point3_t{0., 0., -h_z}}, end_of_world, std::vector{inner_r, outer_r}}); // Outward-facing disc portal pt_disc_factory->push_back( - {surface_id::e_portal, transform3_t{point3_t{0.f, 0.f, h_z}}, + {surface_id::e_portal, transform3_t{point3_t{0., 0., h_z}}, end_of_world, std::vector{inner_r, outer_r}}); beampipe_builder->add_surfaces(pt_disc_factory); @@ -1181,7 +1181,7 @@ inline void add_beampipe_portals( pt_disc_factory = std::make_shared(); } - const scalar_t inner_r{0.f}; + const scalar_t inner_r{0.}; const scalar_t outer_r{cfg.beampipe_vol_radius()}; scalar_t disc_pos_z{-side * std::numeric_limits::max()}; @@ -1191,7 +1191,7 @@ inline void add_beampipe_portals( const scalar_t min_z{math::min(e.second.lower, e.second.upper)}; const scalar_t max_z{math::max(e.second.lower, e.second.upper)}; - if (side < 0.f) { + if (side < 0.) { disc_pos_z = (disc_pos_z > min_z) ? min_z : disc_pos_z; } else { disc_pos_z = (disc_pos_z < max_z) ? max_z : disc_pos_z; @@ -1205,7 +1205,7 @@ inline void add_beampipe_portals( // Outward-facing disc portal pt_disc_factory->push_back( - {surface_id::e_portal, transform3_t{point3_t{0.f, 0.f, disc_pos_z}}, + {surface_id::e_portal, transform3_t{point3_t{0., 0., disc_pos_z}}, end_of_world, std::vector{inner_r, outer_r}}); // Add all portals to the beampipe volume diff --git a/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp b/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp index 3a26fc3b5d..a1a5cf12fd 100644 --- a/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp +++ b/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp @@ -204,7 +204,7 @@ inline auto build_wire_chamber( cylinder_portal_config inner_pt_cfg{}; inner_pt_cfg.do_autofit(false) .fixed_half_length(cfg.half_z()) - .fixed_inner_radius(0.f) + .fixed_inner_radius(0.) .fixed_outer_radius(inner_rad) // No inner subdetectors present -> don't build inner portal .build_inner(false) diff --git a/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp b/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp index 625f948282..06d2e51772 100644 --- a/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp @@ -227,10 +227,10 @@ class barrel_generator final : public surface_factory_interface { // Local z axis is the normal vector const scalar_t tilt_phi{m_cfg.tilt_phi()}; const vector3_t mod_local_z{math::cos(mod_phi + tilt_phi), - math::sin(mod_phi + tilt_phi), 0.f}; + math::sin(mod_phi + tilt_phi), 0.}; // Local x axis the normal to local y,z const vector3_t mod_local_x{-math::sin(mod_phi + tilt_phi), - math::cos(mod_phi + tilt_phi), 0.f}; + math::cos(mod_phi + tilt_phi), 0.}; // Create the module transform transforms.emplace_back(ctx, mod_center, mod_local_z, mod_local_x); diff --git a/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp b/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp index eadcc570f9..4aff4254de 100644 --- a/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp @@ -33,7 +33,7 @@ struct endcap_generator_config { /// Construct positive or negative endcap int m_side{-1}; /// Center position (|z|) - scalar_t m_center_z{0.f}; + scalar_t m_center_z{0.}; /// Inner layer radius scalar_t m_inner_radius{25.f * unit::mm}; /// Outer layer radius @@ -53,7 +53,7 @@ struct endcap_generator_config { std::vector m_phi_sub_stagger = {0.5f * unit::mm, 0.5f * unit::mm}; /// Module tilt (per ring) - std::vector m_tilt = {0.f, 0.f}; + std::vector m_tilt = {0., 0.}; /// Number of modules in phi (per ring) std::vector m_binning = {40u, 68u}; @@ -211,7 +211,7 @@ class endcap_generator final : public surface_factory_interface { (m_cfg.inner_radius() + m_cfg.outer_radius())); } else { // Sum up the total length of the modules along r - scalar_t tot_length{0.f}; + scalar_t tot_length{0.}; for (const auto &bounds : m_cfg.module_bounds()) { tot_length += 2.f * bounds[trapezoid2D::e_half_length_2] + 0.5f; } @@ -223,8 +223,8 @@ class endcap_generator final : public surface_factory_interface { // Fill the radii and gaps scalar_t prev_r{m_cfg.inner_radius() + r_overlap}; - scalar_t prev_hl{0.f}; - scalar_t prev_ol{0.f}; + scalar_t prev_hl{0.}; + scalar_t prev_ol{0.}; for (const auto &bounds : m_cfg.module_bounds()) { const scalar_t mod_hlength{ @@ -252,7 +252,7 @@ class endcap_generator final : public surface_factory_interface { // Generate the ring module positions (observe phi stagger) const scalar_t sub_stagger{m_cfg.phi_sub_stagger().size() > 1u ? m_cfg.phi_sub_stagger()[ir] - : 0.f}; + : 0.}; std::vector module_positions = module_positions_ring(rz, radii[ir], m_cfg.phi_stagger()[ir], @@ -278,9 +278,9 @@ class endcap_generator final : public surface_factory_interface { // The rotation matrix of the module const scalar_t mod_phi{vector::phi(mod_position)}; const vector3_t mod_loc_y{math::cos(mod_phi), - math::sin(mod_phi), 0.f}; + math::sin(mod_phi), 0.}; // Take different axis to have the same readout direction - const vector3_t mod_loc_z{0.f, 0.f, + const vector3_t mod_loc_z{0., 0., static_cast(m_cfg.side())}; const vector3_t mod_loc_x{vector::cross(mod_loc_y, mod_loc_z)}; @@ -332,11 +332,11 @@ class endcap_generator final : public surface_factory_interface { for (unsigned int iphi = 0u; iphi < n_phi_bins; ++iphi) { // If we have a phi sub stagger presents - scalar_t rzs{0.f}; + scalar_t rzs{0.}; // Phi stagger affects 0 vs 1, 2 vs 3 ... etc // -> only works if it is a %4 // Phi sub stagger affects 2 vs 4, 1 vs 3 etc. - if (phi_sub_stagger != 0.f && !(n_phi_bins % 4u)) { + if (phi_sub_stagger != 0. && !(n_phi_bins % 4u)) { // switch sides if (!(iphi % 4u)) { rzs = phi_sub_stagger; diff --git a/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp b/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp index d05744f0d5..944667fb01 100644 --- a/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp @@ -60,10 +60,10 @@ class telescope_generator final : public surface_factory_interface { darray boundaries, trajectory_t traj) : m_traj{traj}, m_positions{}, m_boundaries{boundaries} { - scalar_t pos{0.f}; + scalar_t pos{0.}; scalar_t dist{n_surfaces > 1u ? length / static_cast(n_surfaces - 1u) - : 0.f}; + : 0.}; for (std::size_t i = 0u; i < n_surfaces; ++i) { m_positions.push_back(pos); pos += dist; diff --git a/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp b/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp index 15f3b41a5b..7f5f401940 100644 --- a/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp @@ -148,12 +148,12 @@ class wire_layer_generator final detray::dvector cell_centers{}; // Distance between wires in phi const scalar_t delta = 2.f * m_cfg.cell_size() / m_layer_central_rad; - scalar_t phi{0.f}; + scalar_t phi{0.}; while (phi <= 2.f * constant::pi) { const scalar_t x = m_layer_central_rad * math::cos(phi); const scalar_t y = m_layer_central_rad * math::sin(phi); - const scalar_t z = 0.f; + const scalar_t z = 0.; cell_centers.push_back({x, y, z}); phi += delta; @@ -178,7 +178,7 @@ class wire_layer_generator final m_cfg.half_length()); // Build the transform - vector3_t z_axis{0.f, 0.f, 1.f}; + vector3_t z_axis{0., 0., 1.}; const vector3_t r_axis = vector::normalize(cell_center); z_axis = axis_rotation(r_axis, m_cfg.stereo_angle())(z_axis); diff --git a/tests/include/detray/test/utils/inspectors.hpp b/tests/include/detray/test/utils/inspectors.hpp index 44ee4f32ef..e9c5b0ad19 100644 --- a/tests/include/detray/test/utils/inspectors.hpp +++ b/tests/include/detray/test/utils/inspectors.hpp @@ -175,7 +175,7 @@ struct object_tracer { const scalar_t inv_pos{detray::detail::invalid_value()}; typename candidate_record_t::point3_type last_pos = {inv_pos, inv_pos, inv_pos}; - typename candidate_record_t::vector3_type last_dir = {0.f, 0.f, 0.f}; + typename candidate_record_t::vector3_type last_dir = {0., 0., 0.}; /// Inspector interface template > &distances, // New z- and x-axes vector3_t z{vector::normalize(direction)}; - vector3_t x = vector::normalize(vector3_t{0.f, -z[2], z[1]}); + vector3_t x = vector::normalize(vector3_t{0., -z[2], z[1]}); dvector> surfaces; diff --git a/tests/include/detray/test/utils/prefill_detector.hpp b/tests/include/detray/test/utils/prefill_detector.hpp index 61d60ab09a..0006190a5b 100644 --- a/tests/include/detray/test/utils/prefill_detector.hpp +++ b/tests/include/detray/test/utils/prefill_detector.hpp @@ -41,7 +41,7 @@ void prefill_detector(detector_t& d, std::make_unique>(volume_id::e_cylinder); // Volume position - v_builder->add_volume_placement(transform3_t(point3_t{0.f, 0.f, 2.f})); + v_builder->add_volume_placement(transform3_t(point3_t{0., 0., 2.f})); // Build homogeneous material on surfaces inside the voume auto v_mat_builder = @@ -54,7 +54,7 @@ void prefill_detector(detector_t& d, std::make_unique()); rectangle_factory->push_back({surface_id::e_sensitive, - transform3_t(point3_t{0.f, 0.f, 0.f}), + transform3_t(point3_t{0., 0., 0.}), vol_link, std::vector{-3.f, 3.f}}); rectangle_factory->add_material( material_id::e_slab, @@ -65,7 +65,7 @@ void prefill_detector(detector_t& d, std::make_unique()); annulus_factory->push_back( - {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0.f, 0.f}), + {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0., 0.}), vol_link, std::vector{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}}); annulus_factory->add_material( material_id::e_slab, @@ -77,7 +77,7 @@ void prefill_detector(detector_t& d, std::make_unique()); trapezoid_factory->push_back( - {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0.f, 0.f}), + {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0., 0.}), vol_link, std::vector{1.f, 2.f, 3.f, 1.f / 6.f}}); trapezoid_factory->add_material( material_id::e_rod, diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp index 975e808247..5b5a0625dd 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp @@ -127,7 +127,7 @@ class random_track_generator if constexpr (std::is_same_v>) { mom = vector::normalize(mom); } else { - sin_theta = (sin_theta == scalar_t{0.f}) + sin_theta = (sin_theta == scalar_t{0.}) ? std::numeric_limits::epsilon() : sin_theta; mom = (m_cfg.is_pT() ? 1.f / sin_theta : 1.f) * p_mag * diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp index a50110b4cd..bc89166a75 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp @@ -42,7 +42,7 @@ struct random_track_generator_config { /// Range for phi [-pi, pi) and theta [0, pi) darray m_phi_range{-constant::pi, constant::pi}; - darray m_theta_range{0.f, constant::pi}; + darray m_theta_range{0., constant::pi}; /// Momentum range darray m_mom_range{1.f * unit::GeV, @@ -51,14 +51,14 @@ struct random_track_generator_config { bool m_is_pT{false}; /// Track origin - darray m_origin{0.f, 0.f, 0.f}; - darray m_origin_stddev{0.f, 0.f, 0.f}; + darray m_origin{0., 0., 0.}; + darray m_origin_stddev{0., 0., 0.}; /// Randomly flip the charge sign? bool m_randomize_charge{false}; /// Time parameter and charge of the track - scalar_t m_time{0.f * unit::us}; + scalar_t m_time{0. * unit::us}; scalar_t m_charge{-1.f * unit::e}; /// Setters @@ -97,8 +97,8 @@ struct random_track_generator_config { } DETRAY_HOST_DEVICE random_track_generator_config& theta_range( scalar_t low, scalar_t high) { - auto min_theta{std::clamp(low, scalar_t{0.f}, constant::pi)}; - auto max_theta{std::clamp(high, scalar_t{0.f}, constant::pi)}; + auto min_theta{std::clamp(low, scalar_t{0.}, constant::pi)}; + auto max_theta{std::clamp(high, scalar_t{0.}, constant::pi)}; assert(min_theta <= max_theta); @@ -137,7 +137,7 @@ struct random_track_generator_config { DETRAY_HOST_DEVICE random_track_generator_config& mom_range(scalar_t low, scalar_t high) { m_is_pT = false; - assert(low >= 0.f); + assert(low >= 0.); assert(low <= high); m_mom_range = {low, high}; return *this; @@ -151,7 +151,7 @@ struct random_track_generator_config { DETRAY_HOST_DEVICE random_track_generator_config& pT_range(scalar_t low, scalar_t high) { m_is_pT = true; - assert(low >= 0.f); + assert(low >= 0.); assert(low <= high); m_mom_range = {low, high}; return *this; @@ -198,7 +198,7 @@ struct random_track_generator_config { return *this; } DETRAY_HOST_DEVICE random_track_generator_config& time(scalar_t t) { - assert(t >= 0.f); + assert(t >= 0.); m_time = t; return *this; } diff --git a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp index 8464f832e1..3906c83c6d 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp @@ -158,7 +158,7 @@ class uniform_track_generator if constexpr (std::is_same_v>) { p = vector::normalize(p); } else { - sin_theta = (sin_theta == scalar_t{0.f}) + sin_theta = (sin_theta == scalar_t{0.}) ? std::numeric_limits::epsilon() : sin_theta; p = (m_cfg.is_pT() ? 1.f / sin_theta : 1.f) * m_cfg.m_p_mag * @@ -186,13 +186,13 @@ class uniform_track_generator configuration m_cfg{}; /// Angular step sizes - scalar_t m_phi_step_size{0.f}; - scalar_t m_theta_step_size{0.f}; - scalar_t m_eta_step_size{0.f}; + scalar_t m_phi_step_size{0.}; + scalar_t m_theta_step_size{0.}; + scalar_t m_eta_step_size{0.}; /// Phi and theta angles of momentum direction scalar_t m_phi{-constant::pi}; - scalar_t m_theta{0.f}; + scalar_t m_theta{0.}; /// Iteration indices std::size_t i_phi{0u}; diff --git a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp index 97e6431eb8..b15f0ddbe4 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp @@ -37,7 +37,7 @@ struct uniform_track_generator_config { /// Range for phi [-pi, pi) and theta [0, pi) darray m_phi_range{-constant::pi, k_max_pi}; - darray m_theta_range{0.f, k_max_pi}; + darray m_theta_range{0., k_max_pi}; darray m_eta_range{-5.f, 5.f}; /// Angular step size @@ -49,7 +49,7 @@ struct uniform_track_generator_config { bool m_uniform_eta{false}; /// Track origin - darray m_origin{0.f, 0.f, 0.f}; + darray m_origin{0., 0., 0.}; /// Magnitude of momentum: Default is one to keep directions normalized /// if no momentum information is needed (e.g. for a ray) @@ -61,7 +61,7 @@ struct uniform_track_generator_config { bool m_randomize_charge{false}; /// Time parameter and charge of the track - scalar_t m_time{0.f * unit::us}; + scalar_t m_time{0. * unit::us}; scalar_t m_charge{-1.f * unit::e}; /// Setters @@ -88,8 +88,8 @@ struct uniform_track_generator_config { } DETRAY_HOST_DEVICE uniform_track_generator_config& theta_range( scalar_t low, scalar_t high) { - auto min_theta{std::clamp(low, scalar_t{0.f}, k_max_pi)}; - auto max_theta{std::clamp(high, scalar_t{0.f}, k_max_pi)}; + auto min_theta{std::clamp(low, scalar_t{0.}, k_max_pi)}; + auto max_theta{std::clamp(high, scalar_t{0.}, k_max_pi)}; assert(min_theta <= max_theta); @@ -158,13 +158,13 @@ struct uniform_track_generator_config { return origin(ori[0], ori[1], ori[2]); } DETRAY_HOST_DEVICE uniform_track_generator_config& p_tot(scalar_t p) { - assert(p > 0.f); + assert(p > 0.); m_is_pT = false; m_p_mag = p; return *this; } DETRAY_HOST_DEVICE uniform_track_generator_config& p_T(scalar_t p) { - assert(p > 0.f); + assert(p > 0.); m_is_pT = true; m_p_mag = p; return *this; diff --git a/tests/include/detray/test/utils/simulation/random_scatterer.hpp b/tests/include/detray/test/utils/simulation/random_scatterer.hpp index 710eb2b821..04ac294bed 100644 --- a/tests/include/detray/test/utils/simulation/random_scatterer.hpp +++ b/tests/include/detray/test/utils/simulation/random_scatterer.hpp @@ -44,13 +44,13 @@ struct random_scatterer : actor { std::mt19937_64 generator{rd()}; /// most probable energy loss - scalar_type e_loss_mpv = 0.f; + scalar_type e_loss_mpv = 0.; /// energy loss sigma - scalar_type e_loss_sigma = 0.f; + scalar_type e_loss_sigma = 0.; /// projected scattering angle - scalar_type projected_scattering_angle = 0.f; + scalar_type projected_scattering_angle = 0.; // Simulation setup bool do_energy_loss = true; diff --git a/tests/include/detray/test/utils/simulation/scattering_helper.hpp b/tests/include/detray/test/utils/simulation/scattering_helper.hpp index e75aa63673..820a74a779 100644 --- a/tests/include/detray/test/utils/simulation/scattering_helper.hpp +++ b/tests/include/detray/test/utils/simulation/scattering_helper.hpp @@ -39,8 +39,8 @@ struct scattering_helper { // Generate theta and phi for random scattering const scalar_type r_theta{ angle == scalar_type{0} - ? 0.f - : std::normal_distribution(0.f, angle)(generator)}; + ? 0. + : std::normal_distribution(0., angle)(generator)}; const scalar_type r_phi{std::uniform_real_distribution( -constant::pi, constant::pi)(generator)}; diff --git a/tests/include/detray/test/utils/statistics.hpp b/tests/include/detray/test/utils/statistics.hpp index 4da9496f1f..b6c405c852 100644 --- a/tests/include/detray/test/utils/statistics.hpp +++ b/tests/include/detray/test/utils/statistics.hpp @@ -61,7 +61,7 @@ inline auto variance(const range_t& r) noexcept(false) // Variance is zero for single element if (r.size() == 1u) { - return 0.f; + return 0.; } value_t mean = statistics::mean(r); diff --git a/tests/include/detray/test/utils/types.hpp b/tests/include/detray/test/utils/types.hpp index ad5d2fe1e7..0210685b4b 100644 --- a/tests/include/detray/test/utils/types.hpp +++ b/tests/include/detray/test/utils/types.hpp @@ -33,6 +33,10 @@ static constexpr char filenames[] = "smatrix-"; #elif DETRAY_ALGEBRA_VC_AOS using algebra = detray::vc_aos; static constexpr char filenames[] = "vc_aos-"; + +#elif DETRAY_ALGEBRA_FASTOR +using algebra = detray::fastor; +static constexpr char filenames[] = "fastor-"; #endif // Test algebra types diff --git a/tests/include/detray/test/validation/detector_scanner.hpp b/tests/include/detray/test/validation/detector_scanner.hpp index 63f68b3c95..0c56175daf 100644 --- a/tests/include/detray/test/validation/detector_scanner.hpp +++ b/tests/include/detray/test/validation/detector_scanner.hpp @@ -62,7 +62,7 @@ struct brute_force_scan { inline auto operator()(const typename detector_t::geometry_context ctx, const detector_t &detector, const trajectory_t &traj, const darray - mask_tolerance = {0.f, 0.f}, + mask_tolerance = {0., 0.}, const typename detector_t::scalar_type p = 1.f * unit::GeV) { @@ -79,7 +79,7 @@ struct brute_force_scan { const auto &trf_store = detector.transform_store(); - assert(p > 0.f); + assert(p > 0.); const scalar_t q{p * traj.qop()}; std::vector intersections{}; @@ -91,7 +91,7 @@ struct brute_force_scan { const auto sf = tracking_surface{detector, sf_desc}; sf.template visit_mask( intersections, traj, sf_desc, trf_store, ctx, - sf.is_portal() ? darray{0.f, 0.f} + sf.is_portal() ? darray{0., 0.} : mask_tolerance); // Candidate is invalid if it lies in the opposite direction @@ -101,7 +101,7 @@ struct brute_force_scan { // Record the intersection intersection_trace.push_back( {q, - {traj.pos(sfi.path), 0.f, p * traj.dir(sfi.path), q}, + {traj.pos(sfi.path), 0., p * traj.dir(sfi.path), q}, sf.volume(), sfi}); } @@ -123,15 +123,15 @@ struct brute_force_scan { start_intersection.sf_desc.set_index(dindex_invalid); start_intersection.sf_desc.material().set_id( detector_t::materials::id::e_none); - start_intersection.path = 0.f; - start_intersection.local = {0.f, 0.f, 0.f}; + start_intersection.path = 0.; + start_intersection.local = {0., 0., 0.}; start_intersection.volume_link = static_cast(first_record.vol_idx); intersection_trace.insert(intersection_trace.begin(), intersection_record{ q, - {traj.pos(), 0.f, p * traj.dir(), q}, + {traj.pos(), 0., p * traj.dir(), q}, first_record.vol_idx, start_intersection}); diff --git a/tests/include/detray/test/validation/material_validation_utils.hpp b/tests/include/detray/test/validation/material_validation_utils.hpp index 8b93d62ca0..3e6c7723a6 100644 --- a/tests/include/detray/test/validation/material_validation_utils.hpp +++ b/tests/include/detray/test/validation/material_validation_utils.hpp @@ -35,13 +35,13 @@ struct material_record { scalar_t eta{detail::invalid_value()}; /// @} /// Accumulated radiation length per pathlength through the material - scalar_t sX0{0.f}; + scalar_t sX0{0.}; /// Accumulated radiation length per thickness - scalar_t tX0{0.f}; + scalar_t tX0{0.}; /// Accumulated interaction length per pathlength through the material - scalar_t sL0{0.f}; + scalar_t sL0{0.}; /// Accumulated interaction length per thickness - scalar_t tL0{0.f}; + scalar_t tL0{0.}; }; /// @brief Return type that contains the material parameters and the pathlength @@ -52,9 +52,9 @@ struct material_params { /// Material thickness/radius scalar_t thickness{detail::invalid_value()}; /// Radiation length - scalar_t mat_X0{0.f}; + scalar_t mat_X0{0.}; /// Interaction length - scalar_t mat_L0{0.f}; + scalar_t mat_L0{0.}; }; /// @brief Functor to retrieve the material parameters for a given local @@ -84,7 +84,7 @@ struct get_material_params { if (!mat) { // Set the pathlength and thickness to zero so that they // are not counted - return material_params{0.f, 0.f, inv, inv}; + return material_params{0., 0., inv, inv}; } const scalar_t seg{mat.path_segment(cos_inc_angle, loc[0])}; @@ -204,13 +204,13 @@ struct material_tracer : detray::actor { const scalar_t ml0{mat_params.mat_L0}; // Fill the material record - if (mx0 > 0.f) { + if (mx0 > 0.) { tracer.m_mat_record.sX0 += seg / mx0; tracer.m_mat_record.tX0 += t / mx0; tracer.m_mat_steps.push_back({seg, t, mx0, ml0}); } - if (ml0 > 0.f) { + if (ml0 > 0.) { tracer.m_mat_record.sL0 += seg / ml0; tracer.m_mat_record.tL0 += t / ml0; diff --git a/tests/include/detray/test/validation/navigation_validation_utils.hpp b/tests/include/detray/test/validation/navigation_validation_utils.hpp index 541e2b484f..306790cd97 100644 --- a/tests/include/detray/test/validation/navigation_validation_utils.hpp +++ b/tests/include/detray/test/validation/navigation_validation_utils.hpp @@ -642,7 +642,7 @@ auto write_tracks(const std::string &track_param_file_name, for (const auto &record : trace) { track_params.back().emplace_back( record.charge, - track_param_t{record.pos, 0.f, record.dir, record.charge}); + track_param_t{record.pos, 0., record.dir, record.charge}); } } @@ -686,7 +686,7 @@ auto write_dist_to_boundary( << "," << vector::phi(glob_pos) << ", " << vector::eta(glob_pos) << "," << missed_sfi.path << ", " << dist << ", " << std::boolalpha - << sf.is_inside(missed_sfi.local, 0.f) << ", " + << sf.is_inside(missed_sfi.local, 0.) << ", " << static_cast(sf.shape_id()) << std::endl; } } diff --git a/tests/include/detray/test/validation/step_tracer.hpp b/tests/include/detray/test/validation/step_tracer.hpp index cf1568f084..032af8cd1c 100644 --- a/tests/include/detray/test/validation/step_tracer.hpp +++ b/tests/include/detray/test/validation/step_tracer.hpp @@ -24,8 +24,8 @@ struct step_data { using track_param_type = free_track_parameters; using free_matrix_type = free_matrix; - scalar_type step_size{0.f}; - scalar_type path_length{0.f}; + scalar_type step_size{0.}; + scalar_type path_length{0.}; std::size_t n_total_trials{0u}; navigation::direction nav_dir = navigation::direction::e_forward; geometry::barcode barcode{}; diff --git a/tests/include/detray/test/validation/svg_display.hpp b/tests/include/detray/test/validation/svg_display.hpp index a6fb8c5ffe..840f861a49 100644 --- a/tests/include/detray/test/validation/svg_display.hpp +++ b/tests/include/detray/test/validation/svg_display.hpp @@ -127,7 +127,7 @@ auto draw_intersection_and_traj_svg( // Draw the truth intersections auto svg_traj = il.draw_intersections("truth_trace", truth_intersections, - traj.dir(0.f), view, gctx); + traj.dir(0.), view, gctx); // Draw an approximation of the trajectory with the recorded intersections if (!recorded_intersections.empty()) { From e779d0081436c0ee53b1fed7e07896d2bdbfe7a1 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Tue, 25 Mar 2025 22:15:13 +0530 Subject: [PATCH 06/11] Removed some unnecessary comments. --- .../plugins/algebra/fastor_definitions.hpp | 36 +------------------ 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp b/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp index 4049952e00..fee27727b6 100644 --- a/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp +++ b/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp @@ -1,40 +1,6 @@ -// /** Detray library, part of the ACTS project (R&D line) -// * -// * (c) 2023 CERN for the benefit of the ACTS project -// * -// * Mozilla Public License Version 2.0 -// */ - -// #pragma once - -// // Algebra-Plugins include -// #include "algebra/fastor_fastor.hpp" - -// #define __plugin algebra::fastor -// #define ALGEBRA_PLUGIN fastor - -// namespace detray { - -// // Define scalar type -// using scalar = DETRAY_CUSTOM_SCALARTYPE; - -// // Define namespace(s) -// namespace getter = algebra::getter; -// namespace vector = algebra::vector; -// namespace matrix = algebra::matrix; - -// // Define matrix/vector operator -// template -// using standard_matrix_operator = -// matrix::actor, -// matrix::inverse::preset0>; - -// } // namespace detray - - /** Detray library, part of the ACTS project (R&D line) * - * (c) 2025 CERN for the benefit of the ACTS project + * (c) 2023-2025 CERN for the benefit of the ACTS project * * Mozilla Public License Version 2.0 */ From b54ecf98cb5e6b5780b73a9c52bfa9292015ce43 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Tue, 25 Mar 2025 22:18:00 +0530 Subject: [PATCH 07/11] Formatted the files. --- .../detray/builders/detector_builder.hpp | 2 +- .../detray/geometry/shapes/annulus2D.hpp | 26 +++-- .../detray/geometry/shapes/cuboid3D.hpp | 4 +- .../detray/geometry/shapes/trapezoid2D.hpp | 3 +- .../detail/relativistic_quantities.hpp | 8 +- .../include/detray/materials/material_rod.hpp | 2 +- .../detray/materials/predefined_materials.hpp | 19 ++-- .../intersection/helix_line_intersector.hpp | 4 +- .../intersection/helix_plane_intersector.hpp | 7 +- core/include/detray/navigation/navigator.hpp | 8 +- .../actors/pointwise_material_interactor.hpp | 2 +- .../detray/propagator/base_stepper.hpp | 2 +- .../detail/jacobian_cylindrical.hpp | 3 +- .../propagator/detail/jacobian_line.hpp | 3 +- core/include/detray/propagator/rk_stepper.ipp | 10 +- .../detray/utils/quadratic_equation.hpp | 3 +- .../plugins/algebra/fastor_definitions.hpp | 95 +++++++++---------- .../device/cuda/navigation_validation.hpp | 5 +- .../utils/detectors/build_toy_detector.hpp | 3 +- .../detray/test/utils/prefill_detector.hpp | 12 +-- .../test/validation/detector_scanner.hpp | 29 +++--- 21 files changed, 118 insertions(+), 132 deletions(-) diff --git a/core/include/detray/builders/detector_builder.hpp b/core/include/detray/builders/detector_builder.hpp index 6e1e4773a6..905f5b669f 100644 --- a/core/include/detray/builders/detector_builder.hpp +++ b/core/include/detray/builders/detector_builder.hpp @@ -123,7 +123,7 @@ class detector_builder { // TODO: Construct it correctly with the grid builder mask vgrid_dims{ - 0u, 0., -constant::pi, + 0u, 0., -constant::pi, -2000., 180., constant::pi, 2000.}; darray n_vgrid_bins{1u, 1u, 1u}; diff --git a/core/include/detray/geometry/shapes/annulus2D.hpp b/core/include/detray/geometry/shapes/annulus2D.hpp index 247bae27d3..4a75793380 100644 --- a/core/include/detray/geometry/shapes/annulus2D.hpp +++ b/core/include/detray/geometry/shapes/annulus2D.hpp @@ -375,20 +375,18 @@ class annulus2D { // scalar_t m = math::tan(phi); point2_t dir = {math::cos(phi), math::sin(phi)}; - scalar_t x1 = - (O_x + O_y * m - - math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + - 2. * O_x * O_y * m - math::pow(O_y, 2.) + - math::pow(m, 2.) * math::pow(r, 2.) + - math::pow(r, 2.))) / - (math::pow(m, 2.) + 1.); - scalar_t x2 = - (O_x + O_y * m + - math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + - 2. * O_x * O_y * m - math::pow(O_y, 2.) + - math::pow(m, 2.) * math::pow(r, 2.) + - math::pow(r, 2.))) / - (math::pow(m, 2.) + 1.); + scalar_t x1 = (O_x + O_y * m - + math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + + 2. * O_x * O_y * m - math::pow(O_y, 2.) + + math::pow(m, 2.) * math::pow(r, 2.) + + math::pow(r, 2.))) / + (math::pow(m, 2.) + 1.); + scalar_t x2 = (O_x + O_y * m + + math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + + 2. * O_x * O_y * m - math::pow(O_y, 2.) + + math::pow(m, 2.) * math::pow(r, 2.) + + math::pow(r, 2.))) / + (math::pow(m, 2.) + 1.); point2_t v1 = {x1, m * x1}; if (vector::dot(v1, dir) > 0.) diff --git a/core/include/detray/geometry/shapes/cuboid3D.hpp b/core/include/detray/geometry/shapes/cuboid3D.hpp index d01a0870ba..193b082105 100644 --- a/core/include/detray/geometry/shapes/cuboid3D.hpp +++ b/core/include/detray/geometry/shapes/cuboid3D.hpp @@ -157,8 +157,8 @@ class cuboid3D { const bounds_type> &bounds) const { return 0.5 * dpoint3D{bounds[e_min_x] + bounds[e_max_x], - bounds[e_min_y] + bounds[e_max_y], - bounds[e_min_z] + bounds[e_max_z]}; + bounds[e_min_y] + bounds[e_max_y], + bounds[e_min_z] + bounds[e_max_z]}; } /// Generate vertices in local cartesian frame diff --git a/core/include/detray/geometry/shapes/trapezoid2D.hpp b/core/include/detray/geometry/shapes/trapezoid2D.hpp index 6b51357689..2e319373ec 100644 --- a/core/include/detray/geometry/shapes/trapezoid2D.hpp +++ b/core/include/detray/geometry/shapes/trapezoid2D.hpp @@ -165,8 +165,7 @@ class trapezoid2D { const scalar_t a_2{bounds[e_half_length_1]}; const scalar_t b_2{bounds[e_half_length_0]}; - const scalar_t y{2. * h_2 * (2. * a_2 + b_2) * 1. / - (3. * (a_2 + b_2))}; + const scalar_t y{2. * h_2 * (2. * a_2 + b_2) * 1. / (3. * (a_2 + b_2))}; return {0., y - h_2, 0.}; } diff --git a/core/include/detray/materials/detail/relativistic_quantities.hpp b/core/include/detray/materials/detail/relativistic_quantities.hpp index 3e5900da28..6e615cecbf 100644 --- a/core/include/detray/materials/detail/relativistic_quantities.hpp +++ b/core/include/detray/materials/detail/relativistic_quantities.hpp @@ -77,9 +77,8 @@ struct relativistic_quantities { const scalar_type mfrac{constant::m_e / mass}; // Wmax = 2m_e c^2 beta^2 gamma^2 / (1+2gamma*m_e/M + (m_e/M)^2) - m_Wmax = - (2. * constant::m_e * m_betaGamma * m_betaGamma) / - (1. + 2. * m_gamma * mfrac + mfrac * mfrac); + m_Wmax = (2. * constant::m_e * m_betaGamma * m_betaGamma) / + (1. + 2. * m_gamma * mfrac + mfrac * mfrac); } /// @return 2 * mass * (beta * gamma)² mass term. @@ -121,8 +120,7 @@ struct relativistic_quantities { DETRAY_HOST_DEVICE scalar_type derive_bethe_bloch_log_term() const { assert(m_gamma != 0.); assert(m_E != 0.); - const scalar_type dAdqop = - -1. / (2. * m_qOverP) * (4. - m_Wmax / m_E); + const scalar_type dAdqop = -1. / (2. * m_qOverP) * (4. - m_Wmax / m_E); return dAdqop; } diff --git a/core/include/detray/materials/material_rod.hpp b/core/include/detray/materials/material_rod.hpp index dbb2bad9cf..188d396439 100644 --- a/core/include/detray/materials/material_rod.hpp +++ b/core/include/detray/materials/material_rod.hpp @@ -79,7 +79,7 @@ struct material_rod { const scalar_type sin_inc_angle_2{1. - cos_inc_angle * cos_inc_angle}; return 2. * math::sqrt((m_radius * m_radius - approach * approach) / - sin_inc_angle_2); + sin_inc_angle_2); } /// @returns the path segment through the material in X0 diff --git a/core/include/detray/materials/predefined_materials.hpp b/core/include/detray/materials/predefined_materials.hpp index ecff665afd..5c1a316e36 100644 --- a/core/include/detray/materials/predefined_materials.hpp +++ b/core/include/detray/materials/predefined_materials.hpp @@ -68,16 +68,14 @@ DETRAY_DECLARE_MATERIAL(carbon_gas, 213.5 * unit::mm, // N₂ (7): Nitrogen Gas DETRAY_DECLARE_MATERIAL(nitrogen_gas, 3.260E+02 * unit::m, - 7.696E+02 * unit::m, 2. * 14.007, - 2. * 7., + 7.696E+02 * unit::m, 2. * 14.007, 2. * 7., static_cast(1.165E-03 * unit::g / unit::cm3), material_state::e_gas); // O₂ (8): Oxygen Gas DETRAY_DECLARE_MATERIAL(oxygen_gas, 2.571E+02 * unit::m, - 6.772E+02 * unit::m, 2. * 15.999, - 2. * 8., + 6.772E+02 * unit::m, 2. * 15.999, 2. * 8., static_cast(1.332E-3 * unit::g / unit::cm3), material_state::e_gas); @@ -232,11 +230,12 @@ DETRAY_DECLARE_MATERIAL(cesium_iodide, 1.86 * unit::cm, unit::cm3), material_state::e_solid); -DETRAY_DECLARE_MATERIAL_WITH_DED( - cesium_iodide_with_ded, 1.86 * unit::cm, - 38.04 * unit::cm, 259.81, 108., - static_cast(4.510 * unit::g / unit::cm3), - material_state::e_solid, 0.25381, 2.6657, 0.0395, 3.3353, 553.1, - 6.2807, 0.00); +DETRAY_DECLARE_MATERIAL_WITH_DED(cesium_iodide_with_ded, + 1.86 * unit::cm, + 38.04 * unit::cm, 259.81, 108., + static_cast(4.510 * unit::g / + unit::cm3), + material_state::e_solid, 0.25381, 2.6657, + 0.0395, 3.3353, 553.1, 6.2807, 0.00); } // namespace detray diff --git a/core/include/detray/navigation/intersection/helix_line_intersector.hpp b/core/include/detray/navigation/intersection/helix_line_intersector.hpp index da557504d1..3c016972fb 100644 --- a/core/include/detray/navigation/intersection/helix_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_line_intersector.hpp @@ -160,8 +160,8 @@ struct helix_intersector_impl, algebra_t> { scalar_type tol{mask_tolerance[1]}; if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 - const scalar_type sin_inc2{math::fabs( - 1. - cos_incidence_angle * cos_incidence_angle)}; + const scalar_type sin_inc2{ + math::fabs(1. - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } diff --git a/core/include/detray/navigation/intersection/helix_plane_intersector.hpp b/core/include/detray/navigation/intersection/helix_plane_intersector.hpp index 7b4412c770..e233a4fb52 100644 --- a/core/include/detray/navigation/intersection/helix_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_plane_intersector.hpp @@ -121,8 +121,8 @@ struct helix_intersector_impl, algebra_t> { scalar_type tol{mask_tolerance[1]}; if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 - const scalar_type sin_inc2{math::fabs( - 1. - cos_incidence_angle * cos_incidence_angle)}; + const scalar_type sin_inc2{ + math::fabs(1. - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -141,8 +141,7 @@ struct helix_intersector_impl, algebra_t> { // Starting point on the helix for the Newton iteration const vector3_type dist{trf.point_to_global(mask.centroid()) - h.pos(0.)}; - scalar_type denom{ - vector::dot(sn, h.dir(0.5 * vector::norm(dist)))}; + scalar_type denom{vector::dot(sn, h.dir(0.5 * vector::norm(dist)))}; scalar_type s_ini; if (denom == 0.) { s_ini = vector::norm(dist); diff --git a/core/include/detray/navigation/navigator.hpp b/core/include/detray/navigation/navigator.hpp index 52bc91a31f..9c9d9f5d92 100644 --- a/core/include/detray/navigation/navigator.hpp +++ b/core/include/detray/navigation/navigator.hpp @@ -397,8 +397,8 @@ class navigator { m_heartbeat = false; // Don't do anything if aborted m_trust_level = navigation::trust_level::e_full; - run_inspector({}, point3_type{0., 0., 0.}, - vector3_type{0., 0., 0.}, "Aborted: "); + run_inspector({}, point3_type{0., 0., 0.}, vector3_type{0., 0., 0.}, + "Aborted: "); return m_heartbeat; } @@ -411,8 +411,8 @@ class navigator { m_status = navigation::status::e_on_target; m_heartbeat = false; m_trust_level = navigation::trust_level::e_full; - run_inspector({}, point3_type{0., 0., 0.}, - vector3_type{0., 0., 0.}, "Exited: "); + run_inspector({}, point3_type{0., 0., 0.}, vector3_type{0., 0., 0.}, + "Exited: "); this->clear(); return m_heartbeat; } diff --git a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp index 3c8ae35fff..16c090fa53 100644 --- a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp +++ b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp @@ -251,7 +251,7 @@ struct pointwise_material_interactor : actor { getter::element(covariance, e_bound_phi, e_bound_phi) += (dir[2] == 1.) ? inv - : var_scattering_angle / (1. - dir[2] * dir[2]); + : var_scattering_angle / (1. - dir[2] * dir[2]); getter::element(covariance, e_bound_theta, e_bound_theta) += var_scattering_angle; diff --git a/core/include/detray/propagator/base_stepper.hpp b/core/include/detray/propagator/base_stepper.hpp index fe1a1781c0..3b6da62431 100644 --- a/core/include/detray/propagator/base_stepper.hpp +++ b/core/include/detray/propagator/base_stepper.hpp @@ -113,7 +113,7 @@ class base_stepper { DETRAY_HOST_DEVICE inline step::direction direction() const { return m_step_size >= 0. ? step::direction::e_forward - : step::direction::e_backward; + : step::direction::e_backward; } /// Updates the total number of step trials diff --git a/core/include/detray/propagator/detail/jacobian_cylindrical.hpp b/core/include/detray/propagator/detail/jacobian_cylindrical.hpp index 5c8737f16e..9c7be11762 100644 --- a/core/include/detray/propagator/detail/jacobian_cylindrical.hpp +++ b/core/include/detray/propagator/detail/jacobian_cylindrical.hpp @@ -79,8 +79,7 @@ struct jacobian> { coordinate_frame::global_to_local_3D(trf3, pos, dir); const vector3_type normal = coordinate_frame::normal(trf3, local); - const vector3_type pos_term = - (-1. / vector::dot(normal, dir)) * normal; + const vector3_type pos_term = (-1. / vector::dot(normal, dir)) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; diff --git a/core/include/detray/propagator/detail/jacobian_line.hpp b/core/include/detray/propagator/detail/jacobian_line.hpp index 8dba2a7a0a..b1b188914d 100644 --- a/core/include/detray/propagator/detail/jacobian_line.hpp +++ b/core/include/detray/propagator/detail/jacobian_line.hpp @@ -90,8 +90,7 @@ struct jacobian> { // Local x axis component of pc: const vector3_type pc_x = pc - pz * local_zaxis; - const scalar_type norm = - -1. / (1. - dz * dz + vector::dot(pc_x, dtds)); + const scalar_type norm = -1. / (1. - dz * dz + vector::dot(pc_x, dtds)); const vector3_type pos_term = norm * (dir - dz * local_zaxis); const vector3_type dir_term = norm * pc_x; diff --git a/core/include/detray/propagator/rk_stepper.ipp b/core/include/detray/propagator/rk_stepper.ipp index 7b5fbf09cd..ca16a5db1c 100644 --- a/core/include/detray/propagator/rk_stepper.ipp +++ b/core/include/detray/propagator/rk_stepper.ipp @@ -214,7 +214,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< getter::element(D, e_free_qoverp, e_free_qoverp) = 1. + h_6 * (d2qop1dsdqop1 + 2. * (d2qop2dsdqop1 + d2qop3dsdqop1) + - d2qop4dsdqop1); + d2qop4dsdqop1); } /*----------------------------------------------------------------- @@ -299,10 +299,10 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // dk4/dr1 dkndr[3u] = sd.qop[3u] * mat_helper().column_wise_cross(h * dkndr[2u], sd.b_last); - dkndr[3u] = dkndr[3u] - - sd.qop[3u] * - mat_helper().column_wise_cross( - dBdr_fin * (I33 + h2 * 0.5 * dkndr[2u]), sd.t[3u]); + dkndr[3u] = + dkndr[3u] - + sd.qop[3u] * mat_helper().column_wise_cross( + dBdr_fin * (I33 + h2 * 0.5 * dkndr[2u]), sd.t[3u]); // Set dF/dr1 and dG/dr1 auto dFdr = matrix::identity>(); diff --git a/core/include/detray/utils/quadratic_equation.hpp b/core/include/detray/utils/quadratic_equation.hpp index c719f70bac..f605aa2eb3 100644 --- a/core/include/detray/utils/quadratic_equation.hpp +++ b/core/include/detray/utils/quadratic_equation.hpp @@ -55,8 +55,7 @@ requires std::is_arithmetic_v class quadratic_equation { if (discriminant > tolerance) { m_solutions = 2; const scalar_t q{ - -0.5 * - (b + detail::copysign(math::sqrt(discriminant), b))}; + -0.5 * (b + detail::copysign(math::sqrt(discriminant), b))}; m_values = {q / a, c / q}; // Sort the two solutions if (m_values[0] > m_values[1]) { diff --git a/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp b/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp index fee27727b6..a891707715 100644 --- a/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp +++ b/plugins/algebra/fastor/include/detray/plugins/algebra/fastor_definitions.hpp @@ -5,51 +5,50 @@ * Mozilla Public License Version 2.0 */ - #pragma once - - // Algebra-Plugins include - #include "algebra/fastor_fastor.hpp" - - namespace detray { - - /// The plugin definition - template - using fastor = algebra::plugin::fastor; - - namespace getter { - - using algebra::fastor::storage::block; - using algebra::fastor::storage::element; - using algebra::fastor::storage::set_block; - using algebra::fastor::storage::vector; - - } // namespace getter - - namespace vector { - - using algebra::fastor::math::cross; - using algebra::fastor::math::dot; - using algebra::fastor::math::eta; - using algebra::fastor::math::norm; - using algebra::fastor::math::normalize; - - using algebra::fastor::math::perp; - using algebra::fastor::math::phi; - using algebra::fastor::math::theta; - - } // namespace vector - - namespace matrix { - - using algebra::fastor::math::determinant; - using algebra::fastor::math::identity; - using algebra::fastor::math::inverse; - using algebra::fastor::math::set_identity; - using algebra::fastor::math::set_zero; - using algebra::fastor::math::transpose; - using algebra::fastor::math::zero; - - } // namespace matrix - - } // namespace detray - +#pragma once + +// Algebra-Plugins include +#include "algebra/fastor_fastor.hpp" + +namespace detray { + +/// The plugin definition +template +using fastor = algebra::plugin::fastor; + +namespace getter { + +using algebra::fastor::storage::block; +using algebra::fastor::storage::element; +using algebra::fastor::storage::set_block; +using algebra::fastor::storage::vector; + +} // namespace getter + +namespace vector { + +using algebra::fastor::math::cross; +using algebra::fastor::math::dot; +using algebra::fastor::math::eta; +using algebra::fastor::math::norm; +using algebra::fastor::math::normalize; + +using algebra::fastor::math::perp; +using algebra::fastor::math::phi; +using algebra::fastor::math::theta; + +} // namespace vector + +namespace matrix { + +using algebra::fastor::math::determinant; +using algebra::fastor::math::identity; +using algebra::fastor::math::inverse; +using algebra::fastor::math::set_identity; +using algebra::fastor::math::set_zero; +using algebra::fastor::math::transpose; +using algebra::fastor::math::zero; + +} // namespace matrix + +} // namespace detray diff --git a/tests/include/detray/test/device/cuda/navigation_validation.hpp b/tests/include/detray/test/device/cuda/navigation_validation.hpp index 11f106686e..85abd5048f 100644 --- a/tests/include/detray/test/device/cuda/navigation_validation.hpp +++ b/tests/include/detray/test/device/cuda/navigation_validation.hpp @@ -295,9 +295,8 @@ class navigation_validation : public test::fixture_base<> { const scalar q = start.charge; const scalar pT{q == 0. ? 1.f * unit::GeV - : trck_param.pT(q)}; - const scalar p{q == 0. ? 1.f * unit::GeV - : trck_param.p(q)}; + : trck_param.pT(q)}; + const scalar p{q == 0. ? 1.f * unit::GeV : trck_param.p(q)}; if (detray::detail::is_invalid_value(m_cfg.p_range()[0])) { min_pT = std::min(min_pT, pT); diff --git a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp index 8314de244d..e0ca256f39 100644 --- a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp +++ b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp @@ -863,8 +863,7 @@ inline auto add_endcap_detector( std::min(std::abs(vol_bounds.upper_z), std::abs(vol_bounds.lower_z))}; - const point3_t gap_center{0., 0., - 0.5f * (gap_east_z + gap_west_z)}; + const point3_t gap_center{0., 0., 0.5f * (gap_east_z + gap_west_z)}; vm_builder->add_volume_placement({gap_center}); detail::add_cylinder_portals( diff --git a/tests/include/detray/test/utils/prefill_detector.hpp b/tests/include/detray/test/utils/prefill_detector.hpp index 0006190a5b..212b3a8368 100644 --- a/tests/include/detray/test/utils/prefill_detector.hpp +++ b/tests/include/detray/test/utils/prefill_detector.hpp @@ -54,8 +54,8 @@ void prefill_detector(detector_t& d, std::make_unique()); rectangle_factory->push_back({surface_id::e_sensitive, - transform3_t(point3_t{0., 0., 0.}), - vol_link, std::vector{-3.f, 3.f}}); + transform3_t(point3_t{0., 0., 0.}), vol_link, + std::vector{-3.f, 3.f}}); rectangle_factory->add_material( material_id::e_slab, {3.f * unit::mm, detray::gold()}); @@ -65,8 +65,8 @@ void prefill_detector(detector_t& d, std::make_unique()); annulus_factory->push_back( - {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0., 0.}), - vol_link, std::vector{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}}); + {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0., 0.}), vol_link, + std::vector{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}}); annulus_factory->add_material( material_id::e_slab, {12.f * unit::mm, detray::tungsten()}); @@ -77,8 +77,8 @@ void prefill_detector(detector_t& d, std::make_unique()); trapezoid_factory->push_back( - {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0., 0.}), - vol_link, std::vector{1.f, 2.f, 3.f, 1.f / 6.f}}); + {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0., 0.}), vol_link, + std::vector{1.f, 2.f, 3.f, 1.f / 6.f}}); trapezoid_factory->add_material( material_id::e_rod, {4.f * unit::mm, detray::aluminium()}); diff --git a/tests/include/detray/test/validation/detector_scanner.hpp b/tests/include/detray/test/validation/detector_scanner.hpp index 0c56175daf..099c7095cb 100644 --- a/tests/include/detray/test/validation/detector_scanner.hpp +++ b/tests/include/detray/test/validation/detector_scanner.hpp @@ -59,13 +59,13 @@ struct brute_force_scan { using trajectory_type = trajectory_t; template - inline auto operator()(const typename detector_t::geometry_context ctx, - const detector_t &detector, const trajectory_t &traj, - const darray - mask_tolerance = {0., 0.}, - const typename detector_t::scalar_type p = - 1.f * - unit::GeV) { + inline auto operator()( + const typename detector_t::geometry_context ctx, + const detector_t &detector, const trajectory_t &traj, + const darray mask_tolerance = {0., + 0.}, + const typename detector_t::scalar_type p = + 1.f * unit::GeV) { using algebra_t = typename detector_t::algebra_type; using scalar_t = dscalar; @@ -91,8 +91,7 @@ struct brute_force_scan { const auto sf = tracking_surface{detector, sf_desc}; sf.template visit_mask( intersections, traj, sf_desc, trf_store, ctx, - sf.is_portal() ? darray{0., 0.} - : mask_tolerance); + sf.is_portal() ? darray{0., 0.} : mask_tolerance); // Candidate is invalid if it lies in the opposite direction for (auto &sfi : intersections) { @@ -128,12 +127,12 @@ struct brute_force_scan { start_intersection.volume_link = static_cast(first_record.vol_idx); - intersection_trace.insert(intersection_trace.begin(), - intersection_record{ - q, - {traj.pos(), 0., p * traj.dir(), q}, - first_record.vol_idx, - start_intersection}); + intersection_trace.insert( + intersection_trace.begin(), + intersection_record{q, + {traj.pos(), 0., p * traj.dir(), q}, + first_record.vol_idx, + start_intersection}); return intersection_trace; } From f33cdf4b387fc1f50f25a48d6d87d6c70312f8dc Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Tue, 25 Mar 2025 22:43:34 +0530 Subject: [PATCH 08/11] Fixed a type issue. --- core/include/detray/navigation/navigator.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/include/detray/navigation/navigator.hpp b/core/include/detray/navigation/navigator.hpp index 9c9d9f5d92..7e6b47a9a0 100644 --- a/core/include/detray/navigation/navigator.hpp +++ b/core/include/detray/navigation/navigator.hpp @@ -726,7 +726,7 @@ class navigator { init(track, navigation, cfg, ctx); is_init = true; - // Fresh initialization, reset trust and hearbeat even though we are + // Fresh initialization, reset trust and heartbeat even though we are // on inner portal navigation.m_trust_level = navigation::trust_level::e_full; navigation.m_heartbeat = !navigation.is_exhausted(); @@ -749,8 +749,8 @@ class navigator { // Use the max mask tolerance in case a track leaves the volume // when a sf is 'sticking' out of the portals due to the tol loose_cfg.overstep_tolerance = - math::min(100. * cfg.overstep_tolerance, - -10. * cfg.max_mask_tolerance); + math::min(100.f * cfg.overstep_tolerance, + -10.f * cfg.max_mask_tolerance); init(track, navigation, loose_cfg, ctx, use_path_tolerance_as_overstep_tolerance); From 58664cec76c5e2ca6410734024e9101a91bb80bb Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Tue, 25 Mar 2025 22:52:00 +0530 Subject: [PATCH 09/11] Fixed formatting. --- core/include/detray/navigation/navigator.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/include/detray/navigation/navigator.hpp b/core/include/detray/navigation/navigator.hpp index 7e6b47a9a0..69b4fd4685 100644 --- a/core/include/detray/navigation/navigator.hpp +++ b/core/include/detray/navigation/navigator.hpp @@ -726,8 +726,8 @@ class navigator { init(track, navigation, cfg, ctx); is_init = true; - // Fresh initialization, reset trust and heartbeat even though we are - // on inner portal + // Fresh initialization, reset trust and heartbeat even though we + // are on inner portal navigation.m_trust_level = navigation::trust_level::e_full; navigation.m_heartbeat = !navigation.is_exhausted(); } From cf6f87a22bac5bcd6a22ddeb9a46d3b16cf38276 Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Sat, 26 Apr 2025 17:49:17 +0530 Subject: [PATCH 10/11] Revert "Added the files which needed special casing for Fastor." This reverts commit 3d28674ebc6793eeb3fc953da94d8cda05ba5982. --- .../detray/geometry/coordinates/line2D.hpp | 9 +-- .../detray/geometry/shapes/annulus2D.hpp | 55 +++++++++---------- .../intersection/ray_cylinder_intersector.hpp | 23 +++----- .../intersection/ray_plane_intersector.hpp | 24 ++++---- 4 files changed, 47 insertions(+), 64 deletions(-) diff --git a/core/include/detray/geometry/coordinates/line2D.hpp b/core/include/detray/geometry/coordinates/line2D.hpp index 4a72285341..e676dae03d 100644 --- a/core/include/detray/geometry/coordinates/line2D.hpp +++ b/core/include/detray/geometry/coordinates/line2D.hpp @@ -49,12 +49,7 @@ struct line2D { // Assign the sign depending on the position w.r.t line // Right: -1 // Left: 1 -#ifdef DETRAY_ALGEBRA_FASTOR - const vector3_type tmp = t - p; - const scalar_type sign = vector::dot(r, tmp) > 0. ? -1. : 1.; -#else - const scalar_type sign = vector::dot(r, t - p) > 0. ? -1. : 1.; -#endif + const scalar_type sign = vector::dot(r, t - p) > 0.f ? -1.f : 1.f; return {sign * vector::perp(local3), local3[2], vector::phi(local3)}; } @@ -98,7 +93,7 @@ struct line2D { // Local Z poisition in global cartesian coordinate const point3_type locZ_in_global = - trf.point_to_global(point3_type{0., 0., p[1]}); + trf.point_to_global(point3_type{0.f, 0.f, p[1]}); return locZ_in_global + p[0] * vector::normalize(r); } diff --git a/core/include/detray/geometry/shapes/annulus2D.hpp b/core/include/detray/geometry/shapes/annulus2D.hpp index 4a75793380..5f39ff371c 100644 --- a/core/include/detray/geometry/shapes/annulus2D.hpp +++ b/core/include/detray/geometry/shapes/annulus2D.hpp @@ -76,7 +76,7 @@ class annulus2D { DETRAY_HOST_DEVICE darray stereo_angle( const bounds_type &bounds) const { // Half stereo angle (phi_s / 2) (y points in the long strip direction) - return 2. * math::atan(bounds[e_shift_y] / bounds[e_shift_x]); + return 2.f * math::atan(bounds[e_shift_y] / bounds[e_shift_x]); } /// @returns The phi position in relative to the average phi of the annulus. @@ -95,12 +95,12 @@ class annulus2D { // Go to beam frame to check r boundaries. Use the origin // shift in polar coordinates for that // TODO: Put shift in r-phi into the bounds? - const point_t shift_xy = {-bounds[e_shift_x], -bounds[e_shift_y], 0.}; + const point_t shift_xy = {-bounds[e_shift_x], -bounds[e_shift_y], 0.f}; const scalar_t shift_r = vector::perp(shift_xy); const scalar_t shift_phi = vector::phi(shift_xy); return shift_r * shift_r + loc_p[0] * loc_p[0] + - 2. * shift_r * loc_p[0] * + 2.f * shift_r * loc_p[0] * math::cos(get_phi_rel(bounds, loc_p) - shift_phi); } @@ -135,7 +135,7 @@ class annulus2D { // Compare the radius with the chord return math::min(min_r_dist, - 2. * loc_p[0] * math::sin(0.5 * min_phi_dist)); + 2.f * loc_p[0] * math::sin(0.5f * min_phi_dist)); } /// @brief Check boundary values for a local point. @@ -170,7 +170,7 @@ class annulus2D { const scalar_t minR_tol = bounds[e_min_r] - tol; const scalar_t maxR_tol = bounds[e_max_r] + tol; - assert(detail::all_of(minR_tol >= scalar_t(0.))); + assert(detail::all_of(minR_tol >= scalar_t(0.f))); return ((r_beam2 >= (minR_tol * minR_tol)) && (r_beam2 <= (maxR_tol * maxR_tol))) && @@ -222,7 +222,7 @@ class annulus2D { using scalar_t = dscalar; using point_t = dpoint2D; - assert(env > 0.); + assert(env > 0.f); const auto c_pos = corners(bounds); @@ -237,12 +237,7 @@ class annulus2D { // bisector = 0.5 * (c + b). Scale to the length of the full circle to // get the outermost point -#ifdef DETRAY_ALGEBRA_FASTOR - const point_t tmp = c + b; - const point_t t = bounds[e_max_r] * vector::normalize(tmp); -#else const point_t t = bounds[e_max_r] * vector::normalize(c + b); -#endif // Find the min/max positions in x and y darray x_pos{c_pos[2] * math::cos(c_pos[3]) - o_x, b[0], @@ -331,10 +326,10 @@ class annulus2D { const auto crns = corners(bounds); // Coordinates of the centroid position in strip system - const scalar_t r{0.25 * (crns[0] + crns[2] + crns[4] + crns[6])}; + const scalar_t r{0.25f * (crns[0] + crns[2] + crns[4] + crns[6])}; const scalar_t phi{bounds[e_average_phi]}; - return r * dpoint3D{math::cos(phi), math::sin(phi), 0.}; + return r * dpoint3D{math::cos(phi), math::sin(phi), 0.f}; } /// Generate vertices in local cartesian frame @@ -375,21 +370,23 @@ class annulus2D { // scalar_t m = math::tan(phi); point2_t dir = {math::cos(phi), math::sin(phi)}; - scalar_t x1 = (O_x + O_y * m - - math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + - 2. * O_x * O_y * m - math::pow(O_y, 2.) + - math::pow(m, 2.) * math::pow(r, 2.) + - math::pow(r, 2.))) / - (math::pow(m, 2.) + 1.); - scalar_t x2 = (O_x + O_y * m + - math::sqrt(-math::pow(O_x, 2.) * math::pow(m, 2.) + - 2. * O_x * O_y * m - math::pow(O_y, 2.) + - math::pow(m, 2.) * math::pow(r, 2.) + - math::pow(r, 2.))) / - (math::pow(m, 2.) + 1.); + scalar_t x1 = + (O_x + O_y * m - + math::sqrt(-math::pow(O_x, 2.f) * math::pow(m, 2.f) + + 2.f * O_x * O_y * m - math::pow(O_y, 2.f) + + math::pow(m, 2.f) * math::pow(r, 2.f) + + math::pow(r, 2.f))) / + (math::pow(m, 2.f) + 1.f); + scalar_t x2 = + (O_x + O_y * m + + math::sqrt(-math::pow(O_x, 2.f) * math::pow(m, 2.f) + + 2.f * O_x * O_y * m - math::pow(O_y, 2.f) + + math::pow(m, 2.f) * math::pow(r, 2.f) + + math::pow(r, 2.f))) / + (math::pow(m, 2.f) + 1.f); point2_t v1 = {x1, m * x1}; - if (vector::dot(v1, dir) > 0.) + if (vector::dot(v1, dir) > 0.f) return v1; return {x2, m * x2}; }; @@ -412,13 +409,13 @@ class annulus2D { for (scalar_t iphi : inner_phi) { annulus_vertices.push_back( point3_t{min_r * math::cos(iphi) + origin_x, - min_r * math::sin(iphi) + origin_y, 0.}); + min_r * math::sin(iphi) + origin_y, 0.f}); } for (scalar_t ophi : outer_phi) { annulus_vertices.push_back( point3_t{max_r * math::cos(ophi) + origin_x, - max_r * math::sin(ophi) + origin_y, 0.}); + max_r * math::sin(ophi) + origin_y, 0.f}); } return annulus_vertices; @@ -434,7 +431,7 @@ class annulus2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (math::signbit(bounds[e_min_r]) || bounds[e_max_r] < tol) { os << "ERROR: Radial bounds must be in the range [0, numeric_max)"; diff --git a/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp index 3d28dd7799..15e87d1ea4 100644 --- a/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_cylinder_intersector.hpp @@ -61,9 +61,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { operator()(const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 100. * unit::um}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 100.f * unit::um}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); @@ -102,8 +102,8 @@ struct ray_intersector_impl, algebra_t, do_debug> { operator()(const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., + const scalar_type overstep_tol = 0.f) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, overstep_tol); } @@ -122,9 +122,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); @@ -156,15 +156,10 @@ struct ray_intersector_impl, algebra_t, do_debug> { const point3_type &ro = ray.pos(); const vector3_type &rd = ray.dir(); -#ifdef DETRAY_ALGEBRA_FASTOR - const vector3_type tmp = ro - sc; - const auto pc_cross_sz = vector::cross(tmp, sz); -#else const auto pc_cross_sz = vector::cross(ro - sc, sz); -#endif const auto rd_cross_sz = vector::cross(rd, sz); const scalar_type a{vector::dot(rd_cross_sz, rd_cross_sz)}; - const scalar_type b{2. * vector::dot(rd_cross_sz, pc_cross_sz)}; + const scalar_type b{2.f * vector::dot(rd_cross_sz, pc_cross_sz)}; const scalar_type c{vector::dot(pc_cross_sz, pc_cross_sz) - (r * r)}; return detail::quadratic_equation{a, b, c}; diff --git a/core/include/detray/navigation/intersection/ray_plane_intersector.hpp b/core/include/detray/navigation/intersection/ray_plane_intersector.hpp index 6ff3bd23e1..56c614a64a 100644 --- a/core/include/detray/navigation/intersection/ray_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_plane_intersector.hpp @@ -60,9 +60,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -75,13 +75,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const vector3_type &rd = ray.dir(); const scalar_type denom = vector::dot(rd, sn); // this is dangerous - if (denom != 0.) { -#ifdef DETRAY_ALGEBRA_FASTOR - const vector3_type tmp = st - ro; - is.path = vector::dot(sn, tmp) / denom; -#else + if (denom != 0.f) { is.path = vector::dot(sn, st - ro) / denom; -#endif + // Intersection is valid for navigation - continue if (is.path >= overstep_tol) { @@ -112,8 +108,8 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., + const scalar_type overstep_tol = 0.f) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, overstep_tol); } @@ -133,9 +129,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } From 161bc34461aa47ad8304dfc7a340bdaddf1b27ba Mon Sep 17 00:00:00 2001 From: wermos <63574588+wermos@users.noreply.github.com> Date: Sat, 26 Apr 2025 17:57:01 +0530 Subject: [PATCH 11/11] Revert "Removed the trailing `f` in floating point numbers." This reverts commit 95cbb93f472832a86ae10741dfb50b12d2b63ab3. --- core/include/detray/builders/bin_fillers.hpp | 2 +- .../builders/cuboid_portal_generator.hpp | 18 +-- .../builders/cylinder_portal_generator.hpp | 34 ++--- .../detray/builders/detail/associator.hpp | 12 +- .../builders/detail/bin_association.hpp | 4 +- .../builders/detail/portal_accessor.hpp | 4 +- .../detray/builders/detector_builder.hpp | 10 +- .../homogeneous_material_generator.hpp | 2 +- .../builders/material_map_generator.hpp | 6 +- .../geometry/coordinates/cartesian2D.hpp | 2 +- .../coordinates/concentric_cylindrical2D.hpp | 4 +- .../geometry/coordinates/cylindrical2D.hpp | 4 +- .../detray/geometry/coordinates/polar2D.hpp | 2 +- .../detray/geometry/detail/shape_utils.hpp | 2 +- .../geometry/shapes/concentric_cylinder2D.hpp | 8 +- .../detray/geometry/shapes/cuboid3D.hpp | 10 +- .../detray/geometry/shapes/cylinder2D.hpp | 8 +- .../detray/geometry/shapes/cylinder3D.hpp | 10 +- core/include/detray/geometry/shapes/line.hpp | 18 +-- .../detray/geometry/shapes/rectangle2D.hpp | 16 +-- .../include/detray/geometry/shapes/ring2D.hpp | 6 +- .../detray/geometry/shapes/single3D.hpp | 6 +- .../detray/geometry/shapes/trapezoid2D.hpp | 23 ++-- .../detray/geometry/shapes/unmasked.hpp | 2 +- core/include/detray/grids/axis.hpp | 4 +- .../materials/detail/density_effect_data.hpp | 14 +- .../detail/relativistic_quantities.hpp | 86 ++++++------ core/include/detray/materials/interaction.hpp | 50 +++---- core/include/detray/materials/material.hpp | 16 +-- .../include/detray/materials/material_rod.hpp | 8 +- .../detray/materials/material_slab.hpp | 10 +- core/include/detray/materials/mixture.hpp | 4 +- .../detray/materials/predefined_materials.hpp | 129 +++++++++--------- .../detray/navigation/direct_navigator.hpp | 2 +- .../bounding_box/cuboid_intersector.hpp | 8 +- .../helix_cylinder_intersector.hpp | 26 ++-- .../intersection/helix_line_intersector.hpp | 36 ++--- .../intersection/helix_plane_intersector.hpp | 31 +++-- .../ray_concentric_cylinder_intersector.hpp | 22 +-- .../ray_cylinder_portal_intersector.hpp | 16 +-- .../intersection/ray_line_intersector.hpp | 22 +-- .../soa/ray_cylinder_intersector.hpp | 22 +-- .../soa/ray_cylinder_portal_intersector.hpp | 14 +- .../intersection/soa/ray_line_intersector.hpp | 16 +-- .../soa/ray_plane_intersector.hpp | 12 +- .../detray/navigation/intersection_kernel.hpp | 16 +-- .../include/detray/navigation/intersector.hpp | 10 +- core/include/detray/navigation/navigator.hpp | 12 +- core/include/detray/navigation/policies.hpp | 4 +- .../detray/propagator/actors/aborters.hpp | 4 +- .../actors/pointwise_material_interactor.hpp | 22 +-- .../detray/propagator/base_stepper.hpp | 10 +- .../propagator/detail/jacobian_cartesian.hpp | 2 +- .../detail/jacobian_cylindrical.hpp | 3 +- .../propagator/detail/jacobian_engine.hpp | 8 +- .../propagator/detail/jacobian_line.hpp | 5 +- .../propagator/detail/jacobian_polar.hpp | 4 +- .../detray/propagator/line_stepper.hpp | 4 +- core/include/detray/propagator/rk_stepper.hpp | 8 +- core/include/detray/propagator/rk_stepper.ipp | 80 +++++------ .../detray/tracks/bound_track_parameters.hpp | 18 +-- .../detray/tracks/free_track_parameters.hpp | 14 +- core/include/detray/tracks/helix.hpp | 18 +-- core/include/detray/tracks/ray.hpp | 6 +- core/include/detray/utils/axis_rotation.hpp | 12 +- core/include/detray/utils/bounding_volume.hpp | 12 +- .../detray/utils/grid/detail/axis_binning.hpp | 2 +- core/include/detray/utils/matrix_helper.hpp | 4 +- .../detray/utils/quadratic_equation.hpp | 29 ++-- core/include/detray/utils/root_finding.hpp | 34 ++--- core/include/detray/utils/string_helpers.hpp | 5 +- core/include/detray/utils/unit_vectors.hpp | 6 +- tests/benchmarks/cpu/find_volume.cpp | 2 +- tests/benchmarks/cpu/propagation.cpp | 4 +- .../test/common/detector_scan_config.hpp | 2 +- .../common/material_validation_config.hpp | 2 +- .../common/navigation_validation_config.hpp | 2 +- .../include/detray/test/cpu/detector_scan.hpp | 2 +- .../include/detray/test/cpu/material_scan.hpp | 10 +- .../detray/test/cpu/material_validation.hpp | 2 +- .../detray/test/cpu/navigation_validation.hpp | 4 +- .../device/cuda/navigation_validation.hpp | 7 +- .../detray/test/device/propagator_test.hpp | 4 +- .../detectors/build_telescope_detector.hpp | 8 +- .../utils/detectors/build_toy_detector.hpp | 37 ++--- .../utils/detectors/build_wire_chamber.hpp | 2 +- .../detectors/factories/barrel_generator.hpp | 4 +- .../detectors/factories/endcap_generator.hpp | 20 +-- .../factories/telescope_generator.hpp | 4 +- .../factories/wire_layer_generator.hpp | 6 +- .../include/detray/test/utils/inspectors.hpp | 2 +- .../test/utils/planes_along_direction.hpp | 2 +- .../detray/test/utils/prefill_detector.hpp | 14 +- .../random_track_generator.hpp | 2 +- .../random_track_generator_config.hpp | 18 +-- .../uniform_track_generator.hpp | 10 +- .../uniform_track_generator_config.hpp | 14 +- .../utils/simulation/random_scatterer.hpp | 6 +- .../utils/simulation/scattering_helper.hpp | 4 +- .../include/detray/test/utils/statistics.hpp | 2 +- tests/include/detray/test/utils/types.hpp | 4 - .../test/validation/detector_scanner.hpp | 37 ++--- .../validation/material_validation_utils.hpp | 18 +-- .../navigation_validation_utils.hpp | 4 +- .../detray/test/validation/step_tracer.hpp | 4 +- .../detray/test/validation/svg_display.hpp | 2 +- 106 files changed, 692 insertions(+), 686 deletions(-) diff --git a/core/include/detray/builders/bin_fillers.hpp b/core/include/detray/builders/bin_fillers.hpp index 952e0df22d..82a19a1cfa 100644 --- a/core/include/detray/builders/bin_fillers.hpp +++ b/core/include/detray/builders/bin_fillers.hpp @@ -128,7 +128,7 @@ struct bin_associator { // Fill the surfaces into the grid by matching their contour onto the // grid bins bin_association(ctx, surfaces, transforms, masks, grid, - darray{0.1, 0.1}, false); + darray{0.1f, 0.1f}, false); } }; diff --git a/core/include/detray/builders/cuboid_portal_generator.hpp b/core/include/detray/builders/cuboid_portal_generator.hpp index 9235fa0680..fc83982c6f 100644 --- a/core/include/detray/builders/cuboid_portal_generator.hpp +++ b/core/include/detray/builders/cuboid_portal_generator.hpp @@ -117,7 +117,7 @@ class cuboid_portal_generator final // Max distance in case of infinite bounds constexpr scalar_type max_shift{ - 0.01 * std::numeric_limits::max()}; + 0.01f * std::numeric_limits::max()}; // The bounding boxes around the module surfaces std::vector boxes; @@ -139,7 +139,7 @@ class cuboid_portal_generator final const point3_t box_max = world_box.template loc_max(); // Get the half lengths for the rectangle sides and translation - const point3_t h_lengths = 0.5 * (box_max - box_min); + const point3_t h_lengths = 0.5f * (box_max - box_min); const scalar_type h_x{math::fabs(h_lengths[0])}; const scalar_type h_y{math::fabs(h_lengths[1])}; const scalar_type h_z{math::fabs(h_lengths[2])}; @@ -160,7 +160,7 @@ class cuboid_portal_generator final h_x, h_y); // No rotation, but shift in z for both faces - vector3_t shift{0., 0., + vector3_t shift{0.f, 0.f, detail::is_invalid_value(h_z) ? max_shift : h_z}; transforms.emplace_back(ctx, static_cast(center + shift)); transforms.emplace_back(ctx, static_cast(center - shift)); @@ -183,9 +183,9 @@ class cuboid_portal_generator final h_x, h_z); // Rotate by 90deg around x-axis, plus shift in y - shift = {0., detail::is_invalid_value(h_y) ? max_shift : h_y, 0.}; - vector3_t new_x{1., 0., 0.}; - vector3_t new_z{0., -1., 0.}; + shift = {0.f, detail::is_invalid_value(h_y) ? max_shift : h_y, 0.f}; + vector3_t new_x{1.f, 0.f, 0.f}; + vector3_t new_z{0.f, -1.f, 0.f}; transforms.emplace_back(ctx, static_cast(center + shift), new_z, new_x); transforms.emplace_back(ctx, static_cast(center - shift), @@ -207,9 +207,9 @@ class cuboid_portal_generator final h_z, h_y); // Rotate by 90deg around y-axis, plus shift in x - shift = {detail::is_invalid_value(h_x) ? max_shift : h_x, 0., 0.}; - new_x = {0., 0., -1.}; - new_z = {1., 0., 0.}; + shift = {detail::is_invalid_value(h_x) ? max_shift : h_x, 0.f, 0.f}; + new_x = {0.f, 0.f, -1.f}; + new_z = {1.f, 0.f, 0.f}; transforms.emplace_back(ctx, static_cast(center + shift), new_z, new_x); transforms.emplace_back(ctx, static_cast(center - shift), diff --git a/core/include/detray/builders/cylinder_portal_generator.hpp b/core/include/detray/builders/cylinder_portal_generator.hpp index 3942367487..07011c8bdb 100644 --- a/core/include/detray/builders/cylinder_portal_generator.hpp +++ b/core/include/detray/builders/cylinder_portal_generator.hpp @@ -33,13 +33,13 @@ struct cylinder_portal_config { /// Autofit the lower/upper z extend and inner/outer radii bool m_do_autofit{true}; /// Minimal envelope for the portals (used in autofitting) - scalar_t m_envelope{100. * unit::um}; + scalar_t m_envelope{100.f * unit::um}; /// Fixed inner radius during autofit - scalar_t m_fixed_inner_r{0.}; + scalar_t m_fixed_inner_r{0.f}; /// Fixed outer radius during autofit - scalar_t m_fixed_outer_r{0.}; + scalar_t m_fixed_outer_r{0.f}; /// Fixed length of the cylinder - scalar_t m_fixed_z{0.}; + scalar_t m_fixed_z{0.f}; /// The portal volumes links (north, south, east, west) std::vector m_volume_links{dindex_invalid, dindex_invalid, dindex_invalid, dindex_invalid}; @@ -137,10 +137,10 @@ class cylinder_portal_generator final public: /// Save the boundaries of the cylinder after autofitting the portals struct boundaries { - scalar_t inner_radius{0.}; - scalar_t outer_radius{0.}; - scalar_t lower_z{0.}; - scalar_t upper_z{0.}; + scalar_t inner_radius{0.f}; + scalar_t outer_radius{0.f}; + scalar_t lower_z{0.f}; + scalar_t upper_z{0.f}; }; /// Construct from configuration @param cfg @@ -194,9 +194,9 @@ class cylinder_portal_generator final if (!m_cfg.do_autofit()) { // Without autofit, the portal bounds have to be given explicitly - assert(!(m_cfg.fixed_inner_radius() == 0. && - m_cfg.fixed_outer_radius() == 0.) || - m_cfg.fixed_half_length() != 0.); + assert(!(m_cfg.fixed_inner_radius() == 0.f && + m_cfg.fixed_outer_radius() == 0.f) || + m_cfg.fixed_half_length() != 0.f); } else { // Need surfaces in volume to do autofit assert(n_surfaces != 0u); @@ -228,7 +228,7 @@ class cylinder_portal_generator final const point3_t box_max = world_box.template loc_max(); // Get the half lengths for the cylinder height and disc translation - const point3_t h_lengths = 0.5 * (box_max - box_min); + const point3_t h_lengths = 0.5f * (box_max - box_min); const scalar_t h_x{math::fabs(h_lengths[0])}; const scalar_t h_y{math::fabs(h_lengths[1])}; const scalar_t h_z{math::fabs(h_lengths[2])}; @@ -243,13 +243,13 @@ class cylinder_portal_generator final } // Observe boundary conditions - if (m_cfg.fixed_inner_radius() > 0.) { + if (m_cfg.fixed_inner_radius() > 0.f) { inner_r = m_cfg.fixed_inner_radius(); } - if (m_cfg.fixed_outer_radius() > 0.) { + if (m_cfg.fixed_outer_radius() > 0.f) { outer_r = m_cfg.fixed_outer_radius(); } - if (m_cfg.fixed_half_length() > 0.) { + if (m_cfg.fixed_half_length() > 0.f) { lower_z = -m_cfg.fixed_half_length(); upper_z = m_cfg.fixed_half_length(); } @@ -295,7 +295,7 @@ class cylinder_portal_generator final const scalar_t max_z{math::max(lower_z, upper_z)}; // translation - const point3_t tsl{0., 0., 0.}; + const point3_t tsl{0.f, 0.f, 0.f}; // Add transform and mask data transforms.emplace_back(ctx, tsl); @@ -335,7 +335,7 @@ class cylinder_portal_generator final const scalar_t max_r{math::max(inner_r, outer_r)}; // translation - point3_t tsl{0., 0., z}; + point3_t tsl{0.f, 0.f, z}; // Add transform and mask data transforms.emplace_back(ctx, tsl); diff --git a/core/include/detray/builders/detail/associator.hpp b/core/include/detray/builders/detail/associator.hpp index cc7faf87de..6abcfa2326 100644 --- a/core/include/detray/builders/detail/associator.hpp +++ b/core/include/detray/builders/detail/associator.hpp @@ -38,11 +38,11 @@ struct center_of_gravity_rectangle { using point2_t = dpoint2D; // Check if centre of gravity is inside bin - point2_t cgs = {0., 0.}; + point2_t cgs = {0.f, 0.f}; for (const auto &svtx : surface_contour) { cgs = cgs + svtx; } - cgs = 1. / static_cast(surface_contour.size()) * cgs; + cgs = 1.f / static_cast(surface_contour.size()) * cgs; scalar_t min_l0 = std::numeric_limits::max(); scalar_t max_l0 = -std::numeric_limits::max(); scalar_t min_l1 = std::numeric_limits::max(); @@ -80,11 +80,11 @@ struct center_of_gravity_generic { using point2_t = dpoint2D; // Check if centre of gravity is inside bin - point2_t cgs = {0., 0.}; + point2_t cgs = {0.f, 0.f}; for (const auto &svtx : surface_contour) { cgs = cgs + svtx; } - cgs = 1. / static_cast(surface_contour.size()) * cgs; + cgs = 1.f / static_cast(surface_contour.size()) * cgs; std::size_t i = 0u; std::size_t j = 0u; @@ -126,14 +126,14 @@ struct edges_intersect_generic { scalar_t d = (pj[0] - pi[0]) * (pl[1] - pk[1]) - (pj[1] - pi[1]) * (pl[0] - pk[0]); - if (d != 0.) { + if (d != 0.f) { double r = ((pi[1] - pk[1]) * (pl[0] - pk[0]) - (pi[0] - pk[0]) * (pl[1] - pk[1])) / d; double s = ((pi[1] - pk[1]) * (pj[0] - pi[0]) - (pi[0] - pk[0]) * (pj[1] - pi[1])) / d; - if (r >= 0. && r <= 1. && s >= 0. && s <= 1.) { + if (r >= 0.f && r <= 1.f && s >= 0.f && s <= 1.f) { return true; } } diff --git a/core/include/detray/builders/detail/bin_association.hpp b/core/include/detray/builders/detail/bin_association.hpp index 63659e801a..ceb56dae2d 100644 --- a/core/include/detray/builders/detail/bin_association.hpp +++ b/core/include/detray/builders/detail/bin_association.hpp @@ -200,7 +200,7 @@ static inline void bin_association(const context_t & /*context*/, phi_min = math::min(phi, phi_min); phi_max = math::max(phi, phi_max); surface_contour.push_back({vg[2], phi}); - if (phi < 0.) { + if (phi < 0.f) { s_c_neg.push_back({vg[2], phi}); z_min_neg = math::min(vg[2], z_min_neg); z_max_neg = math::max(vg[2], z_max_neg); @@ -214,7 +214,7 @@ static inline void bin_association(const context_t & /*context*/, std::vector> surface_contours{}; if (phi_max - phi_min > constant::pi && - phi_max * phi_min < 0.) { + phi_max * phi_min < 0.f) { s_c_neg.push_back( {z_max_neg, -constant::pi}); s_c_neg.push_back( diff --git a/core/include/detray/builders/detail/portal_accessor.hpp b/core/include/detray/builders/detail/portal_accessor.hpp index d127b307b0..6ee6e1ab76 100644 --- a/core/include/detray/builders/detail/portal_accessor.hpp +++ b/core/include/detray/builders/detail/portal_accessor.hpp @@ -32,8 +32,8 @@ auto get_cylinder_portals(const tracking_volume &vol) { std::vector inner_pt{}, outer_pt{}, lower_pt{}, upper_pr{}; - std::map radii{0.}; - std::map z_pos{0.}; + std::map radii{0.f}; + std::map z_pos{0.f}; // Loop over all portals for (const auto &pt_desc : vol.portals()) { diff --git a/core/include/detray/builders/detector_builder.hpp b/core/include/detray/builders/detector_builder.hpp index 905f5b669f..7ab28a5f9f 100644 --- a/core/include/detray/builders/detector_builder.hpp +++ b/core/include/detray/builders/detector_builder.hpp @@ -123,16 +123,16 @@ class detector_builder { // TODO: Construct it correctly with the grid builder mask vgrid_dims{ - 0u, 0., -constant::pi, - -2000., 180., constant::pi, - 2000.}; + 0u, 0.f, -constant::pi, + -2000.f, 180.f, constant::pi, + 2000.f}; darray n_vgrid_bins{1u, 1u, 1u}; darray, 3UL> bin_edges{ - std::vector{0., 180.}, + std::vector{0.f, 180.f}, std::vector{-constant::pi, constant::pi}, - std::vector{-2000., 2000.}}; + std::vector{-2000.f, 2000.f}}; grid_factory_type vgrid_factory{}; m_vol_finder = vgrid_factory.template new_grid< diff --git a/core/include/detray/builders/homogeneous_material_generator.hpp b/core/include/detray/builders/homogeneous_material_generator.hpp index 46dc639fb1..9679f25a2e 100644 --- a/core/include/detray/builders/homogeneous_material_generator.hpp +++ b/core/include/detray/builders/homogeneous_material_generator.hpp @@ -33,7 +33,7 @@ struct hom_material_config { /// Type of material to put on the portal surfaces material m_portal_material{vacuum{}}; /// Minimal envelope for the portals (used in autofitting) - scalar_t m_thickness{1.5 * unit::mm}; + scalar_t m_thickness{1.5f * unit::mm}; /// Setters /// @{ diff --git a/core/include/detray/builders/material_map_generator.hpp b/core/include/detray/builders/material_map_generator.hpp index cb13d7c77f..b39af926bc 100644 --- a/core/include/detray/builders/material_map_generator.hpp +++ b/core/include/detray/builders/material_map_generator.hpp @@ -44,7 +44,7 @@ inline std::vector> generate_cyl_mat( // Make sure the cylinder bounds are centered around zero const scalar_t length{math::fabs(bounds[cylinder2D::e_upper_z] - bounds[cylinder2D::e_lower_z])}; - scalar_t z{-0.5 * length}; + scalar_t z{-0.5f * length}; const scalar_t z_step{length / static_cast(nbins - 1u)}; for (std::size_t n = 0u; n < nbins; ++n) { ts.emplace_back(mat, static_cast(scalor * z * z) + t); @@ -92,9 +92,9 @@ struct material_map_config { /// Material to be filled into the maps material mapped_material{silicon_tml()}; /// Minimal thickness of the material slabs in the material maps - scalar_t thickness{0.15 * unit::mm}; + scalar_t thickness{0.15f * unit::mm}; /// Scale factor for the material thickness calculation - scalar_t scalor{1.}; + scalar_t scalor{1.f}; /// How to vary the material thickness along the bins std::function>( const std::vector &, const std::size_t, diff --git a/core/include/detray/geometry/coordinates/cartesian2D.hpp b/core/include/detray/geometry/coordinates/cartesian2D.hpp index a47040853d..332f849915 100644 --- a/core/include/detray/geometry/coordinates/cartesian2D.hpp +++ b/core/include/detray/geometry/coordinates/cartesian2D.hpp @@ -59,7 +59,7 @@ struct cartesian2D { DETRAY_HOST_DEVICE static inline point3_type local_to_global( const transform3_type &trf, const mask_t & /*mask*/, const loc_point &p, const vector3_type & /*dir*/) { - return trf.point_to_global(point3_type{p[0], p[1], 0.}); + return trf.point_to_global(point3_type{p[0], p[1], 0.f}); } /// @returns the normal vector in global coordinates diff --git a/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp b/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp index 0359050f7a..1ea9c65d62 100644 --- a/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp +++ b/core/include/detray/geometry/coordinates/concentric_cylindrical2D.hpp @@ -81,7 +81,7 @@ struct concentric_cylindrical2D { const mask_t & /*mask*/) { // normal vector in global coordinates (concentric cylinders have no // rotation) - return {math::cos(p[0]), math::sin(p[0]), 0.}; + return {math::cos(p[0]), math::sin(p[0]), 0.f}; } /// @returns the normal vector given a local position @param p @@ -89,7 +89,7 @@ struct concentric_cylindrical2D { const transform3_type &, const point3_type &p) { // normal vector in global coordinates (concentric cylinders have no // rotation) - return {math::cos(p[0]), math::sin(p[0]), 0.}; + return {math::cos(p[0]), math::sin(p[0]), 0.f}; } }; // struct concentric_cylindrical2D diff --git a/core/include/detray/geometry/coordinates/cylindrical2D.hpp b/core/include/detray/geometry/coordinates/cylindrical2D.hpp index 347c7f41db..4fad1e04bd 100644 --- a/core/include/detray/geometry/coordinates/cylindrical2D.hpp +++ b/core/include/detray/geometry/coordinates/cylindrical2D.hpp @@ -81,7 +81,7 @@ struct cylindrical2D { DETRAY_HOST_DEVICE static inline vector3_type normal( const transform3_type &trf, const point2_type &p, const mask_t &mask) { const scalar_type phi{p[0] / mask[mask_t::shape::e_r]}; - const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.}; + const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.f}; // normal vector in global coordinate return trf.vector_to_global(local_normal); @@ -92,7 +92,7 @@ struct cylindrical2D { DETRAY_HOST_DEVICE static inline vector3_type normal( const transform3_type &trf, const point3_type &p) { const scalar_type phi{p[0] / p[2]}; - const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.}; + const vector3_type local_normal{math::cos(phi), math::sin(phi), 0.f}; // normal vector in global coordinate return trf.vector_to_global(local_normal); diff --git a/core/include/detray/geometry/coordinates/polar2D.hpp b/core/include/detray/geometry/coordinates/polar2D.hpp index ce345ddb67..1aef0b8cf5 100644 --- a/core/include/detray/geometry/coordinates/polar2D.hpp +++ b/core/include/detray/geometry/coordinates/polar2D.hpp @@ -65,7 +65,7 @@ struct polar2D { const transform3_type &trf, const mask_t & /*mask*/, const loc_point &p, const vector3_type & /*dir*/) { - return polar2D::local_to_global(trf, {p[0], p[1], 0.}); + return polar2D::local_to_global(trf, {p[0], p[1], 0.f}); } /// @returns the normal vector in global coordinates diff --git a/core/include/detray/geometry/detail/shape_utils.hpp b/core/include/detray/geometry/detail/shape_utils.hpp index eba2290d5d..1f3a51829f 100644 --- a/core/include/detray/geometry/detail/shape_utils.hpp +++ b/core/include/detray/geometry/detail/shape_utils.hpp @@ -21,7 +21,7 @@ namespace detray::detail { /// using a small angle approximation template constexpr scalar_t phi_tolerance(scalar_t tol, scalar_t radius) { - return radius > 0. ? tol / radius : tol; + return radius > 0.f ? tol / radius : tol; } } // namespace detray::detail diff --git a/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp b/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp index 137f1189a5..e45f7e9255 100644 --- a/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp +++ b/core/include/detray/geometry/shapes/concentric_cylinder2D.hpp @@ -109,7 +109,7 @@ class concentric_cylinder2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 2. * constant::pi * bounds[e_r] * + return 2.f * constant::pi * bounds[e_r] * (bounds[e_upper_z] - bounds[e_lower_z]); } @@ -128,7 +128,7 @@ class concentric_cylinder2D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.); + assert(env > 0.f); const dscalar xy_bound{bounds[e_r] + env}; return {-xy_bound, -xy_bound, bounds[e_lower_z] - env, xy_bound, xy_bound, bounds[e_upper_z] + env}; @@ -139,7 +139,7 @@ class concentric_cylinder2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return {0., 0., 0.5 * (bounds[e_lower_z] + bounds[e_upper_z])}; + return {0.f, 0.f, 0.5f * (bounds[e_lower_z] + bounds[e_upper_z])}; } /// Generate vertices in local cartesian frame @@ -166,7 +166,7 @@ class concentric_cylinder2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (bounds[e_r] < tol) { os << "ERROR: Radius must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/cuboid3D.hpp b/core/include/detray/geometry/shapes/cuboid3D.hpp index 193b082105..147ad990ee 100644 --- a/core/include/detray/geometry/shapes/cuboid3D.hpp +++ b/core/include/detray/geometry/shapes/cuboid3D.hpp @@ -142,7 +142,7 @@ class cuboid3D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.); + assert(env > 0.f); bounds_type> o_bounds{bounds}; for (unsigned int i{0}; i < 3u; ++i) { o_bounds[i] -= env; @@ -156,9 +156,9 @@ class cuboid3D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return 0.5 * dpoint3D{bounds[e_min_x] + bounds[e_max_x], - bounds[e_min_y] + bounds[e_max_y], - bounds[e_min_z] + bounds[e_max_z]}; + return 0.5f * dpoint3D{bounds[e_min_x] + bounds[e_max_x], + bounds[e_min_y] + bounds[e_max_y], + bounds[e_min_z] + bounds[e_max_z]}; } /// Generate vertices in local cartesian frame @@ -185,7 +185,7 @@ class cuboid3D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (bounds[e_min_x] >= bounds[e_max_x] || math::fabs(bounds[e_min_x] - bounds[e_max_x]) < tol) { diff --git a/core/include/detray/geometry/shapes/cylinder2D.hpp b/core/include/detray/geometry/shapes/cylinder2D.hpp index 22139c21a1..569d6b85f1 100644 --- a/core/include/detray/geometry/shapes/cylinder2D.hpp +++ b/core/include/detray/geometry/shapes/cylinder2D.hpp @@ -109,7 +109,7 @@ class cylinder2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 2. * constant::pi * bounds[e_r] * + return 2.f * constant::pi * bounds[e_r] * (bounds[e_upper_z] - bounds[e_lower_z]); } @@ -127,7 +127,7 @@ class cylinder2D { const bounds_type> &bounds, const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.); + assert(env > 0.f); const dscalar xy_bound{bounds[e_r] + env}; return {-xy_bound, -xy_bound, bounds[e_lower_z] - env, @@ -139,7 +139,7 @@ class cylinder2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return {0., 0., 0.5 * (bounds[e_lower_z] + bounds[e_upper_z])}; + return {0.f, 0.f, 0.5f * (bounds[e_lower_z] + bounds[e_upper_z])}; } /// Generate vertices in local cartesian frame @@ -166,7 +166,7 @@ class cylinder2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (bounds[e_r] < tol) { os << "ERROR: Radius must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/cylinder3D.hpp b/core/include/detray/geometry/shapes/cylinder3D.hpp index 34a0292731..f36214bdce 100644 --- a/core/include/detray/geometry/shapes/cylinder3D.hpp +++ b/core/include/detray/geometry/shapes/cylinder3D.hpp @@ -79,7 +79,7 @@ class cylinder3D { // Use the chord for the phi distance return math::min( math::min(min_r_dist, - 2. * loc_p[0] * math::sin(0.5 * min_phi_dist)), + 2.f * loc_p[0] * math::sin(0.5f * min_phi_dist)), min_z_dist); } @@ -150,7 +150,7 @@ class cylinder3D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.); + assert(env > 0.f); const dscalar r_bound{bounds[e_max_r] + env}; return {-r_bound, -r_bound, bounds[e_min_z] - env, r_bound, r_bound, bounds[e_max_z] + env}; @@ -161,8 +161,8 @@ class cylinder3D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &bounds) const { - return 0.5 * - dpoint3D{0., (bounds[e_min_phi] + bounds[e_max_phi]), + return 0.5f * + dpoint3D{0.f, (bounds[e_min_phi] + bounds[e_max_phi]), (bounds[e_min_z] + bounds[e_max_z])}; } @@ -190,7 +190,7 @@ class cylinder3D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (bounds[e_min_r] < tol) { os << "ERROR: Radii must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/line.hpp b/core/include/detray/geometry/shapes/line.hpp index 74a79211a6..58a31530d9 100644 --- a/core/include/detray/geometry/shapes/line.hpp +++ b/core/include/detray/geometry/shapes/line.hpp @@ -144,10 +144,10 @@ class line { const bounds_type &bounds) const { if constexpr (square_cross_sect) { - return 8. * bounds[e_half_z] * bounds[e_cross_section] * + return 8.f * bounds[e_half_z] * bounds[e_cross_section] * bounds[e_cross_section]; } else { - return constant::pi * 2. * bounds[e_half_z] * + return constant::pi * 2.f * bounds[e_half_z] * bounds[e_cross_section] * bounds[e_cross_section]; } } @@ -162,9 +162,9 @@ class line { const bounds_type &bounds) const { if constexpr (square_cross_sect) { - return 16. * bounds[e_half_z] * bounds[e_cross_section]; + return 16.f * bounds[e_half_z] * bounds[e_cross_section]; } else { - return 4. * constant::pi * bounds[e_cross_section] * + return 4.f * constant::pi * bounds[e_cross_section] * bounds[e_half_z]; } } @@ -186,7 +186,7 @@ class line { using scalar_t = dscalar; - assert(env > 0.); + assert(env > 0.f); const scalar_t xy_bound{bounds[e_cross_section] + env}; const scalar_t z_bound{bounds[e_half_z] + env}; @@ -198,7 +198,7 @@ class line { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &) const { - return {0., 0., 0.}; + return {0.f, 0.f, 0.f}; } /// Generate vertices in local cartesian frame @@ -214,8 +214,8 @@ class line { using point3_t = dpoint3D; - point3_t lc = {0., 0., -bounds[e_half_z]}; - point3_t rc = {0., 0., bounds[e_half_z]}; + point3_t lc = {0.f, 0.f, -bounds[e_half_z]}; + point3_t rc = {0.f, 0.f, bounds[e_half_z]}; return {lc, rc}; } @@ -230,7 +230,7 @@ class line { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (bounds[e_cross_section] < tol) { os << "ERROR: Radius/sides must be in the range (0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/rectangle2D.hpp b/core/include/detray/geometry/shapes/rectangle2D.hpp index 586935370a..e17c43beb1 100644 --- a/core/include/detray/geometry/shapes/rectangle2D.hpp +++ b/core/include/detray/geometry/shapes/rectangle2D.hpp @@ -102,7 +102,7 @@ class rectangle2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 4. * bounds[e_half_x] * bounds[e_half_y]; + return 4.f * bounds[e_half_x] * bounds[e_half_y]; } /// @brief Lower and upper point for minimal axis aligned bounding box. @@ -121,7 +121,7 @@ class rectangle2D { std::numeric_limits>::epsilon()) const { using scalar_t = dscalar; - assert(env > 0.); + assert(env > 0.f); const scalar_t x_bound{bounds[e_half_x] + env}; const scalar_t y_bound{bounds[e_half_y] + env}; return {-x_bound, -y_bound, -env, x_bound, y_bound, env}; @@ -132,7 +132,7 @@ class rectangle2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &) const { - return {0., 0., 0.}; + return {0.f, 0.f, 0.f}; } /// Generate vertices in local cartesian frame @@ -149,13 +149,13 @@ class rectangle2D { using point3_t = dpoint3D; // left hand lower corner - point3_t lh_lc{-bounds[e_half_x], -bounds[e_half_y], 0.}; + point3_t lh_lc{-bounds[e_half_x], -bounds[e_half_y], 0.f}; // right hand lower corner - point3_t rh_lc{bounds[e_half_x], -bounds[e_half_y], 0.}; + point3_t rh_lc{bounds[e_half_x], -bounds[e_half_y], 0.f}; // right hand upper corner - point3_t rh_uc{bounds[e_half_x], bounds[e_half_y], 0.}; + point3_t rh_uc{bounds[e_half_x], bounds[e_half_y], 0.f}; // left hand upper corner - point3_t lh_uc{-bounds[e_half_x], bounds[e_half_y], 0.}; + point3_t lh_uc{-bounds[e_half_x], bounds[e_half_y], 0.f}; // Return the confining vertices return {lh_lc, rh_lc, rh_uc, lh_uc}; @@ -171,7 +171,7 @@ class rectangle2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - if (constexpr auto tol{10. * std::numeric_limits::epsilon()}; + if (constexpr auto tol{10.f * std::numeric_limits::epsilon()}; bounds[e_half_x] < tol || bounds[e_half_y] < tol) { os << "ERROR: Half lengths must be in the range (0, numeric_max)" << std::endl; diff --git a/core/include/detray/geometry/shapes/ring2D.hpp b/core/include/detray/geometry/shapes/ring2D.hpp index 155d99b71c..575717da40 100644 --- a/core/include/detray/geometry/shapes/ring2D.hpp +++ b/core/include/detray/geometry/shapes/ring2D.hpp @@ -125,7 +125,7 @@ class ring2D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.); + assert(env > 0.f); const dscalar r_bound{env + bounds[e_outer_r]}; return {-r_bound, -r_bound, -env, r_bound, r_bound, env}; } @@ -135,7 +135,7 @@ class ring2D { DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type> &) const { - return {0., 0., 0.}; + return {0.f, 0.f, 0.f}; } /// Generate vertices in local cartesian frame @@ -162,7 +162,7 @@ class ring2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (math::signbit(bounds[e_inner_r]) || bounds[e_outer_r] < tol) { os << "ERROR: Radius must be in the range [0, numeric_max)" diff --git a/core/include/detray/geometry/shapes/single3D.hpp b/core/include/detray/geometry/shapes/single3D.hpp index 327745921b..dd83a53f2a 100644 --- a/core/include/detray/geometry/shapes/single3D.hpp +++ b/core/include/detray/geometry/shapes/single3D.hpp @@ -122,7 +122,7 @@ class single3D { const dscalar env = std::numeric_limits>::epsilon()) const { - assert(env > 0.); + assert(env > 0.f); darray, 6> o_bounds{-env, -env, -env, env, env, env}; o_bounds[kCheckIndex] += bounds[e_lower]; o_bounds[3u + kCheckIndex] += bounds[e_upper]; @@ -136,8 +136,8 @@ class single3D { using point3_t = dpoint3D; - point3_t centr{0., 0., 0.}; - centr[kCheckIndex] = 0.5 * (bounds[e_lower] + bounds[e_upper]); + point3_t centr{0.f, 0.f, 0.f}; + centr[kCheckIndex] = 0.5f * (bounds[e_lower] + bounds[e_upper]); return centr; } diff --git a/core/include/detray/geometry/shapes/trapezoid2D.hpp b/core/include/detray/geometry/shapes/trapezoid2D.hpp index 2e319373ec..f8b548b169 100644 --- a/core/include/detray/geometry/shapes/trapezoid2D.hpp +++ b/core/include/detray/geometry/shapes/trapezoid2D.hpp @@ -66,7 +66,7 @@ class trapezoid2D { const bounds_type &bounds, const point_t &loc_p) const { // Minimum distance between loc point and line between corner points - const scalar_t d_y = -2. * bounds[e_half_length_2]; + const scalar_t d_y = -2.f * bounds[e_half_length_2]; const scalar_t d_x = bounds[e_half_length_1] - bounds[e_half_length_0]; const scalar_t denom = math::sqrt(d_y * d_y + d_x * d_x); @@ -123,7 +123,7 @@ class trapezoid2D { template DETRAY_HOST_DEVICE constexpr scalar_t area( const bounds_type &bounds) const { - return 2. * (bounds[e_half_length_0] + bounds[e_half_length_1]) * + return 2.f * (bounds[e_half_length_0] + bounds[e_half_length_1]) * bounds[e_half_length_2]; } @@ -144,7 +144,7 @@ class trapezoid2D { using scalar_t = dscalar; - assert(env > 0.); + assert(env > 0.f); const scalar_t x_bound{ (bounds[e_half_length_0] > bounds[e_half_length_1] ? bounds[e_half_length_0] @@ -165,9 +165,10 @@ class trapezoid2D { const scalar_t a_2{bounds[e_half_length_1]}; const scalar_t b_2{bounds[e_half_length_0]}; - const scalar_t y{2. * h_2 * (2. * a_2 + b_2) * 1. / (3. * (a_2 + b_2))}; + const scalar_t y{2.f * h_2 * (2.f * a_2 + b_2) * 1.f / + (3.f * (a_2 + b_2))}; - return {0., y - h_2, 0.}; + return {0.f, y - h_2, 0.f}; } /// Generate vertices in local cartesian frame @@ -183,13 +184,13 @@ class trapezoid2D { using point3_t = dpoint3D; // left hand lower corner - point3_t lh_lc{-bounds[e_half_length_0], -bounds[e_half_length_2], 0.}; + point3_t lh_lc{-bounds[e_half_length_0], -bounds[e_half_length_2], 0.f}; // right hand lower corner - point3_t rh_lc{bounds[e_half_length_0], -bounds[e_half_length_2], 0.}; + point3_t rh_lc{bounds[e_half_length_0], -bounds[e_half_length_2], 0.f}; // right hand upper corner - point3_t rh_uc{bounds[e_half_length_1], bounds[e_half_length_2], 0.}; + point3_t rh_uc{bounds[e_half_length_1], bounds[e_half_length_2], 0.f}; // left hand upper corner - point3_t lh_uc{-bounds[e_half_length_1], bounds[e_half_length_2], 0.}; + point3_t lh_uc{-bounds[e_half_length_1], bounds[e_half_length_2], 0.f}; // Return the confining vertices return {lh_lc, rh_lc, rh_uc, lh_uc}; @@ -205,7 +206,7 @@ class trapezoid2D { DETRAY_HOST constexpr bool check_consistency( const bounds_type &bounds, std::ostream &os) const { - constexpr auto tol{10. * std::numeric_limits::epsilon()}; + constexpr auto tol{10.f * std::numeric_limits::epsilon()}; if (bounds[e_half_length_0] < tol || bounds[e_half_length_1] < tol) { os << "ERROR: Half length in x must be in the range (0, " @@ -220,7 +221,7 @@ class trapezoid2D { return false; } - if (const auto div{1. / (2. * bounds[e_half_length_2])}; + if (const auto div{1.f / (2.f * bounds[e_half_length_2])}; math::fabs(bounds[e_divisor] - div) > tol) { os << "ERROR: Divisor incorrect. Should be: " << div << std::endl; return false; diff --git a/core/include/detray/geometry/shapes/unmasked.hpp b/core/include/detray/geometry/shapes/unmasked.hpp index b42936831d..8e70702d02 100644 --- a/core/include/detray/geometry/shapes/unmasked.hpp +++ b/core/include/detray/geometry/shapes/unmasked.hpp @@ -133,7 +133,7 @@ class unmasked { template DETRAY_HOST_DEVICE dpoint3D centroid( const bounds_type>&) const { - return {0., 0., 0.}; + return {0.f, 0.f, 0.f}; } /// Generate vertices in local cartesian frame diff --git a/core/include/detray/grids/axis.hpp b/core/include/detray/grids/axis.hpp index 1fff614e67..ca12b13972 100644 --- a/core/include/detray/grids/axis.hpp +++ b/core/include/detray/grids/axis.hpp @@ -437,7 +437,7 @@ struct irregular { DETRAY_HOST_DEVICE irregular() : n_bins(detail::invalid_value()), - min(0.), + min(0.f), max(static_cast(n_bins)), boundaries({}) {} @@ -445,7 +445,7 @@ struct irregular { DETRAY_HOST explicit irregular(vecmem::memory_resource &resource) : n_bins(detail::invalid_value()), - min(0.), + min(0.f), max(static_cast(n_bins)), boundaries(&resource) {} diff --git a/core/include/detray/materials/detail/density_effect_data.hpp b/core/include/detray/materials/detail/density_effect_data.hpp index 4c5f507855..1d1aa222f9 100644 --- a/core/include/detray/materials/detail/density_effect_data.hpp +++ b/core/include/detray/materials/detail/density_effect_data.hpp @@ -70,17 +70,17 @@ struct density_effect_data { /// Fitting parameters of Eq. 33.7 of RPP 2018 /// @{ - scalar_type m_a = 0.; - scalar_type m_m = 0.; - scalar_type m_X0 = 0.; - scalar_type m_X1 = 0.; + scalar_type m_a = 0.f; + scalar_type m_m = 0.f; + scalar_type m_X0 = 0.f; + scalar_type m_X1 = 0.f; /// @} /// Mean excitation energy in eV - scalar_type m_I = 0.; + scalar_type m_I = 0.f; /// -C - scalar_type m_nC = 0.; + scalar_type m_nC = 0.f; /// Density-effect value delta(X_0) - scalar_type m_delta0 = 0.; + scalar_type m_delta0 = 0.f; }; } // namespace detray::detail diff --git a/core/include/detray/materials/detail/relativistic_quantities.hpp b/core/include/detray/materials/detail/relativistic_quantities.hpp index 6e615cecbf..10b4972a68 100644 --- a/core/include/detray/materials/detail/relativistic_quantities.hpp +++ b/core/include/detray/materials/detail/relativistic_quantities.hpp @@ -33,15 +33,15 @@ struct relativistic_quantities { static constexpr auto PlasmaEnergyScale{ static_cast(28.816 * unit::eV)}; - scalar_type m_qOverP{0.}; - scalar_type m_q2OverBeta2{0.}; - scalar_type m_beta{0.}; - scalar_type m_beta2{0.}; - scalar_type m_betaGamma{0.}; - scalar_type m_gamma{0.}; - scalar_type m_gamma2{0.}; - scalar_type m_E{0.}; - scalar_type m_Wmax{0.}; + scalar_type m_qOverP{0.f}; + scalar_type m_q2OverBeta2{0.f}; + scalar_type m_beta{0.f}; + scalar_type m_beta2{0.f}; + scalar_type m_betaGamma{0.f}; + scalar_type m_gamma{0.f}; + scalar_type m_gamma2{0.f}; + scalar_type m_E{0.f}; + scalar_type m_Wmax{0.f}; DETRAY_HOST_DEVICE relativistic_quantities(const pdg_particle& ptc, @@ -56,20 +56,20 @@ struct relativistic_quantities { // q²/beta² = q² + m²(q/p)² m_q2OverBeta2{q * q + (mass * qOverP) * (mass * qOverP)} { - assert(m_qOverP != 0.); - assert(mass != 0.); + assert(m_qOverP != 0.f); + assert(mass != 0.f); // 1/p = q/(qp) = (q/p)/q const scalar_type mOverP{ - mass * ((q != 0.) ? math::fabs(qOverP / q) : math::fabs(qOverP))}; - const scalar_type pOverM{1. / mOverP}; + mass * ((q != 0.f) ? math::fabs(qOverP / q) : math::fabs(qOverP))}; + const scalar_type pOverM{1.f / mOverP}; // beta² = p²/E² = p²/(m² + p²) = 1/(1 + (m/p)²) - m_beta2 = 1. / (1. + mOverP * mOverP); + m_beta2 = 1.f / (1.f + mOverP * mOverP); m_beta = math::sqrt(m_beta2); // beta*gamma = (p/sqrt(m² + p²))*(sqrt(m² + p²)/m) = p/m m_betaGamma = pOverM; // gamma = sqrt(m² + p²)/m = sqrt(1 + (p/m)²) - m_gamma = math::sqrt(1. + pOverM * pOverM); + m_gamma = math::sqrt(1.f + pOverM * pOverM); m_gamma2 = m_gamma * m_gamma; // E = gamma * mass; m_E = m_gamma * mass; @@ -77,21 +77,22 @@ struct relativistic_quantities { const scalar_type mfrac{constant::m_e / mass}; // Wmax = 2m_e c^2 beta^2 gamma^2 / (1+2gamma*m_e/M + (m_e/M)^2) - m_Wmax = (2. * constant::m_e * m_betaGamma * m_betaGamma) / - (1. + 2. * m_gamma * mfrac + mfrac * mfrac); + m_Wmax = + (2.f * constant::m_e * m_betaGamma * m_betaGamma) / + (1.f + 2.f * m_gamma * mfrac + mfrac * mfrac); } /// @return 2 * mass * (beta * gamma)² mass term. DETRAY_HOST_DEVICE constexpr scalar_type compute_mass_term( const scalar_type mass) const { - return 2. * mass * m_betaGamma * m_betaGamma; + return 2.f * mass * m_betaGamma * m_betaGamma; } /// @return [(K/2) * (Z/A) * z^2 / beta^2 * density] in [energy/length] /// @brief defined in 34.12 of 2023 PDG review DETRAY_HOST_DEVICE constexpr scalar_type compute_epsilon_per_length( const material& mat) const { - return 0.5 * K * mat.molar_electron_density() * m_q2OverBeta2; + return 0.5f * K * mat.molar_electron_density() * m_q2OverBeta2; } /// @return (K/2) * (Z/A) * z^2 / beta^2 * density * path_length @@ -107,28 +108,29 @@ struct relativistic_quantities { compute_bethe_bloch_log_term(const material& mat) const { const scalar_type I = mat.mean_excitation_energy(); - assert(I != 0.); + assert(I != 0.f); // u = 2 * m_e c^2* beta^2 * gamma^2 const scalar_t u{compute_mass_term(constant::m_e)}; - const scalar_type A = 0.5 * math::log(u * m_Wmax / (I * I)); + const scalar_type A = 0.5f * math::log(u * m_Wmax / (I * I)); return A; } /// @return d(bethe_log_term)/dqop /// @brief dA/dqop = - 1 / (2 * qop) * [4 - W_max/ (gamma M c^2) ] DETRAY_HOST_DEVICE scalar_type derive_bethe_bloch_log_term() const { - assert(m_gamma != 0.); - assert(m_E != 0.); - const scalar_type dAdqop = -1. / (2. * m_qOverP) * (4. - m_Wmax / m_E); + assert(m_gamma != 0.f); + assert(m_E != 0.f); + const scalar_type dAdqop = + -1.f / (2.f * m_qOverP) * (4.f - m_Wmax / m_E); return dAdqop; } /// @return d(beta^2)/dqop = - 2beta^2 / (qop * gamma^2) DETRAY_HOST_DEVICE scalar_type derive_beta2() const { - assert(m_qOverP != 0.); - assert(m_gamma2 != 0.); - return -2. * m_beta2 / (m_qOverP * m_gamma2); + assert(m_qOverP != 0.f); + assert(m_gamma2 != 0.f); + return -2.f * m_beta2 / (m_qOverP * m_gamma2); } /// @return the half of density correction factor (delta/2). @@ -146,18 +148,18 @@ struct relativistic_quantities { // // For further discussion, please follow the ATLAS JIRA Tickets: // ATLASRECTS-3144 and ATLASRECTS-7586 (ATLAS-restricted) - if (m_betaGamma < 10.) { - return 0.; + if (m_betaGamma < 10.f) { + return 0.f; } // Equation 34.6 of PDG2022 // @NOTE A factor of 1000 is required to convert the unit of density // (mm^-3 to cm^-3) const scalar_type plasmaEnergy{ PlasmaEnergyScale * - math::sqrt(1000. * mat.molar_electron_density())}; + math::sqrt(1000.f * mat.molar_electron_density())}; return math::log(m_betaGamma * plasmaEnergy / mat.mean_excitation_energy()) - - 0.5; + 0.5f; } else { const auto& density = mat.density_effect_data(); @@ -169,32 +171,32 @@ struct relativistic_quantities { const scalar_type x{math::log10(m_betaGamma)}; - scalar_type delta{0.}; + scalar_type delta{0.f}; // From Geant4 // processes/electromagnetic/lowenergy/src/G4hBetheBlochModel.cc if (x < x0den) { - delta = 0.; + delta = 0.f; // @TODO: Add a branch for conductors (Eq 34.7 of // https://pdg.lbl.gov/2023/reviews/rpp2023-rev-particle-detectors-accel.pdf) } else { - delta = 2. * constant::ln10 * x - cden; + delta = 2.f * constant::ln10 * x - cden; if (x < x1den) delta += aden * math::pow((x1den - x), mden); } - return 0.5 * delta; + return 0.5f * delta; } } /// @return the derivation of the density correction factor delta/2. DETRAY_HOST_DEVICE inline scalar_type derive_delta_half( const material& mat) const { - assert(m_qOverP != 0.); + assert(m_qOverP != 0.f); if (!mat.has_density_effect_data()) { // d(ln(betagamma))/dqop = -1/qop - return -1. / m_qOverP; + return -1.f / m_qOverP; } else { const auto& density = mat.density_effect_data(); @@ -206,24 +208,24 @@ struct relativistic_quantities { const scalar_type x{math::log10(m_betaGamma)}; - scalar_type delta{0.}; + scalar_type delta{0.f}; // From Geant4 // processes/electromagnetic/lowenergy/src/G4hBetheBlochModel.cc if (x < x0den) { - delta = 0.; + delta = 0.f; // @TODO: Add a branch for conductors (Eq 34.7 of // https://pdg.lbl.gov/2023/reviews/rpp2023-rev-particle-detectors-accel.pdf) } else { - delta = -2. / m_qOverP; + delta = -2.f / m_qOverP; if (x < x1den) { delta += aden * mden / (m_qOverP * constant::ln10) * - math::pow(x1den - x, mden - 1.); + math::pow(x1den - x, mden - 1.f); } } - return 0.5 * delta; + return 0.5f * delta; } } }; diff --git a/core/include/detray/materials/interaction.hpp b/core/include/detray/materials/interaction.hpp index 6411a2b6bc..20ff02a899 100644 --- a/core/include/detray/materials/interaction.hpp +++ b/core/include/detray/materials/interaction.hpp @@ -30,7 +30,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type stopping_power{0.}; + scalar_type stopping_power{0.f}; // Inelastic collisions with atomic electrons stopping_power += compute_bethe_bloch(mat, ptc, rq); @@ -47,14 +47,14 @@ struct interaction { const relativistic_quantities& rq) const { const scalar_type eps_per_length{rq.compute_epsilon_per_length(mat)}; - if (eps_per_length <= 0.) { - return 0.; + if (eps_per_length <= 0.f) { + return 0.f; } const scalar_type dhalf{rq.compute_delta_half(mat)}; const scalar_type A = rq.compute_bethe_bloch_log_term(mat); const scalar_type running{A - rq.m_beta2 - dhalf}; - return 2. * eps_per_length * running; + return 2.f * eps_per_length * running; } // Function to calculate the Bremsstrahlung energy loss of electron based on @@ -67,7 +67,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type stopping_power{0.}; + scalar_type stopping_power{0.f}; // Only consider electrons and positrons at the moment // For middle-heavy particles muons, the bremss is negligibe @@ -96,7 +96,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type derivative{0.}; + scalar_type derivative{0.f}; // Inelastic collisions with atomic electrons derivative += derive_bethe_bloch(mat, ptc, rq); @@ -117,8 +117,8 @@ struct interaction { // (K/2) * (Z/A) * z^2 / beta^2 * density const scalar_type eps_per_length{rq.compute_epsilon_per_length(mat)}; - if (eps_per_length <= 0.) { - return 0.; + if (eps_per_length <= 0.f) { + return 0.f; } /*----------------------------------------------------------------------- @@ -141,14 +141,14 @@ struct interaction { ------------------------------------------------------------------------*/ const scalar_type first_term = - 2. / (rq.m_qOverP * rq.m_gamma2) * bethe_stopping_power; + 2.f / (rq.m_qOverP * rq.m_gamma2) * bethe_stopping_power; const scalar_type dAdqop = rq.derive_bethe_bloch_log_term(); const scalar_type dBdqop = rq.derive_beta2(); const scalar_type dCdqop = rq.derive_delta_half(mat); const scalar_type second_term = - 2. * eps_per_length * (dAdqop - dBdqop - dCdqop); + 2.f * eps_per_length * (dAdqop - dBdqop - dCdqop); return first_term + second_term; } @@ -158,7 +158,7 @@ struct interaction { const pdg_particle& ptc, const relativistic_quantities& rq) const { - scalar_type derivative{0.}; + scalar_type derivative{0.f}; if (ptc.pdg_num() == electron().pdg_num() || ptc.pdg_num() == positron().pdg_num()) { @@ -189,15 +189,15 @@ struct interaction { const scalar_type I{mat.mean_excitation_energy()}; const scalar_type eps{rq.compute_epsilon(mat, path_segment)}; - if (eps <= 0.) { - return 0.; + if (eps <= 0.f) { + return 0.f; } const scalar_type dhalf{rq.compute_delta_half(mat)}; const scalar_type t{rq.compute_mass_term(constant::m_e)}; // uses RPP2018 eq. 33.11 - const scalar_type running{math::log(t / I) + math::log(eps / I) + 0.2 - - rq.m_beta2 - 2. * dhalf}; + const scalar_type running{math::log(t / I) + math::log(eps / I) + 0.2f - + rq.m_beta2 - 2.f * dhalf}; return eps * running; } @@ -207,7 +207,7 @@ struct interaction { const relativistic_quantities& rq) const { // the Landau-Vavilov fwhm is 4*eps (see RPP2018 fig. 33.7) - return 4. * rq.compute_epsilon(mat, path_segment); + return 4.f * rq.compute_epsilon(mat, path_segment); } DETRAY_HOST_DEVICE scalar_type compute_energy_loss_landau_sigma( @@ -267,30 +267,30 @@ struct interaction { DETRAY_HOST_DEVICE scalar_type theta0Highland(const scalar_type xOverX0, const scalar_type momentumInv, const scalar_type q2OverBeta2) const { - if (xOverX0 <= 0.) { - return 0.; + if (xOverX0 <= 0.f) { + return 0.f; } // RPP2018 eq. 33.15 (treats beta and q² consistenly) const scalar_type t{math::sqrt(xOverX0 * q2OverBeta2)}; // log((x/X0) * (q²/beta²)) = log((sqrt(x/X0) * (q/beta))²) // = 2 * log(sqrt(x/X0) * (q/beta)) - return 13.6 * unit::MeV * momentumInv * t * - (1.0 + 0.038 * 2. * math::log(t)); + return 13.6f * unit::MeV * momentumInv * t * + (1.0f + 0.038f * 2.f * math::log(t)); } /// Multiple scattering theta0 for electrons. DETRAY_HOST_DEVICE scalar_type theta0RossiGreisen(const scalar_type xOverX0, const scalar_type momentumInv, const scalar_type q2OverBeta2) const { - if (xOverX0 <= 0.) { - return 0.; + if (xOverX0 <= 0.f) { + return 0.f; } // TODO add source paper/ resource const scalar_type t{math::sqrt(xOverX0 * q2OverBeta2)}; - return 17.5 * unit::MeV * momentumInv * t * - (1.0 + 0.125 * math::log10(10.0 * xOverX0)); + return 17.5f * unit::MeV * momentumInv * t * + (1.0f + 0.125f * math::log10(10.0f * xOverX0)); } /// Convert Landau full-width-half-maximum to an equivalent Gaussian @@ -304,7 +304,7 @@ struct interaction { /// @todo: Add a unit test for this function DETRAY_HOST_DEVICE scalar_type convert_landau_fwhm_to_gaussian_sigma(const scalar_type fwhm) const { - return 0.5 * constant::inv_sqrt2 * fwhm / + return 0.5f * constant::inv_sqrt2 * fwhm / math::sqrt(constant::ln2); } }; diff --git a/core/include/detray/materials/material.hpp b/core/include/detray/materials/material.hpp index 50af8a88ab..88fb020d30 100644 --- a/core/include/detray/materials/material.hpp +++ b/core/include/detray/materials/material.hpp @@ -131,7 +131,7 @@ struct material { scalar_type mean_excitation_energy() const { if (!m_has_density_effect_data) { // use approximative computation as defined in ATL-SOFT-PUB-2008-003 - return 16. * unit::eV * + return 16.f * unit::eV * math::pow(m_z, static_cast(0.9)); } else { return m_density.get_mean_excitation_energy(); @@ -141,7 +141,7 @@ struct material { DETRAY_HOST_DEVICE constexpr scalar_type fraction() const { if constexpr (ratio::num == 0) { - return 0.; + return 0.f; } else if constexpr (ratio::den == 0) { return detail::invalid_value(); } else { @@ -154,7 +154,7 @@ struct material { DETRAY_HOST std::string to_string() const { std::stringstream strm; - if (m_ar <= 0.) { + if (m_ar <= 0.f) { strm << "vacuum"; return strm.str(); } @@ -225,7 +225,7 @@ struct material { /// @return [mass_density / A] constexpr scalar_type mass_to_molar_density(double ar, double mass_rho) { if (mass_rho == 0.) { - return 0.; + return 0.f; } const double molar_mass{ar * unit::g / unit::mol}; @@ -237,10 +237,10 @@ struct material { // Material properties scalar_type m_x0 = detail::invalid_value(); scalar_type m_l0 = detail::invalid_value(); - scalar_type m_ar = 0.; - scalar_type m_z = 0.; - scalar_type m_mass_rho = 0.; - scalar_type m_molar_rho = 0.; + scalar_type m_ar = 0.f; + scalar_type m_z = 0.f; + scalar_type m_mass_rho = 0.f; + scalar_type m_molar_rho = 0.f; material_state m_state = material_state::e_unknown; detail::density_effect_data m_density = {}; bool m_has_density_effect_data = false; diff --git a/core/include/detray/materials/material_rod.hpp b/core/include/detray/materials/material_rod.hpp index 188d396439..fa36020ffd 100644 --- a/core/include/detray/materials/material_rod.hpp +++ b/core/include/detray/materials/material_rod.hpp @@ -73,13 +73,13 @@ struct material_rod { const scalar_type cos_inc_angle, const scalar_type approach) const { // Assume that is.local[0] is radial distance of line intersector if (math::fabs(approach) > m_radius) { - return 0.; + return 0.f; } - const scalar_type sin_inc_angle_2{1. - cos_inc_angle * cos_inc_angle}; + const scalar_type sin_inc_angle_2{1.f - cos_inc_angle * cos_inc_angle}; - return 2. * math::sqrt((m_radius * m_radius - approach * approach) / - sin_inc_angle_2); + return 2.f * math::sqrt((m_radius * m_radius - approach * approach) / + sin_inc_angle_2); } /// @returns the path segment through the material in X0 diff --git a/core/include/detray/materials/material_slab.hpp b/core/include/detray/materials/material_slab.hpp index 60700ad853..5d910d31cb 100644 --- a/core/include/detray/materials/material_slab.hpp +++ b/core/include/detray/materials/material_slab.hpp @@ -52,8 +52,8 @@ struct material_slab { if (m_thickness <= std::numeric_limits::epsilon() || m_thickness == std::numeric_limits::max() || m_material == vacuum() || - m_material.mass_density() == 0. || - m_material.molar_density() == 0.) { + m_material.mass_density() == 0.f || + m_material.molar_density() == 0.f) { return false; } return true; @@ -76,7 +76,7 @@ struct material_slab { /// /// @param cos_inc_angle cosine of the track incidence angle DETRAY_HOST_DEVICE constexpr scalar_type path_segment( - const scalar_type cos_inc_angle, const scalar_type = 0.) const { + const scalar_type cos_inc_angle, const scalar_type = 0.f) const { return m_thickness / cos_inc_angle; } @@ -84,7 +84,7 @@ struct material_slab { /// /// @param cos_inc_angle cosine of the track incidence angle DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_X0( - const scalar_type cos_inc_angle, const scalar_type = 0.) const { + const scalar_type cos_inc_angle, const scalar_type = 0.f) const { return m_thickness_in_X0 / cos_inc_angle; } @@ -92,7 +92,7 @@ struct material_slab { /// /// @param cos_inc_angle cosine of the track incidence angle DETRAY_HOST_DEVICE constexpr scalar_type path_segment_in_L0( - const scalar_type cos_inc_angle, const scalar_type = 0.) const { + const scalar_type cos_inc_angle, const scalar_type = 0.f) const { return m_thickness_in_L0 / cos_inc_angle; } diff --git a/core/include/detray/materials/mixture.hpp b/core/include/detray/materials/mixture.hpp index b1004e7dbf..7c7d7cd7c3 100644 --- a/core/include/detray/materials/mixture.hpp +++ b/core/include/detray/materials/mixture.hpp @@ -67,7 +67,7 @@ struct mixture return ((M.fraction() / M.X0()) + ...); }; this->set_X0( - 1. / std::apply(sum_rho_over_X0, std::tuple())); + 1.f / std::apply(sum_rho_over_X0, std::tuple())); // Compute effective nuclear radiation length // Follow the same equation of effective X0 @@ -77,7 +77,7 @@ struct mixture }; this->set_L0( - 1. / std::apply(sum_rho_over_L0, std::tuple())); + 1.f / std::apply(sum_rho_over_L0, std::tuple())); // Compute molar density this->set_molar_density( diff --git a/core/include/detray/materials/predefined_materials.hpp b/core/include/detray/materials/predefined_materials.hpp index 5c1a316e36..6640e17129 100644 --- a/core/include/detray/materials/predefined_materials.hpp +++ b/core/include/detray/materials/predefined_materials.hpp @@ -28,141 +28,143 @@ namespace detray { */ // Vacuum DETRAY_DECLARE_MATERIAL(vacuum, std::numeric_limits::max(), - std::numeric_limits::max(), 0., 0., 0., + std::numeric_limits::max(), 0.f, 0.f, 0.f, material_state::e_unknown); // H₂ (1): Hydrogen Gas DETRAY_DECLARE_MATERIAL(hydrogen_gas, 7.526E3f * unit::m, - 6.209E3f * unit::m, 2. * 1.008, 2. * 1., + 6.209E3f * unit::m, 2.f * 1.008f, 2.f * 1.f, static_cast(8.376E-5 * unit::g / unit::cm3), material_state::e_gas); // H₂ (1): Hydrogen Liquid -DETRAY_DECLARE_MATERIAL(hydrogen_liquid, 8.904 * unit::m, - 7.346 * unit::m, 2. * 1.008, 2. * 1., - static_cast(0.07080 * unit::g / +DETRAY_DECLARE_MATERIAL(hydrogen_liquid, 8.904f * unit::m, + 7.346f * unit::m, 2.f * 1.008f, 2.f * 1.f, + static_cast(0.07080f * unit::g / unit::cm3), material_state::e_liquid); // He (2): Helium Gas DETRAY_DECLARE_MATERIAL(helium_gas, 5.671E3f * unit::m, - 4.269E3f * unit::m, 4.003, 2., + 4.269E3f * unit::m, 4.003f, 2.f, static_cast(1.663E-4 * unit::g / unit::cm3), material_state::e_gas); // Be (4) -DETRAY_DECLARE_MATERIAL(beryllium, 352.8 * unit::mm, - 421.0 * unit::mm, 9.012, 4., +DETRAY_DECLARE_MATERIAL(beryllium, 352.8f * unit::mm, + 421.0f * unit::mm, 9.012f, 4.f, static_cast(1.848 * unit::g / unit::cm3), material_state::e_solid); // C (6): Carbon (amorphous) -DETRAY_DECLARE_MATERIAL(carbon_gas, 213.5 * unit::mm, - 429.0 * unit::mm, 12.01, 6., +DETRAY_DECLARE_MATERIAL(carbon_gas, 213.5f * unit::mm, + 429.0f * unit::mm, 12.01f, 6.f, static_cast(2.0 * unit::g / unit::cm3), material_state::e_gas); // N₂ (7): Nitrogen Gas -DETRAY_DECLARE_MATERIAL(nitrogen_gas, 3.260E+02 * unit::m, - 7.696E+02 * unit::m, 2. * 14.007, 2. * 7., +DETRAY_DECLARE_MATERIAL(nitrogen_gas, 3.260E+02f * unit::m, + 7.696E+02f * unit::m, 2.f * 14.007f, + 2.f * 7.f, static_cast(1.165E-03 * unit::g / unit::cm3), material_state::e_gas); // O₂ (8): Oxygen Gas -DETRAY_DECLARE_MATERIAL(oxygen_gas, 2.571E+02 * unit::m, - 6.772E+02 * unit::m, 2. * 15.999, 2. * 8., +DETRAY_DECLARE_MATERIAL(oxygen_gas, 2.571E+02f * unit::m, + 6.772E+02f * unit::m, 2.f * 15.999f, + 2.f * 8.f, static_cast(1.332E-3 * unit::g / unit::cm3), material_state::e_gas); // O₂ (8): Oxygen liquid -DETRAY_DECLARE_MATERIAL(oxygen_liquid, 300.1 * unit::mm, - 790.3 * unit::mm, 2. * 15.999, 2. * 8., +DETRAY_DECLARE_MATERIAL(oxygen_liquid, 300.1f * unit::mm, + 790.3f * unit::mm, 2.f * 15.999f, 2.f * 8.f, static_cast(1.141 * unit::g / unit::cm3), material_state::e_liquid); // Al (13) -DETRAY_DECLARE_MATERIAL(aluminium, 88.97 * unit::mm, - 397.0 * unit::mm, 26.98, 13., +DETRAY_DECLARE_MATERIAL(aluminium, 88.97f * unit::mm, + 397.0f * unit::mm, 26.98f, 13.f, static_cast(2.699 * unit::g / unit::cm3), material_state::e_solid); // Si (14) -DETRAY_DECLARE_MATERIAL(silicon, 93.7 * unit::mm, - 465.2 * unit::mm, 28.0855, 14., +DETRAY_DECLARE_MATERIAL(silicon, 93.7f * unit::mm, + 465.2f * unit::mm, 28.0855f, 14.f, static_cast(2.329 * unit::g / unit::cm3), material_state::e_solid); // Si (14) with density effect data -DETRAY_DECLARE_MATERIAL_WITH_DED(silicon_with_ded, 93.7 * unit::mm, - 465.2 * unit::mm, 28.0855, 14., +DETRAY_DECLARE_MATERIAL_WITH_DED(silicon_with_ded, 93.7f * unit::mm, + 465.2f * unit::mm, 28.0855f, 14.f, static_cast(2.329 * unit::g / unit::cm3), - material_state::e_solid, 0.1492, 3.2546, - 0.2015, 2.8716, 173.0, 4.4355, 0.14); + material_state::e_solid, 0.1492f, 3.2546f, + 0.2015f, 2.8716f, 173.0f, 4.4355f, 0.14f); // Ar (18): Argon gas -DETRAY_DECLARE_MATERIAL(argon_gas, 1.176E+02 * unit::m, - 7.204E+02 * unit::m, 39.948, 18., +DETRAY_DECLARE_MATERIAL(argon_gas, 1.176E+02f * unit::m, + 7.204E+02f * unit::m, 39.948f, 18.f, static_cast(1.662E-03 * unit::g / unit::cm3), material_state::e_gas); // Ar (18): Argon liquid -DETRAY_DECLARE_MATERIAL(argon_liquid, 14. * unit::cm, - 85.77 * unit::cm, 39.948, 18., +DETRAY_DECLARE_MATERIAL(argon_liquid, 14.f * unit::cm, + 85.77f * unit::cm, 39.948f, 18.f, static_cast(1.396 * unit::g / unit::cm3), material_state::e_liquid); // Fe (26) -DETRAY_DECLARE_MATERIAL(iron, 1.757 * unit::cm, - 16.77 * unit::cm, 55.845, 26., +DETRAY_DECLARE_MATERIAL(iron, 1.757f * unit::cm, + 16.77f * unit::cm, 55.845f, 26.f, static_cast(7.874 * unit::g / unit::cm3), material_state::e_solid); // Fe (26) with density effect data -DETRAY_DECLARE_MATERIAL_WITH_DED(iron_with_ded, 1.757 * unit::cm, - 16.77 * unit::cm, 55.845, 26., +DETRAY_DECLARE_MATERIAL_WITH_DED(iron_with_ded, 1.757f * unit::cm, + 16.77f * unit::cm, 55.845f, 26.f, static_cast(7.874 * unit::g / unit::cm3), - material_state::e_solid, 0.14680, 2.9632, - -0.0012, 3.1531, 286.0, 4.2911, 0.12); + material_state::e_solid, 0.14680f, 2.9632f, + -0.0012f, 3.1531f, 286.0f, 4.2911f, 0.12f); // Copper (29) -DETRAY_DECLARE_MATERIAL(copper, 1.436 * unit::cm, - 15.32 * unit::cm, 63.546, 29., +DETRAY_DECLARE_MATERIAL(copper, 1.436f * unit::cm, + 15.32f * unit::cm, 63.546f, 29.f, static_cast(8.960 * unit::g / unit::cm3), material_state::e_solid); // Copper (29) with density effect data -DETRAY_DECLARE_MATERIAL_WITH_DED(copper_with_ded, 1.436 * unit::cm, - 15.32 * unit::cm, 63.546, 29., +DETRAY_DECLARE_MATERIAL_WITH_DED(copper_with_ded, 1.436f * unit::cm, + 15.32f * unit::cm, 63.546f, 29.f, static_cast(8.960 * unit::g / unit::cm3), - material_state::e_solid, 0.14339, 2.9044, - -0.0254, 3.2792, 322.0, 4.4190, 0.08); + material_state::e_solid, 0.14339f, 2.9044f, + -0.0254f, 3.2792f, 322.0f, 4.4190f, 0.08f); // W (74) -DETRAY_DECLARE_MATERIAL(tungsten, 3.504 * unit::mm, - 99.46 * unit::mm, 183.84, 74., +DETRAY_DECLARE_MATERIAL(tungsten, 3.504f * unit::mm, + 99.46f * unit::mm, 183.84f, 74.f, static_cast(19.3 * unit::g / unit::cm3), material_state::e_solid); // Au (79) -DETRAY_DECLARE_MATERIAL(gold, 3.344 * unit::mm, - 101.6 * unit::mm, 196.97, 79., +DETRAY_DECLARE_MATERIAL(gold, 3.344f * unit::mm, + 101.6f * unit::mm, 196.97f, 79.f, static_cast(19.32 * unit::g / unit::cm3), material_state::e_solid); @@ -173,15 +175,15 @@ DETRAY_DECLARE_MATERIAL(gold, 3.344 * unit::mm, */ // Be (4) -DETRAY_DECLARE_MATERIAL(beryllium_tml, 352.8 * unit::mm, - 407. * unit::mm, 9.012, 4., +DETRAY_DECLARE_MATERIAL(beryllium_tml, 352.8f * unit::mm, + 407.f * unit::mm, 9.012f, 4.f, static_cast(1.848 * unit::g / unit::cm3), material_state::e_solid); // Si (14) -DETRAY_DECLARE_MATERIAL(silicon_tml, 95.7 * unit::mm, - 465.2 * unit::mm, 28.03, 14., +DETRAY_DECLARE_MATERIAL(silicon_tml, 95.7f * unit::mm, + 465.2f * unit::mm, 28.03f, 14.f, static_cast(2.32 * unit::g / unit::cm3), material_state::e_solid); @@ -194,8 +196,8 @@ DETRAY_DECLARE_MATERIAL(silicon_tml, 95.7 * unit::mm, // @note: // https://pdg.lbl.gov/2020/AtomicNuclearProperties/HTML/air_dry_1_atm.html // @note: Ar from Wikipedia (https://en.wikipedia.org/wiki/Molar_mass) -DETRAY_DECLARE_MATERIAL(air, 3.039E+02 * unit::m, - 7.477E+02 * unit::m, 28.97, 14.46, +DETRAY_DECLARE_MATERIAL(air, 3.039E+02f * unit::m, + 7.477E+02f * unit::m, 28.97f, 14.46f, static_cast(1.205E-03 * unit::g / unit::cm3), material_state::e_gas); @@ -206,8 +208,8 @@ DETRAY_DECLARE_MATERIAL(air, 3.039E+02 * unit::m, // @note: Z was caculated by simply summing the number of atoms. Surprisingly // it seems the right value because Z/A is 0.58496, which is the same with // in the pdg refernce -DETRAY_DECLARE_MATERIAL(isobutane, 1693E+02 * unit::mm, - 288.3 * unit::mm, 58.124, 34., +DETRAY_DECLARE_MATERIAL(isobutane, 1693E+02f * unit::mm, + 288.3f * unit::mm, 58.124f, 34.f, static_cast(2.67 * unit::g / unit::cm3), material_state::e_gas); @@ -216,26 +218,25 @@ DETRAY_DECLARE_MATERIAL(isobutane, 1693E+02 * unit::mm, // @note: (X0, L0, mass_rho) from // https://pdg.lbl.gov/2020/AtomicNuclearProperties/HTML/propane.html // @note: Ar from Wikipedia (https://en.wikipedia.org/wiki/Propane) -DETRAY_DECLARE_MATERIAL(propane, 2.429E+02 * unit::m, - 4.106E+02 * unit::m, 44.097, 26., +DETRAY_DECLARE_MATERIAL(propane, 2.429E+02f * unit::m, + 4.106E+02f * unit::m, 44.097f, 26.f, static_cast(1.868E-03 * unit::g / unit::cm3), material_state::e_gas); // Cesium Iodide (CsI) // https://pdg.lbl.gov/2023/AtomicNuclearProperties/HTML/cesium_iodide_CsI.html -DETRAY_DECLARE_MATERIAL(cesium_iodide, 1.86 * unit::cm, - 38.04 * unit::cm, 259.81, 108., - static_cast(4.510 * unit::g / +DETRAY_DECLARE_MATERIAL(cesium_iodide, 1.86f * unit::cm, + 38.04f * unit::cm, 259.81f, 108.f, + static_cast(4.510f * unit::g / unit::cm3), material_state::e_solid); -DETRAY_DECLARE_MATERIAL_WITH_DED(cesium_iodide_with_ded, - 1.86 * unit::cm, - 38.04 * unit::cm, 259.81, 108., - static_cast(4.510 * unit::g / - unit::cm3), - material_state::e_solid, 0.25381, 2.6657, - 0.0395, 3.3353, 553.1, 6.2807, 0.00); +DETRAY_DECLARE_MATERIAL_WITH_DED( + cesium_iodide_with_ded, 1.86f * unit::cm, + 38.04f * unit::cm, 259.81f, 108.f, + static_cast(4.510f * unit::g / unit::cm3), + material_state::e_solid, 0.25381f, 2.6657f, 0.0395f, 3.3353f, 553.1f, + 6.2807f, 0.00f); } // namespace detray diff --git a/core/include/detray/navigation/direct_navigator.hpp b/core/include/detray/navigation/direct_navigator.hpp index cc3938a5d5..4db67b22d8 100644 --- a/core/include/detray/navigation/direct_navigator.hpp +++ b/core/include/detray/navigation/direct_navigator.hpp @@ -278,7 +278,7 @@ class direct_navigator { navigation::status m_status{navigation::status::e_unknown}; /// Step size when the valid intersection is not found for the target - scalar_type safe_step_size = 10. * unit::mm; + scalar_type safe_step_size = 10.f * unit::mm; /// Heartbeat of this navigation flow signals navigation is alive bool m_heartbeat{false}; diff --git a/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp b/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp index d06a6e32c8..9c6c72b7e9 100644 --- a/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp +++ b/core/include/detray/navigation/intersection/bounding_box/cuboid_intersector.hpp @@ -37,7 +37,7 @@ struct cuboid_intersector { template DETRAY_HOST_DEVICE bool operator()( const detail::ray &ray, const mask_t &box, - const dscalar /*mask_tolerance*/ = 0.) const { + const dscalar /*mask_tolerance*/ = 0.f) const { using scalar_type = dscalar; using point3_type = dpoint3D; @@ -48,9 +48,9 @@ struct cuboid_intersector { const vector3_type &rd = ray.dir(); // @TODO: put vector-vector operator/ in algebra-plugins constexpr scalar_type inv{detail::invalid_value()}; - const vector3_type inv_dir{rd[0] == 0. ? inv : 1. / rd[0], - rd[1] == 0. ? inv : 1. / rd[1], - rd[2] == 0. ? inv : 1. / rd[2]}; + const vector3_type inv_dir{rd[0] == 0.f ? inv : 1.f / rd[0], + rd[1] == 0.f ? inv : 1.f / rd[1], + rd[2] == 0.f ? inv : 1.f / rd[2]}; // This is prob. slow -> @todo refactor masks to hold custom mask values const vector3_type min{box[boundaries::e_min_x], diff --git a/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp index 4d168c3759..9c366e217c 100644 --- a/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_cylinder_intersector.hpp @@ -67,7 +67,7 @@ struct helix_intersector_impl, algebra_t> const darray mask_tolerance = {detail::invalid_value(), detail::invalid_value()}, - const scalar_type = 0., const scalar_type = 0.) const { + const scalar_type = 0.f, const scalar_type = 0.f) const { assert((mask_tolerance[0] == mask_tolerance[1]) && "Helix intersectors use only one mask tolerance value"); @@ -89,7 +89,7 @@ struct helix_intersector_impl, algebra_t> // Try to guess the best starting positions for the iteration // Direction of the track at the helix origin - const auto h_dir = h.dir(0.); + const auto h_dir = h.dir(0.f); // Default starting path length for the Newton iteration (assumes // concentric cylinder) const scalar_type default_s{r * vector::perp(h_dir)}; @@ -135,7 +135,7 @@ struct helix_intersector_impl, algebra_t> intersection_type &sfi = ret[i]; // Path length in the previous iteration step - scalar_type s_prev{0.}; + scalar_type s_prev{0.f}; // f(s) = ((h.pos(s) - sc) x sz)^2 - r^2 == 0 // Run the iteration on s @@ -146,10 +146,10 @@ struct helix_intersector_impl, algebra_t> // f'(s) = 2 * ( (h.pos(s) - sc) x sz) * (h.dir(s) x sz) ) const vector3_type crp = vector::cross(h.pos(s) - sc, sz); const scalar_type denom{ - 2. * vector::dot(crp, vector::cross(h.dir(s), sz))}; + 2.f * vector::dot(crp, vector::cross(h.dir(s), sz))}; // No intersection can be found if dividing by zero - if (denom == 0.) { + if (denom == 0.f) { return ret; } @@ -176,7 +176,7 @@ struct helix_intersector_impl, algebra_t> // Due to floating point errors this can be negative if // cos ~ 1 const scalar_type sin_inc2{math::fabs( - 1. - cos_incidence_angle * cos_incidence_angle)}; + 1.f - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -201,7 +201,7 @@ struct helix_intersector_impl, algebra_t> // Try to guess the best starting positions for the iteration // Direction of the track at the helix origin - const auto h_dir = h.dir(0.5 * r); + const auto h_dir = h.dir(0.5f * r); // Default starting path length for the Newton iteration (assumes // concentric cylinder) const scalar_type default_s{r * vector::perp(h_dir)}; @@ -247,7 +247,7 @@ struct helix_intersector_impl, algebra_t> const scalar_type f_s{(vector::dot(crp, crp) - r * r)}; // f'(s) = 2 * ( (h.pos(s) - sc) x sz) * (h.dir(s) x sz) ) const scalar_type df_s{ - 2. * vector::dot(crp, vector::cross(h.dir(x), sz))}; + 2.f * vector::dot(crp, vector::cross(h.dir(x), sz))}; return std::make_tuple(f_s, df_s); }; @@ -276,18 +276,18 @@ struct helix_intersector_impl, algebra_t> DETRAY_HOST_DEVICE inline darray, 2> operator()(const helix_type &h, const surface_descr_t &sf_desc, const mask_t &mask, const transform3_type &trf, - const scalar_type mask_tolerance, const scalar_type = 0., - const scalar_type = 0.) const { + const scalar_type mask_tolerance, const scalar_type = 0.f, + const scalar_type = 0.f) const { return this->operator()(h, sf_desc, mask, trf, - {mask_tolerance, mask_tolerance}, 0.); + {mask_tolerance, mask_tolerance}, 0.f); } /// Tolerance for convergence - scalar_type convergence_tolerance{1. * unit::um}; + scalar_type convergence_tolerance{1.f * unit::um}; // Guard against inifinite loops std::size_t max_n_tries{1000u}; // Early exit, if the intersection is too far away - scalar_type max_path{5. * unit::m}; + scalar_type max_path{5.f * unit::m}; // Complement the Newton algorithm with Bisection steps bool run_rtsafe{true}; }; diff --git a/core/include/detray/navigation/intersection/helix_line_intersector.hpp b/core/include/detray/navigation/intersection/helix_line_intersector.hpp index 3c016972fb..8bcffb7c28 100644 --- a/core/include/detray/navigation/intersection/helix_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_line_intersector.hpp @@ -61,7 +61,7 @@ struct helix_intersector_impl, algebra_t> { const darray mask_tolerance = {detail::invalid_value(), detail::invalid_value()}, - const scalar_type = 0., const scalar_type = 0.) const { + const scalar_type = 0.f, const scalar_type = 0.f) const { assert((mask_tolerance[0] == mask_tolerance[1]) && "Helix intersectors use only one mask tolerance value"); @@ -76,20 +76,20 @@ struct helix_intersector_impl, algebra_t> { const point3_type c = trf.translation(); // initial track direction - const vector3_type t0 = h.dir(0.); + const vector3_type t0 = h.dir(0.f); // initial track position - const point3_type r0 = h.pos(0.); + const point3_type r0 = h.pos(0.f); // Projection of line to track direction const scalar_type lt0{vector::dot(l, t0)}; - const scalar_type denom{1. - (lt0 * lt0)}; + const scalar_type denom{1.f - (lt0 * lt0)}; // Case for wire is parallel to track // @NOTE We might not have to call this which is meant to be for ray // intersection... - if (denom < 1e-5) { + if (denom < 1e-5f) { sfi.status = false; return sfi; } @@ -106,8 +106,8 @@ struct helix_intersector_impl, algebra_t> { // Path length to the point of closest approach on the track // @NOTE Ray intersection algorithm is used for the initial guess on // the path length - scalar_type s{1. / denom * (Q - P * lt0)}; - scalar_type s_prev{0.}; + scalar_type s{1.f / denom * (Q - P * lt0)}; + scalar_type s_prev{0.f}; // Run the iteration on s std::size_t n_tries{0u}; @@ -160,8 +160,8 @@ struct helix_intersector_impl, algebra_t> { scalar_type tol{mask_tolerance[1]}; if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 - const scalar_type sin_inc2{ - math::fabs(1. - cos_incidence_angle * cos_incidence_angle)}; + const scalar_type sin_inc2{math::fabs( + 1.f - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -179,20 +179,20 @@ struct helix_intersector_impl, algebra_t> { const point3_type c = trf.translation(); // initial track direction - const vector3_type t0 = h.dir(0.); + const vector3_type t0 = h.dir(0.f); // initial track position - const point3_type r0 = h.pos(0.); + const point3_type r0 = h.pos(0.f); // Projection of line to track direction const scalar_type lt0{vector::dot(l, t0)}; - const scalar_type denom{1. - (lt0 * lt0)}; + const scalar_type denom{1.f - (lt0 * lt0)}; // Case for wire is parallel to track // @NOTE We might not have to call this which is meant to be for ray // intersection... - if (denom < 1e-5) { + if (denom < 1e-5f) { #ifndef NDEBUG std::cout << "ERROR: Helix line intersector encountered " "invalid value!" @@ -214,7 +214,7 @@ struct helix_intersector_impl, algebra_t> { // Path length to the point of closest approach on the track // @NOTE Ray intersection algorithm is used for the initial guess on // the path length - scalar_type s_ini{1. / denom * (Q - P * lt0)}; + scalar_type s_ini{1.f / denom * (Q - P * lt0)}; /// Evaluate the function and its derivative at the point @param x auto line_inters_func = [&h, &c, &l](const scalar_type x) { @@ -265,17 +265,17 @@ struct helix_intersector_impl, algebra_t> { DETRAY_HOST_DEVICE inline intersection_type operator()( const helix_type &h, const surface_descr_t &sf_desc, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type = 0., const scalar_type = 0.) const { + const scalar_type = 0.f, const scalar_type = 0.f) const { return this->operator()(h, sf_desc, mask, trf, - {mask_tolerance, mask_tolerance}, 0.); + {mask_tolerance, mask_tolerance}, 0.f); } /// Tolerance for convergence - scalar_type convergence_tolerance{1. * unit::um}; + scalar_type convergence_tolerance{1.f * unit::um}; // Guard against inifinite loops std::size_t max_n_tries{1000u}; // Early exit, if the intersection is too far away - scalar_type max_path{5. * unit::m}; + scalar_type max_path{5.f * unit::m}; // Complement the Newton algorithm with Bisection steps bool run_rtsafe{true}; }; diff --git a/core/include/detray/navigation/intersection/helix_plane_intersector.hpp b/core/include/detray/navigation/intersection/helix_plane_intersector.hpp index e233a4fb52..d81928dde9 100644 --- a/core/include/detray/navigation/intersection/helix_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/helix_plane_intersector.hpp @@ -63,7 +63,7 @@ struct helix_intersector_impl, algebra_t> { const darray mask_tolerance = {detail::invalid_value(), detail::invalid_value()}, - const scalar_type = 0., const scalar_type = 0.) const { + const scalar_type = 0.f, const scalar_type = 0.f) const { assert((mask_tolerance[0] == mask_tolerance[1]) && "Helix intersectors use only one mask tolerance value"); @@ -80,16 +80,16 @@ struct helix_intersector_impl, algebra_t> { // Starting point on the helix for the Newton iteration const vector3_type dist{trf.point_to_global(mask.centroid()) - - h.pos(0.)}; - scalar_type denom{vector::dot(sn, h.dir(0.))}; + h.pos(0.f)}; + scalar_type denom{vector::dot(sn, h.dir(0.f))}; scalar_type s; - if (denom == 0.) { + if (denom == 0.f) { s = vector::norm(dist); } s = math::fabs(vector::dot(sn, dist) / denom); - scalar_type s_prev{0.}; + scalar_type s_prev{0.f}; // f(s) = sn * (h.pos(s) - st) == 0 // Run the iteration on s @@ -99,7 +99,7 @@ struct helix_intersector_impl, algebra_t> { // f'(s) = sn * h.dir(s) denom = vector::dot(sn, h.dir(s)); // No intersection can be found if dividing by zero - if (denom == 0.) { + if (denom == 0.f) { return sfi; } // x_n+1 = x_n - f(s) / f'(s) @@ -121,8 +121,8 @@ struct helix_intersector_impl, algebra_t> { scalar_type tol{mask_tolerance[1]}; if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 - const scalar_type sin_inc2{ - math::fabs(1. - cos_incidence_angle * cos_incidence_angle)}; + const scalar_type sin_inc2{math::fabs( + 1.f - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs((s - s_prev) * math::sqrt(sin_inc2)); } @@ -140,10 +140,11 @@ struct helix_intersector_impl, algebra_t> { // Starting point on the helix for the Newton iteration const vector3_type dist{trf.point_to_global(mask.centroid()) - - h.pos(0.)}; - scalar_type denom{vector::dot(sn, h.dir(0.5 * vector::norm(dist)))}; + h.pos(0.f)}; + scalar_type denom{ + vector::dot(sn, h.dir(0.5f * vector::norm(dist)))}; scalar_type s_ini; - if (denom == 0.) { + if (denom == 0.f) { s_ini = vector::norm(dist); } else { s_ini = vector::dot(sn, dist) / denom; @@ -177,17 +178,17 @@ struct helix_intersector_impl, algebra_t> { DETRAY_HOST_DEVICE inline intersection_type operator()( const helix_type &h, const surface_descr_t &sf_desc, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type = 0., const scalar_type = 0.) const { + const scalar_type = 0.f, const scalar_type = 0.f) const { return this->operator()(h, sf_desc, mask, trf, - {mask_tolerance, mask_tolerance}, 0.); + {mask_tolerance, mask_tolerance}, 0.f); } /// Tolerance for convergence - scalar_type convergence_tolerance{1. * unit::um}; + scalar_type convergence_tolerance{1.f * unit::um}; // Guard against inifinite loops std::size_t max_n_tries{1000u}; // Early exit, if the intersection is too far away - scalar_type max_path{5. * unit::m}; + scalar_type max_path{5.f * unit::m}; // Complement the Newton algorithm with Bisection steps bool run_rtsafe{true}; }; diff --git a/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp index c36d1f040b..4ffeefffe2 100644 --- a/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_concentric_cylinder_intersector.hpp @@ -60,9 +60,9 @@ struct ray_concentric_cylinder_intersector { const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type & /*trf*/, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -74,20 +74,20 @@ struct ray_concentric_cylinder_intersector { const point3_type l1 = ro + rd; // swap coorinates x/y for numerical stability - const bool swap_x_y = math::fabs(rd[0]) < 1e-3; + const bool swap_x_y = math::fabs(rd[0]) < 1e-3f; unsigned int _x = swap_x_y ? 1u : 0u; unsigned int _y = swap_x_y ? 0u : 1u; const scalar_type k{(l0[_y] - l1[_y]) / (l0[_x] - l1[_x])}; const scalar_type d{l1[_y] - k * l1[_x]}; - detail::quadratic_equation qe{(1. + k * k), 2. * k * d, + detail::quadratic_equation qe{(1.f + k * k), 2.f * k * d, d * d - r * r}; if (qe.solutions() > 0) { const scalar_type overstep_tolerance{overstep_tol}; darray candidates; - darray t01 = {0., 0.}; + darray t01 = {0.f, 0.f}; candidates[0][_x] = qe.smaller(); candidates[0][_y] = k * qe.smaller() + d; @@ -138,8 +138,8 @@ struct ray_concentric_cylinder_intersector { DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., + const scalar_type overstep_tol = 0.f) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, overstep_tol); } @@ -159,9 +159,9 @@ struct ray_concentric_cylinder_intersector { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol)[0]; } diff --git a/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp b/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp index ff5544e756..daacbe698f 100644 --- a/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_cylinder_portal_intersector.hpp @@ -69,9 +69,9 @@ struct ray_intersector_impl, algebra_t, const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -105,8 +105,8 @@ struct ray_intersector_impl, algebra_t, DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., + const scalar_type overstep_tol = 0.f) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, overstep_tol); } @@ -125,9 +125,9 @@ struct ray_intersector_impl, algebra_t, const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection/ray_line_intersector.hpp b/core/include/detray/navigation/intersection/ray_line_intersector.hpp index d1f10dbe86..0e37ec909e 100644 --- a/core/include/detray/navigation/intersection/ray_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/ray_line_intersector.hpp @@ -56,9 +56,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -77,10 +77,10 @@ struct ray_intersector_impl, algebra_t, do_debug> { // Projection of line to track direction const scalar_type zd{vector::dot(_z, _d)}; - const scalar_type denom{1. - (zd * zd)}; + const scalar_type denom{1.f - (zd * zd)}; // Case for wire is parallel to track - if (denom < 1e-5) { + if (denom < 1e-5f) { is.status = false; return is; } @@ -95,7 +95,7 @@ struct ray_intersector_impl, algebra_t, do_debug> { const scalar_type t2l_on_track{vector::dot(t2l, _d)}; // path length to the point of closest approach on the track - const scalar_type A{1. / denom * (t2l_on_track - t2l_on_line * zd)}; + const scalar_type A{1.f / denom * (t2l_on_track - t2l_on_line * zd)}; is.path = A; // Intersection is not valid for navigation - return early @@ -126,8 +126,8 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const ray_type &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const scalar_type mask_tolerance, - const scalar_type overstep_tol = 0.) const { - return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.}, 0., + const scalar_type overstep_tol = 0.f) const { + return this->operator()(ray, sf, mask, trf, {mask_tolerance, 0.f}, 0.f, overstep_tol); } @@ -146,9 +146,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const ray_type &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, const darray &mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); diff --git a/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp index dcd6d7ae15..f9df43d634 100644 --- a/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_cylinder_intersector.hpp @@ -59,9 +59,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { operator()(const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); @@ -98,15 +98,15 @@ struct ray_intersector_impl, algebra_t, do_debug> { const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { // One or both of these solutions might be invalid const auto qe = solve_intersection(ray, mask, trf); // Construct the candidate only when needed - sfi.status = (qe.solutions() > 0.); + sfi.status = (qe.solutions() > 0.f); if (detray::detail::none_of(sfi.status)) { return; @@ -141,7 +141,7 @@ struct ray_intersector_impl, algebra_t, do_debug> { const auto pc_cross_sz = vector::cross(tmp, sz); const auto rd_cross_sz = vector::cross(rd, sz); const scalar_type a = vector::dot(rd_cross_sz, rd_cross_sz); - const scalar_type b = 2. * vector::dot(rd_cross_sz, pc_cross_sz); + const scalar_type b = 2.f * vector::dot(rd_cross_sz, pc_cross_sz); const scalar_type c = vector::dot(pc_cross_sz, pc_cross_sz) - (r * r); return detail::quadratic_equation{a, b, c}; @@ -159,9 +159,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { build_candidate(const detail::ray &ray, const mask_t &mask, const transform3_type &trf, const scalar_type path, const darray &mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; diff --git a/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp index a34b383d24..544f06d20e 100644 --- a/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_cylinder_portal_intersector.hpp @@ -61,9 +61,9 @@ struct ray_intersector_impl, algebra_t, DETRAY_HOST_DEVICE inline intersection_type operator()( const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -81,7 +81,7 @@ struct ray_intersector_impl, algebra_t, // Only the closest intersection that is outside the overstepping // tolerance is needed const auto valid_smaller = (qe.smaller() > overstep_tol); - scalar_type t = 0.; + scalar_type t = 0.f; t(valid_smaller) = qe.smaller(); t(!valid_smaller) = qe.larger(); @@ -107,9 +107,9 @@ struct ray_intersector_impl, algebra_t, const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp index ecf84c7583..6b26cfadd5 100644 --- a/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_line_intersector.hpp @@ -56,9 +56,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -77,10 +77,10 @@ struct ray_intersector_impl, algebra_t, do_debug> { // Projection of line to track direction const scalar_type zd = vector::dot(sz, rd); - const scalar_type denom = 1. - (zd * zd); + const scalar_type denom = 1.f - (zd * zd); // Case for wire is parallel to track - if (detray::detail::all_of(denom < 1e-5)) { + if (detray::detail::all_of(denom < 1e-5f)) { is.status = decltype(is.status)(false); return is; } @@ -138,9 +138,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp b/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp index 82363cc417..41907f2c81 100644 --- a/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp +++ b/core/include/detray/navigation/intersection/soa/ray_plane_intersector.hpp @@ -57,9 +57,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { DETRAY_HOST_DEVICE inline intersection_type operator()( const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { intersection_type is; @@ -126,9 +126,9 @@ struct ray_intersector_impl, algebra_t, do_debug> { const detail::ray &ray, intersection_type &sfi, const mask_t &mask, const transform3_type &trf, - const darray &mask_tolerance = {0., 1.}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, 1.f}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { sfi = this->operator()(ray, sfi.sf_desc, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); } diff --git a/core/include/detray/navigation/intersection_kernel.hpp b/core/include/detray/navigation/intersection_kernel.hpp index ac0576202d..b1d756d89d 100644 --- a/core/include/detray/navigation/intersection_kernel.hpp +++ b/core/include/detray/navigation/intersection_kernel.hpp @@ -48,10 +48,10 @@ struct intersection_initialize { const surface_t &surface, const transform_container_t &contextual_transforms, const typename transform_container_t::context_type &ctx, - const darray &mask_tolerance = {0., - 1. * unit::mm}, - const scalar_t mask_tol_scalor = 0., - const scalar_t overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, + 1.f * unit::mm}, + const scalar_t mask_tol_scalor = 0.f, + const scalar_t overstep_tol = 0.f) const { using mask_t = typename mask_group_t::value_type; using algebra_t = typename mask_t::algebra_type; @@ -140,10 +140,10 @@ struct intersection_update { const traj_t &traj, intersection_t &sfi, const transform_container_t &contextual_transforms, const typename transform_container_t::context_type &ctx, - const darray &mask_tolerance = {0., - 1. * unit::mm}, - const scalar_t mask_tol_scalor = 0., - const scalar_t overstep_tol = 0.) const { + const darray &mask_tolerance = {0.f, + 1.f * unit::mm}, + const scalar_t mask_tol_scalor = 0.f, + const scalar_t overstep_tol = 0.f) const { using mask_t = typename mask_group_t::value_type; using algebra_t = typename mask_t::algebra_type; diff --git a/core/include/detray/navigation/intersector.hpp b/core/include/detray/navigation/intersector.hpp index 34dd2a7c39..400511071d 100644 --- a/core/include/detray/navigation/intersector.hpp +++ b/core/include/detray/navigation/intersector.hpp @@ -43,9 +43,9 @@ struct intersector { const detail::ray &ray, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type mask_tol_scalor = 0., - const scalar_type overstep_tol = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type mask_tol_scalor = 0.f, + const scalar_type overstep_tol = 0.f) const { return ray_intersector_type{}(ray, sf, mask, trf, mask_tolerance, mask_tol_scalor, overstep_tol); @@ -57,8 +57,8 @@ struct intersector { const detail::helix &h, const surface_descr_t &sf, const mask_t &mask, const transform3_type &trf, const darray mask_tolerance = - {0., 1. * unit::mm}, - const scalar_type = 0., const scalar_type = 0.) const { + {0.f, 1.f * unit::mm}, + const scalar_type = 0.f, const scalar_type = 0.f) const { return helix_intersector_type{}(h, sf, mask, trf, mask_tolerance); } diff --git a/core/include/detray/navigation/navigator.hpp b/core/include/detray/navigation/navigator.hpp index 69b4fd4685..dee1b37a44 100644 --- a/core/include/detray/navigation/navigator.hpp +++ b/core/include/detray/navigation/navigator.hpp @@ -397,8 +397,8 @@ class navigator { m_heartbeat = false; // Don't do anything if aborted m_trust_level = navigation::trust_level::e_full; - run_inspector({}, point3_type{0., 0., 0.}, vector3_type{0., 0., 0.}, - "Aborted: "); + run_inspector({}, point3_type{0.f, 0.f, 0.f}, + vector3_type{0.f, 0.f, 0.f}, "Aborted: "); return m_heartbeat; } @@ -411,8 +411,8 @@ class navigator { m_status = navigation::status::e_on_target; m_heartbeat = false; m_trust_level = navigation::trust_level::e_full; - run_inspector({}, point3_type{0., 0., 0.}, vector3_type{0., 0., 0.}, - "Exited: "); + run_inspector({}, point3_type{0.f, 0.f, 0.f}, + vector3_type{0.f, 0.f, 0.f}, "Exited: "); this->clear(); return m_heartbeat; } @@ -622,7 +622,7 @@ class navigator { static_cast(nav_state.direction()) * track.dir()), sf_descr, det.transform_store(), ctx, - sf.is_portal() ? darray{0., 0.} : mask_tol, + sf.is_portal() ? darray{0.f, 0.f} : mask_tol, mask_tol_scalor, overstep_tol); } }; @@ -936,7 +936,7 @@ class navigator { detail::ray( track.pos(), static_cast(nav_dir) * track.dir()), candidate, det.transform_store(), ctx, - sf.is_portal() ? darray{0., 0.} + sf.is_portal() ? darray{0.f, 0.f} : darray{cfg.min_mask_tolerance, cfg.max_mask_tolerance}, static_cast(cfg.mask_tolerance_scalor), diff --git a/core/include/detray/navigation/policies.hpp b/core/include/detray/navigation/policies.hpp index fb2aa0a749..cb3079bdcb 100644 --- a/core/include/detray/navigation/policies.hpp +++ b/core/include/detray/navigation/policies.hpp @@ -98,8 +98,8 @@ template struct stepper_rk_policy : actor { struct state { - scalar_t m_threshold_fair_trust{0.05}; - scalar_t m_threshold_no_trust{0.1}; + scalar_t m_threshold_fair_trust{0.05f}; + scalar_t m_threshold_no_trust{0.1f}; }; /// Sets the navigation trust level depending on the step size correction diff --git a/core/include/detray/propagator/actors/aborters.hpp b/core/include/detray/propagator/actors/aborters.hpp index 7ac4c05193..e69f180320 100644 --- a/core/include/detray/propagator/actors/aborters.hpp +++ b/core/include/detray/propagator/actors/aborters.hpp @@ -56,7 +56,7 @@ struct pathlimit_aborter : actor { math::fabs(prop_state._stepping.abs_path_length()); // Check the path limit - if (step_limit <= 0.) { + if (step_limit <= 0.f) { // Stop navigation prop_state._heartbeat &= nav_state.abort(); } @@ -91,7 +91,7 @@ struct target_aborter : actor { // directly if (navigation.is_on_surface() && (navigation.barcode() == abrt_state._target_surface) && - (stepping.path_length() > 0.)) { + (stepping.path_length() > 0.f)) { prop_state._heartbeat &= navigation.abort(); } } diff --git a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp index 16c090fa53..5643bad10d 100644 --- a/core/include/detray/propagator/actors/pointwise_material_interactor.hpp +++ b/core/include/detray/propagator/actors/pointwise_material_interactor.hpp @@ -36,11 +36,11 @@ struct pointwise_material_interactor : actor { struct state { /// Evaluated energy loss - scalar_type e_loss{0.}; + scalar_type e_loss{0.f}; /// Evaluated projected scattering angle - scalar_type projected_scattering_angle{0.}; + scalar_type projected_scattering_angle{0.f}; /// Evaluated sigma of qoverp - scalar_type sigma_qop{0.}; + scalar_type sigma_qop{0.f}; bool do_covariance_transport = true; bool do_energy_loss = true; @@ -48,9 +48,9 @@ struct pointwise_material_interactor : actor { DETRAY_HOST_DEVICE void reset() { - e_loss = 0.; - projected_scattering_angle = 0.; - sigma_qop = 0.; + e_loss = 0.f; + projected_scattering_angle = 0.f; + sigma_qop = 0.f; } }; @@ -212,12 +212,12 @@ struct pointwise_material_interactor : actor { // Put particle at rest if energy loss is too large const scalar_type next_p{ - (m < next_e) ? math::sqrt(next_e * next_e - m * m) : 0.}; + (m < next_e) ? math::sqrt(next_e * next_e - m * m) : 0.f}; // For neutral particles, qoverp = 1/p constexpr auto inv{detail::invalid_value()}; - const scalar_type next_qop{(q != 0.) ? q / next_p : 1. / next_p}; - vector.set_qop((next_p == 0.) ? inv : next_qop); + const scalar_type next_qop{(q != 0.f) ? q / next_p : 1.f / next_p}; + vector.set_qop((next_p == 0.f) ? inv : next_qop); } /// @brief Update the variance of q over p of bound track parameter @@ -250,8 +250,8 @@ struct pointwise_material_interactor : actor { constexpr auto inv{detail::invalid_value()}; getter::element(covariance, e_bound_phi, e_bound_phi) += - (dir[2] == 1.) ? inv - : var_scattering_angle / (1. - dir[2] * dir[2]); + (dir[2] == 1.f) ? inv + : var_scattering_angle / (1.f - dir[2] * dir[2]); getter::element(covariance, e_bound_theta, e_bound_theta) += var_scattering_angle; diff --git a/core/include/detray/propagator/base_stepper.hpp b/core/include/detray/propagator/base_stepper.hpp index 3b6da62431..df90ebdd6e 100644 --- a/core/include/detray/propagator/base_stepper.hpp +++ b/core/include/detray/propagator/base_stepper.hpp @@ -112,8 +112,8 @@ class base_stepper { /// Get stepping direction DETRAY_HOST_DEVICE inline step::direction direction() const { - return m_step_size >= 0. ? step::direction::e_forward - : step::direction::e_backward; + return m_step_size >= 0.f ? step::direction::e_forward + : step::direction::e_backward; } /// Updates the total number of step trials @@ -247,13 +247,13 @@ class base_stepper { std::size_t m_n_total_trials{0u}; /// Current step size - scalar_type m_step_size{0.}; + scalar_type m_step_size{0.f}; /// Track path length (current position along track) - scalar_type m_path_length{0.}; + scalar_type m_path_length{0.f}; /// Absolute path length (total path length covered by the integration) - scalar_type m_abs_path_length{0.}; + scalar_type m_abs_path_length{0.f}; /// Step size constraints (optional) [[no_unique_address]] constraint_t m_constraint = {}; diff --git a/core/include/detray/propagator/detail/jacobian_cartesian.hpp b/core/include/detray/propagator/detail/jacobian_cartesian.hpp index 6c88ab4abd..0ac10f45cc 100644 --- a/core/include/detray/propagator/detail/jacobian_cartesian.hpp +++ b/core/include/detray/propagator/detail/jacobian_cartesian.hpp @@ -55,7 +55,7 @@ struct jacobian> { const vector3_type normal = coordinate_frame::normal(trf3); - const vector3_type pos_term = -1. / vector::dot(normal, dir) * normal; + const vector3_type pos_term = -1.f / vector::dot(normal, dir) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; diff --git a/core/include/detray/propagator/detail/jacobian_cylindrical.hpp b/core/include/detray/propagator/detail/jacobian_cylindrical.hpp index 9c7be11762..5be2f12427 100644 --- a/core/include/detray/propagator/detail/jacobian_cylindrical.hpp +++ b/core/include/detray/propagator/detail/jacobian_cylindrical.hpp @@ -79,7 +79,8 @@ struct jacobian> { coordinate_frame::global_to_local_3D(trf3, pos, dir); const vector3_type normal = coordinate_frame::normal(trf3, local); - const vector3_type pos_term = (-1. / vector::dot(normal, dir)) * normal; + const vector3_type pos_term = + (-1.f / vector::dot(normal, dir)) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; diff --git a/core/include/detray/propagator/detail/jacobian_engine.hpp b/core/include/detray/propagator/detail/jacobian_engine.hpp index 5dc989219e..09bf9948e4 100644 --- a/core/include/detray/propagator/detail/jacobian_engine.hpp +++ b/core/include/detray/propagator/detail/jacobian_engine.hpp @@ -73,7 +73,7 @@ requires std::is_object_v struct jacobian_engine { pos, dir); // Set d(bound time)/d(free time) - getter::element(jac_to_global, e_free_time, e_bound_time) = 1.; + getter::element(jac_to_global, e_free_time, e_bound_time) = 1.f; // Set d(n_x,n_y,n_z)/d(phi, theta) getter::element(jac_to_global, e_free_dir0, e_bound_phi) = @@ -85,7 +85,7 @@ requires std::is_object_v struct jacobian_engine { getter::element(jac_to_global, e_free_dir1, e_bound_theta) = cos_theta * sin_phi; getter::element(jac_to_global, e_free_dir2, e_bound_theta) = -sin_theta; - getter::element(jac_to_global, e_free_qoverp, e_bound_qoverp) = 1.; + getter::element(jac_to_global, e_free_qoverp, e_bound_qoverp) = 1.f; // Set d(x,y,z)/d(phi, theta) jacobian_t::set_bound_angle_to_free_pos_derivative(jac_to_global, trf3, @@ -120,7 +120,7 @@ requires std::is_object_v struct jacobian_engine { pos, dir); // Set d(free time)/d(bound time) - getter::element(jac_to_local, e_bound_time, e_free_time) = 1.; + getter::element(jac_to_local, e_bound_time, e_free_time) = 1.f; // Set d(phi, theta)/d(n_x, n_y, n_z) // @note This codes have a serious bug when theta is equal to zero... @@ -135,7 +135,7 @@ requires std::is_object_v struct jacobian_engine { getter::element(jac_to_local, e_bound_theta, e_free_dir2) = -sin_theta; // Set d(Free Qop)/d(Bound Qop) - getter::element(jac_to_local, e_bound_qoverp, e_free_qoverp) = 1.; + getter::element(jac_to_local, e_bound_qoverp, e_free_qoverp) = 1.f; return jac_to_local; } diff --git a/core/include/detray/propagator/detail/jacobian_line.hpp b/core/include/detray/propagator/detail/jacobian_line.hpp index b1b188914d..3de161ab6c 100644 --- a/core/include/detray/propagator/detail/jacobian_line.hpp +++ b/core/include/detray/propagator/detail/jacobian_line.hpp @@ -90,7 +90,8 @@ struct jacobian> { // Local x axis component of pc: const vector3_type pc_x = pc - pz * local_zaxis; - const scalar_type norm = -1. / (1. - dz * dz + vector::dot(pc_x, dtds)); + const scalar_type norm = + -1.f / (1.f - dz * dz + vector::dot(pc_x, dtds)); const vector3_type pos_term = norm * (dir - dz * local_zaxis); const vector3_type dir_term = norm * pc_x; @@ -157,7 +158,7 @@ struct jacobian> { const vector3_type new_zaxis = getter::vector<3>(frame, 0u, 2u); // The projection of direction onto ref frame normal - const scalar_type ipdn{1. / vector::dot(dir, new_zaxis)}; + const scalar_type ipdn{1.f / vector::dot(dir, new_zaxis)}; // d(n_x,n_y,n_z)/dPhi const vector3_type dNdPhi = diff --git a/core/include/detray/propagator/detail/jacobian_polar.hpp b/core/include/detray/propagator/detail/jacobian_polar.hpp index eb29208482..755878cfb2 100644 --- a/core/include/detray/propagator/detail/jacobian_polar.hpp +++ b/core/include/detray/propagator/detail/jacobian_polar.hpp @@ -58,7 +58,7 @@ struct jacobian> { const vector3_type normal = coordinate_frame::normal(trf3); - const vector3_type pos_term = -1. / vector::dot(normal, dir) * normal; + const vector3_type pos_term = -1.f / vector::dot(normal, dir) * normal; getter::element(derivative, 0u, e_free_pos0) = pos_term[0]; getter::element(derivative, 0u, e_free_pos1) = pos_term[1]; @@ -135,7 +135,7 @@ struct jacobian> { const matrix_type<1, 3> row0 = dudG * lcos_phi + dvdG * lsin_phi; const matrix_type<1, 3> row1 = - (1. / lrad) * (lcos_phi * dvdG - lsin_phi * dudG); + (1.f / lrad) * (lcos_phi * dvdG - lsin_phi * dudG); getter::set_block(free_pos_to_bound_pos_derivative, row0, e_bound_loc0, e_free_pos0); diff --git a/core/include/detray/propagator/line_stepper.hpp b/core/include/detray/propagator/line_stepper.hpp index 05b7b2b617..3d587c549d 100644 --- a/core/include/detray/propagator/line_stepper.hpp +++ b/core/include/detray/propagator/line_stepper.hpp @@ -75,11 +75,11 @@ class line_stepper final } DETRAY_HOST_DEVICE - constexpr vector3_type dtds() const { return {0., 0., 0.}; } + constexpr vector3_type dtds() const { return {0.f, 0.f, 0.f}; } DETRAY_HOST_DEVICE constexpr scalar_type dqopds(const material*) const { - return 0.; + return 0.f; } }; diff --git a/core/include/detray/propagator/rk_stepper.hpp b/core/include/detray/propagator/rk_stepper.hpp index 97ef0d2de3..750a8971ef 100644 --- a/core/include/detray/propagator/rk_stepper.hpp +++ b/core/include/detray/propagator/rk_stepper.hpp @@ -49,9 +49,9 @@ class rk_stepper final rk_stepper() = default; struct intermediate_state { - vector3_type b_first{0., 0., 0.}; - vector3_type b_middle{0., 0., 0.}; - vector3_type b_last{0., 0., 0.}; + vector3_type b_first{0.f, 0.f, 0.f}; + vector3_type b_middle{0.f, 0.f, 0.f}; + vector3_type b_last{0.f, 0.f, 0.f}; // t = tangential direction = dr/ds darray t; // q/p @@ -158,7 +158,7 @@ class rk_stepper final scalar_type m_dqopds_3; /// Next step size after adaptive step size scaling - scalar_type m_next_step_size{0.}; + scalar_type m_next_step_size{0.f}; /// Magnetic field view const magnetic_field_t m_magnetic_field; diff --git a/core/include/detray/propagator/rk_stepper.ipp b/core/include/detray/propagator/rk_stepper.ipp index ca16a5db1c..35f84748ad 100644 --- a/core/include/detray/propagator/rk_stepper.ipp +++ b/core/include/detray/propagator/rk_stepper.ipp @@ -33,7 +33,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // Reference: Eq (82) of https://doi.org/10.1016/0029-554X(81)90063-X dir = - dir + h_6 * (sd.dtds[0] + 2. * (sd.dtds[1] + sd.dtds[2]) + sd.dtds[3]); + dir + h_6 * (sd.dtds[0] + 2.f * (sd.dtds[1] + sd.dtds[2]) + sd.dtds[3]); dir = vector::normalize(dir); track.set_dir(dir); @@ -41,7 +41,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< if (vol_mat_ptr != nullptr) { // Reference: Eq (82) of https://doi.org/10.1016/0029-554X(81)90063-X qop = - qop + h_6 * (sd.dqopds[0u] + 2. * (sd.dqopds[1u] + sd.dqopds[2u]) + + qop + h_6 * (sd.dqopds[0u] + 2.f * (sd.dqopds[1u] + sd.dqopds[2u]) + sd.dqopds[3u]); } track.set_qop(qop); @@ -86,8 +86,8 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // Half step length const scalar_type h2{h * h}; - const scalar_type half_h{h * 0.5}; - const scalar_type h_6{h * (1. / 6.)}; + const scalar_type half_h{h * 0.5f}; + const scalar_type h_6{h * (1.f / 6.f)}; // 3X3 Identity matrix const auto I33 = matrix::identity>(); @@ -96,7 +96,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< darray, 4u> dkndt{I33, I33, I33, I33}; darray dkndqop; darray, 4u> dkndr; - darray dqopn_dqop{1., 1., 1., 1.}; + darray dqopn_dqop{1.f, 1.f, 1.f, 1.f}; /*--------------------------------------------------------------------------- * dk_n/dt1 @@ -188,22 +188,22 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< ---------------------------------------------------------------------------*/ if (!cfg.use_eloss_gradient) { - getter::element(D, e_free_qoverp, e_free_qoverp) = 1.; + getter::element(D, e_free_qoverp, e_free_qoverp) = 1.f; } else { // Pre-calculate dqop_n/dqop1 const scalar_type d2qop1dsdqop1 = this->d2qopdsdqop(sd.qop[0u], vol_mat_ptr); - dqopn_dqop[0u] = 1.; - dqopn_dqop[1u] = 1. + half_h * d2qop1dsdqop1; + dqopn_dqop[0u] = 1.f; + dqopn_dqop[1u] = 1.f + half_h * d2qop1dsdqop1; const scalar_type d2qop2dsdqop1 = this->d2qopdsdqop(sd.qop[1u], vol_mat_ptr) * dqopn_dqop[1u]; - dqopn_dqop[2u] = 1. + half_h * d2qop2dsdqop1; + dqopn_dqop[2u] = 1.f + half_h * d2qop2dsdqop1; const scalar_type d2qop3dsdqop1 = this->d2qopdsdqop(sd.qop[2u], vol_mat_ptr) * dqopn_dqop[2u]; - dqopn_dqop[3u] = 1. + h * d2qop3dsdqop1; + dqopn_dqop[3u] = 1.f + h * d2qop3dsdqop1; const scalar_type d2qop4dsdqop1 = this->d2qopdsdqop(sd.qop[3u], vol_mat_ptr) * dqopn_dqop[3u]; @@ -213,8 +213,8 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< -------------------------------------------------------------------*/ getter::element(D, e_free_qoverp, e_free_qoverp) = - 1. + h_6 * (d2qop1dsdqop1 + 2. * (d2qop2dsdqop1 + d2qop3dsdqop1) + - d2qop4dsdqop1); + 1.f + h_6 * (d2qop1dsdqop1 + 2.f * (d2qop2dsdqop1 + d2qop3dsdqop1) + + d2qop4dsdqop1); } /*----------------------------------------------------------------- @@ -265,8 +265,8 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // the fourth order RKN vector3_type r_ini = track.pos(); vector3_type r_mid = - r_ini + half_h * sd.t[0u] + h2 * 0.125 * sd.dtds[0u]; - vector3_type r_fin = r_ini + h * sd.t[0u] + h2 * 0.5 * sd.dtds[2u]; + r_ini + half_h * sd.t[0u] + h2 * 0.125f * sd.dtds[0u]; + vector3_type r_fin = r_ini + h * sd.t[0u] + h2 * 0.5f * sd.dtds[2u]; matrix_type<3, 3> dBdr_ini = evaluate_field_gradient(r_ini); matrix_type<3, 3> dBdr_mid = evaluate_field_gradient(r_mid); @@ -285,7 +285,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< half_h * dkndr[0u], sd.b_middle); dkndr[1u] = dkndr[1u] - sd.qop[1u] * mat_helper().column_wise_cross( - dBdr_mid * (I33 + h2 * 0.125 * dkndr[0u]), + dBdr_mid * (I33 + h2 * 0.125f * dkndr[0u]), sd.t[1u]); // dk3/dr1 @@ -293,22 +293,22 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< half_h * dkndr[1u], sd.b_middle); dkndr[2u] = dkndr[2u] - sd.qop[2u] * mat_helper().column_wise_cross( - dBdr_mid * (I33 + h2 * 0.125 * dkndr[0u]), + dBdr_mid * (I33 + h2 * 0.125f * dkndr[0u]), sd.t[2u]); // dk4/dr1 dkndr[3u] = sd.qop[3u] * mat_helper().column_wise_cross(h * dkndr[2u], sd.b_last); - dkndr[3u] = - dkndr[3u] - - sd.qop[3u] * mat_helper().column_wise_cross( - dBdr_fin * (I33 + h2 * 0.5 * dkndr[2u]), sd.t[3u]); + dkndr[3u] = dkndr[3u] - + sd.qop[3u] * + mat_helper().column_wise_cross( + dBdr_fin * (I33 + h2 * 0.5f * dkndr[2u]), sd.t[3u]); // Set dF/dr1 and dG/dr1 auto dFdr = matrix::identity>(); auto dGdr = matrix::identity>(); dFdr = dFdr + h * h_6 * (dkndr[0u] + dkndr[1u] + dkndr[2u]); - dGdr = h_6 * (dkndr[0u] + 2. * (dkndr[1u] + dkndr[2u]) + dkndr[3u]); + dGdr = h_6 * (dkndr[0u] + 2.f * (dkndr[1u] + dkndr[2u]) + dkndr[3u]); getter::set_block(D, dFdr, 0u, 0u); getter::set_block(D, dGdr, 4u, 0u); @@ -319,7 +319,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< auto dGdt = matrix::identity>(); dFdt = dFdt + h_6 * (dkndt[0u] + dkndt[1u] + dkndt[2u]); dFdt = h * dFdt; - dGdt = dGdt + h_6 * (dkndt[0u] + 2. * (dkndt[1u] + dkndt[2u]) + dkndt[3u]); + dGdt = dGdt + h_6 * (dkndt[0u] + 2.f * (dkndt[1u] + dkndt[2u]) + dkndt[3u]); getter::set_block(D, dFdt, 0u, 4u); getter::set_block(D, dGdt, 4u, 4u); @@ -327,7 +327,7 @@ DETRAY_HOST_DEVICE inline void detray::rk_stepper< // Set dF/dqop1 and dG/dqop1 vector3_type dFdqop = h * h_6 * (dkndqop[0u] + dkndqop[1u] + dkndqop[2u]); vector3_type dGdqop = - h_6 * (dkndqop[0u] + 2. * (dkndqop[1u] + dkndqop[2u]) + dkndqop[3u]); + h_6 * (dkndqop[0u] + 2.f * (dkndqop[1u] + dkndqop[2u]) + dkndqop[3u]); getter::set_block(D, dFdqop, 0u, 7u); getter::set_block(D, dGdqop, 4u, 7u); @@ -348,7 +348,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< if (!vol_mat_ptr) { const scalar_type qop = track.qop(); - return detray::make_pair(scalar_type(0.), qop); + return detray::make_pair(scalar_type(0.f), qop); } else if (cfg.use_mean_loss && i != 0u) { // qop_n is calculated recursively like the direction of // evaluate_dtds. @@ -393,7 +393,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< auto dBdr = matrix::zero>(); - constexpr auto delta{1e-1 * unit::mm}; + constexpr auto delta{1e-1f * unit::mm}; for (unsigned int i = 0; i < 3; i++) { @@ -415,7 +415,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< bvec2[1u] = bvec2_tmp[1u]; bvec2[2u] = bvec2_tmp[2u]; - const vector3_type gradient = (bvec1 - bvec2) * (1. / (2. * delta)); + const vector3_type gradient = (bvec1 - bvec2) * (1.f / (2.f * delta)); getter::element(dBdr, 0u, i) = gradient[0u]; getter::element(dBdr, 1u, i) = gradient[1u]; @@ -432,7 +432,7 @@ detray::rk_stepper::state::dtds() const -> vector3_type { // In case there was no step before - if (this->path_length() == 0.) { + if (this->path_length() == 0.f) { const point3_type pos = (*this)().pos(); const auto bvec_tmp = this->m_magnetic_field.at(pos[0], pos[1], pos[2]); @@ -455,7 +455,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper< -> scalar_type { // In case there was no step before - if (this->path_length() == 0.) { + if (this->path_length() == 0.f) { return this->dqopds((*this)().qop(), vol_mat_ptr); } @@ -472,7 +472,7 @@ DETRAY_HOST_DEVICE auto detray::rk_stepper< // d(qop)ds is zero for empty space if (!vol_mat_ptr) { - return 0.; + return 0.f; } const scalar_type q = this->particle_hypothesis().charge(); @@ -486,7 +486,7 @@ DETRAY_HOST_DEVICE auto detray::rk_stepper< *vol_mat_ptr, this->particle_hypothesis(), {mass, qop, q}); // Assert that a momentum is a positive value - assert(p >= 0.); + assert(p >= 0.f); // d(qop)ds, which is equal to (qop) * E * (-dE/ds) / p^2 // or equal to (qop)^3 * E * (-dE/ds) / q^2 @@ -503,7 +503,7 @@ detray::rk_stepper scalar_type { if (!vol_mat_ptr) { - return 0.; + return 0.f; } const scalar_type q = this->particle_hypothesis().charge(); @@ -519,12 +519,12 @@ detray::rk_stepper rq(mass, qop, q); const scalar_type g = - -1. * + -1.f * I.compute_stopping_power(*vol_mat_ptr, this->particle_hypothesis(), rq); // dg/d(qop) = -1 * derivation of stopping power const scalar_type dgdqop = - -1. * + -1.f * I.derive_stopping_power(*vol_mat_ptr, this->particle_hypothesis(), rq); // d(qop)/ds = - qop^3 * E * g / q^2 @@ -532,7 +532,7 @@ detray::rk_stepper break and advance track - if (error <= 4. * cfg.rk_error_tol) { + if (error <= 4.f * cfg.rk_error_tol) { break; } // Error estimate is too big diff --git a/core/include/detray/tracks/bound_track_parameters.hpp b/core/include/detray/tracks/bound_track_parameters.hpp index 4af47fe1d3..448b750136 100644 --- a/core/include/detray/tracks/bound_track_parameters.hpp +++ b/core/include/detray/tracks/bound_track_parameters.hpp @@ -135,7 +135,7 @@ struct bound_parameters_vector { /// Set the global theta angle DETRAY_HOST_DEVICE void set_theta(const scalar_type theta) { - assert(0. < theta); + assert(0.f < theta); assert(theta <= constant::pi); getter::element(m_vector, e_bound_theta, 0u) = theta; } @@ -180,7 +180,7 @@ struct bound_parameters_vector { scalar_type qopT() const { const scalar_type theta{getter::element(m_vector, e_bound_theta, 0u)}; const scalar_type sinTheta{math::sin(theta)}; - assert(sinTheta != 0.); + assert(sinTheta != 0.f); return getter::element(m_vector, e_bound_qoverp, 0u) / sinTheta; } @@ -189,15 +189,15 @@ struct bound_parameters_vector { scalar_type qopz() const { const scalar_type theta{getter::element(m_vector, e_bound_theta, 0u)}; const scalar_type cosTheta{math::cos(theta)}; - assert(cosTheta != 0.); + assert(cosTheta != 0.f); return getter::element(m_vector, e_bound_qoverp, 0u) / cosTheta; } /// @returns the absolute momentum DETRAY_HOST_DEVICE scalar_type p(const scalar_type q) const { - assert(qop() != 0.); - assert(q * qop() > 0.); + assert(qop() != 0.f); + assert(q * qop() > 0.f); return q / qop(); } @@ -208,16 +208,16 @@ struct bound_parameters_vector { /// @returns the transverse momentum DETRAY_HOST_DEVICE scalar_type pT(const scalar_type q) const { - assert(qop() != 0.); - assert(q * qop() > 0.); + assert(qop() != 0.f); + assert(q * qop() > 0.f); return math::fabs(q / qop() * vector::perp(dir())); } /// @returns the absolute momentum z-component DETRAY_HOST_DEVICE scalar_type pz(const scalar_type q) const { - assert(qop() != 0.); - assert(q * qop() > 0.); + assert(qop() != 0.f); + assert(q * qop() > 0.f); return math::fabs(q / qop() * dir()[2]); } diff --git a/core/include/detray/tracks/free_track_parameters.hpp b/core/include/detray/tracks/free_track_parameters.hpp index 14b63d01c8..81cf7b50ff 100644 --- a/core/include/detray/tracks/free_track_parameters.hpp +++ b/core/include/detray/tracks/free_track_parameters.hpp @@ -138,7 +138,7 @@ struct free_parameters_vector { DETRAY_HOST_DEVICE scalar_type qopT() const { const vector3_type dir = this->dir(); - assert(vector::perp(dir) != 0.); + assert(vector::perp(dir) != 0.f); return getter::element(m_vector, e_free_qoverp, 0u) / vector::perp(dir); } @@ -152,8 +152,8 @@ struct free_parameters_vector { /// @returns the absolute momentum DETRAY_HOST_DEVICE scalar_type p(const scalar_type q) const { - assert(qop() != 0.); - assert(q * qop() > 0.); + assert(qop() != 0.f); + assert(q * qop() > 0.f); return q / qop(); } @@ -164,16 +164,16 @@ struct free_parameters_vector { /// @returns the transverse momentum DETRAY_HOST_DEVICE scalar_type pT(const scalar_type q) const { - assert(this->qop() != 0.); - assert(q * qop() > 0.); + assert(this->qop() != 0.f); + assert(q * qop() > 0.f); return math::fabs(q / this->qop() * vector::perp(this->dir())); } /// @returns the absolute momentum z-component DETRAY_HOST_DEVICE scalar_type pz(const scalar_type q) const { - assert(this->qop() != 0.); - assert(q * qop() > 0.); + assert(this->qop() != 0.f); + assert(q * qop() > 0.f); return math::fabs(q / this->qop() * this->dir()[2]); } diff --git a/core/include/detray/tracks/helix.hpp b/core/include/detray/tracks/helix.hpp index b12da46459..c85377cf6d 100644 --- a/core/include/detray/tracks/helix.hpp +++ b/core/include/detray/tracks/helix.hpp @@ -66,12 +66,12 @@ class helix { // Normalized B field _h0 = vector::normalize(mag_field); - assert((math::fabs(vector::norm(_t0) - 1.) < 1e-5) && + assert((math::fabs(vector::norm(_t0) - 1.f) < 1e-5f) && "The helix direction must be normalized"); // Momentum const vector3_type mom = - (1. / static_cast(math::fabs(qop))) * _t0; + (1.f / static_cast(math::fabs(qop))) * _t0; // Normalized _h0 X _t0 _n0 = vector::normalize(vector::cross(_h0, _t0)); @@ -98,7 +98,7 @@ class helix { _R = vector::norm(pT) / _B; // Handle the case of pT ~ 0 - if (vector::norm(pT) < 1e-6) { + if (vector::norm(pT) < 1e-6f) { _vz_over_vt = detail::invalid_value(); } else { // Get vz over vt in new coordinate @@ -140,7 +140,7 @@ class helix { point3_type ret = _pos; ret = ret + _delta / _K * (_K * s - math::sin(_K * s)) * _h0; ret = ret + math::sin(_K * s) / _K * _t0; - ret = ret + _alpha / _K * (1. - math::cos(_K * s)) * _n0; + ret = ret + _alpha / _K * (1.f - math::cos(_K * s)) * _n0; return ret; } @@ -157,7 +157,7 @@ class helix { return _t0; } - vector3_type ret{0., 0., 0.}; + vector3_type ret{0.f, 0.f, 0.f}; ret = ret + _delta * (1 - math::cos(_K * s)) * _h0; ret = ret + math::cos(_K * s) * _t0; @@ -220,7 +220,7 @@ class helix { drdt = drdt + (_K * s - sin_ks) / _K * H0H0_T; drdt = drdt + - (cos_ks - 1.) / _K * mat_helper().column_wise_cross(I33, _h0); + (cos_ks - 1.f) / _K * mat_helper().column_wise_cross(I33, _h0); getter::set_block(ret, drdt, e_free_pos0, e_free_dir0); @@ -234,7 +234,7 @@ class helix { // Get drdl vector3_type drdl = - 1. / _qop * (s * this->dir(s) + _pos - this->pos(s)); + 1.f / _qop * (s * this->dir(s) + _pos - this->pos(s)); getter::set_block(ret, drdl, e_free_pos0, e_free_qoverp); @@ -246,8 +246,8 @@ class helix { getter::set_block(ret, dtdl, e_free_dir0, e_free_qoverp); // 3x3 and 7x7 element is 1 (Maybe?) - getter::element(ret, e_free_time, e_free_time) = 1.; - getter::element(ret, e_free_qoverp, e_free_qoverp) = 1.; + getter::element(ret, e_free_time, e_free_time) = 1.f; + getter::element(ret, e_free_qoverp, e_free_qoverp) = 1.f; return ret; } diff --git a/core/include/detray/tracks/ray.hpp b/core/include/detray/tracks/ray.hpp index 89d1f68694..581286512e 100644 --- a/core/include/detray/tracks/ray.hpp +++ b/core/include/detray/tracks/ray.hpp @@ -75,7 +75,7 @@ class ray { /// @returns the q over p value: Zero for ray DETRAY_HOST_DEVICE - constexpr scalar_type qop() const { return 0.; } + constexpr scalar_type qop() const { return 0.f; } /// Print DETRAY_HOST @@ -91,9 +91,9 @@ class ray { private: /// origin of ray - point3_type _pos{0., 0., 0.}; + point3_type _pos{0.f, 0.f, 0.f}; /// direction of ray - vector3_type _dir{0., 0., 1.}; + vector3_type _dir{0.f, 0.f, 1.f}; }; // Deduce the type of algebra from the track diff --git a/core/include/detray/utils/axis_rotation.hpp b/core/include/detray/utils/axis_rotation.hpp index fb995df4fe..5e614fb7b8 100644 --- a/core/include/detray/utils/axis_rotation.hpp +++ b/core/include/detray/utils/axis_rotation.hpp @@ -44,7 +44,7 @@ struct axis_rotation { matrix_type<3, 3> axis_outer = mat_helper().outer_product(U, U); R = cos_theta * I + math::sin(theta) * axis_cross + - (1. - cos_theta) * axis_outer; + (1.f - cos_theta) * axis_outer; } /// @param v vector to be rotated @@ -72,11 +72,11 @@ struct euler_rotation { using vector3_type = dvector3D; // Following the z-x-z convention - vector3_type x{1.0, 0., 0.}; - vector3_type z{0., 0., 1.}; - scalar_type alpha{0.}; - scalar_type beta{0.}; - scalar_type gamma{0.}; + vector3_type x{1.0f, 0.f, 0.f}; + vector3_type z{0.f, 0.f, 1.f}; + scalar_type alpha{0.f}; + scalar_type beta{0.f}; + scalar_type gamma{0.f}; /// @returns Get the new x and z axis DETRAY_HOST_DEVICE std::pair operator()() diff --git a/core/include/detray/utils/bounding_volume.hpp b/core/include/detray/utils/bounding_volume.hpp index 9beddddc08..92728b66f6 100644 --- a/core/include/detray/utils/bounding_volume.hpp +++ b/core/include/detray/utils/bounding_volume.hpp @@ -212,15 +212,15 @@ class axis_aligned_bounding_volume { DETRAY_HOST_DEVICE constexpr auto center() const -> point3_t { const scalar_t center_x{ - 0.5 * (m_mask[cuboid3D::e_max_x] + m_mask[cuboid3D::e_min_x])}; + 0.5f * (m_mask[cuboid3D::e_max_x] + m_mask[cuboid3D::e_min_x])}; const scalar_t center_y{ - 0.5 * (m_mask[cuboid3D::e_max_y] + m_mask[cuboid3D::e_min_y])}; + 0.5f * (m_mask[cuboid3D::e_max_y] + m_mask[cuboid3D::e_min_y])}; const scalar_t center_z{ - 0.5 * (m_mask[cuboid3D::e_max_z] + m_mask[cuboid3D::e_min_z])}; + 0.5f * (m_mask[cuboid3D::e_max_z] + m_mask[cuboid3D::e_min_z])}; - return {detail::is_invalid_value(center_x) ? 0. : center_x, - detail::is_invalid_value(center_y) ? 0. : center_y, - detail::is_invalid_value(center_z) ? 0. : center_z}; + return {detail::is_invalid_value(center_x) ? 0.f : center_x, + detail::is_invalid_value(center_y) ? 0.f : center_y, + detail::is_invalid_value(center_z) ? 0.f : center_z}; } /// @brief Lower and upper point for minimum axis aligned bounding box of diff --git a/core/include/detray/utils/grid/detail/axis_binning.hpp b/core/include/detray/utils/grid/detail/axis_binning.hpp index 6a9024a9c5..a4a09fbe21 100644 --- a/core/include/detray/utils/grid/detail/axis_binning.hpp +++ b/core/include/detray/utils/grid/detail/axis_binning.hpp @@ -77,7 +77,7 @@ struct regular { /// @returns the corresponding bin index DETRAY_HOST_DEVICE int bin(const scalar_type v) const { - return static_cast((v - span()[0]) / bin_width() + 1.) - 1; + return static_cast((v - span()[0]) / bin_width() + 1.f) - 1; } /// Access function to a range with binned neighborhood diff --git a/core/include/detray/utils/matrix_helper.hpp b/core/include/detray/utils/matrix_helper.hpp index 96669dba4a..a2f5073f52 100644 --- a/core/include/detray/utils/matrix_helper.hpp +++ b/core/include/detray/utils/matrix_helper.hpp @@ -106,7 +106,7 @@ struct matrix_helper { // Cholesky–Banachiewicz algorithm for (size_type i = 0u; i < N; i++) { for (size_type j = 0u; j <= i; j++) { - scalar_type sum = 0.; + scalar_type sum = 0.f; for (size_type k = 0u; k < j; k++) sum += getter::element(L, i, k) * getter::element(L, j, k); @@ -115,7 +115,7 @@ struct matrix_helper { math::sqrt(getter::element(mat, i, i) - sum)); } else { getter::element(L, i, j) = - (1. / getter::element(L, j, j) * + (1.f / getter::element(L, j, j) * (getter::element(mat, i, j) - sum)); } } diff --git a/core/include/detray/utils/quadratic_equation.hpp b/core/include/detray/utils/quadratic_equation.hpp index f605aa2eb3..f8be682088 100644 --- a/core/include/detray/utils/quadratic_equation.hpp +++ b/core/include/detray/utils/quadratic_equation.hpp @@ -50,12 +50,13 @@ requires std::is_arithmetic_v class quadratic_equation { m_values[0] = -c / b; } } else { - const scalar_t discriminant{b * b - 4. * a * c}; + const scalar_t discriminant{b * b - 4.f * a * c}; // If there is more than one solution, then a != 0 and q != 0 if (discriminant > tolerance) { m_solutions = 2; const scalar_t q{ - -0.5 * (b + detail::copysign(math::sqrt(discriminant), b))}; + -0.5f * + (b + detail::copysign(math::sqrt(discriminant), b))}; m_values = {q / a, c / q}; // Sort the two solutions if (m_values[0] > m_values[1]) { @@ -63,9 +64,9 @@ requires std::is_arithmetic_v class quadratic_equation { } } // Only one solution and a != 0 - else if (discriminant >= 0.) { + else if (discriminant >= 0.f) { m_solutions = 1; - m_values[0] = -0.5 * b / a; + m_values[0] = -0.5f * b / a; } // discriminant < 0 is not allowed, since all solutions should be // real @@ -100,10 +101,10 @@ requires(!std::is_arithmetic_v) class quadratic_equation { DETRAY_HOST_DEVICE constexpr quadratic_equation(const scalar_t &a, const scalar_t &b, const scalar_t &c, - const scalar_t &tolerance = 1e-6) { + const scalar_t &tolerance = 1e-6f) { // Linear case auto one_sol = (math::fabs(a) <= tolerance); - m_solutions(one_sol) = 1.; + m_solutions(one_sol) = 1.f; m_values[0] = -c / b; // Early exit @@ -111,18 +112,18 @@ requires(!std::is_arithmetic_v) class quadratic_equation { return; } - const scalar_t discriminant = b * b - (4. * a) * c; + const scalar_t discriminant = b * b - (4.f * a) * c; const auto two_sol = (discriminant > tolerance); - one_sol = !two_sol && (discriminant >= 0.); + one_sol = !two_sol && (discriminant >= 0.f); // If there is more than one solution, then a != 0 and q != 0 if (detray::detail::any_of(two_sol)) { - m_solutions = 2.; + m_solutions = 2.f; m_solutions.setZeroInverted(two_sol); const scalar_t q = - -0.5 * (b + math::copysign(math::sqrt(discriminant), b)); + -0.5f * (b + math::copysign(math::sqrt(discriminant), b)); scalar_t first = q / a; scalar_t second = c / q; @@ -145,8 +146,8 @@ requires(!std::is_arithmetic_v) class quadratic_equation { // Only one solution and a != 0 if (detray::detail::any_of(one_sol)) { - scalar_t sol = 1.; - scalar_t result = -0.5 * b / a; + scalar_t sol = 1.f; + scalar_t result = -0.5f * b / a; sol.setZeroInverted(one_sol); result.setZeroInverted(one_sol); @@ -167,9 +168,9 @@ requires(!std::is_arithmetic_v) class quadratic_equation { private: /// Number of solutions of the equation (needs to be floating point to /// apply the masks correctly) - scalar_t m_solutions = 0.; + scalar_t m_solutions = 0.f; /// The solutions - darray m_values{scalar_t(0.), scalar_t(0.)}; + darray m_values{scalar_t(0.f), scalar_t(0.f)}; }; template diff --git a/core/include/detray/utils/root_finding.hpp b/core/include/detray/utils/root_finding.hpp index 8c9e18955d..11f9a4d496 100644 --- a/core/include/detray/utils/root_finding.hpp +++ b/core/include/detray/utils/root_finding.hpp @@ -39,7 +39,7 @@ template DETRAY_HOST_DEVICE inline bool expand_bracket(const scalar_t a, const scalar_t b, function_t &f, darray &bracket, - const scalar_t k = 1.) { + const scalar_t k = 1.f) { if (a == b) { throw std::invalid_argument( @@ -95,9 +95,9 @@ DETRAY_HOST_DEVICE inline bool expand_bracket(const scalar_t a, template DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( function_t &evaluate_func, scalar_t s, - const scalar_t convergence_tolerance = 1. * unit::um, + const scalar_t convergence_tolerance = 1.f * unit::um, const std::size_t max_n_tries = 1000u, - const scalar_t max_path = 5. * unit::m) { + const scalar_t max_path = 5.f * unit::m) { constexpr scalar_t inv{detail::invalid_value()}; constexpr scalar_t epsilon{std::numeric_limits::epsilon()}; @@ -110,13 +110,13 @@ DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( }; // Initial bracket - scalar_t a{math::fabs(s) == 0. ? -0.1 : 0.9 * s}; - scalar_t b{math::fabs(s) == 0. ? 0.1 : 1.1 * s}; + scalar_t a{math::fabs(s) == 0.f ? -0.1f : 0.9f * s}; + scalar_t b{math::fabs(s) == 0.f ? 0.1f : 1.1f * s}; darray br{}; bool is_bracketed = expand_bracket(a, b, f, br); // Update initial guess on the root after bracketing - s = is_bracketed ? 0.5 * (br[1] + br[0]) : s; + s = is_bracketed ? 0.5f * (br[1] + br[0]) : s; if (is_bracketed) { // Check bracket @@ -153,7 +153,7 @@ DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( } // Run the iteration on s - scalar_t s_prev{0.}; + scalar_t s_prev{0.f}; std::size_t n_tries{0u}; auto [f_s, df_s] = evaluate_func(s); if (math::fabs(f_s) < convergence_tolerance) { @@ -169,37 +169,37 @@ DETRAY_HOST_DEVICE inline std::pair newton_raphson_safe( // Does Newton step escape bracket? bool bracket_escape{true}; - scalar_t s_newton{0.}; - if (math::fabs(df_s) != 0.) { + scalar_t s_newton{0.f}; + if (math::fabs(df_s) != 0.f) { s_newton = s - f_s / df_s; bracket_escape = math::signbit((s_newton - a) * (b - s_newton)); } // This criterion from Numerical Recipes seems to work, but why? - /*const bool slow_convergence{math::fabs(2. * f_s) > + /*const bool slow_convergence{math::fabs(2.f * f_s) > math::fabs((s_prev - s) * df_s)};*/ // Take a bisection step if it converges faster than Newton // |f(next_newton_s)| > |f(next_bisection_s)| bool slow_convergence{true}; // The criterion is only well defined if the step lengths are small - if (const scalar_t ds_bisection{0.5 * (a + b) - s}; + if (const scalar_t ds_bisection{0.5f * (a + b) - s}; is_bracketed && - (math::fabs(ds_bisection) < 10. * unit::mm)) { + (math::fabs(ds_bisection) < 10.f * unit::mm)) { slow_convergence = - (2. * math::fabs(f_s) > math::fabs(df_s * ds_bisection + f_s)); + (2.f * math::fabs(f_s) > math::fabs(df_s * ds_bisection + f_s)); } s_prev = s; // Run bisection if Newton-Raphson would be poor if (is_bracketed && - (bracket_escape || slow_convergence || math::fabs(df_s) == 0.)) { + (bracket_escape || slow_convergence || math::fabs(df_s) == 0.f)) { // Test the function sign in the middle of the interval - s = 0.5 * (a + b); + s = 0.5f * (a + b); } else { // No intersection can be found if dividing by zero - if (!is_bracketed && math::fabs(df_s) == 0.) { + if (!is_bracketed && math::fabs(df_s) == 0.f) { std::cout << "WARNING: Encountered invalid derivative " << std::endl; @@ -282,7 +282,7 @@ DETRAY_HOST_DEVICE inline void build_intersection( if (detail::is_invalid_value(tol)) { // Due to floating point errors this can be negative if cos ~ 1 const scalar_t sin_inc2{ - math::fabs(1. - cos_incidence_angle * cos_incidence_angle)}; + math::fabs(1.f - cos_incidence_angle * cos_incidence_angle)}; tol = math::fabs(ds * math::sqrt(sin_inc2)); } diff --git a/core/include/detray/utils/string_helpers.hpp b/core/include/detray/utils/string_helpers.hpp index 36bf26124c..0cb50c91b3 100644 --- a/core/include/detray/utils/string_helpers.hpp +++ b/core/include/detray/utils/string_helpers.hpp @@ -27,13 +27,12 @@ struct string_view_concat2 { } }; -/// Split string @param input at every occurrence of @param delim +/// Split string @param input at every occurence of @param delim inline dvector split_at_delim(const std::string &input, const char delim) { dvector tokens{}; - std::string delimm{delim}; - for (const auto char_range : std::views::split(input, delimm)) { + for (const auto char_range : std::views::split(input, delim)) { std::string s{""}; // TODO: Remove when range constructor becomes available in c++23 for (const char c : char_range) { diff --git a/core/include/detray/utils/unit_vectors.hpp b/core/include/detray/utils/unit_vectors.hpp index 5a8a6fae2d..993dbce06a 100644 --- a/core/include/detray/utils/unit_vectors.hpp +++ b/core/include/detray/utils/unit_vectors.hpp @@ -28,7 +28,7 @@ struct unit_vectors { DETRAY_HOST_DEVICE inline vector3_t make_curvilinear_unit_u( const vector3_t& dir) { - vector3_t unit_u{0., 0., 0.}; + vector3_t unit_u{0.f, 0.f, 0.f}; // explicit version of U = Z x T unit_u[0] = -dir[1]; unit_u[1] = dir[0]; @@ -39,11 +39,11 @@ struct unit_vectors { // aligned with the z-axis. the ZxT product is ill-defined since any // vector in the x-y plane would be orthogonal to the direction. fix the // U unit vector along the x-axis to avoid this numerical instability. - if (scale < 1e-6) { + if (scale < 1e-6f) { unit_u[0] = 1; unit_u[1] = 0; } else { - unit_u = unit_u * (1. / scale); + unit_u = unit_u * (1.f / scale); } return unit_u; diff --git a/tests/benchmarks/cpu/find_volume.cpp b/tests/benchmarks/cpu/find_volume.cpp index acdd85028b..8f1ab15d77 100644 --- a/tests/benchmarks/cpu/find_volume.cpp +++ b/tests/benchmarks/cpu/find_volume.cpp @@ -57,7 +57,7 @@ void BM_FIND_VOLUMES(benchmark::State &state) { for (auto _ : state) { for (unsigned int i1 = 0u; i1 < itest; ++i1) { for (unsigned int i0 = 0u; i0 < itest; ++i0) { - test::vector3 rz{static_cast(i0) * step0, 0., + test::vector3 rz{static_cast(i0) * step0, 0.f, static_cast(i1) * step1}; const auto &v = d.volume(rz); diff --git a/tests/benchmarks/cpu/propagation.cpp b/tests/benchmarks/cpu/propagation.cpp index da9ff3bf35..c422726ed9 100644 --- a/tests/benchmarks/cpu/propagation.cpp +++ b/tests/benchmarks/cpu/propagation.cpp @@ -58,7 +58,7 @@ int main(int argc, char** argv) { // // Constant magnetic field - vector3 B{0., 0., 2. * unit::T}; + vector3 B{0.f, 0.f, 2.f * unit::T}; // Configure toy detector toy_det_config toy_cfg{}; @@ -68,7 +68,7 @@ int main(int argc, char** argv) { // Configure wire chamber wire_chamber_config wire_chamber_cfg{}; - wire_chamber_cfg.half_z(500. * unit::mm); + wire_chamber_cfg.half_z(500.f * unit::mm); std::cout << wire_chamber_cfg << std::endl; diff --git a/tests/include/detray/test/common/detector_scan_config.hpp b/tests/include/detray/test/common/detector_scan_config.hpp index 54f255d8af..5593f29a47 100644 --- a/tests/include/detray/test/common/detector_scan_config.hpp +++ b/tests/include/detray/test/common/detector_scan_config.hpp @@ -42,7 +42,7 @@ struct detector_scan_config : public test::fixture_base<>::configuration { std::numeric_limits::epsilon(), std::numeric_limits::epsilon()}; /// B-field vector for helix - vector3_type m_B{0. * unit::T, 0. * unit::T, + vector3_type m_B{0.f * unit::T, 0.f * unit::T, 2.f * unit::T}; /// Configuration of the ray generator trk_gen_config_t m_trk_gen_cfg{}; diff --git a/tests/include/detray/test/common/material_validation_config.hpp b/tests/include/detray/test/common/material_validation_config.hpp index 719f02d37f..14ea10262d 100644 --- a/tests/include/detray/test/common/material_validation_config.hpp +++ b/tests/include/detray/test/common/material_validation_config.hpp @@ -82,7 +82,7 @@ struct material_validation_config : public test::fixture_base<>::configuration { return *this; } material_validation_config &relative_error(scalar_type re) { - assert(re > 0.); + assert(re > 0.f); m_rel_error = re; return *this; } diff --git a/tests/include/detray/test/common/navigation_validation_config.hpp b/tests/include/detray/test/common/navigation_validation_config.hpp index c1962b3f99..e8d974f0e5 100644 --- a/tests/include/detray/test/common/navigation_validation_config.hpp +++ b/tests/include/detray/test/common/navigation_validation_config.hpp @@ -45,7 +45,7 @@ struct navigation_validation_config detray::detail::invalid_value(), detray::detail::invalid_value()}; /// B-field vector for helix - vector3_type m_B{0. * unit::T, 0. * unit::T, + vector3_type m_B{0.f * unit::T, 0.f * unit::T, 2.f * unit::T}; /// Visualization style to be applied to the svgs detray::svgtools::styling::style m_style = diff --git a/tests/include/detray/test/cpu/detector_scan.hpp b/tests/include/detray/test/cpu/detector_scan.hpp index 7dfa5f8d56..84ac1c1736 100644 --- a/tests/include/detray/test/cpu/detector_scan.hpp +++ b/tests/include/detray/test/cpu/detector_scan.hpp @@ -215,7 +215,7 @@ class detector_scan : public test::fixture_base<> { // surfaces it encounters // @note: For rays, set the momentum to 1 GeV to keep the // direction vector normalized - const scalar p{q == 0. ? 1.f * unit::GeV : trk.p(q)}; + const scalar p{q == 0.f ? 1.f * unit::GeV : trk.p(q)}; auto trace = detector_scanner::run( m_gctx, m_det, test_traj, m_cfg.mask_tolerance(), p); diff --git a/tests/include/detray/test/cpu/material_scan.hpp b/tests/include/detray/test/cpu/material_scan.hpp index ad08b12301..3ba1d38506 100644 --- a/tests/include/detray/test/cpu/material_scan.hpp +++ b/tests/include/detray/test/cpu/material_scan.hpp @@ -126,7 +126,7 @@ class material_scan : public test::fixture_base<> { } // Record track parameters - tracks.push_back({ray.pos(), 0., ray.dir(), 0.}); + tracks.push_back({ray.pos(), 0.f, ray.dir(), 0.f}); // New material record material_record_t mat_record{}; @@ -181,14 +181,14 @@ class material_scan : public test::fixture_base<> { const scalar_t mx0{mat_params.mat_X0}; const scalar_t ml0{mat_params.mat_L0}; - if (mx0 > 0.) { + if (mx0 > 0.f) { mat_record.sX0 += seg / mx0; mat_record.tX0 += t / mx0; } else { std::cout << "WARNING: Encountered invalid X_0: " << mx0 << "\nOn surface: " << sf << std::endl; } - if (ml0 > 0.) { + if (ml0 > 0.f) { mat_record.sL0 += seg / ml0; mat_record.tL0 += t / ml0; } else { @@ -197,8 +197,8 @@ class material_scan : public test::fixture_base<> { } } - if (mat_record.sX0 == 0. || mat_record.sL0 == 0. || - mat_record.tX0 == 0. || mat_record.tL0 == 0.) { + if (mat_record.sX0 == 0.f || mat_record.sL0 == 0.f || + mat_record.tX0 == 0.f || mat_record.tL0 == 0.f) { std::cout << "WARNING: No material recorded for ray " << n_tracks << "/" << ray_generator.size() << ": " << ray << std::endl; diff --git a/tests/include/detray/test/cpu/material_validation.hpp b/tests/include/detray/test/cpu/material_validation.hpp index 7e82af9510..2953a7acc3 100644 --- a/tests/include/detray/test/cpu/material_validation.hpp +++ b/tests/include/detray/test/cpu/material_validation.hpp @@ -163,7 +163,7 @@ class material_validation_impl : public test::fixture_base<> { if (truth <= e && rec <= e) { // No material for this ray => valid - return scalar_t{0.}; + return scalar_t{0.f}; } else if (truth <= e) { // Material found where none should be return detail::invalid_value(); diff --git a/tests/include/detray/test/cpu/navigation_validation.hpp b/tests/include/detray/test/cpu/navigation_validation.hpp index ff099e2b1b..57cd329f4c 100644 --- a/tests/include/detray/test/cpu/navigation_validation.hpp +++ b/tests/include/detray/test/cpu/navigation_validation.hpp @@ -149,8 +149,8 @@ class navigation_validation : public test::fixture_base<> { trajectory_type test_traj = get_parametrized_trajectory(track); const scalar q = start.charge; - const scalar pT{q == 0. ? 1.f * unit::GeV : track.pT(q)}; - const scalar p{q == 0. ? 1.f * unit::GeV : track.p(q)}; + const scalar pT{q == 0.f ? 1.f * unit::GeV : track.pT(q)}; + const scalar p{q == 0.f ? 1.f * unit::GeV : track.p(q)}; // If the momentum is unknown, 1 GeV is the safest option to keep // the direction vector normalized diff --git a/tests/include/detray/test/device/cuda/navigation_validation.hpp b/tests/include/detray/test/device/cuda/navigation_validation.hpp index 85abd5048f..5d6d478188 100644 --- a/tests/include/detray/test/device/cuda/navigation_validation.hpp +++ b/tests/include/detray/test/device/cuda/navigation_validation.hpp @@ -294,9 +294,10 @@ class navigation_validation : public test::fixture_base<> { trajectory_type test_traj = get_parametrized_trajectory(trck_param); const scalar q = start.charge; - const scalar pT{q == 0. ? 1.f * unit::GeV - : trck_param.pT(q)}; - const scalar p{q == 0. ? 1.f * unit::GeV : trck_param.p(q)}; + const scalar pT{q == 0.f ? 1.f * unit::GeV + : trck_param.pT(q)}; + const scalar p{q == 0.f ? 1.f * unit::GeV + : trck_param.p(q)}; if (detray::detail::is_invalid_value(m_cfg.p_range()[0])) { min_pT = std::min(min_pT, pT); diff --git a/tests/include/detray/test/device/propagator_test.hpp b/tests/include/detray/test/device/propagator_test.hpp index 3066807962..38c7d5f7d2 100644 --- a/tests/include/detray/test/device/propagator_test.hpp +++ b/tests/include/detray/test/device/propagator_test.hpp @@ -196,7 +196,7 @@ inline void compare_propagation_results( auto relative_error = static_cast( 1.f / host_step.path_length * (host_pos - device_pos)); - EXPECT_NEAR(vector::norm(relative_error), 0., is_close) + EXPECT_NEAR(vector::norm(relative_error), 0.f, is_close) << "ERROR: Position at track " << i << " step " << j << ": [" << host_pos[0] << ", " << host_pos[1] << ", " << host_pos[2] << "] (host), [" << device_pos[0] << ", " << device_pos[1] @@ -214,7 +214,7 @@ inline void compare_propagation_results( scalar device_val = getter::element(device_J, row, col); ASSERT_NEAR((host_val - device_val) / host_step.path_length, - 0., is_close) + 0.f, is_close) << "ERROR: matrix element mismatch at row " << row << ", col " << col << std::endl; } diff --git a/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp b/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp index 7e8e1ba52d..4052612811 100644 --- a/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp +++ b/tests/include/detray/test/utils/detectors/build_telescope_detector.hpp @@ -100,7 +100,7 @@ struct tel_det_config { return *this; } constexpr tel_det_config &length(const scalar_t l) { - assert((l > 0.) && + assert((l > 0.f) && "Telescope detector length must be greater than zero"); m_length = l; return *this; @@ -108,7 +108,7 @@ struct tel_det_config { constexpr tel_det_config &positions(const std::vector &dists) { m_positions.clear(); std::ranges::copy_if(dists, std::back_inserter(m_positions), - [](scalar_t d) { return (d >= 0.); }); + [](scalar_t d) { return (d >= 0.f); }); return *this; } constexpr tel_det_config &module_material(const material &mat) { @@ -120,7 +120,7 @@ struct tel_det_config { return *this; } constexpr tel_det_config &mat_thickness(const scalar_t t) { - assert(t >= 0. && "Material thickness must be non-negative"); + assert(t >= 0.f && "Material thickness must be non-negative"); m_material_config.thickness(t); return *this; } @@ -129,7 +129,7 @@ struct tel_det_config { return *this; } constexpr tel_det_config &envelope(const scalar_t e) { - assert(e > 0. && "Portal envelope must be greater than zero"); + assert(e > 0.f && "Portal envelope must be greater than zero"); m_envelope = e; return *this; } diff --git a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp index e0ca256f39..744f7578dd 100644 --- a/tests/include/detray/test/utils/detectors/build_toy_detector.hpp +++ b/tests/include/detray/test/utils/detectors/build_toy_detector.hpp @@ -71,7 +71,7 @@ struct toy_det_config { .phi_stagger({4.f * unit::mm, 4.f * unit::mm}) .phi_sub_stagger( {0.5f * unit::mm, 0.5f * unit::mm}) - .module_tilt({0., 0.}) + .module_tilt({0.f, 0.f}) .binning({40u, 68u}); // Configure the material generation @@ -86,7 +86,7 @@ struct toy_det_config { m_beampipe_map_cfg.mapped_material = beryllium_tml(); m_beampipe_map_cfg.thickness = 0.8f * unit::mm; // Don't scale the generation of the material thickness - m_beampipe_map_cfg.scalor = 0.; + m_beampipe_map_cfg.scalor = 0.f; m_beampipe_map_cfg.mat_generator = detray::detail::generate_cyl_mat; @@ -185,18 +185,18 @@ struct toy_det_config { return *this; } constexpr toy_det_config &material_map_min_thickness(const scalar_t t) { - assert(t > 0.); + assert(t > 0.f); m_cyl_map_cfg.thickness = t; m_disc_map_cfg.thickness = t; return *this; } constexpr toy_det_config &beampipe_mat_thickness(const scalar_t t) { - assert(t > 0.); + assert(t > 0.f); m_beampipe_mat_thickness = t; return *this; } constexpr toy_det_config &module_mat_thickness(const scalar_t t) { - assert(t > 0.); + assert(t > 0.f); m_module_mat_thickness = t; return *this; } @@ -490,12 +490,12 @@ void add_cylinder_portals(volume_builder_interface *v_builder, // Left disc portal pt_disc_factory->push_back({surface_id::e_portal, - transform3_t{point3_t{0., 0., min_z}}, + transform3_t{point3_t{0.f, 0.f, min_z}}, static_cast(link_west), std::vector{min_r, max_r}}); // Right disc portal pt_disc_factory->push_back({surface_id::e_portal, - transform3_t{point3_t{0., 0., max_z}}, + transform3_t{point3_t{0.f, 0.f, max_z}}, static_cast(link_east), std::vector{min_r, max_r}}); @@ -863,7 +863,8 @@ inline auto add_endcap_detector( std::min(std::abs(vol_bounds.upper_z), std::abs(vol_bounds.lower_z))}; - const point3_t gap_center{0., 0., 0.5f * (gap_east_z + gap_west_z)}; + const point3_t gap_center{0.f, 0.f, + 0.5f * (gap_east_z + gap_west_z)}; vm_builder->add_volume_placement({gap_center}); detail::add_cylinder_portals( @@ -900,7 +901,7 @@ inline auto add_endcap_detector( // Position the volume at the respective endcap layer position const scalar_t center_z{sign * cfg.endcap_layer_positions().at(j)}; - const point3_t vol_center{0., 0., center_z}; + const point3_t vol_center{0.f, 0.f, center_z}; vm_builder->add_volume_placement({vol_center}); // Configure the module factory for this layer @@ -1020,7 +1021,7 @@ inline void add_connector_portals( const scalar_t gap_west_z{connector_gap_data.second.upper}; const scalar_t min_z{math::min(gap_east_z, gap_west_z)}; const scalar_t max_z{math::max(gap_east_z, gap_west_z)}; - const point3_t gap_center{0., 0., 0.5f * (gap_east_z + gap_west_z)}; + const point3_t gap_center{0.f, 0.f, 0.5f * (gap_east_z + gap_west_z)}; // Check that the volume under construction is really the connector gap assert(std::abs(gap_east_z) == cfg.barrel_config().half_length() || @@ -1040,7 +1041,7 @@ inline void add_connector_portals( // Barrel-facing disc portal pt_disc_factory->push_back( {surface_id::e_portal, - transform3_t{point3_t{0., 0., (side < 0.) ? max_z : min_z}}, + transform3_t{point3_t{0.f, 0.f, (side < 0.f) ? max_z : min_z}}, static_cast(e.first), std::vector{min_r, max_r}}); } @@ -1048,7 +1049,7 @@ inline void add_connector_portals( // Outward-facing disc portal pt_disc_factory->push_back( {surface_id::e_portal, - transform3_t{point3_t{0., 0., (side < 0.) ? min_z : max_z}}, + transform3_t{point3_t{0.f, 0.f, (side < 0.f) ? min_z : max_z}}, static_cast(connector_gap_idx - 1u), std::vector{inner_r, outer_r}}); @@ -1098,7 +1099,7 @@ inline void add_beampipe_portals( constexpr auto end_of_world{detail::invalid_value()}; const scalar_t h_z{cfg.barrel_config().half_length()}; - const scalar_t inner_r{0.}; + const scalar_t inner_r{0.f}; const scalar_t outer_r{cfg.beampipe_vol_radius()}; // If there are no endcaps, add the beampipe disc portals at the boundaries @@ -1115,12 +1116,12 @@ inline void add_beampipe_portals( // Lower dics portal pt_disc_factory->push_back( - {surface_id::e_portal, transform3_t{point3_t{0., 0., -h_z}}, + {surface_id::e_portal, transform3_t{point3_t{0.f, 0.f, -h_z}}, end_of_world, std::vector{inner_r, outer_r}}); // Outward-facing disc portal pt_disc_factory->push_back( - {surface_id::e_portal, transform3_t{point3_t{0., 0., h_z}}, + {surface_id::e_portal, transform3_t{point3_t{0.f, 0.f, h_z}}, end_of_world, std::vector{inner_r, outer_r}}); beampipe_builder->add_surfaces(pt_disc_factory); @@ -1180,7 +1181,7 @@ inline void add_beampipe_portals( pt_disc_factory = std::make_shared(); } - const scalar_t inner_r{0.}; + const scalar_t inner_r{0.f}; const scalar_t outer_r{cfg.beampipe_vol_radius()}; scalar_t disc_pos_z{-side * std::numeric_limits::max()}; @@ -1190,7 +1191,7 @@ inline void add_beampipe_portals( const scalar_t min_z{math::min(e.second.lower, e.second.upper)}; const scalar_t max_z{math::max(e.second.lower, e.second.upper)}; - if (side < 0.) { + if (side < 0.f) { disc_pos_z = (disc_pos_z > min_z) ? min_z : disc_pos_z; } else { disc_pos_z = (disc_pos_z < max_z) ? max_z : disc_pos_z; @@ -1204,7 +1205,7 @@ inline void add_beampipe_portals( // Outward-facing disc portal pt_disc_factory->push_back( - {surface_id::e_portal, transform3_t{point3_t{0., 0., disc_pos_z}}, + {surface_id::e_portal, transform3_t{point3_t{0.f, 0.f, disc_pos_z}}, end_of_world, std::vector{inner_r, outer_r}}); // Add all portals to the beampipe volume diff --git a/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp b/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp index a1a5cf12fd..3a26fc3b5d 100644 --- a/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp +++ b/tests/include/detray/test/utils/detectors/build_wire_chamber.hpp @@ -204,7 +204,7 @@ inline auto build_wire_chamber( cylinder_portal_config inner_pt_cfg{}; inner_pt_cfg.do_autofit(false) .fixed_half_length(cfg.half_z()) - .fixed_inner_radius(0.) + .fixed_inner_radius(0.f) .fixed_outer_radius(inner_rad) // No inner subdetectors present -> don't build inner portal .build_inner(false) diff --git a/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp b/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp index 06d2e51772..625f948282 100644 --- a/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/barrel_generator.hpp @@ -227,10 +227,10 @@ class barrel_generator final : public surface_factory_interface { // Local z axis is the normal vector const scalar_t tilt_phi{m_cfg.tilt_phi()}; const vector3_t mod_local_z{math::cos(mod_phi + tilt_phi), - math::sin(mod_phi + tilt_phi), 0.}; + math::sin(mod_phi + tilt_phi), 0.f}; // Local x axis the normal to local y,z const vector3_t mod_local_x{-math::sin(mod_phi + tilt_phi), - math::cos(mod_phi + tilt_phi), 0.}; + math::cos(mod_phi + tilt_phi), 0.f}; // Create the module transform transforms.emplace_back(ctx, mod_center, mod_local_z, mod_local_x); diff --git a/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp b/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp index 4aff4254de..eadcc570f9 100644 --- a/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/endcap_generator.hpp @@ -33,7 +33,7 @@ struct endcap_generator_config { /// Construct positive or negative endcap int m_side{-1}; /// Center position (|z|) - scalar_t m_center_z{0.}; + scalar_t m_center_z{0.f}; /// Inner layer radius scalar_t m_inner_radius{25.f * unit::mm}; /// Outer layer radius @@ -53,7 +53,7 @@ struct endcap_generator_config { std::vector m_phi_sub_stagger = {0.5f * unit::mm, 0.5f * unit::mm}; /// Module tilt (per ring) - std::vector m_tilt = {0., 0.}; + std::vector m_tilt = {0.f, 0.f}; /// Number of modules in phi (per ring) std::vector m_binning = {40u, 68u}; @@ -211,7 +211,7 @@ class endcap_generator final : public surface_factory_interface { (m_cfg.inner_radius() + m_cfg.outer_radius())); } else { // Sum up the total length of the modules along r - scalar_t tot_length{0.}; + scalar_t tot_length{0.f}; for (const auto &bounds : m_cfg.module_bounds()) { tot_length += 2.f * bounds[trapezoid2D::e_half_length_2] + 0.5f; } @@ -223,8 +223,8 @@ class endcap_generator final : public surface_factory_interface { // Fill the radii and gaps scalar_t prev_r{m_cfg.inner_radius() + r_overlap}; - scalar_t prev_hl{0.}; - scalar_t prev_ol{0.}; + scalar_t prev_hl{0.f}; + scalar_t prev_ol{0.f}; for (const auto &bounds : m_cfg.module_bounds()) { const scalar_t mod_hlength{ @@ -252,7 +252,7 @@ class endcap_generator final : public surface_factory_interface { // Generate the ring module positions (observe phi stagger) const scalar_t sub_stagger{m_cfg.phi_sub_stagger().size() > 1u ? m_cfg.phi_sub_stagger()[ir] - : 0.}; + : 0.f}; std::vector module_positions = module_positions_ring(rz, radii[ir], m_cfg.phi_stagger()[ir], @@ -278,9 +278,9 @@ class endcap_generator final : public surface_factory_interface { // The rotation matrix of the module const scalar_t mod_phi{vector::phi(mod_position)}; const vector3_t mod_loc_y{math::cos(mod_phi), - math::sin(mod_phi), 0.}; + math::sin(mod_phi), 0.f}; // Take different axis to have the same readout direction - const vector3_t mod_loc_z{0., 0., + const vector3_t mod_loc_z{0.f, 0.f, static_cast(m_cfg.side())}; const vector3_t mod_loc_x{vector::cross(mod_loc_y, mod_loc_z)}; @@ -332,11 +332,11 @@ class endcap_generator final : public surface_factory_interface { for (unsigned int iphi = 0u; iphi < n_phi_bins; ++iphi) { // If we have a phi sub stagger presents - scalar_t rzs{0.}; + scalar_t rzs{0.f}; // Phi stagger affects 0 vs 1, 2 vs 3 ... etc // -> only works if it is a %4 // Phi sub stagger affects 2 vs 4, 1 vs 3 etc. - if (phi_sub_stagger != 0. && !(n_phi_bins % 4u)) { + if (phi_sub_stagger != 0.f && !(n_phi_bins % 4u)) { // switch sides if (!(iphi % 4u)) { rzs = phi_sub_stagger; diff --git a/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp b/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp index 944667fb01..d05744f0d5 100644 --- a/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/telescope_generator.hpp @@ -60,10 +60,10 @@ class telescope_generator final : public surface_factory_interface { darray boundaries, trajectory_t traj) : m_traj{traj}, m_positions{}, m_boundaries{boundaries} { - scalar_t pos{0.}; + scalar_t pos{0.f}; scalar_t dist{n_surfaces > 1u ? length / static_cast(n_surfaces - 1u) - : 0.}; + : 0.f}; for (std::size_t i = 0u; i < n_surfaces; ++i) { m_positions.push_back(pos); pos += dist; diff --git a/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp b/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp index 7f5f401940..15f3b41a5b 100644 --- a/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp +++ b/tests/include/detray/test/utils/detectors/factories/wire_layer_generator.hpp @@ -148,12 +148,12 @@ class wire_layer_generator final detray::dvector cell_centers{}; // Distance between wires in phi const scalar_t delta = 2.f * m_cfg.cell_size() / m_layer_central_rad; - scalar_t phi{0.}; + scalar_t phi{0.f}; while (phi <= 2.f * constant::pi) { const scalar_t x = m_layer_central_rad * math::cos(phi); const scalar_t y = m_layer_central_rad * math::sin(phi); - const scalar_t z = 0.; + const scalar_t z = 0.f; cell_centers.push_back({x, y, z}); phi += delta; @@ -178,7 +178,7 @@ class wire_layer_generator final m_cfg.half_length()); // Build the transform - vector3_t z_axis{0., 0., 1.}; + vector3_t z_axis{0.f, 0.f, 1.f}; const vector3_t r_axis = vector::normalize(cell_center); z_axis = axis_rotation(r_axis, m_cfg.stereo_angle())(z_axis); diff --git a/tests/include/detray/test/utils/inspectors.hpp b/tests/include/detray/test/utils/inspectors.hpp index e9c5b0ad19..44ee4f32ef 100644 --- a/tests/include/detray/test/utils/inspectors.hpp +++ b/tests/include/detray/test/utils/inspectors.hpp @@ -175,7 +175,7 @@ struct object_tracer { const scalar_t inv_pos{detray::detail::invalid_value()}; typename candidate_record_t::point3_type last_pos = {inv_pos, inv_pos, inv_pos}; - typename candidate_record_t::vector3_type last_dir = {0., 0., 0.}; + typename candidate_record_t::vector3_type last_dir = {0.f, 0.f, 0.f}; /// Inspector interface template > &distances, // New z- and x-axes vector3_t z{vector::normalize(direction)}; - vector3_t x = vector::normalize(vector3_t{0., -z[2], z[1]}); + vector3_t x = vector::normalize(vector3_t{0.f, -z[2], z[1]}); dvector> surfaces; diff --git a/tests/include/detray/test/utils/prefill_detector.hpp b/tests/include/detray/test/utils/prefill_detector.hpp index 212b3a8368..61d60ab09a 100644 --- a/tests/include/detray/test/utils/prefill_detector.hpp +++ b/tests/include/detray/test/utils/prefill_detector.hpp @@ -41,7 +41,7 @@ void prefill_detector(detector_t& d, std::make_unique>(volume_id::e_cylinder); // Volume position - v_builder->add_volume_placement(transform3_t(point3_t{0., 0., 2.f})); + v_builder->add_volume_placement(transform3_t(point3_t{0.f, 0.f, 2.f})); // Build homogeneous material on surfaces inside the voume auto v_mat_builder = @@ -54,8 +54,8 @@ void prefill_detector(detector_t& d, std::make_unique()); rectangle_factory->push_back({surface_id::e_sensitive, - transform3_t(point3_t{0., 0., 0.}), vol_link, - std::vector{-3.f, 3.f}}); + transform3_t(point3_t{0.f, 0.f, 0.f}), + vol_link, std::vector{-3.f, 3.f}}); rectangle_factory->add_material( material_id::e_slab, {3.f * unit::mm, detray::gold()}); @@ -65,8 +65,8 @@ void prefill_detector(detector_t& d, std::make_unique()); annulus_factory->push_back( - {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0., 0.}), vol_link, - std::vector{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}}); + {surface_id::e_sensitive, transform3_t(point3_t{1.f, 0.f, 0.f}), + vol_link, std::vector{1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f}}); annulus_factory->add_material( material_id::e_slab, {12.f * unit::mm, detray::tungsten()}); @@ -77,8 +77,8 @@ void prefill_detector(detector_t& d, std::make_unique()); trapezoid_factory->push_back( - {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0., 0.}), vol_link, - std::vector{1.f, 2.f, 3.f, 1.f / 6.f}}); + {surface_id::e_sensitive, transform3_t(point3_t{2.f, 0.f, 0.f}), + vol_link, std::vector{1.f, 2.f, 3.f, 1.f / 6.f}}); trapezoid_factory->add_material( material_id::e_rod, {4.f * unit::mm, detray::aluminium()}); diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp index 5b5a0625dd..975e808247 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator.hpp @@ -127,7 +127,7 @@ class random_track_generator if constexpr (std::is_same_v>) { mom = vector::normalize(mom); } else { - sin_theta = (sin_theta == scalar_t{0.}) + sin_theta = (sin_theta == scalar_t{0.f}) ? std::numeric_limits::epsilon() : sin_theta; mom = (m_cfg.is_pT() ? 1.f / sin_theta : 1.f) * p_mag * diff --git a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp index bc89166a75..a50110b4cd 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/random_track_generator_config.hpp @@ -42,7 +42,7 @@ struct random_track_generator_config { /// Range for phi [-pi, pi) and theta [0, pi) darray m_phi_range{-constant::pi, constant::pi}; - darray m_theta_range{0., constant::pi}; + darray m_theta_range{0.f, constant::pi}; /// Momentum range darray m_mom_range{1.f * unit::GeV, @@ -51,14 +51,14 @@ struct random_track_generator_config { bool m_is_pT{false}; /// Track origin - darray m_origin{0., 0., 0.}; - darray m_origin_stddev{0., 0., 0.}; + darray m_origin{0.f, 0.f, 0.f}; + darray m_origin_stddev{0.f, 0.f, 0.f}; /// Randomly flip the charge sign? bool m_randomize_charge{false}; /// Time parameter and charge of the track - scalar_t m_time{0. * unit::us}; + scalar_t m_time{0.f * unit::us}; scalar_t m_charge{-1.f * unit::e}; /// Setters @@ -97,8 +97,8 @@ struct random_track_generator_config { } DETRAY_HOST_DEVICE random_track_generator_config& theta_range( scalar_t low, scalar_t high) { - auto min_theta{std::clamp(low, scalar_t{0.}, constant::pi)}; - auto max_theta{std::clamp(high, scalar_t{0.}, constant::pi)}; + auto min_theta{std::clamp(low, scalar_t{0.f}, constant::pi)}; + auto max_theta{std::clamp(high, scalar_t{0.f}, constant::pi)}; assert(min_theta <= max_theta); @@ -137,7 +137,7 @@ struct random_track_generator_config { DETRAY_HOST_DEVICE random_track_generator_config& mom_range(scalar_t low, scalar_t high) { m_is_pT = false; - assert(low >= 0.); + assert(low >= 0.f); assert(low <= high); m_mom_range = {low, high}; return *this; @@ -151,7 +151,7 @@ struct random_track_generator_config { DETRAY_HOST_DEVICE random_track_generator_config& pT_range(scalar_t low, scalar_t high) { m_is_pT = true; - assert(low >= 0.); + assert(low >= 0.f); assert(low <= high); m_mom_range = {low, high}; return *this; @@ -198,7 +198,7 @@ struct random_track_generator_config { return *this; } DETRAY_HOST_DEVICE random_track_generator_config& time(scalar_t t) { - assert(t >= 0.); + assert(t >= 0.f); m_time = t; return *this; } diff --git a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp index 3906c83c6d..8464f832e1 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator.hpp @@ -158,7 +158,7 @@ class uniform_track_generator if constexpr (std::is_same_v>) { p = vector::normalize(p); } else { - sin_theta = (sin_theta == scalar_t{0.}) + sin_theta = (sin_theta == scalar_t{0.f}) ? std::numeric_limits::epsilon() : sin_theta; p = (m_cfg.is_pT() ? 1.f / sin_theta : 1.f) * m_cfg.m_p_mag * @@ -186,13 +186,13 @@ class uniform_track_generator configuration m_cfg{}; /// Angular step sizes - scalar_t m_phi_step_size{0.}; - scalar_t m_theta_step_size{0.}; - scalar_t m_eta_step_size{0.}; + scalar_t m_phi_step_size{0.f}; + scalar_t m_theta_step_size{0.f}; + scalar_t m_eta_step_size{0.f}; /// Phi and theta angles of momentum direction scalar_t m_phi{-constant::pi}; - scalar_t m_theta{0.}; + scalar_t m_theta{0.f}; /// Iteration indices std::size_t i_phi{0u}; diff --git a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp index b15f0ddbe4..97e6431eb8 100644 --- a/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp +++ b/tests/include/detray/test/utils/simulation/event_generator/uniform_track_generator_config.hpp @@ -37,7 +37,7 @@ struct uniform_track_generator_config { /// Range for phi [-pi, pi) and theta [0, pi) darray m_phi_range{-constant::pi, k_max_pi}; - darray m_theta_range{0., k_max_pi}; + darray m_theta_range{0.f, k_max_pi}; darray m_eta_range{-5.f, 5.f}; /// Angular step size @@ -49,7 +49,7 @@ struct uniform_track_generator_config { bool m_uniform_eta{false}; /// Track origin - darray m_origin{0., 0., 0.}; + darray m_origin{0.f, 0.f, 0.f}; /// Magnitude of momentum: Default is one to keep directions normalized /// if no momentum information is needed (e.g. for a ray) @@ -61,7 +61,7 @@ struct uniform_track_generator_config { bool m_randomize_charge{false}; /// Time parameter and charge of the track - scalar_t m_time{0. * unit::us}; + scalar_t m_time{0.f * unit::us}; scalar_t m_charge{-1.f * unit::e}; /// Setters @@ -88,8 +88,8 @@ struct uniform_track_generator_config { } DETRAY_HOST_DEVICE uniform_track_generator_config& theta_range( scalar_t low, scalar_t high) { - auto min_theta{std::clamp(low, scalar_t{0.}, k_max_pi)}; - auto max_theta{std::clamp(high, scalar_t{0.}, k_max_pi)}; + auto min_theta{std::clamp(low, scalar_t{0.f}, k_max_pi)}; + auto max_theta{std::clamp(high, scalar_t{0.f}, k_max_pi)}; assert(min_theta <= max_theta); @@ -158,13 +158,13 @@ struct uniform_track_generator_config { return origin(ori[0], ori[1], ori[2]); } DETRAY_HOST_DEVICE uniform_track_generator_config& p_tot(scalar_t p) { - assert(p > 0.); + assert(p > 0.f); m_is_pT = false; m_p_mag = p; return *this; } DETRAY_HOST_DEVICE uniform_track_generator_config& p_T(scalar_t p) { - assert(p > 0.); + assert(p > 0.f); m_is_pT = true; m_p_mag = p; return *this; diff --git a/tests/include/detray/test/utils/simulation/random_scatterer.hpp b/tests/include/detray/test/utils/simulation/random_scatterer.hpp index 04ac294bed..710eb2b821 100644 --- a/tests/include/detray/test/utils/simulation/random_scatterer.hpp +++ b/tests/include/detray/test/utils/simulation/random_scatterer.hpp @@ -44,13 +44,13 @@ struct random_scatterer : actor { std::mt19937_64 generator{rd()}; /// most probable energy loss - scalar_type e_loss_mpv = 0.; + scalar_type e_loss_mpv = 0.f; /// energy loss sigma - scalar_type e_loss_sigma = 0.; + scalar_type e_loss_sigma = 0.f; /// projected scattering angle - scalar_type projected_scattering_angle = 0.; + scalar_type projected_scattering_angle = 0.f; // Simulation setup bool do_energy_loss = true; diff --git a/tests/include/detray/test/utils/simulation/scattering_helper.hpp b/tests/include/detray/test/utils/simulation/scattering_helper.hpp index 820a74a779..e75aa63673 100644 --- a/tests/include/detray/test/utils/simulation/scattering_helper.hpp +++ b/tests/include/detray/test/utils/simulation/scattering_helper.hpp @@ -39,8 +39,8 @@ struct scattering_helper { // Generate theta and phi for random scattering const scalar_type r_theta{ angle == scalar_type{0} - ? 0. - : std::normal_distribution(0., angle)(generator)}; + ? 0.f + : std::normal_distribution(0.f, angle)(generator)}; const scalar_type r_phi{std::uniform_real_distribution( -constant::pi, constant::pi)(generator)}; diff --git a/tests/include/detray/test/utils/statistics.hpp b/tests/include/detray/test/utils/statistics.hpp index b6c405c852..4da9496f1f 100644 --- a/tests/include/detray/test/utils/statistics.hpp +++ b/tests/include/detray/test/utils/statistics.hpp @@ -61,7 +61,7 @@ inline auto variance(const range_t& r) noexcept(false) // Variance is zero for single element if (r.size() == 1u) { - return 0.; + return 0.f; } value_t mean = statistics::mean(r); diff --git a/tests/include/detray/test/utils/types.hpp b/tests/include/detray/test/utils/types.hpp index 0210685b4b..ad5d2fe1e7 100644 --- a/tests/include/detray/test/utils/types.hpp +++ b/tests/include/detray/test/utils/types.hpp @@ -33,10 +33,6 @@ static constexpr char filenames[] = "smatrix-"; #elif DETRAY_ALGEBRA_VC_AOS using algebra = detray::vc_aos; static constexpr char filenames[] = "vc_aos-"; - -#elif DETRAY_ALGEBRA_FASTOR -using algebra = detray::fastor; -static constexpr char filenames[] = "fastor-"; #endif // Test algebra types diff --git a/tests/include/detray/test/validation/detector_scanner.hpp b/tests/include/detray/test/validation/detector_scanner.hpp index 099c7095cb..63f68b3c95 100644 --- a/tests/include/detray/test/validation/detector_scanner.hpp +++ b/tests/include/detray/test/validation/detector_scanner.hpp @@ -59,13 +59,13 @@ struct brute_force_scan { using trajectory_type = trajectory_t; template - inline auto operator()( - const typename detector_t::geometry_context ctx, - const detector_t &detector, const trajectory_t &traj, - const darray mask_tolerance = {0., - 0.}, - const typename detector_t::scalar_type p = - 1.f * unit::GeV) { + inline auto operator()(const typename detector_t::geometry_context ctx, + const detector_t &detector, const trajectory_t &traj, + const darray + mask_tolerance = {0.f, 0.f}, + const typename detector_t::scalar_type p = + 1.f * + unit::GeV) { using algebra_t = typename detector_t::algebra_type; using scalar_t = dscalar; @@ -79,7 +79,7 @@ struct brute_force_scan { const auto &trf_store = detector.transform_store(); - assert(p > 0.); + assert(p > 0.f); const scalar_t q{p * traj.qop()}; std::vector intersections{}; @@ -91,7 +91,8 @@ struct brute_force_scan { const auto sf = tracking_surface{detector, sf_desc}; sf.template visit_mask( intersections, traj, sf_desc, trf_store, ctx, - sf.is_portal() ? darray{0., 0.} : mask_tolerance); + sf.is_portal() ? darray{0.f, 0.f} + : mask_tolerance); // Candidate is invalid if it lies in the opposite direction for (auto &sfi : intersections) { @@ -100,7 +101,7 @@ struct brute_force_scan { // Record the intersection intersection_trace.push_back( {q, - {traj.pos(sfi.path), 0., p * traj.dir(sfi.path), q}, + {traj.pos(sfi.path), 0.f, p * traj.dir(sfi.path), q}, sf.volume(), sfi}); } @@ -122,17 +123,17 @@ struct brute_force_scan { start_intersection.sf_desc.set_index(dindex_invalid); start_intersection.sf_desc.material().set_id( detector_t::materials::id::e_none); - start_intersection.path = 0.; - start_intersection.local = {0., 0., 0.}; + start_intersection.path = 0.f; + start_intersection.local = {0.f, 0.f, 0.f}; start_intersection.volume_link = static_cast(first_record.vol_idx); - intersection_trace.insert( - intersection_trace.begin(), - intersection_record{q, - {traj.pos(), 0., p * traj.dir(), q}, - first_record.vol_idx, - start_intersection}); + intersection_trace.insert(intersection_trace.begin(), + intersection_record{ + q, + {traj.pos(), 0.f, p * traj.dir(), q}, + first_record.vol_idx, + start_intersection}); return intersection_trace; } diff --git a/tests/include/detray/test/validation/material_validation_utils.hpp b/tests/include/detray/test/validation/material_validation_utils.hpp index 3e6c7723a6..8b93d62ca0 100644 --- a/tests/include/detray/test/validation/material_validation_utils.hpp +++ b/tests/include/detray/test/validation/material_validation_utils.hpp @@ -35,13 +35,13 @@ struct material_record { scalar_t eta{detail::invalid_value()}; /// @} /// Accumulated radiation length per pathlength through the material - scalar_t sX0{0.}; + scalar_t sX0{0.f}; /// Accumulated radiation length per thickness - scalar_t tX0{0.}; + scalar_t tX0{0.f}; /// Accumulated interaction length per pathlength through the material - scalar_t sL0{0.}; + scalar_t sL0{0.f}; /// Accumulated interaction length per thickness - scalar_t tL0{0.}; + scalar_t tL0{0.f}; }; /// @brief Return type that contains the material parameters and the pathlength @@ -52,9 +52,9 @@ struct material_params { /// Material thickness/radius scalar_t thickness{detail::invalid_value()}; /// Radiation length - scalar_t mat_X0{0.}; + scalar_t mat_X0{0.f}; /// Interaction length - scalar_t mat_L0{0.}; + scalar_t mat_L0{0.f}; }; /// @brief Functor to retrieve the material parameters for a given local @@ -84,7 +84,7 @@ struct get_material_params { if (!mat) { // Set the pathlength and thickness to zero so that they // are not counted - return material_params{0., 0., inv, inv}; + return material_params{0.f, 0.f, inv, inv}; } const scalar_t seg{mat.path_segment(cos_inc_angle, loc[0])}; @@ -204,13 +204,13 @@ struct material_tracer : detray::actor { const scalar_t ml0{mat_params.mat_L0}; // Fill the material record - if (mx0 > 0.) { + if (mx0 > 0.f) { tracer.m_mat_record.sX0 += seg / mx0; tracer.m_mat_record.tX0 += t / mx0; tracer.m_mat_steps.push_back({seg, t, mx0, ml0}); } - if (ml0 > 0.) { + if (ml0 > 0.f) { tracer.m_mat_record.sL0 += seg / ml0; tracer.m_mat_record.tL0 += t / ml0; diff --git a/tests/include/detray/test/validation/navigation_validation_utils.hpp b/tests/include/detray/test/validation/navigation_validation_utils.hpp index 306790cd97..541e2b484f 100644 --- a/tests/include/detray/test/validation/navigation_validation_utils.hpp +++ b/tests/include/detray/test/validation/navigation_validation_utils.hpp @@ -642,7 +642,7 @@ auto write_tracks(const std::string &track_param_file_name, for (const auto &record : trace) { track_params.back().emplace_back( record.charge, - track_param_t{record.pos, 0., record.dir, record.charge}); + track_param_t{record.pos, 0.f, record.dir, record.charge}); } } @@ -686,7 +686,7 @@ auto write_dist_to_boundary( << "," << vector::phi(glob_pos) << ", " << vector::eta(glob_pos) << "," << missed_sfi.path << ", " << dist << ", " << std::boolalpha - << sf.is_inside(missed_sfi.local, 0.) << ", " + << sf.is_inside(missed_sfi.local, 0.f) << ", " << static_cast(sf.shape_id()) << std::endl; } } diff --git a/tests/include/detray/test/validation/step_tracer.hpp b/tests/include/detray/test/validation/step_tracer.hpp index 032af8cd1c..cf1568f084 100644 --- a/tests/include/detray/test/validation/step_tracer.hpp +++ b/tests/include/detray/test/validation/step_tracer.hpp @@ -24,8 +24,8 @@ struct step_data { using track_param_type = free_track_parameters; using free_matrix_type = free_matrix; - scalar_type step_size{0.}; - scalar_type path_length{0.}; + scalar_type step_size{0.f}; + scalar_type path_length{0.f}; std::size_t n_total_trials{0u}; navigation::direction nav_dir = navigation::direction::e_forward; geometry::barcode barcode{}; diff --git a/tests/include/detray/test/validation/svg_display.hpp b/tests/include/detray/test/validation/svg_display.hpp index 840f861a49..a6fb8c5ffe 100644 --- a/tests/include/detray/test/validation/svg_display.hpp +++ b/tests/include/detray/test/validation/svg_display.hpp @@ -127,7 +127,7 @@ auto draw_intersection_and_traj_svg( // Draw the truth intersections auto svg_traj = il.draw_intersections("truth_trace", truth_intersections, - traj.dir(0.), view, gctx); + traj.dir(0.f), view, gctx); // Draw an approximation of the trajectory with the recorded intersections if (!recorded_intersections.empty()) {