Skip to content

Commit

Permalink
Merge branch 'main' into ex-remove-surfacesortingalg
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 6, 2024
2 parents 312a639 + 03315f8 commit 1af5fef
Show file tree
Hide file tree
Showing 27 changed files with 176 additions and 170 deletions.
81 changes: 3 additions & 78 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,51 +38,6 @@ jobs:
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure

license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
sudo apt-get install -y git
&& CI/check_license.py . --exclude "*thirdparty/*"
include_guards:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
CI/check_include_guards.py . --fail-global --exclude "*thirdparty/*"
pragma_once:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check
run: >
CI/check_pragma_once.sh
type_t:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
CI/check_type_t.py . --exclude "thirdparty/*"
boost_test_macro:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check
run: >
CI/check_boost_test_macro.sh
smearing_config:
runs-on: ubuntu-latest
steps:
Expand All @@ -93,39 +48,7 @@ jobs:
- name: Check
run: >
CI/check_smearing_config.py .
cmake_options:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Check
run: >
docs/parse_cmake_options.py CMakeLists.txt --write docs/getting_started.md --verify
spelling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install codespell
run: >
pip install codespell==2.2.5
- 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 All @@ -136,6 +59,7 @@ jobs:
- name: Check
run: >
CI/missing_include_check.sh
fpe_masks:
runs-on: ubuntu-latest
steps:
Expand All @@ -149,6 +73,7 @@ jobs:
- name: Check
run: >
CI/check_fpe_masks.py --token ${{ secrets.GITHUB_TOKEN }}
unused_files:
runs-on: ubuntu-latest
steps:
Expand Down
67 changes: 40 additions & 27 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,33 +142,46 @@ build_exatrkx:
- cmake --build build -- -j6
- ccache -s

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

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

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

build_linux_ubuntu:
stage: build
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ repos:
- id: codespell
args: [
"-S", "*.ipynb,*.onnx,_build,*.svg",
"-I", "./CI/codespell_ignore.txt"
"-I", "./CI/codespell_ignore.txt",
"-w"
]
exclude: ^CI/.*$

Expand Down
2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_trackfinding_1muon.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run_ckf_tracking(label, seeding):
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
hits=(9, None),
removeNeutral=True,
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
rnd=rnd,
postSelectParticles=ParticleSelectorConfig(
pt=(0.9 * u.GeV, None),
measurements=(9, None),
hits=(9, None),
removeNeutral=True,
),
)
Expand Down
2 changes: 1 addition & 1 deletion CI/physmon/workflows/physmon_trackfinding_ttbar_pu200.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
),
postSelectParticles=ParticleSelectorConfig(
pt=(0.5 * u.GeV, None),
measurements=(9, None),
hits=(9, None),
removeNeutral=True,
),
)
Expand Down
1 change: 1 addition & 0 deletions Examples/Algorithms/TrackFindingExaTrkX/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ add_library(
src/PrototracksToParameters.cpp
src/TrackFindingFromPrototrackAlgorithm.cpp
src/TruthGraphBuilder.cpp
src/createFeatures.cpp
)

target_include_directories(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@

#include "ActsExamples/TruthTracking/ParticleSelector.hpp"

#include "Acts/Definitions/Common.hpp"
#include "Acts/Utilities/VectorHelpers.hpp"
#include "ActsExamples/EventData/Index.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/Framework/AlgorithmContext.hpp"

#include <ostream>
#include <stdexcept>
#include <utility>

ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
Acts::Logging::Level level)
namespace ActsExamples {

ParticleSelector::ParticleSelector(const Config& config,
Acts::Logging::Level level)
: IAlgorithm("ParticleSelector", level), m_cfg(config) {
if (m_cfg.inputParticles.empty()) {
throw std::invalid_argument("Missing input particles collection");
Expand All @@ -28,8 +30,17 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
}

m_inputParticles.initialize(m_cfg.inputParticles);
m_inputParticleMeasurementsMap.maybeInitialize(
m_cfg.inputParticleMeasurementsMap);
m_outputParticles.initialize(m_cfg.outputParticles);

if (!m_inputParticleMeasurementsMap.isInitialized() &&
(m_cfg.measurementsMin > 0 ||
m_cfg.measurementsMax < std::numeric_limits<std::size_t>::max())) {
throw std::invalid_argument(
"Measurement-based cuts require the inputMeasurementParticlesMap");
}

ACTS_DEBUG("selection particle rho [" << m_cfg.rhoMin << "," << m_cfg.rhoMax
<< ")");
ACTS_DEBUG("selection particle |z| [" << m_cfg.absZMin << "," << m_cfg.absZMax
Expand All @@ -46,6 +57,8 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
<< ")");
ACTS_DEBUG("selection particle m [" << m_cfg.mMin << "," << m_cfg.mMax
<< ")");
ACTS_DEBUG("selection particle hits [" << m_cfg.hitsMin << ","
<< m_cfg.hitsMax << ")");
ACTS_DEBUG("selection particle measurements ["
<< m_cfg.measurementsMin << "," << m_cfg.measurementsMax << ")");
ACTS_DEBUG("remove charged particles " << m_cfg.removeCharged);
Expand All @@ -59,12 +72,18 @@ ActsExamples::ParticleSelector::ParticleSelector(const Config& config,
<< m_cfg.maxPrimaryVertexId << ")");
}

ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
const AlgorithmContext& ctx) const {
ProcessCode ParticleSelector::execute(const AlgorithmContext& ctx) const {
// prepare input/ output types
const SimParticleContainer& inputParticles = m_inputParticles(ctx);

const static InverseMultimap<SimBarcode> emptyMeasurementParticlesMap;
const InverseMultimap<SimBarcode>& inputMeasurementParticlesMap =
m_inputParticleMeasurementsMap.isInitialized()
? m_inputParticleMeasurementsMap(ctx)
: emptyMeasurementParticlesMap;

std::size_t nInvalidCharge = 0;
std::size_t nInvalidHitCount = 0;
std::size_t nInvalidMeasurementCount = 0;

// helper functions to select tracks
Expand All @@ -87,9 +106,14 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(

nInvalidCharge += static_cast<std::size_t>(!validCharge);

bool validMeasurementCount =
within(p.numberOfHits(), m_cfg.measurementsMin, m_cfg.measurementsMax);
const bool validHitCount =
within(p.numberOfHits(), m_cfg.hitsMin, m_cfg.hitsMax);
nInvalidHitCount += static_cast<std::size_t>(!validHitCount);

const std::size_t measurementCount =
inputMeasurementParticlesMap.count(p.particleId());
const bool validMeasurementCount =
within(measurementCount, m_cfg.measurementsMin, m_cfg.measurementsMax);
nInvalidMeasurementCount +=
static_cast<std::size_t>(!validMeasurementCount);

Expand All @@ -103,7 +127,7 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
}

return validPdg && validCharge && validSecondary && validPrimaryVertexId &&
validMeasurementCount &&
validHitCount && validMeasurementCount &&
within(p.transverseMomentum(), m_cfg.ptMin, m_cfg.ptMax) &&
within(std::abs(eta), m_cfg.absEtaMin, m_cfg.absEtaMax) &&
within(eta, m_cfg.etaMin, m_cfg.etaMax) &&
Expand Down Expand Up @@ -132,10 +156,13 @@ ActsExamples::ProcessCode ActsExamples::ParticleSelector::execute(
<< outputParticles.size() << " from "
<< inputParticles.size() << " particles");
ACTS_DEBUG("filtered out because of charge: " << nInvalidCharge);
ACTS_DEBUG("filtered out because of hit count: " << nInvalidHitCount);
ACTS_DEBUG("filtered out because of measurement count: "
<< nInvalidMeasurementCount);

m_outputParticles(ctx, std::move(outputParticles));

return ProcessCode::SUCCESS;
}

} // namespace ActsExamples
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/EventData/Index.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/IAlgorithm.hpp"
Expand All @@ -26,6 +27,9 @@ class ParticleSelector final : public IAlgorithm {
struct Config {
/// The input particles collection.
std::string inputParticles;
/// (Optionally) The input particle measurements map. Only required for
/// measurement-based cuts.
std::string inputParticleMeasurementsMap;
/// The output particles collection.
std::string outputParticles;

Expand All @@ -51,7 +55,10 @@ class ParticleSelector final : public IAlgorithm {
// Rest mass cuts
double mMin = 0;
double mMax = std::numeric_limits<double>::infinity();
/// Measurement number cuts
// Hit count cuts
std::size_t hitsMin = 0;
std::size_t hitsMax = std::numeric_limits<std::size_t>::max();
// Measurement number cuts
std::size_t measurementsMin = 0;
std::size_t measurementsMax = std::numeric_limits<std::size_t>::max();
/// Remove charged particles.
Expand Down Expand Up @@ -81,6 +88,8 @@ class ParticleSelector final : public IAlgorithm {
Config m_cfg;

ReadDataHandle<SimParticleContainer> m_inputParticles{this, "InputParticles"};
ReadDataHandle<InverseMultimap<SimBarcode>> m_inputParticleMeasurementsMap{
this, "InputParticleMeasurementsMap"};

WriteDataHandle<SimParticleContainer> m_outputParticles{this,
"OutputParticles"};
Expand Down
Loading

0 comments on commit 1af5fef

Please sign in to comment.