Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Dec 8, 2024
1 parent 13704c7 commit 451f651
Show file tree
Hide file tree
Showing 31 changed files with 310 additions and 292 deletions.
2 changes: 1 addition & 1 deletion core/include/detray/navigation/detail/helix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class helix {

// Momentum
const vector3_type mom =
1.f / static_cast<scalar_type>(math::fabs(qop)) * _t0;
(1.f / static_cast<scalar_type>(math::fabs(qop))) * _t0;

// Normalized _h0 X _t0
_n0 = vector::normalize(vector::cross(_h0, _t0));
Expand Down
5 changes: 3 additions & 2 deletions core/include/detray/propagator/detail/jacobian_polar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ struct jacobian<polar2D<algebra_t>> {
// dvdG = dv/d(x,y,z)
const matrix_type<1, 3> dvdG = getter::block<1, 3>(frameT, 1u, 0u);

const auto row0 = dudG * lcos_phi + dvdG * lsin_phi;
const auto row1 = (1.f / lrad) * (lcos_phi * dvdG - lsin_phi * dudG);
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);

getter::set_block(free_pos_to_bound_pos_derivative, row0, e_bound_loc0,
e_free_pos0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

namespace detray {

// Define scalar type
using scalar = DETRAY_CUSTOM_SCALARTYPE;

/// The plugin definition
template <typename scalar_t = DETRAY_CUSTOM_SCALARTYPE>
using eigen = algebra::plugin::eigen<scalar_t>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

namespace detray {

// Define scalar type
using scalar = DETRAY_CUSTOM_SCALARTYPE;

/// The plugin definition
template <typename scalar_t = DETRAY_CUSTOM_SCALARTYPE>
using smatrix = algebra::plugin::smatrix<scalar_t>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

namespace detray {

// Define scalar type
using scalar = DETRAY_CUSTOM_SCALARTYPE;

/// The plugin definition
template <typename scalar_t = DETRAY_CUSTOM_SCALARTYPE>
using vc_aos = algebra::plugin::vc_aos<scalar_t>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

namespace detray {

// Define scalar type
using scalar = DETRAY_CUSTOM_SCALARTYPE;

/// The plugin definition
template <typename scalar_t = DETRAY_CUSTOM_SCALARTYPE>
using vc_soa = algebra::plugin::vc_soa<scalar_t>;
Expand Down
2 changes: 0 additions & 2 deletions tests/benchmarks/cpu/grid2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
// Use the detray:: namespace implicitly.
using namespace detray;

using scalar = test::scalar;

namespace {

#ifdef DETRAY_BENCHMARK_PRINTOUTS
Expand Down
3 changes: 1 addition & 2 deletions tests/benchmarks/cuda/benchmark_propagator_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ static void BM_PROPAGATOR_CUDA(benchmark::State &state) {

// Get tracks
vecmem::vector<free_track_parameters<algebra_type>> tracks(&bp_mng_mr);
fill_tracks(tracks, static_cast<std::size_t>(state.range(0)),
static_cast<std::size_t>(state.range(0)));
fill_tracks(tracks, n_tracks);

total_tracks += tracks.size();

Expand Down
104 changes: 57 additions & 47 deletions tests/include/detray/test/utils/detectors/build_telescope_detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,98 +36,99 @@

namespace detray {

using scalar = test::scalar;

namespace {

/// Configure the toy detector
template <typename mask_shape_t = rectangle2D,
typename trajectory_t = detail::ray<test::algebra>>
template <typename algebra_t, typename mask_shape_t = rectangle2D,
template <typename> class trajectory_t = detail::ray>
struct tel_det_config {

using scalar_t = dscalar<algebra_t>;

/// Construct from existing mask
tel_det_config(const mask<mask_shape_t, test::algebra> &m,
const trajectory_t &t = {})
tel_det_config(const mask<mask_shape_t, algebra_t> &m,
const trajectory_t<algebra_t> &t = {})
: m_mask(m), m_trajectory(t) {
// Configure the material generation
m_material_config.sensitive_material(silicon_tml<scalar>())
.passive_material(vacuum<scalar>())
.portal_material(vacuum<scalar>())
.thickness(80.f * unit<scalar>::um);
m_material_config.sensitive_material(silicon_tml<scalar_t>())
.passive_material(vacuum<scalar_t>())
.portal_material(vacuum<scalar_t>())
.thickness(80.f * unit<scalar_t>::um);
}

/// Construct from from mask parameter vector
tel_det_config(std::vector<scalar> params, const trajectory_t &t = {})
: tel_det_config(
mask<mask_shape_t, test::algebra>{std::move(params), 0u}, t) {}
tel_det_config(std::vector<scalar_t> params,
const trajectory_t<algebra_t> &t = {})
: tel_det_config(mask<mask_shape_t, algebra_t>{std::move(params), 0u},
t) {}

/// Construct from mask parameters (except volume link, which is not needed)
template <typename... Args>
requires(std::is_same_v<Args, scalar> &&...) explicit tel_det_config(
requires(std::is_same_v<Args, scalar_t> &&...) explicit tel_det_config(
Args &&... args)
: tel_det_config(mask<mask_shape_t, test::algebra>{
0u, std::forward<Args>(args)...}) {}
: tel_det_config(
mask<mask_shape_t, algebra_t>{0u, std::forward<Args>(args)...}) {}

/// Mask of the test surfaces
mask<mask_shape_t, test::algebra> m_mask;
mask<mask_shape_t, algebra_t> m_mask;
/// No. of test surfaces in the telescope
unsigned int m_n_surfaces{10u};
/// Length of the telescope
scalar m_length{500.f * unit<scalar>::mm};
scalar_t m_length{500.f * unit<scalar_t>::mm};
/// Concrete positions where to place the surfaces along the pilot track
std::vector<scalar> m_positions{};
std::vector<scalar_t> m_positions{};
/// Configuration for the homogeneous material generator
hom_material_config<scalar> m_material_config{};
hom_material_config<scalar_t> m_material_config{};
/// Material for volume
material<scalar> m_volume_material = vacuum<scalar>();
material<scalar_t> m_volume_material = vacuum<scalar_t>();
/// Pilot track along which to place the surfaces
trajectory_t m_trajectory{};
trajectory_t<algebra_t> m_trajectory{};
/// Safety envelope between the test surfaces and the portals
scalar m_envelope{0.1f * unit<scalar>::mm};
scalar_t m_envelope{0.1f * unit<scalar_t>::mm};
/// Run detector consistency check after reading
bool m_do_check{true};

/// Setters
/// @{
constexpr tel_det_config &module_mask(
const mask<mask_shape_t, test::algebra> &m) {
const mask<mask_shape_t, algebra_t> &m) {
m_mask = m;
return *this;
}
constexpr tel_det_config &n_surfaces(const unsigned int n) {
m_n_surfaces = n;
return *this;
}
constexpr tel_det_config &length(const scalar l) {
constexpr tel_det_config &length(const scalar_t l) {
assert((l > 0.f) &&
"Telescope detector length must be greater than zero");
m_length = l;
return *this;
}
constexpr tel_det_config &positions(const std::vector<scalar> &dists) {
constexpr tel_det_config &positions(const std::vector<scalar_t> &dists) {
m_positions.clear();
std::ranges::copy_if(dists, std::back_inserter(m_positions),
[](scalar d) { return (d >= 0.f); });
[](scalar_t d) { return (d >= 0.f); });
return *this;
}
constexpr tel_det_config &module_material(const material<scalar> &mat) {
constexpr tel_det_config &module_material(const material<scalar_t> &mat) {
m_material_config.sensitive_material(mat);
return *this;
}
constexpr tel_det_config &volume_material(const material<scalar> &mat) {
constexpr tel_det_config &volume_material(const material<scalar_t> &mat) {
m_volume_material = mat;
return *this;
}
constexpr tel_det_config &mat_thickness(const scalar t) {
constexpr tel_det_config &mat_thickness(const scalar_t t) {
assert(t >= 0.f && "Material thickness must be non-negative");
m_material_config.thickness(t);
return *this;
}
constexpr tel_det_config &pilot_track(const trajectory_t &traj) {
constexpr tel_det_config &pilot_track(const trajectory_t<algebra_t> &traj) {
m_trajectory = traj;
return *this;
}
constexpr tel_det_config &envelope(const scalar e) {
constexpr tel_det_config &envelope(const scalar_t e) {
assert(e > 0.f && "Portal envelope must be greater than zero");
m_envelope = e;
return *this;
Expand All @@ -140,29 +141,36 @@ struct tel_det_config {

/// Getters
/// @{
constexpr const mask<mask_shape_t, test::algebra> &module_mask() const {
constexpr const mask<mask_shape_t, algebra_t> &module_mask() const {
return m_mask;
}
constexpr unsigned int n_surfaces() const { return m_n_surfaces; }
constexpr scalar length() const { return m_length; }
const std::vector<scalar> &positions() const { return m_positions; }
constexpr scalar_t length() const { return m_length; }
const std::vector<scalar_t> &positions() const { return m_positions; }
constexpr const auto &material_config() const { return m_material_config; }
constexpr auto &material_config() { return m_material_config; }
constexpr const material<scalar> &module_material() const {
constexpr const material<scalar_t> &module_material() const {
return m_material_config.sensitive_material();
}
constexpr const material<scalar> &volume_material() const {
constexpr const material<scalar_t> &volume_material() const {
return m_volume_material;
}
constexpr scalar mat_thickness() const {
constexpr scalar_t mat_thickness() const {
return m_material_config.thickness();
}
const trajectory_t &pilot_track() const { return m_trajectory; }
constexpr scalar envelope() const { return m_envelope; }
const trajectory_t<algebra_t> &pilot_track() const { return m_trajectory; }
constexpr scalar_t envelope() const { return m_envelope; }
bool do_check() const { return m_do_check; }
/// @}
};

/// Deduce the type of telescope config
template <typename algebra_t, typename shape_t,
template <typename> class trajectory_t>
DETRAY_HOST_DEVICE tel_det_config(const mask<shape_t, algebra_t> &,
const trajectory_t<algebra_t> &)
->tel_det_config<algebra_t, shape_t, trajectory_t>;

} // namespace

/// Builds a detray geometry that contains only one volume with one type of
Expand All @@ -178,13 +186,15 @@ struct tel_det_config {
///
/// @returns a complete detector object
template <typename algebra_t, typename mask_shape_t = rectangle2D,
typename trajectory_t = detail::ray<algebra_t>>
template <typename> class trajectory_t = detail::ray>
inline auto build_telescope_detector(
vecmem::memory_resource &resource,
const tel_det_config<mask_shape_t, trajectory_t> &cfg =
tel_det_config<mask_shape_t, trajectory_t>{20.f * unit<scalar>::mm,
20.f * unit<scalar>::mm}) {
const tel_det_config<algebra_t, mask_shape_t, trajectory_t> &cfg =
tel_det_config<algebra_t, mask_shape_t, trajectory_t>{
20.f * unit<dscalar<algebra_t>>::mm,
20.f * unit<dscalar<algebra_t>>::mm}) {

using scalar_t = dscalar<algebra_t>;
using metadata_t = telescope_metadata<algebra_t, mask_shape_t>;
using builder_t = detector_builder<metadata_t, volume_builder>;
using detector_t = typename builder_t::detector_type;
Expand All @@ -203,7 +213,7 @@ inline auto build_telescope_detector(

// Add module surfaces to volume
using telescope_factory =
telescope_generator<detector_t, mask_shape_t, trajectory_t>;
telescope_generator<detector_t, mask_shape_t, trajectory_t<algebra_t>>;
std::unique_ptr<surface_factory_interface<detector_t>> tel_generator;

if (cfg.positions().empty()) {
Expand All @@ -221,7 +231,7 @@ inline auto build_telescope_detector(
volume_builder_interface<detector_t> *vm_builder{v_builder};
std::shared_ptr<surface_factory_interface<detector_t>> module_generator;

if (cfg.module_material() != detray::vacuum<scalar>{}) {
if (cfg.module_material() != detray::vacuum<scalar_t>{}) {

// Decorate the builders with homogeneous material
vm_builder =
Expand Down Expand Up @@ -256,7 +266,7 @@ inline auto build_telescope_detector(
std::vector<dindex>{vm_builder->vol_index()});

// If requested, add homogeneous volume material
if (cfg.volume_material() != detray::vacuum<scalar>{}) {
if (cfg.volume_material() != detray::vacuum<scalar_t>{}) {
auto full_v_builder = det_builder.template decorate<
homogeneous_volume_material_builder<detector_t>>(vm_builder);

Expand Down
Loading

0 comments on commit 451f651

Please sign in to comment.