Skip to content

Commit

Permalink
Merge branch 'main' into refactor/gen3-hierarchy-search
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 18, 2024
2 parents 5e17512 + 387d0ad commit f017cf7
Show file tree
Hide file tree
Showing 325 changed files with 3,310 additions and 2,393 deletions.
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ DO NOT USE @-MENTIONS HERE!
--- END COMMIT MESSAGE ---

Any further description goes here, @-mentions are ok here!

- Use a *conventional commits* prefix: [quick summary](https://www.conventionalcommits.org/en/v1.0.0/#summary)
- We mostly use `feat`, `fix`, `refactor`, `docs`, `chore` and `build` types.
- A milestone will be assigned by one of the maintainers
10 changes: 10 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ jobs:
- name: Check
run: >
CI/check_spelling
math_macros:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
CI/check_math_macros.py . --exclude "thirdparty/*"
missing_includes:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ clang_tidy:
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_C_COMPILER=clang
-DPython_EXECUTABLE=$(which python3)
-DACTS_RUN_CLANG_TIDY=ON
-DACTS_BUILD_ODD=OFF
# Main clang-tidy run during cmake compilation
- CI/clang_tidy/run_clang_tidy.sh clang-tidy build
Expand Down Expand Up @@ -168,7 +166,7 @@ build_exatrkx:
# - git clone $CLONE_URL src
# - cd src
# - git checkout $HEAD_SHA
# - pip3 install -r Examples/Python/tests/requirements_ubuntu2004.txt
# - pip3 install -r Examples/Python/tests/requirements.txt
# - nvidia-smi
# - pytest -rFsv -k test_exatrkx

Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ repos:
name: Leftover conflict markers
language: system
entry: git diff --staged --check

- repo: local
hooks:
- id: math_macros
name: math_macros
language: system
entry: CI/check_math_macros.py
files: \.(cpp|hpp|ipp|cu|cuh)$
6 changes: 5 additions & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@
"affiliation": "CERN / University of Amsterdam",
"name": "Stephen Nicholas Swatman",
"orcid": "0000-0002-3747-3229"
}
},
{
"affiliation": "CERN / TU Wien",
"name": "Felix Russo",
"orcid": "0009-0005-8975-2245"
},
{
"affiliation": "UC Berkeley",
"name": "Carlo Varni"
}
],
"access_right": "open",
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ The following people have contributed to the project (in alphabetical order):
- Andreas Stefl, CERN, TU Wien
- Stephen Nicholas Swatman, CERN, University of Amsterdam
- Roman Urmanov, Weizmann Institute of Science
- Carlo Varni, UC Berkeley
120 changes: 120 additions & 0 deletions CI/check_math_macros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env python3

from pathlib import Path
import os
import argparse
from fnmatch import fnmatch
import re
import sys


math_constants = [
("M_PI", "std::numbers::pi"),
("M_PI_2", "std::numbers::pi / 2."),
("M_PI_4", "std::numbers::pi / 4."),
("M_1_PI", "std::numbers::inv_pi"),
("M_2_PI", "2. * std::numbers::inv_pi"),
("M_2_SQRTPI", "2. * std::numbers::inv_sqrtpi"),
("M_E", "std::numbers::e"),
("M_LOG2E", "std::numbers::log2e"),
("M_LOG10E", "std::numbers::log10e"),
("M_LN2", "std::numbers::ln2"),
("M_LN10", "std::numbers::ln10"),
("M_SQRT2", "std::numbers::sqrt2"),
("M_SQRT1_2", "1. / std::numbers::sqrt2"),
("M_SQRT3", "std::numbers::sqrt3"),
("M_INV_SQRT3", "std::numbers::inv_sqrt3"),
("M_EGAMMA", "std::numbers::egamma"),
("M_PHI", "std::numbers::phi"),
]


github = "GITHUB_ACTIONS" in os.environ


def handle_file(
file: Path, fix: bool, math_const: tuple[str, str]
) -> list[tuple[int, str]]:
ex = re.compile(rf"(?<!\w){math_const[0]}(?!\w)")

content = file.read_text()
lines = content.splitlines()

changed_lines = []

for i, oline in enumerate(lines):
line, n_subs = ex.subn(rf"{math_const[1]}", oline)
lines[i] = line
if n_subs > 0:
changed_lines.append((i, oline))

if fix and len(changed_lines) > 0:
file.write_text("\n".join(lines) + "\n")

return changed_lines


def main():
p = argparse.ArgumentParser()
p.add_argument("input", nargs="+")
p.add_argument("--fix", action="store_true", help="Attempt to fix M_* macros.")
p.add_argument("--exclude", "-e", action="append", default=[])

args = p.parse_args()

exit_code = 0

inputs = []

if len(args.input) == 1 and os.path.isdir(args.input[0]):
# walk over all files
for root, _, files in os.walk(args.input[0]):
root = Path(root)
for filename in files:
# get the full path of the file
filepath = root / filename
if filepath.suffix not in (
".hpp",
".cpp",
".ipp",
".h",
".C",
".c",
".cu",
".cuh",
):
continue

if any([fnmatch(str(filepath), e) for e in args.exclude]):
continue

inputs.append(filepath)
else:
for file in args.input:
inputs.append(Path(file))

for filepath in inputs:
for math_const in math_constants:
changed_lines = handle_file(
file=filepath, fix=args.fix, math_const=math_const
)
if len(changed_lines) > 0:
exit_code = 1
print()
print(filepath)
for i, oline in changed_lines:
print(f"{i}: {oline}")

if github:
print(
f"::error file={filepath},line={i+1},title=Do not use macro {math_const[0]}::Replace {math_const[0]} with std::{math_const[1]}"
)

if exit_code == 1 and github:
print(f"::info You will need in each flagged file #include <numbers>")

return exit_code


if "__main__" == __name__:
sys.exit(main())
5 changes: 5 additions & 0 deletions CI/physmon/config/pythia8_ttbar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ exclude:
- particle
- generation
- sub_particle
- e_loss
- total_x0
- total_l0
- number_of_hits
- outcome
Binary file not shown.
6 changes: 2 additions & 4 deletions CI/physmon/workflows/physmon_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
preSelectParticles=None,
postSelectParticles=ParticleSelectorConfig(removeSecondaries=True),
inputParticles="particles_input",
outputParticlesInitial="particles_initial_fatras",
outputParticlesFinal="particles_final_fatras",
outputParticles="particles_fatras",
outputSimHits="simhits_fatras",
outputDirRoot=tp / "fatras",
)
Expand All @@ -99,8 +98,7 @@
killAfterTime=25 * u.ns,
killSecondaries=True,
inputParticles="particles_input",
outputParticlesInitial="particles_initial_geant4",
outputParticlesFinal="particles_final_geant4",
outputParticles="particles_geant4",
outputSimHits="simhits_geant4",
outputDirRoot=tp / "geant4",
)
Expand Down
3 changes: 3 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ authors:
family-names: Russo
affiliation: CERN / TU Wien
orcid: https://orcid.org/0009-0005-8975-2245
- given-names: Carlo
family-names: Varni
affiliation: UC Berkeley
version: 10.0.0
date-released: 2021-07-28
repository-code: https://github.com/acts-project/acts
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ if(ACTS_SETUP_BOOST)
endif()

if(Boost_VERSION VERSION_EQUAL "1.85.0")
set(_boost_version_severity WARNING)
if(ACTS_BUILD_EXAMPLES)
set(_boost_version_severity FATAL_ERROR)
endif()
message(
WARNING
${_boost_version_severity}
"Boost 1.85.0 is known to be broken (https://github.com/boostorg/container/issues/273). Please use a different version."
)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cstddef>
#include <map>
#include <memory>
#include <numbers>
#include <string>
#include <tuple>
#include <vector>
Expand Down Expand Up @@ -103,8 +104,8 @@ class ScoreBasedAmbiguityResolution {
double pTMin = 0 * UnitConstants::GeV;
double pTMax = 1e5 * UnitConstants::GeV;

double phiMin = -M_PI * UnitConstants::rad;
double phiMax = M_PI * UnitConstants::rad;
double phiMin = -std::numbers::pi * UnitConstants::rad;
double phiMax = std::numbers::pi * UnitConstants::rad;

double etaMin = -5;
double etaMax = 5;
Expand Down
4 changes: 3 additions & 1 deletion Core/include/Acts/Definitions/Units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include <numbers>

namespace Acts {

/// @verbatim embed:rst:leading-slashes
Expand Down Expand Up @@ -170,7 +172,7 @@ constexpr double h = 3600.0 * s;
// Angles, native unit radian
constexpr double mrad = 1e-3;
constexpr double rad = 1.0;
constexpr double degree = 0.017453292519943295; // = M_PI / 180.0 * rad;
constexpr double degree = std::numbers::pi / 180. / rad;
// Energy/mass/momentum, native unit GeV
constexpr double GeV = 1.0;
constexpr double eV = 1e-9 * GeV;
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/ProxyAccessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct ProxyAccessorBase {
/// Create the accessor from a string key
/// @param _key the key
constexpr ProxyAccessorBase(const std::string& _key)
: key{hashString(_key)} {}
: key{hashStringDynamic(_key)} {}

/// Access the stored key on the proxy given as an argument. Mutable version
/// @tparam proxy_t the type of the proxy
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/TrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class TrackContainer {
/// Check if this track container has a specific dynamic column
/// @param key the key to check for
constexpr bool hasColumn(const std::string& key) const {
return m_container->hasColumn_impl(hashString(key));
return m_container->hasColumn_impl(hashStringDynamic(key));
}

/// Check if a this track container has a specific dynamic column
Expand Down
4 changes: 2 additions & 2 deletions Core/include/Acts/EventData/TrackProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class TrackProxy {
constexpr T& component(std::string_view key)
requires(!ReadOnly)
{
return m_container->template component<T>(hashString(key), m_index);
return m_container->template component<T>(hashStringDynamic(key), m_index);
}

/// Retrieve a const reference to a component
Expand Down Expand Up @@ -738,7 +738,7 @@ class TrackProxy {
/// @return Const reference to the component given by @p key
template <typename T>
constexpr const T& component(std::string_view key) const {
return m_container->template component<T>(hashString(key), m_index);
return m_container->template component<T>(hashStringDynamic(key), m_index);
}

/// @}
Expand Down
6 changes: 3 additions & 3 deletions Core/include/Acts/EventData/TrackStateProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ class TrackStateProxy {
/// @note This might hash the @p key at runtime instead of compile-time
/// @return true if the component exists, false if not
constexpr bool has(std::string_view key) const {
return has(hashString(key));
return has(hashStringDynamic(key));
}

/// Retrieve a mutable reference to a component
Expand Down Expand Up @@ -1135,7 +1135,7 @@ class TrackStateProxy {
constexpr T& component(std::string_view key)
requires(!ReadOnly)
{
return m_traj->template component<T>(hashString(key), m_istate);
return m_traj->template component<T>(hashStringDynamic(key), m_istate);
}

/// Retrieve a const reference to a component
Expand Down Expand Up @@ -1163,7 +1163,7 @@ class TrackStateProxy {
/// @return Const reference to the component given by @p key
template <typename T>
constexpr const T& component(std::string_view key) const {
return m_traj->template component<T>(hashString(key), m_istate);
return m_traj->template component<T>(hashStringDynamic(key), m_istate);
}

/// @}
Expand Down
7 changes: 5 additions & 2 deletions Core/include/Acts/EventData/TransformationHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Acts/Utilities/Result.hpp"
#include "Acts/Utilities/detail/periodic.hpp"

#include <numbers>

namespace Acts {

class Surface;
Expand All @@ -25,8 +27,9 @@ class Surface;
/// @return Reflected bound track parameters vector
inline BoundVector reflectBoundParameters(const BoundVector& boundParams) {
BoundVector reflected = boundParams;
auto [phi, theta] = detail::normalizePhiTheta(
boundParams[eBoundPhi] - M_PI, M_PI - boundParams[eBoundTheta]);
auto [phi, theta] =
detail::normalizePhiTheta(boundParams[eBoundPhi] - std::numbers::pi,
std::numbers::pi - boundParams[eBoundTheta]);
reflected[eBoundPhi] = phi;
reflected[eBoundTheta] = theta;
reflected[eBoundQOverP] = -boundParams[eBoundQOverP];
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/VectorMultiTrajectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ class VectorMultiTrajectory final

template <typename T>
void addColumn_impl(std::string_view key) {
HashedString hashedKey = hashString(key);
HashedString hashedKey = hashStringDynamic(key);
m_dynamic.insert({hashedKey, std::make_unique<detail::DynamicColumn<T>>()});
}

Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/VectorTrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class VectorTrackContainer final : public detail_vtc::VectorTrackContainerBase {

template <typename T>
constexpr void addColumn_impl(const std::string_view& key) {
HashedString hashedKey = hashString(key);
HashedString hashedKey = hashStringDynamic(key);
m_dynamic.insert({hashedKey, std::make_unique<detail::DynamicColumn<T>>()});
}

Expand Down
Loading

0 comments on commit f017cf7

Please sign in to comment.