Skip to content

Commit

Permalink
Merge branch 'main' into chore-clean-eventgen-includes
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 9, 2024
2 parents 7285d0d + 47db0b9 commit 269bed1
Show file tree
Hide file tree
Showing 142 changed files with 1,998 additions and 2,147 deletions.
70 changes: 43 additions & 27 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,33 +142,49 @@ build_exatrkx:
- cmake --build build -- -j6
- ccache -s

# test_exatrkx_unittests:
# stage: test
# needs:
# - build_exatrkx
# image: ghcr.io/acts-project/ubuntu2204_exatrkx:63
# tags:
# - docker-gpu-nvidia
# script:
# - ctest --test-dir build -R ExaTrkX
#
# test_exatrkx_python:
# stage: test
# needs:
# - build_exatrkx
# image: ghcr.io/acts-project/ubuntu2204_exatrkx:63
# tags:
# - docker-gpu-nvidia
# script:
# - apt-get update -y
# - apt-get install -y python3 libxxhash0
# - source build/this_acts_withdeps.sh
# - git clone $CLONE_URL src
# - cd src
# - git checkout $HEAD_SHA
# - pip3 install -r Examples/Python/tests/requirements.txt
# - nvidia-smi
# - pytest -rFsv -k test_exatrkx
test_exatrkx_unittests:
stage: test
needs:
- build_exatrkx
image: ghcr.io/acts-project/ubuntu2204_exatrkx:63
variables:
DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-22.04/deps.$DEPENDENCY_TAG.tar.zst
tags:
- docker-gpu-nvidia
script:

- apt-get update -y
- git clone $CLONE_URL src
- cd src
- git checkout $HEAD_SHA
- source CI/dependencies.sh
- cd ..
- ctest --test-dir build -R ExaTrkX

test_exatrkx_python:
stage: test
needs:
- build_exatrkx
image: ghcr.io/acts-project/ubuntu2204_exatrkx:63
variables:
DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/ubuntu-22.04/deps.$DEPENDENCY_TAG.tar.zst
tags:
- docker-gpu-nvidia
script:
- apt-get update -y
- git clone $CLONE_URL src
- cd src
- git checkout $HEAD_SHA
- nvidia-smi
- source CI/dependencies.sh
- source ../build/this_acts_withdeps.sh
- python3 -m pip install -r Examples/Python/tests/requirements.txt
- echo $PYTHONPATH
- which python3
- python3 --version
- python3 -c "import acts"
- pytest -rFsv -k torch --collect-only
- pytest -rFsv -k gpu-torch # For now only test torch GPU pipeline

build_linux_ubuntu:
stage: build
Expand Down
1 change: 0 additions & 1 deletion CI/codespell_ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ coner
dthe
iself
sortings
fime
gaus
te
parm
Expand Down
4 changes: 3 additions & 1 deletion CI/physmon/physmon_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def makeSetup() -> PhysmonSetup:
level=acts.logging.INFO,
)

detector, trackingGeometry, decorators = getOpenDataDetector(matDeco)
detector = getOpenDataDetector(matDeco)
trackingGeometry = detector.trackingGeometry()
decorators = detector.contextDecorators()
setup = PhysmonSetup(
detector=detector,
trackingGeometry=trackingGeometry,
Expand Down
2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_trackfinding_1muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run_ckf_tracking(label, seeding):
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
hits=(9, None),
removeNeutral=True,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
hits=(9, None),
removeNeutral=True,
),
)
Expand Down
2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_trackfinding_ttbar_pu200.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
),
postSelectParticles=ParticleSelectorConfig(
pt=(0.5 * u.GeV, None),
measurements=(9, None),
hits=(9, None),
removeNeutral=True,
),
)
Expand Down
4 changes: 1 addition & 3 deletions Core/include/Acts/Utilities/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#pragma once

// STL include(s)
#include <cassert>
#include <ctime>
#include <exception>
#include <functional>
#include <iomanip>
#include <iostream>
#include <memory>
Expand Down
141 changes: 141 additions & 0 deletions Core/include/Acts/Utilities/Result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class Result {
Result(std::variant<T, E>&& var) : m_var(std::move(var)) {}

public:
using ValueType = T;
using ErrorType = E;

/// Default construction is disallowed.
Result() = delete;

Expand Down Expand Up @@ -172,6 +175,144 @@ class Result {
return std::move(std::get<T>(m_var));
}

/// Retrieves the valid value from the result object, or returns a default
/// value if no valid value exists.
///
/// @param[in] v The default value to use if no valid value exists.
/// @note This is the lvalue version.
/// @note This function always returns by value.
/// @return Either the valid value, or the given substitute.
template <typename U>
std::conditional_t<std::is_reference_v<U>, const T&, T> value_or(U&& v) const&
requires(std::same_as<std::decay_t<U>, T>)
{
if (ok()) {
return value();
} else {
return std::forward<U>(v);
}
}

/// Retrieves the valid value from the result object, or returns a default
/// value if no valid value exists.
///
/// @param[in] v The default value to use if no valid value exists.
/// @note This is the rvalue version which moves the value out.
/// @note This function always returns by value.
/// @return Either the valid value, or the given substitute.
template <typename U>
T value_or(U&& v) &&
requires(std::same_as<std::decay_t<U>, T>)
{
if (ok()) {
return std::move(*this).value();
} else {
return std::forward<U>(v);
}
}

/// Transforms the value contained in this result.
///
/// Applying a function `f` to a valid value `x` returns `f(x)`, while
/// applying `f` to an invalid value returns another invalid value.
///
/// @param[in] callable The transformation function to apply.
/// @note This is the lvalue version.
/// @note This functions is `fmap` on the functor in `A` of `Result<A, E>`.
/// @return The modified valid value if exists, or an error otherwise.
template <typename C>
auto transform(C&& callable) const&
requires std::invocable<C, const T&>
{
using CallableReturnType = decltype(std::declval<C>()(std::declval<T>()));
using R = Result<std::decay_t<CallableReturnType>, E>;
if (ok()) {
return R::success(callable(value()));
} else {
return R::failure(error());
}
}

/// Transforms the value contained in this result.
///
/// Applying a function `f` to a valid value `x` returns `f(x)`, while
/// applying `f` to an invalid value returns another invalid value.
///
/// @param[in] callable The transformation function to apply.
/// @note This is the rvalue version.
/// @note This functions is `fmap` on the functor in `A` of `Result<A, E>`.
/// @return The modified valid value if exists, or an error otherwise.
template <typename C>
auto transform(C&& callable) &&
requires std::invocable<C, T&&>
{
using CallableReturnType = decltype(std::declval<C>()(std::declval<T>()));
using R = Result<std::decay_t<CallableReturnType>, E>;
if (ok()) {
return R::success(callable(std::move(*this).value()));
} else {
return R::failure(std::move(*this).error());
}
}

/// Bind a function to this result monadically.
///
/// This function takes a function `f` and, if this result contains a valid
/// value `x`, returns `f(x)`. If the type of `x` is `T`, then `f` is
/// expected to accept type `T` and return `Result<U>`. In this case,
/// `transform` would return the unhelpful type `Result<Result<U>>`, so
/// `and_then` strips away the outer layer to return `Result<U>`. If the
/// value is invalid, this returns an invalid value in `Result<U>`.
///
/// @param[in] callable The transformation function to apply.
/// @note This is the lvalue version.
/// @note This functions is `>>=` on the functor in `A` of `Result<A, E>`.
/// @return The modified valid value if exists, or an error otherwise.
template <typename C>
auto and_then(C&& callable) const&
requires std::invocable<C, const T&>
{
using R = decltype(std::declval<C>()(std::declval<T>()));

static_assert(std::same_as<typename R::ErrorType, ErrorType>,
"bind must take a callable with the same error type");

if (ok()) {
return callable(value());
} else {
return R::failure(error());
}
}

/// Bind a function to this result monadically.
///
/// This function takes a function `f` and, if this result contains a valid
/// value `x`, returns `f(x)`. If the type of `x` is `T`, then `f` is
/// expected to accept type `T` and return `Result<U>`. In this case,
/// `transform` would return the unhelpful type `Result<Result<U>>`, so
/// `and_then` strips away the outer layer to return `Result<U>`. If the
/// value is invalid, this returns an invalid value in `Result<U>`.
///
/// @param[in] callable The transformation function to apply.
/// @note This is the rvalue version.
/// @note This functions is `>>=` on the functor in `A` of `Result<A, E>`.
/// @return The modified valid value if exists, or an error otherwise.
template <typename C>
auto and_then(C&& callable) &&
requires std::invocable<C, T&&>
{
using R = decltype(std::declval<C>()(std::declval<T>()));

static_assert(std::same_as<typename R::ErrorType, ErrorType>,
"bind must take a callable with the same error type");

if (ok()) {
return callable(std::move(*this).value());
} else {
return R::failure(std::move(*this).error());
}
}

private:
std::variant<T, E> m_var;

Expand Down
38 changes: 1 addition & 37 deletions Examples/Algorithms/Geant4/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
add_library(
ActsExamplesGeant4
SHARED
src/GdmlDetectorConstruction.cpp
src/TelescopeG4DetectorConstruction.cpp
src/Geant4Simulation.cpp
src/MagneticFieldWrapper.cpp
src/MaterialPhysicsList.cpp
Expand Down Expand Up @@ -32,43 +30,9 @@ target_link_libraries(
PUBLIC
ActsCore
ActsExamplesFramework
ActsExamplesDetectorTelescope
ActsExamplesDetectorsCommon
Boost::headers
${Geant4_LIBRARIES}
)

if(ACTS_BUILD_EXAMPLES_DD4HEP)
if(${DD4hep_VERSION} VERSION_LESS 1.11)
target_include_directories(
ActsExamplesGeant4
PRIVATE ${DD4hep_INCLUDE_DIRS}
)
target_link_libraries(
ActsExamplesGeant4
PRIVATE ${DD4hep_DDCORE_LIBRARY} ${DD4hep_DDG4_LIBRARY}
)
else()
target_link_libraries(
ActsExamplesGeant4
PUBLIC ActsExamplesDetectorDD4hep DD4hep::DDCore DD4hep::DDG4
)
endif()

target_sources(ActsExamplesGeant4 PUBLIC src/DDG4DetectorConstruction.cpp)
endif()

if(ACTS_BUILD_PLUGIN_GEOMODEL)
target_sources(
ActsExamplesGeant4
PUBLIC src/GeoModelDetectorConstruction.cpp
)

find_library(GeoModel2G4_LIBRARY GeoModel2G4 REQUIRED)

target_link_libraries(
ActsExamplesGeant4
PUBLIC ActsPluginGeoModel ${GeoModel2G4_LIBRARY}
)
endif()

install(TARGETS ActsExamplesGeant4 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
Loading

0 comments on commit 269bed1

Please sign in to comment.