diff --git a/.github/labeler.yml b/.github/labeler.yml index 904ef86daab..11d0c981fa7 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,37 +1,67 @@ 'Infrastructure': - - .github/** - - CI/** - - cmake/** + - changed-files: + - any-glob-to-any-file: + - .github/** + - CI/** + - cmake/** 'Component - Core': - - Core/** - - Tests/UnitTests/Core/** + - changed-files: + - any-glob-to-any-file: + - Core/** + - Tests/UnitTests/Core/** 'Component - Examples': - - Examples/** - - Tests/UnitTests/Examples/** + - changed-files: + - any-glob-to-any-file: + - Examples/** + - Tests/UnitTests/Examples/** 'Component - Fatras': - - Fatras/** - - Tests/UnitTests/Fatras/** + - changed-files: + - any-glob-to-any-file: + - Fatras/** + - Tests/UnitTests/Fatras/** 'Component - Plugins': - - Plugins/** - - Tests/UnitTests/Plugins/** + - changed-files: + - any-glob-to-any-file: + - Plugins/** + - Tests/UnitTests/Plugins/** 'Component - Documentation': - - docs/** + - changed-files: + - any-glob-to-any-file: + - docs/** 'Changes Performance': - - CI/physmon/reference/** - - Examples/Python/tests/root_file_hashes.txt + - changed-files: + - any-glob-to-any-file: + - CI/physmon/reference/** + - Examples/Python/tests/root_file_hashes.txt 'Event Data Model': - - '**/*EventData*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*EventData*/**' 'Clustering': - - '**/*Clusterization*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*Clusterization*/**' 'SP formation': - - '**/*SpacePointFormation*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*SpacePointFormation*/**' 'Seeding': - - '**/*Seeding*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*Seeding*/**' 'Track Finding': - - '**/*TrackFinding*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*TrackFinding*/**' 'Track Fitting': - - '**/*TrackFitting*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*TrackFitting*/**' 'Vertexing': - - '**/*Vertexing*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*Vertexing*/**' 'Ambiguity Resolution': - - '**/*AmbiguityResolution*/**' + - changed-files: + - any-glob-to-any-file: + - '**/*AmbiguityResolution*/**' diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index bbc0f005a2f..4d66787ab16 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -29,7 +29,7 @@ env: jobs: build_debug: runs-on: ubuntu-latest - container: ghcr.io/acts-project/ubuntu2204:v41 + container: ghcr.io/acts-project/ubuntu2404:51 steps: - uses: actions/checkout@v4 @@ -97,7 +97,7 @@ jobs: build_performance: runs-on: ubuntu-latest - container: ghcr.io/acts-project/ubuntu2204:v41 + container: ghcr.io/acts-project/ubuntu2404:51 if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index becc8f76679..04e948c8621 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -24,7 +24,7 @@ env: jobs: linux_ubuntu: runs-on: ubuntu-latest - container: ghcr.io/acts-project/ubuntu2204:51 + container: ghcr.io/acts-project/ubuntu2404:51 env: INSTALL_DIR: ${{ github.workspace }}/install ACTS_LOG_FAILURE_THRESHOLD: WARNING @@ -121,7 +121,7 @@ jobs: linux_examples_test: runs-on: ubuntu-latest - container: ghcr.io/acts-project/ubuntu2204:v41 + container: ghcr.io/acts-project/ubuntu2404:51 needs: [linux_ubuntu] env: ACTS_SEQUENCER_DISABLE_FPEMON: true @@ -158,7 +158,7 @@ jobs: linux_physmon: runs-on: ubuntu-latest - container: ghcr.io/acts-project/ubuntu2204:v41 + container: ghcr.io/acts-project/ubuntu2404:51 needs: [linux_ubuntu] env: ACTS_SEQUENCER_DISABLE_FPEMON: true @@ -191,7 +191,7 @@ jobs: run: > echo "::group::Dependencies" && git config --global safe.directory "$GITHUB_WORKSPACE" - && pip3 install histcmp==0.6.5 spyral-cli==1.1.1 matplotlib + && pip3 install histcmp==0.6.6 matplotlib && pip3 install -r Examples/Scripts/requirements.txt && /usr/local/bin/geant4-config --install-datasets && source build/this_acts_withdeps.sh @@ -211,7 +211,7 @@ jobs: if: github.ref == 'refs/heads/main' steps: - name: Install dependencies - run: pip3 install spyral-cli==1.1.0 + run: pip3 install spyral-cli==1.1.2 - uses: actions/download-artifact@v4 with: @@ -238,13 +238,13 @@ jobs: strategy: matrix: include: - - image: ubuntu2004 + - image: ubuntu2404 std: 17 - image: ubuntu2204_cpp20 std: 20 - image: ubuntu2204_clang std: 17 - container: ghcr.io/acts-project/${{ matrix.image }}:v41 + container: ghcr.io/acts-project/${{ matrix.image }}:51 env: INSTALL_DIR: ${{ github.workspace }}/install ACTS_LOG_FAILURE_THRESHOLD: WARNING @@ -326,115 +326,6 @@ jobs: - name: Downstream run run: ./build-downstream/bin/ShowActsVersion - linux-nodeps: - runs-on: ubuntu-latest - container: ghcr.io/acts-project/${{ matrix.image }}:v41 - strategy: - matrix: - image: - # Note: We only want the centos8 base here, and so we do not - # setup the lcg environment below - - centos8-lcg100-gcc10 - env: - # NOTE: we setup the ROOT from LCG even though this is a - # "nodeps" build. This is because we want to test that the boost - # dependency is handled correctly when building the examples - # (same for tbb below). ROOT is available from the "epel" - # official centos8 repo, but to save hundreds of MB's of package - # download we simply use lcg for this one package. - SETUP: source /opt/lcg/ROOT/v6.24.00-e7098/x86_64-centos8-gcc10-opt/bin/thisroot.sh - PRELOAD: export LD_PRELOAD=/opt/lcg/gcc/10/x86_64-centos8/lib64/libstdc++.so.6 - INSTALL_DIR: ${{ github.workspace }}/install - ACTS_LOG_FAILURE_THRESHOLD: WARNING - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - # Install tbb-devel also to build the examples - run: > - dnf -y install ninja-build tbb-devel ccache - && ln -s $(find / -type f -name 'ccache') /usr/local/bin/ccache - - - name: Restore ccache - uses: actions/cache/restore@v4 - id: ccache-restore - with: - path: ${{ github.workspace }}/ccache - key: ${{ runner.os }}-ccache-linux-nodeps_${{ env.CCACHE_KEY_SUFFIX }}_${{ github.sha }} - restore-keys: | - ${{ runner.os }}-ccache-linux-nodeps_${{ env.CCACHE_KEY_SUFFIX }}_ - - - name: Configure - run: > - ccache -z && - cmake -B build -S . - -GNinja - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS=-Werror - -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" - -DACTS_BUILD_UNITTESTS=ON - -DACTS_BUILD_INTEGRATIONTESTS=ON - -DACTS_ENABLE_LOG_FAILURE_THRESHOLD=ON - -DACTS_FORCE_ASSERTIONS=ON - -DACTS_USE_SYSTEM_BOOST=OFF - -DACTS_USE_SYSTEM_EIGEN3=OFF - -DACTS_BUILD_PLUGIN_JSON=ON - - name: Build - run: ${SETUP} && ( cmake --build build || cmake --build build ) - # The above line is required as a sort of retry mechanism. Without it, - # the build fails for technical reasons. - - name: ccache stats - run: ccache -s - - name: Save ccache - uses: actions/cache/save@v4 - if: always() - with: - path: ${{ github.workspace }}/ccache - key: ${{ steps.ccache-restore.outputs.cache-primary-key }} - - name: Unit tests - run: ${SETUP} && cmake --build build --target test - - name: Integration tests - run: ${SETUP} && cmake --build build --target integrationtests - - name: Install - run: ${SETUP} && cmake --build build --target install - # For some reasons, this version of ROOT complains that it - # cannot find the nlohmann::json config before we even installed - # it. So we have to do the examples in separate step. - - name: Configure Examples - run: > - ${SETUP} && - cmake -B build -S . - -GNinja - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS=-Werror - -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" - -DACTS_ENABLE_LOG_FAILURE_THRESHOLD=ON - -DACTS_FORCE_ASSERTIONS=ON - -DACTS_USE_SYSTEM_BOOST=OFF - -DACTS_USE_SYSTEM_EIGEN3=OFF - -DACTS_BUILD_EXAMPLES=ON - - name: Build Examples - run: ${SETUP} && ${PRELOAD} && cmake --build build - - name: Install Examples - run: ${SETUP} && cmake --build build --target install - - name: Run Examples - # Run a single example to be sure that the boost dependencies - # got linked correctly - run: ${SETUP} && ${PRELOAD} && "${INSTALL_DIR}/bin/ActsExampleHelloWorld" -n 1 - - name: Downstream configure - run: > - ${SETUP} && - cmake -B build-downstream-nodeps -S Tests/DownstreamProjectNodeps - -GNinja - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS=-Werror - -DCMAKE_PREFIX_PATH="${INSTALL_DIR}" - - name: Downstream build - run: cmake --build build-downstream-nodeps - - name: Downstream run - run: ./build-downstream-nodeps/bin/ShowActsVersion - && CI/check_boost_eigen_versions.sh ./build-downstream-nodeps/bin/ShowActsVersion - macos: runs-on: macos-13 env: diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 83069bf636b..5193027dae1 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} sync-labels: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a03bff2d20..4747f60f4d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,14 +17,23 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - run: pip install -r CI/release_requirements.txt + - name: Install git-cliff + run: | + curl -L https://github.com/orhun/git-cliff/releases/download/v2.3.0/git-cliff-2.3.0-x86_64-unknown-linux-musl.tar.gz > git-cliff.tar.gz + echo "3adde9625195825db9a59dd954fc90604172ba4b git-cliff.tar.gz" | shasum -c + mkdir git-cliff + tar xzf git-cliff.tar.gz --strip-components 1 --directory git-cliff + cp git-cliff/git-cliff /usr/local/bin/git-cliff - name: Create release + env: + # for gh cli + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # for git-cliff + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - CI/release.py make-release + + CI/release.sh diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7bc8e68f8e8..b514593fe19 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -105,7 +105,7 @@ jobs: git status - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp@v2 + uses: SonarSource/sonarcloud-github-c-cpp@v3 - name: Debug run: | diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65b313bdbf1..9f976a57708 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ variables: clang_tidy: stage: build - image: ghcr.io/acts-project/ubuntu2004:v41 + image: ghcr.io/acts-project/ubuntu2404:51 tags: - large artifacts: @@ -20,23 +20,17 @@ clang_tidy: - git checkout $HEAD_SHA - > apt-get update - && apt-get install -y g++-8 libstdc++-8-dev parallel software-properties-common - && curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-17 main' - && apt-get install -y clang-17 clang-tidy-17 - && ln -s /usr/bin/clang++-17 /usr/bin/clang++ - && ln -s /usr/bin/clang-17 /usr/bin/clang - && ln -s /usr/bin/clang-tidy-17 /usr/bin/clang-tidy - && mkdir -p /opt/lib/gcc/x86_64-linux-gnu - && ln -s /usr/lib/gcc/x86_64-linux-gnu/8/ /opt/lib/gcc/x86_64-linux-gnu/ - && clang++ --gcc-toolchain=/opt -v + && apt-get install -y clang-tidy-18 + && ln -sf /usr/bin/clang++-18 /usr/bin/clang++ + && ln -sf /usr/bin/clang-18 /usr/bin/clang + && ln -sf /usr/bin/clang-tidy-18 /usr/bin/clang-tidy - > cmake -B build -S . -GNinja -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS="-Werror --gcc-toolchain=/opt" + -DCMAKE_CXX_FLAGS="-Werror" -DACTS_BUILD_EVERYTHING=on -DACTS_RUN_CLANG_TIDY=on @@ -138,7 +132,7 @@ test_exatrkx_python: build_linux_ubuntu: stage: build - image: ghcr.io/acts-project/ubuntu2204:v41 + image: ghcr.io/acts-project/ubuntu2404:51 cache: key: ccache-${CI_JOB_NAME_SLUG}-${HEAD_REF}-${CCACHE_KEY_SUFFIX} @@ -189,7 +183,7 @@ build_linux_ubuntu: linux_test_examples: stage: test - image: ghcr.io/acts-project/ubuntu2204:v41 + image: ghcr.io/acts-project/ubuntu2404:51 needs: [build_linux_ubuntu] script: @@ -210,7 +204,7 @@ linux_test_examples: linux_physmon: stage: test - image: ghcr.io/acts-project/ubuntu2204:v41 + image: ghcr.io/acts-project/ubuntu2404:51 needs: [build_linux_ubuntu] artifacts: @@ -230,7 +224,7 @@ linux_physmon: - cd .. - git config --global safe.directory "$GITHUB_WORKSPACE" - - pip3 install histcmp==0.6.5 spyral-cli==1.1.0 matplotlib + - pip3 install histcmp==0.6.6 matplotlib - pip3 install -r src/Examples/Scripts/requirements.txt - /usr/local/bin/geant4-config --install-datasets - source build/this_acts_withdeps.sh @@ -304,11 +298,11 @@ linux_physmon: # Downstream run - ./build-downstream/bin/ShowActsVersion -linux_ubuntu_2004_cpp17: +linux_ubuntu_2404_cpp17: <<: *linux_ubuntu_extra variables: CXXSTD: 17 - image: ghcr.io/acts-project/ubuntu2004:v41 + image: ghcr.io/acts-project/ubuntu2404:51 linux_ubuntu_2204_cpp20: <<: *linux_ubuntu_extra @@ -414,17 +408,6 @@ linux_ubuntu_2204_clang: - ctest --test-dir build -j$(nproc) -lcg_102b: - <<: *lcg_base_job - - variables: - LCG_VERSION: "102b" - - parallel: - matrix: - - OS: [centos7] - COMPILER: [gcc11] - lcg_104: <<: *lcg_base_job diff --git a/Alignment/CMakeLists.txt b/Alignment/CMakeLists.txt index b16128bcf05..e33424fc5a0 100644 --- a/Alignment/CMakeLists.txt +++ b/Alignment/CMakeLists.txt @@ -5,7 +5,7 @@ target_include_directories( ActsAlignment PUBLIC $ - $) + $) target_link_libraries( ActsAlignment @@ -19,4 +19,3 @@ install( install( DIRECTORY include/ActsAlignment DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - diff --git a/CI/cliff.toml b/CI/cliff.toml new file mode 100644 index 00000000000..9717176922b --- /dev/null +++ b/CI/cliff.toml @@ -0,0 +1,88 @@ +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +[changelog] +# changelog header +header = """ +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + # {{ version | trim_start_matches(pat="v") }} +{% else %}\ + # [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ## {{ group | striptags | trim | upper_first }} + {% for commit in commits %} + - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ + {% if commit.breaking %} ๐Ÿšจ **BREAKING**: {% endif %}\ + {{ commit.message | upper_first }}\ + {% if commit.github.username %} by @{{ commit.github.username }}{%- endif %}\ + {% endfor %} +{% endfor %}\n +""" +# template for the changelog footer +footer = """ +""" +# remove the leading and trailing s +trim = true +# postprocessors +postprocessors = [ + # { pattern = '', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL +] + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = true +# process each line of a commit as an individual commit +split_commits = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # Replace issue numbers + #{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))"}, + # Check spelling of the commit with https://github.com/crate-ci/typos + # If the spelling is incorrect, it will be automatically fixed. + #{ pattern = '.*', replace_command = 'typos --write-changes -' }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "๐Ÿš€ Features" }, + { message = "^fix", group = "๐Ÿ› Bug Fixes" }, + { message = "^doc", group = "๐Ÿ“š Documentation" }, + { message = "^perf", group = "โšก Performance" }, + { message = "^refactor", group = "๐Ÿšœ Refactor" }, + { message = "^test", group = "๐Ÿงช Testing" }, + { message = "^build", group = " ๐Ÿ› ๏ธ Build" }, + { message = "^chore\\(deps.*\\)", skip = true }, + { message = "^chore|^ci", group = "โš™๏ธ Miscellaneous Tasks" }, + { body = ".*security", group = "๐Ÿ›ก๏ธ Security" }, + { message = "^revert", group = "โ—€๏ธ Revert" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +# tag_pattern = "v[0-9].*" +# regex for skipping tags +# skip_tags = "" +# regex for ignoring tags +# ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +# limit the number of commits included in the changelog. +# limit_commits = 42 + +[remote.github] +owner = "acts-project" +repo = "acts" diff --git a/CI/release.py b/CI/release.py deleted file mode 100755 index 827fd7bf1dc..00000000000 --- a/CI/release.py +++ /dev/null @@ -1,387 +0,0 @@ -#!/usr/bin/env python3 -import os -import asyncio -from typing import List, Optional, Tuple -from pathlib import Path -import sys -import http -import json -import yaml -import datetime -import typer -import base64 - -import aiohttp -from gidgethub.aiohttp import GitHubAPI -from gidgethub import InvalidField -from semantic_release.enums import LevelBump -from semantic_release.version import Version -from semantic_release.commit_parser.angular import ( - AngularCommitParser, - AngularParserOptions, -) -from semantic_release.commit_parser.token import ParseError, ParseResult -import gidgethub -import sh -from dotenv import load_dotenv -import functools - -load_dotenv() - -git = sh.git - -RETRY_COUNT = 10 -RETRY_INTERVAL = 0.5 # seconds - - -def get_repo(): - repo = os.environ.get("GITHUB_REPOSITORY", None) - if repo is not None: - return repo - - origin = git.remote("get-url", "origin") - _, loc = origin.split(":", 1) - repo, _ = loc.split(".", 1) - return repo - - -class Commit: - sha: str - message: str - author: str - - def __init__(self, sha: str, message: str, author: str): - self.sha = sha - self.message = self._normalize(message) - self.author = author - - @staticmethod - def _normalize(message): - message = message.replace("\r", "\n") - return message - - def __str__(self): - message = self.message.split("\n")[0] - return f"Commit(sha='{self.sha[:8]}', message='{message}')" - - # needed for semantic_release duck typing - @property - def hexsha(self): - return self.sha - - -_default_parser = AngularCommitParser(AngularParserOptions()) - - -def evaluate_version_bump( - commits: List[Commit], commit_parser=_default_parser -) -> Optional[str]: - """ - Adapted from: https://github.com/relekang/python-semantic-release/blob/master/semantic_release/history/logs.py#L22 - """ - bump = None - - changes = [] - commit_count = 0 - - for commit in commits: - commit_count += 1 - - message: ParseResult = commit_parser.parse(commit) - if isinstance(message, ParseError): - print("Unknown commit message style!") - else: - changes.append(message.bump) - - if changes: - level = max(changes) - if level in LevelBump: - bump = level - else: - print(f"Unknown bump level {level}") - - return bump - - -def generate_changelog(commits, commit_parser=_default_parser) -> dict: - """ - Modified from: https://github.com/relekang/python-semantic-release/blob/48972fb761ed9b0fb376fa3ad7028d65ff407ee6/semantic_release/history/logs.py#L78 - """ - changes: dict = {"breaking": []} - - for commit in commits: - message: ParseResult = commit_parser.parse(commit) - - if isinstance(message, ParseError): - print("Unknown commit message style!") - continue - - if message.type not in changes: - changes[message.type] = list() - - capital_message = ( - message.descriptions[0][0].upper() + message.descriptions[0][1:] - ) - changes[message.type].append((commit.sha, capital_message, commit.author)) - - return changes - - -def markdown_changelog(version: str, changelog: dict, header: bool = False) -> str: - output = f"## v{version}\n" if header else "" - - for section, items in changelog.items(): - if len(items) == 0: - continue - output += "\n### {0}\n".format(section.capitalize()) - - for sha, msg, author in items: - output += "* {} ({}) (@{})\n".format(msg, sha, author) - - return output - - -def update_zenodo(zenodo_file: Path, repo: str, next_version): - data = json.loads(zenodo_file.read_text()) - data["title"] = f"{repo}: v{next_version}" - data["version"] = f"v{next_version}" - zenodo_file.write_text(json.dumps(data, indent=2)) - - -def update_citation(citation_file: Path, next_version): - with citation_file.open() as fh: - data = yaml.safe_load(fh) - data["version"] = f"v{next_version}" - data["date-released"] = datetime.date.today().strftime("%Y-%m-%d") - with citation_file.open("w") as fh: - yaml.dump(data, fh, indent=2) - - -def make_sync(fn): - @functools.wraps(fn) - def wrapped(*args, **kwargs): - loop = asyncio.get_event_loop() - loop.run_until_complete(fn(*args, **kwargs)) - - return wrapped - - -app = typer.Typer() - - -async def get_parsed_commit_range( - start: str, end: str, repo: str, gh: GitHubAPI, edit: bool = False -) -> Tuple[List[Commit], List[Commit]]: - commits_iter = gh.getiter(f"/repos/{repo}/commits?sha={start}") - - commits = [] - unparsed_commits = [] - - try: - async for item in commits_iter: - commit_hash = item["sha"] - commit_message = item["commit"]["message"] - if commit_hash == end: - break - - commit = Commit(commit_hash, commit_message, item["author"]["login"]) - - invalid_message = False - message: ParseResult = _default_parser.parse(commit) - - if isinstance(message, ParseError): - print("Unknown commit message style!") - if not commit_message.startswith("Merge"): - invalid_message = True - - if ( - (invalid_message or edit) - and sys.stdout.isatty() - and False - and typer.confirm(f"Edit effective message '{commit_message}'?") - ): - commit_message = typer.edit(commit_message) - _default_parser(commit_message) - - commits.append(commit) - - if invalid_message: - unparsed_commits.append(commit) - - print("-", commit) - if len(commits) > 200: - raise RuntimeError(f"{len(commits)} are a lot. Aborting!") - return commits, unparsed_commits - except gidgethub.BadRequest: - print( - "BadRequest for commit retrieval. That is most likely because you forgot to push the merge commit." - ) - return - - -@app.command() -@make_sync -async def make_release( - token: str = typer.Argument(..., envvar="GH_TOKEN"), - force_next_version: Optional[str] = typer.Option(None, "--next-version"), - draft: bool = True, - dry_run: bool = False, - edit: bool = False, -): - async with aiohttp.ClientSession(loop=asyncio.get_event_loop()) as session: - gh = GitHubAPI(session, __name__, oauth_token=token) - - version_file = Path("version_number") - current_version = version_file.read_text() - - tag_hash = str(git("rev-list", "-n", "1", f"v{current_version}").strip()) - print("current_version:", current_version, "[" + tag_hash[:8] + "]") - - sha = git("rev-parse", "HEAD").strip() - print("sha:", sha) - - repo = get_repo() - print("repo:", repo) - - commits, _ = await get_parsed_commit_range( - start=sha, end=tag_hash, repo=repo, gh=gh, edit=edit - ) - - bump = evaluate_version_bump(commits) - print("bump:", bump) - if bump is None: - print("-> nothing to do") - return - - current_version_obj = Version(*(map(int, current_version.split(".")))) - next_version_obj = current_version_obj.bump(bump) - next_version = f"{next_version_obj.major}.{next_version_obj.minor}.{next_version_obj.patch}" - if force_next_version is not None: - next_version = force_next_version - print("next version:", next_version) - next_tag = f"v{next_version}" - - changes = generate_changelog(commits) - md = markdown_changelog(next_version, changes, header=False) - - print(md) - - if not dry_run: - execute_bump(next_version) - - git.commit(m=f"Bump to version {next_tag}", no_verify=True) - - target_hash = str(git("rev-parse", "HEAD")).strip() - print("target_hash:", target_hash) - - git.push() - - commit_ok = False - print("Waiting for commit", target_hash[:8], "to be received") - for _ in range(RETRY_COUNT): - try: - url = f"/repos/{repo}/commits/{target_hash}" - await gh.getitem(url) - commit_ok = True - break - except InvalidField: - print("Commit", target_hash[:8], "not received yet") - pass # this is what we want - await asyncio.sleep(RETRY_INTERVAL) - - if not commit_ok: - print("Commit", target_hash[:8], "was not created on remote") - sys.exit(1) - - print("Commit", target_hash[:8], "received") - - await gh.post( - f"/repos/{repo}/releases", - data={ - "body": md, - "tag_name": next_tag, - "name": next_tag, - "draft": draft, - "target_commitish": target_hash, - }, - ) - - -def execute_bump(next_version: str): - version_file = Path("version_number") - - version_file.write_text(next_version) - git.add(version_file) - - repo = get_repo() - zenodo_file = Path(".zenodo.json") - update_zenodo(zenodo_file, repo, next_version) - git.add(zenodo_file) - - citation_file = Path("CITATION.cff") - update_citation(citation_file, next_version) - git.add(citation_file) - - -@app.command() -def bump( - next_version: str = typer.Argument(..., help="Format: X.Y.Z"), commit: bool = False -): - execute_bump(next_version) - next_tag = f"v{next_version}" - - if commit: - git.commit(m=f"Bump to version {next_tag}", no_verify=True) - - -async def get_release_branch_version( - repo: str, target_branch: str, gh: GitHubAPI -) -> str: - content = await gh.getitem( - f"repos/{repo}/contents/version_number?ref={target_branch}" - ) - assert content["type"] == "file" - return base64.b64decode(content["content"]).decode("utf-8") - - -async def get_tag_hash(tag: str, repo: str, gh: GitHubAPI) -> str: - async for item in gh.getiter(f"repos/{repo}/tags"): - if item["name"] == tag: - return item["commit"]["sha"] - raise ValueError(f"Tag {tag} not found") - - -async def get_merge_commit_sha(pr: int, repo: str, gh: GitHubAPI) -> str: - for _ in range(RETRY_COUNT): - pull = await gh.getitem(f"repos/{repo}/pulls/{pr}") - if pull["mergeable"] is None: - # no merge commit yet, wait a bit - await asyncio.sleep(RETRY_INTERVAL) - continue - if not pull["mergeable"]: - raise RuntimeError("Pull request is not mergeable, can't continue") - return pull["merge_commit_sha"] - raise RuntimeError("Timeout waiting for pull request merge status") - - -async def get_tag(tag: str, repo: str, gh: GitHubAPI): - async for item in gh.getiter(f"repos/{repo}/tags"): - if item["name"] == tag: - return item - return None - - -async def get_release(tag: str, repo: str, gh: GitHubAPI): - existing_release = None - try: - existing_release = await gh.getitem(f"repos/{repo}/releases/tags/v{tag}") - except gidgethub.BadRequest as e: - if e.status_code == http.HTTPStatus.NOT_FOUND: - pass # this is what we want - else: - raise e - return existing_release - - -if __name__ == "__main__": - app() diff --git a/CI/release.sh b/CI/release.sh new file mode 100755 index 00000000000..7316234acfc --- /dev/null +++ b/CI/release.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -e +set -u + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +export GIT_CLIFF_CONFIG=$SCRIPT_DIR/cliff.toml + +# helper function to selectively print and run commands without a subshell +function run() { + set -x + "$@" + # save exit code + { rec=$?; } 2> /dev/null + { set +x; } 2> /dev/null + # restore exit code + (exit $rec) +} + +export run + +version=$(git cliff --bumped-version) +echo "Bumped version will be: $version" + +zenodo=$(cat .zenodo.json) +echo "$zenodo" \ + | jq --arg version "$version" '.version = $version' \ + | jq --arg version "$version" '.title = "acts-project/acts: \($version)"' \ + > .zenodo.json +echo "- Updated .zenodo.json" + +citation=$(cat CITATION.cff) +echo "$citation" \ + | sed "s/^version: .*/version: $version/" \ + > CITATION.cff +echo "- Updated CITATION.cff" + +echo "$version" | sed 's/^v//g' > version_number +echo "- Updated version_bumber" + +run git add .zenodo.json CITATION.cff version_number +run git commit -n -m"Bump version to $version" +CI=${CI:-} +if [ -n "$CI" ]; then + run git push +fi + +run git cliff --tag "$version" --latest --unreleased -o release.md + +RELEASE_TARGET=${RELEASE_TARGET:-$(git rev-parse HEAD)} + +set +e +! gh release view "$version" > /dev/null 2>&1 +release_exists=$? +set -e +if [[ $release_exists == 1 ]]; then + echo "Release $version exists" + run gh release edit $version \ + --notes-file release.md \ + --target $RELEASE_TARGET \ + --draft +else + echo "Release $version does not exist" + run gh release create $version \ + --title "$version" \ + --notes-file release.md \ + --target $RELEASE_TARGET \ + --draft +fi diff --git a/CI/release_requirements.in b/CI/release_requirements.in deleted file mode 100644 index adb09d2a499..00000000000 --- a/CI/release_requirements.in +++ /dev/null @@ -1,7 +0,0 @@ -python-semantic-release -aiohttp -gidgethub -python-dotenv -PyYAML -typer -sh \ No newline at end of file diff --git a/CI/release_requirements.txt b/CI/release_requirements.txt deleted file mode 100644 index ea26f526a40..00000000000 --- a/CI/release_requirements.txt +++ /dev/null @@ -1,108 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.10 -# by the following command: -# -# pip-compile CI/release_requirements.in -# -aiohttp==3.9.1 - # via -r CI/release_requirements.in -aiosignal==1.3.1 - # via aiohttp -annotated-types==0.6.0 - # via pydantic -async-timeout==4.0.3 - # via aiohttp -attrs==23.1.0 - # via aiohttp -certifi==2023.11.17 - # via requests -cffi==1.16.0 - # via cryptography -charset-normalizer==3.3.2 - # via requests -click==8.1.7 - # via - # python-semantic-release - # typer -cryptography==41.0.7 - # via pyjwt -dotty-dict==1.3.1 - # via python-semantic-release -frozenlist==1.4.0 - # via - # aiohttp - # aiosignal -gidgethub==5.3.0 - # via -r CI/release_requirements.in -gitdb==4.0.11 - # via gitpython -gitpython==3.1.40 - # via python-semantic-release -idna==3.6 - # via - # requests - # yarl -importlib-resources==6.1.1 - # via python-semantic-release -jinja2==3.1.2 - # via python-semantic-release -markdown-it-py==3.0.0 - # via rich -markupsafe==2.1.3 - # via jinja2 -mdurl==0.1.2 - # via markdown-it-py -multidict==6.0.4 - # via - # aiohttp - # yarl -pycparser==2.21 - # via cffi -pydantic==2.5.2 - # via python-semantic-release -pydantic-core==2.14.5 - # via pydantic -pygments==2.17.2 - # via rich -pyjwt[crypto]==2.8.0 - # via - # gidgethub - # pyjwt -python-dotenv==1.0.0 - # via -r CI/release_requirements.in -python-gitlab==3.15.0 - # via python-semantic-release -python-semantic-release==8.3.0 - # via -r CI/release_requirements.in -pyyaml==6.0.1 - # via -r CI/release_requirements.in -requests==2.31.0 - # via - # python-gitlab - # python-semantic-release - # requests-toolbelt -requests-toolbelt==1.0.0 - # via python-gitlab -rich==13.7.0 - # via python-semantic-release -sh==2.0.6 - # via -r CI/release_requirements.in -shellingham==1.5.4 - # via python-semantic-release -smmap==5.0.1 - # via gitdb -tomlkit==0.12.3 - # via python-semantic-release -typer==0.9.0 - # via -r CI/release_requirements.in -typing-extensions==4.8.0 - # via - # pydantic - # pydantic-core - # typer -uritemplate==4.1.1 - # via gidgethub -urllib3==2.1.0 - # via requests -yarl==1.9.4 - # via aiohttp diff --git a/Core/include/Acts/Detector/ProtoBinning.hpp b/Core/include/Acts/Detector/ProtoBinning.hpp index cba09182a04..8d5d4db8374 100644 --- a/Core/include/Acts/Detector/ProtoBinning.hpp +++ b/Core/include/Acts/Detector/ProtoBinning.hpp @@ -28,7 +28,7 @@ namespace Acts::Experimental { /// translated into concrete axis types struct ProtoBinning { /// The binning value of this - BinningValue binValue = BinningValue::binValues; + BinningValue binValue; /// The axis type: equidistant or variable Acts::AxisType axisType = Acts::AxisType::Equidistant; /// The axis boundary type: Open, Bound or Closed @@ -73,7 +73,7 @@ struct ProtoBinning { : binValue(bValue), boundaryType(bType), expansion(exp) { if (minE >= maxE) { std::string msg = "ProtoBinning: Invalid binning for value '"; - msg += binningValueNames()[bValue]; + msg += binningValueName(bValue); msg += "', min edge (" + std::to_string(minE) + ") "; msg += " needs to be smaller than max edge ("; msg += std::to_string(maxE) + ")."; @@ -116,7 +116,7 @@ struct ProtoBinning { std::string toString() const { std::stringstream ss; ss << "ProtoBinning: " << bins() << " bins in " - << binningValueNames()[binValue]; + << binningValueName(binValue); ss << (axisType == Acts::AxisType::Variable ? ", variable " : ", equidistant "); if (!autorange) { diff --git a/Core/include/Acts/Detector/ProtoSupport.hpp b/Core/include/Acts/Detector/ProtoSupport.hpp index 1c2d5bc4899..55f8110a3a2 100644 --- a/Core/include/Acts/Detector/ProtoSupport.hpp +++ b/Core/include/Acts/Detector/ProtoSupport.hpp @@ -47,7 +47,7 @@ struct ProtoSupport { /// The volume envelope/clearance parameters: these are chosen such that the /// support surface does not touch the volume extent - ExtentEnvelope volumeClearance = zeroEnvelopes; + ExtentEnvelope volumeClearance = ExtentEnvelope::Zero(); /// The constrain(s) from the internal surfaces, done by parsing /// the polyhedron vertices of the internal objects before support building @@ -69,7 +69,7 @@ struct ProtoSupport { unsigned int splits = 1u; /// Planar placement (only valid for planar support surfaces) - BinningValue pPlacement = binZ; + BinningValue pPlacement = BinningValue::binZ; /// Indicate if the support surface(s) should always be addressed in /// navigation diff --git a/Core/include/Acts/Detector/detail/ReferenceGenerators.hpp b/Core/include/Acts/Detector/detail/ReferenceGenerators.hpp index ab72f16d62e..8d03d515bb3 100644 --- a/Core/include/Acts/Detector/detail/ReferenceGenerators.hpp +++ b/Core/include/Acts/Detector/detail/ReferenceGenerators.hpp @@ -41,7 +41,7 @@ struct CenterReferenceGenerator { /// /// This generator will provide only one filling point and hence /// only a single bin in the indexed grid. -template +template struct BinningValueReferenceGenerator { /// Helper to access a reference position based on binning value /// diff --git a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp index 75344e256a2..d0c7a1b604d 100644 --- a/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CuboidVolumeBounds.hpp @@ -124,7 +124,8 @@ class CuboidVolumeBounds : public VolumeBounds { /// /// @return vector of canonical binning values std::vector canonicalBinning() const override { - return {Acts::binX, Acts::binY, Acts::binZ}; + return {Acts::BinningValue::binX, Acts::BinningValue::binY, + Acts::BinningValue::binZ}; }; /// Binning borders in ActsScalar diff --git a/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp index 949da0f778d..2930b0fb22d 100644 --- a/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CutoutCylinderVolumeBounds.hpp @@ -119,7 +119,8 @@ class CutoutCylinderVolumeBounds : public VolumeBounds { /// /// @return vector of canonical binning values std::vector canonicalBinning() const override { - return {Acts::binR, Acts::binPhi, Acts::binZ}; + return {Acts::BinningValue::binR, Acts::BinningValue::binPhi, + Acts::BinningValue::binZ}; }; /// Write information about this instance to an outstream diff --git a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp index 3f16bd6a6f5..c5a28a4edb7 100644 --- a/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/CylinderVolumeBounds.hpp @@ -163,7 +163,8 @@ class CylinderVolumeBounds : public VolumeBounds { /// /// @return vector of canonical binning values std::vector canonicalBinning() const override { - return {Acts::binR, Acts::binPhi, Acts::binZ}; + return {Acts::BinningValue::binR, Acts::BinningValue::binPhi, + Acts::BinningValue::binZ}; }; /// Binning offset - overloaded for some R-binning types diff --git a/Core/include/Acts/Geometry/Extent.hpp b/Core/include/Acts/Geometry/Extent.hpp index 2c5b2b8d9f1..ac9a01e2386 100644 --- a/Core/include/Acts/Geometry/Extent.hpp +++ b/Core/include/Acts/Geometry/Extent.hpp @@ -13,6 +13,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Enumerate.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/RangeXD.hpp" #include @@ -24,12 +25,74 @@ namespace Acts { using Envelope = std::array; -using ExtentEnvelope = std::array; constexpr Envelope zeroEnvelope = {0, 0}; -constexpr ExtentEnvelope zeroEnvelopes = { - zeroEnvelope, zeroEnvelope, zeroEnvelope, zeroEnvelope, - zeroEnvelope, zeroEnvelope, zeroEnvelope, zeroEnvelope}; + +/// This struct models a multi-dimensional enveloper along the binning values +struct ExtentEnvelope { + /// Access a single envelope configuration + /// @param bValue the binning value + /// @return the envelope + Envelope& operator[](BinningValue bValue) { + return m_values.at(toUnderlying(bValue)); + } + + /// Access a single envelope configuration + /// @param bValue the binning value + /// @return the envelope + const Envelope& operator[](BinningValue bValue) const { + return m_values.at(toUnderlying(bValue)); + } + + /// Constructor from a single envelope that is assigned to all values + /// @param envelope the envelope to be assigned + explicit ExtentEnvelope(const Envelope& envelope = zeroEnvelope) { + for (auto& val : m_values) { + val = envelope; + } + } + + /// Constructor from an array of envelopes + /// @param values the array of envelopes + constexpr explicit ExtentEnvelope( + const std::array& values) + : m_values(values) {} + + /// Static factory for a zero envelope + /// @return the zero envelope + constexpr static ExtentEnvelope Zero() { + return ExtentEnvelope{{ + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + zeroEnvelope, + }}; + } + + /// Comparison operator between envelope sets + /// @param lhs the left hand side + /// @param rhs the right hand side + /// @return true if the envelopes are equal + friend bool operator==(const ExtentEnvelope& lhs, const ExtentEnvelope& rhs) { + return lhs.m_values == rhs.m_values; + } + + /// Comparison operator between envelope sets + /// @param lhs the left hand side + /// @param rhs the right hand side + /// @return true if the envelopes are not equal + friend bool operator!=(const ExtentEnvelope& lhs, const ExtentEnvelope& rhs) { + return !(lhs.m_values == rhs.m_values); + } + + private: + std::array m_values{}; +}; /// A class representing the geometric extent of an object in its possible /// dimensions, these can be all dimensions that are described as BinningValues @@ -40,7 +103,7 @@ constexpr ExtentEnvelope zeroEnvelopes = { class Extent { public: /// Constructor with (optional) @param envelope - Extent(const ExtentEnvelope& envelope = zeroEnvelopes); + explicit Extent(const ExtentEnvelope& envelope = ExtentEnvelope::Zero()); /// Define a comparison operator bool operator==(const Extent& e) const; @@ -56,7 +119,7 @@ class Extent { /// @param fillHistograms is a boolean flag to steer whether the values /// to fill this extent should be stored void extend(const Vector3& vtx, - const std::vector& bValues = s_binningValues, + const std::vector& bValues = allBinningValues(), bool applyEnv = true, bool fillHistograms = false); /// Extend with a set of vectors by iterators @@ -69,7 +132,7 @@ class Extent { /// to fill this extent should be stored template void extend(const vector_iterator_t& start, const vector_iterator_t& end, - const std::vector& bValues = s_binningValues, + const std::vector& bValues = allBinningValues(), bool applyEnv = true, bool fillHistograms = false) { for (vector_iterator_t vIt = start; vIt < end; ++vIt) { extend(*vIt, bValues, applyEnv, fillHistograms); @@ -91,7 +154,7 @@ class Extent { /// /// @note that the histogram values can not be filled in this call void extend(const Extent& rhs, - const std::vector& bValues = s_binningValues, + const std::vector& bValues = allBinningValues(), bool applyEnv = true); /// Constrain an extent by another one, this is @@ -102,7 +165,7 @@ class Extent { /// /// @param envelope an envelope applied to the constrained value void addConstrain(const Extent& rhs, - const ExtentEnvelope& envelope = zeroEnvelopes); + const ExtentEnvelope& envelope = ExtentEnvelope::Zero()); /// Set a range for a dedicated binning value /// @@ -126,14 +189,14 @@ class Extent { /// (re-)Set the envelope /// /// @param envelope new envelope to be set - void setEnvelope(const ExtentEnvelope& envelope = zeroEnvelopes); + void setEnvelope(const ExtentEnvelope& envelope = ExtentEnvelope::Zero()); /// Return the individual 1-dimensional range /// /// @param bValue is the binning value to be returned /// /// @return a one dimensional arrange - auto range(BinningValue bValue) { return m_range[bValue]; } + auto range(BinningValue bValue) { return m_range[toUnderlying(bValue)]; } /// Return the individual 1-dimensional range /// @@ -143,10 +206,13 @@ class Extent { Range1D range(BinningValue bValue) const; /// Return the N-dimension range - const RangeXD& range() const; + const RangeXD& range() const; /// Return an D-dimensional sub range according to the - /// the given @param binValues + /// the given binvalues + /// @tparam kSUBDIM the number of sub dimensions + /// @param binValues the binning values + /// @return the sub range template RangeXD range( const std::array& binValues) const { @@ -166,40 +232,47 @@ class Extent { /// Return the histogram store /// /// The histogram store can be used for automated binning detection - const std::array, binValues>& valueHistograms() const; + const std::array, numBinningValues()>& + valueHistograms() const; /// Access the minimum parameter /// /// @param bValue the binning identification - ActsScalar min(BinningValue bValue) const { return m_range[bValue].min(); } + ActsScalar min(BinningValue bValue) const { + return m_range[toUnderlying(bValue)].min(); + } /// Access the maximum parameter /// /// @param bValue the binning identification - ActsScalar max(BinningValue bValue) const { return m_range[bValue].max(); } + ActsScalar max(BinningValue bValue) const { + return m_range[toUnderlying(bValue)].max(); + } /// Access the midpoint /// /// @param bValue the binning identification ActsScalar medium(BinningValue bValue) const { - return 0.5 * (m_range[bValue].min() + m_range[bValue].max()); + return 0.5 * (m_range[toUnderlying(bValue)].min() + + m_range[toUnderlying(bValue)].max()); } /// Access the parameter interval (i.e. the range span) /// /// @param bValue the binning identification ActsScalar interval(BinningValue bValue) const { - return m_range[bValue].size(); + return m_range[toUnderlying(bValue)].size(); } /// Contains check /// /// @param rhs the extent that is check if it is contained - /// @param bValue is the binning value, if set to binValues + /// @param bValue is the binning value, if set to nullopt /// the check on all is done /// /// @return true if the rhs is contained - bool contains(const Extent& rhs, BinningValue bValue = binValues) const; + bool contains(const Extent& rhs, + std::optional bValue = std::nullopt) const; /// Contains check for a single point /// @@ -211,16 +284,20 @@ class Extent { /// Intersection checks /// /// @param rhs the extent that is check for intersection - /// @param bValue is the binning value, if set to binValues + /// @param bValue is the binning value, if set to nulloptr /// the check on all is done /// /// @return true if the rhs intersects - bool intersects(const Extent& rhs, BinningValue bValue = binValues) const; + bool intersects(const Extent& rhs, + std::optional bValue = std::nullopt) const; - /// Constraints check + /// Check if this object constrains a given direction /// - /// @param bValue is the binning value, if all the check on all is done - bool constrains(BinningValue bValue = binValues) const; + /// @param bValue is the binning value + bool constrains(BinningValue bValue) const; + + /// Check if this object constrains any direction + bool constrains() const; /// Convert to output stream for screen output /// @@ -229,20 +306,20 @@ class Extent { private: /// A bitset that remembers the constraint values - std::bitset m_constrains{0}; + std::bitset m_constrains{0}; /// The actual range store - RangeXD m_range; + RangeXD m_range; /// A potential envelope - ExtentEnvelope m_envelope = zeroEnvelopes; + ExtentEnvelope m_envelope = ExtentEnvelope::Zero(); /// (Optional) Value histograms for bin detection - std::array, binValues> m_valueHistograms; + std::array, numBinningValues()> m_valueHistograms; }; inline Range1D Acts::Extent::range(BinningValue bValue) const { - return m_range[bValue]; + return m_range[toUnderlying(bValue)]; } -inline const RangeXD& Extent::range() const { +inline const RangeXD& Extent::range() const { return m_range; } @@ -254,7 +331,7 @@ inline const ExtentEnvelope& Extent::envelope() const { return m_envelope; } -inline const std::array, binValues>& +inline const std::array, numBinningValues()>& Extent::valueHistograms() const { return m_valueHistograms; } diff --git a/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp b/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp index 742fba0d623..a905f79f4a4 100644 --- a/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp +++ b/Core/include/Acts/Geometry/GenericCuboidVolumeBounds.hpp @@ -94,7 +94,8 @@ class GenericCuboidVolumeBounds : public VolumeBounds { /// /// @return vector of canonical binning values std::vector canonicalBinning() const override { - return {Acts::binX, Acts::binY, Acts::binZ}; + return {Acts::BinningValue::binX, Acts::BinningValue::binY, + Acts::BinningValue::binZ}; }; /// @param sl is the output stream to be written into diff --git a/Core/include/Acts/Geometry/GeometryContext.hpp b/Core/include/Acts/Geometry/GeometryContext.hpp index 1ef8c39f5d8..5a67e19402f 100644 --- a/Core/include/Acts/Geometry/GeometryContext.hpp +++ b/Core/include/Acts/Geometry/GeometryContext.hpp @@ -15,6 +15,8 @@ #include "Acts/Utilities/detail/ContextType.hpp" +#include + namespace Acts { /// @brief This is the central definition of the Acts @@ -25,6 +27,37 @@ namespace Acts { using GeometryContext = ContextType; +/// Helper struct that stores an object and a context, and will print it to +/// an outstream. +/// This allows you to write +/// ```cpp +/// std::cout << surface->toStream(geoContext) << std::endl; +/// ``` +template +struct GeometryContextOstreamWrapper { + GeometryContextOstreamWrapper(const T& object, const GeometryContext& gctx) + : m_object(object), m_gctx(gctx) {} + + GeometryContextOstreamWrapper(const GeometryContextOstreamWrapper&) = delete; + GeometryContextOstreamWrapper(GeometryContextOstreamWrapper&&) = delete; + GeometryContextOstreamWrapper& operator=( + const GeometryContextOstreamWrapper&) = delete; + GeometryContextOstreamWrapper& operator=(GeometryContextOstreamWrapper&&) = + delete; + + friend std::ostream& operator<<( + std::ostream& os, const GeometryContextOstreamWrapper& osWrapper) { + osWrapper.toStream(os); + return os; + } + + private: + void toStream(std::ostream& os) const { m_object.toStreamImpl(m_gctx, os); } + + const T& m_object; + const GeometryContext& m_gctx; +}; + } // namespace Acts #endif diff --git a/Core/include/Acts/Geometry/GeometryObjectSorter.hpp b/Core/include/Acts/Geometry/GeometryObjectSorter.hpp index 2daf1a66e7e..bc0def1fafd 100644 --- a/Core/include/Acts/Geometry/GeometryObjectSorter.hpp +++ b/Core/include/Acts/Geometry/GeometryObjectSorter.hpp @@ -41,30 +41,31 @@ class ObjectSorterT { using Acts::VectorHelpers::perp; using Acts::VectorHelpers::phi; // switch the binning value - // - binX, binY, binZ, binR, binPhi, binRPhi, binH, binEta + // - BinningValue::binX, BinningValue::binY, BinningValue::binZ, binR, + // binPhi, binRPhi, binH, binEta switch (m_binningValue) { // compare on x - case binX: { + case BinningValue::binX: { return one.x() < two.x(); } // compare on y - case binY: { + case BinningValue::binY: { return one.y() < two.y(); } // compare on z - case binZ: { + case BinningValue::binZ: { return one.z() < two.z(); } // compare on r - case binR: { + case BinningValue::binR: { return perp(one) < perp(two); } // compare on phi - case binPhi: { + case BinningValue::binPhi: { return phi(one) < phi(two); } // compare on eta - case binEta: { + case BinningValue::binEta: { return eta(one) < eta(two); } // default for the moment @@ -109,37 +110,37 @@ class DistanceSorterT { // - binX, binY, binZ, binR, binPhi, binRPhi, binH, binEta switch (m_binningValue) { // compare on diff x - case binX: { + case BinningValue::binX: { double diffOneX = one.x() - m_reference.x(); double diffTwoX = two.x() - m_reference.x(); return std::abs(diffOneX) < std::abs(diffTwoX); } // compare on diff y - case binY: { + case BinningValue::binY: { double diffOneY = one.y() - m_reference.y(); double diffTwoY = two.y() - m_reference.y(); return std::abs(diffOneY) < std::abs(diffTwoY); } // compare on diff z - case binZ: { + case BinningValue::binZ: { double diffOneZ = one.z() - m_reference.z(); double diffTwoZ = two.z() - m_reference.z(); return std::abs(diffOneZ) < std::abs(diffTwoZ); } // compare on r - case binR: { + case BinningValue::binR: { double diffOneR = perp(one) - m_refR; double diffTwoR = perp(two) - m_refR; return std::abs(diffOneR) < std::abs(diffTwoR); } // compare on phi /// @todo add cyclic value - case binPhi: { + case BinningValue::binPhi: { double diffOnePhi = phi(one) - m_refPhi; double diffTwoPhi = phi(two) - m_refPhi; return std::abs(diffOnePhi) < std::abs(diffTwoPhi); } // compare on eta - case binEta: { + case BinningValue::binEta: { double diffOneEta = eta(one) - m_refEta; double diffTwoEta = eta(two) - m_refEta; return std::abs(diffOneEta) < std::abs(diffTwoEta); diff --git a/Core/include/Acts/Geometry/ILayerArrayCreator.hpp b/Core/include/Acts/Geometry/ILayerArrayCreator.hpp index 602c8b9397f..9cfabed7511 100644 --- a/Core/include/Acts/Geometry/ILayerArrayCreator.hpp +++ b/Core/include/Acts/Geometry/ILayerArrayCreator.hpp @@ -50,6 +50,6 @@ class ILayerArrayCreator { virtual std::unique_ptr layerArray( const GeometryContext& gctx, const LayerVector& layers, double min, double max, BinningType btype = arbitrary, - BinningValue bvalue = binX) const = 0; + BinningValue bvalue = BinningValue::binX) const = 0; }; } // namespace Acts diff --git a/Core/include/Acts/Geometry/LayerArrayCreator.hpp b/Core/include/Acts/Geometry/LayerArrayCreator.hpp index 22ce71c801b..f142ec026c6 100644 --- a/Core/include/Acts/Geometry/LayerArrayCreator.hpp +++ b/Core/include/Acts/Geometry/LayerArrayCreator.hpp @@ -60,7 +60,7 @@ class LayerArrayCreator : public ILayerArrayCreator { std::unique_ptr layerArray( const GeometryContext& gctx, const LayerVector& layersInput, double min, double max, BinningType bType = arbitrary, - BinningValue bValue = binX) const override; + BinningValue bValue = BinningValue::binX) const override; /// set logging instance void setLogger(std::unique_ptr logger) { diff --git a/Core/include/Acts/Geometry/ProtoLayer.hpp b/Core/include/Acts/Geometry/ProtoLayer.hpp index cad4b6ef1bd..39f6827b23f 100644 --- a/Core/include/Acts/Geometry/ProtoLayer.hpp +++ b/Core/include/Acts/Geometry/ProtoLayer.hpp @@ -31,7 +31,7 @@ struct ProtoLayer { Extent extent; /// The envelope parameters - ExtentEnvelope envelope = zeroEnvelopes; + ExtentEnvelope envelope = ExtentEnvelope::Zero(); /// Constructor /// diff --git a/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp b/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp index 46965a8db91..6b6db768a2d 100644 --- a/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp +++ b/Core/include/Acts/Geometry/SurfaceArrayCreator.hpp @@ -242,10 +242,10 @@ class SurfaceArrayCreator { using namespace UnitLiterals; using VectorHelpers::perp; - if (bValue == Acts::binPhi) { + if (bValue == Acts::BinningValue::binPhi) { // Take the two binning positions - auto pos1 = a->binningPosition(gctx, binR), - pos2 = b->binningPosition(gctx, binR); + auto pos1 = a->binningPosition(gctx, BinningValue::binR), + pos2 = b->binningPosition(gctx, BinningValue::binR); // Project them on the (x, y) plane, where Phi angles are calculated auto proj1 = pos1.head<2>(), proj2 = pos2.head<2>(); @@ -260,14 +260,16 @@ class SurfaceArrayCreator { return std::abs(dPhi) < M_PI / 180.; } - if (bValue == Acts::binZ) { - return (std::abs(a->binningPosition(gctx, binR).z() - - b->binningPosition(gctx, binR).z()) < 1_um); + if (bValue == Acts::BinningValue::binZ) { + return (std::abs(a->binningPosition(gctx, BinningValue::binR).z() - + b->binningPosition(gctx, BinningValue::binR).z()) < + 1_um); } - if (bValue == Acts::binR) { - return (std::abs(perp(a->binningPosition(gctx, binR)) - - perp(b->binningPosition(gctx, binR))) < 1_um); + if (bValue == Acts::BinningValue::binR) { + return (std::abs(perp(a->binningPosition(gctx, BinningValue::binR)) - + perp(b->binningPosition(gctx, BinningValue::binR))) < + 1_um); } return false; diff --git a/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp b/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp index fb98000089a..624fe01193c 100644 --- a/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp +++ b/Core/include/Acts/Geometry/SurfaceBinningMatcher.hpp @@ -20,7 +20,7 @@ namespace Acts { struct SurfaceBinningMatcher { /// The binning tolerance parameters using Range = std::pair; - std::vector tolerances{static_cast(binValues), {0., 0.}}; + std::vector tolerances{static_cast(numBinningValues()), {0., 0.}}; SurfaceBinningMatcher() = default; @@ -49,8 +49,9 @@ struct SurfaceBinningMatcher { double otherMin = otherExt.min(bValue); double otherMax = otherExt.max(bValue); - return (std::abs(oneMin - otherMin) <= tolerances[bValue].first && - std::abs(oneMax - otherMax) <= tolerances[bValue].second); + return ( + std::abs(oneMin - otherMin) <= tolerances[toUnderlying(bValue)].first && + std::abs(oneMax - otherMax) <= tolerances[toUnderlying(bValue)].second); } }; diff --git a/Core/include/Acts/Geometry/VolumeBounds.hpp b/Core/include/Acts/Geometry/VolumeBounds.hpp index ffe139bd977..f2f4407cde5 100644 --- a/Core/include/Acts/Geometry/VolumeBounds.hpp +++ b/Core/include/Acts/Geometry/VolumeBounds.hpp @@ -124,7 +124,8 @@ class VolumeBounds { /// returns the bounding box binning. Individual shapes /// should override this method virtual std::vector canonicalBinning() const { - return {Acts::binX, Acts::binY, Acts::binZ}; + return {Acts::BinningValue::binX, Acts::BinningValue::binY, + Acts::BinningValue::binZ}; }; /// Binning offset - overloaded for some R-binning types diff --git a/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp b/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp index 6fd96951163..e2494b35030 100644 --- a/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp +++ b/Core/include/Acts/Material/PropagatorMaterialAssigner.hpp @@ -152,7 +152,7 @@ class PropagatorMaterialAssigner final : public IAssignmentFinder { // The volume collection results auto vcResult = result.template get(); - for (auto [geoId, vIntersection] : vcResult.collected) { + for (const auto& [geoId, vIntersection] : vcResult.collected) { candidates.second.push_back(vIntersection); } diff --git a/Core/include/Acts/Propagator/Navigator.hpp b/Core/include/Acts/Propagator/Navigator.hpp index 84409c75704..5f3c346f75b 100644 --- a/Core/include/Acts/Propagator/Navigator.hpp +++ b/Core/include/Acts/Propagator/Navigator.hpp @@ -907,7 +907,7 @@ class Navigator { << " out of " << state.navigation.navBoundaries.size() << " not reachable anymore, switching to next."); ACTS_VERBOSE("Targeted boundary surface was: \n" - << std::tie(*boundarySurface, state.geoContext)); + << boundarySurface->toStream(state.geoContext)); } // Increase the index to the next one ++state.navigation.navBoundaryIndex; diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 2a0ca55decc..3447263904f 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -750,9 +750,9 @@ void SeedFinderOrthogonal::createSeeds( } // variable middle SP radial region of interest const Acts::Range1D rMiddleSPRange( - std::floor(rRangeSPExtent.min(Acts::binR) / 2) * 2 + + std::floor(rRangeSPExtent.min(Acts::BinningValue::binR) / 2) * 2 + m_config.deltaRMiddleMinSPRange, - std::floor(rRangeSPExtent.max(Acts::binR) / 2) * 2 - + std::floor(rRangeSPExtent.max(Acts::BinningValue::binR) / 2) * 2 - m_config.deltaRMiddleMaxSPRange); /* diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp index fd5a314d6bc..d02d927ab02 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp @@ -6,8 +6,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#include - template Acts::CylindricalSpacePointGrid Acts::CylindricalSpacePointGridCreator::createGrid( @@ -165,12 +163,6 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( "SeedFinderOptions not in ACTS internal units in BinnedSPGroup"); } - // get region of interest (or full detector if configured accordingly) - float phiMin = config.phiMin; - float phiMax = config.phiMax; - float zMin = config.zMin; - float zMax = config.zMax; - // sort by radius // add magnitude of beamPos to rMax to avoid excluding measurements // create number of bins equal to number of millimeters rMax @@ -180,7 +172,9 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( (config.rMax + options.beamPos.norm()) / config.binSizeR); // keep track of changed bins while sorting - boost::container::flat_set rBinsIndex; + std::vector usedBinIndex(grid.size(), false); + std::vector rBinsIndex; + rBinsIndex.reserve(grid.size()); std::size_t counter = 0ul; for (external_spacepoint_iterator_t it = spBegin; it != spEnd; @@ -200,11 +194,12 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( rRangeSPExtent.extend({spX, spY, spZ}); // remove SPs outside z and phi region - if (spZ > zMax || spZ < zMin) { + if (spZ > config.zMax || spZ < config.zMin) { continue; } + float spPhi = std::atan2(spY, spX); - if (spPhi > phiMax || spPhi < phiMin) { + if (spPhi > config.phiMax || spPhi < config.phiMin) { continue; } @@ -220,23 +215,25 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( } // fill rbins into grid - Acts::Vector2 spLocation(isp->phi(), isp->z()); - std::vector>>& - rbin = grid.atPosition(spLocation); + std::size_t globIndex = + grid.globalBinFromPosition(Acts::Vector2{isp->phi(), isp->z()}); + auto& rbin = grid.at(globIndex); rbin.push_back(std::move(isp)); // keep track of the bins we modify so that we can later sort the SPs in // those bins only - if (rbin.size() > 1) { - rBinsIndex.insert(grid.globalBinFromPosition(spLocation)); + if (rbin.size() > 1 && !usedBinIndex[globIndex]) { + usedBinIndex[globIndex] = true; + rBinsIndex.push_back(globIndex); } } /// sort SPs in R for each filled bin - for (auto& binIndex : rBinsIndex) { + for (std::size_t binIndex : rBinsIndex) { auto& rbin = grid.atPosition(binIndex); - std::sort(rbin.begin(), rbin.end(), [](const auto& a, const auto& b) { - return a->radius() < b->radius(); - }); + std::sort(rbin.begin(), rbin.end(), + [](const auto& a, const auto& b) -> bool { + return a->radius() < b->radius(); + }); } } diff --git a/Core/include/Acts/Surfaces/PerigeeSurface.hpp b/Core/include/Acts/Surfaces/PerigeeSurface.hpp index e8c95dba52c..425d7c86e3c 100644 --- a/Core/include/Acts/Surfaces/PerigeeSurface.hpp +++ b/Core/include/Acts/Surfaces/PerigeeSurface.hpp @@ -74,15 +74,6 @@ class PerigeeSurface : public LineSurface { /// Return properly formatted class name for screen output */ std::string name() const final; - /// Output Method for std::ostream - /// - /// @param gctx The current geometry context object, e.g. alignment - /// @param sl is the ostream to be dumped into - /// - /// @return ostreamn object which was streamed into - std::ostream& toStream(const GeometryContext& gctx, - std::ostream& sl) const final; - /// Return a Polyhedron for the surfaces /// /// @param gctx The current geometry context object, e.g. alignment @@ -91,6 +82,16 @@ class PerigeeSurface : public LineSurface { /// @return A list of vertices and a face/facett description of it Polyhedron polyhedronRepresentation(const GeometryContext& gctx, std::size_t lseg) const final; + + protected: + /// Output Method for std::ostream + /// + /// @param gctx The current geometry context object, e.g. alignment + /// @param sl is the ostream to be dumped into + /// + /// @return ostreamn object which was streamed into + std::ostream& toStreamImpl(const GeometryContext& gctx, + std::ostream& sl) const final; }; ACTS_STATIC_CHECK_CONCEPT(SurfaceConcept, PerigeeSurface); diff --git a/Core/include/Acts/Surfaces/Surface.hpp b/Core/include/Acts/Surfaces/Surface.hpp index cf5ef39de38..adf0dba74e4 100644 --- a/Core/include/Acts/Surfaces/Surface.hpp +++ b/Core/include/Acts/Surfaces/Surface.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2020 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -63,6 +63,8 @@ using SurfaceMultiIntersection = ObjectMultiIntersection; class Surface : public virtual GeometryObject, public std::enable_shared_from_this { public: + friend struct GeometryContextOstreamWrapper; + /// @enum SurfaceType /// /// This enumerator simplifies the persistency & calculations, @@ -399,12 +401,14 @@ class Surface : public virtual GeometryObject, const BoundaryCheck& bcheck = BoundaryCheck(false), ActsScalar tolerance = s_onSurfaceTolerance) const = 0; - /// Output Method for std::ostream, to be overloaded by child classes - /// + /// Helper method for printing: the returned object captures the + /// surface and the geometry context and will print the surface /// @param gctx The current geometry context object, e.g. alignment - /// @param sl is the ostream to be dumped into - virtual std::ostream& toStream(const GeometryContext& gctx, - std::ostream& sl) const; + /// @return The wrapper object for printing + GeometryContextOstreamWrapper toStream( + const GeometryContext& gctx) const { + return {*this, gctx}; + } /// Output into a std::string /// @@ -477,9 +481,16 @@ class Surface : public virtual GeometryObject, const GeometryContext& gctx, const Vector3& position) const = 0; protected: + /// Output Method for std::ostream, to be overloaded by child classes + /// + /// @param gctx The current geometry context object, e.g. alignment + /// @param sl is the ostream to be dumped into + virtual std::ostream& toStreamImpl(const GeometryContext& gctx, + std::ostream& sl) const; + /// Transform3 definition that positions /// (translation, rotation) the surface in global space - Transform3 m_transform = Transform3::Identity(); + std::unique_ptr m_transform{}; /// Pointer to the a DetectorElementBase const DetectorElementBase* m_associatedDetElement{nullptr}; @@ -515,15 +526,4 @@ class Surface : public virtual GeometryObject, const Vector3& direction) const; }; -/// Print surface information to the provided stream. Internally invokes the -/// `surface.toStream(...)`-method. This can be easily used e.g. like `std::cout -/// << std::tie(surface, geometryContext);` -inline std::ostream& operator<<( - std::ostream& os, - const std::tuple& tup) { - const auto [surface, gctx] = tup; - surface.toStream(gctx, os); - return os; -} - } // namespace Acts diff --git a/Core/include/Acts/Surfaces/SurfaceArray.hpp b/Core/include/Acts/Surfaces/SurfaceArray.hpp index 21cfb72115c..39f1433ba9f 100644 --- a/Core/include/Acts/Surfaces/SurfaceArray.hpp +++ b/Core/include/Acts/Surfaces/SurfaceArray.hpp @@ -159,7 +159,7 @@ class SurfaceArray { void fill(const GeometryContext& gctx, const SurfaceVector& surfaces) override { for (const auto& srf : surfaces) { - Vector3 pos = srf->binningPosition(gctx, binR); + Vector3 pos = srf->binningPosition(gctx, BinningValue::binR); lookup(pos).push_back(srf); } @@ -194,7 +194,8 @@ class SurfaceArray { Vector3 binCtr = getBinCenter(b); minPath = std::numeric_limits::max(); for (const auto& srf : surfaces) { - curPath = (binCtr - srf->binningPosition(gctx, binR)).norm(); + curPath = + (binCtr - srf->binningPosition(gctx, BinningValue::binR)).norm(); if (curPath < minPath) { minPath = curPath; diff --git a/Core/include/Acts/Surfaces/SurfaceConcept.hpp b/Core/include/Acts/Surfaces/SurfaceConcept.hpp index 46d01b0fbb3..82246ab4254 100644 --- a/Core/include/Acts/Surfaces/SurfaceConcept.hpp +++ b/Core/include/Acts/Surfaces/SurfaceConcept.hpp @@ -86,9 +86,7 @@ concept SurfaceConcept = requires(S s, const S cs, S s2, const S cs2, std::declval(), std::declval()) } -> std::same_as; - { - cs.toStream(gctx, std::declval()) - } -> std::same_as; + { cs.toStream(gctx) } -> std::same_as>; { cs.toString(gctx) } -> std::same_as; diff --git a/Core/include/Acts/Utilities/BinAdjustment.hpp b/Core/include/Acts/Utilities/BinAdjustment.hpp index 5fcc53fcb2b..f83af5971a8 100644 --- a/Core/include/Acts/Utilities/BinAdjustment.hpp +++ b/Core/include/Acts/Utilities/BinAdjustment.hpp @@ -55,12 +55,12 @@ static inline BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binR && bval != binPhi) { + } else if (bval != BinningValue::binR && bval != BinningValue::binPhi) { throw std::invalid_argument("Disc binning must be: phi, r"); } float min = 0., max = 0.; // Perform the value adjustment - if (bval == binPhi) { + if (bval == BinningValue::binPhi) { min = minPhi; max = maxPhi; } else { @@ -106,15 +106,16 @@ static inline BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binRPhi && bval != binPhi && bval != binZ) { + } else if (bval != BinningValue::binRPhi && bval != BinningValue::binPhi && + bval != BinningValue::binZ) { throw std::invalid_argument("Cylinder binning must be: rphi, phi, z"); } float min = 0., max = 0.; // Perform the value adjustment - if (bval == binPhi) { + if (bval == BinningValue::binPhi) { min = minPhi; max = maxPhi; - } else if (bval == binRPhi) { + } else if (bval == BinningValue::binRPhi) { min = cR * minPhi; max = cR * maxPhi; } else { @@ -158,12 +159,12 @@ static inline BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binX && bval != binY) { + } else if (bval != BinningValue::binX && bval != BinningValue::binY) { throw std::invalid_argument("Rectangle binning must be: x, y. "); } float min = 0., max = 0.; // Perform the value adjustment - if (bval == binX) { + if (bval == BinningValue::binX) { min = minX; max = maxX; } else { @@ -208,12 +209,12 @@ static inline BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binX && bval != binY) { + } else if (bval != BinningValue::binX && bval != BinningValue::binY) { throw std::invalid_argument("Rectangle binning must be: x, y. "); } float min = 0., max = 0.; // Perform the value adjustment - if (bval == binX) { + if (bval == BinningValue::binX) { min = -1 * halfX; max = halfX; } else { diff --git a/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp b/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp index 9cb287ba2b1..7dfa6b77724 100644 --- a/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp +++ b/Core/include/Acts/Utilities/BinAdjustmentVolume.hpp @@ -53,19 +53,20 @@ BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binR && bval != binPhi && bval != binZ) { + } else if (bval != BinningValue::binR && bval != BinningValue::binPhi && + bval != BinningValue::binZ) { throw std::invalid_argument("Cylinder volume binning must be: phi, r, z"); } float min = 0; float max = 0; // Perform the value adjustment - if (bval == binPhi) { + if (bval == BinningValue::binPhi) { min = minPhi; max = maxPhi; - } else if (bval == binR) { + } else if (bval == BinningValue::binR) { min = minR; max = maxR; - } else if (bval == binZ) { + } else if (bval == BinningValue::binZ) { min = minZ; max = maxZ; } @@ -108,20 +109,21 @@ BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binR && bval != binPhi && bval != binZ) { + } else if (bval != BinningValue::binR && bval != BinningValue::binPhi && + bval != BinningValue::binZ) { throw std::invalid_argument( "Cutout cylinder volume binning must be: phi, r, z"); } float min = 0; float max = 0; // Perform the value adjustment - if (bval == binPhi) { + if (bval == BinningValue::binPhi) { min = minPhi; max = maxPhi; - } else if (bval == binR) { + } else if (bval == BinningValue::binR) { min = minR; max = maxR; - } else if (bval == binZ) { + } else if (bval == BinningValue::binZ) { min = minZ; max = maxZ; } @@ -163,19 +165,20 @@ BinUtility adjustBinUtility(const BinUtility& bu, // - not equidistant if (bd.type == arbitrary) { throw std::invalid_argument("Arbitrary binning can not be adjusted."); - } else if (bval != binX && bval != binY && bval != binZ) { + } else if (bval != BinningValue::binX && bval != BinningValue::binY && + bval != BinningValue::binZ) { throw std::invalid_argument("Cylinder volume binning must be: x, y, z"); } float min = 0; float max = 0; // Perform the value adjustment - if (bval == binX) { + if (bval == BinningValue::binX) { min = minX; max = maxX; - } else if (bval == binY) { + } else if (bval == BinningValue::binY) { min = minY; max = maxY; - } else if (bval == binZ) { + } else if (bval == BinningValue::binZ) { min = minZ; max = maxZ; } diff --git a/Core/include/Acts/Utilities/BinUtility.hpp b/Core/include/Acts/Utilities/BinUtility.hpp index b4caa3af2c8..59a736dae68 100644 --- a/Core/include/Acts/Utilities/BinUtility.hpp +++ b/Core/include/Acts/Utilities/BinUtility.hpp @@ -72,7 +72,7 @@ class BinUtility { /// @param value is the binninb value : binX, binY, binZ, etc. /// @param tForm is the (optional) transform BinUtility(std::size_t bins, float min, float max, BinningOption opt = open, - BinningValue value = binX, + BinningValue value = BinningValue::binX, const Transform3& tForm = Transform3::Identity()) : m_binningData(), m_transform(tForm), m_itransform(tForm.inverse()) { m_binningData.reserve(3); @@ -86,7 +86,7 @@ class BinUtility { /// @param value is the binninb value : binX, binY, binZ, etc. /// @param tForm is the (optional) transform BinUtility(std::vector& bValues, BinningOption opt = open, - BinningValue value = binPhi, + BinningValue value = BinningValue::binPhi, const Transform3& tForm = Transform3::Identity()) : m_binningData(), m_transform(tForm), m_itransform(tForm.inverse()) { m_binningData.reserve(3); diff --git a/Core/include/Acts/Utilities/BinningData.hpp b/Core/include/Acts/Utilities/BinningData.hpp index ec6aebccfb6..01358a4f14c 100644 --- a/Core/include/Acts/Utilities/BinningData.hpp +++ b/Core/include/Acts/Utilities/BinningData.hpp @@ -10,6 +10,7 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Utilities/BinningType.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/ThrowAssert.hpp" #include "Acts/Utilities/VectorHelpers.hpp" @@ -240,10 +241,11 @@ class BinningData { /// @return float value according to the binning setup float value(const Vector2& lposition) const { // ordered after occurrence - if (binvalue == binR || binvalue == binRPhi || binvalue == binX || - binvalue == binH) { + if (binvalue == BinningValue::binR || binvalue == BinningValue::binRPhi || + binvalue == BinningValue::binX || binvalue == BinningValue::binH) { return lposition[0]; } + return lposition[1]; } @@ -257,17 +259,17 @@ class BinningData { using VectorHelpers::perp; using VectorHelpers::phi; // ordered after occurrence - if (binvalue == binR || binvalue == binH) { + if (binvalue == BinningValue::binR || binvalue == BinningValue::binH) { return (perp(position)); } - if (binvalue == binRPhi) { + if (binvalue == BinningValue::binRPhi) { return (perp(position) * phi(position)); } - if (binvalue == binEta) { + if (binvalue == BinningValue::binEta) { return (eta(position)); } - if (binvalue < 3) { - return (position[binvalue]); + if (toUnderlying(binvalue) < 3) { + return position[toUnderlying(binvalue)]; } // phi gauging return phi(position); diff --git a/Core/include/Acts/Utilities/BinningType.hpp b/Core/include/Acts/Utilities/BinningType.hpp index db02077fec6..4ed8c35bbb4 100644 --- a/Core/include/Acts/Utilities/BinningType.hpp +++ b/Core/include/Acts/Utilities/BinningType.hpp @@ -1,6 +1,6 @@ // This file is part of the Acts project. // -// Copyright (C) 2016-2018 CERN for the benefit of the Acts project +// Copyright (C) 2016-2024 CERN for the benefit of the Acts project // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -8,6 +8,7 @@ #pragma once #include +#include #include namespace Acts { @@ -32,7 +33,7 @@ enum BinningType { equidistant, arbitrary }; enum BinningOption { open, closed }; /// @enum BinningValue how to take the global / local position -enum BinningValue : int { +enum class BinningValue : int { binX = 0, binY = 1, binZ = 2, @@ -41,19 +42,33 @@ enum BinningValue : int { binRPhi = 5, binH = 6, binEta = 7, - binMag = 8, - binValues = 9 + binMag = 8 }; -/// @brief static list of all binning values -static const std::vector s_binningValues = { - binX, binY, binZ, binR, binPhi, binRPhi, binH, binEta, binMag}; +/// Get all possible binning values +/// @return the binning values +const std::vector& allBinningValues(); -/// @brief screen output option -inline const std::vector& binningValueNames() { - static const std::vector _binningValueNames = { - "binX", "binY", "binZ", "binR", "binPhi", - "binRPhi", "binH", "binEta", "binMag"}; - return _binningValueNames; +/// Returns the total number of binningvalues +/// @return the number of binning values +constexpr std::size_t numBinningValues() { + return 9; } + +/// Get the binning value from a name +/// @param name is the name of the binning value +/// @return the binning value +BinningValue binningValueFromName(const std::string& name); + +/// Get the name of a binning value as a string +/// @param bValue is the binning value +/// @return the name of the binning value +const std::string& binningValueName(BinningValue bValue); + +/// Output stream operator for @c BinningValue +/// @param os is the output stream +/// @param bValue is the binning value +/// @return the output stream +std::ostream& operator<<(std::ostream& os, BinningValue bValue); + } // namespace Acts diff --git a/Core/include/Acts/Utilities/Helpers.hpp b/Core/include/Acts/Utilities/Helpers.hpp index 851a67b6048..5d9d2ab22eb 100644 --- a/Core/include/Acts/Utilities/Helpers.hpp +++ b/Core/include/Acts/Utilities/Helpers.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #define ACTS_CHECK_BIT(value, mask) ((value & mask) == mask) @@ -192,4 +193,9 @@ std::tuple range_medium(const T& tseries) { return std::tie(range, medium); } +template +constexpr std::underlying_type_t toUnderlying(enum_t value) { + return static_cast>(value); +} + } // namespace Acts diff --git a/Core/include/Acts/Utilities/VectorHelpers.hpp b/Core/include/Acts/Utilities/VectorHelpers.hpp index 84c0e6791da..ee0b04d87c8 100644 --- a/Core/include/Acts/Utilities/VectorHelpers.hpp +++ b/Core/include/Acts/Utilities/VectorHelpers.hpp @@ -154,23 +154,23 @@ inline std::array evaluateTrigonomics(const Vector3& direction) { /// binning values. inline double cast(const Vector3& position, BinningValue bval) { switch (bval) { - case binX: + case BinningValue::binX: return position[0]; - case binY: + case BinningValue::binY: return position[1]; - case binZ: + case BinningValue::binZ: return position[2]; - case binR: + case BinningValue::binR: return perp(position); - case binPhi: + case BinningValue::binPhi: return phi(position); - case binRPhi: + case BinningValue::binRPhi: return perp(position) * phi(position); - case binH: + case BinningValue::binH: return theta(position); - case binEta: + case BinningValue::binEta: return eta(position); - case binMag: + case BinningValue::binMag: return position.norm(); default: assert(false && "Invalid BinningValue enum value"); diff --git a/Core/include/Acts/Utilities/detail/Subspace.hpp b/Core/include/Acts/Utilities/detail/Subspace.hpp index 9d11f84007d..556a4bc4b2f 100644 --- a/Core/include/Acts/Utilities/detail/Subspace.hpp +++ b/Core/include/Acts/Utilities/detail/Subspace.hpp @@ -93,7 +93,8 @@ class FixedSizeSubspace { /// @tparam index_t Input index type, must be convertible to std::uint8_t /// @param indices Unique, ordered indices template - constexpr FixedSizeSubspace(const std::array& indices) { + constexpr explicit FixedSizeSubspace( + const std::array& indices) { for (std::size_t i = 0u; i < kSize; ++i) { assert((indices[i] < kFullSize) && "Axis indices must be within the full space"); @@ -106,18 +107,18 @@ class FixedSizeSubspace { m_axes[i] = static_cast(indices[i]); } } - // The subset can not be constructed w/o defining its axis indices. - FixedSizeSubspace() = delete; - FixedSizeSubspace(const FixedSizeSubspace&) = default; - FixedSizeSubspace(FixedSizeSubspace&&) = default; - FixedSizeSubspace& operator=(const FixedSizeSubspace&) = default; - FixedSizeSubspace& operator=(FixedSizeSubspace&&) = default; /// Size of the subspace. static constexpr std::size_t size() { return kSize; } /// Size of the full vector space. static constexpr std::size_t fullSize() { return kFullSize; } + /// Access axis index by position. + /// + /// @param i Position in the subspace + /// @return Axis index in the full space + constexpr std::size_t operator[](std::size_t i) const { return m_axes[i]; } + /// Axis indices that comprise the subspace. /// /// The specific container and index type should be considered an @@ -132,8 +133,8 @@ class FixedSizeSubspace { bool isContained = false; // always iterate over all elements to avoid branching and hope the compiler // can optimise this for us. - for (auto a : m_axes) { - isContained = (isContained || (a == index)); + for (std::uint8_t a : m_axes) { + isContained = isContained || (a == index); } return isContained; } @@ -146,12 +147,12 @@ class FixedSizeSubspace { /// /// @note Always returns a column vector regardless of the input template - auto projectVector(const Eigen::MatrixBase& full) const - -> SubspaceVectorFor { + SubspaceVectorFor projectVector( + const Eigen::MatrixBase& full) const { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(fullspace_vector_t, kFullSize); SubspaceVectorFor sub; - for (auto i = 0u; i < kSize; ++i) { + for (std::size_t i = 0u; i < kSize; ++i) { sub[i] = full[m_axes[i]]; } return sub; @@ -165,13 +166,13 @@ class FixedSizeSubspace { /// /// @note Always returns a column vector regardless of the input template - auto expandVector(const Eigen::MatrixBase& sub) const - -> FullspaceVectorFor { + FullspaceVectorFor expandVector( + const Eigen::MatrixBase& sub) const { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(subspace_vector_t, kSize); FullspaceVectorFor full; full.setZero(); - for (auto i = 0u; i < kSize; ++i) { + for (std::size_t i = 0u; i < kSize; ++i) { full[m_axes[i]] = sub[i]; } return full; @@ -181,10 +182,10 @@ class FixedSizeSubspace { /// /// @tparam scalar_t Scalar type for the projection matrix template - auto projector() const -> ProjectionMatrix { + ProjectionMatrix projector() const { ProjectionMatrix proj; proj.setZero(); - for (auto i = 0u; i < kSize; ++i) { + for (std::size_t i = 0u; i < kSize; ++i) { proj(i, m_axes[i]) = 1; } return proj; @@ -194,14 +195,147 @@ class FixedSizeSubspace { /// /// @tparam scalar_t Scalar type of the generated expansion matrix template - auto expander() const -> ExpansionMatrix { + ExpansionMatrix expander() const { ExpansionMatrix expn; expn.setZero(); - for (auto i = 0u; i < kSize; ++i) { + for (std::size_t i = 0u; i < kSize; ++i) { + expn(m_axes[i], i) = 1; + } + return expn; + } +}; + +/// Variable-size subspace representation. +/// +/// @tparam kFullSize Size of the full vector space +/// @tparam kSize Size of the subspace +template +class VariableSizeSubspace { + static_assert(kFullSize <= static_cast(UINT8_MAX), + "Full vector space size is larger than the supported range"); + + template + using FullProjectionMatrix = Eigen::Matrix; + template + using FullExpansionMatrix = Eigen::Matrix; + + std::size_t m_size{}; + + // the functionality could also be implemented using a std::bitset where each + // bit corresponds to an axis in the fullspace and set bits indicate which + // bits make up the subspace. this would be a more compact representation but + // complicates the implementation since we can not easily iterate over the + // indices of the subspace. storing the subspace indices directly requires a + // bit more memory but is easier to work with. for our typical use cases with + // n<=8, this still takes only 64bit of memory. + std::array m_axes{}; + + public: + /// Construct from a container of axis indices. + /// + /// @tparam index_t Input index type, must be convertible to std::uint8_t + /// @param indices Unique, ordered indices + template + constexpr explicit VariableSizeSubspace( + const std::array& indices) { + m_size = kSize; + for (std::size_t i = 0u; i < kSize; ++i) { + assert((indices[i] < kFullSize) && + "Axis indices must be within the full space"); + if (0u < i) { + assert((indices[i - 1u] < indices[i]) && + "Axis indices must be unique and ordered"); + } + } + for (std::size_t i = 0; i < kSize; ++i) { + m_axes[i] = static_cast(indices[i]); + } + } + + /// Size of the subspace. + constexpr std::size_t size() const { return m_size; } + /// Size of the full vector space. + static constexpr std::size_t fullSize() { return kFullSize; } + + /// Access axis index by position. + /// + /// @param i Position in the subspace + /// @return Axis index in the full space + constexpr std::size_t operator[](std::size_t i) const { + assert(i < m_size); + return m_axes[i]; + } + + /// Check if the given axis index in the full space is part of the subspace. + constexpr bool contains(std::size_t index) const { + bool isContained = false; + // always iterate over all elements to avoid branching and hope the compiler + // can optimise this for us. + for (std::size_t i = 0; i < kFullSize; ++i) { + isContained = isContained || ((i < m_size) && (m_axes[i] == index)); + } + return isContained; + } + + /// Projection matrix that maps from the full space into the subspace. + /// + /// @tparam scalar_t Scalar type for the projection matrix + template + FullProjectionMatrix fullProjector() const { + FullProjectionMatrix proj; + proj.setZero(); + for (std::size_t i = 0u; i < m_size; ++i) { + proj(i, m_axes[i]) = 1; + } + return proj; + } + + /// Expansion matrix that maps from the subspace into the full space. + /// + /// @tparam scalar_t Scalar type of the generated expansion matrix + template + FullExpansionMatrix fullExpander() const { + FullExpansionMatrix expn; + expn.setZero(); + for (std::size_t i = 0u; i < m_size; ++i) { expn(m_axes[i], i) = 1; } return expn; } + + std::uint64_t projectorBits() const { + std::uint64_t result = 0; + + for (std::size_t i = 0; i < m_size; ++i) { + for (std::size_t j = 0; j < kFullSize; ++j) { + // the bit order is defined in `Acts/Utilities/AlgebraHelpers.hpp` + // in `matrixToBitset` + std::size_t index = m_size * kFullSize - 1 - (i + j * m_size); + if (m_axes[i] == j) { + result |= (1ull << index); + } + } + } + + return result; + } + + std::uint64_t fullProjectorBits() const { + std::uint64_t result = 0; + + for (std::size_t i = 0; i < kFullSize; ++i) { + for (std::size_t j = 0; j < kFullSize; ++j) { + // the bit order is defined in `Acts/Utilities/AlgebraHelpers.hpp` + // in `matrixToBitset` + std::size_t index = kFullSize * kFullSize - 1 - (i + j * kFullSize); + if (i < m_size && m_axes[i] == j) { + result |= (1ull << index); + } + } + } + + return result; + } }; /// @} diff --git a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp index 34dba7364bf..a1804e1aaff 100644 --- a/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp +++ b/Core/include/Acts/Vertexing/IterativeVertexFinder.hpp @@ -112,7 +112,7 @@ class IterativeVertexFinder final : public IVertexFinder { InputTrack::Extractor extractParameters; /// Magnetic field provider - std::shared_ptr field; + std::shared_ptr field; }; /// State struct diff --git a/Core/src/Detector/CuboidalContainerBuilder.cpp b/Core/src/Detector/CuboidalContainerBuilder.cpp index 7c403d6b55d..5714cba8d0c 100644 --- a/Core/src/Detector/CuboidalContainerBuilder.cpp +++ b/Core/src/Detector/CuboidalContainerBuilder.cpp @@ -35,11 +35,13 @@ Acts::Experimental::CuboidalContainerBuilder::CuboidalContainerBuilder( "CuboidalContainerBuilder: no sub builders provided."); } // Check if binning value is correctly chosen - if (m_cfg.binning != Acts::binX && m_cfg.binning != Acts::binY && - m_cfg.binning != Acts::binZ) { + if (m_cfg.binning != Acts::BinningValue::binX && + m_cfg.binning != Acts::BinningValue::binY && + m_cfg.binning != Acts::BinningValue::binZ) { throw std::invalid_argument( - "CuboidalContainerBuilder: Invalid binning value. Only Acts::binX, " - "Acts::binY, Acts::binZ are supported."); + "CuboidalContainerBuilder: Invalid binning value. Only " + "Acts::BinningValue::binX, " + "Acts::BinningValue::binY, Acts::BinningValue::binZ are supported."); } } @@ -92,11 +94,13 @@ Acts::Experimental::CuboidalContainerBuilder::CuboidalContainerBuilder( } m_cfg.binning = bpNode.binning.at(0); // Check if binning value is correctly chosen - if (m_cfg.binning != Acts::binX && m_cfg.binning != Acts::binY && - m_cfg.binning != Acts::binZ) { + if (m_cfg.binning != Acts::BinningValue::binX && + m_cfg.binning != Acts::BinningValue::binY && + m_cfg.binning != Acts::BinningValue::binZ) { throw std::invalid_argument( - "CuboidalContainerBuilder: Invalid binning value. Only Acts::binX, " - "Acts::binY, Acts::binZ are supported."); + "CuboidalContainerBuilder: Invalid binning value. Only " + "Acts::BinningValue::binX, " + "Acts::BinningValue::binY, Acts::BinningValue::binZ are supported."); } m_cfg.auxiliary = "*** acts auto-generated from proxy ***"; diff --git a/Core/src/Detector/CylindricalContainerBuilder.cpp b/Core/src/Detector/CylindricalContainerBuilder.cpp index 3f4515fee79..18528d2c877 100644 --- a/Core/src/Detector/CylindricalContainerBuilder.cpp +++ b/Core/src/Detector/CylindricalContainerBuilder.cpp @@ -52,17 +52,17 @@ Acts::Experimental::DetectorComponent::PortalContainer connect( Acts::BinningValue bv = binning.front(); // 1-dimensional binning options switch (bv) { - case Acts::binR: { + case Acts::BinningValue::binR: { portalContainer = Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( gctx, objects, {}, logLevel); } break; - case Acts::binZ: { + case Acts::BinningValue::binZ: { portalContainer = Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( gctx, objects, {}, logLevel); } break; - case Acts::binPhi: { + case Acts::BinningValue::binPhi: { portalContainer = Acts::Experimental::detail::CylindricalDetectorHelper::connectInPhi( gctx, objects, {}, logLevel); @@ -71,7 +71,8 @@ Acts::Experimental::DetectorComponent::PortalContainer connect( break; } } else if (binning == - std::vector{Acts::binZ, Acts::binR} && + std::vector{Acts::BinningValue::binZ, + Acts::BinningValue::binR} && objects.size() == 2u) { portalContainer = Acts::Experimental::detail::CylindricalDetectorHelper::wrapInZR( @@ -94,7 +95,8 @@ Acts::Experimental::CylindricalContainerBuilder::CylindricalContainerBuilder( if (m_cfg.binning.size() == 1u) { // 1-dimensional case auto b = m_cfg.binning.front(); - if (b != Acts::binR && b != Acts::binZ && b != Acts::binPhi) { + if (b != Acts::BinningValue::binR && b != Acts::BinningValue::binZ && + b != Acts::BinningValue::binPhi) { throw std::invalid_argument( "CylindricalContainerBuilder: 1D binning only supported in z, r, or " "phi"); @@ -102,7 +104,8 @@ Acts::Experimental::CylindricalContainerBuilder::CylindricalContainerBuilder( } else if (m_cfg.binning.size() == 2u) { // 2-dimensional case, this is for wrapping if (m_cfg.binning != - std::vector{Acts::binZ, Acts::binR}) { + std::vector{Acts::BinningValue::binZ, + Acts::BinningValue::binR}) { throw std::invalid_argument( "CylindricalContainerBuilder: 2D binning only supports wrapping in " "z-r."); @@ -165,7 +168,8 @@ Acts::Experimental::CylindricalContainerBuilder::CylindricalContainerBuilder( if (m_cfg.binning.size() == 1u) { // 1-dimensional case auto b = m_cfg.binning.front(); - if (b != Acts::binR && b != Acts::binZ && b != Acts::binPhi) { + if (b != Acts::BinningValue::binR && b != Acts::BinningValue::binZ && + b != Acts::BinningValue::binPhi) { throw std::invalid_argument( "CylindricalContainerBuilder: 1D binning only supported in z, r, or " "phi"); @@ -173,7 +177,8 @@ Acts::Experimental::CylindricalContainerBuilder::CylindricalContainerBuilder( } else if (m_cfg.binning.size() == 2u) { // 2-dimensional case, this is for wrapping if (m_cfg.binning != - std::vector{Acts::binZ, Acts::binR}) { + std::vector{Acts::BinningValue::binZ, + Acts::BinningValue::binR}) { throw std::invalid_argument( "CylindricalContainerBuilder: 2D binning only supports wrapping in " "z-r."); @@ -254,7 +259,7 @@ Acts::Experimental::CylindricalContainerBuilder::construct( // Assign the proto material // Material assignment from configuration - for (auto [ip, bDescription] : m_cfg.portalMaterialBinning) { + for (const auto& [ip, bDescription] : m_cfg.portalMaterialBinning) { if (portalContainer.find(ip) != portalContainer.end()) { auto bd = detail::ProtoMaterialHelper::attachProtoMaterial( gctx, portalContainer[ip]->surface(), bDescription); diff --git a/Core/src/Detector/DetectorVolumeBuilder.cpp b/Core/src/Detector/DetectorVolumeBuilder.cpp index 986cdf4e044..f15d96926d5 100644 --- a/Core/src/Detector/DetectorVolumeBuilder.cpp +++ b/Core/src/Detector/DetectorVolumeBuilder.cpp @@ -80,7 +80,7 @@ Acts::Experimental::DetectorVolumeBuilder::construct( std::move(surfacesUpdater)); } // All portals are defined and build the current shell - for (auto [ip, p] : enumerate(dVolume->portalPtrs())) { + for (const auto& [ip, p] : enumerate(dVolume->portalPtrs())) { portalContainer[ip] = p; } @@ -92,7 +92,7 @@ Acts::Experimental::DetectorVolumeBuilder::construct( } // Assign the proto material if configured to do so - for (auto [ip, bDescription] : m_cfg.portalMaterialBinning) { + for (const auto& [ip, bDescription] : m_cfg.portalMaterialBinning) { if (portalContainer.find(ip) != portalContainer.end()) { auto bd = detail::ProtoMaterialHelper::attachProtoMaterial( gctx, portalContainer[ip]->surface(), bDescription); diff --git a/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp b/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp index fbbeb3eceb9..c6005b5c142 100644 --- a/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp +++ b/Core/src/Detector/IndexedRootVolumeFinderBuilder.cpp @@ -31,7 +31,8 @@ void fillGridIndices2D( if (ic1 > 0) { Acts::ActsScalar v1 = 0.5 * (c1 + boundaries[1u][ic1 - 1]); if (casts == - std::array{Acts::binZ, Acts::binR}) { + std::array{Acts::BinningValue::binZ, + Acts::BinningValue::binR}) { Acts::Vector3 zrPosition{v1, 0., v0}; for (const auto [iv, v] : Acts::enumerate(rootVolumes)) { if (v->inside(gctx, zrPosition)) { @@ -50,7 +51,8 @@ void fillGridIndices2D( Acts::Experimental::IndexedRootVolumeFinderBuilder:: IndexedRootVolumeFinderBuilder(std::vector binning) : m_casts(std::move(binning)) { - if (m_casts != std::vector{Acts::binZ, Acts::binR}) { + if (m_casts != std::vector{Acts::BinningValue::binZ, + Acts::BinningValue::binR}) { throw std::invalid_argument("Online (z,r) binning is currently supported."); } } diff --git a/Core/src/Detector/LayerStructureBuilder.cpp b/Core/src/Detector/LayerStructureBuilder.cpp index 1e1e311e384..6a421671cf1 100644 --- a/Core/src/Detector/LayerStructureBuilder.cpp +++ b/Core/src/Detector/LayerStructureBuilder.cpp @@ -240,13 +240,13 @@ Acts::Experimental::LayerStructureBuilder::construct( Extent supportExtent; // Let us start with an eventually existing volume extent, but only pick // the binning value that are not constrained by the internal surfaces - for (const auto& bv : s_binningValues) { + for (const auto& bv : allBinningValues()) { if (support.volumeExtent.constrains(bv) && std::find(support.internalConstraints.begin(), support.internalConstraints.end(), bv) == support.internalConstraints.end()) { ACTS_VERBOSE(" Support surface is constrained by volume extent in " - << binningValueNames()[bv]); + << binningValueName(bv)); supportExtent.set(bv, support.volumeExtent.min(bv), support.volumeExtent.max(bv)); } @@ -265,26 +265,27 @@ Acts::Experimental::LayerStructureBuilder::construct( // Add cylindrical support if (support.type == Surface::SurfaceType::Cylinder) { detail::SupportSurfacesHelper::CylindricalSupport cSupport{ - support.offset, support.volumeClearance[binZ], - support.volumeClearance[binPhi]}; + support.offset, support.volumeClearance[BinningValue::binZ], + support.volumeClearance[BinningValue::binPhi]}; detail::SupportSurfacesHelper::addSupport(internalSurfaces, assignToAll, supportExtent, cSupport, support.splits); } else if (support.type == Surface::SurfaceType::Disc) { // Add disc support detail::SupportSurfacesHelper::DiscSupport dSupport{ - support.offset, support.volumeClearance[binR], - support.volumeClearance[binPhi]}; + support.offset, support.volumeClearance[BinningValue::binR], + support.volumeClearance[BinningValue::binPhi]}; detail::SupportSurfacesHelper::addSupport(internalSurfaces, assignToAll, supportExtent, dSupport, support.splits); } else if (support.type == Surface::SurfaceType::Plane) { // Set the local coordinates - cyclic permutation - std::array locals = {binX, binY}; - if (support.pPlacement == binX) { - locals = {binY, binZ}; - } else if (support.pPlacement == binY) { - locals = {binZ, binX}; + std::array locals = {BinningValue::binX, + BinningValue::binY}; + if (support.pPlacement == BinningValue::binX) { + locals = {BinningValue::binY, BinningValue::binZ}; + } else if (support.pPlacement == BinningValue::binY) { + locals = {BinningValue::binZ, BinningValue::binX}; } // Add rectangular support detail::SupportSurfacesHelper::RectangularSupport rSupport{ diff --git a/Core/src/Detector/ProtoDetector.cpp b/Core/src/Detector/ProtoDetector.cpp index eba45c1f6c5..20db1689882 100644 --- a/Core/src/Detector/ProtoDetector.cpp +++ b/Core/src/Detector/ProtoDetector.cpp @@ -82,7 +82,7 @@ void Acts::ProtoVolume::harmonize(bool legacy) { std::vector borders = {}; // The volumes should be harmonized in all other constraining values - for (auto obValue : s_binningValues) { + for (auto obValue : allBinningValues()) { if (obValue != binValue && extent.constrains(obValue)) { otherConstrains.push_back(obValue); } diff --git a/Core/src/Detector/VolumeStructureBuilder.cpp b/Core/src/Detector/VolumeStructureBuilder.cpp index 9a149e978af..49dba260a52 100644 --- a/Core/src/Detector/VolumeStructureBuilder.cpp +++ b/Core/src/Detector/VolumeStructureBuilder.cpp @@ -72,14 +72,15 @@ Acts::Experimental::VolumeStructureBuilder::construct( if (boundValues.empty() && m_cfg.extent.has_value()) { ACTS_VERBOSE("Cuboid: estimate parameters from Extent."); const auto& vExtent = m_cfg.extent.value(); - if (vExtent.constrains(binX) && vExtent.constrains(binY) && - vExtent.constrains(binZ)) { - eTransform.pretranslate(Vector3(vExtent.medium(binX), - vExtent.medium(binY), - vExtent.medium(binZ))); - boundValues = {0.5 * vExtent.interval(binX), - 0.5 * vExtent.interval(binY), - 0.5 * vExtent.interval(binZ)}; + if (vExtent.constrains(BinningValue::binX) && + vExtent.constrains(BinningValue::binY) && + vExtent.constrains(BinningValue::binZ)) { + eTransform.pretranslate(Vector3(vExtent.medium(BinningValue::binX), + vExtent.medium(BinningValue::binY), + vExtent.medium(BinningValue::binZ))); + boundValues = {0.5 * vExtent.interval(BinningValue::binX), + 0.5 * vExtent.interval(BinningValue::binY), + 0.5 * vExtent.interval(BinningValue::binZ)}; } else { throw std::runtime_error( @@ -116,13 +117,16 @@ Acts::Experimental::VolumeStructureBuilder::construct( if (boundValues.empty() && m_cfg.extent.has_value()) { ACTS_VERBOSE("Cylinder: estimate parameters from Extent."); const auto& vExtent = m_cfg.extent.value(); - if (vExtent.constrains(binR) && vExtent.constrains(binZ)) { - eTransform.pretranslate(Vector3(0., 0., vExtent.medium(binZ))); - boundValues = {vExtent.min(binR), vExtent.max(binR), - 0.5 * vExtent.interval(binZ)}; - if (vExtent.constrains(binPhi)) { - boundValues.push_back(0.5 * vExtent.interval(binPhi)); - boundValues.push_back(vExtent.medium(binPhi)); + if (vExtent.constrains(BinningValue::binR) && + vExtent.constrains(BinningValue::binZ)) { + eTransform.pretranslate( + Vector3(0., 0., vExtent.medium(BinningValue::binZ))); + boundValues = {vExtent.min(BinningValue::binR), + vExtent.max(BinningValue::binR), + 0.5 * vExtent.interval(BinningValue::binZ)}; + if (vExtent.constrains(BinningValue::binPhi)) { + boundValues.push_back(0.5 * vExtent.interval(BinningValue::binPhi)); + boundValues.push_back(vExtent.medium(BinningValue::binPhi)); } } else { throw std::runtime_error( diff --git a/Core/src/Detector/detail/BlueprintHelper.cpp b/Core/src/Detector/detail/BlueprintHelper.cpp index 485bc8e129c..353036feeff 100644 --- a/Core/src/Detector/detail/BlueprintHelper.cpp +++ b/Core/src/Detector/detail/BlueprintHelper.cpp @@ -20,13 +20,13 @@ std::array endPointsXYZ( const Acts::Experimental::Blueprint::Node& node, Acts::BinningValue bVal) { unsigned int bIdx = 0; switch (bVal) { - case Acts::binX: + case Acts::BinningValue::binX: bIdx = 0; break; - case Acts::binY: + case Acts::BinningValue::binY: bIdx = 1; break; - case Acts::binZ: + case Acts::BinningValue::binZ: bIdx = 2; break; default: @@ -51,16 +51,18 @@ void Acts::Experimental::detail::BlueprintHelper::sort(Blueprint::Node& node, if (node.binning.size() == 1) { auto bVal = node.binning.front(); // x,y,z binning along the axis - if (bVal == binX || bVal == binY || bVal == binZ) { + if (bVal == BinningValue::binX || bVal == BinningValue::binY || + bVal == BinningValue::binZ) { Vector3 nodeCenter = node.transform.translation(); - Vector3 nodeSortAxis = node.transform.rotation().col(bVal); + Vector3 nodeSortAxis = node.transform.rotation().col(toUnderlying(bVal)); std::sort( node.children.begin(), node.children.end(), [&](const auto& a, const auto& b) { return (a->transform.translation() - nodeCenter).dot(nodeSortAxis) < (b->transform.translation() - nodeCenter).dot(nodeSortAxis); }); - } else if (bVal == binR && node.boundsType == VolumeBounds::eCylinder) { + } else if (bVal == BinningValue::binR && + node.boundsType == VolumeBounds::eCylinder) { std::sort(node.children.begin(), node.children.end(), [](const auto& a, const auto& b) { return 0.5 * (a->boundaryValues[0] + a->boundaryValues[1]) < @@ -111,7 +113,7 @@ void Acts::Experimental::detail::BlueprintHelper::fillGapsCylindrical( std::vector> gaps; // Only 1D binning implemented for the moment auto bVal = node.binning.front(); - if (bVal == binZ) { + if (bVal == BinningValue::binZ) { // adjust inner/outer radius if (adjustToParent) { std::for_each(node.children.begin(), node.children.end(), @@ -155,7 +157,7 @@ void Acts::Experimental::detail::BlueprintHelper::fillGapsCylindrical( gaps.push_back(std::move(gap)); } - } else if (bVal == binR) { + } else if (bVal == BinningValue::binR) { // We have binning in R present if (adjustToParent) { std::for_each(node.children.begin(), node.children.end(), @@ -213,7 +215,8 @@ void Acts::Experimental::detail::BlueprintHelper::fillGapsCuboidal( sort(node, false); // Cuboidal detector binnings - std::array allowedBinVals = {binX, binY, binZ}; + std::array allowedBinVals = { + BinningValue::binX, BinningValue::binY, BinningValue::binZ}; std::vector> gaps; auto binVal = node.binning.front(); @@ -225,8 +228,10 @@ void Acts::Experimental::detail::BlueprintHelper::fillGapsCuboidal( if (bv != binVal) { // Both boundary values and translation // have to be adjusted - child->boundaryValues[bv] = node.boundaryValues[bv]; - child->transform.translation()[bv] = node.transform.translation()[bv]; + child->boundaryValues[toUnderlying(bv)] = + node.boundaryValues[toUnderlying(bv)]; + child->transform.translation()[toUnderlying(bv)] = + node.transform.translation()[toUnderlying(bv)]; } } }); @@ -245,10 +250,10 @@ void Acts::Experimental::detail::BlueprintHelper::fillGapsCuboidal( gapTransform.rotate(node.transform.rotation()); gapTransform.pretranslate(0.5 * (neg + negC)); std::vector gapBounds{0, 0, 0}; - gapBounds[binVal] = 0.5 * gapSpan; + gapBounds[toUnderlying(binVal)] = 0.5 * gapSpan; for (auto bv : allowedBinVals) { if (bv != binVal) { - gapBounds[bv] = node.boundaryValues[bv]; + gapBounds[toUnderlying(bv)] = node.boundaryValues[toUnderlying(bv)]; } } auto gap = std::make_unique( @@ -268,10 +273,10 @@ void Acts::Experimental::detail::BlueprintHelper::fillGapsCuboidal( gapTransform.rotate(node.transform.rotation()); gapTransform.pretranslate(0.5 * (negC + posC)); std::vector gapBounds{0, 0, 0}; - gapBounds[binVal] = 0.5 * gapSpan; + gapBounds[toUnderlying(binVal)] = 0.5 * gapSpan; for (auto bv : allowedBinVals) { if (bv != binVal) { - gapBounds[bv] = node.boundaryValues[bv]; + gapBounds[toUnderlying(bv)] = node.boundaryValues[toUnderlying(bv)]; } } auto gap = std::make_unique( diff --git a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp index 137654223be..d6cd6c35128 100644 --- a/Core/src/Detector/detail/CuboidalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CuboidalDetectorHelper.cpp @@ -32,14 +32,15 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( ACTS_LOCAL_LOGGER(getDefaultLogger("CuboidalDetectorHelper", logLevel)); ACTS_DEBUG("Connect " << volumes.size() << " detector volumes in " - << binningValueNames()[bValue] << "."); + << binningValueName(bValue) << "."); // Check transform for consistency auto centerDistances = DetectorVolumeConsistency::checkCenterAlignment(gctx, volumes, bValue); // Assign the portal indices according to the volume bounds definition - std::array possibleValues = {binX, binY, binZ}; + std::array possibleValues = { + BinningValue::binX, BinningValue::binY, BinningValue::binZ}; // 1 -> [ 2,3 ] for binX connection (cylclic one step) // 2 -> [ 4,5 ] for binY connection (cylclic two steps) // 0 -> [ 0,1 ] for binZ connection (to be in line with cylinder covnention) @@ -48,7 +49,7 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( {PortalSet{2, 3}, PortalSet{4, 5}, PortalSet{0, 1}}}; // This is the picked set for fusing - auto [sIndex, fIndex] = portalSets[bValue]; + auto [sIndex, fIndex] = portalSets[toUnderlying(bValue)]; // Log the merge splits, i.e. the boundaries of the volumes std::array, 3u> mergeSplits; @@ -77,21 +78,22 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( // Values const auto firstBoundValues = firstVolume->volumeBounds().values(); const auto lastBoundValues = lastVolume->volumeBounds().values(); - Vector3 stepDirection = firstVolume->transform(gctx).rotation().col(bValue); + Vector3 stepDirection = + firstVolume->transform(gctx).rotation().col(toUnderlying(bValue)); for (auto [im, mergeValue] : enumerate(possibleValues)) { // Skip the bin value itself, fusing will took care of that if (mergeValue == bValue) { continue; } - for (auto [is, index] : enumerate(portalSets[mergeValue])) { + for (auto [is, index] : enumerate(portalSets[toUnderlying(mergeValue)])) { // Take rotation from first volume auto rotation = firstVolume->portalPtrs()[index] ->surface() .transform(gctx) .rotation(); - ActsScalar stepDown = firstBoundValues[bValue]; - ActsScalar stepUp = lastBoundValues[bValue]; + ActsScalar stepDown = firstBoundValues[toUnderlying(bValue)]; + ActsScalar stepUp = lastBoundValues[toUnderlying(bValue)]; // Take translation from first and last volume auto translationF = firstVolume->portalPtrs()[index] ->surface() @@ -110,7 +112,8 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( portalTransform.prerotate(rotation); portalTransform.pretranslate(translation); // The half length to be kept - ActsScalar keepHalfLength = firstBoundValues[counterPart(mergeValue)]; + ActsScalar keepHalfLength = + firstBoundValues[toUnderlying(counterPart(mergeValue))]; mergeParameters[index] = MergeParameters(keepHalfLength, portalTransform); } } @@ -147,8 +150,8 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( continue; } // Record the merge splits - mergeSplits[im].push_back(2 * boundValues[bValue]); - mergeHalfLengths[im] += boundValues[bValue]; + mergeSplits[im].push_back(2 * boundValues[toUnderlying(bValue)]); + mergeHalfLengths[im] += boundValues[toUnderlying(bValue)]; } } @@ -165,14 +168,14 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( // - this is an anticyclic swap bool mergedInX = true; switch (bValue) { - case binZ: { - mergedInX = (mergeValue == binY); + case BinningValue::binZ: { + mergedInX = (mergeValue == BinningValue::binY); } break; - case binY: { - mergedInX = (mergeValue == binX); + case BinningValue::binY: { + mergedInX = (mergeValue == BinningValue::binX); } break; - case binX: { - mergedInX = (mergeValue == binZ); + case BinningValue::binX: { + mergedInX = (mergeValue == BinningValue::binZ); } break; default: break; @@ -185,7 +188,7 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( stitchBoundaries.push_back(stitchBoundaries.back() + step); } - for (auto [is, index] : enumerate(portalSets[mergeValue])) { + for (auto [is, index] : enumerate(portalSets[toUnderlying(mergeValue)])) { // Check if you need to skip due to selections if (!selectedOnly.empty() && std::find(selectedOnly.begin(), selectedOnly.end(), index) == @@ -210,7 +213,8 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( // Make the stitch boundaries pReplacements.push_back(PortalReplacement( - portal, index, dir, stitchBoundaries, (mergedInX ? binX : binY))); + portal, index, dir, stitchBoundaries, + (mergedInX ? BinningValue::binX : BinningValue::binY))); } } @@ -246,20 +250,21 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( ACTS_LOCAL_LOGGER(getDefaultLogger("CuboidalDetectorHelper", logLevel)); ACTS_DEBUG("Connect " << containers.size() << " containers in " - << binningValueNames()[bValue] << "."); + << binningValueName(bValue) << "."); // Return the new container DetectorComponent::PortalContainer dShell; // The possible bin values - std::array possibleValues = {binX, binY, binZ}; + std::array possibleValues = { + BinningValue::binX, BinningValue::binY, BinningValue::binZ}; // And their associated portal sets, see above using PortalSet = std::array; std::vector portalSets = { {PortalSet{2, 3}, PortalSet{4, 5}, PortalSet{0, 1}}}; // This is the picked set for refubishing - auto [endIndex, startIndex] = portalSets[bValue]; + auto [endIndex, startIndex] = portalSets[toUnderlying(bValue)]; // Fusing along the connection direction (bValue) for (std::size_t ic = 1; ic < containers.size(); ++ic) { @@ -307,8 +312,8 @@ Acts::Experimental::detail::CuboidalDetectorHelper::connect( std::vector sidePortals = {}; for (auto sVals : possibleValues) { if (sVals != bValue) { - sidePortals.push_back(portalSets[sVals][0]); - sidePortals.push_back(portalSets[sVals][1]); + sidePortals.push_back(portalSets[toUnderlying(sVals)][0]); + sidePortals.push_back(portalSets[toUnderlying(sVals)][1]); } } diff --git a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp index 41442140a41..ab7af21e9e3 100644 --- a/Core/src/Detector/detail/CylindricalDetectorHelper.cpp +++ b/Core/src/Detector/detail/CylindricalDetectorHelper.cpp @@ -84,8 +84,9 @@ Acts::Experimental::PortalReplacement createDiscReplacement( const std::vector& phiBoundaries, unsigned int index, Acts::Direction dir) { // Autodetector stitch value - Acts::BinningValue stitchValue = - phiBoundaries.size() == 2u ? Acts::binR : Acts::binPhi; + Acts::BinningValue stitchValue = phiBoundaries.size() == 2u + ? Acts::BinningValue::binR + : Acts::BinningValue::binPhi; // Estimate ranges auto [minR, maxR] = Acts::min_max(rBoundaries); auto [sectorPhi, avgPhi] = Acts::range_medium(phiBoundaries); @@ -98,7 +99,7 @@ Acts::Experimental::PortalReplacement createDiscReplacement( transform, std::move(bounds)); // Make a portal and indicate the new link direction const auto& stitchBoundaries = - (stitchValue == Acts::binR) ? rBoundaries : phiBoundaries; + (stitchValue == Acts::BinningValue::binR) ? rBoundaries : phiBoundaries; return Acts::Experimental::PortalReplacement( std::make_shared(surface), index, dir, stitchBoundaries, stitchValue); @@ -120,8 +121,9 @@ Acts::Experimental::PortalReplacement createCylinderReplacement( const std::vector& phiBoundaries, unsigned int index, Acts::Direction dir) { // Autodetector stitch value - Acts::BinningValue stitchValue = - phiBoundaries.size() == 2u ? Acts::binZ : Acts::binPhi; + Acts::BinningValue stitchValue = phiBoundaries.size() == 2u + ? Acts::BinningValue::binZ + : Acts::BinningValue::binPhi; auto [lengthZ, medZ] = Acts::range_medium(zBoundaries); auto [sectorPhi, avgPhi] = Acts::range_medium(phiBoundaries); @@ -134,7 +136,7 @@ Acts::Experimental::PortalReplacement createCylinderReplacement( // A make a portal and indicate the new link direction const auto& stitchBoundaries = - (stitchValue == Acts::binZ) ? zBoundaries : phiBoundaries; + (stitchValue == Acts::BinningValue::binZ) ? zBoundaries : phiBoundaries; return Acts::Experimental::PortalReplacement( std::make_shared(surface), index, dir, stitchBoundaries, stitchValue); @@ -164,7 +166,7 @@ Acts::Experimental::PortalReplacement createSectorReplacement( // Create a new transform Acts::Transform3 transform = Acts::Transform3::Identity(); - if (binning == Acts::binR) { + if (binning == Acts::BinningValue::binR) { // Range and center-r calculation auto [range, medium] = Acts::range_medium(boundaries); // New joint center: @@ -178,7 +180,7 @@ Acts::Experimental::PortalReplacement createSectorReplacement( boundValues[Acts::RectangleBounds::BoundValues::eMinX]); // New joint bounds bounds = std::make_unique(halfX, 0.5 * range); - } else if (binning == Acts::binZ) { + } else if (binning == Acts::BinningValue::binZ) { // Range and medium z alculation auto [range, medium] = Acts::range_medium(boundaries); // Center R calculation, using projection onto vector @@ -401,8 +403,9 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInR( // As it is r-wrapping, the inner tube is guaranteed const Surface& refSurface = volumes[volumes.size() - 1u]->portals()[iu + 4u]->surface(); - pReplacements.push_back(createSectorReplacement( - gctx, vCenter, refSurface, rBoundaries, Acts::binR, iu + 4u, idir)); + pReplacements.push_back( + createSectorReplacement(gctx, vCenter, refSurface, rBoundaries, + Acts::BinningValue::binR, iu + 4u, idir)); } } } else { @@ -605,9 +608,9 @@ Acts::Experimental::detail::CylindricalDetectorHelper::connectInZ( selectedOnly.end()) { const Surface& refSurface = volumes[0u]->portals()[iu + iSecOffset]->surface(); - pReplacements.push_back( - createSectorReplacement(gctx, combinedCenter, refSurface, - zBoundaries, Acts::binZ, iu + 4u, idir)); + pReplacements.push_back(createSectorReplacement( + gctx, combinedCenter, refSurface, zBoundaries, + Acts::BinningValue::binZ, iu + 4u, idir)); } } } else { @@ -1033,7 +1036,7 @@ Acts::Experimental::detail::CylindricalDetectorHelper::wrapInZR( // The outer one is a single volume represented as a container auto outerContainer = containers.back(); std::shared_ptr wrappingVolume = nullptr; - for (auto [key, value] : outerContainer) { + for (const auto& [key, value] : outerContainer) { auto attachedVolumes = value->attachedDetectorVolumes(); for (const auto& ava : attachedVolumes) { for (const auto& av : ava) { diff --git a/Core/src/Detector/detail/DetectorVolumeConsistency.cpp b/Core/src/Detector/detail/DetectorVolumeConsistency.cpp index 3e1c54aaa87..0f9487c7953 100644 --- a/Core/src/Detector/detail/DetectorVolumeConsistency.cpp +++ b/Core/src/Detector/detail/DetectorVolumeConsistency.cpp @@ -45,7 +45,8 @@ Acts::Experimental::detail::DetectorVolumeConsistency::checkCenterAlignment( checkRotationAlignment(gctx, volumes); // Get the reference axis - Vector3 refAxis = volumes[0u]->transform(gctx).rotation().col(axisValue); + Vector3 refAxis = + volumes[0u]->transform(gctx).rotation().col(toUnderlying(axisValue)); for (auto [iv, v] : enumerate(volumes)) { if (iv > 0) { diff --git a/Core/src/Detector/detail/SupportSurfacesHelper.cpp b/Core/src/Detector/detail/SupportSurfacesHelper.cpp index 5c5ce8583d3..32c12a6499d 100644 --- a/Core/src/Detector/detail/SupportSurfacesHelper.cpp +++ b/Core/src/Detector/detail/SupportSurfacesHelper.cpp @@ -27,23 +27,26 @@ Acts::Experimental::detail::SupportSurfacesHelper::SupportSurfaceComponents Acts::Experimental::detail::SupportSurfacesHelper::CylindricalSupport:: operator()(const Extent& lExtent) const { // Bail out if you have no measure of R, Z - if (!lExtent.constrains(binZ) || !lExtent.constrains(binR)) { + if (!lExtent.constrains(BinningValue::binZ) || + !lExtent.constrains(BinningValue::binR)) { throw std::invalid_argument( "SupportSurfacesHelper::CylindricalSupport::operator() - z or " "r are not constrained."); } // Min / Max z with clearances adapted - ActsScalar minZ = lExtent.min(binZ) + std::abs(zClearance[0u]); - ActsScalar maxZ = lExtent.max(binZ) - std::abs(zClearance[1u]); + ActsScalar minZ = lExtent.min(BinningValue::binZ) + std::abs(zClearance[0u]); + ActsScalar maxZ = lExtent.max(BinningValue::binZ) - std::abs(zClearance[1u]); // Phi sector ActsScalar hPhiSector = M_PI; ActsScalar avgPhi = 0.; - if (lExtent.constrains(binPhi)) { + if (lExtent.constrains(BinningValue::binPhi)) { // Min / Max phi with clearances adapted - ActsScalar minPhi = lExtent.min(binPhi) + std::abs(phiClearance[0u]); - ActsScalar maxPhi = lExtent.max(binPhi) - std::abs(phiClearance[1u]); + ActsScalar minPhi = + lExtent.min(BinningValue::binPhi) + std::abs(phiClearance[0u]); + ActsScalar maxPhi = + lExtent.max(BinningValue::binPhi) - std::abs(phiClearance[1u]); hPhiSector = 0.5 * (maxPhi - minPhi); avgPhi = 0.5 * (minPhi + maxPhi); } @@ -54,10 +57,10 @@ operator()(const Extent& lExtent) const { } // The Radius estimation - ActsScalar r = - rOffset < 0 ? lExtent.min(binR) + rOffset : lExtent.max(binR) + rOffset; + ActsScalar r = rOffset < 0 ? lExtent.min(BinningValue::binR) + rOffset + : lExtent.max(BinningValue::binR) + rOffset; if (rOffset == 0.) { - r = lExtent.medium(binR); + r = lExtent.medium(BinningValue::binR); } // Components are resolved and returned as a tuple return { @@ -68,32 +71,35 @@ Acts::Experimental::detail::SupportSurfacesHelper::SupportSurfaceComponents Acts::Experimental::detail::SupportSurfacesHelper::DiscSupport::operator()( const Extent& lExtent) const { // Bail out if you have no measure of R, Z - if (!lExtent.constrains(binZ) || !lExtent.constrains(binR)) { + if (!lExtent.constrains(BinningValue::binZ) || + !lExtent.constrains(BinningValue::binR)) { throw std::invalid_argument( "SupportSurfacesHelper::DiscSupport::operator() - z or " "r are not constrained."); } // Min / Max r with clearances adapted - ActsScalar minR = lExtent.min(binR) + std::abs(rClearance[0u]); - ActsScalar maxR = lExtent.max(binR) - std::abs(rClearance[1u]); + ActsScalar minR = lExtent.min(BinningValue::binR) + std::abs(rClearance[0u]); + ActsScalar maxR = lExtent.max(BinningValue::binR) - std::abs(rClearance[1u]); // Phi sector ActsScalar hPhiSector = M_PI; ActsScalar avgPhi = 0.; - if (lExtent.constrains(binPhi)) { + if (lExtent.constrains(BinningValue::binPhi)) { // Min / Max phi with clearances adapted - ActsScalar minPhi = lExtent.min(binPhi) + std::abs(phiClearance[0u]); - ActsScalar maxPhi = lExtent.max(binPhi) - std::abs(phiClearance[1u]); + ActsScalar minPhi = + lExtent.min(BinningValue::binPhi) + std::abs(phiClearance[0u]); + ActsScalar maxPhi = + lExtent.max(BinningValue::binPhi) - std::abs(phiClearance[1u]); hPhiSector = 0.5 * (maxPhi - minPhi); avgPhi = 0.5 * (minPhi + maxPhi); } // The z position estimate - ActsScalar z = - zOffset < 0 ? lExtent.min(binZ) + zOffset : lExtent.max(binZ) + zOffset; + ActsScalar z = zOffset < 0 ? lExtent.min(BinningValue::binZ) + zOffset + : lExtent.max(BinningValue::binZ) + zOffset; if (zOffset == 0.) { - z = lExtent.medium(binZ); + z = lExtent.medium(BinningValue::binZ); } Transform3 transform = Transform3::Identity(); @@ -107,19 +113,20 @@ Acts::Experimental::detail::SupportSurfacesHelper::SupportSurfaceComponents Acts::Experimental::detail::SupportSurfacesHelper::RectangularSupport:: operator()(const Extent& lExtent) const { // Bail out if you have no measure of X, Y, Z - if (!(lExtent.constrains(binX) && lExtent.constrains(binY) && - lExtent.constrains(binZ))) { + if (!(lExtent.constrains(BinningValue::binX) && + lExtent.constrains(BinningValue::binY) && + lExtent.constrains(BinningValue::binZ))) { throw std::invalid_argument( "SupportSurfacesHelper::RectangularSupport::operator() - x, y or " "z are not constrained."); } // Set the local coordinates - cyclic permutation - std::array locals = {binX, binY}; - if (pPlacement == binX) { - locals = {binY, binZ}; - } else if (pPlacement == binY) { - locals = {binZ, binX}; + std::array locals = {BinningValue::binX, BinningValue::binY}; + if (pPlacement == BinningValue::binX) { + locals = {BinningValue::binY, BinningValue::binZ}; + } else if (pPlacement == BinningValue::binY) { + locals = {BinningValue::binZ, BinningValue::binX}; } // Make the rectangular shape @@ -130,7 +137,7 @@ operator()(const Extent& lExtent) const { ActsScalar gPlacement = lExtent.medium(pPlacement) + pOffset; Vector3 placement = Vector3::Zero(); - placement[pPlacement] = gPlacement; + placement[toUnderlying(pPlacement)] = gPlacement; Transform3 transform = Transform3::Identity(); transform.pretranslate(placement); diff --git a/Core/src/Geometry/CuboidVolumeBounds.cpp b/Core/src/Geometry/CuboidVolumeBounds.cpp index 2f4c122cb0f..e88507860f6 100644 --- a/Core/src/Geometry/CuboidVolumeBounds.cpp +++ b/Core/src/Geometry/CuboidVolumeBounds.cpp @@ -103,12 +103,14 @@ void CuboidVolumeBounds::buildSurfaceBounds() { } ActsScalar CuboidVolumeBounds::binningBorder(BinningValue bValue) const { - if (bValue <= binZ) { - return m_values[bValue]; + if (bValue <= BinningValue::binZ) { + return m_values[toUnderlying(bValue)]; } - if (bValue == binR) { - return std::sqrt(m_values[binX] * m_values[binX] + - m_values[binY] * m_values[binY]); + if (bValue == BinningValue::binR) { + return std::sqrt(m_values[toUnderlying(BinningValue::binX)] * + m_values[toUnderlying(BinningValue::binX)] + + m_values[toUnderlying(BinningValue::binY)] * + m_values[toUnderlying(BinningValue::binY)]); } return 0.0; } diff --git a/Core/src/Geometry/CuboidVolumeBuilder.cpp b/Core/src/Geometry/CuboidVolumeBuilder.cpp index 7f5385fcd9b..4d01bd78227 100644 --- a/Core/src/Geometry/CuboidVolumeBuilder.cpp +++ b/Core/src/Geometry/CuboidVolumeBuilder.cpp @@ -93,9 +93,9 @@ std::shared_ptr Acts::CuboidVolumeBuilder::buildLayer( lCfg.surfaceArrayCreator = std::make_shared(); LayerCreator layerCreator(lCfg); ProtoLayer pl{gctx, cfg.surfaces}; - pl.envelope[binX] = cfg.envelopeX; - pl.envelope[binY] = cfg.envelopeY; - pl.envelope[binZ] = cfg.envelopeZ; + pl.envelope[BinningValue::binX] = cfg.envelopeX; + pl.envelope[BinningValue::binY] = cfg.envelopeY; + pl.envelope[BinningValue::binZ] = cfg.envelopeZ; return layerCreator.planeLayer(gctx, cfg.surfaces, cfg.binsY, cfg.binsZ, BinningValue::binX, pl, trafo); } @@ -121,10 +121,10 @@ std::pair Acts::CuboidVolumeBuilder::binningRange( for (const auto& layercfg : cfg.layerCfg) { // recreating the protolayer for each layer => slow, but only few sensors ProtoLayer pl{gctx, layercfg.surfaces}; - pl.envelope[binX] = layercfg.envelopeX; + pl.envelope[BinningValue::binX] = layercfg.envelopeX; - double surfacePosMin = pl.min(binX); - double surfacePosMax = pl.max(binX); + double surfacePosMin = pl.min(BinningValue::binX); + double surfacePosMax = pl.max(BinningValue::binX); // Test if new extreme is found and set it if (surfacePosMin < minMax.first) { @@ -136,8 +136,10 @@ std::pair Acts::CuboidVolumeBuilder::binningRange( } // Use the volume boundaries as limits for the binning - minMax.first = std::min(minMax.first, minVolumeBoundaries(binX)); - minMax.second = std::max(minMax.second, maxVolumeBoundaries(binX)); + minMax.first = std::min( + minMax.first, minVolumeBoundaries(toUnderlying(BinningValue::binX))); + minMax.second = std::max( + minMax.second, maxVolumeBoundaries(toUnderlying(BinningValue::binX))); return minMax; } diff --git a/Core/src/Geometry/CylinderLayer.cpp b/Core/src/Geometry/CylinderLayer.cpp index 35002aac461..610147286cd 100644 --- a/Core/src/Geometry/CylinderLayer.cpp +++ b/Core/src/Geometry/CylinderLayer.cpp @@ -37,7 +37,7 @@ Acts::CylinderLayer::CylinderLayer( auto cVolumeBounds = std::make_shared( *CylinderSurface::m_bounds, thickness); // @todo rotate around x for the avePhi if you have a sector - m_representingVolume = std::make_unique(m_transform, cVolumeBounds); + m_representingVolume = std::make_unique(*m_transform, cVolumeBounds); // associate the layer to the surface CylinderSurface::associateLayer(*this); diff --git a/Core/src/Geometry/CylinderVolumeBounds.cpp b/Core/src/Geometry/CylinderVolumeBounds.cpp index 21f6dd667da..325345e2465 100644 --- a/Core/src/Geometry/CylinderVolumeBounds.cpp +++ b/Core/src/Geometry/CylinderVolumeBounds.cpp @@ -233,17 +233,18 @@ bool CylinderVolumeBounds::inside(const Vector3& pos, ActsScalar tol) const { Vector3 CylinderVolumeBounds::binningOffset(BinningValue bValue) const { // the medium radius is taken for r-type binning - if (bValue == Acts::binR || bValue == Acts::binRPhi) { + if (bValue == Acts::BinningValue::binR || + bValue == Acts::BinningValue::binRPhi) { return Vector3(0.5 * (get(eMinR) + get(eMaxR)), 0., 0.); } return VolumeBounds::binningOffset(bValue); } ActsScalar CylinderVolumeBounds::binningBorder(BinningValue bValue) const { - if (bValue == Acts::binR) { + if (bValue == Acts::BinningValue::binR) { return 0.5 * (get(eMaxR) - get(eMinR)); } - if (bValue == Acts::binZ) { + if (bValue == Acts::BinningValue::binZ) { return get(eHalfLengthZ); } return VolumeBounds::binningBorder(bValue); diff --git a/Core/src/Geometry/CylinderVolumeBuilder.cpp b/Core/src/Geometry/CylinderVolumeBuilder.cpp index d6e5786de58..195eaefffe6 100644 --- a/Core/src/Geometry/CylinderVolumeBuilder.cpp +++ b/Core/src/Geometry/CylinderVolumeBuilder.cpp @@ -353,8 +353,8 @@ Acts::CylinderVolumeBuilder::trackingVolume( // Filling loop for (const auto& elay : endcapConfig.layers) { // Getting the reference radius - double test = - elay->surfaceRepresentation().binningPositionValue(gctx, binR); + double test = elay->surfaceRepresentation().binningPositionValue( + gctx, BinningValue::binR); // Find the right bin auto ringVolume = std::find_if( volumeRminRmax.begin(), volumeRminRmax.end(), diff --git a/Core/src/Geometry/CylinderVolumeHelper.cpp b/Core/src/Geometry/CylinderVolumeHelper.cpp index e83ed62eae5..79d73b40505 100644 --- a/Core/src/Geometry/CylinderVolumeHelper.cpp +++ b/Core/src/Geometry/CylinderVolumeHelper.cpp @@ -101,7 +101,7 @@ Acts::CylinderVolumeHelper::createTrackingVolume( double zMinRaw = 0.; double zMaxRaw = 0.; - BinningValue bValue = binR; + BinningValue bValue = BinningValue::binR; // check the dimension and fill raw data if (!estimateAndCheckDimension(gctx, layers, cylinderBounds, transform, @@ -138,7 +138,7 @@ Acts::CylinderVolumeHelper::createTrackingVolume( << bValue); // create the Layer Array - layerArray = (bValue == binR) + layerArray = (bValue == BinningValue::binR) ? m_cfg.layerArrayCreator->layerArray(gctx, layers, rMin, rMax, bType, bValue) : m_cfg.layerArrayCreator->layerArray(gctx, layers, zMin, @@ -378,9 +378,9 @@ Acts::CylinderVolumeHelper::createContainerTrackingVolume( // create the volume array with the ITrackingVolumeArrayCreator std::shared_ptr volumeArray = (rCase) ? m_cfg.trackingVolumeArrayCreator->trackingVolumeArray( - gctx, volumes, binR) + gctx, volumes, BinningValue::binR) : m_cfg.trackingVolumeArrayCreator->trackingVolumeArray( - gctx, volumes, binZ); + gctx, volumes, BinningValue::binZ); if (volumeArray == nullptr) { ACTS_WARNING( "Creation of TrackingVolume array did not succeed - returning 0 "); @@ -485,7 +485,7 @@ bool Acts::CylinderVolumeHelper::estimateAndCheckDimension( } // set the binning value - bValue = radial ? binR : binZ; + bValue = radial ? BinningValue::binR : BinningValue::binZ; ACTS_VERBOSE( "Estimate/check CylinderVolumeBounds from/w.r.t. enclosed " @@ -676,7 +676,7 @@ bool Acts::CylinderVolumeHelper::interGlueTrackingVolume( // create the outside volume array std::shared_ptr glueVolumesNegativeFaceArray = m_cfg.trackingVolumeArrayCreator->trackingVolumeArray( - gctx, glueVolumesNegativeFace, binR); + gctx, glueVolumesNegativeFace, BinningValue::binR); // register the glue voluems glueDescr.registerGlueVolumes(negativeFaceXY, glueVolumesNegativeFaceArray); @@ -685,7 +685,7 @@ bool Acts::CylinderVolumeHelper::interGlueTrackingVolume( // create the outside volume array std::shared_ptr glueVolumesPositiveFaceArray = m_cfg.trackingVolumeArrayCreator->trackingVolumeArray( - gctx, glueVolumesPositiveFace, binR); + gctx, glueVolumesPositiveFace, BinningValue::binR); // register the glue voluems glueDescr.registerGlueVolumes(positiveFaceXY, glueVolumesPositiveFaceArray); @@ -694,7 +694,7 @@ bool Acts::CylinderVolumeHelper::interGlueTrackingVolume( // create the outside volume array std::shared_ptr glueVolumesInnerTubeArray = m_cfg.trackingVolumeArrayCreator->trackingVolumeArray( - gctx, glueVolumesInnerTube, binZ); + gctx, glueVolumesInnerTube, BinningValue::binZ); // register the glue voluems glueDescr.registerGlueVolumes(tubeInnerCover, glueVolumesInnerTubeArray); } @@ -702,7 +702,7 @@ bool Acts::CylinderVolumeHelper::interGlueTrackingVolume( // create the outside volume array std::shared_ptr glueVolumesOuterTubeArray = m_cfg.trackingVolumeArrayCreator->trackingVolumeArray( - gctx, glueVolumesOuterTube, binZ); + gctx, glueVolumesOuterTube, BinningValue::binZ); // register the glue voluems glueDescr.registerGlueVolumes(tubeOuterCover, glueVolumesOuterTubeArray); } @@ -956,7 +956,7 @@ Acts::CylinderVolumeHelper::createCylinderLayer(double z, double r, // z-binning BinUtility layerBinUtility(binsZ, z - halflengthZ, z + halflengthZ, open, - binZ); + BinningValue::binZ); if (binsPhi == 1) { // the BinUtility for the material // ---------------------> create material for the layer surface @@ -966,7 +966,7 @@ Acts::CylinderVolumeHelper::createCylinderLayer(double z, double r, } else { // break the phi symmetry // update the BinUtility: local position on Cylinder is rPhi, z BinUtility layerBinUtilityPhiZ(binsPhi, -r * M_PI, +r * M_PI, closed, - binPhi); + BinningValue::binPhi); layerBinUtilityPhiZ += layerBinUtility; // ---------------------> create material for the layer surface ACTS_VERBOSE(" -> Preparing the binned material with " @@ -991,13 +991,14 @@ std::shared_ptr Acts::CylinderVolumeHelper::createDiscLayer( const Transform3 transform(Translation3(0., 0., z)); // R is the primary binning for the material - BinUtility materialBinUtility(binsR, rMin, rMax, open, binR); + BinUtility materialBinUtility(binsR, rMin, rMax, open, BinningValue::binR); if (binsPhi == 1) { ACTS_VERBOSE(" -> Preparing the binned material with " << binsR << " bins in R. "); } else { // also binning in phi chosen - materialBinUtility += BinUtility(binsPhi, -M_PI, M_PI, closed, binPhi); + materialBinUtility += + BinUtility(binsPhi, -M_PI, M_PI, closed, BinningValue::binPhi); ACTS_VERBOSE(" -> Preparing the binned material with " << binsPhi << " / " << binsR << " bins in phi / R. "); } diff --git a/Core/src/Geometry/CylinderVolumeStack.cpp b/Core/src/Geometry/CylinderVolumeStack.cpp index 0a25937bee8..b6c75afb54f 100644 --- a/Core/src/Geometry/CylinderVolumeStack.cpp +++ b/Core/src/Geometry/CylinderVolumeStack.cpp @@ -108,14 +108,15 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, const Logger& logger) { ACTS_DEBUG("Creating CylinderVolumeStack from " << m_volumes.size() << " volumes in direction " - << binningValueNames()[direction]); + << binningValueName(direction)); if (m_volumes.empty()) { throw std::invalid_argument( "CylinderVolumeStack requires at least one volume"); } - if (direction != Acts::binZ && direction != Acts::binR) { - throw std::invalid_argument(binningValueNames()[direction] + + if (direction != Acts::BinningValue::binZ && + direction != Acts::BinningValue::binR) { + throw std::invalid_argument(binningValueName(direction) + " is not supported "); } @@ -156,7 +157,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, ACTS_VERBOSE("Checking volume alignment"); checkVolumeAlignment(volumeTuples, logger); - if (direction == Acts::binZ) { + if (direction == Acts::BinningValue::binZ) { ACTS_VERBOSE("Sorting by volume z position"); std::sort(volumeTuples.begin(), volumeTuples.end(), [](const auto& a, const auto& b) { @@ -219,7 +220,7 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, // @TODO: We probably can reuse m_transform m_groupTransform = m_transform; - } else if (direction == Acts::binR) { + } else if (direction == Acts::BinningValue::binR) { ACTS_VERBOSE("Sorting by volume r middle point"); std::sort(volumeTuples.begin(), volumeTuples.end(), [](const auto& a, const auto& b) { return a.midR() < b.midR(); }); @@ -278,9 +279,9 @@ void CylinderVolumeStack::initializeOuterVolume(BinningValue direction, m_groupTransform = m_transform; } else { - ACTS_ERROR("Binning in " << binningValueNames()[direction] + ACTS_ERROR("Binning in " << binningValueName(direction) << " is not supported"); - throw std::invalid_argument(binningValueNames()[direction] + + throw std::invalid_argument(binningValueName(direction) + " is not supported "); } } diff --git a/Core/src/Geometry/DiscLayer.cpp b/Core/src/Geometry/DiscLayer.cpp index ccb167f70a1..14f6f82ad68 100644 --- a/Core/src/Geometry/DiscLayer.cpp +++ b/Core/src/Geometry/DiscLayer.cpp @@ -39,7 +39,8 @@ Acts::DiscLayer::DiscLayer(const Transform3& transform, auto rVolumeBounds = std::make_shared(*rBounds, thickness); // @todo rotate around x for the avePhi if you have a sector - m_representingVolume = std::make_unique(m_transform, rVolumeBounds); + m_representingVolume = + std::make_unique(*m_transform, rVolumeBounds); } // associate the layer to the layer surface itself DiscSurface::associateLayer(*this); diff --git a/Core/src/Geometry/Extent.cpp b/Core/src/Geometry/Extent.cpp index 334e8813e46..e8a4467a6a6 100644 --- a/Core/src/Geometry/Extent.cpp +++ b/Core/src/Geometry/Extent.cpp @@ -16,15 +16,15 @@ #include #include -Acts::Extent::Extent( - const std::array, binValues>& envelope) +Acts::Extent::Extent(const ExtentEnvelope& envelope) : m_constrains(0), m_envelope(envelope) { - m_range[binR] = + m_range[toUnderlying(BinningValue::binR)] = Range1D(0., std::numeric_limits::max()); - m_range[binPhi] = Range1D(-M_PI, M_PI); - m_range[binRPhi] = + m_range[toUnderlying(BinningValue::binPhi)] = + Range1D(-M_PI, M_PI); + m_range[toUnderlying(BinningValue::binRPhi)] = Range1D(0., std::numeric_limits::max()); - m_range[binMag] = + m_range[toUnderlying(BinningValue::binMag)] = Range1D(0., std::numeric_limits::max()); } @@ -35,22 +35,22 @@ void Acts::Extent::extend(const Vector3& vtx, // Get the casted value given the binning value description ActsScalar cValue = VectorHelpers::cast(vtx, bValue); if (fillHistograms) { - m_valueHistograms[bValue].push_back(cValue); + m_valueHistograms[toUnderlying(bValue)].push_back(cValue); } // Apply envelope as suggested ActsScalar lEnv = applyEnv ? m_envelope[bValue][0] : 0.; ActsScalar hEnv = applyEnv ? m_envelope[bValue][1] : 0.; ActsScalar mValue = cValue - lEnv; // Special protection for radial value - if (bValue == binR && mValue < 0.) { + if (bValue == BinningValue::binR && mValue < 0.) { mValue = std::max(mValue, 0.); } if (constrains(bValue)) { - m_range[bValue].expand(mValue, cValue + hEnv); + m_range[toUnderlying(bValue)].expand(mValue, cValue + hEnv); } else { - m_range[bValue].shrink(mValue, cValue + hEnv); + m_range[toUnderlying(bValue)].shrink(mValue, cValue + hEnv); } - m_constrains.set(bValue); + m_constrains.set(toUnderlying(bValue)); } } @@ -63,55 +63,58 @@ void Acts::Extent::extend(const Extent& rhs, ActsScalar lEnv = applyEnv ? m_envelope[bValue][0] : 0.; ActsScalar hEnv = applyEnv ? m_envelope[bValue][1] : 0.; if (constrains(bValue)) { - m_range[bValue].expand(rhs.range()[bValue].min() - lEnv, - rhs.range()[bValue].max() + hEnv); + m_range[toUnderlying(bValue)].expand( + rhs.range()[toUnderlying(bValue)].min() - lEnv, + rhs.range()[toUnderlying(bValue)].max() + hEnv); } else { - m_range[bValue].shrink(rhs.range()[bValue].min() - lEnv, - rhs.range()[bValue].max() + hEnv); + m_range[toUnderlying(bValue)].shrink( + rhs.range()[toUnderlying(bValue)].min() - lEnv, + rhs.range()[toUnderlying(bValue)].max() + hEnv); } - m_constrains.set(bValue); + m_constrains.set(toUnderlying(bValue)); } else if (rhs.envelope()[bValue] != zeroEnvelope) { // Only an envelope given, but value is not constraint -> apply envelope - m_range[bValue].expand(m_range[bValue].min() - rhs.envelope()[bValue][0], - m_range[bValue].max() + rhs.envelope()[bValue][1]); - m_constrains.set(bValue); + m_range[toUnderlying(bValue)].expand( + m_range[toUnderlying(bValue)].min() - rhs.envelope()[bValue][0], + m_range[toUnderlying(bValue)].max() + rhs.envelope()[bValue][1]); + m_constrains.set(toUnderlying(bValue)); } } } void Acts::Extent::addConstrain(const Acts::Extent& rhs, const ExtentEnvelope& envelope) { - for (const auto& bValue : s_binningValues) { + for (const auto& bValue : allBinningValues()) { if (rhs.constrains(bValue) && !constrains(bValue)) { const auto& cRange = rhs.range(bValue); - m_range[bValue].setMin(cRange.min() - envelope[bValue][0u]); - m_range[bValue].setMax(cRange.max() + envelope[bValue][1u]); - m_constrains.set(bValue); + m_range[toUnderlying(bValue)].setMin(cRange.min() - envelope[bValue][0u]); + m_range[toUnderlying(bValue)].setMax(cRange.max() + envelope[bValue][1u]); + m_constrains.set(toUnderlying(bValue)); } } } void Acts::Extent::set(BinningValue bValue, ActsScalar min, ActsScalar max) { ActsScalar minval = min; - if (bValue == binR && minval < 0.) { + if (bValue == BinningValue::binR && minval < 0.) { minval = 0.; } - m_range[bValue] = Range1D{minval, max}; - m_constrains.set(bValue); + m_range[toUnderlying(bValue)] = Range1D{minval, max}; + m_constrains.set(toUnderlying(bValue)); } void Acts::Extent::setMin(BinningValue bValue, ActsScalar min) { ActsScalar minval = min; - if (bValue == binR && minval < 0.) { + if (bValue == BinningValue::binR && minval < 0.) { minval = 0.; } - m_range[bValue].setMin(0u, minval); - m_constrains.set(bValue); + m_range[toUnderlying(bValue)].setMin(0u, minval); + m_constrains.set(toUnderlying(bValue)); } void Acts::Extent::setMax(BinningValue bValue, ActsScalar max) { - m_range[bValue].setMax(0u, max); - m_constrains.set(bValue); + m_range[toUnderlying(bValue)].setMax(0u, max); + m_constrains.set(toUnderlying(bValue)); } void Acts::Extent::setEnvelope(const ExtentEnvelope& envelope) { @@ -120,7 +123,7 @@ void Acts::Extent::setEnvelope(const ExtentEnvelope& envelope) { bool Acts::Extent::contains(const Vector3& vtx) const { Extent checkExtent; - for (const auto& bv : s_binningValues) { + for (const auto& bv : allBinningValues()) { if (constrains(bv)) { ActsScalar vtxVal = VectorHelpers::cast(vtx, bv); checkExtent.set(bv, vtxVal, vtxVal); @@ -129,57 +132,52 @@ bool Acts::Extent::contains(const Vector3& vtx) const { return contains(checkExtent); } -bool Acts::Extent::contains(const Extent& rhs, BinningValue bValue) const { +bool Acts::Extent::contains(const Extent& rhs, + std::optional bValue) const { // Helper to check including a constraint bit set check auto checkContainment = [&](BinningValue bvc) -> bool { if (!constrains(bvc)) { return true; } - return (rhs.range()[bvc] <= m_range[bvc]); + return (rhs.range()[toUnderlying(bvc)] <= m_range[toUnderlying(bvc)]); }; // Check all - if (bValue == binValues) { - for (const auto& bv : s_binningValues) { - if (!checkContainment(bv)) { - return false; - } - } - return true; + if (!bValue.has_value()) { + return std::all_of(allBinningValues().begin(), allBinningValues().end(), + checkContainment); } // Check specific - return checkContainment(bValue); + return checkContainment(bValue.value()); } -bool Acts::Extent::intersects(const Extent& rhs, BinningValue bValue) const { +bool Acts::Extent::intersects(const Extent& rhs, + std::optional bValue) const { // Helper to check including a constraint bit set check auto checkIntersect = [&](BinningValue bvc) -> bool { if (!constrains(bvc) || !rhs.constrains(bvc)) { return false; } - return (m_range[bvc] && rhs.range()[bvc]); + return (m_range[toUnderlying(bvc)] && rhs.range()[toUnderlying(bvc)]); }; // Check all - if (bValue == binValues) { - for (const auto& bv : s_binningValues) { - if (checkIntersect(bv)) { - return true; - } - } - return false; + if (!bValue.has_value()) { + return std::any_of(allBinningValues().begin(), allBinningValues().end(), + checkIntersect); } // Check specific - return checkIntersect(bValue); + return checkIntersect(bValue.value()); } bool Acts::Extent::constrains(BinningValue bValue) const { - if (bValue == binValues) { - return (m_constrains.count() > 0); - } return m_constrains.test(static_cast(bValue)); } +bool Acts::Extent::constrains() const { + return m_constrains.count() > 0; +} + bool Acts::Extent::operator==(const Extent& e) const { if (m_constrains != e.m_constrains) { return false; @@ -199,11 +197,11 @@ bool Acts::Extent::operator==(const Extent& e) const { std::string Acts::Extent::toString(const std::string& indent) const { std::stringstream sl; sl << indent << "Extent in space : " << std::endl; - for (const auto& bv : s_binningValues) { + for (const auto& bv : allBinningValues()) { if (constrains(bv)) { - sl << indent << " - value :" << std::setw(10) << binningValueNames()[bv] - << " | range = [" << m_range[bv].min() << ", " << m_range[bv].max() - << "]" << std::endl; + sl << indent << " - value :" << std::setw(10) << binningValueName(bv) + << " | range = [" << m_range[toUnderlying(bv)].min() << ", " + << m_range[toUnderlying(bv)].max() << "]" << std::endl; } } return sl.str(); diff --git a/Core/src/Geometry/KDTreeTrackingGeometryBuilder.cpp b/Core/src/Geometry/KDTreeTrackingGeometryBuilder.cpp index 3da1043d7bd..315c06de01c 100644 --- a/Core/src/Geometry/KDTreeTrackingGeometryBuilder.cpp +++ b/Core/src/Geometry/KDTreeTrackingGeometryBuilder.cpp @@ -52,7 +52,9 @@ Acts::KDTreeTrackingGeometryBuilder::trackingGeometry( for (auto& s : m_cfg.surfaces) { auto ext = s->polyhedronRepresentation(gctx, 1u).extent(); surfacesMeasured.push_back(MeasuredSurface{ - std::array{ext.medium(binZ), ext.medium(binR)}, s}); + std::array{ext.medium(BinningValue::binZ), + ext.medium(BinningValue::binR)}, + s}); } // Create the KDTree @@ -82,8 +84,8 @@ Acts::KDTreeTrackingGeometryBuilder::translateVolume( std::vector> translatedVolumes = {}; // Volume extent - auto rangeR = ptVolume.extent.range(Acts::binR); - auto rangeZ = ptVolume.extent.range(Acts::binZ); + auto rangeR = ptVolume.extent.range(Acts::BinningValue::binR); + auto rangeZ = ptVolume.extent.range(Acts::BinningValue::binZ); // Simple gap volume if (!ptVolume.container.has_value()) { @@ -156,8 +158,8 @@ Acts::KDTreeTrackingGeometryBuilder::translateLayer( // Try to pull from the kd tree RangeXD<2u, ActsScalar> zrRange; - zrRange[0u] = plVolume.extent.range(Acts::binZ); - zrRange[1u] = plVolume.extent.range(Acts::binR); + zrRange[0u] = plVolume.extent.range(Acts::BinningValue::binZ); + zrRange[1u] = plVolume.extent.range(Acts::BinningValue::binR); auto layerSurfaces = kdt.rangeSearchWithKey(zrRange); ACTS_VERBOSE(indent + ">> looking z/r range = " << zrRange.toString()); diff --git a/Core/src/Geometry/LayerArrayCreator.cpp b/Core/src/Geometry/LayerArrayCreator.cpp index cfc49623eb0..baca1a8c13d 100644 --- a/Core/src/Geometry/LayerArrayCreator.cpp +++ b/Core/src/Geometry/LayerArrayCreator.cpp @@ -179,19 +179,19 @@ std::shared_ptr Acts::LayerArrayCreator::createNavigationSurface( // switching he binnig values switch (bValue) { // case x - case binX: { + case BinningValue::binX: { translation = Vector3(offset, 0., 0.); } break; // case y - case binY: { + case BinningValue::binY: { translation = Vector3(0., offset, 0.); } break; // case z - case binZ: { + case BinningValue::binZ: { translation = Vector3(0., 0., offset); } break; // case R - case binR: { + case BinningValue::binR: { // binning in R and cylinder surface means something different if (layerSurface.type() == Surface::Cylinder) { break; diff --git a/Core/src/Geometry/LayerCreator.cpp b/Core/src/Geometry/LayerCreator.cpp index 174d0578773..a5c194b0323 100644 --- a/Core/src/Geometry/LayerCreator.cpp +++ b/Core/src/Geometry/LayerCreator.cpp @@ -59,25 +59,26 @@ Acts::MutableLayerPtr Acts::LayerCreator::cylinderLayer( _protoLayer ? *_protoLayer : ProtoLayer(gctx, surfaces); // Remaining layer parameters - they include the envelopes - double layerR = protoLayer.medium(binR); - double layerZ = protoLayer.medium(binZ); - double layerHalfZ = 0.5 * protoLayer.range(binZ); - double layerThickness = protoLayer.range(binR); + double layerR = protoLayer.medium(BinningValue::binR); + double layerZ = protoLayer.medium(BinningValue::binZ); + double layerHalfZ = 0.5 * protoLayer.range(BinningValue::binZ); + double layerThickness = protoLayer.range(BinningValue::binR); ACTS_VERBOSE("Creating a cylindrical Layer:"); ACTS_VERBOSE(" - with layer R = " << layerR); - ACTS_VERBOSE(" - from R min/max = " << protoLayer.min(binR, false) << " / " - << protoLayer.max(binR, false)); + ACTS_VERBOSE(" - from R min/max = " + << protoLayer.min(BinningValue::binR, false) << " / " + << protoLayer.max(BinningValue::binR, false)); ACTS_VERBOSE(" - with R thickness = " << layerThickness); - ACTS_VERBOSE(" - incl envelope = " << protoLayer.envelope[binR][0u] - << " / " - << protoLayer.envelope[binR][1u]); + ACTS_VERBOSE(" - incl envelope = " + << protoLayer.envelope[BinningValue::binR][0u] << " / " + << protoLayer.envelope[BinningValue::binR][1u]); ACTS_VERBOSE(" - with z min/max = " - << protoLayer.min(binZ, false) << " (-" - << protoLayer.envelope[binZ][0u] << ") / " - << protoLayer.max(binZ, false) << " (+" - << protoLayer.envelope[binZ][1u] << ")"); + << protoLayer.min(BinningValue::binZ, false) << " (-" + << protoLayer.envelope[BinningValue::binZ][0u] << ") / " + << protoLayer.max(BinningValue::binZ, false) << " (+" + << protoLayer.envelope[BinningValue::binZ][1u] << ")"); ACTS_VERBOSE(" - z center = " << layerZ); ACTS_VERBOSE(" - halflength z = " << layerHalfZ); @@ -91,9 +92,9 @@ Acts::MutableLayerPtr Acts::LayerCreator::cylinderLayer( ACTS_VERBOSE(" - layer z shift = " << -layerZ); } - ACTS_VERBOSE(" - with phi min/max = " << protoLayer.min(binPhi, false) - << " / " - << protoLayer.max(binPhi, false)); + ACTS_VERBOSE(" - with phi min/max = " + << protoLayer.min(BinningValue::binPhi, false) << " / " + << protoLayer.max(BinningValue::binPhi, false)); ACTS_VERBOSE(" - # of modules = " << surfaces.size() << " ordered in ( " << binsPhi << " x " << binsZ << ")"); std::unique_ptr sArray; @@ -131,25 +132,26 @@ Acts::MutableLayerPtr Acts::LayerCreator::cylinderLayer( _protoLayer ? *_protoLayer : ProtoLayer(gctx, surfaces); // remaining layer parameters - double layerR = protoLayer.medium(binR); - double layerZ = protoLayer.medium(binZ); - double layerHalfZ = 0.5 * protoLayer.range(binZ); - double layerThickness = protoLayer.range(binR); + double layerR = protoLayer.medium(BinningValue::binR); + double layerZ = protoLayer.medium(BinningValue::binZ); + double layerHalfZ = 0.5 * protoLayer.range(BinningValue::binZ); + double layerThickness = protoLayer.range(BinningValue::binR); // adjust the layer radius ACTS_VERBOSE("Creating a cylindrical Layer:"); ACTS_VERBOSE(" - with layer R = " << layerR); - ACTS_VERBOSE(" - from R min/max = " << protoLayer.min(binR, false) << " / " - << protoLayer.max(binR, false)); + ACTS_VERBOSE(" - from R min/max = " + << protoLayer.min(BinningValue::binR, false) << " / " + << protoLayer.max(BinningValue::binR, false)); ACTS_VERBOSE(" - with R thickness = " << layerThickness); - ACTS_VERBOSE(" - incl envelope = " << protoLayer.envelope[binR][0u] - << " / " - << protoLayer.envelope[binR][1u]); + ACTS_VERBOSE(" - incl envelope = " + << protoLayer.envelope[BinningValue::binR][0u] << " / " + << protoLayer.envelope[BinningValue::binR][1u]); ACTS_VERBOSE(" - with z min/max = " - << protoLayer.min(binZ, false) << " (-" - << protoLayer.envelope[binZ][0u] << ") / " - << protoLayer.max(binZ, false) << " (+" - << protoLayer.envelope[binZ][1u] << ")"); + << protoLayer.min(BinningValue::binZ, false) << " (-" + << protoLayer.envelope[BinningValue::binZ][0u] << ") / " + << protoLayer.max(BinningValue::binZ, false) << " (+" + << protoLayer.envelope[BinningValue::binZ][1u] << ")"); ACTS_VERBOSE(" - z center = " << layerZ); ACTS_VERBOSE(" - halflength z = " << layerHalfZ); @@ -163,9 +165,9 @@ Acts::MutableLayerPtr Acts::LayerCreator::cylinderLayer( ACTS_VERBOSE(" - layer z shift = " << -layerZ); } - ACTS_VERBOSE(" - with phi min/max = " << protoLayer.min(binPhi, false) - << " / " - << protoLayer.max(binPhi, false)); + ACTS_VERBOSE(" - with phi min/max = " + << protoLayer.min(BinningValue::binPhi, false) << " / " + << protoLayer.max(BinningValue::binPhi, false)); ACTS_VERBOSE(" - # of modules = " << surfaces.size() << ""); // create the surface array @@ -203,26 +205,27 @@ Acts::MutableLayerPtr Acts::LayerCreator::discLayer( ProtoLayer protoLayer = _protoLayer ? *_protoLayer : ProtoLayer(gctx, surfaces); - double layerZ = protoLayer.medium(binZ); - double layerThickness = protoLayer.range(binZ); + double layerZ = protoLayer.medium(BinningValue::binZ); + double layerThickness = protoLayer.range(BinningValue::binZ); // adjust the layer radius ACTS_VERBOSE("Creating a disk Layer:"); ACTS_VERBOSE(" - at Z position = " << layerZ); - ACTS_VERBOSE(" - from Z min/max = " << protoLayer.min(binZ, false) << " / " - << protoLayer.max(binZ, false)); + ACTS_VERBOSE(" - from Z min/max = " + << protoLayer.min(BinningValue::binZ, false) << " / " + << protoLayer.max(BinningValue::binZ, false)); ACTS_VERBOSE(" - with Z thickness = " << layerThickness); - ACTS_VERBOSE(" - incl envelope = " << protoLayer.envelope[binZ][0u] - << " / " - << protoLayer.envelope[binZ][1u]); + ACTS_VERBOSE(" - incl envelope = " + << protoLayer.envelope[BinningValue::binZ][0u] << " / " + << protoLayer.envelope[BinningValue::binZ][1u]); ACTS_VERBOSE(" - with R min/max = " - << protoLayer.min(binR, false) << " (-" - << protoLayer.envelope[binR][0u] << ") / " - << protoLayer.max(binR, false) << " (+" - << protoLayer.envelope[binR][1u] << ")"); - ACTS_VERBOSE(" - with phi min/max = " << protoLayer.min(binPhi, false) - << " / " - << protoLayer.max(binPhi, false)); + << protoLayer.min(BinningValue::binR, false) << " (-" + << protoLayer.envelope[BinningValue::binR][0u] << ") / " + << protoLayer.max(BinningValue::binR, false) << " (+" + << protoLayer.envelope[BinningValue::binR][1u] << ")"); + ACTS_VERBOSE(" - with phi min/max = " + << protoLayer.min(BinningValue::binPhi, false) << " / " + << protoLayer.max(BinningValue::binPhi, false)); ACTS_VERBOSE(" - # of modules = " << surfaces.size() << " ordered in ( " << binsR << " x " << binsPhi << ")"); @@ -241,8 +244,8 @@ Acts::MutableLayerPtr Acts::LayerCreator::discLayer( } // create the share disc bounds - auto dBounds = std::make_shared(protoLayer.min(binR), - protoLayer.max(binR)); + auto dBounds = std::make_shared( + protoLayer.min(BinningValue::binR), protoLayer.max(BinningValue::binR)); // create the layers // we use the same transform here as for the layer itself @@ -267,26 +270,27 @@ Acts::MutableLayerPtr Acts::LayerCreator::discLayer( ProtoLayer protoLayer = _protoLayer ? *_protoLayer : ProtoLayer(gctx, surfaces); - double layerZ = protoLayer.medium(binZ); - double layerThickness = protoLayer.range(binZ); + double layerZ = protoLayer.medium(BinningValue::binZ); + double layerThickness = protoLayer.range(BinningValue::binZ); // adjust the layer radius ACTS_VERBOSE("Creating a disk Layer:"); ACTS_VERBOSE(" - at Z position = " << layerZ); - ACTS_VERBOSE(" - from Z min/max = " << protoLayer.min(binZ, false) << " / " - << protoLayer.max(binZ, false)); + ACTS_VERBOSE(" - from Z min/max = " + << protoLayer.min(BinningValue::binZ, false) << " / " + << protoLayer.max(BinningValue::binZ, false)); ACTS_VERBOSE(" - with Z thickness = " << layerThickness); - ACTS_VERBOSE(" - incl envelope = " << protoLayer.envelope[binZ][0u] - << " / " - << protoLayer.envelope[binZ][1u]); + ACTS_VERBOSE(" - incl envelope = " + << protoLayer.envelope[BinningValue::binZ][0u] << " / " + << protoLayer.envelope[BinningValue::binZ][1u]); ACTS_VERBOSE(" - with R min/max = " - << protoLayer.min(binR, false) << " (-" - << protoLayer.envelope[binR][0u] << ") / " - << protoLayer.max(binR, false) << " (+" - << protoLayer.envelope[binR][1u] << ")"); - ACTS_VERBOSE(" - with phi min/max = " << protoLayer.min(binPhi, false) - << " / " - << protoLayer.max(binPhi, false)); + << protoLayer.min(BinningValue::binR, false) << " (-" + << protoLayer.envelope[BinningValue::binR][0u] << ") / " + << protoLayer.max(BinningValue::binR, false) << " (+" + << protoLayer.envelope[BinningValue::binR][1u] << ")"); + ACTS_VERBOSE(" - with phi min/max = " + << protoLayer.min(BinningValue::binPhi, false) << " / " + << protoLayer.max(BinningValue::binPhi, false)); ACTS_VERBOSE(" - # of modules = " << surfaces.size()); // create the layer transforms if not given @@ -305,8 +309,8 @@ Acts::MutableLayerPtr Acts::LayerCreator::discLayer( } // create the shared disc bounds - auto dBounds = std::make_shared(protoLayer.min(binR), - protoLayer.max(binR)); + auto dBounds = std::make_shared( + protoLayer.min(BinningValue::binR), protoLayer.max(BinningValue::binR)); // create the layers MutableLayerPtr dLayer = @@ -333,38 +337,52 @@ Acts::MutableLayerPtr Acts::LayerCreator::planeLayer( double layerHalf1 = 0, layerHalf2 = 0, layerThickness = 0; switch (bValue) { case BinningValue::binX: { - layerHalf1 = 0.5 * (protoLayer.max(binY) - protoLayer.min(binY)); - layerHalf2 = 0.5 * (protoLayer.max(binZ) - protoLayer.min(binZ)); - layerThickness = (protoLayer.max(binX) - protoLayer.min(binX)); + layerHalf1 = 0.5 * (protoLayer.max(BinningValue::binY) - + protoLayer.min(BinningValue::binY)); + layerHalf2 = 0.5 * (protoLayer.max(BinningValue::binZ) - + protoLayer.min(BinningValue::binZ)); + layerThickness = (protoLayer.max(BinningValue::binX) - + protoLayer.min(BinningValue::binX)); break; } case BinningValue::binY: { - layerHalf1 = 0.5 * (protoLayer.max(binX) - protoLayer.min(binX)); - layerHalf2 = 0.5 * (protoLayer.max(binZ) - protoLayer.min(binZ)); - layerThickness = (protoLayer.max(binY) - protoLayer.min(binY)); + layerHalf1 = 0.5 * (protoLayer.max(BinningValue::binX) - + protoLayer.min(BinningValue::binX)); + layerHalf2 = 0.5 * (protoLayer.max(BinningValue::binZ) - + protoLayer.min(BinningValue::binZ)); + layerThickness = (protoLayer.max(BinningValue::binY) - + protoLayer.min(BinningValue::binY)); break; } case BinningValue::binZ: { - layerHalf1 = 0.5 * (protoLayer.max(binX) - protoLayer.min(binX)); - layerHalf2 = 0.5 * (protoLayer.max(binY) - protoLayer.min(binY)); - layerThickness = (protoLayer.max(binZ) - protoLayer.min(binZ)); + layerHalf1 = 0.5 * (protoLayer.max(BinningValue::binX) - + protoLayer.min(BinningValue::binX)); + layerHalf2 = 0.5 * (protoLayer.max(BinningValue::binY) - + protoLayer.min(BinningValue::binY)); + layerThickness = (protoLayer.max(BinningValue::binZ) - + protoLayer.min(BinningValue::binZ)); break; } default: throw std::invalid_argument("Invalid binning value"); } - double centerX = 0.5 * (protoLayer.max(binX) + protoLayer.min(binX)); - double centerY = 0.5 * (protoLayer.max(binY) + protoLayer.min(binY)); - double centerZ = 0.5 * (protoLayer.max(binZ) + protoLayer.min(binZ)); + double centerX = 0.5 * (protoLayer.max(BinningValue::binX) + + protoLayer.min(BinningValue::binX)); + double centerY = 0.5 * (protoLayer.max(BinningValue::binY) + + protoLayer.min(BinningValue::binY)); + double centerZ = 0.5 * (protoLayer.max(BinningValue::binZ) + + protoLayer.min(BinningValue::binZ)); ACTS_VERBOSE("Creating a plane Layer:"); ACTS_VERBOSE(" - with layer center = " << "(" << centerX << ", " << centerY << ", " << centerZ << ")"); - ACTS_VERBOSE(" - from X min/max = " << protoLayer.min(binX) << " / " - << protoLayer.max(binX)); - ACTS_VERBOSE(" - from Y min/max = " << protoLayer.min(binY) << " / " - << protoLayer.max(binY)); + ACTS_VERBOSE(" - from X min/max = " << protoLayer.min(BinningValue::binX) + << " / " + << protoLayer.max(BinningValue::binX)); + ACTS_VERBOSE(" - from Y min/max = " << protoLayer.min(BinningValue::binY) + << " / " + << protoLayer.max(BinningValue::binY)); ACTS_VERBOSE(" - with Z thickness = " << layerThickness); ACTS_VERBOSE(" - incl envelope = " << protoLayer.envelope[bValue][0u] << " / " @@ -473,7 +491,7 @@ bool Acts::LayerCreator::checkBinning(const GeometryContext& gctx, ACTS_ERROR(" -- Inaccessible surfaces: "); for (const auto& srf : diff) { // have to choose BinningValue here - Vector3 ctr = srf->binningPosition(gctx, binR); + Vector3 ctr = srf->binningPosition(gctx, BinningValue::binR); ACTS_ERROR(" Surface(x=" << ctr.x() << ", y=" << ctr.y() << ", z=" << ctr.z() << ", r=" << perp(ctr) << ", phi=" << phi(ctr) << ")"); diff --git a/Core/src/Geometry/Polyhedron.cpp b/Core/src/Geometry/Polyhedron.cpp index c2af9153349..6663a49705a 100644 --- a/Core/src/Geometry/Polyhedron.cpp +++ b/Core/src/Geometry/Polyhedron.cpp @@ -48,10 +48,11 @@ Acts::Extent Acts::Polyhedron::extent(const Transform3& transform) const { return (vt); }); - // Special checks of binR for hyper plane surfaces + // Special checks of BinningValue::binR for hyper plane surfaces if (detail::VerticesHelper::onHyperPlane(vtxs)) { // Check inclusion of origin (i.e. convex around origin) - Vector3 origin = transform * Vector3(0., 0., extent.medium(binZ)); + Vector3 origin = + transform * Vector3(0., 0., extent.medium(BinningValue::binZ)); for (const auto& face : faces) { std::vector tface; tface.reserve(face.size()); @@ -59,8 +60,8 @@ Acts::Extent Acts::Polyhedron::extent(const Transform3& transform) const { tface.push_back(vtxs[f]); } if (detail::VerticesHelper::isInsidePolygon(origin, tface)) { - extent.range(binR).setMin(0.); - extent.range(binPhi).set(-M_PI, M_PI); + extent.range(BinningValue::binR).setMin(0.); + extent.range(BinningValue::binPhi).set(-M_PI, M_PI); break; } } @@ -89,7 +90,7 @@ Acts::Extent Acts::Polyhedron::extent(const Transform3& transform) const { for (std::size_t iv = 1; iv < vtxs.size() + 1; ++iv) { std::size_t fpoint = iv < vtxs.size() ? iv : 0; double testR = radialDistance(vtxs[fpoint], vtxs[iv - 1]); - extent.range(binR).expandMin(testR); + extent.range(BinningValue::binR).expandMin(testR); } } } diff --git a/Core/src/Geometry/ProtoLayerHelper.cpp b/Core/src/Geometry/ProtoLayerHelper.cpp index 2e3e64f8476..9d00aea6369 100644 --- a/Core/src/Geometry/ProtoLayerHelper.cpp +++ b/Core/src/Geometry/ProtoLayerHelper.cpp @@ -66,7 +66,7 @@ std::vector Acts::ProtoLayerHelper::protoLayers( std::vector> sortSurfaces = {surfaces}; for (const auto& sorting : sortings) { ACTS_VERBOSE("-> Sorting a set of " << sortSurfaces.size() << " in " - << binningValueNames()[sorting.first]); + << binningValueName(sorting.first)); std::vector> subSurfaces; for (const auto& ssurfaces : sortSurfaces) { ACTS_VERBOSE("-> Surfaces for this sorting step: " << ssurfaces.size()); diff --git a/Core/src/Geometry/SurfaceArrayCreator.cpp b/Core/src/Geometry/SurfaceArrayCreator.cpp index 80e223fa895..c01a4473b4f 100644 --- a/Core/src/Geometry/SurfaceArrayCreator.cpp +++ b/Core/src/Geometry/SurfaceArrayCreator.cpp @@ -43,12 +43,12 @@ Acts::SurfaceArrayCreator::surfaceArrayOnCylinder( << binsPhi * binsZ << " bins."); Transform3 ftransform = transform; - ProtoAxis pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, binPhi, - protoLayer, ftransform, binsPhi); - ProtoAxis pAxisZ = createEquidistantAxis(gctx, surfacesRaw, binZ, protoLayer, - ftransform, binsZ); + ProtoAxis pAxisPhi = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binPhi, protoLayer, ftransform, binsPhi); + ProtoAxis pAxisZ = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binZ, protoLayer, ftransform, binsZ); - double R = protoLayer.medium(binR, true); + double R = protoLayer.medium(BinningValue::binR, true); Transform3 itransform = ftransform.inverse(); // Transform lambda captures the transform matrix @@ -84,7 +84,7 @@ Acts::SurfaceArrayCreator::surfaceArrayOnCylinder( ProtoLayer protoLayer = protoLayerOpt ? *protoLayerOpt : ProtoLayer(gctx, surfacesRaw); - double R = protoLayer.medium(binR, true); + double R = protoLayer.medium(BinningValue::binR, true); ProtoAxis pAxisPhi; ProtoAxis pAxisZ; @@ -92,19 +92,19 @@ Acts::SurfaceArrayCreator::surfaceArrayOnCylinder( Transform3 ftransform = transform; if (bTypePhi == equidistant) { - pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, binPhi, protoLayer, - ftransform, 0); + pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, BinningValue::binPhi, + protoLayer, ftransform, 0); } else { - pAxisPhi = - createVariableAxis(gctx, surfacesRaw, binPhi, protoLayer, ftransform); + pAxisPhi = createVariableAxis(gctx, surfacesRaw, BinningValue::binPhi, + protoLayer, ftransform); } if (bTypeZ == equidistant) { - pAxisZ = - createEquidistantAxis(gctx, surfacesRaw, binZ, protoLayer, ftransform); + pAxisZ = createEquidistantAxis(gctx, surfacesRaw, BinningValue::binZ, + protoLayer, ftransform); } else { - pAxisZ = - createVariableAxis(gctx, surfacesRaw, binZ, protoLayer, ftransform); + pAxisZ = createVariableAxis(gctx, surfacesRaw, BinningValue::binZ, + protoLayer, ftransform); } Transform3 itransform = ftransform.inverse(); @@ -153,12 +153,12 @@ Acts::SurfaceArrayCreator::surfaceArrayOnDisc( ACTS_VERBOSE("Creating a SurfaceArray on a disc"); Transform3 ftransform = transform; - ProtoAxis pAxisR = createEquidistantAxis(gctx, surfacesRaw, binR, protoLayer, - ftransform, binsR); - ProtoAxis pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, binPhi, - protoLayer, ftransform, binsPhi); + ProtoAxis pAxisR = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binR, protoLayer, ftransform, binsR); + ProtoAxis pAxisPhi = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binPhi, protoLayer, ftransform, binsPhi); - double Z = protoLayer.medium(binZ, true); + double Z = protoLayer.medium(BinningValue::binZ, true); ACTS_VERBOSE("- z-position of disk estimated as " << Z); Transform3 itransform = transform.inverse(); @@ -211,11 +211,11 @@ Acts::SurfaceArrayCreator::surfaceArrayOnDisc( Transform3 ftransform = transform; if (bTypeR == equidistant) { - pAxisR = - createEquidistantAxis(gctx, surfacesRaw, binR, protoLayer, ftransform); + pAxisR = createEquidistantAxis(gctx, surfacesRaw, BinningValue::binR, + protoLayer, ftransform); } else { - pAxisR = - createVariableAxis(gctx, surfacesRaw, binR, protoLayer, ftransform); + pAxisR = createVariableAxis(gctx, surfacesRaw, BinningValue::binR, + protoLayer, ftransform); } // if we have more than one R ring, we need to figure out @@ -225,7 +225,7 @@ Acts::SurfaceArrayCreator::surfaceArrayOnDisc( // this FORCES equidistant binning std::vector> phiModules(pAxisR.nBins); for (const auto& srf : surfacesRaw) { - Vector3 bpos = srf->binningPosition(gctx, binR); + Vector3 bpos = srf->binningPosition(gctx, BinningValue::binR); std::size_t bin = pAxisR.getBin(perp(bpos)); phiModules.at(bin).push_back(srf); } @@ -233,7 +233,7 @@ Acts::SurfaceArrayCreator::surfaceArrayOnDisc( std::vector nPhiModules; auto matcher = m_cfg.surfaceMatcher; auto equal = [&gctx, &matcher](const Surface* a, const Surface* b) { - return matcher(gctx, binPhi, a, b); + return matcher(gctx, BinningValue::binPhi, a, b); }; std::transform( @@ -251,21 +251,21 @@ Acts::SurfaceArrayCreator::surfaceArrayOnDisc( // @TODO: check in extrapolation std::size_t nBinsPhi = (*std::min_element(nPhiModules.begin(), nPhiModules.end())); - pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, binPhi, protoLayer, - ftransform, nBinsPhi); + pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, BinningValue::binPhi, + protoLayer, ftransform, nBinsPhi); } else { // use regular determination if (bTypePhi == equidistant) { - pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, binPhi, protoLayer, - ftransform, 0); + pAxisPhi = createEquidistantAxis(gctx, surfacesRaw, BinningValue::binPhi, + protoLayer, ftransform, 0); } else { - pAxisPhi = - createVariableAxis(gctx, surfacesRaw, binPhi, protoLayer, ftransform); + pAxisPhi = createVariableAxis(gctx, surfacesRaw, BinningValue::binPhi, + protoLayer, ftransform); } } - double Z = protoLayer.medium(binZ, true); + double Z = protoLayer.medium(BinningValue::binZ, true); ACTS_VERBOSE("- z-position of disk estimated as " << Z); Transform3 itransform = ftransform.inverse(); @@ -333,30 +333,30 @@ Acts::SurfaceArrayCreator::surfaceArrayOnPlane( // Axis along the binning switch (bValue) { case BinningValue::binX: { - ProtoAxis pAxis1 = createEquidistantAxis(gctx, surfacesRaw, binY, - protoLayer, ftransform, bins1); - ProtoAxis pAxis2 = createEquidistantAxis(gctx, surfacesRaw, binZ, - protoLayer, ftransform, bins2); + ProtoAxis pAxis1 = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binY, protoLayer, ftransform, bins1); + ProtoAxis pAxis2 = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binZ, protoLayer, ftransform, bins2); sl = makeSurfaceGridLookup2D( globalToLocal, localToGlobal, pAxis1, pAxis2); break; } case BinningValue::binY: { - ProtoAxis pAxis1 = createEquidistantAxis(gctx, surfacesRaw, binX, - protoLayer, ftransform, bins1); - ProtoAxis pAxis2 = createEquidistantAxis(gctx, surfacesRaw, binZ, - protoLayer, ftransform, bins2); + ProtoAxis pAxis1 = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binX, protoLayer, ftransform, bins1); + ProtoAxis pAxis2 = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binZ, protoLayer, ftransform, bins2); sl = makeSurfaceGridLookup2D( globalToLocal, localToGlobal, pAxis1, pAxis2); break; } case BinningValue::binZ: { - ProtoAxis pAxis1 = createEquidistantAxis(gctx, surfacesRaw, binX, - protoLayer, ftransform, bins1); - ProtoAxis pAxis2 = createEquidistantAxis(gctx, surfacesRaw, binY, - protoLayer, ftransform, bins2); + ProtoAxis pAxis1 = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binX, protoLayer, ftransform, bins1); + ProtoAxis pAxis2 = createEquidistantAxis( + gctx, surfacesRaw, BinningValue::binY, protoLayer, ftransform, bins2); sl = makeSurfaceGridLookup2D( globalToLocal, localToGlobal, pAxis1, pAxis2); @@ -431,15 +431,17 @@ Acts::SurfaceArrayCreator::createVariableAxis( std::vector keys = findKeySurfaces(surfaces, equal); std::vector bValues; - if (bValue == Acts::binPhi) { - std::stable_sort(keys.begin(), keys.end(), - [&gctx](const Acts::Surface* a, const Acts::Surface* b) { - return (phi(a->binningPosition(gctx, binPhi)) < - phi(b->binningPosition(gctx, binPhi))); - }); + if (bValue == Acts::BinningValue::binPhi) { + std::stable_sort( + keys.begin(), keys.end(), + [&gctx](const Acts::Surface* a, const Acts::Surface* b) { + return (phi(a->binningPosition(gctx, BinningValue::binPhi)) < + phi(b->binningPosition(gctx, BinningValue::binPhi))); + }); - AxisScalar maxPhi = 0.5 * (phi(keys.at(0)->binningPosition(gctx, binPhi)) + - phi(keys.at(1)->binningPosition(gctx, binPhi))); + AxisScalar maxPhi = + 0.5 * (phi(keys.at(0)->binningPosition(gctx, BinningValue::binPhi)) + + phi(keys.at(1)->binningPosition(gctx, BinningValue::binPhi))); // create rotation, so that maxPhi is +pi AxisScalar angle = -(M_PI + maxPhi); @@ -448,18 +450,19 @@ Acts::SurfaceArrayCreator::createVariableAxis( // iterate over all key surfaces, and use their mean position as bValues, // but // rotate using transform from before - AxisScalar previous = phi(keys.at(0)->binningPosition(gctx, binPhi)); + AxisScalar previous = + phi(keys.at(0)->binningPosition(gctx, BinningValue::binPhi)); // go through key surfaces for (std::size_t i = 1; i < keys.size(); i++) { const Surface* surface = keys.at(i); // create central binning values which is the mean of the center // positions in the binning direction of the current and previous // surface - AxisScalar edge = - 0.5 * (previous + phi(surface->binningPosition(gctx, binPhi))) + - angle; + AxisScalar edge = 0.5 * (previous + phi(surface->binningPosition( + gctx, BinningValue::binPhi))) + + angle; bValues.push_back(edge); - previous = phi(surface->binningPosition(gctx, binPhi)); + previous = phi(surface->binningPosition(gctx, BinningValue::binPhi)); } // segments @@ -487,56 +490,58 @@ Acts::SurfaceArrayCreator::createVariableAxis( bValues.push_back(M_PI); - } else if (bValue == Acts::binZ) { - std::stable_sort(keys.begin(), keys.end(), - [&gctx](const Acts::Surface* a, const Acts::Surface* b) { - return (a->binningPosition(gctx, binZ).z() < - b->binningPosition(gctx, binZ).z()); - }); + } else if (bValue == Acts::BinningValue::binZ) { + std::stable_sort( + keys.begin(), keys.end(), + [&gctx](const Acts::Surface* a, const Acts::Surface* b) { + return (a->binningPosition(gctx, BinningValue::binZ).z() < + b->binningPosition(gctx, BinningValue::binZ).z()); + }); - bValues.push_back(protoLayer.min(binZ)); - bValues.push_back(protoLayer.max(binZ)); + bValues.push_back(protoLayer.min(BinningValue::binZ)); + bValues.push_back(protoLayer.max(BinningValue::binZ)); // the z-center position of the previous surface - AxisScalar previous = keys.front()->binningPosition(gctx, binZ).z(); + AxisScalar previous = + keys.front()->binningPosition(gctx, BinningValue::binZ).z(); // go through key surfaces for (auto surface = keys.begin() + 1; surface != keys.end(); surface++) { // create central binning values which is the mean of the center // positions in the binning direction of the current and previous // surface bValues.push_back( - 0.5 * (previous + (*surface)->binningPosition(gctx, binZ).z())); - previous = (*surface)->binningPosition(gctx, binZ).z(); + 0.5 * (previous + + (*surface)->binningPosition(gctx, BinningValue::binZ).z())); + previous = (*surface)->binningPosition(gctx, BinningValue::binZ).z(); } - } else { // binR - std::stable_sort(keys.begin(), keys.end(), - [&gctx](const Acts::Surface* a, const Acts::Surface* b) { - return (perp(a->binningPosition(gctx, binR)) < - perp(b->binningPosition(gctx, binR))); - }); + } else { // BinningValue::binR + std::stable_sort( + keys.begin(), keys.end(), + [&gctx](const Acts::Surface* a, const Acts::Surface* b) { + return (perp(a->binningPosition(gctx, BinningValue::binR)) < + perp(b->binningPosition(gctx, BinningValue::binR))); + }); - bValues.push_back(protoLayer.min(binR)); - bValues.push_back(protoLayer.max(binR)); + bValues.push_back(protoLayer.min(BinningValue::binR)); + bValues.push_back(protoLayer.max(BinningValue::binR)); // the r-center position of the previous surface - AxisScalar previous = perp(keys.front()->binningPosition(gctx, binR)); + AxisScalar previous = + perp(keys.front()->binningPosition(gctx, BinningValue::binR)); // go through key surfaces for (auto surface = keys.begin() + 1; surface != keys.end(); surface++) { // create central binning values which is the mean of the center // positions in the binning direction of the current and previous // surface - bValues.push_back( - 0.5 * (previous + perp((*surface)->binningPosition(gctx, binR)))); - previous = perp((*surface)->binningPosition(gctx, binR)); + bValues.push_back(0.5 * (previous + perp((*surface)->binningPosition( + gctx, BinningValue::binR)))); + previous = perp((*surface)->binningPosition(gctx, BinningValue::binR)); } } std::sort(bValues.begin(), bValues.end()); ACTS_VERBOSE("Create variable binning Axis for binned SurfaceArray"); ACTS_VERBOSE(" BinningValue: " << bValue); - ACTS_VERBOSE( - " (binX = 0, binY = 1, binZ = 2, binR = 3, binPhi = 4, " - "binRPhi = 5, binH = 6, binEta = 7)"); ACTS_VERBOSE(" Number of bins: " << (bValues.size() - 1)); ACTS_VERBOSE(" (Min/Max) = (" << bValues.front() << "/" << bValues.back() << ")"); @@ -584,7 +589,7 @@ Acts::SurfaceArrayCreator::createEquidistantAxis( auto matcher = m_cfg.surfaceMatcher; // now check the binning value - if (bValue == binPhi) { + if (bValue == BinningValue::binPhi) { if (m_cfg.doPhiBinningOptimization) { // Phi binning // set the binning option for phi @@ -592,8 +597,8 @@ Acts::SurfaceArrayCreator::createEquidistantAxis( const Acts::Surface* maxElem = *std::max_element( surfaces.begin(), surfaces.end(), [&gctx](const Acts::Surface* a, const Acts::Surface* b) { - return phi(a->binningPosition(gctx, binR)) < - phi(b->binningPosition(gctx, binR)); + return phi(a->binningPosition(gctx, BinningValue::binR)) < + phi(b->binningPosition(gctx, BinningValue::binR)); }); // get the key surfaces at the different phi positions @@ -615,15 +620,15 @@ Acts::SurfaceArrayCreator::createEquidistantAxis( // rotate to max phi module plus one half step // this should make sure that phi wrapping at +- pi // never falls on a module center - double max = phi(maxElem->binningPosition(gctx, binR)); + double max = phi(maxElem->binningPosition(gctx, BinningValue::binR)); double angle = M_PI - (max + 0.5 * step); // replace given transform ref transform = (transform)*AngleAxis3(angle, Vector3::UnitZ()); } else { - minimum = protoLayer.min(binPhi, true); - maximum = protoLayer.max(binPhi, true); + minimum = protoLayer.min(BinningValue::binPhi, true); + maximum = protoLayer.max(BinningValue::binPhi, true); // we do not need a transform in this case } } else { @@ -638,9 +643,6 @@ Acts::SurfaceArrayCreator::createEquidistantAxis( // assign the bin size ACTS_VERBOSE("Create equidistant binning Axis for binned SurfaceArray"); ACTS_VERBOSE(" BinningValue: " << bValue); - ACTS_VERBOSE( - " (binX = 0, binY = 1, binZ = 2, binR = 3, binPhi = 4, " - "binRPhi = 5, binH = 6, binEta = 7)"); ACTS_VERBOSE(" Number of bins: " << binNumber); ACTS_VERBOSE(" (Min/Max) = (" << minimum << "/" << maximum << ")"); diff --git a/Core/src/Geometry/TrackingVolume.cpp b/Core/src/Geometry/TrackingVolume.cpp index 5065034185b..1c2fd682e9e 100644 --- a/Core/src/Geometry/TrackingVolume.cpp +++ b/Core/src/Geometry/TrackingVolume.cpp @@ -153,10 +153,11 @@ void TrackingVolume::glueTrackingVolume(const GeometryContext& gctx, BoundarySurfaceFace bsfMine, TrackingVolume* neighbor, BoundarySurfaceFace bsfNeighbor) { - // Find the connection of the two tracking volumes: binR returns the center - // except for cylindrical volumes - Vector3 bPosition(binningPosition(gctx, binR)); - Vector3 distance = Vector3(neighbor->binningPosition(gctx, binR) - bPosition); + // Find the connection of the two tracking volumes: BinningValue::binR returns + // the center except for cylindrical volumes + Vector3 bPosition(binningPosition(gctx, BinningValue::binR)); + Vector3 distance = + Vector3(neighbor->binningPosition(gctx, BinningValue::binR) - bPosition); // glue to the face std::shared_ptr> bSurfaceMine = boundarySurfaces().at(bsfMine); @@ -196,14 +197,14 @@ void TrackingVolume::glueTrackingVolumes( const GeometryContext& gctx, BoundarySurfaceFace bsfMine, const std::shared_ptr& neighbors, BoundarySurfaceFace bsfNeighbor) { - // find the connection of the two tracking volumes : binR returns the center - // except for cylindrical volumes + // find the connection of the two tracking volumes : BinningValue::binR + // returns the center except for cylindrical volumes std::shared_ptr nRefVolume = neighbors->arrayObjects().at(0); // get the distance - Vector3 bPosition(binningPosition(gctx, binR)); - Vector3 distance = - Vector3(nRefVolume->binningPosition(gctx, binR) - bPosition); + Vector3 bPosition(binningPosition(gctx, BinningValue::binR)); + Vector3 distance = Vector3( + nRefVolume->binningPosition(gctx, BinningValue::binR) - bPosition); // take the normal at the binning positio std::shared_ptr> bSurfaceMine = boundarySurfaces().at(bsfMine); diff --git a/Core/src/Geometry/TrackingVolumeArrayCreator.cpp b/Core/src/Geometry/TrackingVolumeArrayCreator.cpp index 6de559c88c1..15ca130289a 100644 --- a/Core/src/Geometry/TrackingVolumeArrayCreator.cpp +++ b/Core/src/Geometry/TrackingVolumeArrayCreator.cpp @@ -23,7 +23,7 @@ Acts::TrackingVolumeArrayCreator::trackingVolumeArray( const GeometryContext& gctx, const TrackingVolumeVector& tVolumes, BinningValue bValue) const { // MSG_VERBOSE("Create VolumeArray of "<< tVolumes.size() << " TrackingVolumes - // with binning in : " << binningValueNames()[bValue] ); + // with binning in : " << binningValueName(bValue) ); // let's copy and sort TrackingVolumeVector volumes(tVolumes); // sort it accordingly to the binning value diff --git a/Core/src/Geometry/Volume.cpp b/Core/src/Geometry/Volume.cpp index a69154624b5..79dcf5598dc 100644 --- a/Core/src/Geometry/Volume.cpp +++ b/Core/src/Geometry/Volume.cpp @@ -37,7 +37,7 @@ Vector3 Volume::binningPosition(const GeometryContext& /*gctx*/, BinningValue bValue) const { // for most of the binning types it is actually the center, // just for R-binning types the - if (bValue == binR || bValue == binRPhi) { + if (bValue == BinningValue::binR || bValue == BinningValue::binRPhi) { // the binning Position for R-type may have an offset return (center() + m_volumeBounds->binningOffset(bValue)); } diff --git a/Core/src/Material/BinnedSurfaceMaterialAccumulater.cpp b/Core/src/Material/BinnedSurfaceMaterialAccumulater.cpp index 88329c4bd28..60620bce24e 100644 --- a/Core/src/Material/BinnedSurfaceMaterialAccumulater.cpp +++ b/Core/src/Material/BinnedSurfaceMaterialAccumulater.cpp @@ -126,7 +126,8 @@ void Acts::BinnedSurfaceMaterialAccumulater::accumulate( // Empty bin correction if (m_cfg.emptyBinCorrection) { - for (auto [surface, position, direction] : surfacesWithoutAssignment) { + for (const auto& [surface, position, direction] : + surfacesWithoutAssignment) { // Get the accumulated material auto missedMaterial = cState->accumulatedMaterial.find(surface->geometryId()); diff --git a/Core/src/Material/MaterialGridHelper.cpp b/Core/src/Material/MaterialGridHelper.cpp index a348169bda6..23792f3bd7f 100644 --- a/Core/src/Material/MaterialGridHelper.cpp +++ b/Core/src/Material/MaterialGridHelper.cpp @@ -88,41 +88,40 @@ std::function Acts::globalToLocalFromBin( std::function transfoGlobalToLocal; switch (type) { - case Acts::binX: + case Acts::BinningValue::binX: transfoGlobalToLocal = [](const Acts::Vector3& pos) -> double { return (pos.x()); }; break; - case Acts::binY: + case Acts::BinningValue::binY: transfoGlobalToLocal = [](const Acts::Vector3& pos) -> double { return (pos.y()); }; break; - case Acts::binR: + case Acts::BinningValue::binR: transfoGlobalToLocal = [](const Acts::Vector3& pos) -> double { return (Acts::VectorHelpers::perp(pos)); }; break; - case Acts::binPhi: + case Acts::BinningValue::binPhi: transfoGlobalToLocal = [](const Acts::Vector3& pos) -> double { return (Acts::VectorHelpers::phi(pos)); }; break; - case Acts::binZ: + case Acts::BinningValue::binZ: transfoGlobalToLocal = [](const Acts::Vector3& pos) -> double { return (pos.z()); }; break; - // case Acts::binRPhi: - // case Acts::binEta: - // case Acts::binH: - // case Acts::binMag: - // case Acts::binValues: + // case Acts::BinningValue::binRPhi: + // case Acts::BinningValue::binEta: + // case Acts::BinningValue::binH: + // case Acts::BinningValue::binMag: default: throw std::invalid_argument("Incorrect bin, should be x,y,z,r,phi"); } @@ -138,10 +137,12 @@ Acts::Grid2D Acts::createGrid2D( bool isCylindrical = false; for (std::size_t b = 0; b < bu.size(); b++) { - if (bu[b].binvalue == Acts::binX || bu[b].binvalue == Acts::binY) { + if (bu[b].binvalue == Acts::BinningValue::binX || + bu[b].binvalue == Acts::BinningValue::binY) { isCartesian = true; } - if (bu[b].binvalue == Acts::binR || bu[b].binvalue == Acts::binPhi) { + if (bu[b].binvalue == Acts::BinningValue::binR || + bu[b].binvalue == Acts::BinningValue::binPhi) { isCylindrical = true; } } @@ -176,10 +177,12 @@ Acts::Grid3D Acts::createGrid3D( bool isCylindrical = false; for (std::size_t b = 0; b < bu.size(); b++) { - if (bu[b].binvalue == Acts::binX || bu[b].binvalue == Acts::binY) { + if (bu[b].binvalue == Acts::BinningValue::binX || + bu[b].binvalue == Acts::BinningValue::binY) { isCartesian = true; } - if (bu[b].binvalue == Acts::binR || bu[b].binvalue == Acts::binPhi) { + if (bu[b].binvalue == Acts::BinningValue::binR || + bu[b].binvalue == Acts::BinningValue::binPhi) { isCylindrical = true; } } diff --git a/Core/src/Material/MaterialValidater.cpp b/Core/src/Material/MaterialValidater.cpp index d1fc6078805..04ef21de1ae 100644 --- a/Core/src/Material/MaterialValidater.cpp +++ b/Core/src/Material/MaterialValidater.cpp @@ -34,7 +34,7 @@ Acts::RecordedMaterialTrack Acts::MaterialValidater::recordMaterial( m_cfg.materialAssigner->assignmentCandidates(gctx, mctx, position, direction); - for (auto [surface, sposition, sdirection] : surfaceAssignments) { + for (const auto& [surface, sposition, sdirection] : surfaceAssignments) { // The slab and the path correction auto materialSlab = surface->surfaceMaterial()->materialSlab(sposition); auto pathCorrection = surface->pathCorrection(gctx, sposition, sdirection); diff --git a/Core/src/Surfaces/ConeSurface.cpp b/Core/src/Surfaces/ConeSurface.cpp index 71a94aff0eb..3ee3feeb58e 100644 --- a/Core/src/Surfaces/ConeSurface.cpp +++ b/Core/src/Surfaces/ConeSurface.cpp @@ -64,12 +64,15 @@ Acts::Vector3 Acts::ConeSurface::binningPosition( const Vector3& sfCenter = center(gctx); // special binning type for R-type methods - if (bValue == Acts::binR || bValue == Acts::binRPhi) { + if (bValue == Acts::BinningValue::binR || + bValue == Acts::BinningValue::binRPhi) { return Vector3(sfCenter.x() + bounds().r(sfCenter.z()), sfCenter.y(), sfCenter.z()); } // give the center as default for all of these binning types - // binX, binY, binZ, binR, binPhi, binRPhi, binH, binEta + // BinningValue::binX, BinningValue::binY, BinningValue::binZ, + // BinningValue::binR, BinningValue::binPhi, BinningValue::binRPhi, + // BinningValue::binH, BinningValue::binEta return sfCenter; } diff --git a/Core/src/Surfaces/CylinderSurface.cpp b/Core/src/Surfaces/CylinderSurface.cpp index b044fb9bec1..b04bb2fca58 100644 --- a/Core/src/Surfaces/CylinderSurface.cpp +++ b/Core/src/Surfaces/CylinderSurface.cpp @@ -85,13 +85,16 @@ Acts::CylinderSurface& Acts::CylinderSurface::operator=( Acts::Vector3 Acts::CylinderSurface::binningPosition( const GeometryContext& gctx, BinningValue bValue) const { // special binning type for R-type methods - if (bValue == Acts::binR || bValue == Acts::binRPhi) { + if (bValue == Acts::BinningValue::binR || + bValue == Acts::BinningValue::binRPhi) { double R = bounds().get(CylinderBounds::eR); double phi = bounds().get(CylinderBounds::eAveragePhi); return localToGlobal(gctx, Vector2{phi * R, 0}, Vector3{}); } // give the center as default for all of these binning types - // binX, binY, binZ, binR, binPhi, binRPhi, binH, binEta + // BinningValue::binX, BinningValue::binY, BinningValue::binZ, + // BinningValue::binR, BinningValue::binPhi, BinningValue::binRPhi, + // BinningValue::binH, BinningValue::binEta return center(gctx); } @@ -370,7 +373,7 @@ std::shared_ptr Acts::CylinderSurface::mergedWith( BinningValue direction, const Logger& logger) const { using namespace Acts::UnitLiterals; - ACTS_DEBUG("Merging cylinder surfaces in " << binningValueNames()[direction] + ACTS_DEBUG("Merging cylinder surfaces in " << binningValueName(direction) << " direction"); Transform3 otherLocal = transform(gctx).inverse() * other.transform(gctx); @@ -433,7 +436,7 @@ std::shared_ptr Acts::CylinderSurface::mergedWith( "CylinderSurface::merge: surfaces have relative translation in x/y"); } - if (direction == Acts::binZ) { + if (direction == Acts::BinningValue::binZ) { // z shift must match the bounds ActsScalar hlZ = bounds().get(CylinderBounds::eHalfLengthZ); @@ -475,7 +478,7 @@ std::shared_ptr Acts::CylinderSurface::mergedWith( return Surface::makeShared(newTransform, newBounds); - } else if (direction == Acts::binRPhi) { + } else if (direction == Acts::BinningValue::binRPhi) { // no z shift is allowed if (std::abs(translation[2]) > tolerance) { ACTS_ERROR( @@ -508,6 +511,6 @@ std::shared_ptr Acts::CylinderSurface::mergedWith( } else { throw SurfaceMergingException(getSharedPtr(), other.getSharedPtr(), "CylinderSurface::merge: invalid direction " + - binningValueNames()[direction]); + binningValueName(direction)); } } diff --git a/Core/src/Surfaces/DiscSurface.cpp b/Core/src/Surfaces/DiscSurface.cpp index bc0543887f0..384d1cf5e08 100644 --- a/Core/src/Surfaces/DiscSurface.cpp +++ b/Core/src/Surfaces/DiscSurface.cpp @@ -351,7 +351,7 @@ Acts::Vector3 Acts::DiscSurface::normal(const GeometryContext& gctx) const { Acts::Vector3 Acts::DiscSurface::binningPosition(const GeometryContext& gctx, BinningValue bValue) const { - if (bValue == binR || bValue == binPhi) { + if (bValue == BinningValue::binR || bValue == BinningValue::binPhi) { double r = m_bounds->binningValueR(); double phi = m_bounds->binningValuePhi(); return localToGlobal(gctx, Vector2{r, phi}, Vector3{}); @@ -361,10 +361,10 @@ Acts::Vector3 Acts::DiscSurface::binningPosition(const GeometryContext& gctx, double Acts::DiscSurface::binningPositionValue(const GeometryContext& gctx, BinningValue bValue) const { - if (bValue == binR) { + if (bValue == BinningValue::binR) { return VectorHelpers::perp(binningPosition(gctx, bValue)); } - if (bValue == binPhi) { + if (bValue == BinningValue::binPhi) { return VectorHelpers::phi(binningPosition(gctx, bValue)); } @@ -383,7 +383,7 @@ std::shared_ptr Acts::DiscSurface::mergedWith( BinningValue direction, const Logger& logger) const { using namespace Acts::UnitLiterals; - ACTS_DEBUG("Merging disc surfaces in " << binningValueNames()[direction] + ACTS_DEBUG("Merging disc surfaces in " << binningValueName(direction) << " direction"); Transform3 otherLocal = transform(gctx).inverse() * other.transform(gctx); @@ -447,7 +447,7 @@ std::shared_ptr Acts::DiscSurface::mergedWith( << otherAvgPhi / 1_degree << " +- " << otherHlPhi / 1_degree); - if (direction == Acts::binR) { + if (direction == Acts::BinningValue::binR) { if (std::abs(minR - otherMaxR) > tolerance && std::abs(maxR - otherMinR) > tolerance) { ACTS_ERROR("DiscSurface::merge: surfaces are not touching r"); @@ -479,7 +479,7 @@ std::shared_ptr Acts::DiscSurface::mergedWith( return Surface::makeShared(transform(gctx), newBounds); - } else if (direction == Acts::binPhi) { + } else if (direction == Acts::BinningValue::binPhi) { if (std::abs(maxR - otherMaxR) > tolerance || std::abs(minR - otherMinR) > tolerance) { ACTS_ERROR("DiscSurface::merge: surfaces don't have same r bounds"); @@ -503,10 +503,9 @@ std::shared_ptr Acts::DiscSurface::mergedWith( } else { ACTS_ERROR("DiscSurface::merge: invalid direction " - << binningValueNames()[direction]); - - throw SurfaceMergingException(getSharedPtr(), other.getSharedPtr(), - "DiscSurface::merge: invalid direction " + - binningValueNames()[direction]); + << binningValueName(direction)); + throw SurfaceMergingException( + getSharedPtr(), other.getSharedPtr(), + "DiscSurface::merge: invalid direction " + binningValueName(direction)); } } diff --git a/Core/src/Surfaces/PerigeeSurface.cpp b/Core/src/Surfaces/PerigeeSurface.cpp index f5b6678898d..cfa85858fe2 100644 --- a/Core/src/Surfaces/PerigeeSurface.cpp +++ b/Core/src/Surfaces/PerigeeSurface.cpp @@ -45,8 +45,8 @@ std::string Acts::PerigeeSurface::name() const { return "Acts::PerigeeSurface"; } -std::ostream& Acts::PerigeeSurface::toStream(const GeometryContext& gctx, - std::ostream& sl) const { +std::ostream& Acts::PerigeeSurface::toStreamImpl(const GeometryContext& gctx, + std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(7); sl << "Acts::PerigeeSurface:" << std::endl; diff --git a/Core/src/Surfaces/PlaneSurface.cpp b/Core/src/Surfaces/PlaneSurface.cpp index d378694c67c..a43bd92efea 100644 --- a/Core/src/Surfaces/PlaneSurface.cpp +++ b/Core/src/Surfaces/PlaneSurface.cpp @@ -38,7 +38,8 @@ Acts::PlaneSurface::PlaneSurface(const GeometryContext& gctx, Acts::PlaneSurface::PlaneSurface(const Vector3& center, const Vector3& normal) : RegularSurface(), m_bounds(nullptr) { - m_transform = CurvilinearSurface(center, normal).transform(); + m_transform = std::make_unique( + CurvilinearSurface(center, normal).transform()); } Acts::PlaneSurface::PlaneSurface(std::shared_ptr pbounds, diff --git a/Core/src/Surfaces/Surface.cpp b/Core/src/Surfaces/Surface.cpp index 9bbf4b82283..f20294966e7 100644 --- a/Core/src/Surfaces/Surface.cpp +++ b/Core/src/Surfaces/Surface.cpp @@ -22,7 +22,7 @@ std::array "Cone", "Cylinder", "Disc", "Perigee", "Plane", "Straw", "Curvilinear"}; Acts::Surface::Surface(const Transform3& transform) - : GeometryObject(), m_transform(transform) {} + : GeometryObject(), m_transform(std::make_unique(transform)) {} Acts::Surface::Surface(const DetectorElementBase& detelement) : GeometryObject(), m_associatedDetElement(&detelement) {} @@ -30,13 +30,17 @@ Acts::Surface::Surface(const DetectorElementBase& detelement) Acts::Surface::Surface(const Surface& other) : GeometryObject(other), std::enable_shared_from_this(), - m_transform(other.m_transform), - m_surfaceMaterial(other.m_surfaceMaterial) {} + m_associatedDetElement(other.m_associatedDetElement), + m_surfaceMaterial(other.m_surfaceMaterial) { + if (other.m_transform) { + m_transform = std::make_unique(*other.m_transform); + } +} Acts::Surface::Surface(const GeometryContext& gctx, const Surface& other, const Transform3& shift) : GeometryObject(), - m_transform(shift * other.transform(gctx)), + m_transform(std::make_unique(shift * other.transform(gctx))), m_surfaceMaterial(other.m_surfaceMaterial) {} Acts::Surface::~Surface() = default; @@ -156,7 +160,11 @@ Acts::Surface& Acts::Surface::operator=(const Surface& other) { if (&other != this) { GeometryObject::operator=(other); // detector element, identifier & layer association are unique - m_transform = other.m_transform; + if (other.m_transform) { + m_transform = std::make_unique(*other.m_transform); + } else { + m_transform.reset(); + } m_associatedLayer = other.m_associatedLayer; m_surfaceMaterial = other.m_surfaceMaterial; m_associatedDetElement = other.m_associatedDetElement; @@ -182,7 +190,8 @@ bool Acts::Surface::operator==(const Surface& other) const { return false; } // (e) compare transform values - if (!m_transform.isApprox(other.m_transform, 1e-9)) { + if (m_transform && other.m_transform && + !m_transform->isApprox((*other.m_transform), 1e-9)) { return false; } // (f) compare material @@ -195,8 +204,8 @@ bool Acts::Surface::operator==(const Surface& other) const { } // overload dump for stream operator -std::ostream& Acts::Surface::toStream(const GeometryContext& gctx, - std::ostream& sl) const { +std::ostream& Acts::Surface::toStreamImpl(const GeometryContext& gctx, + std::ostream& sl) const { sl << std::setiosflags(std::ios::fixed); sl << std::setprecision(4); sl << name() << std::endl; @@ -221,7 +230,7 @@ std::ostream& Acts::Surface::toStream(const GeometryContext& gctx, std::string Acts::Surface::toString(const GeometryContext& gctx) const { std::stringstream ss; - toStream(gctx, ss); + ss << toStream(gctx); return ss.str(); } @@ -240,7 +249,7 @@ const Acts::Transform3& Acts::Surface::transform( if (m_associatedDetElement != nullptr) { return m_associatedDetElement->transform(gctx); } - return m_transform; + return *m_transform; } bool Acts::Surface::insideBounds(const Vector2& lposition, @@ -337,7 +346,7 @@ void Acts::Surface::assignDetectorElement( m_associatedDetElement = &detelement; // resetting the transform as it will be handled through the detector element // now - m_transform = Transform3::Identity(); + m_transform.reset(); } void Acts::Surface::assignSurfaceMaterial( diff --git a/Core/src/Utilities/BinningType.cpp b/Core/src/Utilities/BinningType.cpp new file mode 100644 index 00000000000..08a3dd58ce5 --- /dev/null +++ b/Core/src/Utilities/BinningType.cpp @@ -0,0 +1,54 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2016-2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "Acts/Utilities/BinningType.hpp" + +#include +#include +#include + +namespace Acts { + +namespace { + +static const std::vector s_binningValueNames = { + "binX", "binY", "binZ", "binR", "binPhi", + "binRPhi", "binH", "binEta", "binMag"}; + +static const std::vector s_binningValues = { + BinningValue::binX, BinningValue::binY, BinningValue::binZ, + BinningValue::binR, BinningValue::binPhi, BinningValue::binRPhi, + BinningValue::binH, BinningValue::binEta, BinningValue::binMag}; + +} // namespace + +const std::vector& allBinningValues() { + return s_binningValues; +} + +BinningValue binningValueFromName(const std::string& name) { + auto it = + std::find(s_binningValueNames.begin(), s_binningValueNames.end(), name); + if (it == s_binningValueNames.end()) { + throw std::invalid_argument("Unknown binning value name: " + name); + } + return static_cast( + std::distance(s_binningValueNames.begin(), it)); +} + +const std::string& binningValueName(BinningValue bValue) { + return s_binningValueNames.at( + static_cast>(bValue)); +} + +std::ostream& operator<<(std::ostream& os, BinningValue bValue) { + os << binningValueName(bValue); + return os; +} + +} // namespace Acts diff --git a/Core/src/Utilities/CMakeLists.txt b/Core/src/Utilities/CMakeLists.txt index 53a23bfd83d..64ede8dcd89 100644 --- a/Core/src/Utilities/CMakeLists.txt +++ b/Core/src/Utilities/CMakeLists.txt @@ -6,4 +6,5 @@ target_sources( Logger.cpp SpacePointUtility.cpp TrackHelpers.cpp + BinningType.cpp ) diff --git a/Core/src/Visualization/GeometryView3D.cpp b/Core/src/Visualization/GeometryView3D.cpp index 960182a4431..33822f9ac7d 100644 --- a/Core/src/Visualization/GeometryView3D.cpp +++ b/Core/src/Visualization/GeometryView3D.cpp @@ -127,8 +127,9 @@ void Acts::GeometryView3D::drawSurfaceArray( auto axes = surfaceArray.getAxes(); if (!binning.empty() && binning.size() == 2 && axes.size() == 2) { // Cylinder surface array - if (binning[0] == binPhi && binning[1] == binZ) { - double R = arrayExtent.medium(binR) + gridConfig.offset; + if (binning[0] == BinningValue::binPhi && + binning[1] == BinningValue::binZ) { + double R = arrayExtent.medium(BinningValue::binR) + gridConfig.offset; auto phiValues = axes[0]->getBinEdges(); auto zValues = axes[1]->getBinEdges(); ViewConfig gridRadConfig = gridConfig; @@ -151,8 +152,9 @@ void Acts::GeometryView3D::drawSurfaceArray( } } - } else if (binning[0] == binR && binning[1] == binPhi) { - double z = arrayExtent.medium(binZ) + gridConfig.offset; + } else if (binning[0] == BinningValue::binR && + binning[1] == BinningValue::binPhi) { + double z = arrayExtent.medium(BinningValue::binZ) + gridConfig.offset; auto rValues = axes[0]->getBinEdges(); auto phiValues = axes[1]->getBinEdges(); ViewConfig gridRadConfig = gridConfig; diff --git a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp index 94023637068..1305ea657b8 100644 --- a/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp +++ b/Examples/Algorithms/Digitization/include/ActsExamples/Digitization/Smearers.hpp @@ -138,7 +138,7 @@ struct Uniform { /// Construct with a @param pitch standard deviation and @param range Uniform(double pitch, const std::pair& range_) : binningData( - Acts::open, Acts::binX, + Acts::open, Acts::BinningValue::binX, static_cast((range_.second - range_.first) / pitch), range_.first, range_.second) {} @@ -176,7 +176,7 @@ struct Digital { /// Construct with a @param pitch standard deviation and @param range Digital(double pitch, const std::pair& range_) : binningData( - Acts::open, Acts::binX, + Acts::open, Acts::BinningValue::binX, static_cast((range_.second - range_.first) / pitch), range_.first, range_.second) {} diff --git a/Examples/Algorithms/Digitization/scripts/smearing-config.py b/Examples/Algorithms/Digitization/scripts/smearing-config.py index 3554c239535..504f364f4c0 100644 --- a/Examples/Algorithms/Digitization/scripts/smearing-config.py +++ b/Examples/Algorithms/Digitization/scripts/smearing-config.py @@ -145,7 +145,7 @@ def block_to_json(args): data["bindata"] = [ 0, # Acts::Open, - 0, # Acts::binX, + 0, # Acts::BinningValue::binX, (high - low) / pitch, low, high, diff --git a/Examples/Algorithms/Digitization/src/DigitizationConfigurator.cpp b/Examples/Algorithms/Digitization/src/DigitizationConfigurator.cpp index 7e12064df20..6e363809ca2 100644 --- a/Examples/Algorithms/Digitization/src/DigitizationConfigurator.cpp +++ b/Examples/Algorithms/Digitization/src/DigitizationConfigurator.cpp @@ -80,15 +80,17 @@ void ActsExamples::DigitizationConfigurator::operator()( switch (sBounds.type()) { // The module is a rectangle module case Acts::SurfaceBounds::eRectangle: { - if (inputSegmentation.binningData()[0].binvalue == Acts::binX) { + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binX) { Acts::ActsScalar minX = boundValues[Acts::RectangleBounds::eMinX]; Acts::ActsScalar maxX = boundValues[Acts::RectangleBounds::eMaxX]; unsigned int nBins = static_cast(std::round( (maxX - minX) / inputSegmentation.binningData()[0].step)); - outputSegmentation += - Acts::BinUtility(nBins, minX, maxX, Acts::open, Acts::binX); + outputSegmentation += Acts::BinUtility( + nBins, minX, maxX, Acts::open, Acts::BinningValue::binX); } - if (inputSegmentation.binningData()[0].binvalue == Acts::binY || + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binY || inputSegmentation.dimensions() == 2) { unsigned int accessBin = inputSegmentation.dimensions() == 2 ? 1 : 0; @@ -97,23 +99,25 @@ void ActsExamples::DigitizationConfigurator::operator()( unsigned int nBins = static_cast( std::round((maxY - minY) / inputSegmentation.binningData()[accessBin].step)); - outputSegmentation += - Acts::BinUtility(nBins, minY, maxY, Acts::open, Acts::binY); + outputSegmentation += Acts::BinUtility( + nBins, minY, maxY, Acts::open, Acts::BinningValue::binY); } } break; // The module is a trapezoid module case Acts::SurfaceBounds::eTrapezoid: { - if (inputSegmentation.binningData()[0].binvalue == Acts::binX) { + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binX) { Acts::ActsScalar maxX = std::max( boundValues[Acts::TrapezoidBounds::eHalfLengthXnegY], boundValues[Acts::TrapezoidBounds::eHalfLengthXposY]); unsigned int nBins = static_cast(std::round( 2 * maxX / inputSegmentation.binningData()[0].step)); - outputSegmentation += - Acts::BinUtility(nBins, -maxX, maxX, Acts::open, Acts::binX); + outputSegmentation += Acts::BinUtility( + nBins, -maxX, maxX, Acts::open, Acts::BinningValue::binX); } - if (inputSegmentation.binningData()[0].binvalue == Acts::binY || + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binY || inputSegmentation.dimensions() == 2) { unsigned int accessBin = inputSegmentation.dimensions() == 2 ? 1 : 0; @@ -122,22 +126,24 @@ void ActsExamples::DigitizationConfigurator::operator()( unsigned int nBins = static_cast( std::round((2 * maxY) / inputSegmentation.binningData()[accessBin].step)); - outputSegmentation += - Acts::BinUtility(nBins, -maxY, maxY, Acts::open, Acts::binY); + outputSegmentation += Acts::BinUtility( + nBins, -maxY, maxY, Acts::open, Acts::BinningValue::binY); } } break; // The module is an annulus module case Acts::SurfaceBounds::eAnnulus: { - if (inputSegmentation.binningData()[0].binvalue == Acts::binR) { + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binR) { Acts::ActsScalar minR = boundValues[Acts::AnnulusBounds::eMinR]; Acts::ActsScalar maxR = boundValues[Acts::AnnulusBounds::eMaxR]; unsigned int nBins = static_cast(std::round( (maxR - minR) / inputSegmentation.binningData()[0].step)); - outputSegmentation += - Acts::BinUtility(nBins, minR, maxR, Acts::open, Acts::binR); + outputSegmentation += Acts::BinUtility( + nBins, minR, maxR, Acts::open, Acts::BinningValue::binR); } - if (inputSegmentation.binningData()[0].binvalue == Acts::binPhi || + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binPhi || inputSegmentation.dimensions() == 2) { unsigned int accessBin = inputSegmentation.dimensions() == 2 ? 1 : 0; @@ -150,8 +156,9 @@ void ActsExamples::DigitizationConfigurator::operator()( unsigned int nBins = static_cast( std::round((maxPhi - minPhi) / inputSegmentation.binningData()[accessBin].step)); - outputSegmentation += Acts::BinUtility(nBins, minPhi, maxPhi, - Acts::open, Acts::binPhi); + outputSegmentation += + Acts::BinUtility(nBins, minPhi, maxPhi, Acts::open, + Acts::BinningValue::binPhi); } } break; @@ -163,13 +170,15 @@ void ActsExamples::DigitizationConfigurator::operator()( Acts::ActsScalar maxR = boundValues[Acts::DiscTrapezoidBounds::eMaxR]; - if (inputSegmentation.binningData()[0].binvalue == Acts::binR) { + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binR) { unsigned int nBins = static_cast(std::round( (maxR - minR) / inputSegmentation.binningData()[0].step)); - outputSegmentation += - Acts::BinUtility(nBins, minR, maxR, Acts::open, Acts::binR); + outputSegmentation += Acts::BinUtility( + nBins, minR, maxR, Acts::open, Acts::BinningValue::binR); } - if (inputSegmentation.binningData()[0].binvalue == Acts::binPhi || + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binPhi || inputSegmentation.dimensions() == 2) { unsigned int accessBin = inputSegmentation.dimensions() == 2 ? 1 : 0; @@ -185,23 +194,25 @@ void ActsExamples::DigitizationConfigurator::operator()( Acts::ActsScalar alpha = std::max(alphaMinR, alphaMaxR); unsigned int nBins = static_cast(std::round( 2 * alpha / inputSegmentation.binningData()[accessBin].step)); - outputSegmentation += Acts::BinUtility(nBins, averagePhi - alpha, - averagePhi + alpha, - Acts::open, Acts::binPhi); + outputSegmentation += Acts::BinUtility( + nBins, averagePhi - alpha, averagePhi + alpha, Acts::open, + Acts::BinningValue::binPhi); } } break; case Acts::SurfaceBounds::eDisc: { - if (inputSegmentation.binningData()[0].binvalue == Acts::binR) { + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binR) { Acts::ActsScalar minR = boundValues[Acts::RadialBounds::eMinR]; Acts::ActsScalar maxR = boundValues[Acts::RadialBounds::eMaxR]; unsigned int nBins = static_cast(std::round( (maxR - minR) / inputSegmentation.binningData()[0].step)); - outputSegmentation += - Acts::BinUtility(nBins, minR, maxR, Acts::open, Acts::binR); + outputSegmentation += Acts::BinUtility( + nBins, minR, maxR, Acts::open, Acts::BinningValue::binR); } - if (inputSegmentation.binningData()[0].binvalue == Acts::binPhi || + if (inputSegmentation.binningData()[0].binvalue == + Acts::BinningValue::binPhi || inputSegmentation.dimensions() == 2) { unsigned int accessBin = inputSegmentation.dimensions() == 2 ? 1 : 0; @@ -216,8 +227,9 @@ void ActsExamples::DigitizationConfigurator::operator()( unsigned int nBins = static_cast( std::round((maxPhi - minPhi) / inputSegmentation.binningData()[accessBin].step)); - outputSegmentation += Acts::BinUtility(nBins, minPhi, maxPhi, - Acts::open, Acts::binPhi); + outputSegmentation += + Acts::BinUtility(nBins, minPhi, maxPhi, Acts::open, + Acts::BinningValue::binPhi); } } break; diff --git a/Examples/Algorithms/Digitization/src/ModuleClusters.cpp b/Examples/Algorithms/Digitization/src/ModuleClusters.cpp index 1478dbe750d..b880a1534f4 100644 --- a/Examples/Algorithms/Digitization/src/ModuleClusters.cpp +++ b/Examples/Algorithms/Digitization/src/ModuleClusters.cpp @@ -32,7 +32,7 @@ void ModuleClusters::add(DigitizedParameters params, simhit_t simhit) { if (m_merge && !params.cluster.channels.empty()) { // Break-up the cluster - for (auto cell : params.cluster.channels) { + for (const auto& cell : params.cluster.channels) { ModuleValue mval_cell = mval; mval_cell.value = cell; m_moduleValues.push_back(std::move(mval_cell)); diff --git a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp index 9fbda5c4c93..dfc837889b4 100644 --- a/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp +++ b/Examples/Algorithms/Geant4/src/TelescopeG4DetectorConstruction.cpp @@ -72,8 +72,8 @@ ActsExamples::Telescope::TelescopeG4DetectorConstruction::Construct() { new G4Material("Silicon", 14, 28.0855 * g / mole, 2.329 * g / cm3); // Construct the rotation - // This assumes the binValue is binX, binY or binZ. No reset is necessary in - // case of binZ + // This assumes the binValue is BinningValue::binX, BinningValue::binY or + // BinningValue::binZ. No reset is necessary in case of BinningValue::binZ G4RotationMatrix* rotation = nullptr; if (static_cast(m_cfg.binValue) == Acts::BinningValue::binX) { diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp index 1a9fce3fcca..e2217692e7b 100644 --- a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp @@ -204,10 +204,10 @@ class MappingMaterialDecorator : public IMaterialDecorator { Acts::s_epsilon ? Acts::closed : Acts::open, - Acts::binPhi); - bUtility += - Acts::BinUtility(binning.second, radialBounds->rMin(), - radialBounds->rMax(), Acts::open, Acts::binR); + Acts::BinningValue::binPhi); + bUtility += Acts::BinUtility(binning.second, radialBounds->rMin(), + radialBounds->rMax(), Acts::open, + Acts::BinningValue::binR); } if (cylinderBounds != nullptr) { bUtility += Acts::BinUtility( @@ -220,43 +220,44 @@ class MappingMaterialDecorator : public IMaterialDecorator { Acts::s_epsilon ? Acts::closed : Acts::open, - Acts::binPhi); + Acts::BinningValue::binPhi); bUtility += Acts::BinUtility( binning.second, -1 * cylinderBounds->get(Acts::CylinderBounds::eHalfLengthZ), cylinderBounds->get(Acts::CylinderBounds::eHalfLengthZ), Acts::open, - Acts::binZ); + Acts::BinningValue::binZ); } if (annulusBounds != nullptr) { bUtility += Acts::BinUtility( binning.first, annulusBounds->get(Acts::AnnulusBounds::eMinPhiRel), annulusBounds->get(Acts::AnnulusBounds::eMaxPhiRel), Acts::open, - Acts::binPhi); - bUtility += - Acts::BinUtility(binning.second, annulusBounds->rMin(), - annulusBounds->rMax(), Acts::open, Acts::binR); + Acts::BinningValue::binPhi); + bUtility += Acts::BinUtility(binning.second, annulusBounds->rMin(), + annulusBounds->rMax(), Acts::open, + Acts::BinningValue::binR); } if (rectangleBounds != nullptr) { bUtility += Acts::BinUtility( binning.first, rectangleBounds->get(Acts::RectangleBounds::eMinX), rectangleBounds->get(Acts::RectangleBounds::eMaxX), Acts::open, - Acts::binX); + Acts::BinningValue::binX); bUtility += Acts::BinUtility( binning.second, rectangleBounds->get(Acts::RectangleBounds::eMinY), rectangleBounds->get(Acts::RectangleBounds::eMaxY), Acts::open, - Acts::binY); + Acts::BinningValue::binY); } if (trapezoidBounds != nullptr) { double halfLengthX = std::max( trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthXnegY), trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthXposY)); - bUtility += Acts::BinUtility(binning.first, -1 * halfLengthX, - halfLengthX, Acts::open, Acts::binX); + bUtility += + Acts::BinUtility(binning.first, -1 * halfLengthX, halfLengthX, + Acts::open, Acts::BinningValue::binX); bUtility += Acts::BinUtility( binning.second, -1 * trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthY), trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthY), - Acts::open, Acts::binY); + Acts::open, Acts::BinningValue::binY); } } return std::make_shared(bUtility); diff --git a/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp b/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp index 547fd52ad03..9333d7b11a8 100644 --- a/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp +++ b/Examples/Algorithms/TrackFinding/src/HoughTransformSeeder.cpp @@ -509,7 +509,7 @@ void ActsExamples::HoughTransformSeeder::addMeasurements( // arbitrary range. do the equivalent grouping manually auto groupedByModule = makeGroupBy(range, detail::GeometryIdGetter()); - for (auto [moduleGeoId, moduleSourceLinks] : groupedByModule) { + for (const auto& [moduleGeoId, moduleSourceLinks] : groupedByModule) { // find corresponding surface const Acts::Surface* surface = m_cfg.trackingGeometry->findSurface(moduleGeoId); diff --git a/Examples/Algorithms/TrackFinding/src/MuonHoughSeeder.cpp b/Examples/Algorithms/TrackFinding/src/MuonHoughSeeder.cpp index 7034c91f322..79553cbd89d 100644 --- a/Examples/Algorithms/TrackFinding/src/MuonHoughSeeder.cpp +++ b/Examples/Algorithms/TrackFinding/src/MuonHoughSeeder.cpp @@ -108,12 +108,16 @@ ActsExamples::ProcessCode ActsExamples::MuonHoughSeeder::execute( // loop pver true hirs for (auto& SH : gotSH) { // read the identifier - muonMdtIdentifierFields detailedInfo = + MuonMdtIdentifierFields detailedInfo = ActsExamples::splitId(SH.geometryId().value()); - // store the true parameters truePatterns.emplace_back(SH.direction().y() / SH.direction().z(), SH.fourPosition().y()); + // std::cout<<"station name=" << + // static_cast(SH.stationName)<(detailedInfo.stationEta), diff --git a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp index 023a6e386ca..efaa4c1891a 100644 --- a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp @@ -266,11 +266,11 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute( // safely clamp double to float float up = Acts::clampValue( - std::floor(rRangeSPExtent.max(Acts::binR) / 2) * 2); + std::floor(rRangeSPExtent.max(Acts::BinningValue::binR) / 2) * 2); /// variable middle SP radial region of interest const Acts::Range1D rMiddleSPRange( - std::floor(rRangeSPExtent.min(Acts::binR) / 2) * 2 + + std::floor(rRangeSPExtent.min(Acts::BinningValue::binR) / 2) * 2 + m_cfg.seedFinderConfig.deltaRMiddleMinSPRange, up - m_cfg.seedFinderConfig.deltaRMiddleMaxSPRange); diff --git a/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp b/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp index 1ca19c91b3b..4cf3205f2b0 100644 --- a/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp +++ b/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp @@ -147,8 +147,8 @@ ActsExamples::ProcessCode ActsExamples::SpacePointMaker::execute( // arbitrary range. do the equivalent grouping manually auto groupedByModule = makeGroupBy(range, detail::GeometryIdGetter()); - for (auto [moduleGeoId, moduleSourceLinks] : groupedByModule) { - for (auto& sourceLink : moduleSourceLinks) { + for (const auto& [moduleGeoId, moduleSourceLinks] : groupedByModule) { + for (const auto& sourceLink : moduleSourceLinks) { m_spacePointBuilder.buildSpacePoint( ctx.geoContext, {Acts::SourceLink{sourceLink}}, spOpt, std::back_inserter(spacePoints)); diff --git a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp index 5a6faea1494..a812b249625 100644 --- a/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp +++ b/Examples/Algorithms/Vertexing/src/IterativeVertexFinderAlgorithm.cpp @@ -122,8 +122,8 @@ ActsExamples::ProcessCode ActsExamples::IterativeVertexFinderAlgorithm::execute( // show some debug output ACTS_INFO("Found " << vertices.size() << " vertices in event"); for (const auto& vtx : vertices) { - ACTS_INFO("Found vertex at " << vtx.fullPosition().transpose() << " with " - << vtx.tracks().size() << " tracks."); + ACTS_DEBUG("Found vertex at " << vtx.fullPosition().transpose() << " with " + << vtx.tracks().size() << " tracks."); } // store proto vertices extracted from the found vertices diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp index 265cfe34408..9d42ad9441c 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/BuildGenericDetector.hpp @@ -159,17 +159,21 @@ std::unique_ptr buildDetector( // Prepare the proto material - in case it's designed to do so // - cylindrical - Acts::BinUtility pCylinderUtility(10, -1, 1, Acts::closed, Acts::binPhi); - pCylinderUtility += Acts::BinUtility(10, -1, 1, Acts::open, Acts::binZ); + Acts::BinUtility pCylinderUtility(10, -1, 1, Acts::closed, + Acts::BinningValue::binPhi); + pCylinderUtility += + Acts::BinUtility(10, -1, 1, Acts::open, Acts::BinningValue::binZ); auto pCylinderMaterial = std::make_shared(pCylinderUtility); // - disc - Acts::BinUtility pDiscUtility(10, 0, 1, Acts::open, Acts::binR); - pDiscUtility += Acts::BinUtility(10, -1, 1, Acts::closed, Acts::binPhi); + Acts::BinUtility pDiscUtility(10, 0, 1, Acts::open, Acts::BinningValue::binR); + pDiscUtility += + Acts::BinUtility(10, -1, 1, Acts::closed, Acts::BinningValue::binPhi); auto pDiscMaterial = std::make_shared(pDiscUtility); // - plane - Acts::BinUtility pPlaneUtility(1, -1, 1, Acts::open, Acts::binX); + Acts::BinUtility pPlaneUtility(1, -1, 1, Acts::open, + Acts::BinningValue::binX); auto pPlaneMaterial = std::make_shared(pPlaneUtility); diff --git a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp index 651fc643ae3..8eef808dbb9 100644 --- a/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp +++ b/Examples/Detectors/GenericDetector/include/ActsExamples/GenericDetector/ProtoLayerCreatorT.hpp @@ -329,9 +329,10 @@ ProtoLayerCreatorT::centralProtoLayers( // create the surface array - it will also fill the accessible binmember // cache if available Acts::ProtoLayer pl(gctx, sVector); - pl.envelope[Acts::binR] = {m_cfg.approachSurfaceEnvelope, - m_cfg.approachSurfaceEnvelope}; - pl.envelope[Acts::binZ] = {layerEnvelopeCoverZ, layerEnvelopeCoverZ}; + pl.envelope[Acts::BinningValue::binR] = {m_cfg.approachSurfaceEnvelope, + m_cfg.approachSurfaceEnvelope}; + pl.envelope[Acts::BinningValue::binZ] = {layerEnvelopeCoverZ, + layerEnvelopeCoverZ}; // Record the proto layer and the surfaces for the later layer building ProtoLayerSurfaces pls{std::move(pl), sVector, phiBins, zBins}; @@ -515,9 +516,9 @@ ProtoLayerCreatorT::createProtoLayers( } // create the layers with the surface arrays Acts::ProtoLayer ple(gctx, esVector); - ple.envelope[Acts::binR] = {layerEnvelopeR, layerEnvelopeR}; - ple.envelope[Acts::binZ] = {m_cfg.approachSurfaceEnvelope, - m_cfg.approachSurfaceEnvelope}; + ple.envelope[Acts::BinningValue::binR] = {layerEnvelopeR, layerEnvelopeR}; + ple.envelope[Acts::BinningValue::binZ] = {m_cfg.approachSurfaceEnvelope, + m_cfg.approachSurfaceEnvelope}; // push it into the layer vector ProtoLayerSurfaces ples{std::move(ple), esVector, layerBinsR, diff --git a/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp b/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp index f60af5f7afe..77edfa78e1a 100644 --- a/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp +++ b/Examples/Detectors/TGeoDetector/src/TGeoDetector.cpp @@ -66,13 +66,16 @@ std::vector makeLayerBuilderConfigs( // configure surface autobinning std::vector> binTolerances( - static_cast(Acts::binValues), {0., 0.}); - binTolerances[Acts::binR] = {volume.binToleranceR.lower.value_or(0.), - volume.binToleranceR.upper.value_or(0.)}; - binTolerances[Acts::binZ] = {volume.binToleranceZ.lower.value_or(0.), - volume.binToleranceZ.upper.value_or(0.)}; - binTolerances[Acts::binPhi] = {volume.binTolerancePhi.lower.value_or(0.), - volume.binTolerancePhi.upper.value_or(0.)}; + Acts::numBinningValues(), {0., 0.}); + binTolerances[toUnderlying(Acts::BinningValue::binR)] = { + volume.binToleranceR.lower.value_or(0.), + volume.binToleranceR.upper.value_or(0.)}; + binTolerances[toUnderlying(Acts::BinningValue::binZ)] = { + volume.binToleranceZ.lower.value_or(0.), + volume.binToleranceZ.upper.value_or(0.)}; + binTolerances[toUnderlying(Acts::BinningValue::binPhi)] = { + volume.binTolerancePhi.lower.value_or(0.), + volume.binTolerancePhi.upper.value_or(0.)}; layerBuilderConfig.autoSurfaceBinning = true; layerBuilderConfig.surfaceBinMatcher = @@ -101,18 +104,18 @@ std::vector makeLayerBuilderConfigs( auto zMin = zR.lower.value_or(-std::numeric_limits::max()); auto zMax = zR.upper.value_or(std::numeric_limits::max()); lConfig.parseRanges = { - {Acts::binR, {rMin, rMax}}, - {Acts::binZ, {zMin, zMax}}, + {Acts::BinningValue::binR, {rMin, rMax}}, + {Acts::BinningValue::binZ, {zMin, zMax}}, }; // Fill the layer splitting parameters in r/z auto str = volume.splitTolR.at(ncp); auto stz = volume.splitTolZ.at(ncp); if (0 < str) { - lConfig.splitConfigs.emplace_back(Acts::binR, str); + lConfig.splitConfigs.emplace_back(Acts::BinningValue::binR, str); } if (0 < stz) { - lConfig.splitConfigs.emplace_back(Acts::binZ, stz); + lConfig.splitConfigs.emplace_back(Acts::BinningValue::binZ, stz); } lConfig.binning0 = volume.binning0.at(ncp); lConfig.binning1 = volume.binning1.at(ncp); @@ -284,7 +287,7 @@ std::shared_ptr buildTGeoDetector( -> void { for (const auto& lcfg : lConfigs) { for (const auto& scfg : lcfg.splitConfigs) { - if (scfg.first == Acts::binR && scfg.second > 0.) { + if (scfg.first == Acts::BinningValue::binR && scfg.second > 0.) { volumeConfig.ringTolerance = std::max(volumeConfig.ringTolerance, scfg.second); volumeConfig.checkRingLayout = true; diff --git a/Examples/Framework/include/ActsExamples/EventData/MuonSimHit.hpp b/Examples/Framework/include/ActsExamples/EventData/MuonSimHit.hpp index 64ca853bc13..9a3144eeb4e 100644 --- a/Examples/Framework/include/ActsExamples/EventData/MuonSimHit.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/MuonSimHit.hpp @@ -13,6 +13,7 @@ #include "Acts/EventData/SourceLink.hpp" #include "ActsExamples/EventData/Index.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/SimHit.hpp" #include #include @@ -33,7 +34,7 @@ enum class MuonIdentifierFieldMaps { tubeLayer = 8, tube = 0, }; -struct muonMdtIdentifierFields { +struct MuonMdtIdentifierFields { std::int8_t stationName = 0; std::int8_t stationEta = 0; std::int8_t stationPhi = 0; @@ -41,8 +42,8 @@ struct muonMdtIdentifierFields { std::int8_t tubeLayer = 0; std::int8_t tube = 0; }; -muonMdtIdentifierFields splitId(Acts::GeometryIdentifier::Value theID) { - muonMdtIdentifierFields f; +MuonMdtIdentifierFields splitId(Acts::GeometryIdentifier::Value theID) { + MuonMdtIdentifierFields f; f.tube = theID & 0xFF; theID = theID >> g_fieldShift; f.tubeLayer = theID & 0xFF; @@ -56,11 +57,11 @@ muonMdtIdentifierFields splitId(Acts::GeometryIdentifier::Value theID) { f.stationName = theID & 0xFF; return f; } -Acts::GeometryIdentifier::Value compressId(muonMdtIdentifierFields f) { +Acts::GeometryIdentifier::Value compressId(MuonMdtIdentifierFields f) { Acts::GeometryIdentifier::Value out{0}; out = out << g_fieldShift | f.stationName; - out = out << g_fieldShift | f.stationEta; - out = out << g_fieldShift | f.stationPhi; + out = out << g_fieldShift | static_cast(f.stationEta); + out = out << g_fieldShift | static_cast(f.stationPhi); out = out << g_fieldShift | f.multilayer; out = out << g_fieldShift | f.tubeLayer; out = out << g_fieldShift | f.tube; diff --git a/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp b/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp index 8d248df3e1d..fbc6f4e1592 100644 --- a/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp +++ b/Examples/Io/Csv/src/CsvMuonSimHitReader.cpp @@ -74,7 +74,7 @@ ActsExamples::ProcessCode ActsExamples::CsvMuonSimHitReader::read( data.LocalDirectiony * data.LocalDirectiony + data.LocalDirectionz * data.LocalDirectionz) * Acts::UnitConstants::GeV}; - muonMdtIdentifierFields f; + MuonMdtIdentifierFields f; f.multilayer = 0; f.tube = 0; f.tubeLayer = 0; diff --git a/Examples/Io/Root/src/RootTrackParameterWriter.cpp b/Examples/Io/Root/src/RootTrackParameterWriter.cpp index 6269e4a88ea..c64c9fd2f0a 100644 --- a/Examples/Io/Root/src/RootTrackParameterWriter.cpp +++ b/Examples/Io/Root/src/RootTrackParameterWriter.cpp @@ -194,7 +194,11 @@ ActsExamples::ProcessCode ActsExamples::RootTrackParameterWriter::writeT( if (ip != particles.end()) { const auto& particle = *ip; m_t_charge = static_cast(particle.charge()); - m_t_qop = m_t_charge / p; + if (p != 0.0) { + m_t_qop = m_t_charge / p; + } else { + m_t_qop = std::numeric_limits::quiet_NaN(); + } } else { ACTS_DEBUG("Truth particle with barcode " << particleId << "=" << particleId.value() << " not found!"); diff --git a/Examples/Python/CMakeLists.txt b/Examples/Python/CMakeLists.txt index ba8672c1d74..d15a8cf8b7f 100644 --- a/Examples/Python/CMakeLists.txt +++ b/Examples/Python/CMakeLists.txt @@ -84,6 +84,13 @@ else() target_sources(ActsPythonBindings PRIVATE src/GeoModelStub.cpp) endif() +if(ACTS_BUILD_PLUGIN_DETRAY) + target_link_libraries(ActsPythonBindings PUBLIC ActsPluginDetray) + target_sources(ActsPythonBindings PRIVATE src/Detray.cpp) +else() + target_sources(ActsPythonBindings PRIVATE src/DetrayStub.cpp) +endif() + if(ACTS_BUILD_PLUGIN_ACTSVG) target_link_libraries(ActsPythonBindings PUBLIC ActsExamplesIoSvg) target_sources(ActsPythonBindings PRIVATE src/Svg.cpp) diff --git a/Examples/Python/src/Detray.cpp b/Examples/Python/src/Detray.cpp new file mode 100644 index 00000000000..34d23aad495 --- /dev/null +++ b/Examples/Python/src/Detray.cpp @@ -0,0 +1,64 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "Acts/Detector/Detector.hpp" +#include "Acts/Plugins/Detray/DetrayConverter.hpp" +#include "Acts/Plugins/Python/Utilities.hpp" + +#include +#include + +#include +#include +#include + +#include "detray/builders/detector_builder.hpp" +#include "detray/io/frontend/detector_reader_config.hpp" + +namespace py = pybind11; +using namespace pybind11::literals; + +using namespace Acts; +using namespace detray; +using namespace detray::io::detail; + +namespace Acts::Python { + +void addDetray(Context& ctx) { + auto [m, mex] = ctx.get("main", "examples"); + + { + py::class_, + std::shared_ptr>>(m, + "detray_detector"); + } + + { mex.def("writeToJson", &DetrayConverter::writeToJson); } + /** + { + /// @brief Converts an Acts::Detector to a detray::detector + mex.def("convertDetectorToDetray", + [](const Acts::GeometryContext& gctx, + const Acts::Experimental::Detector& acts_detector, + const std::string& name) -> auto + {//detector + + // Create a host memory resource + vecmem::host_memory_resource host_mr; + // Convert Acts detector to detray detector using the + detray converter function auto det_tuple = + DetrayConverter::detrayConvert(acts_detector, gctx, host_mr); + + return true; //TO DO:: cannot return tuple + + }); + } + + **/ +} +} // namespace Acts::Python diff --git a/Examples/Python/src/DetrayStub.cpp b/Examples/Python/src/DetrayStub.cpp new file mode 100644 index 00000000000..2ade0dd8bc5 --- /dev/null +++ b/Examples/Python/src/DetrayStub.cpp @@ -0,0 +1,13 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "Acts/Plugins/Python/Utilities.hpp" + +namespace Acts::Python { +void addDetray(Context& /*ctx*/) {} +} // namespace Acts::Python diff --git a/Examples/Python/src/ModuleEntry.cpp b/Examples/Python/src/ModuleEntry.cpp index cc6442fe285..8b129e37fae 100644 --- a/Examples/Python/src/ModuleEntry.cpp +++ b/Examples/Python/src/ModuleEntry.cpp @@ -71,6 +71,7 @@ void addDigitization(Context& ctx); void addPythia8(Context& ctx); void addGeoModel(Context& ctx); void addJson(Context& ctx); +void addDetray(Context& ctx); void addHepMC3(Context& ctx); void addExaTrkXTrackFinding(Context& ctx); void addSvg(Context& ctx); @@ -132,6 +133,7 @@ PYBIND11_MODULE(ActsPythonBindings, m) { addPythia8(ctx); addJson(ctx); addGeoModel(ctx); + addDetray(ctx); addHepMC3(ctx); addExaTrkXTrackFinding(ctx); addObj(ctx); diff --git a/Examples/Python/tests/root_file_hashes.txt b/Examples/Python/tests/root_file_hashes.txt index 54aaebf8851..fa99e0e19bd 100644 --- a/Examples/Python/tests/root_file_hashes.txt +++ b/Examples/Python/tests/root_file_hashes.txt @@ -1,7 +1,7 @@ -test_pythia8__pythia8_particles.root: 49b89c3458a51aa9407f887be50e6bbcd9a2a0c897e6f2be5a5d6a29d1bf3505 +test_pythia8__pythia8_particles.root: fb7d886314f737847838a714a4aa49c179cfaabfd9f16e3d4b7672a7d12db0d3 test_fatras__particles_simulation.root: bc970873fef0c2efd86ed5413623802353d2cd04abea72de14e8cdfc0e40076f test_fatras__hits.root: 6e4beb045fa1712c4d14c280ba33c3fa13e4aff9de88d55c3e32f62ad226f724 -test_geant4__particles_simulation.root: a51f15555abefec7e9d9de31f9d856a3026af1b991db73fefaec5ae160a4af2f +test_geant4__particles_simulation.root: 3c9c6265183b04c9d62ed5f2d0709c6dd74e33fbb53ac0aeb3274f6600257fc1 test_geant4__hits.root: adf5dcdf000a580412dc5089e17460897d6535c978eafa021584ba4281d0a1ac test_seeding__estimatedparams.root: d18718704a9ba5bf6627a0e4bf60581c640d80d66fc46dbd3e7c1d051ad99f71 test_seeding__performance_seeding.root: 992f9c611d30dde0d3f3ab676bab19ada61ab6a4442828e27b65ec5e5b7a2880 @@ -18,18 +18,18 @@ test_itk_seeding__particles_simulation.root: ef0246069aa697019f28a8b270a68de9531 test_propagation__propagation_steps.root: ba2e20d66f9f58850a9248bfaaafecbf0e8257020bb879b4572b783917f4d19b test_material_recording__geant4_material_tracks.root: c022b9362249b29f57a07926b20644e3ab4ab8ebcf03f773fbf46c446fc1a0a1 test_truth_tracking_kalman[generic-0.0]__trackstates_fitter.root: 26640d70f7fab870e59666b0915569a6f8f82af68c63e5505548ffa9d24a3212 -test_truth_tracking_kalman[generic-0.0]__tracksummary_fitter.root: 11b2e2a50343c636fa977175a30220805412d3200e164ae4c3f439fe2087fb88 +test_truth_tracking_kalman[generic-0.0]__tracksummary_fitter.root: 496467c8305c52ef76f855f6eef00033f4428f785c6099b5ba60c1f3cae19dc3 test_truth_tracking_kalman[generic-0.0]__performance_track_finder.root: ada9cda2ec3c648b144bdaa081d6eff923c80f3d484c4196006e847428cf67a8 test_truth_tracking_kalman[generic-1000.0]__trackstates_fitter.root: 476e0dca91e5168f0574b86aea797dc22900fd456b3c3fb24d5f571b4be804fc -test_truth_tracking_kalman[generic-1000.0]__tracksummary_fitter.root: fc82abfc4e3016cda806e743a270bf78b6d4cc404cd52145ea1eabed85d32feb +test_truth_tracking_kalman[generic-1000.0]__tracksummary_fitter.root: c8bdd0ccddeda38867517dd86665804bac2f3ab4bbb11a02a82dc725ee65e771 test_truth_tracking_kalman[generic-1000.0]__performance_track_finder.root: ada9cda2ec3c648b144bdaa081d6eff923c80f3d484c4196006e847428cf67a8 test_truth_tracking_kalman[odd-0.0]__trackstates_fitter.root: 56eeee0a03a2ba23fddc1dc56b935e4040803800c68f0f2cca1a35b40a74edb2 -test_truth_tracking_kalman[odd-0.0]__tracksummary_fitter.root: 010eb33b0d99bafc06f63dc6385aa315c15f0ba9f698fc56c05737162ca686bb +test_truth_tracking_kalman[odd-0.0]__tracksummary_fitter.root: 3802b1bc849fe47bfa7ae72fb13d6bd592e0a82a97277bad12a8ceef59c00f64 test_truth_tracking_kalman[odd-0.0]__performance_track_finder.root: 39aec6316cceb90e314e16b02947faa691c18f57c3a851a25e547a8fc05a4593 test_truth_tracking_kalman[odd-1000.0]__trackstates_fitter.root: 72c79be1458c4f9c9a1661778c900f0875d257f2d391c4183a698825448919a1 -test_truth_tracking_kalman[odd-1000.0]__tracksummary_fitter.root: 3d424dec9b172f253c8c4ffbda470f678fd1081a3d36dcfea517ab0f94995ae4 +test_truth_tracking_kalman[odd-1000.0]__tracksummary_fitter.root: a53253b509b5779a5d856f8c09d76a499b217b55ba4b0e52d9076ffad726463f test_truth_tracking_kalman[odd-1000.0]__performance_track_finder.root: 39aec6316cceb90e314e16b02947faa691c18f57c3a851a25e547a8fc05a4593 -test_truth_tracking_gsf[generic]__trackstates_gsf.root: 9456102b40bda129a05fbf8c27a585b45755c466e73e9a0a66519d28a93fb097 +test_truth_tracking_gsf[generic]__trackstates_gsf.root: b72aa54745447984810ecda68a2e1787198aea07337f89d95c3034d0b3c60e1b test_truth_tracking_gsf[generic]__tracksummary_gsf.root: 618a47def602f4a9b387ed2c7eb0c33aa26ca91c0e177ca0fcef67c092d791f0 test_truth_tracking_gsf[odd]__trackstates_gsf.root: 1b70e6e24af0c18f80d42c39e05dd20189bf4d1fcb48851f807cf723f461d7c0 test_truth_tracking_gsf[odd]__tracksummary_gsf.root: ee806a7cddbc4bd41a74dceead569762954e8161af221ad60d637c6264e41752 @@ -44,19 +44,19 @@ test_digitization_example_input[smeared]__particles.root: 5fe7dda2933ee6b9615b06 test_digitization_example_input[smeared]__measurements.root: 02a12e9949da9ba40b0120462d822f89e55562956fe3811981bdfd8648b7d946 test_digitization_example_input[geometric]__particles.root: 5fe7dda2933ee6b9615b064d192322fe07831133cd998e5ed99a3b992b713a10 test_digitization_example_input[geometric]__measurements.root: 919abc40e61811bb1c591b6b5125594b922fd5a4bfd65d6b9f653e6a9292f662 -test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: c58d0323826464ed34afabae43376805a06aebf0a56efacc8dcaa648fac4c0aa -test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: 63c3079d447776ef5b6f41be19932baf1f1bec3c5bbb287e4766826fa0a49c41 +test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: 66fbe62b5294c95ab6ea74861e2413b926c3cd5f0a8a53cf8c2d69bc1fb2986f +test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: b8ddfc25b013ec181e2a9f77925b86e57528140ccb6250696a9869272e1afa10 test_ckf_tracks_example[generic-full_seeding]__performance_seeding_trees.root: 0e0676ffafdb27112fbda50d1cf627859fa745760f98073261dcf6db3f2f991e -test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: c685405a17554eae17547a28e83bebefc0633e99eb22af5289bb8e2ce5e7176f -test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 4996336963dfde1e2371be1a3d3ace5e758b96dbab3153d406c1e3dcc6edae0b +test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: 8599106b114828187b416226eae86e9b4eeab5f32f0c4b4b1d963ef3735a5b8a +test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 2fab4f59cc4c919cb2449b1a335701d2a417782dfa38b233f68495c002308a64 test_ckf_tracks_example[generic-truth_estimated]__performance_seeding.root: 1facb05c066221f6361b61f015cdf0918e94d9f3fce2269ec7b6a4dffeb2bc7e -test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: 89a284d518849eec0448e6cf41a2ca8d8deae3e9f8f913ca9ee3a17d422c8c0e +test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: a3b90fbf1c2e2bca49922b89396eb449ac6560032efdffc67f0b6da6d1511322 test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: 472cd838f89f11498211f6f4d4412a21992fa1d76a511f3299e50cc5cb1d5ea3 -test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 3c9a5a14b29c57e98966a29a6b1470957fbb2e3df4c639c7350b8258a6ca8038 -test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 94854ad91323a6b17e1d9ede841722f6f38d18a42ce48c7adad5e9f244fd0249 +test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 7023586366bcdf180a117953633e04dbb1f72bd3b6c042c2f5e392eafdc553d1 +test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 331758a5c689733302eda21571ced8b3c3c513834f276ab31c0872f35e646d34 test_ckf_tracks_example[odd-full_seeding]__performance_seeding_trees.root: 43c58577aafe07645e5660c4f43904efadf91d8cda45c5c04c248bbe0f59814f -test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: e413b327de467587cc1d6bf291bb1ed9ba7748e42067995cc0d5cf6eea916d56 -test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: bc98c730f9a75dc0b361d39bc537cf6618327629851dd7efef69f8abe0719a84 +test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: 6cc679a67e547193728d7dcb6f4cded6db18f6fabfe9e0fcc46c2780676a78d4 +test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 5611ea2a2aef8fcd3c159acddf011d62bc5d4a8b8a04e87941f5044dadeaac80 test_ckf_tracks_example[odd-truth_estimated]__performance_seeding.root: 1a36b7017e59f1c08602ef3c2cb0483c51df248f112e3780c66594110719c575 test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: 22e6d12dcbdca5bc7492c5e073cd7759b61653f9cd5eb43a26a8a3525424f62a test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: e2aaf2bdafb5757698ee7a1db542c4612ab35ea305dbfb7908dc204974a85ffe @@ -65,8 +65,8 @@ test_vertex_fitting_reading[Iterative-False-100]__performance_vertexing.root: 60 test_vertex_fitting_reading[Iterative-True-100]__performance_vertexing.root: e34f217d524a5051dbb04a811d3407df3ebe2cc4bb7f54f6bda0847dbd7b52c3 test_vertex_fitting_reading[AMVF-False-100]__performance_vertexing.root: 009e4b1687f755e835aa46a4742233e3f336413bc039fa2ac4003ad1d48266e4 test_vertex_fitting_reading[AMVF-True-100]__performance_vertexing.root: 2d0dc1e02bfd1f7eaae26ef8ac657ce0291f70c7e4efddd35d171d31988a631e -test_bfield_writing__solenoid.root: 7ab4d298cd1657c93c90ad7759ea536ad93f52b11cc90f8e3abe611b9cf13234 -test_bfield_writing__solenoid2.root: 948435fab0d2d23b61884acb44e150adc6ab7b432dc41e4e03ae289d8ac30224 +test_bfield_writing__solenoid.root: 7be51f0ed9cb99f59ae0271ba79cdb84635e6ee3d2109ea8a4b521875029c21d +test_bfield_writing__solenoid2.root: 2db149336c9cd749dc50025076b49f9bc0586d53792b87a0fdd7f21a649a01a5 test_root_prop_step_writer[configPosConstructor]__prop_steps.root: 02460dea7b0b56b501223e08eeb7a0f087cdf19d0dd6da95a7ac7de2fe95bdd4 test_root_prop_step_writer[configKwConstructor]__prop_steps.root: 02460dea7b0b56b501223e08eeb7a0f087cdf19d0dd6da95a7ac7de2fe95bdd4 test_root_prop_step_writer[kwargsConstructor]__prop_steps.root: 02460dea7b0b56b501223e08eeb7a0f087cdf19d0dd6da95a7ac7de2fe95bdd4 diff --git a/Examples/Python/tests/test_misc.py b/Examples/Python/tests/test_misc.py new file mode 100644 index 00000000000..066fd4c999f --- /dev/null +++ b/Examples/Python/tests/test_misc.py @@ -0,0 +1,59 @@ +from pathlib import Path +import os +import json +import functools +import tarfile +import urllib.request +import subprocess +import sys +import re +import collections + +import pytest + +from helpers import ( + geant4Enabled, + rootEnabled, + dd4hepEnabled, + hepmc3Enabled, + pythia8Enabled, + exatrkxEnabled, + onnxEnabled, + AssertCollectionExistsAlg, + failure_threshold, +) + + +def test_gsf_debugger(tmp_path): + path = ( + Path(__file__).parent.parent.parent.parent + / "Examples" + / "Scripts" + / "GsfDebugger" + ) + scriptdir = ( + Path(__file__).parent.parent.parent.parent / "Examples" / "Scripts" / "Python" + ) + + gsf_script = path / "make_gsf_verbose_log.py" + assert gsf_script.exists() + + debugger = path / "src/main.py" + assert debugger.exists() + + env = os.environ.copy() + env["PYTHONPATH"] = f"{scriptdir}:{env['PYTHONPATH']}" + gsf_result = subprocess.run( + [gsf_script], capture_output=True, cwd=tmp_path, env=env + ) + + logfile = tmp_path / "test.log" + with open(logfile, "w") as f: + f.write(gsf_result.stdout.decode("utf8")) + + assert gsf_result.returncode == 0 + + debugger_result = subprocess.run( + [debugger, f"--logfile={logfile}", "--nogui"], cwd=tmp_path + ) + assert debugger_result.returncode == 0 diff --git a/Examples/Scripts/GsfDebugger/README.md b/Examples/Scripts/GsfDebugger/README.md new file mode 100644 index 00000000000..915f70510ef --- /dev/null +++ b/Examples/Scripts/GsfDebugger/README.md @@ -0,0 +1,27 @@ +# GSF Debugger + +This is a (not so) tiny tool that should ease inspecting the very complicated GSF logs. +The infrastructure is designed to be generic and extendable, so it should be not too much of an effort to adapt it e.g. to the CKF. + +**Important:** This tool is probably quite unstable, especially the log parsing. However, the code is not so complicated, if you encounter problems, just fix the issue :) + +## Usage + +The debugger can used with a saved VERBOSE log file of a **single** trackfit: +```bash +python src/main.py --log=mylog.txt +``` + +Another option is to pipe it to the process: +```bash +./my_gsf_run_script.sh | python src/main.py +``` + +Further options can be found with +```bash +python src/main.py --help +``` + +## Further reading + +See also in the documentation: put-link-here diff --git a/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py b/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py new file mode 100755 index 00000000000..c72e183feae --- /dev/null +++ b/Examples/Scripts/GsfDebugger/make_gsf_verbose_log.py @@ -0,0 +1,49 @@ +#!/bin/python3 +import sys +from pathlib import Path +import os + +import acts +import acts.examples + +from truth_tracking_gsf import runTruthTrackingGsf + +u = acts.UnitConstants + +if __name__ == "__main__": + field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) + + srcdir = Path(__file__).resolve().parent.parent.parent.parent + digiConfigFile = ( + srcdir + / "Examples/Algorithms/Digitization/share/default-smearing-config-generic.json" + ) + assert digiConfigFile.exists() + + detector, trackingGeometry, decorators = acts.examples.GenericDetector.create() + + field = acts.ConstantBField(acts.Vector3(0, 0, 2 * u.T)) + + seq = acts.examples.Sequencer( + events=1, + numThreads=1, + trackFpes=False, + logLevel=acts.logging.VERBOSE, + ) + + seq.addWriter( + acts.examples.CsvTrackingGeometryWriter( + level=acts.logging.INFO, + trackingGeometry=trackingGeometry, + outputDir=Path.cwd(), + writePerEvent=False, + ) + ) + + runTruthTrackingGsf( + s=seq, + trackingGeometry=trackingGeometry, + field=field, + digiConfigFile=digiConfigFile, + outputDir=Path.cwd(), + ).run() diff --git a/Examples/Scripts/GsfDebugger/requirements.txt b/Examples/Scripts/GsfDebugger/requirements.txt new file mode 100644 index 00000000000..957f1d2746b --- /dev/null +++ b/Examples/Scripts/GsfDebugger/requirements.txt @@ -0,0 +1,6 @@ +matplotlib==3.8.4 +numpy==2.0.0 +pandas==2.2.2 +PyQt5==5.15.10 +PyQt5_sip==12.13.0 +scipy==1.13.1 diff --git a/Examples/Scripts/GsfDebugger/src/drawers.py b/Examples/Scripts/GsfDebugger/src/drawers.py new file mode 100644 index 00000000000..c9571f72c38 --- /dev/null +++ b/Examples/Scripts/GsfDebugger/src/drawers.py @@ -0,0 +1,158 @@ +import numpy as np +import pandas as pd + +detector_color = "grey" + + +class ViewDrawer: + """ + Base class for a drawer that encapsulates drawing the state with a certain view (x-y, z-r, ...) + """ + + def draw_detector(self, ax): + ax = self.draw_detector_impl(ax) + ax.set_title("{}-{} plot".format(self.coor0, self.coor1)) + ax.set_ylabel(self.coor1) + ax.set_xlabel(self.coor0) + return ax + + def plot(self, ax, values, title_appendix="", **kwargs): + ax.plot(self.get_coor0(values), self.get_coor1(values), **kwargs) + ax.set_title("{}-{} plot: {}".format(self.coor0, self.coor1, title_appendix)) + return ax + + def scatter(self, ax, values, title_appendix="", **kwargs): + ax.scatter(self.get_coor0(values), self.get_coor1(values), **kwargs) + return ax + + def annotate(self, ax, position_3d, text): + l = np.array([position_3d]) + position_2d = (self.get_coor0(l), self.get_coor1(l)) + ax.annotate(text, position_2d) + return ax + + def set_title(self, ax, title_appendix=""): + ax.set_title("{}-{} plot: {}".format(self.coor0, self.coor1, title_appendix)) + return ax + + +class ZRDrawer(ViewDrawer): + """ + Base class for a z-r drawer + """ + + def __init__(self): + self.coor0 = "z" + self.coor1 = "r" + + def get_coor0(self, values): + return values[:, 2] + + def get_coor1(self, values): + return np.hypot(values[:, 0], values[:, 1]) + + +class XYDrawer(ViewDrawer): + """ + Base class for a x-y drawer + """ + + def __init__(self): + self.coor0 = "x" + self.coor1 = "y" + + def get_coor0(self, values): + return values[:, 0] + + def get_coor1(self, values): + return values[:, 1] + + +class XZDrawer(ViewDrawer): + """ + Base class for a x-z drawer + """ + + def __init__(self): + self.coor0 = "x" + self.coor1 = "z" + + def get_coor0(self, values): + return values[:, 0] + + def get_coor1(self, values): + return values[:, 2] + + +# Helper to unify code for drawers not involve radius +class CsvCartesianDrawer: + def __init__(self, detector_csv, centers, bounds=None): + super().__init__() + d = pd.read_csv(detector_csv) + d["cr"] = np.hypot(d["cx"], d["cy"]) + + l = len(d) + + # millimeter precision should be enough + for c in centers: + d[c] = d[c].astype(int) + + d = d.drop_duplicates(centers).copy() + print("INFO CsvCartesianDrawer", centers, "dup drop", l, "->", len(d)) + self.points = d[centers].to_numpy() + + # assumes x axis is telescope axis + self.simple_telescope = bounds is not None + if self.simple_telescope: + self.bounds = d[bounds].to_numpy() + + def draw_detector_impl(self, ax): + if not self.simple_telescope: + ax.scatter(self.points[:, 0], self.points[:, 1], color=detector_color, s=1) + else: + for point, bound in zip(self.points, self.bounds): + ax.plot( + [point[0], point[0]], + [point[1] + bound[0], point[1] + bound[1]], + color=detector_color, + zorder=0.5, + ) + + return ax + + +class CsvXYDrawer(XYDrawer): + def __init__(self, detector_csv, assume_telescope=False): + super().__init__() + if assume_telescope: + self.drawer = CsvCartesianDrawer( + detector_csv, ["cx", "cy"], ["bound_param1", "bound_param3"] + ) + else: + self.drawer = CsvCartesianDrawer(detector_csv, ["cx", "cy"]) + + def draw_detector_impl(self, ax): + return self.drawer.draw_detector_impl(ax) + + +class CsvXZDrawer(XZDrawer): + def __init__(self, detector_csv, assume_telescope=False): + super().__init__() + if assume_telescope: + self.drawer = CsvCartesianDrawer( + detector_csv, ["cx", "cz"], ["bound_param0", "bound_param2"] + ) + else: + self.drawer = CsvCartesianDrawer(detector_csv, ["cx", "cz"]) + + def draw_detector_impl(self, ax): + return self.drawer.draw_detector_impl(ax) + + +class CsvZRDrawer(ZRDrawer): + def __init__(self, detector_csv): + super().__init__() + self.drawer = CsvCartesianDrawer(detector_csv, ["cz", "cr"]) + + def draw_detector_impl(self, ax): + return self.drawer.draw_detector_impl(ax) diff --git a/Examples/Scripts/GsfDebugger/src/main.py b/Examples/Scripts/GsfDebugger/src/main.py new file mode 100755 index 00000000000..81712c5e4d4 --- /dev/null +++ b/Examples/Scripts/GsfDebugger/src/main.py @@ -0,0 +1,87 @@ +#!/bin/env python3 +import argparse +import os +import sys +import copy + +from processors import ( + AverageTrackPlotter, + ComponentsPlotter, + MomentumGraph, + BoundParametersProcessor, +) + + +def main(): + # fmt: off + parser = argparse.ArgumentParser(description='GSF Debugger') + parser.add_argument('--detector', '-d', help="detector description as csv file", type=str) + parser.add_argument('--logfile', '-f', help="log file (if not given, stdin is read)", type=str) + parser.add_argument('--nogui', action="store_true", default=False, help="for testing the log parsing (works without Qt)") + parser.add_argument('--view', choices=["cylindrical", "telescope"], default="cylindrical", help="cylindrical=zr+xy, telescope=zx,xy") + # fmt: on + args = vars(parser.parse_args()) + + # Try to be smart an load the detectors.csv from the current working dir if possible + if args["detector"] is None and "detectors.csv" in os.listdir(): + args["detector"] = "detectors.csv" + + # If no logfile is given, read from stdin (for piping) + if args["logfile"] is not None: + with open(args["logfile"], "r") as f: + lines = f.readlines() + else: + print("Read from standard input...") + lines = sys.stdin.readlines() + + # Group the log into steps to forward it to the processors + # TODO this is maybe not super reliable and also highly GSF specific + steps = [] + current_step = [] + for line in lines: + if line.count("at mean position") == 1: + steps.append(copy.deepcopy(current_step)) + current_step = [] + + current_step.append(line) + + # Initialize the drawers + if args["nogui"]: + drawers = None + else: + from drawers import CsvZRDrawer, CsvXYDrawer, CsvXZDrawer + + if args["view"] == "cylindrical": + drawers = [CsvZRDrawer(args["detector"]), CsvXYDrawer(args["detector"])] + elif args["view"] == "telescope": + drawers = [ + CsvXZDrawer(args["detector"], assume_telescope=True), + CsvXYDrawer(args["detector"], assume_telescope=True), + ] + + # Initialize the processors + processors = [ + AverageTrackPlotter(drawers), + ComponentsPlotter(drawers), + MomentumGraph(), + BoundParametersProcessor("Predicted"), + BoundParametersProcessor("Filtered"), + ] + + # Parse the step in each processor + for step in steps: + for processor in processors: + processor.parse_step(step) + + # Run the Qt app + if not args["nogui"]: + from PyQt5 import QtWidgets + from widgets import MainWindow + + app = QtWidgets.QApplication(sys.argv) + w = MainWindow(processors, steps) + app.exec_() + + +if __name__ == "__main__": + main() diff --git a/Examples/Scripts/GsfDebugger/src/processors.py b/Examples/Scripts/GsfDebugger/src/processors.py new file mode 100644 index 00000000000..3d42d06c123 --- /dev/null +++ b/Examples/Scripts/GsfDebugger/src/processors.py @@ -0,0 +1,446 @@ +import traceback +import re +import copy +import sys +from itertools import cycle + +import numpy as np + +# This should allow to run the non-gui mode in the CI +try: + from matplotlib.pyplot import subplots +except: + + def subplots(*args, **kwargs): + raise RuntimeError("Matplotlib could not be imported") + + +class AverageTrackPlotter: + def __init__(self, view_drawers, annotate_steps=False): + self.annotate_steps = annotate_steps + + self.positions = [] + self.ibackward = None + + self.view_drawers = view_drawers + + def parse_step(self, step): + for line in step: + if line.count("Do backward propagation") == 1: + self.ibackward = len(self.positions) + + elif line.count("at mean position") == 1: + line = re.sub(r"^.*position", "", line) + line = re.sub(r"with.*$", "", line) + + self.positions.append(np.array([float(item) for item in line.split()])) + + def name(self): + return "Average track" + + def get_figure_axes(self): + return subplots(1, len(self.view_drawers)) + + def draw(self, fig, axes, step): + for ax, drawer in zip(axes, self.view_drawers): + ax = drawer.draw_detector(ax) + + fwd_to_plot = self.positions[: self.ibackward] + bwd_to_plot = self.positions[self.ibackward :] + + if step < len(fwd_to_plot): + fwd_to_plot = fwd_to_plot[:step] + bwd_to_plot = [] + else: + bwd_steps = step - len(fwd_to_plot) + bwd_to_plot = bwd_to_plot[:bwd_steps] + + positions = [fwd_to_plot, bwd_to_plot] + names = ["forward", "backward"] + + for positions, direction in zip(positions, names): + if len(positions) == 0: + continue + + positions = np.vstack(positions) + + for ax, drawer in zip(axes, self.view_drawers): + ax = drawer.plot(ax, positions, label=direction, marker="x", lw=1) + + if self.annotate_steps: + for i, p in enumerate(positions): + ax = drawer.annotate(ax, p, str(i)) + + ax = drawer.set_title(ax) + ax.legend() + + fig.tight_layout() + return fig, axes + + +class ComponentsPlotter: + def __init__(self, view_drawers): + self.current_direction = "forward" + self.steps = [] + + self.view_drawers = view_drawers + + self.colors = [ + "red", + "orangered", + "orange", + "gold", + "olive", + "forestgreen", + "lime", + "teal", + "cyan", + "blue", + "indigo", + "magenta", + "brown", + ] + + def parse_step(self, step): + surface_name = None + component_sets = [] + components = [] + + for line in step: + if line.count("Step is at surface") == 1: + surface_name = line[line.find("vol") :] + + elif line.count("Do backward propagation") == 1: + self.current_direction = "backward" + + elif re.match(r"^.*#[0-9]+\spos", line): + line = line.replace(",", "") + splits = line.split() + + current_cmp = int(splits[3][1:]) + pos = np.array([float(part) for part in splits[5:8]]) + + # There can be two sets of components printed in a step + if current_cmp < len(components): + component_sets.append(copy.deepcopy(components)) + components = [] + + components.append(pos) + + component_sets.append(copy.deepcopy(components)) + assert len(component_sets) <= 2 + + self.steps.append( + ( + surface_name, + self.current_direction, + component_sets, + ) + ) + + def name(self): + return "Components" + + def get_figure_axes(self): + return subplots(1, len(self.view_drawers)) + + def number_steps(self): + return sum([len(s[3]) for s in self.stages]) + + def draw(self, fig, axes, requested_step): + kSurface = 0 + kDirection = 1 + kComponents = 2 + + for ax, drawer in zip(axes, self.view_drawers): + ax = drawer.draw_detector(ax) + + if requested_step >= len(self.steps): + fig.suptitle("Step out of range") + return fig, axes + + n_components = len(self.steps[requested_step][kComponents][-1]) + + # go back to last surface + start_surface = "" + positions = [] + for si in range(requested_step, 0, -1): + if len(self.steps[si][kComponents][-1]) != n_components: + fig.suptitle("error: component number mismatch") + return fig, axes + positions.append(self.steps[si][kComponents][-1]) + + if self.steps[si][kSurface] is not None: + start_surface = self.steps[si][kSurface] + break + + fig.suptitle( + "Stepping {} with {} components from {}".format( + self.steps[requested_step][kDirection], + n_components, + start_surface.strip(), + ) + ) + + n_steps = len(positions) + if n_steps == 0: + return fig, axes + + try: + positions = np.array(positions) + assert len(positions.shape) == 3 + + assert positions.shape[0] == n_steps + assert positions.shape[1] == n_components + assert positions.shape[2] == 3 + + for i, color in zip(range(n_components), cycle(self.colors)): + for ax, drawer in zip(axes, self.view_drawers): + ax = drawer.plot(ax, positions[:, i, :], c=color, marker="x", lw=1) + except: + fig.suptitle("Error drawing") + import pprint + + pprint.pprint(positions) + + fig.tight_layout() + return fig, axes + + +class GsfMomentumRecorder: + def __init__(self): + # Global state + self.gsf_started_backwards = False + self.gsf_accumulated_pathlength = 0 + self.printed_qop_warning = False + + # Recordings + self.gsf_momenta = [] + self.gsf_cmp_data = [] + self.gsf_pathlengths = [] + + # Current step + self.gsf_current_step_cmp_momenta = [] + self.gsf_current_step_cmp_weights = [] + self.gsf_have_momentum = False + self.gsf_last_step_number = None + + def parse_line(self, line): + if line.count("Gsf step") == 1: + # Last step appears twice in log, prevent this + if int(line.split()[5]) == self.gsf_last_step_number: + return + + self.gsf_last_step_number = int(line.split()[5]) + + # Update component states if not in first step + if len(self.gsf_current_step_cmp_momenta) > 0: + self.gsf_cmp_data.append( + ( + self.gsf_current_step_cmp_momenta, + self.gsf_current_step_cmp_weights, + ) + ) + self.gsf_current_step_cmp_momenta = [] + self.gsf_current_step_cmp_weights = [] + + # Save momentum + assert len(self.gsf_momenta) == len(self.gsf_pathlengths) + self.gsf_momenta.append(float(line.split()[-4])) + self.gsf_have_momentum = True + + elif re.match(r"^.*#[0-9]+\spos", line) and not self.gsf_started_backwards: + line = line.replace(",", "") + qop = float(line.split()[-3]) + p = abs(1 / qop) + w = float(line.split()[-7]) + self.gsf_current_step_cmp_momenta.append(p) + self.gsf_current_step_cmp_weights.append(w) + + elif line.count("Step with size") == 1: + self.gsf_accumulated_pathlength += float(line.split()[-2]) + + if self.gsf_have_momentum: + self.gsf_have_momentum = False + self.gsf_pathlengths.append(self.gsf_accumulated_pathlength) + assert len(self.gsf_pathlengths) == len(self.gsf_momenta) + + +class MomentumGraph: + def __init__(self): + self._flipped = False + + self.momenta = [] + self.pathlenghts = [] + self.iBackward = None + + def parse_step(self, step): + mom = None + pl = None + + for line in step: + if line.count("Gsf step") == 1: + mom = float(line.split()[-4]) + + elif line.count("Step with size") == 1: + pl = float(line.split()[-2]) + + if line.count("Do backward") == 1: + self.iBackward = len(self.momenta) + + if mom is None or pl is None: + return + + self.momenta.append(mom) + self.pathlenghts.append(pl) + + def name(self): + return "Momentum" + + def get_figure_axes(self): + return subplots() + + def draw(self, fig, ax, requested_step): + fwd_mom, bwd_mom, fwd_pls, bwd_pls = [], [], [], [] + + if self.iBackward is None: + fwd_mom = self.momenta + fwd_pls = self.pathlenghts + else: + fwd_mom = self.momenta[: self.iBackward] + fwd_pls = self.pathlenghts[: self.iBackward] + + bwd_mom = self.momenta[self.iBackward :] + bwd_pls = self.pathlenghts[self.iBackward :] + + fwd_pls = np.cumsum(fwd_pls) + ax.plot(fwd_pls, fwd_mom, color="tab:blue") + + bwd_pls = np.cumsum(bwd_pls) + bwd_pls = max(abs(bwd_pls)) + bwd_pls + ax.plot(bwd_pls, bwd_mom, color="tab:orange") + + if requested_step < self.iBackward: + ax.vlines( + fwd_pls[requested_step], *ax.get_ylim(), alpha=0.5, color="tab:blue" + ) + else: + s = requested_step - self.iBackward + if s < len(bwd_pls): + ax.vlines(bwd_pls[s], *ax.get_ylim(), alpha=0.5, color="tab:orange") + + +class BoundParametersProcessor: + def __init__(self, key): + assert key == "Filtered" or key == "Predicted" + self.key = key + self.pars_pattern = "^.*" + self.key + " parameters:(.*)$" + self.cov_preamble = "^.*" + self.key + " covariance:$" + + self.step_data = [] + + def parse_step(self, step): + weights = [] + parameters = [] + covs = [] + for i in range(len(step)): + line = step[i] + + m = re.match(r"^.*weight: (.*), status:.*$", line) + if m: + weights.append(float(m[1])) + + if not ( + f"{self.key} parameters" in line or f"{self.key} covariance" in line + ): + continue + + m = re.match(self.pars_pattern, line) + if m: + pars = np.array([float(f) for f in m[1].split()]) + assert len(pars) == 6 + parameters.append(pars) + continue + + m = re.match(self.cov_preamble, line) + + if m: + cov = [] + for j in range(i + 1, i + 7): + cov.append([float(f) for f in step[j].split()]) + covs.append(np.array(cov)) + assert covs[-1].shape == (6, 6) + i = i + 6 + + assert len(parameters) == len(covs) + assert len(weights) >= len(parameters) + if len(parameters) > 0: + self.step_data.append((weights[: len(parameters)], parameters, covs)) + else: + self.step_data.append(None) + + def name(self): + return f"{self.key} state" + + def get_figure_axes(self): + return subplots(2, 3) + + def draw(self, fig, axes, requested_step): + import scipy + + if requested_step >= len(self.step_data): + fig.suptitle("Error: Step out of bound") + return fig, axes + + if self.step_data[requested_step] is None: + fig.suptitle("nothing to draw, not on surface") + return fig, axes + + ws, pars, covs = self.step_data[requested_step] + + w_str = ", ".join([f"{w:.2f}" for w in ws]) + fig.suptitle(f"draw {len(ws)} components\nweights: {w_str}") + + j_max = np.argmax(ws) + + for i, (ax, title) in enumerate( + zip(axes.flatten(), ["l0", "l1", "theta", "phi", "qop", "t"]) + ): + cmps = [(ws[j], pars[j][i], covs[j][i, i]) for j in range(len(ws))] + + # minx = min([ m[1]-3*np.sqrt(m[2]) for m in cmps ]) + # maxx = max([ m[1]+3*np.sqrt(m[2]) for m in cmps ]) + minx = cmps[j_max][1] - 3 * np.sqrt(cmps[j_max][2]) + maxx = cmps[j_max][1] + 3 * np.sqrt(cmps[j_max][2]) + + minx = min(minx, min([m[1] for m in cmps if m[0] > 0.05])) + maxx = max(maxx, max([m[1] for m in cmps if m[0] > 0.05])) + + # minx = pars[0][i]-3*covs[0] + mixture = lambda x: sum( + [ + w * scipy.stats.norm(loc=mu, scale=np.sqrt(var)).pdf(x) + for w, mu, var in cmps + ] + ) + + x = np.linspace(minx, maxx, 200) + y = sum( + [ + w * scipy.stats.norm(loc=mu, scale=np.sqrt(var)).pdf(x) + for w, mu, var in cmps + ] + ) + + if len(ws) > 1: + for w, mu, var in cmps: + ax.plot( + x, w * scipy.stats.norm(loc=mu, scale=np.sqrt(var)).pdf(x), lw=1 + ) + + ax.plot(x, y, lw=3, color="black") + # ax.plot(x, [ scipy.stats.norm(loc=pars[0][i], scale=np.sqrt(covs[0][i,i])).pdf(xx) for xx in x]) + ax.set_title(title) + + fig.tight_layout() + return fig, ax diff --git a/Examples/Scripts/GsfDebugger/src/widgets.py b/Examples/Scripts/GsfDebugger/src/widgets.py new file mode 100644 index 00000000000..92e54e37a32 --- /dev/null +++ b/Examples/Scripts/GsfDebugger/src/widgets.py @@ -0,0 +1,161 @@ +import matplotlib + +matplotlib.use("QtAgg") + +from PyQt5 import QtCore, QtWidgets, QtGui + +from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg, NavigationToolbar2QT +from matplotlib.figure import Figure +import matplotlib.pyplot as plt + +from PyQt5 import QtCore, QtWidgets + + +class MatplotlibWidget(QtWidgets.QWidget): + """ + This widget is supposed to support a processor that renders its output to + a matplotlib figure. + For performance reasons, it only renders the content if the widget is_active. + """ + + def __init__(self, processor, parent=None): + super(MatplotlibWidget, self).__init__() + self.processor = processor + self.fig, self.axes = processor.get_figure_axes() + + self.canvas = FigureCanvasQTAgg(self.fig) + toolbar = NavigationToolbar2QT(self.canvas, self) + + self.layout = QtWidgets.QVBoxLayout() + self.layout.addWidget(toolbar) + self.layout.addWidget(self.canvas) + self.setLayout(self.layout) + + self.is_active = False + + def change_step(self, step): + try: + for ax in self.axes.flatten(): + ax.cla() + except: + self.axes.cla() + + if self.is_active: + self.processor.draw(self.fig, self.axes, step) + self.canvas.draw() + + +class LogWidget(QtWidgets.QTextEdit): + """ + This is a widget dedicated to rendering the log + of a certain step. + """ + + def __init__(self, steps, parent=None): + super(LogWidget, self).__init__() + self.steps = steps + + font = QtGui.QFont() + font.setFamily("monospace [Consolas]") + font.setFixedPitch(True) + font.setStyleHint(QtGui.QFont.TypeWriter) + + self.setFont(font) + self.setReadOnly(True) + self.setLineWrapMode(QtWidgets.QTextEdit.NoWrap) + + def change_step(self, step): + if step >= len(self.steps): + self.setText(f"Error: cannot display log for step {step}") + else: + self.setText("".join(self.steps[step])) + + +class MainWindow(QtWidgets.QWidget): + """ + This is the main window. It sets the gui up etc. + Most importantly, it calls .step_changed() on the active tab-widget + if the step-slider has changed + """ + + def __init__(self, processors, steps, *args, **kwargs): + super(MainWindow, self).__init__(*args, **kwargs) + self.setWindowTitle("GSF Debugger") + + layout = QtWidgets.QVBoxLayout() + + # Step label + self.label = QtWidgets.QLabel("step: 0", self) + layout.addWidget(self.label) + + # Slider + self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) + self.slider.setMinimum(0) + self.slider.setMaximum(len(steps)) + self.slider.valueChanged.connect(self.step_changed) + + def disable(): + for p in self.processor_widgets: + if hasattr(p, "is_active"): + p.is_active = False + + self.slider.sliderPressed.connect(disable) + + def switch(i=None): + if i is None: + i = self.tabs.currentIndex() + for p in self.processor_widgets: + if hasattr(p, "is_active"): + p.is_active = False + if hasattr(self.processor_widgets[i], "is_active"): + self.processor_widgets[i].is_active = True + self.step_changed() + + self.slider.sliderReleased.connect(switch) + + def bwd(): + self.slider.setValue(max(self.slider.value() - 1, 0)) + self.step_changed() + + bwdBtn = QtWidgets.QPushButton("-") + bwdBtn.pressed.connect(bwd) + + def fwd(): + self.slider.setValue(min(self.slider.value() + 1, len(steps))) + self.step_changed() + + fwdBtn = QtWidgets.QPushButton("+") + fwdBtn.pressed.connect(fwd) + + hlayout = QtWidgets.QHBoxLayout() + hlayout.addWidget(bwdBtn, 1) + hlayout.addWidget(self.slider, 18) + hlayout.addWidget(fwdBtn, 1) + + layout.addLayout(hlayout) + + # Tabs + self.processor_widgets = [] + self.tabs = QtWidgets.QTabWidget(self) + for p in processors: + self.processor_widgets.append(MatplotlibWidget(p)) + self.tabs.addTab(self.processor_widgets[-1], p.name()) + + self.processor_widgets.append(LogWidget(steps)) + self.tabs.addTab(self.processor_widgets[-1], "Log") + self.tabs.currentChanged.connect(switch) + + layout.addWidget(self.tabs) + + # init + switch(0) + self.step_changed() + + # Finalize + self.setLayout(layout) + self.show() + + def step_changed(self): + self.label.setText(f"step: {self.slider.value()}") + for w in self.processor_widgets: + w.change_step(self.slider.value()) diff --git a/Examples/Scripts/Python/detector_creation.py b/Examples/Scripts/Python/detector_creation.py index b3d2e0f039f..6939ae9cb20 100644 --- a/Examples/Scripts/Python/detector_creation.py +++ b/Examples/Scripts/Python/detector_creation.py @@ -92,3 +92,5 @@ ) acts.examples.writeDetectorToJsonDetray(geoContext, detector, "odd-detray") + + # det_detector = acts.examples.DetrayConverter(geoContext, detector,"odd-detray") diff --git a/Examples/Scripts/TrackingPerformance/boundParamResolution.C b/Examples/Scripts/TrackingPerformance/boundParamResolution.C index c4d30aa8f0c..80baebd47f9 100644 --- a/Examples/Scripts/TrackingPerformance/boundParamResolution.C +++ b/Examples/Scripts/TrackingPerformance/boundParamResolution.C @@ -204,7 +204,7 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, float range = pullRange * h1_range->GetRMS(); ranges[ir] = range; } - if (! saveAs.empty()) { + if (!saveAs.empty()) { rangeCanvas->SaveAs( (vlIdCut[0] + std::string("res_ranges.") + saveAs).c_str()); } @@ -315,8 +315,8 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, // - per layer (identified by vol, lay) // - per volume (identified by vol, -1) // - overall (identified by lay) - for (auto [vol, layers] : volLayIds) { - for (auto lay : layers) { + for (const auto& [vol, layers] : volLayIds) { + for (const auto& lay : layers) { // Estimate the ranges from smoothed auto vlIdCut = volLayIdCut(vol, lay); auto ranges = histRanges(vlIdCut); @@ -562,7 +562,7 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, profiles[ipar]->Write(); } // Save the canvas: mean - if (! saveAs.empty()) { + if (!saveAs.empty()) { respull_mean_prf->SaveAs((std::string("all_") + res_pull + std::string("_mean_prf_") + type + std::string(".") + saveAs) @@ -602,7 +602,7 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, var->Write(); } // Save the canvas: pulls - if (! saveAs.empty()) { + if (!saveAs.empty()) { respull_var_prf->SaveAs((std::string("all_") + res_pull + std::string("_var_prf_") + type + std::string(".") + saveAs) @@ -632,8 +632,8 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, auto pulls = new TCanvas("pulls", "Pull distributions", 1200, 800); pulls->Divide(3, 2); - for (auto [vol, layers] : volLayIds) { - for (auto lay : layers) { + for (const auto& [vol, layers] : volLayIds) { + for (const auto& lay : layers) { auto vlID = volLayIdCut(vol, lay)[0]; // Residual plotting @@ -668,7 +668,7 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, legend->SetTextFont(42); legend->Draw(); } - if (! saveAs.empty()) { + if (!saveAs.empty()) { residuals->SaveAs((vlID + std::string("residuals.") + saveAs).c_str()); } @@ -769,7 +769,7 @@ int boundParamResolution(const std::string& inFile, const std::string& treeName, } // Save the Canvases as pictures - if (! saveAs.empty()) { + if (!saveAs.empty()) { pulls->SaveAs((vlID + std::string("pulls.") + saveAs).c_str()); } } diff --git a/Fatras/CMakeLists.txt b/Fatras/CMakeLists.txt index 6ae0048f63f..1fdfe72e961 100644 --- a/Fatras/CMakeLists.txt +++ b/Fatras/CMakeLists.txt @@ -17,7 +17,7 @@ target_include_directories( ActsFatras PUBLIC $ - $) + $) target_link_libraries( ActsFatras PUBLIC ActsCore) @@ -30,5 +30,5 @@ install( install( DIRECTORY include/ActsFatras DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - + add_component_if(Geant4 FatrasGeant4 ACTS_BUILD_FATRAS_GEANT4) diff --git a/Fatras/Geant4/CMakeLists.txt b/Fatras/Geant4/CMakeLists.txt index d2f318d47bd..e9912af1d97 100644 --- a/Fatras/Geant4/CMakeLists.txt +++ b/Fatras/Geant4/CMakeLists.txt @@ -13,7 +13,7 @@ target_include_directories( ActsFatrasGeant4 PUBLIC $ - $) + $) target_link_libraries( ActsFatrasGeant4 PUBLIC ActsCore ActsFatras ${Geant4_LIBRARIES}) diff --git a/Fatras/src/Digitization/Segmentizer.cpp b/Fatras/src/Digitization/Segmentizer.cpp index 76467ebd220..9c2bb72c972 100644 --- a/Fatras/src/Digitization/Segmentizer.cpp +++ b/Fatras/src/Digitization/Segmentizer.cpp @@ -116,7 +116,8 @@ ActsFatras::Segmentizer::segments(const Acts::GeometryContext& geoCtx, } // The phi boundaries if (bstart[1] != bend[1]) { - double referenceR = surface.binningPositionValue(geoCtx, Acts::binR); + double referenceR = + surface.binningPositionValue(geoCtx, Acts::BinningValue::binR); Acts::Vector2 origin = {0., 0.}; const auto& phiboundaries = segmentation.binningData()[1].boundaries(); std::vector phibbounds = { diff --git a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/GridSvgConverter.hpp b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/GridSvgConverter.hpp index 1b11badec5c..96076d50377 100644 --- a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/GridSvgConverter.hpp +++ b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/GridSvgConverter.hpp @@ -70,7 +70,7 @@ ProtoGrid convert(const grid_type& grid, // 1D case (more to be filled in later) if constexpr (grid_type::DIM == 1u) { - if (bValues[0u] == binPhi && + if (bValues[0u] == BinningValue::binPhi && axes[0]->getBoundaryType() == AxisBoundaryType::Closed) { // swap needed edges1 = axes[0]->getBinEdges(); @@ -78,7 +78,7 @@ ProtoGrid convert(const grid_type& grid, } if (cOptions.optionalBound.has_value()) { auto [boundRange, boundValue] = cOptions.optionalBound.value(); - if (boundValue == binR) { + if (boundValue == BinningValue::binR) { // good - no swap needed edges0 = {boundRange[0u], boundRange[1u]}; } @@ -89,21 +89,26 @@ ProtoGrid convert(const grid_type& grid, // Assign edges0 = axes[0]->getBinEdges(); edges1 = axes[1]->getBinEdges(); - if (bValues[0] == binPhi && bValues[1] == binZ) { + if (bValues[0] == BinningValue::binPhi && + bValues[1] == BinningValue::binZ) { // swap needed std::swap(edges0, edges1); pGrid._type = actsvg::proto::grid::e_z_phi; - } else if (bValues[0] == binPhi && bValues[1] == binR) { + } else if (bValues[0] == BinningValue::binPhi && + bValues[1] == BinningValue::binR) { // swap needed std::swap(edges0, edges1); pGrid._type = actsvg::proto::grid::e_r_phi; - } else if (bValues[0] == binZ && bValues[1] == binPhi) { + } else if (bValues[0] == BinningValue::binZ && + bValues[1] == BinningValue::binPhi) { // good - no swap needed pGrid._type = actsvg::proto::grid::e_z_phi; - } else if (bValues[0] == binR && bValues[1] == binPhi) { + } else if (bValues[0] == BinningValue::binR && + bValues[1] == BinningValue::binPhi) { // good - no swap needed pGrid._type = actsvg::proto::grid::e_r_phi; - } else if (bValues[0] == binX && bValues[1] == binY) { + } else if (bValues[0] == BinningValue::binX && + bValues[1] == BinningValue::binY) { // good - no swap needed pGrid._type = actsvg::proto::grid::e_x_y; } diff --git a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp index 4596067a828..ceb12c5acb0 100644 --- a/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp +++ b/Plugins/ActSVG/include/Acts/Plugins/ActSVG/IndexedSurfacesSvgConverter.hpp @@ -73,10 +73,11 @@ ProtoIndexedSurfaceGrid convertImpl(const GeometryContext& gctx, // Estimate the radial extension // - for 1D phi // - for 2D z-phi or phi-z - bool estimateR = - (index_grid::grid_type::DIM == 1 && indexGrid.casts[0u] == binPhi) || - (index_grid::grid_type::DIM == 2 && - (indexGrid.casts[0u] == binPhi || indexGrid.casts[1u] == binPhi)); + bool estimateR = (index_grid::grid_type::DIM == 1 && + indexGrid.casts[0u] == BinningValue::binPhi) || + (index_grid::grid_type::DIM == 2 && + (indexGrid.casts[0u] == BinningValue::binPhi || + indexGrid.casts[1u] == BinningValue::binPhi)); for (auto [is, s] : enumerate(surfaces)) { // Create the surface converter options @@ -91,9 +92,9 @@ ProtoIndexedSurfaceGrid convertImpl(const GeometryContext& gctx, if (estimateR) { auto sExtent = s->polyhedronRepresentation(gctx, 4u).extent(); if constexpr (index_grid::grid_type::DIM == 2u) { - pSurface._radii[0u] = sExtent.medium(binR); + pSurface._radii[0u] = sExtent.medium(BinningValue::binR); } - constrain.extend(sExtent, {binR}); + constrain.extend(sExtent, {BinningValue::binR}); } // Add center info std::string centerInfo = " - center = ("; @@ -113,10 +114,10 @@ ProtoIndexedSurfaceGrid convertImpl(const GeometryContext& gctx, // Adjust the grid options if constexpr (index_grid::grid_type::DIM == 1u) { - if (indexGrid.casts[0u] == binPhi) { - auto estRangeR = constrain.range(binR); + if (indexGrid.casts[0u] == BinningValue::binPhi) { + auto estRangeR = constrain.range(BinningValue::binR); std::array rRange = {estRangeR.min(), estRangeR.max()}; - gridOptions.optionalBound = {rRange, binR}; + gridOptions.optionalBound = {rRange, BinningValue::binR}; } } @@ -164,7 +165,7 @@ ProtoIndexedSurfaceGrid convertImpl(const GeometryContext& gctx, std::to_string(binCenter1) + ")"; pGrid._bin_ids.push_back(binInfo); if (estimateR) { - pGrid._reference_r = constrain.medium(binR); + pGrid._reference_r = constrain.medium(BinningValue::binR); } } } diff --git a/Plugins/ActSVG/src/LayerSvgConverter.cpp b/Plugins/ActSVG/src/LayerSvgConverter.cpp index f9ccb81b498..11cabd0e0e7 100644 --- a/Plugins/ActSVG/src/LayerSvgConverter.cpp +++ b/Plugins/ActSVG/src/LayerSvgConverter.cpp @@ -85,7 +85,8 @@ std::vector Acts::Svg::LayerConverter::convert( for (const auto& sf : layer.surfaceArray()->surfaces()) { // Surface center - const Acts::Vector3 rCenter = sf->binningPosition(gctx, Acts::binR); + const Acts::Vector3 rCenter = + sf->binningPosition(gctx, Acts::BinningValue::binR); const Acts::Vector3 sfCenter = sf->center(gctx); Acts::ActsScalar radius = Acts::VectorHelpers::perp(rCenter); Acts::ActsScalar phi = Acts::VectorHelpers::phi(rCenter); diff --git a/Plugins/ActSVG/src/PortalSvgConverter.cpp b/Plugins/ActSVG/src/PortalSvgConverter.cpp index 0d59a08c780..47ca4a12c1a 100644 --- a/Plugins/ActSVG/src/PortalSvgConverter.cpp +++ b/Plugins/ActSVG/src/PortalSvgConverter.cpp @@ -75,15 +75,15 @@ std::vector convertMultiLink( Acts::ActsScalar refC = 0.5 * (boundaries[il + 1u] + boundaries[il]); - if (bValue == Acts::binR) { + if (bValue == Acts::BinningValue::binR) { Acts::ActsScalar phi = Acts::VectorHelpers::phi(refPosition); position = Acts::Vector3(refC * std::cos(phi), refC * std::sin(phi), refPosition.z()); - } else if (bValue == Acts::binZ) { + } else if (bValue == Acts::BinningValue::binZ) { // correct to global refC += surface.transform(gctx).translation().z(); position[2] = refC; - } else if (bValue == Acts::binPhi) { + } else if (bValue == Acts::BinningValue::binPhi) { Acts::ActsScalar r = Acts::VectorHelpers::perp(refPosition); position = Acts::Vector3(r * std::cos(refC), r * std::sin(refC), refPosition.z()); diff --git a/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp b/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp index 976d1b6fd40..990cfdc75bb 100644 --- a/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp +++ b/Plugins/ActSVG/src/SurfaceArraySvgConverter.cpp @@ -48,25 +48,29 @@ Acts::Svg::SurfaceArrayConverter::convert( }; // Walk through the binning and translate - if (binning[0] == binPhi && binning[1] == binZ) { + if (binning[0] == BinningValue::binPhi && + binning[1] == BinningValue::binZ) { vType = cylinder; // flip to fit with actsvg convention edges1 = axes[0]->getBinEdges(); edges0 = axes[1]->getBinEdges(); pGrid._type = actsvg::proto::grid::e_z_phi; - } else if (binning[0] == binPhi && binning[1] == binR) { + } else if (binning[0] == BinningValue::binPhi && + binning[1] == BinningValue::binR) { vType = polar; // flip to fit with actsvg convention edges1 = axes[0]->getBinEdges(); edges0 = axes[1]->getBinEdges(); pGrid._type = actsvg::proto::grid::e_r_phi; - } else if (binning[0] == binZ && binning[1] == binPhi) { + } else if (binning[0] == BinningValue::binZ && + binning[1] == BinningValue::binPhi) { // good vType = cylinder; edges0 = axes[0]->getBinEdges(); edges1 = axes[1]->getBinEdges(); pGrid._type = actsvg::proto::grid::e_z_phi; - } else if (binning[0] == binR && binning[1] == binPhi) { + } else if (binning[0] == BinningValue::binR && + binning[1] == BinningValue::binPhi) { // good vType = polar; edges0 = axes[0]->getBinEdges(); diff --git a/Plugins/CMakeLists.txt b/Plugins/CMakeLists.txt index 93fa92a23e8..c961f82fd7f 100644 --- a/Plugins/CMakeLists.txt +++ b/Plugins/CMakeLists.txt @@ -10,6 +10,7 @@ add_component_if(Json PluginJson ACTS_BUILD_PLUGIN_JSON) add_component_if(Legacy PluginLegacy ACTS_BUILD_PLUGIN_LEGACY) add_component_if(Onnx PluginOnnx ACTS_BUILD_PLUGIN_ONNX) add_component_if(ExaTrkX PluginExaTrkX ACTS_BUILD_PLUGIN_EXATRKX) +add_component_if(Detray PluginDetray ACTS_BUILD_PLUGIN_DETRAY) # dependent plugins. depend either on a independent plugins or on one another add_component_if(TGeo PluginTGeo ACTS_BUILD_PLUGIN_TGEO) diff --git a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp index 10e2a0bcfa2..aa5ddabef2a 100644 --- a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp +++ b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp @@ -26,7 +26,11 @@ namespace Acts { static std::vector> allowedBinnings = { - {"x", binX}, {"y", binY}, {"z", binZ}, {"phi", binPhi}, {"r", binR}}; + {"x", BinningValue::binX}, + {"y", BinningValue::binY}, + {"z", BinningValue::binZ}, + {"phi", BinningValue::binPhi}, + {"r", BinningValue::binR}}; /// Helper method to convert the string to binning value /// @@ -35,15 +39,15 @@ static std::vector> allowedBinnings = { /// @return a binningValue inline BinningValue stringToBinningValue(const std::string &binningString) { if (binningString == "x") { - return binX; + return BinningValue::binX; } else if (binningString == "y") { - return binY; + return BinningValue::binY; } else if (binningString == "z") { - return binZ; + return BinningValue::binZ; } else if (binningString == "phi") { - return binPhi; + return BinningValue::binPhi; } else if (binningString == "r") { - return binR; + return BinningValue::binR; } else { throw std::invalid_argument("DD4hepBinningHelpers: Binning value " + binningString + " not allowed."); diff --git a/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp b/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp index 73a9794eed8..2b37ebc040f 100644 --- a/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp +++ b/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp @@ -36,14 +36,14 @@ Acts::DD4hepBinningHelpers::convertBinning( Experimental::ProtoBinning(bVal, bType, nBins, nExpansion)); } else { // Equidistant binning - ActsScalar minDefault = bVal == binPhi ? -M_PI : 0.; - ActsScalar maxDefault = bVal == binPhi ? M_PI : 0.; + ActsScalar minDefault = bVal == BinningValue::binPhi ? -M_PI : 0.; + ActsScalar maxDefault = bVal == BinningValue::binPhi ? M_PI : 0.; auto min = getParamOr(bname + "_" + ab + "_min", dd4hepElement, minDefault); auto max = getParamOr(bname + "_" + ab + "_max", dd4hepElement, maxDefault); // Check for closed phi binning - if (bVal == binPhi && (max - min) > 1.9 * M_PI) { + if (bVal == BinningValue::binPhi && (max - min) > 1.9 * M_PI) { bType = Acts::AxisBoundaryType::Closed; } protoBinnings.push_back(Experimental::ProtoBinning( @@ -57,7 +57,8 @@ Acts::DD4hepBinningHelpers::convertBinning( bname + "_" + ab + "_b" + std::to_string(ib), dd4hepElement, 0.)); } // Check for closed phi binning - if (bVal == binPhi && (edges.back() - edges.front()) > 1.9 * M_PI) { + if (bVal == BinningValue::binPhi && + (edges.back() - edges.front()) > 1.9 * M_PI) { bType = Acts::AxisBoundaryType::Closed; } protoBinnings.push_back( diff --git a/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp b/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp index dfc07bf71c3..351b5312af3 100644 --- a/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp +++ b/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp @@ -32,7 +32,7 @@ Acts::Experimental::DD4hepBlueprintFactory::create( // Create the root node std::vector bValues = {0., 150., 1000.}; - std::vector binning = {Acts::binR}; + std::vector binning = {Acts::BinningValue::binR}; auto root = std::make_unique( dd4hepElement.name(), Acts::Transform3::Identity(), Acts::VolumeBounds::eCylinder, bValues, binning); @@ -173,17 +173,17 @@ Acts::Experimental::DD4hepBlueprintFactory::extractExternals( // Set as defaults bValues = {0., 0., 0.}; auto parsedExtent = extOpt.value(); - if (parsedExtent.constrains(binR)) { - bValues[0u] = std::floor(parsedExtent.min(binR)); - bValues[1u] = std::ceil(parsedExtent.max(binR)); + if (parsedExtent.constrains(BinningValue::binR)) { + bValues[0u] = std::floor(parsedExtent.min(BinningValue::binR)); + bValues[1u] = std::ceil(parsedExtent.max(BinningValue::binR)); } - if (parsedExtent.constrains(binZ)) { - ActsScalar minZ = parsedExtent.min(binZ) > 0. - ? std::floor(parsedExtent.min(binZ)) - : std::ceil(parsedExtent.min(binZ)); - ActsScalar maxZ = parsedExtent.max(binZ) > 0. - ? std::floor(parsedExtent.max(binZ)) - : std::ceil(parsedExtent.max(binZ)); + if (parsedExtent.constrains(BinningValue::binZ)) { + ActsScalar minZ = parsedExtent.min(BinningValue::binZ) > 0. + ? std::floor(parsedExtent.min(BinningValue::binZ)) + : std::ceil(parsedExtent.min(BinningValue::binZ)); + ActsScalar maxZ = parsedExtent.max(BinningValue::binZ) > 0. + ? std::floor(parsedExtent.max(BinningValue::binZ)) + : std::ceil(parsedExtent.max(BinningValue::binZ)); bValues[2u] = 0.5 * (maxZ - minZ); transform.translation().z() = 0.5 * (maxZ + minZ); } @@ -258,10 +258,9 @@ Acts::Experimental::DD4hepBlueprintFactory::extractInternals( if (!internalBinningValues.empty()) { ACTS_VERBOSE(" - internals extent measurement requested"); Extent internalsExtent; - ExtentEnvelope clearance = zeroEnvelopes; + ExtentEnvelope clearance = ExtentEnvelope::Zero(); for (const auto& bv : internalBinningValues) { - ACTS_VERBOSE(" -> measuring extent for " - << binningValueNames()[bv]); + ACTS_VERBOSE(" -> measuring extent for " << binningValueName(bv)); ACTS_VERBOSE(" -> with clearance :" << internalsClearance); clearance[bv] = {internalsClearance, internalsClearance}; } @@ -286,7 +285,8 @@ Acts::Experimental::DD4hepBlueprintFactory::extractInternals( baseName + "_root_volume_finder", dd4hepElement, ""); if (rootFinder == "indexed") { aux[1u] = "root finder : indexed"; - std::vector binning = {binZ, binR}; + std::vector binning = {BinningValue::binZ, + BinningValue::binR}; rootsFinderBuilder = std::make_shared( binning); diff --git a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp index 896d0c3854b..2fb52291a04 100644 --- a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp +++ b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp @@ -118,10 +118,12 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::endcapLayers( params.contains("envelope_z_max")) { // set the values of the proto layer in case enevelopes are handed // over - pl.envelope[Acts::binR] = {params.get("envelope_r_min"), - params.get("envelope_r_max")}; - pl.envelope[Acts::binZ] = {params.get("envelope_z_min"), - params.get("envelope_z_max")}; + pl.envelope[Acts::BinningValue::binR] = { + params.get("envelope_r_min"), + params.get("envelope_r_max")}; + pl.envelope[Acts::BinningValue::binZ] = { + params.get("envelope_z_min"), + params.get("envelope_z_max")}; } else if (geoShape != nullptr) { TGeoTubeSeg* tube = dynamic_cast(geoShape); if (tube == nullptr) { @@ -151,20 +153,22 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::endcapLayers( // manually create a proto layer double eiz = (z != 0.) ? z - m_cfg.defaultThickness : 0.; double eoz = (z != 0.) ? z + m_cfg.defaultThickness : 0.; - pl.extent.range(Acts::binZ).set(eiz, eoz); - pl.extent.range(Acts::binR).set(rMin, rMax); - pl.envelope[Acts::binR] = {0., 0.}; - pl.envelope[Acts::binZ] = {0., 0.}; + pl.extent.range(Acts::BinningValue::binZ).set(eiz, eoz); + pl.extent.range(Acts::BinningValue::binR).set(rMin, rMax); + pl.envelope[Acts::BinningValue::binR] = {0., 0.}; + pl.envelope[Acts::BinningValue::binZ] = {0., 0.}; } else { ACTS_VERBOSE(" Disc layer has " << layerSurfaces.size() << " sensitive surfaces."); // set the values of the proto layer in case dimensions are given by // geometry - pl.envelope[Acts::binZ] = {std::abs(zMin - pl.min(Acts::binZ)), - std::abs(zMax - pl.max(Acts::binZ))}; - pl.envelope[Acts::binR] = {std::abs(rMin - pl.min(Acts::binR)), - std::abs(rMax - pl.max(Acts::binR))}; - pl.extent.range(Acts::binR).set(rMin, rMax); + pl.envelope[Acts::BinningValue::binZ] = { + std::abs(zMin - pl.min(Acts::BinningValue::binZ)), + std::abs(zMax - pl.max(Acts::BinningValue::binZ))}; + pl.envelope[Acts::BinningValue::binR] = { + std::abs(rMin - pl.min(Acts::BinningValue::binR)), + std::abs(rMax - pl.max(Acts::BinningValue::binR))}; + pl.extent.range(Acts::BinningValue::binR).set(rMin, rMax); } } else { throw std::logic_error( @@ -200,9 +204,10 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::endcapLayers( auto sArray = std::make_unique(sensitiveSurf); // create the share disc bounds - auto dBounds = std::make_shared(pl.min(Acts::binR), - pl.max(Acts::binR)); - double thickness = std::fabs(pl.max(Acts::binZ) - pl.min(Acts::binZ)); + auto dBounds = std::make_shared( + pl.min(Acts::BinningValue::binR), pl.max(Acts::BinningValue::binR)); + double thickness = std::fabs(pl.max(Acts::BinningValue::binZ) - + pl.min(Acts::BinningValue::binZ)); // Create the layer containing the sensitive surface endcapLayer = DiscLayer::create(transform, dBounds, std::move(sArray), thickness, nullptr, Acts::active); @@ -283,10 +288,12 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::centralLayers( params.contains("envelope_z_min") && params.contains("envelope_z_max")) { // set the values of the proto layer in case enevelopes are handed over - pl.envelope[Acts::binR] = {params.get("envelope_r_min"), - params.get("envelope_r_max")}; - pl.envelope[Acts::binZ] = {params.get("envelope_z_min"), - params.get("envelope_z_max")}; + pl.envelope[Acts::BinningValue::binR] = { + params.get("envelope_r_min"), + params.get("envelope_r_max")}; + pl.envelope[Acts::BinningValue::binZ] = { + params.get("envelope_z_min"), + params.get("envelope_z_max")}; } else if (geoShape != nullptr) { TGeoTubeSeg* tube = dynamic_cast(geoShape); if (tube == nullptr) { @@ -307,17 +314,19 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::centralLayers( // manually create a proto layer double eir = (r != 0.) ? r - m_cfg.defaultThickness : 0.; double eor = (r != 0.) ? r + m_cfg.defaultThickness : 0.; - pl.extent.range(Acts::binR).set(eir, eor); - pl.extent.range(Acts::binZ).set(-dz, dz); - pl.envelope[Acts::binR] = {0., 0.}; - pl.envelope[Acts::binZ] = {0., 0.}; + pl.extent.range(Acts::BinningValue::binR).set(eir, eor); + pl.extent.range(Acts::BinningValue::binZ).set(-dz, dz); + pl.envelope[Acts::BinningValue::binR] = {0., 0.}; + pl.envelope[Acts::BinningValue::binZ] = {0., 0.}; } else { // set the values of the proto layer in case dimensions are given by // geometry - pl.envelope[Acts::binZ] = {std::abs(-dz - pl.min(Acts::binZ)), - std::abs(dz - pl.max(Acts::binZ))}; - pl.envelope[Acts::binR] = {std::abs(rMin - pl.min(Acts::binR)), - std::abs(rMax - pl.max(Acts::binR))}; + pl.envelope[Acts::BinningValue::binZ] = { + std::abs(-dz - pl.min(Acts::BinningValue::binZ)), + std::abs(dz - pl.max(Acts::BinningValue::binZ))}; + pl.envelope[Acts::BinningValue::binR] = { + std::abs(rMin - pl.min(Acts::BinningValue::binR)), + std::abs(rMax - pl.max(Acts::BinningValue::binR))}; } } else { throw std::logic_error( @@ -327,7 +336,9 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::centralLayers( "constructor!")); } - double halfZ = (pl.min(Acts::binZ) - pl.max(Acts::binZ)) * 0.5; + double halfZ = (pl.min(Acts::BinningValue::binZ) - + pl.max(Acts::BinningValue::binZ)) * + 0.5; std::shared_ptr centralLayer = nullptr; // In case the layer is sensitive @@ -339,8 +350,11 @@ const Acts::LayerVector Acts::DD4hepLayerBuilder::centralLayers( std::make_unique(sensitiveSurf); // create the layer - double layerR = (pl.min(Acts::binR) + pl.max(Acts::binR)) * 0.5; - double thickness = std::fabs(pl.max(Acts::binR) - pl.min(Acts::binR)); + double layerR = (pl.min(Acts::BinningValue::binR) + + pl.max(Acts::BinningValue::binR)) * + 0.5; + double thickness = std::fabs(pl.max(Acts::BinningValue::binR) - + pl.min(Acts::BinningValue::binR)); auto cBounds = std::make_shared(layerR, halfZ); // Create the layer containing the sensitive surface centralLayer = diff --git a/Plugins/DD4hep/src/DD4hepLayerStructure.cpp b/Plugins/DD4hep/src/DD4hepLayerStructure.cpp index 558132a4605..f2b45ab2e46 100644 --- a/Plugins/DD4hep/src/DD4hepLayerStructure.cpp +++ b/Plugins/DD4hep/src/DD4hepLayerStructure.cpp @@ -69,7 +69,7 @@ Acts::Experimental::DD4hepLayerStructure::builder( ACTS_VERBOSE("Checking if surface binning ranges can be patched."); for (auto& b : fCache.binnings) { if (extent.constrains(b.binValue)) { - ACTS_VERBOSE("Binning '" << binningValueNames()[b.binValue] + ACTS_VERBOSE("Binning '" << binningValueName(b.binValue) << "' is patched."); ACTS_VERBOSE(" <- from : [" << b.edges.front() << ", " << b.edges.back() << "]"); @@ -93,14 +93,14 @@ Acts::Experimental::DD4hepLayerStructure::builder( cElements.reserve(fCache.sensitiveSurfaces.size()); // Fill them in to the surface provider struct and detector store - for (auto [de, ds] : fCache.sensitiveSurfaces) { + for (const auto& [de, ds] : fCache.sensitiveSurfaces) { lSurfaces.push_back(ds); cElements.push_back(de); } dd4hepStore[options.name] = cElements; // Passive surfaces to be added - for (auto [ps, toAll] : fCache.passiveSurfaces) { + for (const auto& [ps, toAll] : fCache.passiveSurfaces) { // Passive surface is not declared to be added to all navigation bins if (!toAll) { lSurfaces.push_back(ps); diff --git a/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp b/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp index 6667da5b912..02fb1fa4947 100644 --- a/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp +++ b/Plugins/DD4hep/src/DD4hepMaterialHelpers.cpp @@ -13,6 +13,7 @@ #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/BinUtility.hpp" +#include "Acts/Utilities/BinningType.hpp" #include #include @@ -34,11 +35,7 @@ std::shared_ptr Acts::createProtoMaterial( Acts::BinUtility bu; // Loop over the bins for (auto& bin : binning) { - // finding the iterator position to determine the binning value - auto bit = std::find(Acts::binningValueNames().begin(), - Acts::binningValueNames().end(), bin.first); - const int indx = std::distance(Acts::binningValueNames().begin(), bit); - Acts::BinningValue bval = Acts::BinningValue{indx}; + BinningValue bval = binningValueFromName(bin.first); Acts::BinningOption bopt = bin.second; double min = 0.; double max = 0.; diff --git a/Plugins/Detray/CMakeLists.txt b/Plugins/Detray/CMakeLists.txt new file mode 100644 index 00000000000..a2a1585063d --- /dev/null +++ b/Plugins/Detray/CMakeLists.txt @@ -0,0 +1,34 @@ +add_library( + ActsPluginDetray SHARED + src/DetrayConverter.cpp) + +add_dependencies(ActsPluginDetray + detray::core + covfie::core + vecmem::core) + +target_include_directories( + ActsPluginDetray + PUBLIC + $ + $) + +target_link_libraries( + ActsPluginDetray + PUBLIC + ActsCore + detray::core + detray::core_array + detray::io + detray::utils + detray::svgtools + vecmem::core) + +install( + TARGETS ActsPluginDetray + EXPORT ActsPluginDetrayTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY include/Acts + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp new file mode 100644 index 00000000000..5fdbd2d7002 --- /dev/null +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConversionHelper.hpp @@ -0,0 +1,117 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2023 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Surfaces/SurfaceBounds.hpp" +#include "Acts/Utilities/BinningData.hpp" + +#include +#include + +#include + +#include "detray/io/frontend/definitions.hpp" + +namespace Acts::DetrayConversionHelper { + +/// @brief Helper function to switch keys from ACTS to detray +/// +/// DETRAY types @todo change to detray imports when available +/// annulus2 = 0u, +/// cuboid3 = 1u, +/// cylinder2 = 2u, +/// cylinder3 = 3u, +/// portal_cylinder2 = 4u, +/// rectangle2 = 5u, +/// ring2 = 6u, +/// trapezoid2 = 7u, +/// cell_wire = 8u, +/// straw_wire = 9u, +/// single1 = 10u, +/// single2 = 11u, +/// single3 = 12u, +/// unknown = 13u +/// +/// @param sBounds is the surface bounds type +/// @param portal is the flag for conversion into detray portal format +/// +/// @return type and value array in detray format +inline static std::tuple> maskFromBounds( + const Acts::SurfaceBounds& sBounds, bool portal = false) { + auto bType = sBounds.type(); + auto bValues = sBounds.values(); + // Return value + unsigned int type = 13u; + std::vector boundaries = bValues; + // Special treatment for some portals + if (portal && bType == SurfaceBounds::BoundsType::eCylinder) { + boundaries = {bValues[0u], -bValues[1u], bValues[1u]}; + type = 4u; + } else { + switch (bType) { + case SurfaceBounds::BoundsType::eAnnulus: { + type = 0u; + } break; + case SurfaceBounds::BoundsType::eRectangle: { + type = 5u; + // ACTS: eMinX = 0, eMinY = 1, eMaxX = 2, eMaxY = 3, + // detray: e_half_x, e_half_y + boundaries = {0.5 * (bValues[2] - bValues[0]), + 0.5 * (bValues[3] - bValues[1])}; + } break; + case SurfaceBounds::BoundsType::eCylinder: { + boundaries = {bValues[0u], -bValues[1u], bValues[1u]}; + type = 2u; + } break; + case SurfaceBounds::BoundsType::eTrapezoid: { + type = 7u; + boundaries = {bValues[0u], bValues[1u], bValues[2u], + 1 / (2 * bValues[2u])}; + } break; + case SurfaceBounds::BoundsType::eDisc: { + boundaries = {bValues[0u], bValues[1u]}; + type = 6u; + } break; + default: + break; + } + } + return std::tie(type, boundaries); +} + +/// Determine the acceleration link from a grid +/// +/// @param casts are the grid axes cast types +/// +/// @return the acceleration link idnetifier +template +inline static std::size_t accelerationLink(const binning_values_t& casts) { + // Default is `brute_force` + std::size_t accLink = detray::io::accel_id::brute_force; + if (casts.size() == 2u) { + if (casts[0u] == binX && casts[1u] == binY) { + accLink = detray::io::accel_id::cartesian2_grid; + } else if (casts[0u] == binR && casts[1u] == binPhi) { + accLink = detray::io::accel_id::polar2_grid; + } else if (casts[0u] == binZ && casts[1u] == binPhi) { + accLink = detray::io::accel_id::cylinder2_grid; + } else if (casts[0u] == binZ && casts[1u] == binR) { + accLink = detray::io::accel_id::cylinder3_grid; + } + } else if (casts.size() == 3u) { + if (casts[0u] == binX && casts[1u] == binY && casts[2u] == binZ) { + accLink = detray::io::accel_id::cuboid3_grid; + } else if (casts[0u] == binZ && casts[1u] == binPhi && casts[2u] == binR) { + accLink = detray::io::accel_id::cylinder3_grid; + } + } + return accLink; +} + +} // namespace Acts::DetrayConversionHelper diff --git a/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp new file mode 100644 index 00000000000..4de8a8bf5ac --- /dev/null +++ b/Plugins/Detray/include/Acts/Plugins/Detray/DetrayConverter.hpp @@ -0,0 +1,144 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Definitions/Algebra.hpp" +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Geometry/VolumeBounds.hpp" + +#include + +#include "detray/builders/detector_builder.hpp" +#include "detray/core/detector.hpp" +#include "detray/definitions/geometry.hpp" +#include "detray/io/common/geometry_reader.hpp" +#include "detray/io/frontend/detector_writer.hpp" +#include "detray/io/frontend/payloads.hpp" +#include "detray/utils/consistency_checker.hpp" + +namespace Acts { + +class Surface; +class SurfaceBounds; + +namespace Experimental { +class Detector; +class DetectorVolume; +class Portal; +} // namespace Experimental + +namespace DetrayConverter { + +using DetrayDetector = detray::detector; + +/// Write the detector to json output +/// +/// @param dDetector is the detray detector (converted) +/// @param names a name map for the detector volumes +/// @param writer_cfg the writer configuration +void writeToJson(const DetrayDetector& dDetector, + const typename DetrayDetector::name_map& names = {}, + detray::io::detector_writer_config writer_cfg = {}); + +/// Conversion method for transform objects to detray::transform payloads +/// +/// @param t the transform to be converted +/// +/// @return the transform_payload(translation, rotation) +detray::io::transform_payload convertTransform(const Transform3& t); + +/// Conversion method for surface bounds to detray::mask payloads +/// +/// @param bounds the bounds object to be converted +/// @param portal the flag for conversion into detray portal format +/// +/// @return the mask_payload representing the bounds +detray::io::mask_payload convertMask(const SurfaceBounds& bounds, + bool portal = false); + +/// Conversion method for surface objects to detray::surface payloads +/// +/// @param gctx the geometry context +/// @param surface the surface to be converted +/// @param portal the flag for conversion into detray portal format +/// +/// @return the surface_payload for portals and volumes by @param Surface acts object +detray::io::surface_payload convertSurface(const GeometryContext& gctx, + const Surface& surface, + bool portal = false); +/// Conversion method for Portal object to detray::portal payloads +/// +/// @param gctx the geometry context +/// @param portal the portal to be converted +/// @param ip the portal index +/// @param volume the volume to which the portal belongs +/// @param orientedSurfaces the oriented surfaces of the portal +/// @param detectorVolumes the detector volumes for the link lookup +/// +/// @note due to portal splitting this can add up in N portals for one initial one +/// +/// @brief convert the acts portal to detray surface payload and populate the payload +std::vector convertPortal( + const GeometryContext& gctx, const Experimental::Portal& portal, + std::size_t ip, const Experimental::DetectorVolume& volume, + const std::vector& orientedSurfaces, + const std::vector& detectorVolumes); + +/// Conversion method for volume objects to detray::volume payloads +/// +/// @param gctx the geometry context +/// @param volume the volume to be converted +/// @param detectorVolumes the detector volumes for the link lookup +/// +/// @return the volume_payload for portals and volumes by @param volume acts object +detray::io::volume_payload convertVolume( + const GeometryContext& gctx, const Experimental::DetectorVolume& volume, + const std::vector& detectorVolumes); + +/// Conversion method for (common) header payload +/// +/// @param detector is the detector to be converted +/// +/// @return a geometry header payload +detray::io::geo_header_payload convertHead( + const Acts::Experimental::Detector& detector); + +/// Convert an Acts::Experimental::Detector to a detray::detector object +/// +/// @param gctx the geometry context +/// @param detector the detector to be converted +/// @param mr the memory resource to be used +/// +/// @returns a detector of requested return type +template +std::tuple convertDetector( + const Acts::GeometryContext& gctx, + const Acts::Experimental::Detector& detector, vecmem::memory_resource& mr) { + detray::io::detector_payload detectorPayload; + for (const auto volume : detector.volumes()) { + detectorPayload.volumes.push_back( + convertVolume(gctx, *volume, detector.volumes())); + } + typename detector_t::name_map names = {{0u, detector.name()}}; + + // build detector + detray::detector_builder detectorBuilder{}; + detray::io::geometry_reader::convert(detectorBuilder, names, + detectorPayload); + detector_t detrayDetector(detectorBuilder.build(mr)); + + // checks and print + detray::detail::check_consistency(detrayDetector); + converterPrint(detrayDetector, names); + + return {std::move(detrayDetector), mr}; +} + +} // namespace DetrayConverter +} // namespace Acts diff --git a/Plugins/Detray/src/DetrayConverter.cpp b/Plugins/Detray/src/DetrayConverter.cpp new file mode 100644 index 00000000000..d3ce397923c --- /dev/null +++ b/Plugins/Detray/src/DetrayConverter.cpp @@ -0,0 +1,318 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "Acts/Plugins/Detray/DetrayConverter.hpp" + +#include "Acts/Detector/Detector.hpp" +#include "Acts/Detector/DetectorVolume.hpp" +#include "Acts/Detector/Portal.hpp" +#include "Acts/Navigation/PortalNavigation.hpp" +#include "Acts/Plugins/Detray/DetrayConversionHelper.hpp" +#include "Acts/Surfaces/CylinderBounds.hpp" +#include "Acts/Surfaces/CylinderSurface.hpp" +#include "Acts/Surfaces/DiscSurface.hpp" +#include "Acts/Surfaces/RadialBounds.hpp" +#include "Acts/Surfaces/RegularSurface.hpp" +#include "Acts/Surfaces/Surface.hpp" +#include "Acts/Surfaces/SurfaceBounds.hpp" + +#include "detray/io/frontend/detector_writer.hpp" + +using namespace detray; + +namespace { + +/// Find the position of the volume to point to +/// +/// @param volume the volume to find +/// @param the collection of volumes +/// +/// @note return -1 if not found, to be interpreted by the caller +int findVolume( + const Acts::Experimental::DetectorVolume* volume, + const std::vector& volumes) { + auto candidate = std::find(volumes.begin(), volumes.end(), volume); + if (candidate != volumes.end()) { + return std::distance(volumes.begin(), candidate); + } + return -1; +} +} // namespace + +/// detray geometry writer function, debug purposes +void Acts::DetrayConverter::writeToJson( + const DetrayDetector& dDetector, + const typename DetrayDetector::name_map& names, + detray::io::detector_writer_config writer_cfg) { + writer_cfg.format(detray::io::format::json); + detray::io::write_detector(dDetector, names, writer_cfg); +} + +detray::io::transform_payload Acts::DetrayConverter::convertTransform( + const Transform3& t) { + detray::io::transform_payload tfPayload; + auto translation = t.translation(); + tfPayload.tr = {translation.x(), translation.y(), translation.z()}; + + const auto rotation = t.rotation(); + tfPayload.rot = {rotation(0, 0), rotation(0, 1), rotation(0, 2), + rotation(1, 0), rotation(1, 1), rotation(1, 2), + rotation(2, 0), rotation(2, 1), rotation(2, 2)}; + return tfPayload; +} + +detray::io::mask_payload Acts::DetrayConverter::convertMask( + const Acts::SurfaceBounds& bounds, bool portal) { + detray::io::mask_payload maskPayload; + auto [shape, boundaries] = + DetrayConversionHelper::maskFromBounds(bounds, portal); + maskPayload.shape = static_cast(shape); + maskPayload.boundaries = static_cast>(boundaries); + // default maskPayload.volume_link + + return maskPayload; +} + +detray::io::surface_payload Acts::DetrayConverter::convertSurface( + const Acts::GeometryContext& gctx, const Surface& surface, bool portal) { + using material_link_payload = + detray::io::typed_link_payload; + + detray::io::surface_payload surfacePayload; + + surfacePayload.transform = convertTransform(surface.transform(gctx)); + surfacePayload.source = surface.geometryId().value(); + surfacePayload.barcode = std::nullopt; + surfacePayload.type = static_cast( + portal ? surface_id::e_portal + : (surface.geometryId().sensitive() > 0 + ? detray::surface_id::e_sensitive + : detray::surface_id::e_passive)); + surfacePayload.mask = convertMask(surface.bounds()); + return surfacePayload; +} + +std::vector Acts::DetrayConverter::convertPortal( + const GeometryContext& gctx, const Experimental::Portal& portal, + std::size_t ip, const Experimental::DetectorVolume& volume, + const std::vector& orientedSurfaces, + const std::vector& detectorVolumes) { + std::vector portals{}; + + const RegularSurface& surface = portal.surface(); + const auto& volumeLinks = portal.portalNavigation(); + + // First assumption for outside link (along direction) + std::size_t outside = 1u; + + // Find out if you need to take the outside or inside volume + // for planar surfaces that's easy + if (surface.type() != Acts::Surface::SurfaceType::Cylinder) { + // Get the two volume center + const auto volumeCenter = volume.transform(gctx).translation(); + const auto surfaceCenter = surface.center(gctx); + const auto surfaceNormal = surface.normal(gctx, surfaceCenter); + // Get the direction from the volume to the surface, correct link + const auto volumeToSurface = surfaceCenter - volumeCenter; + if (volumeToSurface.dot(surfaceNormal) < 0.) { + outside = 0u; + } + } else { + // This is a cylinder portal, inner cover reverses the normal + if (ip == 3u) { + outside = 0u; + } + } + + const auto& outsideLink = volumeLinks[outside]; + // Grab the corresponding volume link + // If it is a single link, we are done + const auto* instance = outsideLink.instance(); + // Single link cast + auto singleLink = + dynamic_cast( + instance); + + auto [surfaceAdjusted, insidePointer] = orientedSurfaces[ip]; + + // Single link detected - just write it out, we use the oriented surface + // in order to make sure the size is adjusted + if (singleLink != nullptr) { + // Single link can be written out + std::size_t vLink = findVolume(singleLink->object(), detectorVolumes); + auto portalPayload = convertSurface(gctx, *surfaceAdjusted, true); + portalPayload.mask.volume_link.link = vLink; + portals.push_back(portalPayload); + } else { + // Multi link detected - 1D + auto multiLink1D = + dynamic_cast( + instance); + if (multiLink1D != nullptr) { + // Resolve the multi link 1D + auto boundaries = + multiLink1D->indexedUpdater.grid.axes()[0u]->getBinEdges(); + const auto& cast = multiLink1D->indexedUpdater.casts[0u]; + const auto& transform = multiLink1D->indexedUpdater.transform; + const auto& volumes = multiLink1D->indexedUpdater.extractor.dVolumes; + + // Apply the correction from local to global boundaries + ActsScalar gCorr = VectorHelpers::cast(transform.translation(), cast); + std::for_each(boundaries.begin(), boundaries.end(), + [&gCorr](ActsScalar& b) { b -= gCorr; }); + + // Get the volume indices + auto surfaceType = surfaceAdjusted->type(); + std::vector vIndices = {}; + for (const auto& v : volumes) { + vIndices.push_back(findVolume(v, detectorVolumes)); + } + + // Pick the surface dimension - via poly + std::array clipRange = {0., 0.}; + std::vector boundValues = surfaceAdjusted->bounds().values(); + if (surfaceType == Surface::SurfaceType::Cylinder && cast == binZ) { + ActsScalar zPosition = surfaceAdjusted->center(gctx).z(); + clipRange = { + zPosition - boundValues[CylinderBounds::BoundValues::eHalfLengthZ], + zPosition + boundValues[CylinderBounds::BoundValues::eHalfLengthZ]}; + } else if (surfaceType == Surface::SurfaceType::Disc && cast == binR) { + clipRange = {boundValues[RadialBounds::BoundValues::eMinR], + boundValues[RadialBounds::BoundValues::eMaxR]}; + } else { + throw std::runtime_error( + "PortalDetrayConverter: surface type not (yet) supported for " + "detray " + "conversion, only cylinder and disc are currently supported."); + } + + // Need to clip the parameter space to the surface dimension + std::vector clippedIndices = {}; + std::vector clippedBoundaries = {}; + clippedBoundaries.push_back(clipRange[0u]); + for (const auto [ib, b] : enumerate(boundaries)) { + if (ib > 0) { + unsigned int vI = vIndices[ib - 1u]; + ActsScalar highEdge = boundaries[ib]; + if (boundaries[ib - 1] >= clipRange[1u]) { + break; + } + if (highEdge <= clipRange[0u] || + std::abs(highEdge - clipRange[0u]) < 1e-5) { + continue; + } + if (highEdge > clipRange[1u]) { + highEdge = clipRange[1u]; + } + clippedIndices.push_back(vI); + clippedBoundaries.push_back(highEdge); + } + } + // Interpret the clipped information + // + // Clipped cylinder case + if (surfaceType == Surface::SurfaceType::Cylinder) { + for (auto [ib, b] : enumerate(clippedBoundaries)) { + if (ib > 0) { + // Create sub surfaces + std::array + subBoundValues = {}; + for (auto [ibv, bv] : enumerate(boundValues)) { + subBoundValues[ibv] = bv; + } + subBoundValues[CylinderBounds::BoundValues::eHalfLengthZ] = + 0.5 * (b - clippedBoundaries[ib - 1u]); + auto subBounds = std::make_shared(subBoundValues); + auto subTransform = Transform3::Identity(); + subTransform.pretranslate(Vector3( + 0., 0., + clippedBoundaries[ib - 1u] + + subBoundValues[CylinderBounds::BoundValues::eHalfLengthZ])); + auto subSurface = + Surface::makeShared(subTransform, subBounds); + + auto portalPayload = convertSurface(gctx, *subSurface, true); + portalPayload.mask.volume_link.link = clippedIndices[ib - 1u]; + portals.push_back(portalPayload); + } + } + } else { + for (auto [ib, b] : enumerate(clippedBoundaries)) { + if (ib > 0) { + // Create sub surfaces + std::array + subBoundValues = {}; + for (auto [ibv, bv] : enumerate(boundValues)) { + subBoundValues[ibv] = bv; + } + subBoundValues[RadialBounds::BoundValues::eMinR] = + clippedBoundaries[ib - 1u]; + subBoundValues[RadialBounds::BoundValues::eMaxR] = b; + auto subBounds = std::make_shared(subBoundValues); + auto subSurface = Surface::makeShared( + portal.surface().transform(gctx), subBounds); + + auto portalPayload = convertSurface(gctx, *subSurface, true); + portalPayload.mask.volume_link.link = clippedIndices[ib - 1u]; + portals.push_back(portalPayload); + } + } + } + + } else { + // End of world portal + // Write surface with invalid link + auto portalPayload = convertSurface(gctx, *surfaceAdjusted, true); + using NavigationLink = + typename DetrayDetector::surface_type::navigation_link; + portalPayload.mask.volume_link.link = + std::numeric_limits::max(); + + portals.push_back(portalPayload); + } + } + + return portals; +} + +detray::io::volume_payload Acts::DetrayConverter::convertVolume( + const Acts::GeometryContext& gctx, + const Acts::Experimental::DetectorVolume& volume, + const std::vector& detectorVolumes) { + detray::io::volume_payload volumePayload; + volumePayload.name = volume.name(); + volumePayload.index.link = findVolume(&volume, detectorVolumes); + volumePayload.transform = convertTransform(volume.transform(gctx)); + + // iterate over surfaces and portals keeping the same surf_pd.index_in_coll + std::size_t sIndex = 0; + for (const auto surface : volume.surfaces()) { + io::surface_payload surfacePayload = convertSurface(gctx, *surface, false); + + surfacePayload.index_in_coll = sIndex++; + surfacePayload.mask.volume_link.link = + volumePayload.index.link; // link surface' mask to volume + volumePayload.surfaces.push_back(surfacePayload); + } + + auto orientedSurfaces = + volume.volumeBounds().orientedSurfaces(volume.transform(gctx)); + + int portalCounter = 0; + for (const auto& [ip, p] : enumerate(volume.portals())) { + auto portals = + convertPortal(gctx, *p, ip, volume, orientedSurfaces, detectorVolumes); + std::for_each(portals.begin(), portals.end(), [&](auto& portalPayload) { + portalPayload.index_in_coll = sIndex++; + volumePayload.surfaces.push_back(portalPayload); + portalCounter++; + }); + } + + return volumePayload; +} diff --git a/Plugins/FpeMonitoring/CMakeLists.txt b/Plugins/FpeMonitoring/CMakeLists.txt index 89f8b645164..6486027fd2e 100644 --- a/Plugins/FpeMonitoring/CMakeLists.txt +++ b/Plugins/FpeMonitoring/CMakeLists.txt @@ -5,7 +5,7 @@ target_include_directories( ActsPluginFpeMonitoring PUBLIC $ - $) + $) target_link_libraries( ActsPluginFpeMonitoring PUBLIC ActsCore) @@ -24,7 +24,7 @@ else() if(dl_LIBRARY) target_link_libraries(ActsPluginFpeMonitoring PUBLIC ${dl_LIBRARY}) - + set(_backtrace_setup_complete FALSE) if(Backtrace_FOUND) diff --git a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/detail/GeoModelBinningHelper.hpp b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/detail/GeoModelBinningHelper.hpp index c00bbb80d94..bbd0e55c83b 100644 --- a/Plugins/GeoModel/include/Acts/Plugins/GeoModel/detail/GeoModelBinningHelper.hpp +++ b/Plugins/GeoModel/include/Acts/Plugins/GeoModel/detail/GeoModelBinningHelper.hpp @@ -39,7 +39,7 @@ inline BinningValue toBinningValue(const std::string& binning, throw std::invalid_argument( "GeoModelBinningHelper: Unknown binning value '" + binning + "'"); } - return BinningValue::binValues; + return BinningValue::numBinningValues(); } /// @brief Convert a binning string into a ProtoiBinning description diff --git a/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp b/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp index 78265c3dd93..3f12c01037d 100644 --- a/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp +++ b/Plugins/GeoModel/src/GeoModelBlueprintCreater.cpp @@ -49,7 +49,8 @@ Acts::GeoModelBlueprintCreater::create(const GeometryContext& gctx, // Prepare the KdtSurfaces if configured to do so // if (!m_cfg.detectorSurfaces.empty()) { - std::array kdtBinning = {binX, binY, binZ}; + std::array kdtBinning = { + BinningValue::binX, BinningValue::binY, BinningValue::binZ}; if (m_cfg.kdtBinning.empty()) { throw std::invalid_argument( "GeoModelBlueprintCreater: At least one binning value for KDTree " @@ -155,7 +156,7 @@ Acts::GeoModelBlueprintCreater::createNode( ACTS_VERBOSE("Found " << internalConstraints.size() << " internal constraints to check for: "); for (const auto& ic : internalConstraints) { - ACTS_VERBOSE("- " << binningValueNames()[ic]); + ACTS_VERBOSE("- " << binningValueName(ic)); } } @@ -411,9 +412,10 @@ Acts::GeoModelBlueprintCreater::parseBounds( // Switch on the bounds type if (boundsType == VolumeBounds::BoundsType::eCylinder) { // Create the translation & bound values - translation = Acts::Vector3(0., 0., extent.medium(binZ)); - boundValues = {extent.min(binR), extent.max(binR), - 0.5 * extent.interval(binZ)}; + translation = Acts::Vector3(0., 0., extent.medium(BinningValue::binZ)); + boundValues = {extent.min(BinningValue::binR), + extent.max(BinningValue::binR), + 0.5 * extent.interval(BinningValue::binZ)}; } else { throw std::invalid_argument( "GeoModelBlueprintCreater: Unknown bounds type, only 'cyl' is " diff --git a/Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp b/Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp index 75339964300..56156e5bb6d 100644 --- a/Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp +++ b/Plugins/GeoModel/src/detail/GeoModelExtentHelper.cpp @@ -36,8 +36,9 @@ Acts::detail::GeoModelExentHelper::readBoundsConstaints( "least 4 entries (rmin, rmax, zmin, zmax)"); } // Raw database values to extent entries - constexpr std::array bvCyl = {binR, binR, binZ, - binZ, binPhi, binPhi}; + constexpr std::array bvCyl = { + BinningValue::binR, BinningValue::binR, BinningValue::binZ, + BinningValue::binZ, BinningValue::binPhi, BinningValue::binPhi}; for (auto [iv, value] : enumerate(valuesEntry)) { if (value == ctype || value[0u] == ctype[0u]) { @@ -61,7 +62,7 @@ Acts::detail::GeoModelExentHelper::readBinningConstraints( boost::split(sbTokens, sbe, boost::is_any_of(",")); BinningValue bv = Acts::detail::GeoModelBinningHelper::toBinningValue(sbTokens[0], false); - if (bv != binValues && sbTokens.size() > 1u) { + if (bv != numBinningValues() && sbTokens.size() > 1u) { std::vector valueTokens = {sbTokens.begin() + 1, sbTokens.end()}; if (!valueTokens.empty() && valueTokens[0] == "bound") { @@ -102,8 +103,9 @@ Acts::detail::GeoModelExentHelper::extentFromTable( "least 4 entries (rmin, rmax, zmin, zmax)"); } // Raw database values to extent entries - constexpr std::array bvCyl = {binR, binR, binZ, - binZ, binPhi, binPhi}; + constexpr std::array bvCyl = { + BinningValue::binR, BinningValue::binR, BinningValue::binZ, + BinningValue::binZ, BinningValue::binPhi, BinningValue::binPhi}; for (auto [iv, value] : enumerate(valuesEntry)) { // Get the binning value BinningValue bValue = bvCyl.at(iv); @@ -147,7 +149,7 @@ Acts::detail::GeoModelExentHelper::extentFromTable( } // Round up / down if configured if (roundInternalExtent) { - for (const auto& bv : s_binningValues) { + for (const auto& bv : allBinningValues()) { if (internalExtent.constrains(bv)) { extent.setMin(bv, std::floor(extent.min(bv))); extent.setMax(bv, std::ceil(extent.max(bv))); diff --git a/Plugins/Json/CMakeLists.txt b/Plugins/Json/CMakeLists.txt index 88d20478ea0..3398582ec45 100644 --- a/Plugins/Json/CMakeLists.txt +++ b/Plugins/Json/CMakeLists.txt @@ -24,7 +24,7 @@ target_include_directories( ActsPluginJson PUBLIC $ - $) + $) target_link_libraries( ActsPluginJson PUBLIC ActsCore) acts_target_link_libraries_system( diff --git a/Plugins/Json/include/Acts/Plugins/Json/DetrayJsonHelper.hpp b/Plugins/Json/include/Acts/Plugins/Json/DetrayJsonHelper.hpp index 84519166324..fe00fbc0aee 100644 --- a/Plugins/Json/include/Acts/Plugins/Json/DetrayJsonHelper.hpp +++ b/Plugins/Json/include/Acts/Plugins/Json/DetrayJsonHelper.hpp @@ -109,19 +109,25 @@ inline static std::size_t accelerationLink(const binning_values_t& casts) { // Default is `brute_force` std::size_t accLink = 0u; if (casts.size() == 2u) { - if (casts[0u] == binX && casts[1u] == binY) { + if (casts[0u] == BinningValue::binX && casts[1u] == BinningValue::binY) { accLink = 1u; - } else if (casts[0u] == binR && casts[1u] == binPhi) { + } else if (casts[0u] == BinningValue::binR && + casts[1u] == BinningValue::binPhi) { accLink = 3u; - } else if (casts[0u] == binZ && casts[1u] == binPhi) { + } else if (casts[0u] == BinningValue::binZ && + casts[1u] == BinningValue::binPhi) { accLink = 4u; - } else if (casts[0u] == binZ && casts[1u] == binR) { + } else if (casts[0u] == BinningValue::binZ && + casts[1u] == BinningValue::binR) { accLink = 5u; } } else if (casts.size() == 3u) { - if (casts[0u] == binX && casts[1u] == binY && casts[2u] == binZ) { + if (casts[0u] == BinningValue::binX && casts[1u] == BinningValue::binY && + casts[2u] == BinningValue::binZ) { accLink = 2u; - } else if (casts[0u] == binZ && casts[1u] == binPhi && casts[2u] == binR) { + } else if (casts[0u] == BinningValue::binZ && + casts[1u] == BinningValue::binPhi && + casts[2u] == BinningValue::binR) { accLink = 5u; } } diff --git a/Plugins/Json/include/Acts/Plugins/Json/IndexedGridJsonHelper.hpp b/Plugins/Json/include/Acts/Plugins/Json/IndexedGridJsonHelper.hpp index cd3d96c46bf..27f8c60fa59 100644 --- a/Plugins/Json/include/Acts/Plugins/Json/IndexedGridJsonHelper.hpp +++ b/Plugins/Json/include/Acts/Plugins/Json/IndexedGridJsonHelper.hpp @@ -46,8 +46,8 @@ nlohmann::json convertImpl(const index_grid& indexGrid, bool detray = false, jCasts.push_back(indexGrid.casts[0u]); jCasts.push_back(indexGrid.casts[1u]); // Check for axis swap (detray version) - swapAxes = checkSwap && - (indexGrid.casts[0u] == binZ && indexGrid.casts[1u] == binPhi); + swapAxes = checkSwap && (indexGrid.casts[0u] == BinningValue::binZ && + indexGrid.casts[1u] == BinningValue::binPhi); } jIndexedGrid["casts"] = jCasts; jIndexedGrid["transform"] = diff --git a/Plugins/Json/src/ExtentJsonConverter.cpp b/Plugins/Json/src/ExtentJsonConverter.cpp index 8f644ce765e..5e509d74e97 100644 --- a/Plugins/Json/src/ExtentJsonConverter.cpp +++ b/Plugins/Json/src/ExtentJsonConverter.cpp @@ -19,14 +19,12 @@ #include void Acts::to_json(nlohmann::json& j, const Acts::Extent& e) { - const auto& bValueNames = binningValueNames(); - { nlohmann::json jrange; const auto& xrange = e.range(); - for (auto [ib, ibv] : enumerate(s_binningValues)) { + for (auto ibv : allBinningValues()) { if (e.constrains(ibv)) { - jrange[bValueNames[ib]] = xrange[ib]; + jrange[binningValueName(ibv)] = xrange[toUnderlying(ibv)]; } } j["range"] = jrange; @@ -35,10 +33,10 @@ void Acts::to_json(nlohmann::json& j, const Acts::Extent& e) { { nlohmann::json jenvelope; const auto& envelope = e.envelope(); - for (auto [ib, ibv] : enumerate(s_binningValues)) { + for (auto ibv : allBinningValues()) { if (envelope[ibv] != zeroEnvelope) { - jenvelope[bValueNames[ib]] = - Range1D(envelope[ib][0], envelope[ib][1]); + jenvelope[binningValueName(ibv)] = + Range1D(envelope[ibv][0], envelope[ibv][1]); } } if (!jenvelope.empty()) { @@ -48,26 +46,22 @@ void Acts::to_json(nlohmann::json& j, const Acts::Extent& e) { } void Acts::from_json(const nlohmann::json& j, Acts::Extent& e) { - const auto& bValueNames = binningValueNames(); + const auto& jrange = j["range"]; - { - const auto& jrange = j["range"]; - for (auto [ib, bvn] : enumerate(bValueNames)) { - if (jrange.contains(bvn)) { - e.set(static_cast(ib), jrange[bvn]["min"], - jrange[bvn]["max"]); - } - } + for (const auto& [key, value] : jrange.items()) { + BinningValue bval = binningValueFromName(key); + e.set(bval, value["min"], value["max"]); } if (j.contains("envelope")) { const auto& jenvelope = j["envelope"]; ExtentEnvelope envelope; - for (auto [ib, bvn] : enumerate(bValueNames)) { - if (jenvelope.find(bvn) != jenvelope.end()) { - envelope[ib] = {jenvelope[bvn]["min"], jenvelope[bvn]["max"]}; - } + + for (const auto& [key, value] : jenvelope.items()) { + BinningValue bval = binningValueFromName(key); + envelope[bval] = {value["min"], value["max"]}; } + e.setEnvelope(envelope); } } diff --git a/Plugins/Json/src/GridJsonConverter.cpp b/Plugins/Json/src/GridJsonConverter.cpp index 4dddd4b7619..8d9a805b685 100644 --- a/Plugins/Json/src/GridJsonConverter.cpp +++ b/Plugins/Json/src/GridJsonConverter.cpp @@ -197,10 +197,12 @@ nlohmann::json Acts::GridAccessJsonConverter::toJson( std::array transformOptions = {false, true}; // One dimensional sub spaces - const std::tuple< - GridAccess::GlobalSubspace, GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, GridAccess::GlobalSubspace> + const std::tuple, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace> oneDimSubspaces = {}; for (bool transform : transformOptions) { @@ -212,16 +214,17 @@ nlohmann::json Acts::GridAccessJsonConverter::toJson( } // Useful two dimensional sub spaces - const std::tuple, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace, - GridAccess::GlobalSubspace> + const std::tuple< + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace, + GridAccess::GlobalSubspace> twoDimSubspaces = {}; for (bool transform : transformOptions) { @@ -246,23 +249,29 @@ Acts::GridAccessJsonConverter::globalToGridLocalFromJson( // Switch and fill for 1D if (accessors.size() == 1u) { switch (accessors[0]) { - case binX: - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); + case BinningValue::binX: + globalToGridLocal = + decodeGeneralSubspace(jGlobalToGridLocal); break; - case binY: - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); + case BinningValue::binY: + globalToGridLocal = + decodeGeneralSubspace(jGlobalToGridLocal); break; - case binZ: - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); + case BinningValue::binZ: + globalToGridLocal = + decodeGeneralSubspace(jGlobalToGridLocal); break; - case binR: - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); + case BinningValue::binR: + globalToGridLocal = + decodeGeneralSubspace(jGlobalToGridLocal); break; - case binPhi: - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); + case BinningValue::binPhi: + globalToGridLocal = + decodeGeneralSubspace(jGlobalToGridLocal); break; - case binEta: - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); + case BinningValue::binEta: + globalToGridLocal = + decodeGeneralSubspace(jGlobalToGridLocal); break; default: // globalToGridLocal = nullptr; @@ -272,30 +281,56 @@ Acts::GridAccessJsonConverter::globalToGridLocalFromJson( // Switch and fill for 2D if (accessors.size() == 2u) { - if (accessors == std::vector{binX, binY}) { - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binY, binX}) { - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binX, binZ}) { - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binZ, binX}) { - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binY, binZ}) { - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binZ, binY}) { - globalToGridLocal = decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binR, binPhi}) { + if (accessors == + std::vector{BinningValue::binX, BinningValue::binY}) { + globalToGridLocal = + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binY, + BinningValue::binX}) { + globalToGridLocal = + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binX, + BinningValue::binZ}) { + globalToGridLocal = + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binZ, + BinningValue::binX}) { + globalToGridLocal = + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binY, + BinningValue::binZ}) { + globalToGridLocal = + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binZ, + BinningValue::binY}) { globalToGridLocal = - decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binPhi, binR}) { + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binR, + BinningValue::binPhi}) { globalToGridLocal = - decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binZ, binPhi}) { + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binPhi, + BinningValue::binR}) { globalToGridLocal = - decodeGeneralSubspace(jGlobalToGridLocal); - } else if (accessors == std::vector{binPhi, binZ}) { + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binZ, + BinningValue::binPhi}) { globalToGridLocal = - decodeGeneralSubspace(jGlobalToGridLocal); + decodeGeneralSubspace( + jGlobalToGridLocal); + } else if (accessors == std::vector{BinningValue::binPhi, + BinningValue::binZ}) { + globalToGridLocal = + decodeGeneralSubspace( + jGlobalToGridLocal); } // else globalToGridLocal = nullptr; } @@ -312,7 +347,9 @@ Acts::GridAccessJsonConverter::globalToGridLocal1DimDelegateFromJson( } // Unroll the decoration Acts::GridAccess::GlobalToGridLocal1DimDelegate delegate; - decorateGlobal1DimDelegate( + decorateGlobal1DimDelegate( delegate, jGlobalToGridLocal); return delegate; } @@ -329,26 +366,36 @@ Acts::GridAccessJsonConverter::globalToGridLocal2DimDelegateFromJson( Acts::GridAccess::GlobalToGridLocal2DimDelegate delegate; // Only the matching one will be applied, matching condition is checked inside // the call - may unroll this es well - decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); decorateGlobalDelegate(delegate, jGlobalToGridLocal); - decorateGlobalDelegate(delegate, jGlobalToGridLocal); + BinningValue::binX, BinningValue::binY>( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); decorateGlobalDelegate(delegate, jGlobalToGridLocal); + BinningValue::binZ, BinningValue::binY>( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); + decorateGlobalDelegate( + delegate, jGlobalToGridLocal); return delegate; } diff --git a/Plugins/Json/src/MaterialJsonConverter.cpp b/Plugins/Json/src/MaterialJsonConverter.cpp index 316d0507acb..cb718f01ba4 100644 --- a/Plugins/Json/src/MaterialJsonConverter.cpp +++ b/Plugins/Json/src/MaterialJsonConverter.cpp @@ -685,12 +685,12 @@ nlohmann::json Acts::MaterialJsonConverter::toJsonDetray( BinUtility bUtility = binnedMaterial->binUtility(); // Turn the bin value into a 2D grid if (bUtility.dimensions() == 1u) { - if (bUtility.binningData()[0u].binvalue == binR) { + if (bUtility.binningData()[0u].binvalue == BinningValue::binR) { // Turn to R-Phi - bUtility += BinUtility(1u, -M_PI, M_PI, closed, binR); - } else if (bUtility.binningData()[0u].binvalue == binZ) { + bUtility += BinUtility(1u, -M_PI, M_PI, closed, BinningValue::binR); + } else if (bUtility.binningData()[0u].binvalue == BinningValue::binZ) { // Turn to Phi-Z - swap needed - BinUtility nbUtility(1u, -M_PI, M_PI, closed, binPhi); + BinUtility nbUtility(1u, -M_PI, M_PI, closed, BinningValue::binPhi); nbUtility += bUtility; bUtility = std::move(nbUtility); swapped = true; @@ -698,8 +698,8 @@ nlohmann::json Acts::MaterialJsonConverter::toJsonDetray( std::runtime_error("Unsupported binning for Detray"); } } else if (bUtility.dimensions() == 2u && - bUtility.binningData()[0u].binvalue == binZ && - bUtility.binningData()[1u].binvalue == binPhi) { + bUtility.binningData()[0u].binvalue == BinningValue::binZ && + bUtility.binningData()[1u].binvalue == BinningValue::binPhi) { BinUtility nbUtility(bUtility.binningData()[1u]); nbUtility += bUtility.binningData()[0u]; bUtility = std::move(nbUtility); @@ -711,11 +711,11 @@ nlohmann::json Acts::MaterialJsonConverter::toJsonDetray( // Translate into grid index type int gridIndexType = 0; - if (bVal0 == binR && bVal1 == binPhi) { + if (bVal0 == BinningValue::binR && bVal1 == BinningValue::binPhi) { gridIndexType = 0; - } else if (bVal0 == binPhi && bVal1 == binZ) { + } else if (bVal0 == BinningValue::binPhi && bVal1 == BinningValue::binZ) { gridIndexType = 3; - } else if (bVal0 == binX && bVal1 == binY) { + } else if (bVal0 == BinningValue::binX && bVal1 == BinningValue::binY) { gridIndexType = 2; } else { std::runtime_error("Unsupported binning for Detray"); @@ -798,7 +798,7 @@ nlohmann::json Acts::MaterialJsonConverter::toJsonDetray( jAxis["label"] = ib; jAxis["bins"] = bData.bins(); ActsScalar offset = 0; - if (bData.binvalue == binZ) { + if (bData.binvalue == BinningValue::binZ) { offset = surface.center(Acts::GeometryContext{}).z(); } jAxis["edges"] = diff --git a/Plugins/Json/src/MaterialMapJsonConverter.cpp b/Plugins/Json/src/MaterialMapJsonConverter.cpp index c3b126eca14..e13a4ab59e6 100644 --- a/Plugins/Json/src/MaterialMapJsonConverter.cpp +++ b/Plugins/Json/src/MaterialMapJsonConverter.cpp @@ -118,9 +118,9 @@ Acts::SurfaceAndMaterialWithContext defaultSurfaceMaterial( Acts::s_epsilon ? Acts::closed : Acts::open, - Acts::binPhi); + Acts::BinningValue::binPhi); bUtility += Acts::BinUtility(1, radialBounds->rMin(), radialBounds->rMax(), - Acts::open, Acts::binR); + Acts::open, Acts::BinningValue::binR); } if (cylinderBounds != nullptr) { bUtility += Acts::BinUtility( @@ -133,40 +133,41 @@ Acts::SurfaceAndMaterialWithContext defaultSurfaceMaterial( Acts::s_epsilon ? Acts::closed : Acts::open, - Acts::binPhi); + Acts::BinningValue::binPhi); bUtility += Acts::BinUtility( 1, -1 * cylinderBounds->get(Acts::CylinderBounds::eHalfLengthZ), cylinderBounds->get(Acts::CylinderBounds::eHalfLengthZ), Acts::open, - Acts::binZ); + Acts::BinningValue::binZ); } if (annulusBounds != nullptr) { bUtility += Acts::BinUtility(1, annulusBounds->get(Acts::AnnulusBounds::eMinPhiRel), annulusBounds->get(Acts::AnnulusBounds::eMaxPhiRel), - Acts::open, Acts::binPhi); - bUtility += Acts::BinUtility(1, annulusBounds->rMin(), - annulusBounds->rMax(), Acts::open, Acts::binR); + Acts::open, Acts::BinningValue::binPhi); + bUtility += + Acts::BinUtility(1, annulusBounds->rMin(), annulusBounds->rMax(), + Acts::open, Acts::BinningValue::binR); } if (rectangleBounds != nullptr) { bUtility += Acts::BinUtility(1, rectangleBounds->get(Acts::RectangleBounds::eMinX), rectangleBounds->get(Acts::RectangleBounds::eMaxX), - Acts::open, Acts::binX); + Acts::open, Acts::BinningValue::binX); bUtility += Acts::BinUtility(1, rectangleBounds->get(Acts::RectangleBounds::eMinY), rectangleBounds->get(Acts::RectangleBounds::eMaxY), - Acts::open, Acts::binY); + Acts::open, Acts::BinningValue::binY); } if (trapezoidBounds != nullptr) { double halfLengthX = std::max(trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthXnegY), trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthXposY)); bUtility += Acts::BinUtility(1, -1 * halfLengthX, halfLengthX, Acts::open, - Acts::binX); + Acts::BinningValue::binX); bUtility += Acts::BinUtility( 1, -1 * trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthY), trapezoidBounds->get(Acts::TrapezoidBounds::eHalfLengthY), Acts::open, - Acts::binY); + Acts::BinningValue::binY); } return {surface, std::make_shared(bUtility), context}; @@ -190,7 +191,7 @@ Acts::TrackingVolumeAndMaterial defaultVolumeMaterial( bUtility += Acts::BinUtility(1, cyBounds->get(Acts::CylinderVolumeBounds::eMinR), cyBounds->get(Acts::CylinderVolumeBounds::eMaxR), - Acts::open, Acts::binR); + Acts::open, Acts::BinningValue::binR); bUtility += Acts::BinUtility( 1, -cyBounds->get(Acts::CylinderVolumeBounds::eHalfPhiSector), cyBounds->get(Acts::CylinderVolumeBounds::eHalfPhiSector), @@ -198,35 +199,36 @@ Acts::TrackingVolumeAndMaterial defaultVolumeMaterial( Acts::s_epsilon ? Acts::closed : Acts::open, - Acts::binPhi); + Acts::BinningValue::binPhi); bUtility += Acts::BinUtility( 1, -cyBounds->get(Acts::CylinderVolumeBounds::eHalfLengthZ), cyBounds->get(Acts::CylinderVolumeBounds::eHalfLengthZ), Acts::open, - Acts::binZ); + Acts::BinningValue::binZ); } if (cutcylBounds != nullptr) { bUtility += Acts::BinUtility( 1, cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eMinR), cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eMaxR), Acts::open, - Acts::binR); - bUtility += Acts::BinUtility(1, -M_PI, M_PI, Acts::closed, Acts::binPhi); + Acts::BinningValue::binR); + bUtility += Acts::BinUtility(1, -M_PI, M_PI, Acts::closed, + Acts::BinningValue::binPhi); bUtility += Acts::BinUtility( 1, -cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eHalfLengthZ), cutcylBounds->get(Acts::CutoutCylinderVolumeBounds::eHalfLengthZ), - Acts::open, Acts::binZ); + Acts::open, Acts::BinningValue::binZ); } else if (cuBounds != nullptr) { bUtility += Acts::BinUtility( 1, -cuBounds->get(Acts::CuboidVolumeBounds::eHalfLengthX), cuBounds->get(Acts::CuboidVolumeBounds::eHalfLengthX), Acts::open, - Acts::binX); + Acts::BinningValue::binX); bUtility += Acts::BinUtility( 1, -cuBounds->get(Acts::CuboidVolumeBounds::eHalfLengthY), cuBounds->get(Acts::CuboidVolumeBounds::eHalfLengthY), Acts::open, - Acts::binY); + Acts::BinningValue::binY); bUtility += Acts::BinUtility( 1, -cuBounds->get(Acts::CuboidVolumeBounds::eHalfLengthZ), cuBounds->get(Acts::CuboidVolumeBounds::eHalfLengthZ), Acts::open, - Acts::binZ); + Acts::BinningValue::binZ); } return {volume, std::make_shared(bUtility)}; } diff --git a/Plugins/Json/src/PortalJsonConverter.cpp b/Plugins/Json/src/PortalJsonConverter.cpp index 5a311b58f48..a394525a957 100644 --- a/Plugins/Json/src/PortalJsonConverter.cpp +++ b/Plugins/Json/src/PortalJsonConverter.cpp @@ -156,12 +156,14 @@ Acts::PortalJsonConverter::toJsonDetray( // Pick the surface dimension - via poly std::array clipRange = {0., 0.}; std::vector boundValues = surfaceAdjusted->bounds().values(); - if (surfaceType == Surface::SurfaceType::Cylinder && cast == binZ) { + if (surfaceType == Surface::SurfaceType::Cylinder && + cast == BinningValue::binZ) { ActsScalar zPosition = surfaceAdjusted->center(gctx).z(); clipRange = { zPosition - boundValues[CylinderBounds::BoundValues::eHalfLengthZ], zPosition + boundValues[CylinderBounds::BoundValues::eHalfLengthZ]}; - } else if (surfaceType == Surface::SurfaceType::Disc && cast == binR) { + } else if (surfaceType == Surface::SurfaceType::Disc && + cast == BinningValue::binR) { clipRange = {boundValues[RadialBounds::BoundValues::eMinR], boundValues[RadialBounds::BoundValues::eMaxR]}; } else { diff --git a/Plugins/TGeo/src/TGeoLayerBuilder.cpp b/Plugins/TGeo/src/TGeoLayerBuilder.cpp index fca4d96bc77..9476bca114a 100644 --- a/Plugins/TGeo/src/TGeoLayerBuilder.cpp +++ b/Plugins/TGeo/src/TGeoLayerBuilder.cpp @@ -149,10 +149,13 @@ void Acts::TGeoLayerBuilder::buildLayers(const GeometryContext& gctx, if (type == 0) { ProtoLayer pl(gctx, lSurfaces); ACTS_DEBUG("- creating CylinderLayer with " - << lSurfaces.size() << " surfaces at r = " << pl.medium(binR)); + << lSurfaces.size() + << " surfaces at r = " << pl.medium(BinningValue::binR)); - pl.envelope[Acts::binR] = {lCfg.envelope.first, lCfg.envelope.second}; - pl.envelope[Acts::binZ] = {lCfg.envelope.second, lCfg.envelope.second}; + pl.envelope[Acts::BinningValue::binR] = {lCfg.envelope.first, + lCfg.envelope.second}; + pl.envelope[Acts::BinningValue::binZ] = {lCfg.envelope.second, + lCfg.envelope.second}; if (nb0 >= 0 && nb1 >= 0) { layers.push_back( m_cfg.layerCreator->cylinderLayer(gctx, lSurfaces, nb0, nb1, pl)); @@ -163,10 +166,13 @@ void Acts::TGeoLayerBuilder::buildLayers(const GeometryContext& gctx, } else { ProtoLayer pl(gctx, lSurfaces); ACTS_DEBUG("- creating DiscLayer with " - << lSurfaces.size() << " surfaces at z = " << pl.medium(binZ)); + << lSurfaces.size() + << " surfaces at z = " << pl.medium(BinningValue::binZ)); - pl.envelope[Acts::binR] = {lCfg.envelope.first, lCfg.envelope.second}; - pl.envelope[Acts::binZ] = {lCfg.envelope.second, lCfg.envelope.second}; + pl.envelope[Acts::BinningValue::binR] = {lCfg.envelope.first, + lCfg.envelope.second}; + pl.envelope[Acts::BinningValue::binZ] = {lCfg.envelope.second, + lCfg.envelope.second}; if (nb0 >= 0 && nb1 >= 0) { layers.push_back( m_cfg.layerCreator->discLayer(gctx, lSurfaces, nb0, nb1, pl)); @@ -186,7 +192,7 @@ void Acts::TGeoLayerBuilder::buildLayers(const GeometryContext& gctx, if (!layerCfg.parseRanges.empty()) { for (const auto& pRange : layerCfg.parseRanges) { ACTS_DEBUG("- layer parsing restricted in " - << binningValueNames()[pRange.first] << " to [" + << binningValueName(pRange.first) << " to [" << pRange.second.first << "/" << pRange.second.second << "]."); } @@ -194,7 +200,7 @@ void Acts::TGeoLayerBuilder::buildLayers(const GeometryContext& gctx, if (!layerCfg.splitConfigs.empty()) { for (const auto& sConfig : layerCfg.splitConfigs) { ACTS_DEBUG("- layer splitting attempt in " - << binningValueNames()[sConfig.first] << " with tolerance " + << binningValueName(sConfig.first) << " with tolerance " << sConfig.second << "."); } } @@ -234,7 +240,7 @@ void Acts::TGeoLayerBuilder::buildLayers(const GeometryContext& gctx, ACTS_DEBUG("- applying " << layerCfg.parseRanges.size() << " search restrictions."); for (const auto& prange : layerCfg.parseRanges) { - ACTS_VERBOSE(" - range " << binningValueNames()[prange.first] + ACTS_VERBOSE(" - range " << binningValueName(prange.first) << " within [ " << prange.second.first << ", " << prange.second.second << "]"); } diff --git a/Tests/Benchmarks/BinUtilityBenchmark.cpp b/Tests/Benchmarks/BinUtilityBenchmark.cpp index 463a4d7d70e..6c9abdf5e4d 100644 --- a/Tests/Benchmarks/BinUtilityBenchmark.cpp +++ b/Tests/Benchmarks/BinUtilityBenchmark.cpp @@ -50,14 +50,14 @@ int main(int argc, char* argv[]) { for (unsigned int ib = 0; ib < 6; ++ib) { fewBins.push_back(ib * 6. / 5.); } - Acts::BinUtility small(fewBins, Acts::open, Acts::binX); + Acts::BinUtility small(fewBins, Acts::open, Acts::BinningValue::binX); std::vector mediumBins; mediumBins.reserve(21); for (unsigned int ib = 0; ib < 21; ++ib) { mediumBins.push_back(ib * 6. / 20.); } - Acts::BinUtility medium(mediumBins, Acts::open, Acts::binX); + Acts::BinUtility medium(mediumBins, Acts::open, Acts::BinningValue::binX); std::vector manyBins; manyBins.reserve(101); @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) { manyBins.push_back(ib * 6. / 100.); } - Acts::BinUtility many(manyBins, Acts::open, Acts::binX); + Acts::BinUtility many(manyBins, Acts::open, Acts::BinningValue::binX); Acts::Vector3 low = Acts::Vector3(1.5, 0., 0.); Acts::Vector3 high = Acts::Vector3(4.5, 0., 0.); @@ -124,7 +124,8 @@ int main(int argc, char* argv[]) { ACTS_INFO("Execution stats many: " << bin_utility_benchmark_many); ACTS_INFO("Fraction is: " << st << " vs. " << gt); - Acts::BinUtility equidistant(100, 0., 6., Acts::open, Acts::binX); + Acts::BinUtility equidistant(100, 0., 6., Acts::open, + Acts::BinningValue::binX); st = 0; gt = 0; num_iters = 0; diff --git a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp index 0e569c2fc68..b13c4843baf 100644 --- a/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp +++ b/Tests/CommonHelpers/Acts/Tests/CommonHelpers/CylindricalTrackingGeometry.hpp @@ -303,7 +303,7 @@ struct CylindricalTrackingGeometry { // create the layer and store it ProtoLayer protoLayer(geoContext, layerSurfaces); - protoLayer.envelope[binR] = {0.5, 0.5}; + protoLayer.envelope[BinningValue::binR] = {0.5, 0.5}; auto pLayer = layerCreator->cylinderLayer( geoContext, std::move(layerSurfacePtrs), pLayerBinning[ilp].first, pLayerBinning[ilp].second, protoLayer); @@ -317,8 +317,8 @@ struct CylindricalTrackingGeometry { } // loop over layers // layer array - auto pLayerArray = layerArrayCreator->layerArray(geoContext, pLayers, 25., - 300., arbitrary, binR); + auto pLayerArray = layerArrayCreator->layerArray( + geoContext, pLayers, 25., 300., arbitrary, BinningValue::binR); auto pVolumeBounds = std::make_shared(25., 300., 1100.); // create the Tracking volume diff --git a/Tests/UnitTests/Core/Detector/BlueprintHelperTests.cpp b/Tests/UnitTests/Core/Detector/BlueprintHelperTests.cpp index 0f704545e7b..a307d8cba8d 100644 --- a/Tests/UnitTests/Core/Detector/BlueprintHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/BlueprintHelperTests.cpp @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_SUITE(Experimental) BOOST_AUTO_TEST_CASE(BlueprintHelperSorting) { // Create root node - std::vector detectorBinning = {Acts::binR}; + std::vector detectorBinning = {Acts::BinningValue::binR}; std::vector detectorBoundaries = {0., 50., 100.}; auto detector = std::make_unique( "detector", Acts::Transform3::Identity(), Acts::VolumeBounds::eCylinder, @@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(BlueprintHelperSorting) { BOOST_CHECK(detector->children.empty()); BOOST_CHECK_EQUAL(detector->name, "detector"); - std::vector pixelsBinning = {Acts::binZ}; + std::vector pixelsBinning = {Acts::BinningValue::binZ}; std::vector pixelsBoundaries = {20., 50., 100.}; auto pixels = std::make_unique( @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(BlueprintCylindricalGapFilling) { std::make_shared(); // Create root node - std::vector detectorBinning = {Acts::binR}; + std::vector detectorBinning = {Acts::BinningValue::binR}; std::vector detectorBoundaries = {detectorIr, detectorOr, detectorHz}; @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(BlueprintCylindricalGapFilling) { // A pixel system std::vector pixelBoundaries = {pixelIr, pixelOr, detectorHz}; - std::vector pixelBinning = {Acts::binZ}; + std::vector pixelBinning = {Acts::BinningValue::binZ}; auto pixel = std::make_unique( "pixel", Acts::Transform3::Identity(), Acts::VolumeBounds::eCylinder, pixelBoundaries, pixelBinning); @@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(BlueprintCylindricalGapFilling) { // Nec: Small differences to check if the adjustments are made std::vector pixelEcBoundaries = {pixelIr, pixelOr - 5., pixelEcHz}; - std::vector pixelEcBinning = {Acts::binZ}; + std::vector pixelEcBinning = {Acts::BinningValue::binZ}; auto pixelNec = std::make_unique( "pixelNec", @@ -155,7 +155,8 @@ BOOST_AUTO_TEST_CASE(BlueprintCylindricalGapFilling) { // Barrel std::vector pixelBarrelBoundaries = { pixelIr + 1, pixelOr - 1., detectorHz - 2 * pixelEcHz}; - std::vector pixelBarrelBinning = {Acts::binR}; + std::vector pixelBarrelBinning = { + Acts::BinningValue::binR}; auto pixelBarrel = std::make_unique( "pixelBarrel", Acts::Transform3::Identity(), @@ -265,7 +266,7 @@ BOOST_AUTO_TEST_CASE(BlueprintCylindricalGapException) { // The root node - detector std::vector detectorBoundaries = {0., 50., 100.}; - std::vector detectorBinning = {Acts::binX}; + std::vector detectorBinning = {Acts::BinningValue::binX}; auto detector = std::make_unique( "detector", Acts::Transform3::Identity(), Acts::VolumeBounds::eCylinder, detectorBoundaries, detectorBinning); diff --git a/Tests/UnitTests/Core/Detector/BlueprintTests.cpp b/Tests/UnitTests/Core/Detector/BlueprintTests.cpp index a8d2acfcaaa..323de9218a7 100644 --- a/Tests/UnitTests/Core/Detector/BlueprintTests.cpp +++ b/Tests/UnitTests/Core/Detector/BlueprintTests.cpp @@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(BlueprintTest) { std::vector bValues = {0., 10., 100.}; // Create root node - std::vector binning = {Acts::binR}; + std::vector binning = {Acts::BinningValue::binR}; auto root = std::make_unique( "detector", Acts::Transform3::Identity(), Acts::VolumeBounds::eOther, bValues, binning); diff --git a/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp index 1d26fc7b0eb..70243622fe9 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalContainerBuilderTests.cpp @@ -125,14 +125,15 @@ BOOST_AUTO_TEST_CASE(CuboidalContainerBuilder_Misconfiguration) { std::invalid_argument); // misconfiguration - 1D binning not in x, y, z misCfg.builders = {nullptr}; - misCfg.binning = Acts::binR; + misCfg.binning = Acts::BinningValue::binR; BOOST_CHECK_THROW(auto b = CuboidalContainerBuilder(misCfg), std::invalid_argument); } BOOST_AUTO_TEST_CASE(CuboidalContainerBuildingXYZVolumes) { - std::array binningValues = {Acts::binX, Acts::binY, - Acts::binZ}; + std::array binningValues = {Acts::BinningValue::binX, + Acts::BinningValue::binY, + Acts::BinningValue::binZ}; for (auto bVal : binningValues) { // A perfect box shape auto box = Acts::CuboidVolumeBounds(10, 10, 10); @@ -141,7 +142,7 @@ BOOST_AUTO_TEST_CASE(CuboidalContainerBuildingXYZVolumes) { auto transformB = Acts::Transform3::Identity(); Acts::Vector3 translation = Acts::Vector3::Zero(); - translation[bVal] = 20; + translation[toUnderlying(bVal)] = 20; transformB.pretranslate(translation); auto builderA = std::make_shared( @@ -167,10 +168,14 @@ BOOST_AUTO_TEST_CASE(CuboidalContainerBuildingXYZVolumes) { BOOST_CHECK_EQUAL(roots.volumes.size(), 2u); BOOST_CHECK_EQUAL(roots.volumes.at(0)->geometryId().volume(), 1u); BOOST_CHECK_EQUAL(roots.volumes.at(1)->geometryId().volume(), 2u); - BOOST_CHECK_EQUAL( - roots.volumes.at(0)->transform(tContext).translation()[bVal], 0); - BOOST_CHECK_EQUAL( - roots.volumes.at(1)->transform(tContext).translation()[bVal], 20); + BOOST_CHECK_EQUAL(roots.volumes.at(0) + ->transform(tContext) + .translation()[toUnderlying(bVal)], + 0); + BOOST_CHECK_EQUAL(roots.volumes.at(1) + ->transform(tContext) + .translation()[toUnderlying(bVal)], + 20); for (auto& portal : portals) { if (portal.second->attachedDetectorVolumes().at(0).empty()) { diff --git a/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp index 0137d8ffcd9..3365afeedcb 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalDetectorFromBlueprintTests.cpp @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(CuboidalDetectorFromBlueprintTest) { Acts::ActsScalar pixelZ = 10; // Create root node - std::vector detectorBins = {Acts::binX}; + std::vector detectorBins = {Acts::BinningValue::binX}; std::vector detectorBounds = {detectorX, detectorY, detectorZ}; @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(CuboidalDetectorFromBlueprintTest) { std::vector leftArmBounds = {detectorX * 0.5, detectorY, detectorZ}; - std::vector leftArmBins = {Acts::binZ}; + std::vector leftArmBins = {Acts::BinningValue::binZ}; Acts::Transform3 leftArmTransform = Acts::Transform3::Identity() * @@ -155,7 +155,7 @@ BOOST_AUTO_TEST_CASE(CuboidalDetectorFromBlueprintTest) { std::vector rightArmBounds = {detectorX * 0.5, detectorY, detectorZ}; - std::vector rightArmBins = {Acts::binZ}; + std::vector rightArmBins = {Acts::BinningValue::binZ}; Acts::Transform3 rightArmTransform = Acts::Transform3::Identity() * Acts::Translation3(detectorX * 0.5, 0., 0); @@ -258,38 +258,78 @@ BOOST_AUTO_TEST_CASE(CuboidalDetectorFromBlueprintTest) { // Volumes have to be contained within the // initial detector bounds double internalStretchLeftZ = - detector->volumes()[0]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[1]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[2]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[3]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[4]->volumeBounds().values()[Acts::binZ]; + detector->volumes()[0] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[1] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[2] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[3] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[4] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)]; double internalStretchRightZ = - detector->volumes()[5]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[6]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[7]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[8]->volumeBounds().values()[Acts::binZ] + - detector->volumes()[9]->volumeBounds().values()[Acts::binZ]; + detector->volumes()[5] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[6] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[7] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[8] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)] + + detector->volumes()[9] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binZ)]; double internalStretchX1 = - detector->volumes()[0]->volumeBounds().values()[Acts::binX] + - detector->volumes()[5]->volumeBounds().values()[Acts::binX]; + detector->volumes()[0] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)] + + detector->volumes()[5] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)]; double internalStretchX2 = - detector->volumes()[1]->volumeBounds().values()[Acts::binX] + - detector->volumes()[6]->volumeBounds().values()[Acts::binX]; + detector->volumes()[1] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)] + + detector->volumes()[6] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)]; double internalStretchX3 = - detector->volumes()[2]->volumeBounds().values()[Acts::binX] + - detector->volumes()[7]->volumeBounds().values()[Acts::binX]; + detector->volumes()[2] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)] + + detector->volumes()[7] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)]; double internalStretchX4 = - detector->volumes()[3]->volumeBounds().values()[Acts::binX] + - detector->volumes()[8]->volumeBounds().values()[Acts::binX]; + detector->volumes()[3] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)] + + detector->volumes()[8] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)]; double internalStretchX5 = - detector->volumes()[4]->volumeBounds().values()[Acts::binX] + - detector->volumes()[9]->volumeBounds().values()[Acts::binX]; + detector->volumes()[4] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)] + + detector->volumes()[9] + ->volumeBounds() + .values()[toUnderlying(Acts::BinningValue::binX)]; BOOST_CHECK_EQUAL(internalStretchLeftZ, detectorZ); BOOST_CHECK_EQUAL(internalStretchRightZ, detectorZ); @@ -300,7 +340,9 @@ BOOST_AUTO_TEST_CASE(CuboidalDetectorFromBlueprintTest) { BOOST_CHECK_EQUAL(internalStretchX5, detectorX); for (auto& volume : detector->volumes()) { - BOOST_CHECK_EQUAL(volume->volumeBounds().values()[Acts::binY], detectorY); + BOOST_CHECK_EQUAL( + volume->volumeBounds().values()[toUnderlying(Acts::BinningValue::binY)], + detectorY); } // There should be surfaces inside the pixel diff --git a/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp b/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp index dc02f2a894f..2159a62b763 100644 --- a/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/CuboidalDetectorHelperTests.cpp @@ -49,15 +49,16 @@ BOOST_AUTO_TEST_CASE(CubicVolumeExceptions) { std::vector> volumes = { volumeA, volumeB}; - BOOST_CHECK_THROW( - Acts::Experimental::detail::CuboidalDetectorHelper::connect( - tContext, volumes, Acts::binX, {}, Acts::Logging::VERBOSE), - std::invalid_argument); + BOOST_CHECK_THROW(Acts::Experimental::detail::CuboidalDetectorHelper::connect( + tContext, volumes, Acts::BinningValue::binX, {}, + Acts::Logging::VERBOSE), + std::invalid_argument); } BOOST_AUTO_TEST_CASE(SimpleBoxConnection) { - std::array binningValues = {Acts::binX, Acts::binY, - Acts::binZ}; + std::array binningValues = {Acts::BinningValue::binX, + Acts::BinningValue::binY, + Acts::BinningValue::binZ}; for (auto bVal : binningValues) { // A perfect box shape auto box = std::make_shared(10, 10, 10); @@ -71,7 +72,7 @@ BOOST_AUTO_TEST_CASE(SimpleBoxConnection) { auto transformB = Acts::Transform3::Identity(); Acts::Vector3 translation = Acts::Vector3::Zero(); - translation[bVal] = 20; + translation[toUnderlying(bVal)] = 20; transformB.pretranslate(translation); // Create volume B auto volumeB = Acts::Experimental::DetectorVolumeFactory::construct( @@ -90,14 +91,15 @@ BOOST_AUTO_TEST_CASE(SimpleBoxConnection) { Acts::ObjVisualization3D obj; Acts::GeometryView3D::drawDetectorVolume(obj, *volumeA, tContext); Acts::GeometryView3D::drawDetectorVolume(obj, *volumeB, tContext); - obj.write("ConnectectBoxesRegular_" + Acts::binningValueNames()[bVal] + + obj.write("ConnectectBoxesRegular_" + Acts::binningValueName(bVal) + ".obj"); } } BOOST_AUTO_TEST_CASE(IrregularBoxConnectionInZ) { - std::vector binningValues = {Acts::binX, Acts::binY, - Acts::binZ}; + std::vector binningValues = {Acts::BinningValue::binX, + Acts::BinningValue::binY, + Acts::BinningValue::binZ}; using HlPos = std::array; using VolHlPos = std::array; @@ -121,7 +123,7 @@ BOOST_AUTO_TEST_CASE(IrregularBoxConnectionInZ) { auto rotation = t.rotation(); // Try for all binning values for (auto bVal : binningValues) { - auto [vsA, vsB, vsC] = volSetups[bVal]; + auto [vsA, vsB, vsC] = volSetups[toUnderlying(bVal)]; // Three box shares with different length in Z auto boxA = std::make_shared( @@ -168,7 +170,7 @@ BOOST_AUTO_TEST_CASE(IrregularBoxConnectionInZ) { Acts::GeometryView3D::drawDetectorVolume(obj, *volumeA, tContext); Acts::GeometryView3D::drawDetectorVolume(obj, *volumeB, tContext); Acts::GeometryView3D::drawDetectorVolume(obj, *volumeC, tContext); - obj.write("ConnectectBoxesIrregular_" + Acts::binningValueNames()[bVal] + + obj.write("ConnectectBoxesIrregular_" + Acts::binningValueName(bVal) + trstr + ".obj"); } } @@ -188,7 +190,7 @@ BOOST_AUTO_TEST_CASE(ContainerConnection) { // Move it into the bval direction auto transformB = Acts::Transform3::Identity(); Acts::Vector3 translationB = Acts::Vector3::Zero(); - translationB[Acts::binX] = 20; + translationB[toUnderlying(Acts::BinningValue::binX)] = 20; transformB.pretranslate(translationB); // Create volume B auto volumeB = Acts::Experimental::DetectorVolumeFactory::construct( @@ -199,13 +201,14 @@ BOOST_AUTO_TEST_CASE(ContainerConnection) { volumeA, volumeB}; auto containerAB = Acts::Experimental::detail::CuboidalDetectorHelper::connect( - tContext, volumes, Acts::binX, {}, Acts::Logging::VERBOSE); + tContext, volumes, Acts::BinningValue::binX, {}, + Acts::Logging::VERBOSE); // Create a CD container auto transformC = Acts::Transform3::Identity(); Acts::Vector3 translationC = Acts::Vector3::Zero(); - translationC[Acts::binY] = 20; + translationC[toUnderlying(Acts::BinningValue::binY)] = 20; transformC.pretranslate(translationC); auto volumeC = Acts::Experimental::DetectorVolumeFactory::construct( @@ -214,8 +217,8 @@ BOOST_AUTO_TEST_CASE(ContainerConnection) { auto transformD = Acts::Transform3::Identity(); Acts::Vector3 translationD = Acts::Vector3::Zero(); - translationD[Acts::binX] = 20; - translationD[Acts::binY] = 20; + translationD[toUnderlying(Acts::BinningValue::binX)] = 20; + translationD[toUnderlying(Acts::BinningValue::binY)] = 20; transformD.pretranslate(translationD); auto volumeD = Acts::Experimental::DetectorVolumeFactory::construct( @@ -225,11 +228,12 @@ BOOST_AUTO_TEST_CASE(ContainerConnection) { volumes = {volumeC, volumeD}; auto containerCD = Acts::Experimental::detail::CuboidalDetectorHelper::connect( - tContext, volumes, Acts::binX, {}, Acts::Logging::VERBOSE); + tContext, volumes, Acts::BinningValue::binX, {}, + Acts::Logging::VERBOSE); auto containerABCD = Acts::Experimental::detail::CuboidalDetectorHelper::connect( - tContext, {containerAB, containerCD}, Acts::binY, {}, + tContext, {containerAB, containerCD}, Acts::BinningValue::binY, {}, Acts::Logging::VERBOSE); // Check the container is constructed diff --git a/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp index 98edad2f301..5fe880f57dd 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalContainerBuilderTests.cpp @@ -132,19 +132,19 @@ BOOST_AUTO_TEST_CASE(CylindricaContainerBuilder_Misconfiguration) { std::invalid_argument); // misconfiguration - 1D binning not in z, r, phi misCfg.builders = {nullptr}; - misCfg.binning = {Acts::binX}; + misCfg.binning = {Acts::BinningValue::binX}; BOOST_CHECK_THROW(auto b = CylindricalContainerBuilder(misCfg), std::invalid_argument); // misconfiguration - 2D binning not in z, r, misCfg.builders = {nullptr, nullptr}; - misCfg.binning = {Acts::binZ, Acts::binPhi}; + misCfg.binning = {Acts::BinningValue::binZ, Acts::BinningValue::binPhi}; BOOST_CHECK_THROW(auto c = CylindricalContainerBuilder(misCfg), std::invalid_argument); // misconfiguration - 2D binning in z, r, but not exactly 2 builders misCfg.builders = {nullptr, nullptr, nullptr}; - misCfg.binning = {Acts::binZ, Acts::binR}; + misCfg.binning = {Acts::BinningValue::binZ, Acts::BinningValue::binR}; BOOST_CHECK_THROW(auto d = CylindricalContainerBuilder(misCfg), std::invalid_argument); } @@ -175,12 +175,13 @@ BOOST_AUTO_TEST_CASE(CylindricaContainerBuildingZ) { CylindricalContainerBuilder::Config tripleZCfg; tripleZCfg.auxiliary = "*** Test 0 - Build triple in Z ***"; tripleZCfg.builders = {negDisc, barrel, posDisc}; - tripleZCfg.binning = {binZ}; + tripleZCfg.binning = {BinningValue::binZ}; tripleZCfg.geoIdGenerator = std::make_shared(); // Create a materialBinning tripleZCfg.portalMaterialBinning[2u] = BinningDescription{ - {ProtoBinning(binZ, Acts::AxisBoundaryType::Bound, 50), - ProtoBinning(binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 12)}}; + {ProtoBinning(BinningValue::binZ, Acts::AxisBoundaryType::Bound, 50), + ProtoBinning(BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, + M_PI, 12)}}; // Let's test the reverse generation tripleZCfg.geoIdReverseGen = true; @@ -227,7 +228,7 @@ BOOST_AUTO_TEST_CASE(CylindricaContainerBuildingR) { CylindricalContainerBuilder::Config barrelRCfg; barrelRCfg.auxiliary = "*** Test 1 - Build multilayer barrel ***"; barrelRCfg.builders = {barrel0, barrel1, barrel2}; - barrelRCfg.binning = {binR}; + barrelRCfg.binning = {BinningValue::binR}; barrelRCfg.geoIdGenerator = std::make_shared(); auto barrelR = std::make_shared( @@ -246,7 +247,7 @@ BOOST_AUTO_TEST_CASE(CylindricaContainerBuildingPhi) { // Create the container builder CylindricalContainerBuilder::Config barrelPhiCfg; barrelPhiCfg.auxiliary = "*** Test 2 - Build segmented phi barrel ***"; - barrelPhiCfg.binning = {binPhi}; + barrelPhiCfg.binning = {BinningValue::binPhi}; unsigned int phiSectors = 5; Acts::ActsScalar phiHalfSector = M_PI / phiSectors; @@ -312,7 +313,7 @@ BOOST_AUTO_TEST_CASE(CylindricalContainerBuilderDetector) { // Create the barrel container builder CylindricalContainerBuilder::Config barrelRCfg; barrelRCfg.builders = {barrel0, barrel1, barrel2}; - barrelRCfg.binning = {binR}; + barrelRCfg.binning = {BinningValue::binR}; auto barrel = std::make_shared( barrelRCfg, getDefaultLogger("BarrelBuilderR", Logging::VERBOSE)); @@ -327,7 +328,7 @@ BOOST_AUTO_TEST_CASE(CylindricalContainerBuilderDetector) { // Create the barrel container builder CylindricalContainerBuilder::Config barrelEndcapCfg; barrelEndcapCfg.builders = {endcapN, barrel, endcapP}; - barrelEndcapCfg.binning = {binZ}; + barrelEndcapCfg.binning = {BinningValue::binZ}; auto barrelEndcap = std::make_shared( barrelEndcapCfg, @@ -336,7 +337,7 @@ BOOST_AUTO_TEST_CASE(CylindricalContainerBuilderDetector) { // Create the barrel container builder CylindricalContainerBuilder::Config detectorCfg; detectorCfg.builders = {beampipe, barrelEndcap}; - detectorCfg.binning = {binR}; + detectorCfg.binning = {BinningValue::binR}; auto detector = std::make_shared( detectorCfg, getDefaultLogger("DetectorBuilder", Logging::VERBOSE)); diff --git a/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp b/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp index 49d4ddfb100..427a1effa11 100644 --- a/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp +++ b/Tests/UnitTests/Core/Detector/CylindricalDetectorFromBlueprintTests.cpp @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(CylindricalDetectorFromBlueprintTest) { Acts::ActsScalar pixelEcLayerHz = 10; // Create root node - std::vector detectorBinning = {Acts::binR}; + std::vector detectorBinning = {Acts::BinningValue::binR}; std::vector detectorBoundaries = {detectorIr, detectorOr, detectorHz}; @@ -116,7 +116,7 @@ BOOST_AUTO_TEST_CASE(CylindricalDetectorFromBlueprintTest) { // A pixel system std::vector pixelBoundaries = {pixelIr, pixelOr, detectorHz}; - std::vector pixelBinning = {Acts::binZ}; + std::vector pixelBinning = {Acts::BinningValue::binZ}; auto pixel = std::make_unique( "pixel", Acts::Transform3::Identity(), Acts::VolumeBounds::eCylinder, pixelBoundaries, pixelBinning); @@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE(CylindricalDetectorFromBlueprintTest) { // Nec: Small differences to check if the adjustments are made std::vector pixelEcBoundaries = {pixelIr, pixelOr - 5., pixelEcHz}; - std::vector pixelEcBinning = {Acts::binZ}; + std::vector pixelEcBinning = {Acts::BinningValue::binZ}; Acts::Transform3 pixelNecTransform = Acts::Transform3::Identity() * @@ -151,7 +151,8 @@ BOOST_AUTO_TEST_CASE(CylindricalDetectorFromBlueprintTest) { // Barrel std::vector pixelBarrelBoundaries = { pixelIr + 1, pixelOr - 1., detectorHz - 2 * pixelEcHz}; - std::vector pixelBarrelBinning = {Acts::binR}; + std::vector pixelBarrelBinning = { + Acts::BinningValue::binR}; auto pixelBarrel = std::make_unique( "pixel_barrel", Acts::Transform3::Identity(), @@ -210,7 +211,8 @@ BOOST_AUTO_TEST_CASE(CylindricalDetectorFromBlueprintTest) { detectorBpr->add(std::move(pixel)); // An Indexed volume finder will be attached - std::vector rootVolumeBinning = {Acts::binZ, Acts::binR}; + std::vector rootVolumeBinning = { + Acts::BinningValue::binZ, Acts::BinningValue::binR}; detectorBpr->rootVolumeFinderBuilder = std::make_shared( rootVolumeBinning); diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp index 522878468ad..641226f0c43 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeBuilderTests.cpp @@ -160,8 +160,9 @@ BOOST_AUTO_TEST_CASE(DetectorVolumeBuilder_EmptyVolume) { // Assign proto material to dvCfg.portalMaterialBinning[2u] = BinningDescription{ - {ProtoBinning(binZ, Acts::AxisBoundaryType::Bound, 50), - ProtoBinning(binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 12)}}; + {ProtoBinning(BinningValue::binZ, Acts::AxisBoundaryType::Bound, 50), + ProtoBinning(BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, + M_PI, 12)}}; auto dvBuilder = std::make_shared( dvCfg, getDefaultLogger("DetectorVolumeBuilder", Logging::VERBOSE)); diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp index 26bca183611..0bbabbaf293 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeConsistencyTests.cpp @@ -33,8 +33,8 @@ BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyFail) { // Move it into the bval direction auto transformB = Acts::Transform3::Identity(); Acts::Vector3 translationB = Acts::Vector3::Zero(); - translationB[Acts::binX] = 20; - translationB[Acts::binY] = 5; + translationB[toUnderlying(Acts::BinningValue::binX)] = 20; + translationB[toUnderlying(Acts::BinningValue::binY)] = 5; transformB.pretranslate(translationB); // Create volume B auto volumeB = Acts::Experimental::DetectorVolumeFactory::construct( @@ -44,10 +44,10 @@ BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyFail) { std::vector> volumes = { volumeA, volumeB}; - BOOST_CHECK_THROW( - Acts::Experimental::detail::DetectorVolumeConsistency:: - checkCenterAlignment(tContext, {volumeA, volumeB}, Acts::binX), - std::invalid_argument); + BOOST_CHECK_THROW(Acts::Experimental::detail::DetectorVolumeConsistency:: + checkCenterAlignment(tContext, {volumeA, volumeB}, + Acts::BinningValue::binX), + std::invalid_argument); } BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyPass) { @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyPass) { // Move it into the bval direction auto transformB = Acts::Transform3::Identity(); Acts::Vector3 translationB = Acts::Vector3::Zero(); - translationB[Acts::binX] = 20; + translationB[toUnderlying(Acts::BinningValue::binX)] = 20; transformB.pretranslate(translationB); // Create volume B auto volumeB = Acts::Experimental::DetectorVolumeFactory::construct( @@ -72,9 +72,9 @@ BOOST_AUTO_TEST_CASE(DetectorVolumeConsistencyPass) { std::vector> volumes = { volumeA, volumeB}; - BOOST_CHECK_NO_THROW( - Acts::Experimental::detail::DetectorVolumeConsistency:: - checkCenterAlignment(tContext, {volumeA, volumeB}, Acts::binX)); + BOOST_CHECK_NO_THROW(Acts::Experimental::detail::DetectorVolumeConsistency:: + checkCenterAlignment(tContext, {volumeA, volumeB}, + Acts::BinningValue::binX)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp b/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp index 9b8d8a91203..9221bc0eed0 100644 --- a/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp +++ b/Tests/UnitTests/Core/Detector/DetectorVolumeTests.cpp @@ -185,10 +185,10 @@ BOOST_AUTO_TEST_CASE(CylindricalDetectorVolumePortals) { // Check the extent auto volumeExtent = tubeCylinderVolume->extent(tContext, 1); - CHECK_CLOSE_ABS(volumeExtent.min(Acts::binR), 10., 10e-5); - CHECK_CLOSE_ABS(volumeExtent.max(Acts::binR), 100., 10e-5); - CHECK_CLOSE_ABS(volumeExtent.min(Acts::binZ), -200., 10e-5); - CHECK_CLOSE_ABS(volumeExtent.max(Acts::binZ), 200., 10e-5); + CHECK_CLOSE_ABS(volumeExtent.min(Acts::BinningValue::binR), 10., 10e-5); + CHECK_CLOSE_ABS(volumeExtent.max(Acts::BinningValue::binR), 100., 10e-5); + CHECK_CLOSE_ABS(volumeExtent.min(Acts::BinningValue::binZ), -200., 10e-5); + CHECK_CLOSE_ABS(volumeExtent.max(Acts::BinningValue::binZ), 200., 10e-5); } BOOST_AUTO_TEST_CASE(UpdatePortal) { diff --git a/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp b/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp index 50e6cb4f44a..956bb597047 100644 --- a/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedRootVolumeFinderBuilderTests.cpp @@ -68,7 +68,8 @@ BOOST_AUTO_TEST_CASE(IndexedRootVolumeFinderBuilderCylindrical) { std::vector> rootVolumes = { innerV, middleLV, middleDV, middleUV, middleRV, outerV}; - IndexedRootVolumeFinderBuilder builder({Acts::binZ, Acts::binR}); + IndexedRootVolumeFinderBuilder builder( + {Acts::BinningValue::binZ, Acts::BinningValue::binR}); // Let's construct a detector auto rootVolumeFinder = builder.construct(tContext, rootVolumes); diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp index f7f30da2849..d67b6a8fbe5 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfaceGridFillerTests.cpp @@ -126,8 +126,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfaceCenter) { std::move(axisY)); // Indexed Surface grid - IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY( + std::move(gridXY), {BinningValue::binX, BinningValue::binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -162,8 +162,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfaceBinValue) { std::move(axisY)); // Indexed Surface grid - IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY( + std::move(gridXY), {BinningValue::binX, BinningValue::binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -174,7 +174,7 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfaceBinValue) { IndexedGridFiller filler{{}}; filler.oLogger = getDefaultLogger("IndexGridFiller", Logging::VERBOSE); - BinningValueReferenceGenerator generator; + BinningValueReferenceGenerator generator; std::vector> surfaces = {pSurface}; // Fill the surface @@ -199,8 +199,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfacePolyhedron) { std::move(axisY)); // Indexed Surface grid - IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY( + std::move(gridXY), {BinningValue::binX, BinningValue::binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -236,8 +236,8 @@ BOOST_AUTO_TEST_CASE(IndexGridXYOneSurfacePolyhedronBinExpansion) { std::move(axisY)); // Indexed Surface grid - IndexedSurfacesNavigation indexedGridXY(std::move(gridXY), - {binX, binY}); + IndexedSurfacesNavigation indexedGridXY( + std::move(gridXY), {BinningValue::binX, BinningValue::binY}); // Create a single surface in the center auto rBounds = std::make_shared(4., 4.); @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfacePolyhedronBinExpansion) { // Indexed Surface grid IndexedSurfacesNavigation indexedGridZPhi( - std::move(gridZPhi), {binZ, binPhi}); + std::move(gridZPhi), {BinningValue::binZ, BinningValue::binPhi}); auto cBounds = std::make_shared(10, 2., M_PI / 30, 0.); auto cSurface = Surface::makeShared(Transform3::Identity(), @@ -309,7 +309,7 @@ BOOST_AUTO_TEST_CASE(IndexGridZPhiYOneSurfaceMPIPolyhedronBinExpansion) { // Indexed Surface grid IndexedSurfacesNavigation indexedGridZPhi( - std::move(gridZPhi), {binZ, binPhi}); + std::move(gridZPhi), {BinningValue::binZ, BinningValue::binPhi}); auto cBounds = std::make_shared(10, 2., M_PI / 10, 0.); auto tf = AngleAxis3(M_PI, Vector3::UnitZ()) * Transform3::Identity(); diff --git a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp index a95d52cf6ac..ab1212e4887 100644 --- a/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp +++ b/Tests/UnitTests/Core/Detector/IndexedSurfacesGeneratorTests.cpp @@ -53,7 +53,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { 55., 0., 2., 22u); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binPhi}}; + irSurfaces{rSurfaces, {}, {BinningValue::binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -98,7 +98,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { rSurfaces.push_back(dSurface.get()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {binPhi}}; + irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {BinningValue::binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binR, binPhi}}; + irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::VarBoundEqClosed aGenerator{ {24., 74., 110.}, {-M_PI, M_PI}, 44u}; @@ -191,7 +191,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binR, binPhi}}; + irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -238,7 +238,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binR, binPhi}, {2u, 4u}}; + irSurfaces{ + rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}, {2u, 4u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -272,7 +273,8 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { 116., 3., 2., {52, 14}); IndexedSurfacesGenerator - icSurfaces{surfaces, {}, {binZ, binPhi}, {1u, 1u}}; + icSurfaces{ + surfaces, {}, {BinningValue::binZ, BinningValue::binPhi}, {1u, 1u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {-500., 500}, 28, {-M_PI, M_PI}, 52u}; diff --git a/Tests/UnitTests/Core/Detector/KdtSurfacesProviderTests.cpp b/Tests/UnitTests/Core/Detector/KdtSurfacesProviderTests.cpp index f02102c1892..16a5e9f772c 100644 --- a/Tests/UnitTests/Core/Detector/KdtSurfacesProviderTests.cpp +++ b/Tests/UnitTests/Core/Detector/KdtSurfacesProviderTests.cpp @@ -99,12 +99,13 @@ BOOST_AUTO_TEST_CASE(KdtSurfacesProvider) { BOOST_CHECK_EQUAL(pSurfaces.size(), refNumber); using KDTS = Acts::Experimental::KdtSurfaces<>; - auto skdt = std::make_shared(KDTS(tContext, pSurfaces, {binZ, binR})); + auto skdt = std::make_shared( + KDTS(tContext, pSurfaces, {BinningValue::binZ, BinningValue::binR})); // query: Negative disc 3, it should yield 22 surfaces Acts::Extent regionND3; - regionND3.set(binZ, -820, -780); - regionND3.set(binR, 0., 200.); + regionND3.set(BinningValue::binZ, -820, -780); + regionND3.set(BinningValue::binR, 0., 200.); Acts::Experimental::KdtSurfacesProvider<> end3(skdt, regionND3); auto nd3 = end3.surfaces(tContext); @@ -112,8 +113,8 @@ BOOST_AUTO_TEST_CASE(KdtSurfacesProvider) { // query: 2nd Pixel barrel Acts::Extent regionB1; - regionB1.set(binZ, -580, 580); - regionB1.set(binR, 60., 80.); + regionB1.set(BinningValue::binZ, -580, 580); + regionB1.set(BinningValue::binR, 60., 80.); Acts::Experimental::KdtSurfacesProvider<> ba1(skdt, regionB1); diff --git a/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp b/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp index 35ec5a7c916..2e832a29f74 100644 --- a/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/LayerStructureBuilderTests.cpp @@ -66,8 +66,9 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationRing) { Acts::Experimental::LayerStructureBuilder::Config lsConfig; lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; - lsConfig.binnings = {ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 22u, 1u)}; + lsConfig.binnings = {ProtoBinning(Acts::BinningValue::binPhi, + Acts::AxisBoundaryType::Closed, -M_PI, M_PI, + 22u, 1u)}; auto endcapBuilder = Acts::Experimental::LayerStructureBuilder( lsConfig, Acts::getDefaultLogger("EndcapBuilder", Logging::VERBOSE)); @@ -87,7 +88,8 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationRing) { LayerSupport supportDisc; supportDisc.type = Acts::Surface::SurfaceType::Disc; supportDisc.offset = 15.; - supportDisc.internalConstraints = {Acts::binZ, Acts::binR}; + supportDisc.internalConstraints = {Acts::BinningValue::binZ, + Acts::BinningValue::binR}; lsConfig.auxiliary = "*** Endcap with 22 surfaces + 1 support disc, " @@ -115,9 +117,9 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationRing) { // clearance: z is still from internals, but r is from the volume/external // // Second test with one support disc, but external constraint - supportDisc.internalConstraints = {Acts::binZ}; - supportDisc.volumeExtent.set(Acts::binR, 10., 120.); - supportDisc.volumeClearance[Acts::binR] = {2., 1.}; + supportDisc.internalConstraints = {Acts::BinningValue::binZ}; + supportDisc.volumeExtent.set(Acts::BinningValue::binR, 10., 120.); + supportDisc.volumeClearance[Acts::BinningValue::binR] = {2., 1.}; lsConfig.supports = {supportDisc}; @@ -184,10 +186,12 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationCylinder) { lsConfig.auxiliary = "*** Barrel with 448 surfaces ***"; lsConfig.surfacesProvider = barrelSurfaces; lsConfig.binnings = { - Acts::Experimental::ProtoBinning{ - Acts::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, + Acts::AxisBoundaryType::Bound, -480., + 480., 14u, 1u}, + Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, + Acts::AxisBoundaryType::Closed, -M_PI, + M_PI, 32u, 1u)}; auto barrelBuilder = Acts::Experimental::LayerStructureBuilder( lsConfig, Acts::getDefaultLogger("BarrelBuilder", Logging::VERBOSE)); @@ -206,7 +210,8 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationCylinder) { LayerSupport supportCylinder; supportCylinder.type = Acts::Surface::SurfaceType::Cylinder; supportCylinder.offset = 15.; - supportCylinder.internalConstraints = {Acts::binZ, Acts::binR}; + supportCylinder.internalConstraints = {Acts::BinningValue::binZ, + Acts::BinningValue::binR}; lsConfig.supports = {supportCylinder}; lsConfig.auxiliary = "*** Barrel with 448 surfaces + 1 support cylinder, r/z evaluated ***"; @@ -223,9 +228,9 @@ BOOST_AUTO_TEST_CASE(LayerStructureBuilder_creationCylinder) { BOOST_CHECK(volumeUpdater1.connected()); // Second test: z-range externally given - supportCylinder.internalConstraints = {Acts::binR}; - supportCylinder.volumeExtent.set(Acts::binZ, -600., 600.); - supportCylinder.volumeClearance[Acts::binZ] = {2., 2.}; + supportCylinder.internalConstraints = {Acts::BinningValue::binR}; + supportCylinder.volumeExtent.set(Acts::BinningValue::binZ, -600., 600.); + supportCylinder.volumeClearance[Acts::BinningValue::binZ] = {2., 2.}; lsConfig.supports = {supportCylinder}; lsConfig.auxiliary = "*** Barrel with 448 surfaces + 1 support cylinder, r evaluated, z given " diff --git a/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp b/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp index f14048389d2..7f54da797b7 100644 --- a/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/MultiWireStructureBuilderTests.cpp @@ -70,10 +70,11 @@ BOOST_AUTO_TEST_CASE(Multi_Wire_Structure_Builder_StrawSurfacesCreation) { mlCfg.name = "Multi_Layer_With_Wires"; mlCfg.mlSurfaces = strawSurfaces; mlCfg.mlBounds = vBounds; - mlCfg.mlBinning = {ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, - -vBounds[0], vBounds[0], nSurfacesX, 1u), - ProtoBinning(Acts::binY, Acts::AxisBoundaryType::Bound, - -vBounds[1], vBounds[1], nSurfacesY, 0u)}; + mlCfg.mlBinning = { + ProtoBinning(Acts::BinningValue::binX, Acts::AxisBoundaryType::Bound, + -vBounds[0], vBounds[0], nSurfacesX, 1u), + ProtoBinning(Acts::BinningValue::binY, Acts::AxisBoundaryType::Bound, + -vBounds[1], vBounds[1], nSurfacesY, 0u)}; MultiWireStructureBuilder mlBuilder(mlCfg); auto [volumes, portals, roots] = mlBuilder.construct(tContext); diff --git a/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp b/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp index 77f1d7bce3a..05c4c5946a8 100644 --- a/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp +++ b/Tests/UnitTests/Core/Detector/ProtoBinningTests.cpp @@ -18,28 +18,29 @@ BOOST_AUTO_TEST_SUITE(Detector) BOOST_AUTO_TEST_CASE(ProtoBinningPlaceHolderEquidistant) { // A valid placeholder binning - auto peq = ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, 5u); + auto peq = + ProtoBinning(Acts::BinningValue::binX, Acts::AxisBoundaryType::Bound, 5u); BOOST_CHECK_EQUAL(peq.bins(), 5u); } BOOST_AUTO_TEST_CASE(ProtoBinningEquidistant) { // An invalid binning, 0 bins given - BOOST_CHECK_THROW( - ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, 15., 20., 0), - std::invalid_argument); + BOOST_CHECK_THROW(ProtoBinning(Acts::BinningValue::binX, + Acts::AxisBoundaryType::Bound, 15., 20., 0), + std::invalid_argument); // Another invalid binning, min/max swapped - BOOST_CHECK_THROW( - ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, 150., 20., 10), - std::invalid_argument); + BOOST_CHECK_THROW(ProtoBinning(Acts::BinningValue::binX, + Acts::AxisBoundaryType::Bound, 150., 20., 10), + std::invalid_argument); // A valid binning - auto eq = - ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, 0., 10., 5u); + auto eq = ProtoBinning(Acts::BinningValue::binX, + Acts::AxisBoundaryType::Bound, 0., 10., 5u); std::vector reference = {0., 2., 4., 6., 8., 10.}; BOOST_CHECK_EQUAL(eq.bins(), 5u); - BOOST_CHECK_EQUAL(eq.binValue, Acts::binX); + BOOST_CHECK_EQUAL(eq.binValue, Acts::BinningValue::binX); BOOST_CHECK(eq.axisType == Acts::AxisType::Equidistant); BOOST_CHECK(eq.boundaryType == Acts::AxisBoundaryType::Bound); BOOST_CHECK_EQUAL_COLLECTIONS(eq.edges.begin(), eq.edges.end(), @@ -49,16 +50,17 @@ BOOST_AUTO_TEST_CASE(ProtoBinningEquidistant) { BOOST_AUTO_TEST_CASE(ProtoBinningVariable) { // An invalid binning, edge size < 2u std::vector iedges = {12.}; - BOOST_CHECK_THROW( - ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, iedges), - std::invalid_argument); + BOOST_CHECK_THROW(ProtoBinning(Acts::BinningValue::binX, + Acts::AxisBoundaryType::Bound, iedges), + std::invalid_argument); // A valid binning std::vector varEdges = {0., 12., 13., 15., 20.}; - auto var = ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, varEdges); + auto var = ProtoBinning(Acts::BinningValue::binX, + Acts::AxisBoundaryType::Bound, varEdges); BOOST_CHECK_EQUAL(var.bins(), 4u); - BOOST_CHECK_EQUAL(var.binValue, Acts::binX); + BOOST_CHECK_EQUAL(var.binValue, Acts::BinningValue::binX); BOOST_CHECK(var.axisType == Acts::AxisType::Variable); BOOST_CHECK(var.boundaryType == Acts::AxisBoundaryType::Bound); BOOST_CHECK_EQUAL_COLLECTIONS(var.edges.begin(), var.edges.end(), @@ -67,9 +69,9 @@ BOOST_AUTO_TEST_CASE(ProtoBinningVariable) { BOOST_AUTO_TEST_CASE(BinningDescriptionFromAndToBinUtility) { // A valid binning - Acts::BinUtility bUtility(5u, 0., 10., Acts::open, Acts::binR); + Acts::BinUtility bUtility(5u, 0., 10., Acts::open, Acts::BinningValue::binR); std::vector edges = {-M_PI, 0.1, M_PI}; - bUtility += Acts::BinUtility(edges, Acts::closed, Acts::binPhi); + bUtility += Acts::BinUtility(edges, Acts::closed, Acts::BinningValue::binPhi); auto bDescription = BinningDescription::fromBinUtility(bUtility); @@ -77,7 +79,7 @@ BOOST_AUTO_TEST_CASE(BinningDescriptionFromAndToBinUtility) { // Test the first entry BOOST_CHECK_EQUAL(bDescription.binning[0].bins(), 5u); - BOOST_CHECK_EQUAL(bDescription.binning[0].binValue, Acts::binR); + BOOST_CHECK_EQUAL(bDescription.binning[0].binValue, Acts::BinningValue::binR); BOOST_CHECK(bDescription.binning[0].axisType == Acts::AxisType::Equidistant); BOOST_CHECK(bDescription.binning[0].boundaryType == Acts::AxisBoundaryType::Bound); @@ -85,7 +87,8 @@ BOOST_AUTO_TEST_CASE(BinningDescriptionFromAndToBinUtility) { // Check the second entry BOOST_CHECK_EQUAL(bDescription.binning[1].bins(), 2u); - BOOST_CHECK_EQUAL(bDescription.binning[1].binValue, Acts::binPhi); + BOOST_CHECK_EQUAL(bDescription.binning[1].binValue, + Acts::BinningValue::binPhi); BOOST_CHECK(bDescription.binning[1].axisType == Acts::AxisType::Variable); BOOST_CHECK(bDescription.binning[1].boundaryType == Acts::AxisBoundaryType::Closed); diff --git a/Tests/UnitTests/Core/Detector/ProtoDetectorTests.cpp b/Tests/UnitTests/Core/Detector/ProtoDetectorTests.cpp index 0a973cbd995..114006c0351 100644 --- a/Tests/UnitTests/Core/Detector/ProtoDetectorTests.cpp +++ b/Tests/UnitTests/Core/Detector/ProtoDetectorTests.cpp @@ -35,56 +35,56 @@ Acts::ProtoDetector createProtoDetector() { // Container Acts::ProtoVolume detectorVolume; detectorVolume.name = "detector-container"; - detectorVolume.extent.set(Acts::binZ, -2000., 2000); + detectorVolume.extent.set(Acts::BinningValue::binZ, -2000., 2000); // Beam Pipe volume Acts::ProtoVolume beamPipe; beamPipe.name = "beam-pipe"; - beamPipe.extent.set(Acts::binR, 0., 30.); + beamPipe.extent.set(Acts::BinningValue::binR, 0., 30.); // Pixel section Acts::ProtoVolume pixelContainer; pixelContainer.name = "pixel-container"; - pixelContainer.extent.set(Acts::binR, 40., 200); + pixelContainer.extent.set(Acts::BinningValue::binR, 40., 200); // Pixel volume sub structure Acts::ProtoVolume pixelNec; pixelNec.name = "pixel-nec"; - pixelNec.extent.set(Acts::binZ, -1900., -600); + pixelNec.extent.set(Acts::BinningValue::binZ, -1900., -600); Acts::ProtoVolume pixelBarrel; pixelBarrel.name = "pixel-barrel"; - pixelBarrel.extent.set(Acts::binR, 41., 199.); - pixelBarrel.extent.set(Acts::binZ, -550., 550.); + pixelBarrel.extent.set(Acts::BinningValue::binR, 41., 199.); + pixelBarrel.extent.set(Acts::BinningValue::binZ, -550., 550.); Acts::ProtoVolume pixelBarrelL0; pixelBarrelL0.name = "pixel-barrel-l0"; - pixelBarrelL0.extent.set(Acts::binR, 45., 50.); + pixelBarrelL0.extent.set(Acts::BinningValue::binR, 45., 50.); pixelBarrelL0.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; Acts::ProtoVolume pixelBarrelL1; pixelBarrelL1.name = "pixel-barrel-l1"; - pixelBarrelL1.extent.set(Acts::binR, 70., 80.); + pixelBarrelL1.extent.set(Acts::BinningValue::binR, 70., 80.); pixelBarrelL1.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; pixelBarrel.container = Acts::ProtoVolume::ContainerStructure{ {pixelBarrelL0, pixelBarrelL1}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 1.})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1.})}, true}; Acts::ProtoVolume pixelPec; pixelPec.name = "pixel-pec"; - pixelPec.extent.set(Acts::binZ, 600., 1900.); + pixelPec.extent.set(Acts::BinningValue::binZ, 600., 1900.); pixelContainer.container = Acts::ProtoVolume::ContainerStructure{ {pixelNec, pixelBarrel, pixelPec}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}}; + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}}; detectorVolume.container = Acts::ProtoVolume::ContainerStructure{ {beamPipe, pixelContainer}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 1})}}; + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1})}}; Acts::ProtoDetector detector; detector.name = "detector"; @@ -108,10 +108,10 @@ BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) { auto& detectorVolume = detector.worldVolume; // The detector volume should have received maximum dimensions - CHECK_CLOSE_ABS(detectorVolume.extent.min(Acts::binR), 0, + CHECK_CLOSE_ABS(detectorVolume.extent.min(Acts::BinningValue::binR), 0, std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(detectorVolume.extent.max(Acts::binR), 200., + CHECK_CLOSE_ABS(detectorVolume.extent.max(Acts::BinningValue::binR), 200., std::numeric_limits::epsilon()); // The detector container should have binning in R @@ -122,7 +122,8 @@ BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) { BOOST_CHECK_EQUAL(cts.constituentBinning.size(), 1u); BOOST_CHECK_EQUAL(cts.constituentBinning[0].type, Acts::arbitrary); - BOOST_CHECK_EQUAL(cts.constituentBinning[0].binvalue, Acts::binR); + BOOST_CHECK_EQUAL(cts.constituentBinning[0].binvalue, + Acts::BinningValue::binR); const auto& binBoundaries = cts.constituentBinning[0].boundaries(); BOOST_CHECK_EQUAL(binBoundaries.size(), 3u); @@ -138,14 +139,14 @@ BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) { auto& beamPipe = cts.constituentVolumes[0u]; BOOST_CHECK_EQUAL(beamPipe.name, "beam-pipe"); - CHECK_CLOSE_ABS(beamPipe.extent.min(Acts::binZ), -2000., + CHECK_CLOSE_ABS(beamPipe.extent.min(Acts::BinningValue::binZ), -2000., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(beamPipe.extent.max(Acts::binZ), 2000., + CHECK_CLOSE_ABS(beamPipe.extent.max(Acts::BinningValue::binZ), 2000., std::numeric_limits::epsilon()); // The new beam pipe radius should have been applied - CHECK_CLOSE_ABS(beamPipe.extent.max(Acts::binR), 35., + CHECK_CLOSE_ABS(beamPipe.extent.max(Acts::BinningValue::binR), 35., std::numeric_limits::epsilon()); // The second volume is the pixel detector @@ -153,13 +154,13 @@ BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) { BOOST_CHECK_EQUAL(pixelContainer.name, "pixel-container"); // Pixel container should have fitting boundaries - CHECK_CLOSE_ABS(pixelContainer.extent.min(Acts::binR), 35., + CHECK_CLOSE_ABS(pixelContainer.extent.min(Acts::BinningValue::binR), 35., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(pixelContainer.extent.max(Acts::binR), 200., + CHECK_CLOSE_ABS(pixelContainer.extent.max(Acts::BinningValue::binR), 200., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(pixelContainer.extent.min(Acts::binZ), -2000., + CHECK_CLOSE_ABS(pixelContainer.extent.min(Acts::BinningValue::binZ), -2000., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(pixelContainer.extent.max(Acts::binZ), 2000., + CHECK_CLOSE_ABS(pixelContainer.extent.max(Acts::BinningValue::binZ), 2000., std::numeric_limits::epsilon()); // The Pixel container has constituents @@ -169,17 +170,18 @@ BOOST_AUTO_TEST_CASE(ProtoTrackingGeometryTests) { // All of the internal containers should now have synchronized // inner & outer boundaries for (auto& pv : cts1.constituentVolumes) { - CHECK_CLOSE_ABS(pv.extent.min(Acts::binR), 35., + CHECK_CLOSE_ABS(pv.extent.min(Acts::BinningValue::binR), 35., std::numeric_limits::epsilon()); - CHECK_CLOSE_ABS(pv.extent.max(Acts::binR), 200., + CHECK_CLOSE_ABS(pv.extent.max(Acts::BinningValue::binR), 200., std::numeric_limits::epsilon()); } // The binning should have been estimated BOOST_CHECK_EQUAL(cts1.constituentBinning.size(), 1u); BOOST_CHECK_EQUAL(cts1.constituentBinning[0].type, Acts::arbitrary); - BOOST_CHECK_EQUAL(cts1.constituentBinning[0].binvalue, Acts::binZ); + BOOST_CHECK_EQUAL(cts1.constituentBinning[0].binvalue, + Acts::BinningValue::binZ); const auto& binBoundariesZ = cts1.constituentBinning[0].boundaries(); BOOST_CHECK_EQUAL(binBoundariesZ.size(), 4u); diff --git a/Tests/UnitTests/Core/Detector/ReferenceGeneratorsTests.cpp b/Tests/UnitTests/Core/Detector/ReferenceGeneratorsTests.cpp index af521326ce2..a0063e5d471 100644 --- a/Tests/UnitTests/Core/Detector/ReferenceGeneratorsTests.cpp +++ b/Tests/UnitTests/Core/Detector/ReferenceGeneratorsTests.cpp @@ -42,8 +42,8 @@ BOOST_AUTO_TEST_CASE(BinningPositionReference) { // Simply return binning position, we test only the behavior of the generator // not the output auto binningPosition = - BinningValueReferenceGenerator{}.references(tContext, - *pSurface); + BinningValueReferenceGenerator{}.references( + tContext, *pSurface); BOOST_CHECK_EQUAL(binningPosition.size(), 1u); } diff --git a/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp b/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp index d60950c9b8d..624e0987a40 100644 --- a/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp +++ b/Tests/UnitTests/Core/Detector/SupportSurfacesHelperTests.cpp @@ -42,8 +42,8 @@ BOOST_AUTO_TEST_CASE(CylindricalSupportCase) { // phi max = 2pi Acts::Extent lExtent; - lExtent.set(Acts::binR, 100., 110.); - lExtent.set(Acts::binZ, -400., 400.); + lExtent.set(Acts::BinningValue::binR, 100., 110.); + lExtent.set(Acts::BinningValue::binZ, -400., 400.); // Test creation of surface components CylindricalSupport csCreator{10., {1., 1.}}; @@ -100,8 +100,8 @@ BOOST_AUTO_TEST_CASE(DiscSupportCase) { /// phi min = 0 // phi max = 2pi Acts::Extent lExtent; - lExtent.set(Acts::binR, 100., 400.); - lExtent.set(Acts::binZ, -405., -395.); + lExtent.set(Acts::BinningValue::binR, 100., 400.); + lExtent.set(Acts::BinningValue::binZ, -405., -395.); // Test creation of surface components DiscSupport dsCreator{0., {1., 1.}}; @@ -161,13 +161,14 @@ BOOST_AUTO_TEST_CASE(RectangularSupportCase) { // dy = [-200,200] // dz = [-50, -60] Acts::Extent lExtent; - lExtent.set(Acts::binX, -100., 100.); - lExtent.set(Acts::binY, -200., 200.); - lExtent.set(Acts::binZ, -60., -50.); + lExtent.set(Acts::BinningValue::binX, -100., 100.); + lExtent.set(Acts::BinningValue::binY, -200., 200.); + lExtent.set(Acts::BinningValue::binZ, -60., -50.); // place in Z with offset 2_mm // Asymmetric clearances in x an y for testing - RectangularSupport rsCreator{Acts::binZ, 2., {1., 2.}, {3., 4.}}; + RectangularSupport rsCreator{ + Acts::BinningValue::binZ, 2., {1., 2.}, {3., 4.}}; auto rsComponents = rsCreator(lExtent); auto& [rsType, rsValues, rsTransform] = rsComponents; @@ -190,8 +191,8 @@ BOOST_AUTO_TEST_CASE(RectangularSupportCase) { // Invalid / runtime checks Acts::Extent invalid; - invalid.set(Acts::binX, -100., 100.); - invalid.set(Acts::binY, -200., 200.); + invalid.set(Acts::BinningValue::binX, -100., 100.); + invalid.set(Acts::BinningValue::binY, -200., 200.); BOOST_CHECK_THROW(rsCreator(invalid), std::invalid_argument); } @@ -207,8 +208,8 @@ BOOST_AUTO_TEST_CASE(addCylinderSupportCase) { // -> did yield and extend of 100 < r 110 // The volume would give an extend of -400 < z < 400 Acts::Extent lExtent; - lExtent.set(Acts::binR, 100., 110.); - lExtent.set(Acts::binZ, -400., 400.); + lExtent.set(Acts::BinningValue::binR, 100., 110.); + lExtent.set(Acts::BinningValue::binZ, -400., 400.); // Cylinder support CylindricalSupport csCreator{10., {1., 1.}}; @@ -247,8 +248,8 @@ BOOST_AUTO_TEST_CASE(addDiscSupportCase) { // The Extent Acts::Extent lExtent; - lExtent.set(Acts::binR, 100., 400.); - lExtent.set(Acts::binZ, -110., -100.); + lExtent.set(Acts::BinningValue::binR, 100., 400.); + lExtent.set(Acts::BinningValue::binZ, -110., -100.); // Disc support: this would set the disc at the center DiscSupport dsCreator{0., {1., 1.}}; @@ -289,13 +290,14 @@ BOOST_AUTO_TEST_CASE(addRectangularSupportCase) { // dy = [-200,200] // dz = [-50, -60] Acts::Extent lExtent; - lExtent.set(Acts::binX, -100., 100.); - lExtent.set(Acts::binY, -200., 200.); - lExtent.set(Acts::binZ, -60., -50.); + lExtent.set(Acts::BinningValue::binX, -100., 100.); + lExtent.set(Acts::BinningValue::binY, -200., 200.); + lExtent.set(Acts::BinningValue::binZ, -60., -50.); // place in Z with offset 2_mm // Asymmetric clearances in x an y for testing - RectangularSupport rsCreator{Acts::binZ, 2., {1., 2.}, {3., 4.}}; + RectangularSupport rsCreator{ + Acts::BinningValue::binZ, 2., {1., 2.}, {3., 4.}}; // Add a single disc as a support surface Acts::Experimental::detail::SupportSurfacesHelper::addSupport( @@ -334,8 +336,8 @@ BOOST_AUTO_TEST_CASE(addMisconfiguredSupportCase) { std::invalid_argument); // The Extent - lExtent.set(Acts::binR, 100., 400.); - lExtent.set(Acts::binZ, -110., -100.); + lExtent.set(Acts::BinningValue::binR, 100., 400.); + lExtent.set(Acts::BinningValue::binZ, -110., -100.); // Wrong surface type struct InvalidCreator { diff --git a/Tests/UnitTests/Core/Detector/VolumeStructureBuilderTests.cpp b/Tests/UnitTests/Core/Detector/VolumeStructureBuilderTests.cpp index a5f4b2b98da..6ff8c35a291 100644 --- a/Tests/UnitTests/Core/Detector/VolumeStructureBuilderTests.cpp +++ b/Tests/UnitTests/Core/Detector/VolumeStructureBuilderTests.cpp @@ -107,9 +107,9 @@ BOOST_AUTO_TEST_CASE(VolumeStructureBuilderCuboid) { // Cuboid volume from extent Extent cuboidExtent; - cuboidExtent.set(binX, -100, 100); - cuboidExtent.set(binY, -200, 200); - cuboidExtent.set(binZ, -300, 300); + cuboidExtent.set(BinningValue::binX, -100, 100); + cuboidExtent.set(BinningValue::binY, -200, 200); + cuboidExtent.set(BinningValue::binZ, -300, 300); VolumeStructureBuilder::Config cuboidExtentConfig; cuboidExtentConfig.boundsType = VolumeBounds::BoundsType::eCuboid; @@ -224,8 +224,8 @@ BOOST_AUTO_TEST_CASE(VolumeStructureBuilderCylinder) { // Cylinder volume from extent Extent cylinderExtent; - cylinderExtent.set(binR, 100., 200.); - cylinderExtent.set(binZ, -800., 0.); + cylinderExtent.set(BinningValue::binR, 100., 200.); + cylinderExtent.set(BinningValue::binZ, -800., 0.); VolumeStructureBuilder::Config cylExtentConfig; cylExtentConfig.extent = cylinderExtent; diff --git a/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp index df24dc264f1..dac15d46ba5 100644 --- a/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CuboidVolumeBoundsTests.cpp @@ -104,11 +104,11 @@ BOOST_AUTO_TEST_CASE(CuboidVolumeProperties) { } // Check the binning value positions - CHECK_CLOSE_ABS(box.binningBorder(Acts::binX), hx, s_epsilon); - CHECK_CLOSE_ABS(box.binningBorder(Acts::binY), hy, s_epsilon); - CHECK_CLOSE_ABS(box.binningBorder(Acts::binZ), hz, s_epsilon); - CHECK_CLOSE_ABS(box.binningBorder(Acts::binR), std::sqrt(hx * hx + hy * hy), - s_epsilon); + CHECK_CLOSE_ABS(box.binningBorder(Acts::BinningValue::binX), hx, s_epsilon); + CHECK_CLOSE_ABS(box.binningBorder(Acts::BinningValue::binY), hy, s_epsilon); + CHECK_CLOSE_ABS(box.binningBorder(Acts::BinningValue::binZ), hz, s_epsilon); + CHECK_CLOSE_ABS(box.binningBorder(Acts::BinningValue::binR), + std::sqrt(hx * hx + hy * hy), s_epsilon); } BOOST_AUTO_TEST_CASE(CuboidVolumeBoundarySurfaces) { diff --git a/Tests/UnitTests/Core/Geometry/CutoutCylinderVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CutoutCylinderVolumeBoundsTests.cpp index d1206870e8a..2cac47c5415 100644 --- a/Tests/UnitTests/Core/Geometry/CutoutCylinderVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CutoutCylinderVolumeBoundsTests.cpp @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(CutoutCylinderVolumeOrientedBoundaries) { Vector3 zaxis(0., 0., 1.); for (auto& os : ccvbOrientedSurfaces) { - auto onSurface = os.surface->binningPosition(geoCtx, binR); + auto onSurface = os.surface->binningPosition(geoCtx, BinningValue::binR); auto locPos = os.surface->globalToLocal(geoCtx, onSurface, Vector3::Zero()).value(); auto osNormal = os.surface->normal(geoCtx, locPos); diff --git a/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp b/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp index ba7a04142e9..585f4503093 100644 --- a/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CylinderVolumeBoundsTests.cpp @@ -306,7 +306,7 @@ BOOST_AUTO_TEST_CASE(CylinderVolumeOrientedBoundaries) { Vector3 zaxis(0., 0., 1.); for (auto& os : cvbOrientedSurfaces) { - auto onSurface = os.surface->binningPosition(geoCtx, binR); + auto onSurface = os.surface->binningPosition(geoCtx, BinningValue::binR); auto locPos = os.surface->globalToLocal(geoCtx, onSurface, Vector3::Zero()).value(); auto osNormal = os.surface->normal(geoCtx, locPos); diff --git a/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp b/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp index b45a2ee0829..93141684032 100644 --- a/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp +++ b/Tests/UnitTests/Core/Geometry/CylinderVolumeStackTests.cpp @@ -106,12 +106,12 @@ BOOST_DATA_TEST_CASE(Baseline, if (shift < 1.0) { BOOST_CHECK_THROW( - CylinderVolumeStack(volumes, binZ, strategy, + CylinderVolumeStack(volumes, BinningValue::binZ, strategy, CylinderVolumeStack::ResizeStrategy::Gap, *logger), std::invalid_argument); return; } - CylinderVolumeStack cylStack(volumes, binZ, strategy, + CylinderVolumeStack cylStack(volumes, BinningValue::binZ, strategy, CylinderVolumeStack::ResizeStrategy::Gap, *logger); @@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(Asymmetric) { std::vector volumes = {vol2.get(), vol1.get(), vol3.get()}; CylinderVolumeStack cylStack( - volumes, binZ, CylinderVolumeStack::AttachmentStrategy::Gap, + volumes, BinningValue::binZ, CylinderVolumeStack::AttachmentStrategy::Gap, CylinderVolumeStack::ResizeStrategy::Gap, *logger); BOOST_CHECK_EQUAL(volumes.size(), 5); @@ -381,7 +381,7 @@ BOOST_DATA_TEST_CASE(RotationInZ, boost::unit_test::data::make(strategies), std::vector volumes = {vol1.get(), vol2.get()}; - CylinderVolumeStack cylStack(volumes, binZ, strategy, + CylinderVolumeStack cylStack(volumes, BinningValue::binZ, strategy, CylinderVolumeStack::ResizeStrategy::Gap, *logger); @@ -477,7 +477,7 @@ BOOST_DATA_TEST_CASE(UpdateStack, transform3}; CylinderVolumeStack cylStack( - volumes, binZ, + volumes, BinningValue::binZ, CylinderVolumeStack::AttachmentStrategy::Gap, // should not make a // difference strategy, *logger); @@ -708,7 +708,7 @@ BOOST_DATA_TEST_CASE( std::vector volumes = {vol1.get(), vol2.get()}; - CylinderVolumeStack cylStack{volumes, binZ, + CylinderVolumeStack cylStack{volumes, BinningValue::binZ, CylinderVolumeStack::AttachmentStrategy::Gap, strategy, *logger}; const auto* originalBounds = @@ -873,13 +873,13 @@ BOOST_DATA_TEST_CASE(Baseline, if (f < 0.0) { BOOST_CHECK_THROW( - CylinderVolumeStack(volumes, binR, strategy, + CylinderVolumeStack(volumes, BinningValue::binR, strategy, CylinderVolumeStack::ResizeStrategy::Gap, *logger), std::invalid_argument); return; } - CylinderVolumeStack cylStack(volumes, binR, strategy, + CylinderVolumeStack cylStack(volumes, BinningValue::binR, strategy, CylinderVolumeStack::ResizeStrategy::Gap, *logger); @@ -1115,7 +1115,7 @@ BOOST_DATA_TEST_CASE(UpdateStack, } cylStack = std::make_unique( - volumes, binR, + volumes, BinningValue::binR, CylinderVolumeStack::AttachmentStrategy::Gap, // should not make a // difference strategy, *logger); @@ -1434,7 +1434,7 @@ BOOST_DATA_TEST_CASE( std::vector volumes = {vol1.get(), vol2.get()}; - CylinderVolumeStack cylStack{volumes, binR, + CylinderVolumeStack cylStack{volumes, BinningValue::binR, CylinderVolumeStack::AttachmentStrategy::Gap, strategy, *logger}; const auto* originalBounds = @@ -1516,7 +1516,7 @@ BOOST_DATA_TEST_CASE(JoinCylinderVolumesInvalidDirection, volumes.push_back(vol1.get()); // Single volume invalid direction still gives an error - BOOST_CHECK_THROW(CylinderVolumeStack(volumes, binY, strategy), + BOOST_CHECK_THROW(CylinderVolumeStack(volumes, BinningValue::binY, strategy), std::invalid_argument); auto vol2 = std::make_shared( @@ -1524,13 +1524,14 @@ BOOST_DATA_TEST_CASE(JoinCylinderVolumesInvalidDirection, std::make_shared(100_mm, 400_mm, 400_mm)); volumes.push_back(vol2.get()); - BOOST_CHECK_THROW(CylinderVolumeStack(volumes, binY, strategy), + BOOST_CHECK_THROW(CylinderVolumeStack(volumes, BinningValue::binY, strategy), std::invalid_argument); } BOOST_DATA_TEST_CASE(JoinCylinderVolumesInvalidInput, (boost::unit_test::data::make(strategies) * - boost::unit_test::data::make(Acts::binZ, Acts::binR)), + boost::unit_test::data::make(Acts::BinningValue::binZ, + Acts::BinningValue::binR)), strategy, direction) { BOOST_TEST_CONTEXT("Empty Volume") { std::vector volumes; @@ -1617,7 +1618,7 @@ BOOST_DATA_TEST_CASE(JoinCylinderVolumesInvalidInput, { std::shared_ptr vol; - if (direction == binZ) { + if (direction == BinningValue::binZ) { vol = std::make_shared( Transform3{Translation3{Vector3{0_mm, 0_mm, 500_mm}}}, invalid); } else { @@ -1641,7 +1642,8 @@ BOOST_DATA_TEST_CASE(JoinCylinderVolumesInvalidInput, } BOOST_DATA_TEST_CASE(JoinCylinderVolumeSingle, - (boost::unit_test::data::make(Acts::binZ, Acts::binR) * + (boost::unit_test::data::make(Acts::BinningValue::binZ, + Acts::BinningValue::binR) * boost::unit_test::data::make(strategies)), direction, strategy) { auto vol = std::make_shared( diff --git a/Tests/UnitTests/Core/Geometry/ExtentTests.cpp b/Tests/UnitTests/Core/Geometry/ExtentTests.cpp index 015380b1546..5d987935a28 100644 --- a/Tests/UnitTests/Core/Geometry/ExtentTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ExtentTests.cpp @@ -42,24 +42,24 @@ BOOST_AUTO_TEST_CASE(ExtentTest) { double phiMax = std::atan2(3_mm, 15_mm); double rMin = std::hypot(15_mm, 3_mm); - CHECK_CLOSE_ABS(gExt.min(binX), 15_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binX), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binY), -3_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binY), 3_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binZ), -10_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binZ), 10_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binR), rMin, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binR), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binPhi), phiMin, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binPhi), phiMax, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binX), 15_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binX), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binY), -3_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binY), 3_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binZ), -10_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binZ), 10_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binR), rMin, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binR), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binPhi), phiMin, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binPhi), phiMax, 1e-6); // Call with histogram filling Extent gExtHist; for (const auto& v : vertices) { - gExtHist.extend(v, {binX}, false, true); + gExtHist.extend(v, {BinningValue::binX}, false, true); } const auto& vHist = gExtHist.valueHistograms(); - auto xVals = vHist[binX]; + auto xVals = vHist[toUnderlying(BinningValue::binX)]; BOOST_CHECK_EQUAL(xVals.size(), 6u); std::vector reference = {15_mm, 18_mm, 15_mm, @@ -69,31 +69,31 @@ BOOST_AUTO_TEST_CASE(ExtentTest) { // Call with ieterator range Extent gExtItr; gExtItr.extend(vertices.begin(), vertices.end()); - CHECK_CLOSE_ABS(gExtItr.min(binX), 15_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.max(binX), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.min(binY), -3_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.max(binY), 3_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.min(binZ), -10_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.max(binZ), 10_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.min(binR), rMin, 1e-6); - CHECK_CLOSE_ABS(gExtItr.max(binR), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExtItr.min(binPhi), phiMin, 1e-6); - CHECK_CLOSE_ABS(gExtItr.max(binPhi), phiMax, 1e-6); + CHECK_CLOSE_ABS(gExtItr.min(BinningValue::binX), 15_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.max(BinningValue::binX), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.min(BinningValue::binY), -3_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.max(BinningValue::binY), 3_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.min(BinningValue::binZ), -10_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.max(BinningValue::binZ), 10_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.min(BinningValue::binR), rMin, 1e-6); + CHECK_CLOSE_ABS(gExtItr.max(BinningValue::binR), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExtItr.min(BinningValue::binPhi), phiMin, 1e-6); + CHECK_CLOSE_ABS(gExtItr.max(BinningValue::binPhi), phiMax, 1e-6); // Create a second Extent Extent gExtCopy; gExtCopy.extend(gExt); - CHECK_CLOSE_ABS(gExtCopy.min(binX), 15_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.max(binX), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.min(binY), -3_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.max(binY), 3_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.min(binZ), -10_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.max(binZ), 10_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.min(binR), rMin, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.max(binR), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.min(binPhi), phiMin, 1e-6); - CHECK_CLOSE_ABS(gExtCopy.max(binPhi), phiMax, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.min(BinningValue::binX), 15_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.max(BinningValue::binX), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.min(BinningValue::binY), -3_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.max(BinningValue::binY), 3_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.min(BinningValue::binZ), -10_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.max(BinningValue::binZ), 10_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.min(BinningValue::binR), rMin, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.max(BinningValue::binR), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.min(BinningValue::binPhi), phiMin, 1e-6); + CHECK_CLOSE_ABS(gExtCopy.max(BinningValue::binPhi), phiMax, 1e-6); // Check containment Extent unbound; @@ -101,56 +101,56 @@ BOOST_AUTO_TEST_CASE(ExtentTest) { BOOST_CHECK(unbound.contains(gExtCopy)); // Check application of an envelope on it - ExtentEnvelope xEnvelopes = zeroEnvelopes; - xEnvelopes[binX] = {1., 2.}; + ExtentEnvelope xEnvelopes = ExtentEnvelope::Zero(); + xEnvelopes[BinningValue::binX] = {1., 2.}; // Take the extent and extend by an envelope Extent envelope(xEnvelopes); gExt.extend(envelope); // Changed ones - CHECK_CLOSE_ABS(gExt.min(binX), 14_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binX), 20_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binX), 14_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binX), 20_mm, 1e-6); // Unchanged ones - CHECK_CLOSE_ABS(gExt.min(binY), -3_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binY), 3_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binZ), -10_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binZ), 10_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binR), rMin, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binR), 18_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.min(binPhi), phiMin, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binPhi), phiMax, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binY), -3_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binY), 3_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binZ), -10_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binZ), 10_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binR), rMin, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binR), 18_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binPhi), phiMin, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binPhi), phiMax, 1e-6); // Fill it with envelope Extent gExtEnv(envelope); gExtEnv.extend(vertices.begin(), vertices.end()); // Changed ones - CHECK_CLOSE_ABS(gExtEnv.min(binX), 14_mm, 1e-6); - CHECK_CLOSE_ABS(gExtEnv.max(binX), 20_mm, 1e-6); + CHECK_CLOSE_ABS(gExtEnv.min(BinningValue::binX), 14_mm, 1e-6); + CHECK_CLOSE_ABS(gExtEnv.max(BinningValue::binX), 20_mm, 1e-6); // Check the set method - gExt.set(binX, 2_mm, 8_mm); - CHECK_CLOSE_ABS(gExt.min(binX), 2_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binX), 8_mm, 1e-6); + gExt.set(BinningValue::binX, 2_mm, 8_mm); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binX), 2_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binX), 8_mm, 1e-6); // Radius can not go below 0 - gExt.set(binR, -2_mm, 18_mm); - CHECK_CLOSE_ABS(gExt.min(binR), 0_mm, 1e-6); - CHECK_CLOSE_ABS(gExt.max(binR), 18_mm, 1e-6); + gExt.set(BinningValue::binR, -2_mm, 18_mm); + CHECK_CLOSE_ABS(gExt.min(BinningValue::binR), 0_mm, 1e-6); + CHECK_CLOSE_ABS(gExt.max(BinningValue::binR), 18_mm, 1e-6); // Take an Extent and add a constraint Extent gExtConst; - gExtConst.set(binR, 0., 5.); + gExtConst.set(BinningValue::binR, 0., 5.); Extent gExtNonConst; - BOOST_CHECK(!gExtNonConst.constrains(binR)); + BOOST_CHECK(!gExtNonConst.constrains(BinningValue::binR)); gExtNonConst.addConstrain(gExtConst); - BOOST_CHECK(gExtNonConst.constrains(binR)); + BOOST_CHECK(gExtNonConst.constrains(BinningValue::binR)); std::string tString = gExtConst.toString(); BOOST_CHECK(!tString.empty()); // Check single vertex containment Extent gExtVertexCheck; - gExtVertexCheck.set(binR, 0., 5.); + gExtVertexCheck.set(BinningValue::binR, 0., 5.); BOOST_CHECK(gExtVertexCheck.contains(Vector3(1., 0., 0.))); BOOST_CHECK(!gExtVertexCheck.contains(Vector3(6., 0., 0.))); } @@ -164,16 +164,16 @@ BOOST_AUTO_TEST_CASE(ProtoSupportCaseTests) { Vector3(18_mm, 0_mm, 10_mm), Vector3(15_mm, 3_mm, 10_mm)}; Extent volumeExtent; - volumeExtent.set(binZ, -300_mm, 300_mm); + volumeExtent.set(BinningValue::binZ, -300_mm, 300_mm); - BOOST_CHECK(volumeExtent.constrains(binZ)); - BOOST_CHECK(!volumeExtent.constrains(binR)); + BOOST_CHECK(volumeExtent.constrains(BinningValue::binZ)); + BOOST_CHECK(!volumeExtent.constrains(BinningValue::binR)); for (const auto& v : vertices) { - volumeExtent.extend(v, {binR}); + volumeExtent.extend(v, {BinningValue::binR}); } - BOOST_CHECK(volumeExtent.constrains(binR)); + BOOST_CHECK(volumeExtent.constrains(BinningValue::binR)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Geometry/KDTreeTrackingGeometryBuilderTests.cpp b/Tests/UnitTests/Core/Geometry/KDTreeTrackingGeometryBuilderTests.cpp index 4f3cf125bfe..ea6caa240ae 100644 --- a/Tests/UnitTests/Core/Geometry/KDTreeTrackingGeometryBuilderTests.cpp +++ b/Tests/UnitTests/Core/Geometry/KDTreeTrackingGeometryBuilderTests.cpp @@ -100,33 +100,35 @@ BOOST_AUTO_TEST_CASE(KDTreeTrackingGeometryBuilder_simple) { // Make a proto detectpr description Acts::ProtoVolume beamPipeContainer; beamPipeContainer.name = "odd-beam-pipe"; - beamPipeContainer.extent.set(Acts::binR, 0., 17); + beamPipeContainer.extent.set(Acts::BinningValue::binR, 0., 17); Acts::ProtoVolume beamPipe; beamPipe.name = "odd-beam-pipe-l"; - beamPipe.extent.set(Acts::binR, 2., 16.); + beamPipe.extent.set(Acts::BinningValue::binR, 2., 16.); beamPipe.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; beamPipeContainer.container = Acts::ProtoVolume::ContainerStructure{ - {beamPipe}, {Acts::BinningData(Acts::open, Acts::binR, {0., 1.})}, true}; + {beamPipe}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1.})}, + true}; // Pixel section Acts::ProtoVolume pixelContainer; pixelContainer.name = "odd-pixel"; - pixelContainer.extent.set(Acts::binR, 18., 200); + pixelContainer.extent.set(Acts::BinningValue::binR, 18., 200); Acts::ProtoVolume pixelNec; pixelNec.name = "odd-pixel-nec"; - pixelNec.extent.set(Acts::binZ, -1000., -580); + pixelNec.extent.set(Acts::BinningValue::binZ, -1000., -580); Acts::ProtoVolume pixNecD1; pixNecD1.name = "odd-pixel-nec-d1"; - pixNecD1.extent.set(Acts::binZ, -720., -680); + pixNecD1.extent.set(Acts::BinningValue::binZ, -720., -680); Acts::ProtoVolume pixNecD0; pixNecD0.name = "odd-pixel-nec-d0"; - pixNecD0.extent.set(Acts::binZ, -620., -580); + pixNecD0.extent.set(Acts::BinningValue::binZ, -620., -580); pixelNec.container = Acts::ProtoVolume::ContainerStructure{ {pixNecD1, pixNecD0}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1.})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1.})}, true}; for (auto& cv : pixelNec.container.value().constituentVolumes) { cv.internal = @@ -135,52 +137,52 @@ BOOST_AUTO_TEST_CASE(KDTreeTrackingGeometryBuilder_simple) { Acts::ProtoVolume pixelBarrel; pixelBarrel.name = "odd-pixel-barrel"; - pixelBarrel.extent.set(Acts::binZ, -580., 580); + pixelBarrel.extent.set(Acts::BinningValue::binZ, -580., 580); Acts::ProtoVolume pixBarrelL0; pixBarrelL0.name = "odd-pixel-barrel-l0"; - pixBarrelL0.extent.set(Acts::binR, 28., 48.); - pixBarrelL0.extent.set(Acts::binZ, -580., 580); + pixBarrelL0.extent.set(Acts::BinningValue::binR, 28., 48.); + pixBarrelL0.extent.set(Acts::BinningValue::binZ, -580., 580); pixBarrelL0.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; Acts::ProtoVolume pixBarrelL1; pixBarrelL1.name = "odd-pixel-barrel-l1"; - pixBarrelL1.extent.set(Acts::binR, 62., 76); - pixBarrelL1.extent.set(Acts::binZ, -580., 580); + pixBarrelL1.extent.set(Acts::BinningValue::binR, 62., 76); + pixBarrelL1.extent.set(Acts::BinningValue::binZ, -580., 580); pixBarrelL1.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; Acts::ProtoVolume pixBarrelL2; pixBarrelL2.name = "odd-pixel-barrel-l2"; - pixBarrelL2.extent.set(Acts::binR, 100., 120.); - pixBarrelL2.extent.set(Acts::binZ, -580., 580); + pixBarrelL2.extent.set(Acts::BinningValue::binR, 100., 120.); + pixBarrelL2.extent.set(Acts::BinningValue::binZ, -580., 580); pixBarrelL2.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; Acts::ProtoVolume pixBarrelL3; pixBarrelL3.name = "odd-pixel-barrel-l3"; - pixBarrelL3.extent.set(Acts::binR, 160., 180.); - pixBarrelL3.extent.set(Acts::binZ, -580., 580); + pixBarrelL3.extent.set(Acts::BinningValue::binR, 160., 180.); + pixBarrelL3.extent.set(Acts::BinningValue::binZ, -580., 580); pixBarrelL3.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; pixelBarrel.container = Acts::ProtoVolume::ContainerStructure{ {pixBarrelL0, pixBarrelL1, pixBarrelL2, pixBarrelL3}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1})}, true}; Acts::ProtoVolume pixelPec; pixelPec.name = "odd-pixel-pec"; - pixelPec.extent.set(Acts::binZ, 580., 1000.); + pixelPec.extent.set(Acts::BinningValue::binZ, 580., 1000.); Acts::ProtoVolume pixPecD0; pixPecD0.name = "odd-pixel-pec-d0"; - pixPecD0.extent.set(Acts::binZ, 580., 620); + pixPecD0.extent.set(Acts::BinningValue::binZ, 580., 620); Acts::ProtoVolume pixPecD1; pixPecD1.name = "odd-pixel-pec-d1"; - pixPecD1.extent.set(Acts::binZ, 680., 720); + pixPecD1.extent.set(Acts::BinningValue::binZ, 680., 720); pixelPec.container = Acts::ProtoVolume::ContainerStructure{ {pixPecD0, pixPecD1}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}, true}; for (auto& cv : pixelPec.container.value().constituentVolumes) { cv.internal = @@ -189,15 +191,16 @@ BOOST_AUTO_TEST_CASE(KDTreeTrackingGeometryBuilder_simple) { pixelContainer.container = Acts::ProtoVolume::ContainerStructure{ {pixelNec, pixelBarrel, pixelPec}, - {Acts::BinningData(Acts::open, Acts::binZ, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {-1000., -580., 580., 1000.})}}; Acts::ProtoVolume detectorContainer; detectorContainer.name = "odd-detector"; - detectorContainer.extent.set(Acts::binR, 0., 200); + detectorContainer.extent.set(Acts::BinningValue::binR, 0., 200); detectorContainer.container = Acts::ProtoVolume::ContainerStructure{ {beamPipeContainer, pixelContainer}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 17.5, 200.})}}; + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, + {0., 17.5, 200.})}}; Acts::ProtoDetector detector; detector.name = "odd"; diff --git a/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp b/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp index c0306af56d1..fcf862ef126 100644 --- a/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp +++ b/Tests/UnitTests/Core/Geometry/LayerCreatorTests.cpp @@ -240,8 +240,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { // CASE I double envR = 0.1, envZ = 0.5; ProtoLayer pl(tgContext, srf); - pl.envelope[Acts::binR] = {envR, envR}; - pl.envelope[Acts::binZ] = {envZ, envZ}; + pl.envelope[Acts::BinningValue::binR] = {envR, envR}; + pl.envelope[Acts::BinningValue::binZ] = {envZ, envZ}; std::shared_ptr layer = std::dynamic_pointer_cast( p_LC->cylinderLayer(tgContext, srf, equidistant, equidistant, pl)); @@ -265,8 +265,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { // CASE II ProtoLayer pl2(tgContext, srf); - pl2.envelope[Acts::binR] = {envR, envR}; - pl2.envelope[Acts::binZ] = {envZ, envZ}; + pl2.envelope[Acts::BinningValue::binR] = {envR, envR}; + pl2.envelope[Acts::BinningValue::binZ] = {envZ, envZ}; layer = std::dynamic_pointer_cast( p_LC->cylinderLayer(tgContext, srf, 30, 7, pl2)); CHECK_CLOSE_REL(layer->thickness(), (rMax - rMin) + 2 * envR, 1e-3); @@ -301,8 +301,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createCylinderLayer, LayerCreatorFixture) { // CASE III ProtoLayer pl3; - pl3.extent.range(Acts::binR).set(1, 20); - pl3.extent.range(Acts::binZ).set(-25, 25); + pl3.extent.range(Acts::BinningValue::binR).set(1, 20); + pl3.extent.range(Acts::BinningValue::binZ).set(-25, 25); layer = std::dynamic_pointer_cast( p_LC->cylinderLayer(tgContext, srf, equidistant, equidistant, pl3)); CHECK_CLOSE_REL(layer->thickness(), 19, 1e-3); @@ -335,8 +335,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createDiscLayer, LayerCreatorFixture) { draw_surfaces(surfaces, "LayerCreator_createDiscLayer_EC_1.obj"); ProtoLayer pl(tgContext, surfaces); - pl.extent.range(binZ).set(-10, 10); - pl.extent.range(binR).set(5., 25.); + pl.extent.range(BinningValue::binZ).set(-10, 10); + pl.extent.range(BinningValue::binR).set(5., 25.); std::shared_ptr layer = std::dynamic_pointer_cast( p_LC->discLayer(tgContext, surfaces, equidistant, equidistant, pl)); CHECK_CLOSE_REL(layer->thickness(), 20, 1e-3); @@ -363,8 +363,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_createDiscLayer, LayerCreatorFixture) { double envMinR = 1, envMaxR = 1, envZ = 5; std::size_t nBinsR = 3, nBinsPhi = 30; ProtoLayer pl2(tgContext, surfaces); - pl2.envelope[binR] = {envMinR, envMaxR}; - pl2.envelope[binZ] = {envZ, envZ}; + pl2.envelope[BinningValue::binR] = {envMinR, envMaxR}; + pl2.envelope[BinningValue::binZ] = {envZ, envZ}; layer = std::dynamic_pointer_cast( p_LC->discLayer(tgContext, surfaces, nBinsR, nBinsPhi, pl2)); @@ -419,8 +419,8 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_barrelStagger, LayerCreatorFixture) { double envR = 0, envZ = 0; ProtoLayer pl(tgContext, brl); - pl.envelope[binR] = {envR, envR}; - pl.envelope[binZ] = {envZ, envZ}; + pl.envelope[BinningValue::binR] = {envR, envR}; + pl.envelope[BinningValue::binZ] = {envZ, envZ}; std::shared_ptr layer = std::dynamic_pointer_cast( p_LC->cylinderLayer(tgContext, brl, equidistant, equidistant, pl)); @@ -439,7 +439,7 @@ BOOST_FIXTURE_TEST_CASE(LayerCreator_barrelStagger, LayerCreatorFixture) { // std::cout << "dPHi = " << A->center().phi() - B->center().phi() << // std::endl; - Vector3 ctr = A->binningPosition(tgContext, binR); + Vector3 ctr = A->binningPosition(tgContext, BinningValue::binR); auto binContent = layer->surfaceArray()->at(ctr); BOOST_CHECK_EQUAL(binContent.size(), 2u); std::set act; diff --git a/Tests/UnitTests/Core/Geometry/PolyhedronTests.cpp b/Tests/UnitTests/Core/Geometry/PolyhedronTests.cpp index e7dd166984d..0d92383745f 100644 --- a/Tests/UnitTests/Core/Geometry/PolyhedronTests.cpp +++ b/Tests/UnitTests/Core/Geometry/PolyhedronTests.cpp @@ -83,28 +83,31 @@ BOOST_AUTO_TEST_CASE(PolyhedronExtent) { Polyhedron rectangle(rvertices, rfaces, rmesh); auto rExtent = rectangle.extent(); - CHECK_CLOSE_ABS(rExtent.min(binX), -1., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binX), 1., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binY), -2., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binY), -1., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binZ), 0., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binZ), 0., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binR), 1., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binR), VectorHelpers::perp(rvertices[0]), 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binPhi), VectorHelpers::phi(rvertices[3]), 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binPhi), VectorHelpers::phi(rvertices[2]), 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binX), -1., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binX), 1., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binY), -2., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binY), -1., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binZ), 0., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binZ), 0., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binR), 1., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binR), + VectorHelpers::perp(rvertices[0]), 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binPhi), + VectorHelpers::phi(rvertices[3]), 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binPhi), + VectorHelpers::phi(rvertices[2]), 1e-6); // Now shift the Extent Vector3 shift(-1., 0., 1.); Transform3 shiftedTransform = Transform3::Identity(); shiftedTransform.pretranslate(shift); rExtent = rectangle.extent(shiftedTransform); - CHECK_CLOSE_ABS(rExtent.min(binX), -2., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binX), 0., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binY), -2., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binY), -1., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binZ), 1., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binZ), 1., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binX), -2., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binX), 0., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binY), -2., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binY), -1., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binZ), 1., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binZ), 1., 1e-6); // Test a rectangle in yz - pane (at x == 3) rvertices = {Vector3(3_mm, -5_mm, -10_mm), Vector3(3_mm, 5_mm, -10_mm), @@ -112,14 +115,14 @@ BOOST_AUTO_TEST_CASE(PolyhedronExtent) { rectangle = Polyhedron(rvertices, rfaces, rmesh); rExtent = rectangle.extent(); - CHECK_CLOSE_ABS(rExtent.min(binX), 3., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binX), 3., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binY), -5., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binY), 5., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binZ), -10., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binZ), 10., 1e-6); - CHECK_CLOSE_ABS(rExtent.min(binR), 3., 1e-6); - CHECK_CLOSE_ABS(rExtent.max(binR), std::sqrt(9. + 25.), 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binX), 3., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binX), 3., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binY), -5., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binY), 5., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binZ), -10., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binZ), 10., 1e-6); + CHECK_CLOSE_ABS(rExtent.min(BinningValue::binR), 3., 1e-6); + CHECK_CLOSE_ABS(rExtent.max(BinningValue::binR), std::sqrt(9. + 25.), 1e-6); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp index 57c6db68935..e316b2f29aa 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerHelperTests.cpp @@ -73,7 +73,8 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) { // Sort into ProtoLayers auto radialLayers = plHelper.protoLayers( - tgContext, cylinderSurfaces, ProtoLayerHelper::SortingConfig(binR, 5.)); + tgContext, cylinderSurfaces, + ProtoLayerHelper::SortingConfig(BinningValue::binR, 5.)); BOOST_CHECK_EQUAL(radialLayers.size(), 4); @@ -127,7 +128,8 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) { objVis.clear(); // Sort into ProtoLayers - auto discLayersZ = plHelper.protoLayers(tgContext, discSurfaces, {binZ, 5.}); + auto discLayersZ = + plHelper.protoLayers(tgContext, discSurfaces, {BinningValue::binZ, 5.}); BOOST_CHECK_EQUAL(discLayersZ.size(), 4); @@ -178,16 +180,17 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) { // First: Sort into ProtoLayers radially auto rSorted = plHelper.protoLayers( - tgContext, ringSurfaces, ProtoLayerHelper::SortingConfig(binR, 1.)); + tgContext, ringSurfaces, + ProtoLayerHelper::SortingConfig(BinningValue::binR, 1.)); BOOST_CHECK_EQUAL(rSorted.size(), 3); ColorRGB dColor = {0, 0, 0}; int ir = 0; for (auto& rBatch : rSorted) { - auto lSorted = - plHelper.protoLayers(tgContext, rBatch.surfaces(), - ProtoLayerHelper::SortingConfig(binZ, 5.)); + auto lSorted = plHelper.protoLayers( + tgContext, rBatch.surfaces(), + ProtoLayerHelper::SortingConfig(BinningValue::binZ, 5.)); il = 0; dColor[ir] = 256; for (auto& layer : lSorted) { @@ -204,7 +207,8 @@ BOOST_AUTO_TEST_CASE(ProtoLayerHelperTests) { // Perform the split at once auto rzSorted = - plHelper.protoLayers(tgContext, ringSurfaces, {{binR, 1.}, {binZ, 5}}); + plHelper.protoLayers(tgContext, ringSurfaces, + {{BinningValue::binR, 1.}, {BinningValue::binZ, 5}}); std::size_t irz = 0; for (auto& layer : rzSorted) { diff --git a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp index 38b504d3a19..0a0d9434c90 100644 --- a/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ProtoLayerTests.cpp @@ -105,20 +105,20 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { // Test 1 - identity transform auto protoLayer = createProtoLayer(Transform3::Identity()); - CHECK_CLOSE_ABS(protoLayer.range(binX), 12., 1e-8); - CHECK_CLOSE_ABS(protoLayer.medium(binX), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(binX), -6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(binX), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.range(binY), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.medium(binY), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(binY), -3., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(binY), 3., 1e-8); - CHECK_CLOSE_ABS(protoLayer.range(binZ), 12., 1e-8); - CHECK_CLOSE_ABS(protoLayer.medium(binZ), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(binZ), -6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(binZ), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayer.max(binR), std::hypot(3, 6), 1e-8); - CHECK_CLOSE_ABS(protoLayer.min(binR), 3., 1e-8); + CHECK_CLOSE_ABS(protoLayer.range(BinningValue::binX), 12., 1e-8); + CHECK_CLOSE_ABS(protoLayer.medium(BinningValue::binX), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binX), -6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binX), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.range(BinningValue::binY), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.medium(BinningValue::binY), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binY), -3., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binY), 3., 1e-8); + CHECK_CLOSE_ABS(protoLayer.range(BinningValue::binZ), 12., 1e-8); + CHECK_CLOSE_ABS(protoLayer.medium(BinningValue::binZ), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binZ), -6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binZ), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayer.max(BinningValue::binR), std::hypot(3, 6), 1e-8); + CHECK_CLOSE_ABS(protoLayer.min(BinningValue::binR), 3., 1e-8); // Test 1a @@ -127,15 +127,16 @@ BOOST_AUTO_TEST_CASE(ProtoLayerTests) { auto protoLayerRot = createProtoLayer(AngleAxis3(-0.345, Vector3::UnitZ()) * Transform3::Identity()); - BOOST_CHECK_NE(protoLayer.min(binX), -6.); - CHECK_CLOSE_ABS(protoLayerRot.medium(binX), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.medium(binY), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.range(binZ), 12., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.medium(binZ), 0., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.min(binZ), -6., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.max(binZ), 6., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.min(binR), 3., 1e-8); - CHECK_CLOSE_ABS(protoLayerRot.max(binR), std::hypot(3, 6), 1e-8); + BOOST_CHECK_NE(protoLayer.min(BinningValue::binX), -6.); + CHECK_CLOSE_ABS(protoLayerRot.medium(BinningValue::binX), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.medium(BinningValue::binY), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.range(BinningValue::binZ), 12., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.medium(BinningValue::binZ), 0., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.min(BinningValue::binZ), -6., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.max(BinningValue::binZ), 6., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.min(BinningValue::binR), 3., 1e-8); + CHECK_CLOSE_ABS(protoLayerRot.max(BinningValue::binR), std::hypot(3, 6), + 1e-8); std::stringstream sstream; protoLayerRot.toStream(sstream); diff --git a/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp b/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp index fdbac2fce6f..6f68b8b7315 100644 --- a/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp +++ b/Tests/UnitTests/Core/Geometry/SurfaceArrayCreatorTests.cpp @@ -590,7 +590,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_completeBinning, // actually filled SA for (const auto& srf : brl) { - Vector3 ctr = srf->binningPosition(tgContext, binR); + Vector3 ctr = srf->binningPosition(tgContext, BinningValue::binR); auto binContent = sa.at(ctr); BOOST_CHECK_EQUAL(binContent.size(), 1u); @@ -640,7 +640,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_barrelStagger, auto A = pr.first; auto B = pr.second; - Vector3 ctr = A->binningPosition(tgContext, binR); + Vector3 ctr = A->binningPosition(tgContext, BinningValue::binR); auto binContent = sa.at(ctr); BOOST_CHECK_EQUAL(binContent.size(), 2u); std::set act; @@ -710,7 +710,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArrayCreator_barrelStagger, auto A = pr.first; auto B = pr.second; - Vector3 ctr = A->binningPosition(tgContext, binR); + Vector3 ctr = A->binningPosition(tgContext, BinningValue::binR); auto binContent = sa2.at(ctr); BOOST_CHECK_EQUAL(binContent.size(), 2u); std::set act; diff --git a/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp b/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp index 4831f23b19e..efd2da5e8b6 100644 --- a/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp +++ b/Tests/UnitTests/Core/Geometry/SurfaceBinningMatcherTests.cpp @@ -55,24 +55,26 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceMatcher) { Surface::makeShared(identity, similarPhiBounds); SurfaceBinningMatcher sbm; - sbm.tolerances[binR] = {rMinTol, rMaxTol}; - sbm.tolerances[binPhi] = {phiTol, phiTol}; + sbm.tolerances[toUnderlying(BinningValue::binR)] = {rMinTol, rMaxTol}; + sbm.tolerances[toUnderlying(BinningValue::binPhi)] = {phiTol, phiTol}; // Always true - for (int ib = 0; ib < binValues; ++ib) { - BOOST_CHECK( - sbm(tgContext, (BinningValue)ib, oneSurface.get(), oneSurface.get())); + for (BinningValue ib : allBinningValues()) { + BOOST_CHECK(sbm(tgContext, ib, oneSurface.get(), oneSurface.get())); } // Not matching in R - BOOST_CHECK(!sbm(tgContext, binR, oneSurface.get(), otherSurface.get())); + BOOST_CHECK(!sbm(tgContext, BinningValue::binR, oneSurface.get(), + otherSurface.get())); // Not matching in phi - BOOST_CHECK(!sbm(tgContext, binPhi, oneSurface.get(), otherSurface.get())); + BOOST_CHECK(!sbm(tgContext, BinningValue::binPhi, oneSurface.get(), + otherSurface.get())); // Good enough matching in R - BOOST_CHECK(sbm(tgContext, binR, oneSurface.get(), similarRSurface.get())); + BOOST_CHECK(sbm(tgContext, BinningValue::binR, oneSurface.get(), + similarRSurface.get())); // Good enough matching in phi - BOOST_CHECK( - sbm(tgContext, binPhi, oneSurface.get(), similarPhiSurface.get())); + BOOST_CHECK(sbm(tgContext, BinningValue::binPhi, oneSurface.get(), + similarPhiSurface.get())); } } // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp b/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp index e47d51306ce..58a7b30380a 100644 --- a/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp +++ b/Tests/UnitTests/Core/Geometry/TrackingVolumeCreation.hpp @@ -95,14 +95,15 @@ MutableTrackingVolumePtr constructContainerVolume(const GeometryContext& gctx, const std::string& name) { /// create the volume array using VAP = std::pair; - std::vector volumes = {{iVolume, iVolume->binningPosition(gctx, binR)}, - {oVolume, oVolume->binningPosition(gctx, binR)}}; + std::vector volumes = { + {iVolume, iVolume->binningPosition(gctx, BinningValue::binR)}, + {oVolume, oVolume->binningPosition(gctx, BinningValue::binR)}}; /// the bounds for the container auto hVolumeBounds = std::make_shared(0., hVolumeR, hVolumeHalflength); /// create the BinUtility & the BinnedArray - auto vUtility = std::make_unique(volumes.size(), 0., - hVolumeR, open, binR); + auto vUtility = std::make_unique( + volumes.size(), 0., hVolumeR, open, BinningValue::binR); std::shared_ptr vArray = std::make_shared>( volumes, std::move(vUtility)); diff --git a/Tests/UnitTests/Core/Geometry/VolumeTests.cpp b/Tests/UnitTests/Core/Geometry/VolumeTests.cpp index 64d749cb38c..93d86595b12 100644 --- a/Tests/UnitTests/Core/Geometry/VolumeTests.cpp +++ b/Tests/UnitTests/Core/Geometry/VolumeTests.cpp @@ -72,7 +72,8 @@ BOOST_AUTO_TEST_CASE(VolumeTest) { // Binning test GeometryContext gctx; - BOOST_CHECK_EQUAL(volume.binningPosition(gctx, binX), volume.center()); + BOOST_CHECK_EQUAL(volume.binningPosition(gctx, BinningValue::binX), + volume.center()); } BOOST_AUTO_TEST_CASE(VolumeUpdateTest) { diff --git a/Tests/UnitTests/Core/Material/AccumulatedSurfaceMaterialTests.cpp b/Tests/UnitTests/Core/Material/AccumulatedSurfaceMaterialTests.cpp index b5f41f55185..edb601fe5ad 100644 --- a/Tests/UnitTests/Core/Material/AccumulatedSurfaceMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/AccumulatedSurfaceMaterialTests.cpp @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_construction_test) { // Test: // BinsSurfaceMaterial accumulation - 1D - BinUtility binUtility1D(10, -5., 5., open, binX); + BinUtility binUtility1D(10, -5., 5., open, BinningValue::binX); AccumulatedSurfaceMaterial material1D{binUtility1D}; auto accMat1D = material1D.accumulatedMaterial(); BOOST_CHECK_EQUAL(accMat1D.size(), 1u); @@ -43,8 +43,8 @@ BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_construction_test) { // Test: // BinsSurfaceMaterial accumulation - 2D - BinUtility binUtility2D(10, -5., 5., open, binX); - binUtility2D += BinUtility(20, -10., 10., open, binY); + BinUtility binUtility2D(10, -5., 5., open, BinningValue::binX); + binUtility2D += BinUtility(20, -10., 10., open, BinningValue::binY); AccumulatedSurfaceMaterial material2D{binUtility2D}; auto accMat2D = material2D.accumulatedMaterial(); BOOST_CHECK_EQUAL(accMat2D.size(), 20u); @@ -91,8 +91,8 @@ BOOST_AUTO_TEST_CASE(AccumulatedSurfaceMaterial_fill_convert_1D) { MaterialSlab four(mat, 4.); // BinsSurfaceMaterial accumulation - 2D - BinUtility binUtility2D(2, -1., 1., open, binX); - binUtility2D += BinUtility(2, -1., 1., open, binY); + BinUtility binUtility2D(2, -1., 1., open, BinningValue::binX); + binUtility2D += BinUtility(2, -1., 1., open, BinningValue::binY); AccumulatedSurfaceMaterial material2D{binUtility2D}; const std::vector> bin; diff --git a/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp b/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp index c93938c8149..f4aea23e2dc 100644 --- a/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp +++ b/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialAccumulaterTests.cpp @@ -85,14 +85,14 @@ BOOST_AUTO_TEST_CASE(AccumulationTest) { std::make_shared(mp, 1.)); // Second surface is binned Phi / Z - BinUtility sb1(4, -M_PI, M_PI, closed, binPhi); - sb1 += BinUtility(2, -100., 100., open, binZ); + BinUtility sb1(4, -M_PI, M_PI, closed, BinningValue::binPhi); + sb1 += BinUtility(2, -100., 100., open, BinningValue::binZ); surfaces[1u]->assignSurfaceMaterial( std::make_shared(sb1)); // Third is binned std::vector mps = {mp, mp, mp}; - BinUtility sb2(3, -100., 100., open, binZ); + BinUtility sb2(3, -100., 100., open, BinningValue::binZ); surfaces[2u]->assignSurfaceMaterial( std::make_shared(sb2, mps)); diff --git a/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialTests.cpp b/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialTests.cpp index 1468cb8f0b9..7cd38d324b4 100644 --- a/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/BinnedSurfaceMaterialTests.cpp @@ -21,8 +21,8 @@ namespace Acts::Test { /// Test the constructors BOOST_AUTO_TEST_CASE(BinnedSurfaceMaterial_construction_test) { - BinUtility xyBinning(2, -1., 1., open, binX); - xyBinning += BinUtility(3, -3., 3., open, binY); + BinUtility xyBinning(2, -1., 1., open, BinningValue::binX); + xyBinning += BinUtility(3, -3., 3., open, BinningValue::binY); // Constructor a few material properties MaterialSlab a00(Material::fromMolarDensity(1., 2., 3., 4., 5.), 6.); diff --git a/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp b/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp index 28d82704f64..2eebf107fc9 100644 --- a/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialGridHelperTests.cpp @@ -39,8 +39,8 @@ using MaterialGrid3D = /// @brief Various test for the Material in the case of a Cuboid volume and 2D /// Grid BOOST_AUTO_TEST_CASE(Square_Grid_test) { - BinUtility bu(7, -3., 3., open, binX); - bu += BinUtility(3, -2., 2., open, binY); + BinUtility bu(7, -3., 3., open, BinningValue::binX); + bu += BinUtility(3, -2., 2., open, BinningValue::binY); auto bd = bu.binningData(); std::function transfoGlobalToLocal; @@ -130,8 +130,8 @@ BOOST_AUTO_TEST_CASE(Square_Grid_test) { /// @brief Various test for the Material in the case of a Cylindrical volume /// with a 2D grid BOOST_AUTO_TEST_CASE(PhiZ_Grid_test) { - BinUtility bu(2, -2., 2., open, binZ); - bu += BinUtility(3, -M_PI, M_PI, closed, binPhi); + BinUtility bu(2, -2., 2., open, BinningValue::binZ); + bu += BinUtility(3, -M_PI, M_PI, closed, BinningValue::binPhi); auto bd = bu.binningData(); std::function transfoGlobalToLocal; @@ -221,9 +221,9 @@ BOOST_AUTO_TEST_CASE(PhiZ_Grid_test) { /// @brief Various test for the Material in the case of a Cuboid volume BOOST_AUTO_TEST_CASE(Cubic_Grid_test) { - BinUtility bu(7, -3., 3., open, binX); - bu += BinUtility(3, -2., 2., open, binY); - bu += BinUtility(2, -1., 1., open, binZ); + BinUtility bu(7, -3., 3., open, BinningValue::binX); + bu += BinUtility(3, -2., 2., open, BinningValue::binY); + bu += BinUtility(2, -1., 1., open, BinningValue::binZ); auto bd = bu.binningData(); std::function transfoGlobalToLocal; @@ -315,9 +315,9 @@ BOOST_AUTO_TEST_CASE(Cubic_Grid_test) { /// @brief Various test for the Material in the case of a Cylindrical volume BOOST_AUTO_TEST_CASE(Cylindrical_Grid_test) { - BinUtility bu(4, 1., 4., open, binR); - bu += BinUtility(3, -M_PI, M_PI, closed, binPhi); - bu += BinUtility(2, -2., 2., open, binZ); + BinUtility bu(4, 1., 4., open, BinningValue::binR); + bu += BinUtility(3, -M_PI, M_PI, closed, BinningValue::binPhi); + bu += BinUtility(2, -2., 2., open, BinningValue::binZ); auto bd = bu.binningData(); std::function transfoGlobalToLocal; diff --git a/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp b/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp index 105aca93ea6..9f33c2d62b1 100644 --- a/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp +++ b/Tests/UnitTests/Core/Material/PropagatorMaterialAssignerTests.cpp @@ -68,8 +68,8 @@ BOOST_AUTO_TEST_CASE(FindSurfaceIntersectionsTrackingGeometry) { LayerArrayCreator::Config lacConfig; LayerArrayCreator lac = LayerArrayCreator(lacConfig); - auto layers = - lac.layerArray(tContext, {pCylinderLayer}, rMin, rMid, arbitrary, binR); + auto layers = lac.layerArray(tContext, {pCylinderLayer}, rMin, rMid, + arbitrary, BinningValue::binR); auto innerVolume = std::make_shared( Transform3::Identity(), vCylinderInner, nullptr, std::move(layers), @@ -84,8 +84,8 @@ BOOST_AUTO_TEST_CASE(FindSurfaceIntersectionsTrackingGeometry) { TrackingVolumeArrayCreator::Config tvacConfig; TrackingVolumeArrayCreator tvac = TrackingVolumeArrayCreator(tvacConfig); - auto volumes = - tvac.trackingVolumeArray(tContext, {innerVolume, outerVolume}, binR); + auto volumes = tvac.trackingVolumeArray(tContext, {innerVolume, outerVolume}, + BinningValue::binR); auto vCylinderTop = std::make_shared(rMin, rMax, 110.); diff --git a/Tests/UnitTests/Core/Material/ProtoSurfaceMaterialTests.cpp b/Tests/UnitTests/Core/Material/ProtoSurfaceMaterialTests.cpp index bb084a3ccd1..a5b28beee03 100644 --- a/Tests/UnitTests/Core/Material/ProtoSurfaceMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/ProtoSurfaceMaterialTests.cpp @@ -18,8 +18,8 @@ namespace Acts::Test { /// Test the constructors BOOST_AUTO_TEST_CASE(ProtoSurfaceMaterial_construction_test) { - BinUtility smpBU(10, -10., 10., open, binX); - smpBU += BinUtility(10, -10., 10., open, binY); + BinUtility smpBU(10, -10., 10., open, BinningValue::binX); + smpBU += BinUtility(10, -10., 10., open, BinningValue::binY); // Constructor from arguments ProtoSurfaceMaterial smp(smpBU); diff --git a/Tests/UnitTests/Core/Material/ProtoVolumeMaterialTests.cpp b/Tests/UnitTests/Core/Material/ProtoVolumeMaterialTests.cpp index d075e4db2d5..a3ebc0e527a 100644 --- a/Tests/UnitTests/Core/Material/ProtoVolumeMaterialTests.cpp +++ b/Tests/UnitTests/Core/Material/ProtoVolumeMaterialTests.cpp @@ -18,9 +18,9 @@ namespace Acts::Test { /// Test the constructors BOOST_AUTO_TEST_CASE(ProtoVolumeMaterial_construction_test) { - BinUtility vmpBU(10, -10., 10., open, binX); - vmpBU += BinUtility(10, -10., 10., open, binY); - vmpBU += BinUtility(10, -10., 10., open, binZ); + BinUtility vmpBU(10, -10., 10., open, BinningValue::binX); + vmpBU += BinUtility(10, -10., 10., open, BinningValue::binY); + vmpBU += BinUtility(10, -10., 10., open, BinningValue::binZ); // Constructor from arguments ProtoVolumeMaterial vmp(vmpBU); diff --git a/Tests/UnitTests/Core/Material/SurfaceMaterialMapperTests.cpp b/Tests/UnitTests/Core/Material/SurfaceMaterialMapperTests.cpp index 6e3754083d5..661463fcb11 100644 --- a/Tests/UnitTests/Core/Material/SurfaceMaterialMapperTests.cpp +++ b/Tests/UnitTests/Core/Material/SurfaceMaterialMapperTests.cpp @@ -40,7 +40,7 @@ namespace Acts { std::shared_ptr trackingGeometry() { using namespace Acts::UnitLiterals; - BinUtility zbinned(8, -40, 40, open, binZ); + BinUtility zbinned(8, -40, 40, open, BinningValue::binZ); auto matProxy = std::make_shared(zbinned); Logging::Level surfaceLLevel = Logging::INFO; diff --git a/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp b/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp index fc2bbe378d6..406cf9deabe 100644 --- a/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp +++ b/Tests/UnitTests/Core/Material/VolumeMaterialMapperTests.cpp @@ -86,17 +86,17 @@ namespace Acts::Test { BOOST_AUTO_TEST_CASE(SurfaceMaterialMapper_tests) { using namespace Acts::UnitLiterals; - BinUtility bu1(4, 0_m, 1_m, open, binX); - bu1 += BinUtility(2, -0.5_m, 0.5_m, open, binY); - bu1 += BinUtility(2, -0.5_m, 0.5_m, open, binZ); + BinUtility bu1(4, 0_m, 1_m, open, BinningValue::binX); + bu1 += BinUtility(2, -0.5_m, 0.5_m, open, BinningValue::binY); + bu1 += BinUtility(2, -0.5_m, 0.5_m, open, BinningValue::binZ); - BinUtility bu2(4, 1_m, 2_m, open, binX); - bu2 += BinUtility(2, -0.5_m, 0.5_m, open, binY); - bu2 += BinUtility(2, -0.5_m, 0.5_m, open, binZ); + BinUtility bu2(4, 1_m, 2_m, open, BinningValue::binX); + bu2 += BinUtility(2, -0.5_m, 0.5_m, open, BinningValue::binY); + bu2 += BinUtility(2, -0.5_m, 0.5_m, open, BinningValue::binZ); - BinUtility bu3(4, 2_m, 3_m, open, binX); - bu3 += BinUtility(2, -0.5_m, 0.5_m, open, binY); - bu3 += BinUtility(2, -0.5_m, 0.5_m, open, binZ); + BinUtility bu3(4, 2_m, 3_m, open, BinningValue::binX); + bu3 += BinUtility(2, -0.5_m, 0.5_m, open, BinningValue::binY); + bu3 += BinUtility(2, -0.5_m, 0.5_m, open, BinningValue::binZ); // Build a vacuum volume CuboidVolumeBuilder::VolumeConfig vCfg1; diff --git a/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp b/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp index 51c02317ac6..959aae85be8 100644 --- a/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp +++ b/Tests/UnitTests/Core/Navigation/DetectorVolumeFindersTests.cpp @@ -130,8 +130,8 @@ BOOST_AUTO_TEST_CASE(IndexedDetectorVolumeFinder) { g.atPosition(std::array{50.}) = 1u; g.atPosition(std::array{150.}) = 2u; - Acts::Experimental::IndexedDetectorVolumesImpl idv(std::move(g), - {Acts::binR}); + Acts::Experimental::IndexedDetectorVolumesImpl idv( + std::move(g), {Acts::BinningValue::binR}); // Cylinder 0 nState.position = Acts::Vector3(5., 0., 0.); diff --git a/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp b/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp index d89c4dc7b63..5c8b4ee6866 100644 --- a/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp +++ b/Tests/UnitTests/Core/Navigation/MultiWireNavigationTests.cpp @@ -75,10 +75,11 @@ BOOST_AUTO_TEST_CASE(Navigation_in_Indexed_Surfaces) { mlCfg.name = "Multi_Layer_With_Wires"; mlCfg.mlSurfaces = strawSurfaces; - mlCfg.mlBinning = {ProtoBinning(Acts::binX, Acts::AxisBoundaryType::Bound, - -vBounds[0], vBounds[0], nSurfacesX, 1u), - ProtoBinning(Acts::binY, Acts::AxisBoundaryType::Bound, - -vBounds[1], vBounds[1], nSurfacesY, 0u)}; + mlCfg.mlBinning = { + ProtoBinning(Acts::BinningValue::binX, Acts::AxisBoundaryType::Bound, + -vBounds[0], vBounds[0], nSurfacesX, 1u), + ProtoBinning(Acts::BinningValue::binY, Acts::AxisBoundaryType::Bound, + -vBounds[1], vBounds[1], nSurfacesY, 0u)}; mlCfg.mlBounds = vBounds; MultiWireStructureBuilder mlBuilder(mlCfg); diff --git a/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp b/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp index 3d9250391ab..7efecc884c9 100644 --- a/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp +++ b/Tests/UnitTests/Core/Navigation/NavigationStateUpdatersTests.cpp @@ -265,7 +265,8 @@ BOOST_AUTO_TEST_CASE(AllPortalsGrid1DSurfaces) { Acts::Experimental::IInternalNavigation, decltype(grid), Acts::Experimental::IndexedSurfacesExtractor, Acts::Experimental::SurfacesFiller>; - auto grid1DSurfaces = Grid1DSurfacesProvider(std::move(grid), {Acts::binR}); + auto grid1DSurfaces = + Grid1DSurfacesProvider(std::move(grid), {Acts::BinningValue::binR}); auto allPortalsGrid1DSurfaces = Acts::Experimental::ChainedNavigation< Acts::Experimental::IInternalNavigation, AllPortalsProvider, @@ -291,8 +292,8 @@ BOOST_AUTO_TEST_CASE(AllPortalsGrid2DSurfaces) { Acts::Experimental::IInternalNavigation, decltype(grid), Acts::Experimental::IndexedSurfacesExtractor, Acts::Experimental::SurfacesFiller>; - auto grid2DSurfaces = - Grid2DSurfacesProvider(std::move(grid), {Acts::binR, Acts::binZ}); + auto grid2DSurfaces = Grid2DSurfacesProvider( + std::move(grid), {Acts::BinningValue::binR, Acts::BinningValue::binZ}); auto allPortalsGrid2DSurfaces = Acts::Experimental::ChainedNavigation< Acts::Experimental::IInternalNavigation, AllPortalsProvider, diff --git a/Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp b/Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp index c5bf26e88dd..a379d72c4eb 100644 --- a/Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp +++ b/Tests/UnitTests/Core/Navigation/PortalNavigationTests.cpp @@ -75,8 +75,8 @@ BOOST_AUTO_TEST_CASE(VolumeArrayUpdate) { std::vector volumes = { volumeA.get(), volumeB.get(), volumeC.get(), volumeD.get()}; - Acts::Experimental::BoundVolumesGrid1Navigation bvg(zArray, Acts::binZ, - volumes); + Acts::Experimental::BoundVolumesGrid1Navigation bvg( + zArray, Acts::BinningValue::binZ, volumes); // Reset the navigation state nState.currentVolume = nullptr; @@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(VolumeArrayUpdate) { shift300.pretranslate(Acts::Vector3(0, 0, 300)); Acts::Experimental::BoundVolumesGrid1Navigation bvgs( - zArray, Acts::binZ, volumes, shift300.inverse()); + zArray, Acts::BinningValue::binZ, volumes, shift300.inverse()); // 150 (-300) -> transforms to -150, hence it yields A nState.position = Acts::Vector3(0., 0., 150.); diff --git a/Tests/UnitTests/Core/Seeding/CMakeLists.txt b/Tests/UnitTests/Core/Seeding/CMakeLists.txt index 74279751405..fbd76cb24a6 100644 --- a/Tests/UnitTests/Core/Seeding/CMakeLists.txt +++ b/Tests/UnitTests/Core/Seeding/CMakeLists.txt @@ -3,3 +3,4 @@ target_link_libraries(ActsUnitTestSeedFinder PRIVATE ActsCore Boost::boost) add_unittest(EstimateTrackParamsFromSeed EstimateTrackParamsFromSeedTest.cpp) add_unittest(BinnedGroupTest BinnedGroupTest.cpp) +add_unittest(HoughTransformTest HoughTransformTest.cpp) diff --git a/Tests/UnitTests/Core/Seeding/HoughTransformTest.cpp b/Tests/UnitTests/Core/Seeding/HoughTransformTest.cpp new file mode 100644 index 00000000000..0a5b869e9da --- /dev/null +++ b/Tests/UnitTests/Core/Seeding/HoughTransformTest.cpp @@ -0,0 +1,123 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include "Acts/Definitions/Algebra.hpp" +#include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/Seeding/HoughTransformUtils.hpp" +#include "Acts/Utilities/Logger.hpp" + +#include +#include +#include + +namespace Acts::Test { + +using Scalar = Acts::ActsScalar; +auto logger = Acts::getDefaultLogger("UnitTests", Acts::Logging::VERBOSE); + +struct DriftCircle { + Scalar y{0.}; + Scalar z{0.}; + Scalar rDrift{0.}; + Scalar rDriftError{0.}; + + DriftCircle(const Scalar _y, const Scalar _z, const Scalar _r, + const Scalar _rUncert) + : y{_y}, z{_z}, rDrift{_r}, rDriftError{_rUncert} {} +}; + +BOOST_AUTO_TEST_CASE(hough_transform_seeder) { + Logging::ScopedFailureThreshold ft{Logging::FATAL}; + + // we are using the slope on yz plane with the y coordinate (hardcoded from + // the csv MuonSimHit data) + std::vector> simHits = { + {-0.0401472 / 0.994974, -422.612}}; + + // Define the drift Circles + constexpr double uncert{0.3}; + std::array driftCircles{ + DriftCircle{-427.981, -225.541, 14.5202, uncert}, + DriftCircle{-412.964, -199.53, 1.66237, uncert}, + DriftCircle{-427.981, -173.519, 12.3176, uncert}, + DriftCircle{-427.981, 173.519, 1.5412, uncert}, + DriftCircle{-442.999, 199.53, 12.3937, uncert}, + DriftCircle{-427.981, 225.541, 3.77967, uncert} + + }; + + // configure the binning of the hough plane + Acts::HoughTransformUtils::HoughPlaneConfig planeCfg; + planeCfg.nBinsX = 1000; + planeCfg.nBinsY = 1000; + + // instantiate the peak finder + Acts::HoughTransformUtils::PeakFinders::IslandsAroundMaxConfig peakFinderCfg; + peakFinderCfg.fractionCutoff = 0.7; + peakFinderCfg.threshold = 3.; + peakFinderCfg.minSpacingBetweenPeaks = {0., 30.}; + + // and map the hough plane to parameter ranges. + // The first coordinate is tan(theta), the second is z0 in mm + Acts::HoughTransformUtils::HoughAxisRanges axisRanges{-3., 3., -2000., 2000.}; + + // create the functions parametrising the hough space lines for drift circles. + // Note that there are two solutions for each drift circle and angle + + // left solution + auto houghParamFromDCleft = [](double tanTheta, const DriftCircle& DC) { + return DC.y - tanTheta * DC.z - DC.rDrift / std::cos(std::atan(tanTheta)); + }; + // right solution + auto houghParamFromDCright = [](double tanTheta, const DriftCircle& DC) { + return DC.y - tanTheta * DC.z + DC.rDrift / std::cos(std::atan(tanTheta)); + }; + + // create the function parametrising the drift radius uncertainty + auto houghWidthFromDC = [](double, const DriftCircle& DC) { + return std::min(DC.rDriftError * 3., + 1.0); // scale reported errors up to at least 1mm or 3 + // times the reported error as drift circle calib not + // fully reliable at this stage + }; + + // instantiate the hough plane + Acts::HoughTransformUtils::HoughPlane + houghPlane(planeCfg); + + // also insantiate the peak finder + Acts::HoughTransformUtils::PeakFinders::IslandsAroundMax< + Acts::GeometryIdentifier::Value> + peakFinder(peakFinderCfg); + + // loop over the true hits + for (auto& sh : simHits) { + houghPlane.reset(); + + for (std::size_t k = 0; k < driftCircles.size(); ++k) { + auto dc = driftCircles[k]; + + houghPlane.fill(dc, axisRanges, houghParamFromDCleft, + houghWidthFromDC, k); + houghPlane.fill(dc, axisRanges, houghParamFromDCright, + houghWidthFromDC, k); + } + + // now get the peaks + auto maxima = peakFinder.findPeaks(houghPlane, axisRanges); + for (auto& max : maxima) { + // check the Hough Transforms results + BOOST_CHECK_CLOSE(max.x, sh.first, 4.); + BOOST_CHECK_CLOSE(max.y, sh.second, 0.2); + } + } +} + +} // namespace Acts::Test diff --git a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp index 8aee4c889f1..9719f811c3a 100644 --- a/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/ConeSurfaceTests.cpp @@ -6,7 +6,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -//#include +// #include #include #include "Acts/Definitions/Algebra.hpp" @@ -220,14 +220,22 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { auto pConeExtent = pCone->polyhedronRepresentation(tgContext, 1).extent(); double rMax = zMax * std::tan(alpha); - CHECK_CLOSE_ABS(zMin, pConeExtent.min(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(zMax, pConeExtent.max(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(0., pConeExtent.min(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pConeExtent.max(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-rMax, pConeExtent.min(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pConeExtent.max(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-rMax, pConeExtent.min(binY), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pConeExtent.max(binY), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(zMin, pConeExtent.min(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(zMax, pConeExtent.max(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pConeExtent.min(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-rMax, pConeExtent.min(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-rMax, pConeExtent.min(BinningValue::binY), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binY), + s_onSurfaceTolerance); // Now a sector double halfPhiSector = M_PI / 8.; @@ -236,10 +244,14 @@ BOOST_AUTO_TEST_CASE(ConeSurfaceExtent) { pCone = Surface::makeShared(pTransform, pConeBounds); pConeExtent = pCone->polyhedronRepresentation(tgContext, 1).extent(); - CHECK_CLOSE_ABS(zMin, pConeExtent.min(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(zMax, pConeExtent.max(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(0., pConeExtent.min(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pConeExtent.max(binR), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(zMin, pConeExtent.min(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(zMax, pConeExtent.max(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pConeExtent.min(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pConeExtent.max(BinningValue::binR), + s_onSurfaceTolerance); } /// Unit test for testing ConeSurface alignment derivatives diff --git a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp index 67dd7d9d5a2..3635591f6ab 100644 --- a/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/CylinderSurfaceTests.cpp @@ -214,15 +214,16 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceProperties) { std::string("Acts::CylinderSurface")); // /// Test dump - boost::test_tools::output_test_stream dumpOuput; - cylinderSurfaceObject->toStream(testContext, dumpOuput); - BOOST_CHECK( - dumpOuput.is_equal("Acts::CylinderSurface\n\ + boost::test_tools::output_test_stream dumpOutput; + std::string expected = + "Acts::CylinderSurface\n\ Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\ Rotation: colX = (1.000000, 0.000000, 0.000000)\n\ colY = (0.000000, 1.000000, 0.000000)\n\ colZ = (0.000000, 0.000000, 1.000000)\n\ - Bounds : Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, averagePhi, bevelMinZ, bevelMaxZ) = (1.0000000, 10.0000000, 3.1415927, 0.0000000, 0.0000000, 0.0000000)")); + Bounds : Acts::CylinderBounds: (radius, halfLengthZ, halfPhiSector, averagePhi, bevelMinZ, bevelMaxZ) = (1.0000000, 10.0000000, 3.1415927, 0.0000000, 0.0000000, 0.0000000)"; + dumpOutput << cylinderSurfaceObject->toStream(testContext); + BOOST_CHECK(dumpOutput.is_equal(expected)); } BOOST_AUTO_TEST_CASE(CylinderSurfaceEqualityOperators) { @@ -260,14 +261,22 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceExtent) { auto cylinderExtent = cylinderSurface->polyhedronRepresentation(testContext, 1).extent(); - CHECK_CLOSE_ABS(-8, cylinderExtent.min(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(12, cylinderExtent.max(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(radius, cylinderExtent.min(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(radius, cylinderExtent.max(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-radius, cylinderExtent.min(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(radius, cylinderExtent.max(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-radius, cylinderExtent.min(binY), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(radius, cylinderExtent.max(binY), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-8, cylinderExtent.min(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(12, cylinderExtent.max(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(radius, cylinderExtent.min(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(radius, cylinderExtent.max(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-radius, cylinderExtent.min(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(radius, cylinderExtent.max(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-radius, cylinderExtent.min(BinningValue::binY), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(radius, cylinderExtent.max(BinningValue::binY), + s_onSurfaceTolerance); } /// Unit test for testing CylinderSurface alignment derivatives @@ -315,17 +324,21 @@ BOOST_AUTO_TEST_CASE(CylinderSurfaceBinningPosition) { Vector3 exp = Vector3{r * std::cos(averagePhi), r * std::sin(averagePhi), 0}; exp = trf * exp; - Vector3 bp = cylinder->binningPosition(testContext, binR); + Vector3 bp = cylinder->binningPosition(testContext, BinningValue::binR); CHECK_CLOSE_ABS(bp, exp, 1e-10); - CHECK_CLOSE_ABS(cylinder->binningPositionValue(testContext, binR), - VectorHelpers::perp(exp), 1e-10); + CHECK_CLOSE_ABS( + cylinder->binningPositionValue(testContext, BinningValue::binR), + VectorHelpers::perp(exp), 1e-10); - bp = cylinder->binningPosition(testContext, binRPhi); + bp = cylinder->binningPosition(testContext, BinningValue::binRPhi); CHECK_CLOSE_ABS(bp, exp, 1e-10); - CHECK_CLOSE_ABS(cylinder->binningPositionValue(testContext, binRPhi), - VectorHelpers::phi(exp) * VectorHelpers::perp(exp), 1e-10); + CHECK_CLOSE_ABS( + cylinder->binningPositionValue(testContext, BinningValue::binRPhi), + VectorHelpers::phi(exp) * VectorHelpers::perp(exp), 1e-10); - for (auto b : {binX, binY, binZ, binEta, binH, binMag}) { + for (auto b : + {BinningValue::binX, BinningValue::binY, BinningValue::binZ, + BinningValue::binEta, BinningValue::binH, BinningValue::binMag}) { BOOST_TEST_CONTEXT("binValue: " << b) { BOOST_CHECK_EQUAL(cylinder->binningPosition(testContext, b), cylinder->center(testContext)); @@ -352,61 +365,67 @@ BOOST_DATA_TEST_CASE(IncompatibleZDirection, auto cyl2 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm); - BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cyl2, Acts::binPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + cyl->mergedWith(testContext, *cyl2, Acts::BinningValue::binPhi, *logger), + SurfaceMergingException); auto cylShiftedXy = Surface::makeShared( base * Translation3{Vector3{1_mm, 2_mm, 200_mm}}, 30_mm, 100_mm); - BOOST_CHECK_THROW( - cyl->mergedWith(testContext, *cylShiftedXy, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cylShiftedXy, + Acts::BinningValue::binZ, *logger), + SurfaceMergingException); auto cylRotatedZ = Surface::makeShared( base * AngleAxis3{10_degree, Vector3::UnitZ()} * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm); - BOOST_CHECK_THROW( - cyl->mergedWith(testContext, *cylRotatedZ, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cylRotatedZ, + Acts::BinningValue::binZ, *logger), + SurfaceMergingException); auto cylRotatedX = Surface::makeShared( base * AngleAxis3{10_degree, Vector3::UnitX()} * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm); - BOOST_CHECK_THROW( - cyl->mergedWith(testContext, *cylRotatedX, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cylRotatedX, + Acts::BinningValue::binZ, *logger), + SurfaceMergingException); // Cylinder with different radius auto cyl3 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 200_mm}, 35_mm, 100_mm); - BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cyl3, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + cyl->mergedWith(testContext, *cyl3, Acts::BinningValue::binZ, *logger), + SurfaceMergingException); // Cylinder with bevel auto cyl4 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm, M_PI, 0, M_PI / 8.0); - BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cyl4, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + cyl->mergedWith(testContext, *cyl4, Acts::BinningValue::binZ, *logger), + SurfaceMergingException); auto cyl5 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm, M_PI, 0, 0, M_PI / 8.0); - BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cyl5, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + cyl->mergedWith(testContext, *cyl5, Acts::BinningValue::binZ, *logger), + SurfaceMergingException); // Cylinder with overlap in z auto cyl6 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 150_mm}, 30_mm, 100_mm); - BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cyl6, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + cyl->mergedWith(testContext, *cyl6, Acts::BinningValue::binZ, *logger), + SurfaceMergingException); // Cylinder with gap in z auto cyl7 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 250_mm}, 30_mm, 100_mm); - BOOST_CHECK_THROW(cyl->mergedWith(testContext, *cyl7, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + cyl->mergedWith(testContext, *cyl7, Acts::BinningValue::binZ, *logger), + SurfaceMergingException); } BOOST_DATA_TEST_CASE(ZDirection, @@ -425,10 +444,12 @@ BOOST_DATA_TEST_CASE(ZDirection, auto cyl2 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 200_mm}, 30_mm, 100_mm); - auto cyl3 = cyl->mergedWith(testContext, *cyl2, Acts::binZ, *logger); + auto cyl3 = + cyl->mergedWith(testContext, *cyl2, Acts::BinningValue::binZ, *logger); BOOST_REQUIRE_NE(cyl3, nullptr); - auto cyl3Reversed = cyl2->mergedWith(testContext, *cyl, Acts::binZ, *logger); + auto cyl3Reversed = + cyl2->mergedWith(testContext, *cyl, Acts::BinningValue::binZ, *logger); BOOST_REQUIRE_NE(cyl3Reversed, nullptr); BOOST_CHECK(*cyl3 == *cyl3Reversed); @@ -464,24 +485,24 @@ BOOST_DATA_TEST_CASE(IncompatibleRPhiDirection, // Cylinder with overlap in phi auto cylPhi2 = Surface::makeShared(base, 30_mm, 100_mm, 45_degree, a(85_degree)); - BOOST_CHECK_THROW( - cylPhi->mergedWith(testContext, *cylPhi2, Acts::binRPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(cylPhi->mergedWith(testContext, *cylPhi2, + Acts::BinningValue::binRPhi, *logger), + SurfaceMergingException); // Cylinder with gap in phi auto cylPhi3 = Surface::makeShared(base, 30_mm, 100_mm, 45_degree, a(105_degree)); - BOOST_CHECK_THROW( - cylPhi->mergedWith(testContext, *cylPhi3, Acts::binRPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(cylPhi->mergedWith(testContext, *cylPhi3, + Acts::BinningValue::binRPhi, *logger), + SurfaceMergingException); // Cylinder with a z shift auto cylPhi4 = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 20_mm}, 30_mm, 100_mm, 45_degree, a(95_degree)); - BOOST_CHECK_THROW( - cylPhi->mergedWith(testContext, *cylPhi4, Acts::binRPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(cylPhi->mergedWith(testContext, *cylPhi4, + Acts::BinningValue::binRPhi, *logger), + SurfaceMergingException); } BOOST_DATA_TEST_CASE(RPhiDirection, @@ -505,12 +526,13 @@ BOOST_DATA_TEST_CASE(RPhiDirection, auto cyl2 = Surface::makeShared(base, 30_mm, 100_mm, 45_degree, a(95_degree)); - auto cyl3 = cyl->mergedWith(testContext, *cyl2, Acts::binRPhi, *logger); + auto cyl3 = + cyl->mergedWith(testContext, *cyl2, Acts::BinningValue::binRPhi, *logger); BOOST_REQUIRE_NE(cyl3, nullptr); BOOST_CHECK_EQUAL(base.matrix(), cyl3->transform(testContext).matrix()); auto cyl3Reversed = - cyl2->mergedWith(testContext, *cyl, Acts::binRPhi, *logger); + cyl2->mergedWith(testContext, *cyl, Acts::BinningValue::binRPhi, *logger); BOOST_REQUIRE_NE(cyl3Reversed, nullptr); BOOST_CHECK(*cyl3 == *cyl3Reversed); @@ -526,11 +548,13 @@ BOOST_DATA_TEST_CASE(RPhiDirection, 20_degree, a(170_degree)); auto cyl5 = Surface::makeShared(base, 30_mm, 100_mm, 10_degree, a(-160_degree)); - auto cyl45 = cyl4->mergedWith(testContext, *cyl5, Acts::binRPhi, *logger); + auto cyl45 = cyl4->mergedWith(testContext, *cyl5, Acts::BinningValue::binRPhi, + *logger); BOOST_REQUIRE_NE(cyl45, nullptr); BOOST_CHECK_EQUAL(base.matrix(), cyl45->transform(testContext).matrix()); - auto cyl54 = cyl5->mergedWith(testContext, *cyl4, Acts::binRPhi, *logger); + auto cyl54 = cyl5->mergedWith(testContext, *cyl4, Acts::BinningValue::binRPhi, + *logger); BOOST_REQUIRE_NE(cyl54, nullptr); BOOST_CHECK(*cyl54 == *cyl45); diff --git a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp index 4db74e0af17..40e16d69c36 100644 --- a/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/DiscSurfaceTests.cpp @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceProperties) { // /// Test binningPosition // auto binningPosition= - // discSurfaceObject.binningPosition(BinningValue::binRPhi ); + // discSurfaceObject.binningPosition(BinningValue::BinningValue::binRPhi ); // std::cout<binningPosition(tgContext, BinningValue::binRPhi), @@ -245,29 +245,47 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceExtent) { Surface::makeShared(Transform3::Identity(), 0., rMax); auto pDiscExtent = pDisc->polyhedronRepresentation(tgContext, 1).extent(); - CHECK_CLOSE_ABS(0., pDiscExtent.min(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(0., pDiscExtent.max(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(0., pDiscExtent.min(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pDiscExtent.max(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-rMax, pDiscExtent.min(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pDiscExtent.max(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-rMax, pDiscExtent.min(binY), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pDiscExtent.max(binY), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-M_PI, pDiscExtent.min(binPhi), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(M_PI, pDiscExtent.max(binPhi), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pDiscExtent.min(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pDiscExtent.max(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pDiscExtent.min(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pDiscExtent.max(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-rMax, pDiscExtent.min(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pDiscExtent.max(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-rMax, pDiscExtent.min(BinningValue::binY), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pDiscExtent.max(BinningValue::binY), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-M_PI, pDiscExtent.min(BinningValue::binPhi), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(M_PI, pDiscExtent.max(BinningValue::binPhi), + s_onSurfaceTolerance); auto pRing = Surface::makeShared(Transform3::Identity(), rMin, rMax); auto pRingExtent = pRing->polyhedronRepresentation(tgContext, 1).extent(); - CHECK_CLOSE_ABS(0., pRingExtent.min(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(0., pRingExtent.max(binZ), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMin, pRingExtent.min(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pRingExtent.max(binR), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-rMax, pRingExtent.min(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pRingExtent.max(binX), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(-rMax, pRingExtent.min(binY), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(rMax, pRingExtent.max(binY), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pRingExtent.min(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(0., pRingExtent.max(BinningValue::binZ), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMin, pRingExtent.min(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pRingExtent.max(BinningValue::binR), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-rMax, pRingExtent.min(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pRingExtent.max(BinningValue::binX), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(-rMax, pRingExtent.min(BinningValue::binY), + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(rMax, pRingExtent.max(BinningValue::binY), + s_onSurfaceTolerance); } /// Unit test for testing DiscSurface alignment derivatives @@ -324,22 +342,25 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { auto bounds = std::make_shared(minR, maxR, M_PI / 8, 0.1); auto disc = Acts::Surface::makeShared(trf, bounds); - Vector3 bp = disc->binningPosition(tgContext, binR); + Vector3 bp = disc->binningPosition(tgContext, BinningValue::binR); double r = (bounds->rMax() + bounds->rMin()) / 2.0; double phi = bounds->get(RadialBounds::eAveragePhi); Vector3 exp = Vector3{r * std::cos(phi), r * std::sin(phi), 0}; exp = trf * exp; BOOST_CHECK_EQUAL(bp, exp); - BOOST_CHECK_EQUAL(disc->binningPositionValue(tgContext, binR), + BOOST_CHECK_EQUAL(disc->binningPositionValue(tgContext, BinningValue::binR), VectorHelpers::perp(exp)); - bp = disc->binningPosition(tgContext, binPhi); + bp = disc->binningPosition(tgContext, BinningValue::binPhi); BOOST_CHECK_EQUAL(bp, exp); - BOOST_CHECK_EQUAL(disc->binningPositionValue(tgContext, binPhi), - VectorHelpers::phi(exp)); + BOOST_CHECK_EQUAL( + disc->binningPositionValue(tgContext, BinningValue::binPhi), + VectorHelpers::phi(exp)); - for (auto b : {binX, binY, binZ, binEta, binRPhi, binH, binMag}) { + for (auto b : {BinningValue::binX, BinningValue::binY, BinningValue::binZ, + BinningValue::binEta, BinningValue::binRPhi, + BinningValue::binH, BinningValue::binMag}) { BOOST_TEST_CONTEXT("binValue: " << b) { BOOST_CHECK_EQUAL(disc->binningPosition(tgContext, b), disc->center(tgContext)); @@ -357,7 +378,7 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { auto disc = Acts::Surface::makeShared(trf, bounds); - Vector3 bp = disc->binningPosition(tgContext, binR); + Vector3 bp = disc->binningPosition(tgContext, BinningValue::binR); double r = (bounds->rMax() + bounds->rMin()) / 2.0; double phi = bounds->get(AnnulusBounds::eAveragePhi); Vector3 exp = Vector3{r * std::cos(phi), r * std::sin(phi), 0}; @@ -365,10 +386,12 @@ BOOST_AUTO_TEST_CASE(DiscSurfaceBinningPosition) { BOOST_CHECK_EQUAL(bp, exp); - bp = disc->binningPosition(tgContext, binPhi); + bp = disc->binningPosition(tgContext, BinningValue::binPhi); BOOST_CHECK_EQUAL(bp, exp); - for (auto b : {binX, binY, binZ, binEta, binRPhi, binH, binMag}) { + for (auto b : {BinningValue::binX, BinningValue::binY, BinningValue::binZ, + BinningValue::binEta, BinningValue::binRPhi, + BinningValue::binH, BinningValue::binMag}) { BOOST_TEST_CONTEXT("binValue: " << b) { BOOST_CHECK_EQUAL(disc->binningPosition(tgContext, b), disc->center(tgContext)); @@ -398,11 +421,13 @@ BOOST_AUTO_TEST_CASE(IncompatibleBounds) { auto discTrap2 = Surface::makeShared(base, 20_mm, 40_mm, 30_mm, 100_mm); - BOOST_CHECK_THROW(discRadial->mergedWith(tgContext, *discTrap, binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + discRadial->mergedWith(tgContext, *discTrap, BinningValue::binR, *logger), + SurfaceMergingException); - BOOST_CHECK_THROW(discTrap2->mergedWith(tgContext, *discTrap, binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + discTrap2->mergedWith(tgContext, *discTrap, BinningValue::binR, *logger), + SurfaceMergingException); } BOOST_DATA_TEST_CASE(IncompatibleRDirection, @@ -422,37 +447,38 @@ BOOST_DATA_TEST_CASE(IncompatibleRDirection, // Disc with overlap in r auto discOverlap = makeDisc(base, 90_mm, 150_mm); - BOOST_CHECK_THROW( - disc->mergedWith(tgContext, *discOverlap, Acts::binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(disc->mergedWith(tgContext, *discOverlap, + Acts::BinningValue::binR, *logger), + SurfaceMergingException); // Disc with gap in r auto discGap = makeDisc(base, 110_mm, 150_mm); - BOOST_CHECK_THROW(disc->mergedWith(tgContext, *discGap, Acts::binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW( + disc->mergedWith(tgContext, *discGap, Acts::BinningValue::binR, *logger), + SurfaceMergingException); auto discShiftedZ = Surface::makeShared( base * Translation3{Vector3::UnitZ() * 10_mm}, 100_mm, 150_mm); - BOOST_CHECK_THROW( - disc->mergedWith(tgContext, *discShiftedZ, Acts::binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(disc->mergedWith(tgContext, *discShiftedZ, + Acts::BinningValue::binR, *logger), + SurfaceMergingException); auto discShiftedXy = makeDisc( base * Translation3{Vector3{1_mm, 2_mm, 200_mm}}, 100_mm, 150_mm); - BOOST_CHECK_THROW( - disc->mergedWith(tgContext, *discShiftedXy, Acts::binZ, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(disc->mergedWith(tgContext, *discShiftedXy, + Acts::BinningValue::binZ, *logger), + SurfaceMergingException); auto discRotatedZ = makeDisc(base * AngleAxis3{10_degree, Vector3::UnitZ()}, 100_mm, 150_mm); - BOOST_CHECK_THROW( - disc->mergedWith(tgContext, *discRotatedZ, Acts::binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(disc->mergedWith(tgContext, *discRotatedZ, + Acts::BinningValue::binR, *logger), + SurfaceMergingException); auto discRotatedX = makeDisc(base * AngleAxis3{10_degree, Vector3::UnitX()}, 100_mm, 150_mm); - BOOST_CHECK_THROW( - disc->mergedWith(tgContext, *discRotatedX, Acts::binR, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(disc->mergedWith(tgContext, *discRotatedX, + Acts::BinningValue::binR, *logger), + SurfaceMergingException); } BOOST_DATA_TEST_CASE(RDirection, @@ -470,10 +496,12 @@ BOOST_DATA_TEST_CASE(RDirection, auto disc2 = makeDisc(base, 100_mm, 150_mm); - auto disc3 = disc->mergedWith(tgContext, *disc2, Acts::binR, *logger); + auto disc3 = + disc->mergedWith(tgContext, *disc2, Acts::BinningValue::binR, *logger); BOOST_REQUIRE_NE(disc3, nullptr); - auto disc3Reversed = disc2->mergedWith(tgContext, *disc, Acts::binR, *logger); + auto disc3Reversed = + disc2->mergedWith(tgContext, *disc, Acts::BinningValue::binR, *logger); BOOST_REQUIRE_NE(disc3Reversed, nullptr); BOOST_CHECK(*disc3 == *disc3Reversed); @@ -508,28 +536,28 @@ BOOST_DATA_TEST_CASE(IncompatiblePhiDirection, // Disc with overlap in phi auto discPhi2 = makeDisc(base, 30_mm, 100_mm, 45_degree, a(85_degree)); - BOOST_CHECK_THROW( - discPhi->mergedWith(tgContext, *discPhi2, Acts::binPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(discPhi->mergedWith(tgContext, *discPhi2, + Acts::BinningValue::binPhi, *logger), + SurfaceMergingException); // Disc with gap in phi auto discPhi3 = makeDisc(base, 30_mm, 100_mm, 45_degree, a(105_degree)); - BOOST_CHECK_THROW( - discPhi->mergedWith(tgContext, *discPhi3, Acts::binPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(discPhi->mergedWith(tgContext, *discPhi3, + Acts::BinningValue::binPhi, *logger), + SurfaceMergingException); // Disc with a z shift auto discPhi4 = makeDisc(base * Translation3{Vector3::UnitZ() * 20_mm}, 30_mm, 100_mm, 45_degree, a(95_degree)); - BOOST_CHECK_THROW( - discPhi->mergedWith(tgContext, *discPhi4, Acts::binPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(discPhi->mergedWith(tgContext, *discPhi4, + Acts::BinningValue::binPhi, *logger), + SurfaceMergingException); // Disc with different r bounds: could be merged in r but not in phi auto discPhi5 = makeDisc(base, 100_mm, 150_mm, 45_degree, a(95_degree)); - BOOST_CHECK_THROW( - discPhi->mergedWith(tgContext, *discPhi5, Acts::binPhi, *logger), - SurfaceMergingException); + BOOST_CHECK_THROW(discPhi->mergedWith(tgContext, *discPhi5, + Acts::BinningValue::binPhi, *logger), + SurfaceMergingException); } BOOST_DATA_TEST_CASE(PhiDirection, @@ -551,12 +579,13 @@ BOOST_DATA_TEST_CASE(PhiDirection, auto disc = makeDisc(base, 30_mm, 100_mm, 10_degree, a(40_degree)); auto disc2 = makeDisc(base, 30_mm, 100_mm, 45_degree, a(95_degree)); - auto disc3 = disc->mergedWith(tgContext, *disc2, Acts::binPhi, *logger); + auto disc3 = + disc->mergedWith(tgContext, *disc2, Acts::BinningValue::binPhi, *logger); BOOST_REQUIRE_NE(disc3, nullptr); BOOST_CHECK_EQUAL(base.matrix(), disc3->transform(tgContext).matrix()); auto disc3Reversed = - disc2->mergedWith(tgContext, *disc, Acts::binPhi, *logger); + disc2->mergedWith(tgContext, *disc, Acts::BinningValue::binPhi, *logger); BOOST_REQUIRE_NE(disc3Reversed, nullptr); BOOST_CHECK(*disc3 == *disc3Reversed); @@ -571,11 +600,13 @@ BOOST_DATA_TEST_CASE(PhiDirection, auto disc4 = makeDisc(base, 30_mm, 100_mm, 20_degree, a(170_degree)); auto disc5 = makeDisc(base, 30_mm, 100_mm, 10_degree, a(-160_degree)); - auto disc45 = disc4->mergedWith(tgContext, *disc5, Acts::binPhi, *logger); + auto disc45 = + disc4->mergedWith(tgContext, *disc5, Acts::BinningValue::binPhi, *logger); BOOST_REQUIRE_NE(disc45, nullptr); BOOST_CHECK_EQUAL(base.matrix(), disc45->transform(tgContext).matrix()); - auto disc54 = disc5->mergedWith(tgContext, *disc4, Acts::binPhi, *logger); + auto disc54 = + disc5->mergedWith(tgContext, *disc4, Acts::BinningValue::binPhi, *logger); BOOST_REQUIRE_NE(disc54, nullptr); BOOST_CHECK(*disc54 == *disc45); diff --git a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp index 3c922a51740..780a9fd9071 100644 --- a/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/LineSurfaceTests.cpp @@ -96,8 +96,8 @@ BOOST_AUTO_TEST_CASE(LineSurface_allNamedMethods_test) { Transform3 transform(translation); LineSurfaceStub line(transform, 2.0, 20.); Vector3 referencePosition{0., 1., 2.}; - CHECK_CLOSE_ABS(referencePosition, line.binningPosition(tgContext, binX), - 1e-6); + CHECK_CLOSE_ABS(referencePosition, + line.binningPosition(tgContext, BinningValue::binX), 1e-6); // // bounds() auto pLineBounds = std::make_shared(2., 10.0); diff --git a/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp index 9d89ae7059d..416ceefedbc 100644 --- a/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PerigeeSurfaceTests.cpp @@ -65,10 +65,10 @@ BOOST_AUTO_TEST_CASE(PerigeeSurfaceProperties) { std::string("Acts::PerigeeSurface")); // /// Test dump - boost::test_tools::output_test_stream dumpOuput; - perigeeSurfaceObject->toStream(tgContext, dumpOuput); + boost::test_tools::output_test_stream dumpOutput; + dumpOutput << perigeeSurfaceObject->toStream(tgContext); BOOST_CHECK( - dumpOuput.is_equal("Acts::PerigeeSurface:\n\ + dumpOutput.is_equal("Acts::PerigeeSurface:\n\ Center position (x, y, z) = (1.0000000, 1.0000000, 1.0000000)")); } diff --git a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp index 17ffbb2fb30..51f24d09c28 100644 --- a/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PlaneSurfaceTests.cpp @@ -234,14 +234,21 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceExtent) { auto planeExtent = plane->polyhedronRepresentation(tgContext, 1).extent(); - CHECK_CLOSE_ABS(planeExtent.min(binZ), -rHx, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.max(binZ), rHx, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.min(binX), -rHy, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.max(binX), rHy, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.min(binY), yPs, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.max(binY), yPs, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.min(binR), yPs, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtent.max(binR), std::hypot(yPs, rHy), + CHECK_CLOSE_ABS(planeExtent.min(BinningValue::binZ), -rHx, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.max(BinningValue::binZ), rHx, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.min(BinningValue::binX), -rHy, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.max(BinningValue::binX), rHy, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.min(BinningValue::binY), yPs, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.max(BinningValue::binY), yPs, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.min(BinningValue::binR), yPs, + s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtent.max(BinningValue::binR), std::hypot(yPs, rHy), s_onSurfaceTolerance); // Now rotate @@ -253,17 +260,19 @@ BOOST_AUTO_TEST_CASE(PlaneSurfaceExtent) { auto planeExtentRot = planeRot->polyhedronRepresentation(tgContext, 1).extent(); - CHECK_CLOSE_ABS(planeExtentRot.min(binZ), -rHx, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtentRot.max(binZ), rHx, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtentRot.min(binX), -rHy * std::cos(alpha), - s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtentRot.max(binX), rHy * std::cos(alpha), + CHECK_CLOSE_ABS(planeExtentRot.min(BinningValue::binZ), -rHx, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtentRot.min(binY), yPs - rHy * std::sin(alpha), + CHECK_CLOSE_ABS(planeExtentRot.max(BinningValue::binZ), rHx, s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtentRot.max(binY), yPs + rHy * std::sin(alpha), + CHECK_CLOSE_ABS(planeExtentRot.min(BinningValue::binX), + -rHy * std::cos(alpha), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtentRot.max(BinningValue::binX), rHy * std::cos(alpha), s_onSurfaceTolerance); - CHECK_CLOSE_ABS(planeExtentRot.min(binR), yPs * std::cos(alpha), + CHECK_CLOSE_ABS(planeExtentRot.min(BinningValue::binY), + yPs - rHy * std::sin(alpha), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtentRot.max(BinningValue::binY), + yPs + rHy * std::sin(alpha), s_onSurfaceTolerance); + CHECK_CLOSE_ABS(planeExtentRot.min(BinningValue::binR), yPs * std::cos(alpha), s_onSurfaceTolerance); } diff --git a/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp b/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp index 53a98eeb991..b37649eebc5 100644 --- a/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/PolyhedronSurfacesTests.cpp @@ -72,14 +72,14 @@ BOOST_AUTO_TEST_CASE(ConeSurfacePolyhedrons) { auto oneConePh = oneCone->polyhedronRepresentation(tgContext, segments); const auto extent = oneConePh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0_mm, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0_mm, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), hzPos, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0_mm, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0_mm, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), hzPos, epsAbs); const unsigned int expectedFaces = segments < 4 ? 4 : segments; BOOST_CHECK_EQUAL(oneConePh.faces.size(), expectedFaces); @@ -98,14 +98,14 @@ BOOST_AUTO_TEST_CASE(ConeSurfacePolyhedrons) { oneConePiece->polyhedronRepresentation(tgContext, segments); const auto extent = oneConePiecePh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), rMin, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), hzpMin, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), hzPos, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), rMin, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), hzpMin, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), hzPos, epsAbs); } /// The full cone on both sides @@ -115,14 +115,14 @@ BOOST_AUTO_TEST_CASE(ConeSurfacePolyhedrons) { auto twoConesPh = twoCones->polyhedronRepresentation(tgContext, segments); const auto extent = twoConesPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0_mm, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), hzNeg, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), hzPos, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0_mm, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), hzNeg, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), hzPos, epsAbs); const unsigned int expectedFaces = segments < 4 ? 8 : 2 * segments; BOOST_CHECK_EQUAL(twoConesPh.faces.size(), expectedFaces); @@ -141,14 +141,15 @@ BOOST_AUTO_TEST_CASE(ConeSurfacePolyhedrons) { sectoralCones->polyhedronRepresentation(tgContext, segments); const auto extent = sectoralConesPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), 0, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rMax, epsAbs); - // CHECK_CLOSE_ABS(extent.range(binY).min(), ???, epsAbs); - // CHECK_CLOSE_ABS(extent.range(binY).max(), ???, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0_mm, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), rMax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), hzNeg, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), hzPos, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), 0, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rMax, epsAbs); + // CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), ???, + // epsAbs); CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), + // ???, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0_mm, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), rMax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), hzNeg, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), hzPos, epsAbs); } } } @@ -175,14 +176,14 @@ BOOST_AUTO_TEST_CASE(CylinderSurfacePolyhedrons) { fullCylinder->polyhedronRepresentation(tgContext, segments); const auto extent = fullCylinderPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), -hZ, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), hZ, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), -hZ, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), hZ, epsAbs); const unsigned int expectedFaces = segments < 4 ? 4 : segments; const unsigned int expectedVertices = segments < 4 ? 8 : 2 * segments; @@ -201,17 +202,17 @@ BOOST_AUTO_TEST_CASE(CylinderSurfacePolyhedrons) { centerSectoredCylinder->polyhedronRepresentation(tgContext, segments); const auto extent = centerSectoredCylinderPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), r * std::cos(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -r * std::sin(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), r * std::sin(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), r, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), -hZ, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), hZ, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), + r * std::cos(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), + -r * std::sin(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), + r * std::sin(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), r, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), -hZ, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), hZ, epsAbs); } } } @@ -237,14 +238,14 @@ BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) { auto fullDiscPh = fullDisc->polyhedronRepresentation(tgContext, segments); const auto extent = fullDiscPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); const unsigned int expectedFaces = 1; const unsigned int expectedVertices = segments > 4 ? segments + 1 : 4 + 1; @@ -259,14 +260,14 @@ BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) { auto radialPh = radialDisc->polyhedronRepresentation(tgContext, segments); const auto extent = radialPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), innerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), innerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } /// Sectoral disc - around 0. @@ -276,16 +277,16 @@ BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) { auto sectorPh = sectorDisc->polyhedronRepresentation(tgContext, segments); const auto extent = sectorPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -outerR * std::sin(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), outerR * std::sin(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), + -outerR * std::sin(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), + outerR * std::sin(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } /// Sectoral ring - around 0. @@ -298,17 +299,17 @@ BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) { sectorRingDisc->polyhedronRepresentation(tgContext, segments); const auto extent = sectorRingDiscPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), innerR * std::cos(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -outerR * std::sin(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), outerR * std::sin(phiSector), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), innerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), outerR, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), + innerR * std::cos(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), + -outerR * std::sin(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), + outerR * std::sin(phiSector), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), innerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), outerR, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } /// Trapezoid for a disc @@ -324,18 +325,19 @@ BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) { trapezoidDiscSf->polyhedronRepresentation(tgContext, segments); const auto extent = trapezoidDiscSfPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -std::abs(outerR - innerR) / 2., - epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), std::abs(outerR - innerR) / 2., + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), + -std::abs(outerR - innerR) / 2., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), + std::abs(outerR - innerR) / 2., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -halfXmax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -halfXmax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), halfXmax, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), halfXmax, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), std::hypot(std::abs(outerR - innerR) / 2., halfXmax), epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } /// AnnulusBounds for a disc @@ -353,14 +355,18 @@ BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) { annulusDisc->polyhedronRepresentation(tgContext, segments); const auto extent = annulusDiscPh.extent(); - // CHECK_CLOSE_ABS(extent.range(binX).min(), ???, epsAbs); - // CHECK_CLOSE_ABS(extent.range(binX).max(), ???, epsAbs); - // CHECK_CLOSE_ABS(extent.range(binY).min(), ???, epsAbs); - // CHECK_CLOSE_ABS(extent.range(binY).max(), ???, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), minRadius, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), maxRadius, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + // CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), ???, + // epsAbs); CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), + // ???, epsAbs); + // CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), ???, + // epsAbs); CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), + // ???, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), minRadius, + epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), maxRadius, + epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } } } @@ -387,14 +393,15 @@ BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) { rectangularPlane->polyhedronRepresentation(tgContext, segments); const auto extent = rectangularPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rhX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rhX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rhY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rhY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), std::hypot(rhX, rhY), epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rhX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rhX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rhY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rhY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), + std::hypot(rhX, rhY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); BOOST_CHECK_EQUAL(rectangularPh.vertices.size(), 4); BOOST_CHECK_EQUAL(rectangularPh.faces.size(), 1); @@ -416,15 +423,17 @@ BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) { trapezoidalPlane->polyhedronRepresentation(tgContext, segments); const auto extent = trapezoidalPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -std::max(thX1, thX2), epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), std::max(thX1, thX2), epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -thY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), thY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), + -std::max(thX1, thX2), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), + std::max(thX1, thX2), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -thY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), thY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), std::hypot(std::max(thX1, thX2), thY), epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); BOOST_CHECK_EQUAL(trapezoidalPh.vertices.size(), 4); BOOST_CHECK_EQUAL(trapezoidalPh.faces.size(), 1); @@ -447,14 +456,16 @@ BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) { ellipsoidPlane->polyhedronRepresentation(tgContext, segments); const auto extent = ellipsoidPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rMaxX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rMaxX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rMaxY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rMaxY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), std::min(rMinX, rMinY), epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), std::max(rMaxX, rMaxY), epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rMaxX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rMaxX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rMaxY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rMaxY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), + std::min(rMinX, rMinY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), + std::max(rMaxX, rMaxY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } { @@ -470,14 +481,16 @@ BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) { ellipsoidRingPlane->polyhedronRepresentation(tgContext, segments); const auto extent = ellipsoidRingPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rMaxX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rMaxX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rMaxY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rMaxY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), std::min(rMinX, rMinY), epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), std::max(rMaxX, rMaxY), epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rMaxX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rMaxX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rMaxY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rMaxY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), + std::min(rMinX, rMinY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), + std::max(rMaxX, rMaxY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } /// ConvexPolygonBounds test @@ -493,14 +506,15 @@ BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) { hexagonPlane->polyhedronRepresentation(tgContext, segments); const auto extent = hexagonPlanePh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -40, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), 30, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -30, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), 50, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), std::sqrt(2900), epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -40, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), 30, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -30, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), 50, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), std::sqrt(2900), + epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); } /// Diamond shaped plane @@ -518,15 +532,15 @@ BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) { diamondPlane->polyhedronRepresentation(tgContext, segments); const auto extent = diamondPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -hMedX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), hMedX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -hMinY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), hMaxY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), std::hypot(hMaxX, hMaxY), - epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -hMedX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), hMedX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -hMinY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), hMaxY, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), + std::hypot(hMaxX, hMaxY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); BOOST_CHECK_EQUAL(diamondPh.vertices.size(), 6); BOOST_CHECK_EQUAL(diamondPh.faces.size(), 1); @@ -561,15 +575,17 @@ BOOST_AUTO_TEST_CASE(ShiftedSurfacePolyhedrons) { rectangularPlane->polyhedronRepresentation(tgContext, segments); const auto extent = rectangularPh.extent(); - CHECK_CLOSE_ABS(extent.range(binX).min(), -rhX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binX).max(), rhX, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).min(), -rhY + shiftY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binY).max(), rhY + shiftY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).min(), 25, epsAbs); - CHECK_CLOSE_ABS(extent.range(binR).max(), std::hypot(rhX, rhY + shiftY), + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).min(), -rhX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binX).max(), rhX, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).min(), -rhY + shiftY, + epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binY).max(), rhY + shiftY, epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).min(), 0., epsAbs); - CHECK_CLOSE_ABS(extent.range(binZ).max(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).min(), 25, epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binR).max(), + std::hypot(rhX, rhY + shiftY), epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).min(), 0., epsAbs); + CHECK_CLOSE_ABS(extent.range(BinningValue::binZ).max(), 0., epsAbs); BOOST_CHECK_EQUAL(rectangularPh.vertices.size(), 4); BOOST_CHECK_EQUAL(rectangularPh.faces.size(), 1); diff --git a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp index 368dd0a86f8..0402afcfabf 100644 --- a/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/StrawSurfaceTests.cpp @@ -91,10 +91,10 @@ BOOST_AUTO_TEST_CASE(StrawSurfaceProperties) { std::string("Acts::StrawSurface")); // /// Test dump - boost::test_tools::output_test_stream dumpOuput; - strawSurfaceObject->toStream(tgContext, dumpOuput); + boost::test_tools::output_test_stream dumpOutput; + dumpOutput << strawSurfaceObject->toStream(tgContext); BOOST_CHECK( - dumpOuput.is_equal("Acts::StrawSurface\n\ + dumpOutput.is_equal("Acts::StrawSurface\n\ Center position (x, y, z) = (0.0000, 1.0000, 2.0000)\n\ Rotation: colX = (1.000000, 0.000000, 0.000000)\n\ colY = (0.000000, 1.000000, 0.000000)\n\ diff --git a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp index 0f1ccee9d65..0425c91897d 100644 --- a/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp +++ b/Tests/UnitTests/Core/Surfaces/SurfaceArrayTests.cpp @@ -210,7 +210,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { sa.toStream(tgContext, std::cout); for (const auto& srf : brl) { - Vector3 ctr = srf->binningPosition(tgContext, binR); + Vector3 ctr = srf->binningPosition(tgContext, BinningValue::binR); std::vector binContent = sa.at(ctr); BOOST_CHECK_EQUAL(binContent.size(), 1u); @@ -230,7 +230,7 @@ BOOST_FIXTURE_TEST_CASE(SurfaceArray_create, SurfaceArrayFixture) { SurfaceArray sa2(std::move(sl2), brl); sa.toStream(tgContext, std::cout); for (const auto& srf : brl) { - Vector3 ctr = srf->binningPosition(tgContext, binR); + Vector3 ctr = srf->binningPosition(tgContext, BinningValue::binR); std::vector binContent = sa2.at(ctr); BOOST_CHECK_EQUAL(binContent.size(), 1u); diff --git a/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp b/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp index 7772073d75d..ff21fc6659d 100644 --- a/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinAdjustmentTests.cpp @@ -27,8 +27,8 @@ namespace Acts::Test { BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) { RadialBounds bound(50, 75, M_PI, 0); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binR); - bu += BinUtility(1, 0, 1, Acts::closed, Acts::binPhi); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binR); + bu += BinUtility(1, 0, 1, Acts::closed, Acts::BinningValue::binPhi); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); @@ -42,8 +42,8 @@ BOOST_AUTO_TEST_CASE(BinAdjustment_Radial) { BOOST_AUTO_TEST_CASE(BinAdjustment_Cylinder) { CylinderBounds bound(25, 50, M_PI / 4, 0); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binPhi); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binPhi); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binZ); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); @@ -57,8 +57,8 @@ BOOST_AUTO_TEST_CASE(BinAdjustment_Cylinder) { BOOST_AUTO_TEST_CASE(BinAdjustment_Rectangle) { RectangleBounds bound(20, 30); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binX); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binY); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binX); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binY); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); @@ -72,8 +72,8 @@ BOOST_AUTO_TEST_CASE(BinAdjustment_Rectangle) { BOOST_AUTO_TEST_CASE(BinAdjustment_Trapezoid) { TrapezoidBounds bound(5, 15, 30); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binX); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binY); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binX); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binY); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); diff --git a/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp b/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp index 7422dfd5dd3..eab989e5e0a 100644 --- a/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinAdjustmentVolumeTests.cpp @@ -26,9 +26,9 @@ namespace Acts::Test { BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cylinder) { CylinderVolumeBounds bound(10, 50, 150, M_PI / 2, 0); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binR); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binPhi); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binR); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binPhi); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binZ); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); @@ -44,9 +44,9 @@ BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cylinder) { BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_CutoutCylinder) { CutoutCylinderVolumeBounds bound(10, 20, 50, 100, 15); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binR); - bu += BinUtility(1, 0, 1, Acts::closed, Acts::binPhi); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binR); + bu += BinUtility(1, 0, 1, Acts::closed, Acts::BinningValue::binPhi); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binZ); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); @@ -62,9 +62,9 @@ BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_CutoutCylinder) { BOOST_AUTO_TEST_CASE(BinAdjustmentVolume_Cuboid) { CuboidVolumeBounds bound(13, 23, 42); BinUtility bu; - bu += BinUtility(1, 0, 1, Acts::open, Acts::binX); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binY); - bu += BinUtility(1, 0, 1, Acts::open, Acts::binZ); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binX); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binY); + bu += BinUtility(1, 0, 1, Acts::open, Acts::BinningValue::binZ); BinUtility buAdjust = adjustBinUtility(bu, bound, Transform3::Identity()); diff --git a/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp b/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp index d08eaeff295..83b2cfc796b 100644 --- a/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinUtilityTests.cpp @@ -26,12 +26,12 @@ BOOST_AUTO_TEST_CASE(BinUtility_equidistant_binning) { Vector3 edgePosition(0.5, 0.5, 0.5); // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | - BinUtility xUtil_eq(10, 0., 10., open, binX); - BinUtility yUtil_eq(10, 0., 10., open, binY); - BinUtility zUtil_eq(10, 0., 10., open, binZ); + BinUtility xUtil_eq(10, 0., 10., open, BinningValue::binX); + BinUtility yUtil_eq(10, 0., 10., open, BinningValue::binY); + BinUtility zUtil_eq(10, 0., 10., open, BinningValue::binZ); BOOST_CHECK_EQUAL(xUtil_eq.bins(), std::size_t{10}); // make it 2-dim - BinUtility xyUtil_eq(10, 0., 10., open, binX); + BinUtility xyUtil_eq(10, 0., 10., open, BinningValue::binX); xyUtil_eq += yUtil_eq; BOOST_CHECK_EQUAL(xyUtil_eq.bins(), 100u); // make it 3-dim @@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(BinUtility_equidistant_binning) { BOOST_CHECK_EQUAL(xyzUtil_eq.dimensions(), 3u); // check equality operator - BinUtility xUtil_eq_copy(10, 0., 10., open, binX); + BinUtility xUtil_eq_copy(10, 0., 10., open, BinningValue::binX); BOOST_CHECK_EQUAL(xUtil_eq_copy, xUtil_eq); BOOST_CHECK_NE(yUtil_eq, xUtil_eq); @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(BinUtility_equidistant_binning) { // OPEN - equidistant binning tests BOOST_AUTO_TEST_CASE(BinUtility_arbitrary_binning) { std::vector bvalues = {-5., 0., 1., 1.1, 8.}; - BinUtility xUtil(bvalues, Acts::open, Acts::binX); + BinUtility xUtil(bvalues, Acts::open, Acts::BinningValue::binX); // Underflow BOOST_CHECK_EQUAL(xUtil.bin(Vector3(-6., 0., 0.)), 0u); @@ -93,9 +93,9 @@ BOOST_AUTO_TEST_CASE(BinUtility_transform) { Transform3 transform_GtoL = transform_LtoG.inverse(); - BinUtility rUtil(10, 0., 100., open, binR); - BinUtility phiUtil(10, -M_PI, M_PI, closed, binPhi); - BinUtility zUtil(10, -100., 100., open, binZ); + BinUtility rUtil(10, 0., 100., open, BinningValue::binR); + BinUtility phiUtil(10, -M_PI, M_PI, closed, BinningValue::binPhi); + BinUtility zUtil(10, -100., 100., open, BinningValue::binZ); BinUtility noTranform; noTranform += rUtil; diff --git a/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp b/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp index 18371852613..a7effbe4200 100644 --- a/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp +++ b/Tests/UnitTests/Core/Utilities/BinningDataTests.cpp @@ -36,36 +36,36 @@ Vector2 rphiPosition(3.5, M_PI / 8.); // x/y/zData // bin boundaries // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -BinningData xData_eq(open, binX, 10, 0., 10.); -BinningData yData_eq(open, binY, 10, 0., 10.); -BinningData zData_eq(open, binZ, 10, 0., 10.); +BinningData xData_eq(open, BinningValue::binX, 10, 0., 10.); +BinningData yData_eq(open, BinningValue::binY, 10, 0., 10.); +BinningData zData_eq(open, BinningValue::binZ, 10, 0., 10.); // r/phi/rphiData // bin boundaries // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -BinningData rData_eq(open, binR, 10, 0., 10.); +BinningData rData_eq(open, BinningValue::binR, 10, 0., 10.); // bin boundaries // > -M_PI | -3/5 M_PI | -1/5 M_PI | 1/5 M_PI | 3/5 M_PI | M_PI < -BinningData phiData_eq(closed, binPhi, 5, -M_PI, M_PI); -// BinningData rPhiData_eq(closed, binRPhi, 5, -M_PI, M_PI); +BinningData phiData_eq(closed, BinningValue::binPhi, 5, -M_PI, M_PI); +// BinningData rPhiData_eq(closed, BinningValue::binRPhi, 5, -M_PI, M_PI); // h/etaData // bin boundaries // | 0 | 2 | 4 | 6 | 8 | 10 | -// BinningData hData_eq(open, binH, 5, 0., 10.); +// BinningData hData_eq(open, BinningValue::binH, 5, 0., 10.); // | -2.5 | -1.5 | -0.5 | 0.5 | 1.5 | 2.5 | -BinningData etaData_eq(open, binEta, 5, -2.5, 2.5); +BinningData etaData_eq(open, BinningValue::binEta, 5, -2.5, 2.5); // Fest equality operator -BinningData xData_eq_copy(open, binX, 10, 0., 10.); +BinningData xData_eq_copy(open, BinningValue::binX, 10, 0., 10.); // the binnings - arbitrary std::vector values = {0., 1., 2., 3., 4., 10.}; // bin boundaries // | 0 | 1 | 2 | 3 | 4 | 10 | -BinningData xData_arb(open, binX, values); -BinningData yData_arb(open, binY, values); +BinningData xData_arb(open, BinningValue::binX, values); +BinningData yData_arb(open, BinningValue::binY, values); // | -M_PI | -2 | -1 | 1 | 2 | M_PI | std::vector phiValues = {-M_PI, -2., -1., 1., 2., M_PI}; -BinningData phiData_arb(closed, binPhi, phiValues); +BinningData phiData_arb(closed, BinningValue::binPhi, phiValues); // the binnings - arbitrary when switching to binary search - for boundary // sizes >= 50 @@ -78,16 +78,22 @@ double phiDelta = 0.1064; // the binning - substructure std::vector sstr = {0., 1., 1.5, 2., 3.}; // multiplicative -auto xData_sstr_mult = std::make_unique(open, binX, sstr); +auto xData_sstr_mult = + std::make_unique(open, BinningValue::binX, sstr); // | 0 | 1 | 1.5 | 2 | 3 | 4 | 4.5 | 5 | 6 | 7 | 7.5 | 8 | 9 | -BinningData xData_mult(open, binX, 3, 0., 9., std::move(xData_sstr_mult)); +BinningData xData_mult(open, BinningValue::binX, 3, 0., 9., + std::move(xData_sstr_mult)); /// additive // | 0 | 1 | 1.5 | 2 | 3 | 4 | 5 | std::vector main_sstr = {0., 3., 4., 5.}; -auto xData_sstr_add = std::make_unique(open, binX, sstr); -BinningData xData_add(open, binX, main_sstr, std::move(xData_sstr_add)); - -// enum BinningValue { binX, binY, binZ, binR, binPhi, binRPhi, binH, binEta } +auto xData_sstr_add = + std::make_unique(open, BinningValue::binX, sstr); +BinningData xData_add(open, BinningValue::binX, main_sstr, + std::move(xData_sstr_add)); + +// enum BinningValue { BinningValue::binX, BinningValue::binY, +// BinningValue::binZ, BinningValue::binR, BinningValue::binPhi, +// BinningValue::binRPhi, BinningValue::binH, BinningValue::binEta } // // test the different binning values BOOST_AUTO_TEST_CASE(BinningData_BinningValue) { @@ -100,8 +106,9 @@ BOOST_AUTO_TEST_CASE(BinningData_BinningValue) { phiValues_binary.push_back(phiMin + i * phiDelta); } // bin boundaries when switching to binary search - for boundary sizes >= 50 - BinningData xData_arb_binary(open, binX, values_binary); - BinningData phiData_arb_binary(closed, binPhi, phiValues_binary); + BinningData xData_arb_binary(open, BinningValue::binX, values_binary); + BinningData phiData_arb_binary(closed, BinningValue::binPhi, + phiValues_binary); /// x/y/zData /// check the global position requests // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | @@ -161,8 +168,9 @@ BOOST_AUTO_TEST_CASE(BinningData_bins) { phiValues_binary.push_back(phiMin + i * phiDelta); } // bin boundaries when switching to binary search - for boundary sizes >= 50 - BinningData xData_arb_binary(open, binX, values_binary); - BinningData phiData_arb_binary(closed, binPhi, phiValues_binary); + BinningData xData_arb_binary(open, BinningValue::binX, values_binary); + BinningData phiData_arb_binary(closed, BinningValue::binPhi, + phiValues_binary); /// x/y/zData /// check the global position requests // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | @@ -228,8 +236,9 @@ BOOST_AUTO_TEST_CASE(BinningData_inside_outside) { phiValues_binary.push_back(phiMin + i * phiDelta); } // bin boundaries when switching to binary search - for boundary sizes >= 50 - BinningData xData_arb_binary(open, binX, values_binary); - BinningData phiData_arb_binary(closed, binPhi, phiValues_binary); + BinningData xData_arb_binary(open, BinningValue::binX, values_binary); + BinningData phiData_arb_binary(closed, BinningValue::binPhi, + phiValues_binary); // check the global inside BOOST_CHECK_EQUAL(xData_eq.inside(xyzPosition), true); BOOST_CHECK_EQUAL(yData_eq.inside(xyzPosition), true); @@ -271,8 +280,9 @@ BOOST_AUTO_TEST_CASE(BinningData_open_close) { phiValues_binary.push_back(phiMin + i * phiDelta); } // bin boundaries when switching to binary search - for boundary sizes >= 50 - BinningData xData_arb_binary(open, binX, values_binary); - BinningData phiData_arb_binary(closed, binPhi, phiValues_binary); + BinningData xData_arb_binary(open, BinningValue::binX, values_binary); + BinningData phiData_arb_binary(closed, BinningValue::binPhi, + phiValues_binary); // open values BOOST_CHECK_EQUAL(xData_eq.searchGlobal(xyzPositionOutside), std::size_t{9}); BOOST_CHECK_EQUAL(yData_eq.searchGlobal(xyzPositionOutside), std::size_t{0}); @@ -323,8 +333,9 @@ BOOST_AUTO_TEST_CASE(BinningData_bincenter) { phiValues_binary.push_back(phiMin + i * phiDelta); } // bin boundaries when switching to binary search - for boundary sizes >= 50 - BinningData xData_arb_binary(open, binX, values_binary); - BinningData phiData_arb_binary(closed, binPhi, phiValues_binary); + BinningData xData_arb_binary(open, BinningValue::binX, values_binary); + BinningData phiData_arb_binary(closed, BinningValue::binPhi, + phiValues_binary); /// check the global position requests // | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | BOOST_CHECK_EQUAL(xData_eq.center(3), 3.5); @@ -369,7 +380,8 @@ BOOST_AUTO_TEST_CASE(BinningData_phi_modules) { // n phi modules with phi boundary at -M_Pi/+M_PI are checked above // one module expands over -M_Pi/+M_PI float deltaPhi = 0.1; - BinningData phiData_mod(closed, binPhi, 5, -M_PI + deltaPhi, M_PI + deltaPhi); + BinningData phiData_mod(closed, BinningValue::binPhi, 5, -M_PI + deltaPhi, + M_PI + deltaPhi); float phiStep = M_PI * 2. / 5.; std::vector phiBoundaries_mod = { static_cast(-M_PI + deltaPhi), diff --git a/Tests/UnitTests/Core/Utilities/GridAccessHelpersTests.cpp b/Tests/UnitTests/Core/Utilities/GridAccessHelpersTests.cpp index 33d9cb2bc21..a69298fe222 100644 --- a/Tests/UnitTests/Core/Utilities/GridAccessHelpersTests.cpp +++ b/Tests/UnitTests/Core/Utilities/GridAccessHelpersTests.cpp @@ -44,9 +44,9 @@ BOOST_AUTO_TEST_CASE(Grid1DAccess) { // Global access Vector3 gPosition{0.5, 3.5, 6.5}; - std::vector fCast = {Acts::binX}; - std::vector sCast = {Acts::binY}; - std::vector tCast = {Acts::binZ}; + std::vector fCast = {Acts::BinningValue::binX}; + std::vector sCast = {Acts::BinningValue::binY}; + std::vector tCast = {Acts::BinningValue::binZ}; auto fgAccess = GridAccessHelpers::castPosition(gPosition, fCast); auto sgAccess = GridAccessHelpers::castPosition(gPosition, sCast); @@ -56,9 +56,11 @@ BOOST_AUTO_TEST_CASE(Grid1DAccess) { BOOST_CHECK_EQUAL(grid.atPosition(tgAccess), 6u); // Can this go into a delegate? - auto gsu = std::make_unique>(); + auto gsu = std::make_unique< + const Acts::GridAccess::GlobalSubspace>(); Acts::GridAccess::GlobalToGridLocal1DimDelegate gsuDelegate; - gsuDelegate.connect<&Acts::GridAccess::GlobalSubspace::toGridLocal>( + gsuDelegate.connect< + &Acts::GridAccess::GlobalSubspace::toGridLocal>( std::move(gsu)); BOOST_CHECK(gsuDelegate.connected()); @@ -86,23 +88,26 @@ BOOST_AUTO_TEST_CASE(Grid2DAccess) { // Global access Vector3 gPosition{0.5, 3.5, 6.5}; - std::vector fCast = {Acts::binX, Acts::binY}; + std::vector fCast = {Acts::BinningValue::binX, + Acts::BinningValue::binY}; auto fgAccess = GridAccessHelpers::castPosition(gPosition, fCast); BOOST_CHECK_EQUAL(grid.atPosition(fgAccess), 300u); } BOOST_AUTO_TEST_CASE(GlobalToGridLocalTests) { - Acts::GridAccess::GlobalSubspace gssXY; + Acts::GridAccess::GlobalSubspace + gssXY; auto xy = gssXY.toGridLocal(Vector3{1., 2., 3.}); BOOST_CHECK_EQUAL(xy[0], 1.); BOOST_CHECK_EQUAL(xy[1], 2.); - Acts::GridAccess::GlobalSubspace gssZ; + Acts::GridAccess::GlobalSubspace gssZ; auto z = gssZ.toGridLocal(Vector3{1., 2., 3.}); BOOST_CHECK_EQUAL(z[0], 3.); - Acts::GridAccess::Affine3Transformed> + Acts::GridAccess::Affine3Transformed< + Acts::GridAccess::GlobalSubspace> gssZT(gssZ, Acts::Transform3{Acts::Transform3::Identity()}.pretranslate( Vector3{0., 0., 100.})); diff --git a/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp b/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp index 07655743103..0d91065089e 100644 --- a/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp +++ b/Tests/UnitTests/Core/Utilities/SubspaceTests.cpp @@ -9,11 +9,14 @@ #include #include "Acts/Definitions/Algebra.hpp" +#include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/Utilities/AlgebraHelpers.hpp" #include "Acts/Utilities/detail/Subspace.hpp" #include #include #include +#include #include #include #include @@ -95,7 +98,7 @@ BOOST_AUTO_TEST_SUITE(UtilitiesSubspace) // } // } -BOOST_AUTO_TEST_CASE_TEMPLATE(FixedSizeSubspaceFloat, ScalarAndSubspace, +BOOST_AUTO_TEST_CASE_TEMPLATE(FixedSizeSubspace, ScalarAndSubspace, ScalarsAndFixedSizeSubspaces) { // extract the test types using Scalar = std::tuple_element_t<0, ScalarAndSubspace>; @@ -137,4 +140,49 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(FixedSizeSubspaceFloat, ScalarAndSubspace, } while (std::next_permutation(fullIndices.begin(), fullIndices.end())); } +BOOST_AUTO_TEST_CASE_TEMPLATE(VariableSizeSubspace, ScalarAndSubspace, + ScalarsAndFixedSizeSubspaces) { + // extract the test types + using Scalar = std::tuple_element_t<0, ScalarAndSubspace>; + using FixedSubspace = std::tuple_element_t<1, ScalarAndSubspace>; + using VariableSubspace = + detail::VariableSizeSubspace; + + auto fullIndices = makeMonotonicIndices(FixedSubspace::fullSize()); + + // in principle, we would like to iterate over all possible ordered subsets + // from the full space indices with a size identical to the subspace. since i + // do not know how to do that in a simple manner, we are iterating over all + // permutations of the full indices and pick the first n elements. this should + // give a reasonable set of different subspace configurations. + do { + auto indices = selectFixedIndices(fullIndices); + FixedSubspace fixedSubspace(indices); + VariableSubspace variableSubspace(indices); + + BOOST_CHECK_EQUAL(variableSubspace.size(), fixedSubspace.size()); + BOOST_CHECK_EQUAL(variableSubspace.fullSize(), fixedSubspace.fullSize()); + + auto fixedProjector = fixedSubspace.template projector(); + std::uint64_t fixedProjectorBits = + matrixToBitset(fixedProjector).to_ullong(); + + Eigen::Matrix + fixedFullProjector; + fixedFullProjector.setZero(); + fixedFullProjector.template topLeftCorner() = + fixedProjector; + std::uint64_t fixedFullProjectorBits = + matrixToBitset(fixedFullProjector).to_ullong(); + + std::uint64_t variableProjectorBits = variableSubspace.projectorBits(); + std::uint64_t variableFullProjectorBits = + variableSubspace.fullProjectorBits(); + + BOOST_CHECK_EQUAL(variableProjectorBits, fixedProjectorBits); + BOOST_CHECK_EQUAL(variableFullProjectorBits, fixedFullProjectorBits); + } while (std::next_permutation(fullIndices.begin(), fullIndices.end())); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Examples/Io/Json/JsonDigitizationConfigTests.cpp b/Tests/UnitTests/Examples/Io/Json/JsonDigitizationConfigTests.cpp index 85cd2e5c1c2..a5b29cb257b 100644 --- a/Tests/UnitTests/Examples/Io/Json/JsonDigitizationConfigTests.cpp +++ b/Tests/UnitTests/Examples/Io/Json/JsonDigitizationConfigTests.cpp @@ -156,8 +156,10 @@ BOOST_AUTO_TEST_CASE(DigitizationConfigRoundTrip) { ActsExamples::GeometricConfig gdc; Acts::BinUtility segmentation; - segmentation += Acts::BinUtility(336, -8.4, 8.4, Acts::open, Acts::binX); - segmentation += Acts::BinUtility(1280, -36, 36, Acts::open, Acts::binY); + segmentation += + Acts::BinUtility(336, -8.4, 8.4, Acts::open, Acts::BinningValue::binX); + segmentation += + Acts::BinUtility(1280, -36, 36, Acts::open, Acts::BinningValue::binY); gdc.segmentation = segmentation; gdc.threshold = 0.01; diff --git a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp index 07a3b2a2cbd..14fd079c56a 100644 --- a/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp +++ b/Tests/UnitTests/Fatras/Digitization/PlanarSurfaceTestBeds.hpp @@ -52,8 +52,10 @@ struct PlanarSurfaceTestBeds { auto rectangle = std::make_shared(xhalf, yhalf); auto rSurface = Acts::Surface::makeShared( Acts::Transform3::Identity(), rectangle); - Acts::BinUtility pixelated(15, -xhalf, xhalf, Acts::open, Acts::binX); - pixelated += Acts::BinUtility(26, -yhalf, yhalf, Acts::open, Acts::binY); + Acts::BinUtility pixelated(15, -xhalf, xhalf, Acts::open, + Acts::BinningValue::binX); + pixelated += Acts::BinUtility(26, -yhalf, yhalf, Acts::open, + Acts::BinningValue::binY); RectangleRandom rRandom(xhalf * rScale, yhalf * rScale); // Cartesian strip test in Trapezoid @@ -64,8 +66,10 @@ struct PlanarSurfaceTestBeds { std::make_shared(xhalfminy, xhalfmaxy, yhalf); auto tSurface = Acts::Surface::makeShared( Acts::Transform3::Identity(), trapezoid); - Acts::BinUtility stripsX(35, -xhalfmaxy, xhalfmaxy, Acts::open, Acts::binX); - stripsX += Acts::BinUtility(1, -yhalf, yhalf, Acts::open, Acts::binY); + Acts::BinUtility stripsX(35, -xhalfmaxy, xhalfmaxy, Acts::open, + Acts::BinningValue::binX); + stripsX += Acts::BinUtility(1, -yhalf, yhalf, Acts::open, + Acts::BinningValue::binY); TrapezoidRandom tRandom(xhalfminy * rScale, xhalfmaxy * rScale, yhalf * rScale); @@ -81,9 +85,10 @@ struct PlanarSurfaceTestBeds { std::make_shared(xmin, xmax, rmin, rmax); auto dtSurface = Acts::Surface::makeShared( Acts::Transform3::Identity(), discTrapezoid); - Acts::BinUtility stripsPhi(1, rmin, rmax, Acts::open, Acts::binR); + Acts::BinUtility stripsPhi(1, rmin, rmax, Acts::open, + Acts::BinningValue::binR); stripsPhi += Acts::BinUtility(25, M_PI_2 - alpha, M_PI_2 + alpha, - Acts::open, Acts::binPhi); + Acts::open, Acts::BinningValue::binPhi); TrapezoidRandom dtRandom(xmin * rScale, xmax * rScale, rmin * irScale, ymax * rScale); @@ -92,9 +97,10 @@ struct PlanarSurfaceTestBeds { std::make_shared(rmin, rmax, M_PI_4, M_PI_2); auto dSurface = Acts::Surface::makeShared( Acts::Transform3::Identity(), discRadial); - Acts::BinUtility rphiseg(10, rmin, rmax, Acts::open, Acts::binR); + Acts::BinUtility rphiseg(10, rmin, rmax, Acts::open, + Acts::BinningValue::binR); rphiseg += Acts::BinUtility(20, (M_PI_2 - M_PI_4), (M_PI_2 + M_PI_4), - Acts::open, Acts::binPhi); + Acts::open, Acts::BinningValue::binPhi); DiscRandom dRandom(rmin * irScale, rmax * rScale, (M_PI_2 - M_PI_4) * irScale, (M_PI_2 + M_PI_4) * rScale); @@ -119,9 +125,10 @@ struct PlanarSurfaceTestBeds { rmax = std::max(rmax, r); }); - Acts::BinUtility stripsPhiA(1, rmin, rmax, Acts::open, Acts::binR); - stripsPhiA += - Acts::BinUtility(12, phimin, phimax, Acts::open, Acts::binPhi); + Acts::BinUtility stripsPhiA(1, rmin, rmax, Acts::open, + Acts::BinningValue::binR); + stripsPhiA += Acts::BinUtility(12, phimin, phimax, Acts::open, + Acts::BinningValue::binPhi); AnnulusRandom aRandom(rmin * irScale, rmax * rScale, phimin * rScale, phimax * rScale, aorigin.x(), aorigin.y()); diff --git a/Tests/UnitTests/Fatras/Digitization/SegmentizerTests.cpp b/Tests/UnitTests/Fatras/Digitization/SegmentizerTests.cpp index 8bca761f28e..4680d39f974 100644 --- a/Tests/UnitTests/Fatras/Digitization/SegmentizerTests.cpp +++ b/Tests/UnitTests/Fatras/Digitization/SegmentizerTests.cpp @@ -47,8 +47,9 @@ BOOST_AUTO_TEST_CASE(SegmentizerCartesian) { Acts::Transform3::Identity(), rectangleBounds); // The segmentation - Acts::BinUtility pixelated(20, -1., 1., Acts::open, Acts::binX); - pixelated += Acts::BinUtility(20, -1., 1., Acts::open, Acts::binY); + Acts::BinUtility pixelated(20, -1., 1., Acts::open, Acts::BinningValue::binX); + pixelated += + Acts::BinUtility(20, -1., 1., Acts::open, Acts::BinningValue::binY); Segmentizer cl; @@ -91,8 +92,9 @@ BOOST_AUTO_TEST_CASE(SegmentizerPolarRadial) { Acts::Transform3::Identity(), radialBounds); // The segmentation - Acts::BinUtility strips(2, 5., 10., Acts::open, Acts::binR); - strips += Acts::BinUtility(250, -0.25, 0.25, Acts::open, Acts::binPhi); + Acts::BinUtility strips(2, 5., 10., Acts::open, Acts::BinningValue::binR); + strips += Acts::BinUtility(250, -0.25, 0.25, Acts::open, + Acts::BinningValue::binPhi); Segmentizer cl; @@ -167,8 +169,8 @@ BOOST_DATA_TEST_CASE( } // 1 - write the grid grid.open("Segmentizer" + name + "Grid.csv"); - if (segmentation.binningData()[0].binvalue == Acts::binX && - segmentation.binningData()[1].binvalue == Acts::binY) { + if (segmentation.binningData()[0].binvalue == Acts::BinningValue::binX && + segmentation.binningData()[1].binvalue == Acts::BinningValue::binY) { double bxmin = segmentation.binningData()[0].min; double bxmax = segmentation.binningData()[0].max; double bymin = segmentation.binningData()[1].min; @@ -181,8 +183,10 @@ BOOST_DATA_TEST_CASE( for (const auto yval : yboundaries) { csvHelper.writeLine(grid, {bxmin, yval}, {bxmax, yval}); } - } else if (segmentation.binningData()[0].binvalue == Acts::binR && - segmentation.binningData()[1].binvalue == Acts::binPhi) { + } else if (segmentation.binningData()[0].binvalue == + Acts::BinningValue::binR && + segmentation.binningData()[1].binvalue == + Acts::BinningValue::binPhi) { double brmin = segmentation.binningData()[0].min; double brmax = segmentation.binningData()[0].max; double bphimin = segmentation.binningData()[1].min; diff --git a/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp index 349f6a77112..cb28a9766ff 100644 --- a/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/DetectorSvgConverterTests.cpp @@ -129,7 +129,7 @@ BOOST_AUTO_TEST_CASE(CylindricalDetector) { // Create the barrel container builder CylindricalContainerBuilder::Config barrelRCfg; barrelRCfg.builders = {barrel0, barrel1, barrel2}; - barrelRCfg.binning = {binR}; + barrelRCfg.binning = {BinningValue::binR}; auto barrel = std::make_shared( barrelRCfg, getDefaultLogger("BarrelBuilderR", Logging::VERBOSE)); @@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(CylindricalDetector) { // Create the barrel container builder CylindricalContainerBuilder::Config barrelEndcapCfg; barrelEndcapCfg.builders = {endcapN, barrel, endcapP}; - barrelEndcapCfg.binning = {binZ}; + barrelEndcapCfg.binning = {BinningValue::binZ}; auto barrelEndcap = std::make_shared( barrelEndcapCfg, @@ -153,7 +153,7 @@ BOOST_AUTO_TEST_CASE(CylindricalDetector) { // Create the barrel container builder CylindricalContainerBuilder::Config detectorCfg; detectorCfg.builders = {beampipe, barrelEndcap}; - detectorCfg.binning = {binR}; + detectorCfg.binning = {BinningValue::binR}; auto containerBuilder = std::make_shared( detectorCfg, getDefaultLogger("DetectorBuilder", Logging::VERBOSE)); diff --git a/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp index ac2cc63e392..7d6241e8f4e 100644 --- a/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/DetectorVolumeSvgConverterTests.cpp @@ -149,7 +149,8 @@ BOOST_AUTO_TEST_CASE(EndcapVolumeWithSurfaces) { lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; lsConfig.binnings = {Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 22u, 1u)}; + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, + 22u, 1u)}; auto layerBuilder = std::make_shared( @@ -218,10 +219,12 @@ BOOST_AUTO_TEST_CASE(BarrelVolumeWithSurfaces) { lsConfig.auxiliary = "*** Barrel with 448 surfaces ***"; lsConfig.surfacesProvider = barrelSurfaces; lsConfig.binnings = { - Acts::Experimental::ProtoBinning{ - Acts::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, + Acts::AxisBoundaryType::Bound, -480., + 480., 14u, 1u}, + Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, + Acts::AxisBoundaryType::Closed, -M_PI, + M_PI, 32u, 1u)}; auto barrelBuilder = std::make_shared( diff --git a/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp index a543f8ee930..01ee38ab44b 100644 --- a/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/GridSvgConverterTests.cpp @@ -56,7 +56,8 @@ BOOST_AUTO_TEST_CASE(BoundGridXY) { Grid gridXY(Type>, axisX, axisY); Svg::GridConverter::Options cOptions; - auto pGrid = Svg::GridConverter::convert(gridXY, {binX, binY}, cOptions); + auto pGrid = Svg::GridConverter::convert( + gridXY, {BinningValue::binX, BinningValue::binY}, cOptions); BOOST_CHECK_EQUAL(pGrid._type, actsvg::proto::grid::type::e_x_y); // Labelling the grid tiles @@ -108,8 +109,8 @@ BOOST_AUTO_TEST_CASE(BoundGridXY) { std::vector captionText = { "Binning schema for global and local bins: ", - "- axis 0 : AxisBoundaryType::Bound, (-200., 200, 4), binX", - "- axis 1 : AxisBoundaryType::Bound, (-200, 200, 6), binY"}; + "- axis 0 : AxisBoundaryType::Bound, (-200., 200, 4), BinningValue::binX", + "- axis 1 : AxisBoundaryType::Bound, (-200, 200, 6), BinningValue::binY"}; auto caption = actsvg::draw::text("caption", {-180, -220}, captionText); @@ -132,7 +133,8 @@ BOOST_AUTO_TEST_CASE(OpenGridXY) { Grid gridXY(Type>, axisX, axisY); Svg::GridConverter::Options cOptions; - auto pGrid = Svg::GridConverter::convert(gridXY, {binX, binY}, cOptions); + auto pGrid = Svg::GridConverter::convert( + gridXY, {BinningValue::binX, BinningValue::binY}, cOptions); BOOST_CHECK_EQUAL(pGrid._type, actsvg::proto::grid::type::e_x_y); // Labelling the grid tiles @@ -183,8 +185,8 @@ BOOST_AUTO_TEST_CASE(OpenGridXY) { std::vector captionText = { "Binning schema for global and local bins: ", - "- axis 0 : AxisBoundaryType::Open, (-200., 200, 4), binX", - "- axis 1 : AxisBoundaryType::Open, (-200, 200, 6), binY"}; + "- axis 0 : AxisBoundaryType::Open, (-200., 200, 4), BinningValue::binX", + "- axis 1 : AxisBoundaryType::Open, (-200, 200, 6), BinningValue::binY"}; auto caption = actsvg::draw::text("caption", {-180, -220}, captionText); auto oGrid = actsvg::display::grid("OpenGridXY", pGrid); @@ -208,7 +210,8 @@ BOOST_AUTO_TEST_CASE(ClosedCylinderGridZPhi) { Grid gridZPhi(Type>, axisZ, axisPhi); Svg::GridConverter::Options cOptions; - auto pGrid = Svg::GridConverter::convert(gridZPhi, {binZ, binPhi}, cOptions); + auto pGrid = Svg::GridConverter::convert( + gridZPhi, {BinningValue::binZ, BinningValue::binPhi}, cOptions); BOOST_CHECK_EQUAL(pGrid._type, actsvg::proto::grid::type::e_z_phi); pGrid._reference_r = 80.; @@ -260,8 +263,8 @@ BOOST_AUTO_TEST_CASE(ClosedCylinderGridZPhi) { std::vector captionText = { "Binning schema for global and local bins: ", - "- axis 0 : AxisBoundaryType::Bound, (-200., 200, 3), binZ", - "- axis 1 : AxisBoundaryType::Closed, (-PI, PI, 6), binPhi", + "- axis 0 : AxisBoundaryType::Bound, (-200., 200, 3), BinningValue::binZ", + "- axis 1 : AxisBoundaryType::Closed, (-PI, PI, 6), BinningValue::binPhi", "- draw reference radius set to 80"}; auto caption = actsvg::draw::text("caption", {-180, -270}, captionText); @@ -286,7 +289,8 @@ BOOST_AUTO_TEST_CASE(ClosedDiscGridRPhi) { Grid gridRPhi(Type>, axisR, axisPhi); Svg::GridConverter::Options cOptions; - auto pGrid = Svg::GridConverter::convert(gridRPhi, {binR, binPhi}, cOptions); + auto pGrid = Svg::GridConverter::convert( + gridRPhi, {BinningValue::binR, BinningValue::binPhi}, cOptions); BOOST_CHECK_EQUAL(pGrid._type, actsvg::proto::grid::type::e_r_phi); // Labelling the grid tiles @@ -343,7 +347,8 @@ BOOST_AUTO_TEST_CASE(ClosedDiscGridRPhi) { std::vector captionText = { "Binning schema for global and local bins: ", "- axis 0 : AxisBoundaryType::Bound, (100., 400, 3), binR", - "- axis 1 : AxisBoundaryType::Closed, (-PI, PI, 4), binPhi"}; + "- axis 1 : AxisBoundaryType::Closed, (-PI, PI, 4), " + "binPhi"}; auto caption = actsvg::draw::text("caption", {-180, -420}, captionText); auto oGrid = actsvg::display::grid("ClosedDiscGridRPhi", pGrid); diff --git a/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp b/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp index d51417b3d5a..1f4bcebd77f 100644 --- a/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp +++ b/Tests/UnitTests/Plugins/ActSVG/IndexedSurfacesSvgConverterTests.cpp @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1D) { 55., 0., 2., 22u); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binPhi}}; + irSurfaces{rSurfaces, {}, {BinningValue::binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -100,7 +100,7 @@ BOOST_AUTO_TEST_CASE(RingDisc1DWithSupport) { rSurfaces.push_back(dSurface.get()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {binPhi}}; + irSurfaces{rSurfaces, {rSurfaces.size() - 1u}, {BinningValue::binPhi}}; GridAxisGenerators::EqClosed aGenerator{{-M_PI, M_PI}, 44u}; PolyhedronReferenceGenerator<1u, true> rGenerator; @@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2D) { rSurfaces.insert(rSurfaces.end(), rSurfacesR1.begin(), rSurfacesR1.end()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binR, binPhi}}; + irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::VarBoundEqClosed aGenerator{ {24., 74., 110.}, {-M_PI, M_PI}, 44u}; @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFine) { rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binR, binPhi}}; + irSurfaces{rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -190,7 +190,8 @@ BOOST_AUTO_TEST_CASE(RingDisc2DFineExpanded) { rSurfaces.insert(rSurfaces.end(), rSurfacesR2.begin(), rSurfacesR2.end()); IndexedSurfacesGenerator - irSurfaces{rSurfaces, {}, {binR, binPhi}, {2u, 4u}}; + irSurfaces{ + rSurfaces, {}, {BinningValue::binR, BinningValue::binPhi}, {2u, 4u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {24., 152}, 8u, {-M_PI, M_PI}, 88u}; @@ -211,7 +212,8 @@ BOOST_AUTO_TEST_CASE(Cylinder2D) { 116., 3., 2., {52, 14}); IndexedSurfacesGenerator - icSurfaces{surfaces, {}, {binZ, binPhi}, {1u, 1u}}; + icSurfaces{ + surfaces, {}, {BinningValue::binZ, BinningValue::binPhi}, {1u, 1u}}; GridAxisGenerators::EqBoundEqClosed aGenerator{ {-500., 500}, 28, {-M_PI, M_PI}, 52u}; diff --git a/Tests/UnitTests/Plugins/DD4hep/DD4hepCylinderLayerStructureTests.cpp b/Tests/UnitTests/Plugins/DD4hep/DD4hepCylinderLayerStructureTests.cpp index f4cd1f6a573..cf1550a5886 100644 --- a/Tests/UnitTests/Plugins/DD4hep/DD4hepCylinderLayerStructureTests.cpp +++ b/Tests/UnitTests/Plugins/DD4hep/DD4hepCylinderLayerStructureTests.cpp @@ -36,7 +36,7 @@ const char* beampipe_head_xml = - + )""""; const char* cylinder_layer_head_xml = @@ -295,15 +295,16 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginCylinderLayerStructureAutoRange) { lsOptions.name = "AutoRangeLayer"; auto extent = Acts::Extent(); lsOptions.extent = extent; - lsOptions.extentConstraints = {Acts::binZ, Acts::binR}; + lsOptions.extentConstraints = {Acts::BinningValue::binZ, + Acts::BinningValue::binR}; lsOptions.logLevel = Acts::Logging::VERBOSE; auto [barrelInternalsBuilder, barrelExt] = barrelStructure.builder(dd4hepStore, tContext, world, lsOptions); BOOST_CHECK(barrelExt != std::nullopt); - BOOST_CHECK(barrelExt.value().constrains(Acts::binZ)); - BOOST_CHECK(barrelExt.value().constrains(Acts::binR)); + BOOST_CHECK(barrelExt.value().constrains(Acts::BinningValue::binZ)); + BOOST_CHECK(barrelExt.value().constrains(Acts::BinningValue::binR)); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Plugins/DD4hep/DD4hepCylindricalDetectorTests.cpp b/Tests/UnitTests/Plugins/DD4hep/DD4hepCylindricalDetectorTests.cpp index 894bfb89cce..715a2a09159 100644 --- a/Tests/UnitTests/Plugins/DD4hep/DD4hepCylindricalDetectorTests.cpp +++ b/Tests/UnitTests/Plugins/DD4hep/DD4hepCylindricalDetectorTests.cpp @@ -409,7 +409,7 @@ BOOST_AUTO_TEST_CASE(DD4hepCylidricalDetectorStructure) { BOOST_CHECK_EQUAL(detectorStore.size(), 6u); int elements = 0; - for (auto [key, value] : detectorStore) { + for (const auto& [key, value] : detectorStore) { elements += value.size(); } diff --git a/Tests/UnitTests/Plugins/DD4hep/DD4hepDetectorElementTests.cpp b/Tests/UnitTests/Plugins/DD4hep/DD4hepDetectorElementTests.cpp index f8b76b58955..9f4b44e51f1 100644 --- a/Tests/UnitTests/Plugins/DD4hep/DD4hepDetectorElementTests.cpp +++ b/Tests/UnitTests/Plugins/DD4hep/DD4hepDetectorElementTests.cpp @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginDetectorElementCylinder) { auto world = lcdd->world(); std::shared_ptr cylindricalElement = nullptr; - for (auto [chn, child] : world.children()) { + for (const auto& [chn, child] : world.children()) { cylindricalElement = std::make_shared(child, "XYZ", 10.); } @@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginDetectorElementSectoralCylinder) { auto world = lcdd->world(); std::shared_ptr cylindricalElement = nullptr; - for (auto [chn, child] : world.children()) { + for (const auto& [chn, child] : world.children()) { cylindricalElement = std::make_shared(child, "XYZ", 10.); } @@ -172,7 +172,7 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginDetectorElementDisc) { auto world = lcdd->world(); std::shared_ptr discElement = nullptr; - for (auto [chn, child] : world.children()) { + for (const auto& [chn, child] : world.children()) { discElement = std::make_shared(child, "XYZ", 10., true); } @@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginDetectorElementSectoralDisc) { auto world = lcdd->world(); std::shared_ptr discElement = nullptr; - for (auto [chn, child] : world.children()) { + for (const auto& [chn, child] : world.children()) { discElement = std::make_shared(child, "XYZ", 10., true); } @@ -241,7 +241,7 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginDetectorElementRectangle) { auto world = lcdd->world(); std::shared_ptr rectangleElement = nullptr; - for (auto [chn, child] : world.children()) { + for (const auto& [chn, child] : world.children()) { rectangleElement = std::make_shared(child, "XYZ", 10., true); } @@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(DD4hepPluginDetectorElementTrapezoid) { auto world = lcdd->world(); std::shared_ptr trapezoidElement = nullptr; - for (auto [chn, child] : world.children()) { + for (const auto& [chn, child] : world.children()) { trapezoidElement = std::make_shared(child, "xZ", 10., true); } diff --git a/Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp b/Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp index d5de645fc17..0349d32ff8b 100644 --- a/Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp +++ b/Tests/UnitTests/Plugins/Geant4/Geant4SurfaceProviderTests.cpp @@ -270,8 +270,9 @@ BOOST_AUTO_TEST_CASE(Geant4SurfaceProviderRanges) { std::map> ranges; std::array g4Axes{0}; - for (auto& bv : {Acts::binX, Acts::binY, Acts::binZ}) { - g4Axes[bv] = Acts::binToGeant4Axis(bv); + for (auto& bv : {Acts::BinningValue::binX, Acts::BinningValue::binY, + Acts::BinningValue::binZ}) { + g4Axes[toUnderlying(bv)] = Acts::binToGeant4Axis(bv); } ranges[g4Axes[0]] = std::make_tuple(armOffset - 5, armOffset + 100); diff --git a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp index cea7400562b..224549bb340 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorJsonConverterTests.cpp @@ -169,7 +169,8 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; lsConfig.binnings = {Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 22u, 1u)}; + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, + 22u, 1u)}; auto layerBuilder = std::make_shared( @@ -230,10 +231,12 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { lsConfig.auxiliary = "*** Barrel with 448 surfaces ***"; lsConfig.surfacesProvider = barrelSurfaces; lsConfig.binnings = { - Acts::Experimental::ProtoBinning{ - Acts::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, + Acts::AxisBoundaryType::Bound, -480., + 480., 14u, 1u}, + Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, + Acts::AxisBoundaryType::Closed, -M_PI, + M_PI, 32u, 1u)}; auto barrelBuilder = std::make_shared( @@ -277,7 +280,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { // Build the combined barrel Acts::Experimental::CylindricalContainerBuilder::Config ccBarrelBuilderCfg; ccBarrelBuilderCfg.builders = {ivBuilder, dvBuilder, ovBuilder}; - ccBarrelBuilderCfg.binning = {Acts::binR}; + ccBarrelBuilderCfg.binning = {Acts::BinningValue::binR}; auto ccBarrelBuilder = std::make_shared( @@ -288,7 +291,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { Acts::Experimental::CylindricalContainerBuilder::Config ccBarrelEcBuilderCfg; ccBarrelEcBuilderCfg.builders = {endcapBuilders[0u], ccBarrelBuilder, endcapBuilders[1u]}; - ccBarrelEcBuilderCfg.binning = {Acts::binZ}; + ccBarrelEcBuilderCfg.binning = {Acts::BinningValue::binZ}; auto ccBarrelEndcapBuilder = std::make_shared( @@ -315,7 +318,7 @@ BOOST_AUTO_TEST_CASE(BeamPipeEndcapBarrelDetector) { // Full detector Acts::Experimental::CylindricalContainerBuilder::Config detCompBuilderCfg; detCompBuilderCfg.builders = {bpBuilder, ccBarrelEndcapBuilder}; - detCompBuilderCfg.binning = {Acts::binR}; + detCompBuilderCfg.binning = {Acts::BinningValue::binR}; auto detCompBuilder = std::make_shared( diff --git a/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp index 2b1a57e0b35..f9842a182d5 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorVolumeFinderJsonConverterTests.cpp @@ -51,7 +51,8 @@ BOOST_AUTO_TEST_CASE(RzVolumes) { grid.atPosition(p22) = 22u; grid.atPosition(p23) = 23u; - auto casts = std::array{Acts::binZ, Acts::binR}; + auto casts = std::array{Acts::BinningValue::binZ, + Acts::BinningValue::binR}; using IndexedDetectorVolumesImpl = Acts::Experimental::IndexedGridNavigation< Acts::Experimental::IExternalNavigation, GridType, diff --git a/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp index 2b8a314d05c..126322514e2 100644 --- a/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/DetectorVolumeJsonConverterTests.cpp @@ -148,7 +148,8 @@ BOOST_AUTO_TEST_CASE(EndcapVolumeWithSurfaces) { lsConfig.auxiliary = "*** Endcap with 22 surfaces ***"; lsConfig.surfacesProvider = endcapSurfaces; lsConfig.binnings = {Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 22u, 1u)}; + Acts::BinningValue::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, + 22u, 1u)}; auto layerBuilder = std::make_shared( @@ -226,10 +227,12 @@ BOOST_AUTO_TEST_CASE(BarrelVolumeWithSurfaces) { lsConfig.auxiliary = "*** Barrel with 448 surfaces ***"; lsConfig.surfacesProvider = barrelSurfaces; lsConfig.binnings = { - Acts::Experimental::ProtoBinning{ - Acts::binZ, Acts::AxisBoundaryType::Bound, -480., 480., 14u, 1u}, - Acts::Experimental::ProtoBinning( - Acts::binPhi, Acts::AxisBoundaryType::Closed, -M_PI, M_PI, 32u, 1u)}; + Acts::Experimental::ProtoBinning{Acts::BinningValue::binZ, + Acts::AxisBoundaryType::Bound, -480., + 480., 14u, 1u}, + Acts::Experimental::ProtoBinning(Acts::BinningValue::binPhi, + Acts::AxisBoundaryType::Closed, -M_PI, + M_PI, 32u, 1u)}; auto barrelBuilder = std::make_shared( diff --git a/Tests/UnitTests/Plugins/Json/EqualityHelpers.hpp b/Tests/UnitTests/Plugins/Json/EqualityHelpers.hpp index 44a6499fdd0..546ba6d8be7 100644 --- a/Tests/UnitTests/Plugins/Json/EqualityHelpers.hpp +++ b/Tests/UnitTests/Plugins/Json/EqualityHelpers.hpp @@ -91,7 +91,7 @@ inline static bool isEqual(const Acts::Extent& ea, const Acts::Extent& eb, Acts::ActsScalar tolerance = 0.) { bool equalConstrains = true; bool equalRange = true; - for (auto& bVal : s_binningValues) { + for (auto& bVal : allBinningValues()) { equalConstrains = equalConstrains && (ea.constrains(bVal) == eb.constrains(bVal)); BOOST_CHECK(equalConstrains); diff --git a/Tests/UnitTests/Plugins/Json/ExtentJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/ExtentJsonConverterTests.cpp index 914dc29099e..f8e943c66c3 100644 --- a/Tests/UnitTests/Plugins/Json/ExtentJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/ExtentJsonConverterTests.cpp @@ -22,18 +22,24 @@ BOOST_AUTO_TEST_SUITE(ExtentJsonConverter) BOOST_AUTO_TEST_CASE(ExtentRoundtripTests) { Extent e; - e.set(binR, 0, 200); - e.set(binZ, -50, 50); + e.set(BinningValue::binR, 0, 200); + e.set(BinningValue::binZ, -50, 50); nlohmann::json j; j["extent"] = e; + std::cout << j.dump(2) << std::endl; + Extent eIn = j["extent"]; - CHECK_CLOSE_ABS(eIn.min(binR), e.min(binR), 10e-5); - CHECK_CLOSE_ABS(eIn.max(binR), e.max(binR), 10e-5); - CHECK_CLOSE_ABS(eIn.min(binZ), e.min(binZ), 10e-5); - CHECK_CLOSE_ABS(eIn.max(binZ), e.max(binZ), 10e-5); + CHECK_CLOSE_ABS(eIn.min(BinningValue::binR), e.min(BinningValue::binR), + 10e-5); + CHECK_CLOSE_ABS(eIn.max(BinningValue::binR), e.max(BinningValue::binR), + 10e-5); + CHECK_CLOSE_ABS(eIn.min(BinningValue::binZ), e.min(BinningValue::binZ), + 10e-5); + CHECK_CLOSE_ABS(eIn.max(BinningValue::binZ), e.max(BinningValue::binZ), + 10e-5); } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp index 0cf3c030368..07a92711ebf 100644 --- a/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/GridJsonConverterTests.cpp @@ -361,12 +361,12 @@ void checkGlobalSubspaceTuple(const SubspactTuple& sstuple) { BOOST_AUTO_TEST_CASE(GlobalSubSpaceTests1D) { // One dimensional sub spaces - const std::tuple, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace> + const std::tuple, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace> sspace1D; // Check the tuple for 1D @@ -375,16 +375,26 @@ BOOST_AUTO_TEST_CASE(GlobalSubSpaceTests1D) { BOOST_AUTO_TEST_CASE(GlobalSubSpaceTests2D) { // Two dimensional sub spaces - const std::tuple, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace, - Acts::GridAccess::GlobalSubspace> + const std::tuple, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace, + Acts::GridAccess::GlobalSubspace> sspace2D = {}; // Check the tuple for 2D diff --git a/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp index cbef8dafbce..2a755ef8dad 100644 --- a/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/MaterialJsonConverterTests.cpp @@ -53,10 +53,11 @@ BOOST_AUTO_TEST_CASE(IndexedSurfaceMaterial1DTests) { bToX.connect<&Acts::GridAccess::LocalSubspace<0u>::toGridLocal>( std::move(localX)); - auto globalX = - std::make_unique>(); + auto globalX = std::make_unique< + const Acts::GridAccess::GlobalSubspace>(); Acts::IndexedSurfaceMaterial::GlobalToGridLocalDelegate gToX; - gToX.connect<&Acts::GridAccess::GlobalSubspace::toGridLocal>( + gToX.connect< + &Acts::GridAccess::GlobalSubspace::toGridLocal>( std::move(globalX)); Acts::IndexedSurfaceMaterial ism( @@ -127,11 +128,11 @@ BOOST_AUTO_TEST_CASE(IndexedSurfaceMaterial2DTests) { std::move(boundToGrid)); // With z shift 10 - auto globalToGrid = std::make_unique< - const Acts::GridAccess::GlobalSubspace>(); + auto globalToGrid = std::make_unique>(); Acts::IndexedSurfaceMaterial::GlobalToGridLocalDelegate gToZphi; - gToZphi.connect< - &Acts::GridAccess::GlobalSubspace::toGridLocal>( + gToZphi.connect<&Acts::GridAccess::GlobalSubspace< + Acts::BinningValue::binZ, Acts::BinningValue::binPhi>::toGridLocal>( std::move(globalToGrid)); // Create the indexed material grid diff --git a/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp index b9405d7e0f4..7bc829a1c88 100644 --- a/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/PortalJsonConverterTests.cpp @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(PortalMultiConnected) { Acts::Experimental::detail::PortalHelper::attachDetectorVolumesUpdater( tContext, *portal, {forwardVolumeA, forwardVolumeB, forwardVolumeC}, - Acts::Direction::Forward, {-100, 10, 20, 200}, Acts::binX); + Acts::Direction::Forward, {-100, 10, 20, 200}, Acts::BinningValue::binX); std::vector detectorVolumes = { forwardVolumeA.get(), forwardVolumeB.get(), forwardVolumeC.get(), diff --git a/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp index 5b7daaea467..f728f900542 100644 --- a/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/ProtoDetectorJsonConverterTests.cpp @@ -115,65 +115,67 @@ bool isEqual(const Acts::ProtoVolume& one, const Acts::ProtoVolume& two, BOOST_AUTO_TEST_SUITE(ProtoDetectorJsonConverter) BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { - Acts::ExtentEnvelope cylinderLayerEnvelope = zeroEnvelopes; - cylinderLayerEnvelope[Acts::binR] = {1., 1.}; - cylinderLayerEnvelope[Acts::binZ] = {2., 2.}; + Acts::ExtentEnvelope cylinderLayerEnvelope = ExtentEnvelope::Zero(); + cylinderLayerEnvelope[Acts::BinningValue::binR] = {1., 1.}; + cylinderLayerEnvelope[Acts::BinningValue::binZ] = {2., 2.}; - Acts::ExtentEnvelope discLayerEnvelope = zeroEnvelopes; - discLayerEnvelope[Acts::binR] = {1., 1.}; - discLayerEnvelope[Acts::binZ] = {1., 1.}; + Acts::ExtentEnvelope discLayerEnvelope = ExtentEnvelope::Zero(); + discLayerEnvelope[Acts::BinningValue::binR] = {1., 1.}; + discLayerEnvelope[Acts::BinningValue::binZ] = {1., 1.}; // Beam Pipe container Acts::ProtoVolume beamPipeContainer; beamPipeContainer.name = "odd-beam-pipe"; - beamPipeContainer.extent.set(Acts::binR, 0., 25); + beamPipeContainer.extent.set(Acts::BinningValue::binR, 0., 25); Acts::ProtoVolume beamPipe; beamPipe.name = "odd-beam-pipe-l"; - beamPipe.extent.set(Acts::binR, 2., 24.); + beamPipe.extent.set(Acts::BinningValue::binR, 2., 24.); beamPipe.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; beamPipeContainer.container = Acts::ProtoVolume::ContainerStructure{ - {beamPipe}, {Acts::BinningData(Acts::open, Acts::binR, {0., 1.})}, true}; + {beamPipe}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1.})}, + true}; // Pixel section Acts::ProtoVolume pixelContainer; pixelContainer.name = "odd-pixel"; - pixelContainer.extent.set(Acts::binR, 25., 200); + pixelContainer.extent.set(Acts::BinningValue::binR, 25., 200); Acts::ProtoVolume pixelNec; pixelNec.name = "odd-pixel-nec"; - pixelNec.extent.set(Acts::binZ, -3100., -580); + pixelNec.extent.set(Acts::BinningValue::binZ, -3100., -580); Acts::ProtoVolume pixNecD6; pixNecD6.name = "odd-pixel-nec-d6"; - pixNecD6.extent.set(Acts::binZ, -1540., -1500); + pixNecD6.extent.set(Acts::BinningValue::binZ, -1540., -1500); Acts::ProtoVolume pixNecD5; pixNecD5.name = "odd-pixel-nec-d5"; - pixNecD5.extent.set(Acts::binZ, -1340., -1300); + pixNecD5.extent.set(Acts::BinningValue::binZ, -1340., -1300); Acts::ProtoVolume pixNecD4; pixNecD4.name = "odd-pixel-nec-d4"; - pixNecD4.extent.set(Acts::binZ, -1140., -1100); + pixNecD4.extent.set(Acts::BinningValue::binZ, -1140., -1100); Acts::ProtoVolume pixNecD3; pixNecD3.name = "odd-pixel-nec-d3"; - pixNecD3.extent.set(Acts::binZ, -1000., -960.); + pixNecD3.extent.set(Acts::BinningValue::binZ, -1000., -960.); Acts::ProtoVolume pixNecD2; pixNecD2.name = "odd-pixel-nec-d2"; - pixNecD2.extent.set(Acts::binZ, -860., -820); + pixNecD2.extent.set(Acts::BinningValue::binZ, -860., -820); Acts::ProtoVolume pixNecD1; pixNecD1.name = "odd-pixel-nec-d1"; - pixNecD1.extent.set(Acts::binZ, -740., -700); + pixNecD1.extent.set(Acts::BinningValue::binZ, -740., -700); Acts::ProtoVolume pixNecD0; pixNecD0.name = "odd-pixel-nec-d0"; - pixNecD0.extent.set(Acts::binZ, -640., -600); + pixNecD0.extent.set(Acts::BinningValue::binZ, -640., -600); pixelNec.container = Acts::ProtoVolume::ContainerStructure{ {pixNecD6, pixNecD5, pixNecD4, pixNecD3, pixNecD2, pixNecD1, pixNecD0}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1.})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1.})}, true}; Acts::BinningData pixEcBinningR = - Acts::BinningData(Acts::open, Acts::binR, 2., 0., 1.); - Acts::BinningData pixEcBinningPhi = - Acts::BinningData(Acts::closed, Acts::binPhi, 30., -M_PI, M_PI); + Acts::BinningData(Acts::open, Acts::BinningValue::binR, 2., 0., 1.); + Acts::BinningData pixEcBinningPhi = Acts::BinningData( + Acts::closed, Acts::BinningValue::binPhi, 30., -M_PI, M_PI); for (auto& cv : pixelNec.container.value().constituentVolumes) { cv.extent.setEnvelope(discLayerEnvelope); @@ -183,28 +185,28 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::ProtoVolume pixelBarrel; pixelBarrel.name = "odd-pixel-barrel"; - pixelBarrel.extent.set(Acts::binZ, -580., 580); + pixelBarrel.extent.set(Acts::BinningValue::binZ, -580., 580); Acts::ProtoVolume pixBarrelL0; pixBarrelL0.name = "odd-pixel-barrel-l0"; - pixBarrelL0.extent.set(Acts::binR, 28., 48.); - pixBarrelL0.extent.set(Acts::binZ, -580., 580); + pixBarrelL0.extent.set(Acts::BinningValue::binR, 28., 48.); + pixBarrelL0.extent.set(Acts::BinningValue::binZ, -580., 580); Acts::ProtoVolume pixBarrelL1; pixBarrelL1.name = "odd-pixel-barrel-l1"; - pixBarrelL1.extent.set(Acts::binR, 62., 76); - pixBarrelL1.extent.set(Acts::binZ, -580., 580); + pixBarrelL1.extent.set(Acts::BinningValue::binR, 62., 76); + pixBarrelL1.extent.set(Acts::BinningValue::binZ, -580., 580); Acts::ProtoVolume pixBarrelL2; pixBarrelL2.name = "odd-pixel-barrel-l2"; - pixBarrelL2.extent.set(Acts::binR, 100., 120.); - pixBarrelL2.extent.set(Acts::binZ, -580., 580); + pixBarrelL2.extent.set(Acts::BinningValue::binR, 100., 120.); + pixBarrelL2.extent.set(Acts::BinningValue::binZ, -580., 580); Acts::ProtoVolume pixBarrelL3; pixBarrelL3.name = "odd-pixel-barrel-l3"; - pixBarrelL3.extent.set(Acts::binR, 160., 180.); - pixBarrelL3.extent.set(Acts::binZ, -580., 580); + pixBarrelL3.extent.set(Acts::BinningValue::binR, 160., 180.); + pixBarrelL3.extent.set(Acts::BinningValue::binZ, -580., 580); pixelBarrel.container = Acts::ProtoVolume::ContainerStructure{ {pixBarrelL0, pixBarrelL1, pixBarrelL2, pixBarrelL3}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1})}, true}; for (auto& cv : pixelBarrel.container.value().constituentVolumes) { @@ -215,33 +217,33 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::ProtoVolume pixelPec; pixelPec.name = "odd-pixel-pec"; - pixelPec.extent.set(Acts::binZ, 580., 3100.); + pixelPec.extent.set(Acts::BinningValue::binZ, 580., 3100.); Acts::ProtoVolume pixPecD0; pixPecD0.name = "odd-pixel-pec-d0"; - pixPecD0.extent.set(Acts::binZ, 600., 640); + pixPecD0.extent.set(Acts::BinningValue::binZ, 600., 640); Acts::ProtoVolume pixPecD1; pixPecD1.name = "odd-pixel-pec-d1"; - pixPecD1.extent.set(Acts::binZ, 700., 740); + pixPecD1.extent.set(Acts::BinningValue::binZ, 700., 740); Acts::ProtoVolume pixPecD2; pixPecD2.name = "odd-pixel-pec-d2"; - pixPecD2.extent.set(Acts::binZ, 820., 860.); + pixPecD2.extent.set(Acts::BinningValue::binZ, 820., 860.); Acts::ProtoVolume pixPecD3; pixPecD3.name = "odd-pixel-pec-d3"; - pixPecD3.extent.set(Acts::binZ, 960., 1000.); + pixPecD3.extent.set(Acts::BinningValue::binZ, 960., 1000.); Acts::ProtoVolume pixPecD4; pixPecD4.name = "odd-pixel-pec-d4"; - pixPecD4.extent.set(Acts::binZ, 1100., 1140); + pixPecD4.extent.set(Acts::BinningValue::binZ, 1100., 1140); Acts::ProtoVolume pixPecD5; pixPecD5.name = "odd-pixel-pec-d5"; - pixPecD5.extent.set(Acts::binZ, 1300., 1340.); + pixPecD5.extent.set(Acts::BinningValue::binZ, 1300., 1340.); Acts::ProtoVolume pixPecD6; pixPecD6.name = "odd-pixel-pec-d6"; - pixPecD6.extent.set(Acts::binZ, 1500., 1540.); + pixPecD6.extent.set(Acts::BinningValue::binZ, 1500., 1540.); pixelPec.container = Acts::ProtoVolume::ContainerStructure{ {pixPecD0, pixPecD1, pixPecD2, pixPecD3, pixPecD4, pixPecD5, pixPecD6}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}, true}; for (auto& cv : pixelPec.container.value().constituentVolumes) { @@ -252,57 +254,59 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { pixelContainer.container = Acts::ProtoVolume::ContainerStructure{ {pixelNec, pixelBarrel, pixelPec}, - {Acts::BinningData(Acts::open, Acts::binZ, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {-3100., -580., 580., 3100.})}}; // Short Strip section Acts::ProtoVolume pstContainer; pstContainer.name = "odd-pst"; - pstContainer.extent.set(Acts::binR, 200., 210.); + pstContainer.extent.set(Acts::BinningValue::binR, 200., 210.); Acts::ProtoVolume pst; pst.name = "odd-pst-l"; - pst.extent.set(Acts::binR, 201., 209.); + pst.extent.set(Acts::BinningValue::binR, 201., 209.); pst.internal = Acts::ProtoVolume::InternalStructure{ Acts::Surface::SurfaceType::Cylinder}; pstContainer.container = Acts::ProtoVolume::ContainerStructure{ - {pst}, {Acts::BinningData(Acts::open, Acts::binR, {0., 1.})}, true}; + {pst}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1.})}, + true}; // Short Strip section Acts::ProtoVolume sstripContainer; sstripContainer.name = "odd-sstrip"; - sstripContainer.extent.set(Acts::binR, 210., 720); + sstripContainer.extent.set(Acts::BinningValue::binR, 210., 720); Acts::BinningData sstripEcBinningR = - Acts::BinningData(Acts::open, Acts::binR, 3., 0., 1.); - Acts::BinningData sstripEcBinningPhi = - Acts::BinningData(Acts::closed, Acts::binPhi, 42., -M_PI, M_PI); + Acts::BinningData(Acts::open, Acts::BinningValue::binR, 3., 0., 1.); + Acts::BinningData sstripEcBinningPhi = Acts::BinningData( + Acts::closed, Acts::BinningValue::binPhi, 42., -M_PI, M_PI); Acts::ProtoVolume sstripNec; sstripNec.name = "odd-sstrip-nec"; - sstripNec.extent.set(Acts::binZ, -3100., -1200); + sstripNec.extent.set(Acts::BinningValue::binZ, -3100., -1200); Acts::ProtoVolume sstripNecD5; sstripNecD5.name = "odd-sstrip-nec-d5"; - sstripNecD5.extent.set(Acts::binZ, -3000, -2900.); + sstripNecD5.extent.set(Acts::BinningValue::binZ, -3000, -2900.); Acts::ProtoVolume sstripNecD4; sstripNecD4.name = "odd-sstrip-nec-d4"; - sstripNecD4.extent.set(Acts::binZ, -2600., -2500.); + sstripNecD4.extent.set(Acts::BinningValue::binZ, -2600., -2500.); Acts::ProtoVolume sstripNecD3; sstripNecD3.name = "odd-sstrip-nec-d3"; - sstripNecD3.extent.set(Acts::binZ, -2250, -2150.); + sstripNecD3.extent.set(Acts::BinningValue::binZ, -2250, -2150.); Acts::ProtoVolume sstripNecD2; sstripNecD2.name = "odd-sstrip-nec-d2"; - sstripNecD2.extent.set(Acts::binZ, -1900, -1800.); + sstripNecD2.extent.set(Acts::BinningValue::binZ, -1900, -1800.); Acts::ProtoVolume sstripNecD1; sstripNecD1.name = "odd-sstrip-nec-d1"; - sstripNecD1.extent.set(Acts::binZ, -1600., -1500.); + sstripNecD1.extent.set(Acts::BinningValue::binZ, -1600., -1500.); Acts::ProtoVolume sstripNecD0; sstripNecD0.name = "odd-sstrip-nec-d0"; - sstripNecD0.extent.set(Acts::binZ, -1350., -1250.); + sstripNecD0.extent.set(Acts::BinningValue::binZ, -1350., -1250.); sstripNec.container = Acts::ProtoVolume::ContainerStructure{ {sstripNecD5, sstripNecD4, sstripNecD3, sstripNecD2, sstripNecD1, sstripNecD0}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}, true}; for (auto& cv : sstripNec.container.value().constituentVolumes) { @@ -314,24 +318,24 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::ProtoVolume sstripBarrel; sstripBarrel.name = "odd-sstrip-barrel"; - sstripBarrel.extent.set(Acts::binZ, -1200., 1200); + sstripBarrel.extent.set(Acts::BinningValue::binZ, -1200., 1200); Acts::ProtoVolume sstripBarrelL0; sstripBarrelL0.name = "odd-sstrip-barrel-l0"; - sstripBarrelL0.extent.set(Acts::binR, 240., 280.); + sstripBarrelL0.extent.set(Acts::BinningValue::binR, 240., 280.); Acts::ProtoVolume sstripBarrelL1; sstripBarrelL1.name = "odd-sstrip-barrel-l1"; - sstripBarrelL1.extent.set(Acts::binR, 340., 380.); + sstripBarrelL1.extent.set(Acts::BinningValue::binR, 340., 380.); Acts::ProtoVolume sstripBarrelL2; sstripBarrelL2.name = "odd-sstrip-barrel-l2"; - sstripBarrelL2.extent.set(Acts::binR, 480., 520.); + sstripBarrelL2.extent.set(Acts::BinningValue::binR, 480., 520.); Acts::ProtoVolume sstripBarrelL3; sstripBarrelL3.name = "odd-sstrip-barrel-l3"; - sstripBarrelL3.extent.set(Acts::binR, 640., 680.); + sstripBarrelL3.extent.set(Acts::BinningValue::binR, 640., 680.); sstripBarrel.container = Acts::ProtoVolume::ContainerStructure{ {sstripBarrelL0, sstripBarrelL1, sstripBarrelL2, sstripBarrelL3}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1})}, true}; for (auto& cv : sstripBarrel.container.value().constituentVolumes) { @@ -342,31 +346,31 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::ProtoVolume sstripPec; sstripPec.name = "odd-sstrip-pec"; - sstripPec.extent.set(Acts::binZ, 1200., 3100); + sstripPec.extent.set(Acts::BinningValue::binZ, 1200., 3100); Acts::ProtoVolume sstripPecD0; sstripPecD0.name = "odd-sstrip-pec-d0"; - sstripPecD0.extent.set(Acts::binZ, 1250., 1350); + sstripPecD0.extent.set(Acts::BinningValue::binZ, 1250., 1350); Acts::ProtoVolume sstripPecD1; sstripPecD1.name = "odd-sstrip-pec-d1"; - sstripPecD1.extent.set(Acts::binZ, 1500., 1600.); + sstripPecD1.extent.set(Acts::BinningValue::binZ, 1500., 1600.); Acts::ProtoVolume sstripPecD2; sstripPecD2.name = "odd-sstrip-pec-d2"; - sstripPecD2.extent.set(Acts::binZ, 1800., 1900.); + sstripPecD2.extent.set(Acts::BinningValue::binZ, 1800., 1900.); Acts::ProtoVolume sstripPecD3; sstripPecD3.name = "odd-sstrip-pec-d3"; - sstripPecD3.extent.set(Acts::binZ, 2150., 2250.); + sstripPecD3.extent.set(Acts::BinningValue::binZ, 2150., 2250.); Acts::ProtoVolume sstripPecD4; sstripPecD4.name = "odd-sstrip-pec-d4"; - sstripPecD4.extent.set(Acts::binZ, 2500., 2600.); + sstripPecD4.extent.set(Acts::BinningValue::binZ, 2500., 2600.); Acts::ProtoVolume sstripPecD5; sstripPecD5.name = "odd-sstrip-pec-d5"; - sstripPecD5.extent.set(Acts::binZ, 2900., 3000.); + sstripPecD5.extent.set(Acts::BinningValue::binZ, 2900., 3000.); sstripPec.container = Acts::ProtoVolume::ContainerStructure{ {sstripPecD0, sstripPecD1, sstripPecD2, sstripPecD3, sstripPecD4, sstripPecD5}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}, true}; for (auto& cv : sstripPec.container.value().constituentVolumes) { cv.extent.setEnvelope(discLayerEnvelope); @@ -377,40 +381,40 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { sstripContainer.container = Acts::ProtoVolume::ContainerStructure{ {sstripNec, sstripBarrel, sstripPec}, - {Acts::BinningData(Acts::open, Acts::binZ, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {-3100., -1200., 1200., 3100.})}}; // Long Strip section Acts::ProtoVolume lstripContainer; lstripContainer.name = "odd-lstrip"; - lstripContainer.extent.set(Acts::binR, 720, 1100.); + lstripContainer.extent.set(Acts::BinningValue::binR, 720, 1100.); Acts::ProtoVolume lstripNec; lstripNec.name = "odd-lstrip-nec"; - lstripNec.extent.set(Acts::binZ, -3100., -1200); + lstripNec.extent.set(Acts::BinningValue::binZ, -3100., -1200); Acts::ProtoVolume lstripNecD5; lstripNecD5.name = "odd-lstrip-nec-d5"; - lstripNecD5.extent.set(Acts::binZ, -3050, -2900.); + lstripNecD5.extent.set(Acts::BinningValue::binZ, -3050, -2900.); Acts::ProtoVolume lstripNecD4; lstripNecD4.name = "odd-lstrip-nec-d4"; - lstripNecD4.extent.set(Acts::binZ, -2650., -2500.); + lstripNecD4.extent.set(Acts::BinningValue::binZ, -2650., -2500.); Acts::ProtoVolume lstripNecD3; lstripNecD3.name = "odd-lstrip-nec-d3"; - lstripNecD3.extent.set(Acts::binZ, -2300, -2150.); + lstripNecD3.extent.set(Acts::BinningValue::binZ, -2300, -2150.); Acts::ProtoVolume lstripNecD2; lstripNecD2.name = "odd-lstrip-nec-d2"; - lstripNecD2.extent.set(Acts::binZ, -1950, -1800.); + lstripNecD2.extent.set(Acts::BinningValue::binZ, -1950, -1800.); Acts::ProtoVolume lstripNecD1; lstripNecD1.name = "odd-lstrip-nec-d1"; - lstripNecD1.extent.set(Acts::binZ, -1650., -1500.); + lstripNecD1.extent.set(Acts::BinningValue::binZ, -1650., -1500.); Acts::ProtoVolume lstripNecD0; lstripNecD0.name = "odd-lstrip-nec-d0"; - lstripNecD0.extent.set(Acts::binZ, -1400., -1250.); + lstripNecD0.extent.set(Acts::BinningValue::binZ, -1400., -1250.); lstripNec.container = Acts::ProtoVolume::ContainerStructure{ {lstripNecD5, lstripNecD4, lstripNecD3, lstripNecD2, lstripNecD1, lstripNecD0}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}, true}; for (auto& cv : lstripNec.container.value().constituentVolumes) { @@ -421,18 +425,18 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::ProtoVolume lstripBarrel; lstripBarrel.name = "odd-lstrip-barrel"; - lstripBarrel.extent.set(Acts::binZ, -1200., 1200); + lstripBarrel.extent.set(Acts::BinningValue::binZ, -1200., 1200); Acts::ProtoVolume lstripBarrelL0; lstripBarrelL0.name = "odd-lstrip-barrel-l0"; - lstripBarrelL0.extent.set(Acts::binR, 800., 840.); + lstripBarrelL0.extent.set(Acts::BinningValue::binR, 800., 840.); Acts::ProtoVolume lstripBarrelL1; lstripBarrelL1.name = "odd-lstrip-barrel-l1"; - lstripBarrelL1.extent.set(Acts::binR, 1000., 1050.); + lstripBarrelL1.extent.set(Acts::BinningValue::binR, 1000., 1050.); lstripBarrel.container = Acts::ProtoVolume::ContainerStructure{ {lstripBarrelL0, lstripBarrelL1}, - {Acts::BinningData(Acts::open, Acts::binR, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 1})}, true}; for (auto& cv : lstripBarrel.container.value().constituentVolumes) { @@ -443,31 +447,31 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { Acts::ProtoVolume lstripPec; lstripPec.name = "odd-lstrip-pec"; - lstripPec.extent.set(Acts::binZ, 1200., 3100); + lstripPec.extent.set(Acts::BinningValue::binZ, 1200., 3100); Acts::ProtoVolume lstripPecD0; lstripPecD0.name = "odd-lstrip-pec-d0"; - lstripPecD0.extent.set(Acts::binZ, 1250., 1400); + lstripPecD0.extent.set(Acts::BinningValue::binZ, 1250., 1400); Acts::ProtoVolume lstripPecD1; lstripPecD1.name = "odd-lstrip-pec-d1"; - lstripPecD1.extent.set(Acts::binZ, 1500., 1650.); + lstripPecD1.extent.set(Acts::BinningValue::binZ, 1500., 1650.); Acts::ProtoVolume lstripPecD2; lstripPecD2.name = "odd-lstrip-pec-d2"; - lstripPecD2.extent.set(Acts::binZ, 1800., 1950.); + lstripPecD2.extent.set(Acts::BinningValue::binZ, 1800., 1950.); Acts::ProtoVolume lstripPecD3; lstripPecD3.name = "odd-lstrip-pec-d3"; - lstripPecD3.extent.set(Acts::binZ, 2150., 2300.); + lstripPecD3.extent.set(Acts::BinningValue::binZ, 2150., 2300.); Acts::ProtoVolume lstripPecD4; lstripPecD4.name = "odd-lstrip-pec-d4"; - lstripPecD4.extent.set(Acts::binZ, 2500., 2650.); + lstripPecD4.extent.set(Acts::BinningValue::binZ, 2500., 2650.); Acts::ProtoVolume lstripPecD5; lstripPecD5.name = "odd-lstrip-pec-d5"; - lstripPecD5.extent.set(Acts::binZ, 2900., 3050.); + lstripPecD5.extent.set(Acts::BinningValue::binZ, 2900., 3050.); lstripPec.container = Acts::ProtoVolume::ContainerStructure{ {lstripPecD0, lstripPecD1, lstripPecD2, lstripPecD3, lstripPecD4, lstripPecD5}, - {Acts::BinningData(Acts::open, Acts::binZ, {0., 1})}, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {0., 1})}, true}; for (auto& cv : lstripPec.container.value().constituentVolumes) { cv.internal = @@ -476,18 +480,18 @@ BOOST_AUTO_TEST_CASE(ProtoDetectorRoundTrip) { } lstripContainer.container = Acts::ProtoVolume::ContainerStructure{ {lstripNec, lstripBarrel, lstripPec}, - {Acts::BinningData(Acts::open, Acts::binZ, + {Acts::BinningData(Acts::open, Acts::BinningValue::binZ, {-3100., -1200., 1200., 3100.})}}; // The overall container Acts::ProtoVolume detectorContainer; detectorContainer.name = "odd-light-world"; - detectorContainer.extent.set(Acts::binR, 0., 1100.); - detectorContainer.extent.set(Acts::binZ, -3100., 3100.); + detectorContainer.extent.set(Acts::BinningValue::binR, 0., 1100.); + detectorContainer.extent.set(Acts::BinningValue::binZ, -3100., 3100.); detectorContainer.container = Acts::ProtoVolume::ContainerStructure{ {beamPipeContainer, pixelContainer, pstContainer, sstripContainer, lstripContainer}, - {Acts::BinningData(Acts::open, Acts::binR, + {Acts::BinningData(Acts::open, Acts::BinningValue::binR, {0., 25., 200., 210., 720., 1100.})}}; // ---------------------------------------------------------- diff --git a/Tests/UnitTests/Plugins/Json/SurfaceJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/SurfaceJsonConverterTests.cpp index 44a530cd4f8..44c8b3470f9 100644 --- a/Tests/UnitTests/Plugins/Json/SurfaceJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/SurfaceJsonConverterTests.cpp @@ -34,9 +34,11 @@ using namespace Acts; +namespace { std::ofstream out; Acts::GeometryContext gctx; +} // namespace BOOST_AUTO_TEST_SUITE(SurfaceJsonConversion) diff --git a/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp b/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp index a2b0e56ea68..8a5b1c9c533 100644 --- a/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp +++ b/Tests/UnitTests/Plugins/Json/UtilitiesJsonConverterTests.cpp @@ -30,7 +30,7 @@ using namespace Acts; BOOST_AUTO_TEST_SUITE(UtilitiesJsonConverter) BOOST_AUTO_TEST_CASE(BinUtilityRoundTripTests) { - BinUtility reference(2, 0., 4., open, binR); + BinUtility reference(2, 0., 4., open, BinningValue::binR); std::ofstream out; @@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(BinUtilityRoundTripTests) { BOOST_CHECK(isEqual(reference, test, 0.0001)); // Increase to two dimensions - reference += BinUtility(10., -M_PI, M_PI, closed, binPhi); + reference += BinUtility(10., -M_PI, M_PI, closed, BinningValue::binPhi); nlohmann::json jtwoDimOut; to_json(jtwoDimOut, reference); out.open("BinUtility_2D.json"); @@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(BinUtilityRoundTripTests) { // Increase to three dimensions std::vector boundaries = {-4., -1.5, 0., 10.}; - reference += BinUtility(boundaries, open, binZ); + reference += BinUtility(boundaries, open, BinningValue::binZ); nlohmann::json jthreeDimOut; to_json(jthreeDimOut, reference); out.open("BinUtility_3D.json"); diff --git a/Tests/UnitTests/Plugins/TGeo/TGeoLayerBuilderTests.cpp b/Tests/UnitTests/Plugins/TGeo/TGeoLayerBuilderTests.cpp index 7adf9b986d0..3c00279d813 100644 --- a/Tests/UnitTests/Plugins/TGeo/TGeoLayerBuilderTests.cpp +++ b/Tests/UnitTests/Plugins/TGeo/TGeoLayerBuilderTests.cpp @@ -56,7 +56,8 @@ BOOST_AUTO_TEST_CASE(TGeoLayerBuilderTests) { b0Config.sensorNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5", "PixelActiveo6"}; b0Config.localAxes = "XYZ"; - b0Config.parseRanges = {{binR, {0., 40_mm}}, {binZ, {-60_mm, 15_mm}}}; + b0Config.parseRanges = {{BinningValue::binR, {0., 40_mm}}, + {BinningValue::binZ, {-60_mm, 15_mm}}}; b0Config.envelope = {0_mm, 0_mm}; TglConfig eAllConfig; @@ -64,8 +65,9 @@ BOOST_AUTO_TEST_CASE(TGeoLayerBuilderTests) { eAllConfig.sensorNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5", "PixelActiveo6"}; eAllConfig.localAxes = "XYZ"; - eAllConfig.parseRanges = {{binR, {0., 40_mm}}, {binZ, {16_mm, 60_mm}}}; - eAllConfig.splitConfigs = {{binZ, 5_mm}}; + eAllConfig.parseRanges = {{BinningValue::binR, {0., 40_mm}}, + {BinningValue::binZ, {16_mm, 60_mm}}}; + eAllConfig.splitConfigs = {{BinningValue::binZ, 5_mm}}; eAllConfig.envelope = {0_mm, 0_mm}; std::vector cConfigs = {b0Config}; diff --git a/Tests/UnitTests/Plugins/TGeo/TGeoParserTests.cpp b/Tests/UnitTests/Plugins/TGeo/TGeoParserTests.cpp index b2acbae4871..e91fe6413de 100644 --- a/Tests/UnitTests/Plugins/TGeo/TGeoParserTests.cpp +++ b/Tests/UnitTests/Plugins/TGeo/TGeoParserTests.cpp @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE(TGeoParser_Pixel_SelectInnermost) { tgpOptions.volumeNames = {volumeName}; tgpOptions.targetNames = {"PixelActiveo2", "PixelActiveo4", "PixelActiveo5", "PixelActiveo6"}; - tgpOptions.parseRanges.push_back({binR, {0., 40.}}); - tgpOptions.parseRanges.push_back({binZ, {-60., 15.}}); + tgpOptions.parseRanges.push_back({BinningValue::binR, {0., 40.}}); + tgpOptions.parseRanges.push_back({BinningValue::binZ, {-60., 15.}}); tgpOptions.unit = 10.; std::string axes = "XYZ"; diff --git a/docs/examples/howto/figures/gsf_debugger/gsf_debugger_0.jpg b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_0.jpg new file mode 100644 index 00000000000..e0070a5ceec Binary files /dev/null and b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_0.jpg differ diff --git a/docs/examples/howto/figures/gsf_debugger/gsf_debugger_1.jpg b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_1.jpg new file mode 100644 index 00000000000..1b03b1179b3 Binary files /dev/null and b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_1.jpg differ diff --git a/docs/examples/howto/figures/gsf_debugger/gsf_debugger_2.jpg b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_2.jpg new file mode 100644 index 00000000000..d4ec0193a72 Binary files /dev/null and b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_2.jpg differ diff --git a/docs/examples/howto/figures/gsf_debugger/gsf_debugger_4.jpg b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_4.jpg new file mode 100644 index 00000000000..4bf8396d2ae Binary files /dev/null and b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_4.jpg differ diff --git a/docs/examples/howto/figures/gsf_debugger/gsf_debugger_5.jpg b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_5.jpg new file mode 100644 index 00000000000..d2fb2a51703 Binary files /dev/null and b/docs/examples/howto/figures/gsf_debugger/gsf_debugger_5.jpg differ diff --git a/docs/examples/howto/gsf_debugger.md b/docs/examples/howto/gsf_debugger.md new file mode 100644 index 00000000000..fa040dde841 --- /dev/null +++ b/docs/examples/howto/gsf_debugger.md @@ -0,0 +1,30 @@ +# GSF Debugger + +Python utility to visualize the `VERBOSE` log of a GSF track in ACTS. In general, the infrastructure could be used to also display tracks of other fitters with little adjustments. + +## Usage + +In order to run, the utility requires a logfile and a geometry description as CSV file (this can be produced using the CSV geometry writer in the examples framework): + +```bash +python3 acts/Examples/Scripts/GsfDebugger/src/main.py --logfile --detector +``` + +Alternatively, it can also used via piping: +```bash +./my_gsf_script.py | acts/Examples/Scripts/GsfDebugger/src/main.py --detector +``` + +## Screenshots + +This section shows some screenshots of the provided views: + +![gsf_debugger_0](figures/gsf_debugger/gsf_debugger_0.jpg) + +![gsf_debugger_1](figures/gsf_debugger/gsf_debugger_1.jpg) + +![gsf_debugger_2](figures/gsf_debugger/gsf_debugger_2.jpg) + +![gsf_debugger_4](figures/gsf_debugger/gsf_debugger_4.jpg) + +![gsf_debugger_5](figures/gsf_debugger/gsf_debugger_5.jpg) diff --git a/docs/examples/howto/howto.md b/docs/examples/howto/howto.md index 4da7277e3cd..8006ca1aca5 100644 --- a/docs/examples/howto/howto.md +++ b/docs/examples/howto/howto.md @@ -7,4 +7,5 @@ analysis_apps material_mapping run_ckf_auto_tuning digitization_config +gsf_debugger ::: diff --git a/docs/getting_started.md b/docs/getting_started.md index 56cb3100f3f..a840e1a67e5 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -124,10 +124,13 @@ A set of container images is available through the [ACTS container registry][acts_containers]. The following containers are used as part of the continuous integration setup and come with all dependencies pre-installed. -- `centos7-lcg101-gcc11`: based on CentOS 7 with HEP-specific software from - LCG 101 using the GCC 11 compiler -- `ubuntu2204`: based on Ubuntu 22.04 with manual installation of HEP-specific - software +- `ubuntu2204` +- `ubuntu2404` + +Furthermore, we are also testing on, but do not provide the corresponding containers: + +- `alma9` (HEP-specific software from LCG 104 or 105 and gcc13 or clang16) +- `macOS-10.15` :::{attention} We stopped producing fully-contained LCG containers in favor of running LCG @@ -141,13 +144,13 @@ available tags, e.g. for the `ubuntu2004` image, you can use the following command: ```console -$ docker search --list-tags ghcr.io/acts-project/ubuntu2004 +$ docker search --list-tags ghcr.io/acts-project/ubuntu2404 ``` -The following command then downloads a stable tag of the `ubuntu2004` image: +The following command then downloads a stable tag of the `ubuntu2404` image: ```console -$ docker pull ghcr.io/acts-project/ubuntu2004:v9 +$ docker pull ghcr.io/acts-project/ubuntu2404:51 ``` This should print the image id as part of the output. You can also find out the diff --git a/thirdparty/FRNN/CMakeLists.txt.in b/thirdparty/FRNN/CMakeLists.txt.in index 131fd3c4b82..b321e0d0415 100644 --- a/thirdparty/FRNN/CMakeLists.txt.in +++ b/thirdparty/FRNN/CMakeLists.txt.in @@ -31,7 +31,6 @@ target_include_directories(frnn SYSTEM PUBLIC ${TORCH_INCLUDE_DIRS} $ - $ ) target_link_libraries(frnn PRIVATE ${TORCH_LIBRARIES})