Skip to content

Commit

Permalink
Add coordinates and refactor the classes with the template type of tr…
Browse files Browse the repository at this point in the history
…ansform3
  • Loading branch information
beomki-yeo committed Aug 23, 2022
1 parent 3631646 commit 7e944cc
Show file tree
Hide file tree
Showing 107 changed files with 2,488 additions and 1,426 deletions.
21 changes: 17 additions & 4 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ message(STATUS "Building 'detray::core' component")

# Set up the library.
detray_add_library( detray_core core
# coordinate include(s)
"include/detray/coordinates/cartesian2.hpp"
"include/detray/coordinates/cartesian3.hpp"
"include/detray/coordinates/coordinate_base.hpp"
"include/detray/coordinates/coordinates.hpp"
"include/detray/coordinates/cylindrical2.hpp"
"include/detray/coordinates/cylindrical3.hpp"
"include/detray/coordinates/line2.hpp"
"include/detray/coordinates/polar2.hpp"
# core include(s)
"include/detray/core/detail/tuple_array_container.hpp"
"include/detray/core/detail/tuple_container.hpp"
Expand All @@ -23,9 +32,9 @@ detray_add_library( detray_core core
"include/detray/definitions/cuda_definitions.hpp"
"include/detray/definitions/indexing.hpp"
"include/detray/definitions/qualifiers.hpp"
"include/detray/definitions/track_parameterization.hpp"
"include/detray/definitions/units.hpp"
"include/detray/definitions/detail/accessor.hpp"
"include/detray/definitions/track_parametrization.hpp"
# field include(s)
"include/detray/field/constant_magnetic_field.hpp"
# geometry include(s)
Expand Down Expand Up @@ -71,21 +80,25 @@ detray_add_library( detray_core core
"include/detray/propagator/constrained_step.hpp"
"include/detray/propagator/detail/covariance_engine.hpp"
"include/detray/propagator/detail/jacobian_engine.hpp"
"include/detray/propagator/detail/vector_engine.hpp"
"include/detray/propagator/line_stepper.hpp"
"include/detray/propagator/navigation_policies.hpp"
"include/detray/propagator/navigator.hpp"
"include/detray/propagator/propagator.hpp"
"include/detray/propagator/rk_stepper.hpp"
"include/detray/propagator/track.hpp"
# tools include(s)
"include/detray/tools/associator.hpp"
"include/detray/tools/bin_association.hpp"
"include/detray/tools/generators.hpp"
"include/detray/tools/grid_array_helper.hpp"
"include/detray/tools/local_object_finder.hpp"
# tracks include(s)
"include/detray/tracks/detail/track_helper.hpp"
"include/detray/tracks/detail/trigonometrics.hpp"
"include/detray/tracks/bound_track_parameters.hpp"
"include/detray/tracks/free_track_parameters.hpp"
"include/detray/tracks/tracks.hpp"
# utils include(s)
"include/detray/utils/algebra_helpers.hpp"
"include/detray/utils/column_wise_operator.hpp"
"include/detray/utils/enumerate.hpp"
"include/detray/utils/invalid_values.hpp"
"include/detray/utils/quadratic_equation.hpp"
Expand Down
105 changes: 105 additions & 0 deletions core/include/detray/coordinates/cartesian2.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2020-2022 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "detray/coordinates/coordinate_base.hpp"
#include "detray/definitions/qualifiers.hpp"

namespace detray {

/** Frame projection into a cartesian coordinate frame
*/
template <typename transform3_t>
struct cartesian2 final : public coordinate_base<cartesian2, transform3_t> {

/// @name Type definitions for the struct
/// @{

/// Base type
using base_type = coordinate_base<cartesian2, transform3_t>;
/// Sclar type
using scalar_type = typename base_type::scalar_type;
/// Point in 2D space
using point2 = typename base_type::point2;
/// Point in 3D space
using point3 = typename base_type::point3;
/// Vector in 3D space
using vector3 = typename base_type::vector3;
/// Matrix actor
using matrix_actor = typename base_type::matrix_actor;
/// Matrix size type
using size_type = typename base_type::size_type;
/// 2D matrix type
template <size_type ROWS, size_type COLS>
using matrix_type = typename base_type::template matrix_type<ROWS, COLS>;

// Trigonometrics
using trigonometrics = typename base_type::trigonometrics;
// Vector types
using bound_vector = typename base_type::bound_vector;
using free_vector = typename base_type::free_vector;

/// @}

/** This method transform from a point from 2D cartesian frame to a 2D
* cartesian point */
DETRAY_HOST_DEVICE
inline point2 operator()(const point2 &local2) const {

return {local2[0], local2[1]};
}

/** This method transform from a point from 3D cartesian frame to a 2D
* cartesian point */
DETRAY_HOST_DEVICE
inline point2 operator()(const point3 &local3) const {

return {local3[0], local3[1]};
}

/** This method transform from a point from global cartesian 3D frame to a
* local 2D cartesian point */
DETRAY_HOST_DEVICE
inline point2 global_to_local(const transform3_t &trf, const point3 &p,
const vector3 & /*d*/) const {
const auto local3 = trf.point_to_local(p);
return this->operator()(local3);
}

/** This method transform from a local 2D cartesian point to a point global
* cartesian 3D frame*/
template <typename mask_t>
DETRAY_HOST_DEVICE inline point3 local_to_global(
const transform3_t &trf, const mask_t & /*mask*/, const point2 &p,
const vector3 & /*d*/) const {
return trf.point_to_global(point3{p[0], p[1], 0.});
}

DETRAY_HOST_DEVICE
inline matrix_type<3, 2> bound_to_free_rotation(
const transform3_t &trf3, const trigonometrics & /*t*/) {

// Get d(x,y,z)/d(loc0, loc1)
return matrix_actor().template block<3, 2>(trf3.matrix(), 0, 0);
}

DETRAY_HOST_DEVICE
inline matrix_type<2, 3> free_to_bound_rotation(
const transform3_t &trf3, const trigonometrics & /*t*/) {

// Get transpose of transform3 matrix
const auto trf3T = matrix_actor().transpose(trf3);

// Get d(loc0, loc1)/d(x,y,z)
return matrix_actor().template block<2, 3>(trf3T.matrix(), 0, 0);
}

}; // struct cartesian2

} // namespace detray
61 changes: 61 additions & 0 deletions core/include/detray/coordinates/cartesian3.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2022 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "detray/coordinates/coordinate_base.hpp"
#include "detray/definitions/qualifiers.hpp"

namespace detray {

/** Frame projection into a cartesian coordinate frame
*/
template <typename transform3_t>
struct cartesian3 final : public coordinate_base<cartesian3, transform3_t> {

/// @name Type definitions for the struct
/// @{

/// Base type
using base_type = coordinate_base<cartesian3, transform3_t>;
/// Sclar type
using scalar_type = typename base_type::scalar_type;
/// Point in 2D space
using point2 = typename base_type::point2;
/// Point in 3D space
using point3 = typename base_type::point3;
/// Vector in 3D space
using vector3 = typename base_type::vector3;

/// @}

/** This method transform from a point from 3D cartesian frame to a 3D
* cartesian point */
DETRAY_HOST_DEVICE
inline point3 operator()(const point3 &local3) const { return local3; }

/** This method transform from a point from global cartesian 3D frame to a
* local 3D cartesian point */
DETRAY_HOST_DEVICE
inline point3 global_to_local(const transform3_t &trf, const point3 &p,
const vector3 & /*d*/) const {
return trf.point_to_local(p);
}

/** This method transform from a local 3D cartesian point to a point global
* cartesian 3D frame*/
template <typename mask_t>
DETRAY_HOST_DEVICE inline point3 local_to_global(
const transform3_t &trf, const mask_t & /*mask*/, const point3 &p,
const vector3 & /*d*/) const {
return trf.point_to_global(p);
}

}; // struct cartesian3

} // namespace detray
Loading

0 comments on commit 7e944cc

Please sign in to comment.