Skip to content

Commit

Permalink
Merge branch 'main' into add-option-initial-step-size
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Mar 3, 2025
2 parents 5604630 + da90577 commit ff2d659
Show file tree
Hide file tree
Showing 203 changed files with 3,793 additions and 48,686 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,3 @@ jobs:
- name: Check
run: >
CI/check_unused_files.py
codegen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: >
pip install -r codegen/requirements.txt
- name: Check
run: >
CI/check_codegen
- uses: actions/upload-artifact@v4
if: failure()
with:
name: changed
path: changed
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,12 @@ repos:
language: system
entry: CI/check_math_macros.py
files: \.(cpp|hpp|ipp|cu|cuh)$

- repo: local
hooks:
- id: codegen_dependencies
name: codegen_dependencies
language: python
entry: CI/check_codegen_dependencies.sh
additional_dependencies: ["uv"]
files: pyproject.toml$
38 changes: 0 additions & 38 deletions CI/check_codegen

This file was deleted.

18 changes: 18 additions & 0 deletions CI/check_codegen_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -e
set -u

PYTHON_VERSION=3.13

input=$1
input_abs=$(realpath "$input")
input_rel=$(basename "$input_abs")
dir=$(dirname "$input_abs")
output=requirements.txt

pushd "$dir"
uv pip compile \
--python-version $PYTHON_VERSION \
"$input_rel" \
-o "$output"
popd
1 change: 1 addition & 0 deletions CI/check_unused_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def main():
# TODO Mention these files somewhere?
"generate_particle_data_table.py",
"lazy_autodoc.py",
"codegen/src/codegen/sympy_common.py",
)

suffix_header = (
Expand Down
132 changes: 53 additions & 79 deletions CI/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,79 +1,53 @@
certifi==2020.6.20 \
--hash=sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41 \
--hash=sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3
chardet==3.0.4 \
--hash=sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691 \
--hash=sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae
click==7.1.2 \
--hash=sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc \
--hash=sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a
colorama==0.4.3 \
--hash=sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff \
--hash=sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1
commonmark==0.9.1 \
--hash=sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9 \
--hash=sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60
cursor==1.3.4 \
--hash=sha256:33f279a17789c04efd27a92501a0dad62bb011f8a4cdff93867c798d26508940
deprecated==1.2.10 \
--hash=sha256:a766c1dccb30c5f6eb2b203f87edd1d8588847709c78589e1521d769addc8218 \
--hash=sha256:525ba66fb5f90b07169fdd48b6373c18f1ee12728ca277ca44567a367d9d7f74
halo==0.0.29 \
--hash=sha256:67996649083229a9b7a93fe7c871c97d40bd2f1a988540eccf948a6b1844f644 \
--hash=sha256:a8aeb0164e269d7c96fb7444b2a4caaa09b8989fa0c85e6a26e8b2c6d1af3b9d
idna==2.10 \
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0 \
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6
log-symbols==0.0.14 \
--hash=sha256:4952106ff8b605ab7d5081dd2c7e6ca7374584eff7086f499c06edd1ce56dcca \
--hash=sha256:cf0bbc6fe1a8e53f0d174a716bc625c4f87043cc21eb55dd8a740cfe22680556
pprintpp==0.4.0 \
--hash=sha256:b6b4dcdd0c0c0d75e4d7b2f21a9e933e5b2ce62b26e1a54537f9651ae5a5c01d \
--hash=sha256:ea826108e2c7f49dc6d66c752973c3fc9749142a798d6b254e1e301cfdbc6403
pygithub==1.51 \
--hash=sha256:8375a058ec651cc0774244a3bc7395cf93617298735934cdd59e5bcd9a1df96e \
--hash=sha256:d2d17d1e3f4474e070353f201164685a95b5a92f5ee0897442504e399c7bc249
pygments==2.6.1 \
--hash=sha256:ff7a40b4860b727ab48fad6360eb351cc1b33cbf9b15a0f689ca5353e9463324 \
--hash=sha256:647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44
pyjwt==1.7.1 \
--hash=sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e \
--hash=sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96
pyyaml==5.3.1 \
--hash=sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f \
--hash=sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76 \
--hash=sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2 \
--hash=sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c \
--hash=sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2 \
--hash=sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648 \
--hash=sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a \
--hash=sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf \
--hash=sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97 \
--hash=sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee \
--hash=sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d
requests==2.24.0 \
--hash=sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898 \
--hash=sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b
rich==3.3.0 \
--hash=sha256:632e2203f6b926b105d252c84eb2c4ac5090e8d48f24665a9b64e1488872bbf0 \
--hash=sha256:de8e58622f0b8e29e0cdfaa6c3b88231589a5d53efee8eedb980d82f13c7a537
sh==1.13.1 \
--hash=sha256:6f792e45b45d039b423081558904981e8ab49572b0c38009fcc65feaab06bcda \
--hash=sha256:97a3d2205e3c6a842d87ebbc9ae93acae5a352b1bc4609b428d0fd5bb9e286a3
six==1.15.0 \
--hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced \
--hash=sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259
spinners==0.0.24 \
--hash=sha256:2fa30d0b72c9650ad12bbe031c9943b8d441e41b4f5602b0ec977a19f3290e98 \
--hash=sha256:1eb6aeb4781d72ab42ed8a01dcf20f3002bf50740d7154d12fb8c9769bf9e27f
termcolor==1.1.0 \
--hash=sha256:1d6d69ce66211143803fbc56652b41d73b4a400a2891d7bf7a1cdf4c02de613b
typing-extensions==3.7.4.2 \
--hash=sha256:f8d2bd89d25bc39dabe7d23df520442fa1d8969b82544370e03d88b5a591c392 \
--hash=sha256:6e95524d8a547a91e08f404ae485bbb71962de46967e1b71a0cb89af24e761c5 \
--hash=sha256:79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae
urllib3==1.25.9 \
--hash=sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115 \
--hash=sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527
wrapt==1.12.1 \
--hash=sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7
# This file was autogenerated by uv via the following command:
# uv pip compile --python-version 3.13 pyproject.toml -o requirements.txt
certifi==2020.6.20
# via requests
chardet==3.0.4
# via requests
click==7.1.2
# via acts-ci (pyproject.toml)
colorama==0.4.3
# via
# halo
# log-symbols
# rich
commonmark==0.9.1
# via rich
cursor==1.3.4
# via halo
deprecated==1.2.10
# via pygithub
halo==0.0.29
# via acts-ci (pyproject.toml)
idna==2.10
# via requests
log-symbols==0.0.14
# via halo
pprintpp==0.4.0
# via rich
pygithub==1.51
# via acts-ci (pyproject.toml)
pygments==2.6.1
# via rich
pyjwt==1.7.1
# via pygithub
pyyaml==5.3.1
# via acts-ci (pyproject.toml)
requests==2.24.0
# via pygithub
rich==3.3.0
# via acts-ci (pyproject.toml)
sh==1.13.1
# via acts-ci (pyproject.toml)
six==1.15.0
# via halo
spinners==0.0.24
# via halo
termcolor==1.1.0
# via halo
typing-extensions==3.7.4.2
# via rich
urllib3==1.25.9
# via requests
wrapt==1.12.1
# via deprecated
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Acts {
/// enough hits
/// 5) Remove tracks that are not good enough based on cuts Contains method for
/// data preparations

class ScoreBasedAmbiguityResolution {
public:
/// @brief Detector configuration struct : contains the configuration for each detector
Expand All @@ -50,11 +51,23 @@ class ScoreBasedAmbiguityResolution {
int outliersScoreWeight = 0;
int otherScoreWeight = 0;

std::size_t minHits = 0;
// the eta bins for the detector
std::vector<double> etaBins = {-5, 5};

// the minimum number of hits for each eta bin
std::vector<std::size_t> minHitsPerEta = {0};

// the maximum number of holes for each eta bin
std::vector<std::size_t> maxHolesPerEta = {0};

// the maximum number of outliers for each eta bin
std::vector<std::size_t> maxOutliersPerEta = {0};

// the maximum number of shared hits for each eta bin
std::vector<std::size_t> maxSharedHitsPerEta = {0};

std::size_t maxHits = 0;
std::size_t maxHoles = 0;
std::size_t maxOutliers = 0;
std::size_t maxSharedHits = 0;

/// if true, the shared hits are considered as bad hits for this detector
bool sharedHitsFlag = false;
Expand All @@ -63,12 +76,12 @@ class ScoreBasedAmbiguityResolution {

/// a list of values from 0 to 1, the higher number of hits, higher value
/// in the list is multiplied to ambuiguity score applied only if
/// useAmbiguityFunction is true
/// useAmbiguityScoring is true
std::vector<double> factorHits = {1.0};

/// a list of values from 0 to 1, the higher number of holes, lower value
/// in the list is multiplied to ambuiguity score applied only if
/// useAmbiguityFunction is true
/// useAmbiguityScoring is true
std::vector<double> factorHoles = {1.0};
};

Expand Down Expand Up @@ -107,28 +120,21 @@ class ScoreBasedAmbiguityResolution {
std::size_t maxSharedTracksPerMeasurement = 10;
/// maximum number of shared hit per track
std::size_t maxShared = 5;

double pTMin = 0 * UnitConstants::GeV;
double pTMax = 1e5 * UnitConstants::GeV;

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

double etaMin = -5;
double etaMax = 5;
/// minimum number of unshared hits per track
std::size_t minUnshared = 5;

// if true, the ambiguity score is computed based on a different function.
bool useAmbiguityFunction = false;
bool useAmbiguityScoring = false;
};

/// @brief OptionalCuts struct : contains the optional cuts to be applied.
/// @brief Optionals struct: contains the optional cuts, weights and score to be applied.
///
/// The optional cuts,weights and score are used to remove tracks that are not
/// good enough, based on some criteria. Users are free to add their own cuts
/// with the help of this struct.
/// The default cuts and scoring has only a basic set of cuts and
/// score-modifiers. For more flexibility users can define custom cuts and
/// scores using this structure.
template <TrackProxyConcept track_proxy_t>
struct OptionalCuts {
using OptionalFilter = std::function<bool(const track_proxy_t&)>;
struct Optionals {
using OptionalCuts = std::function<bool(const track_proxy_t&)>;

using OptionalScoreModifier =
std::function<void(const track_proxy_t&, double&)>;
Expand All @@ -137,10 +143,10 @@ class ScoreBasedAmbiguityResolution {
const track_proxy_t&,
const typename track_proxy_t::ConstTrackStateProxy&, TrackStateTypes&)>;

std::vector<OptionalFilter> cuts = {};
std::vector<OptionalCuts> cuts = {};
std::vector<OptionalScoreModifier> weights = {};

/// applied only if useAmbiguityFunction is true
/// applied only if useAmbiguityScoring is true
std::vector<OptionalScoreModifier> scores = {};
std::vector<OptionalHitSelection> hitSelections = {};
};
Expand All @@ -163,27 +169,37 @@ class ScoreBasedAmbiguityResolution {
///
/// @param tracks is the input track container
/// @param trackFeaturesVectors is the trackFeatures map from detector ID to trackFeatures
/// @param optionalCuts is the user defined optional cuts to be applied.
/// @param optionals is the user defined optional cuts to be applied.
/// @return a vector of scores for each track
template <TrackContainerFrontend track_container_t>
std::vector<double> simpleScore(
const track_container_t& tracks,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts = {}) const;
const Optionals<typename track_container_t::ConstTrackProxy>& optionals =
{}) const;

/// Compute the score of each track based on the ambiguity function.
///
/// @param tracks is the input track container
/// @param trackFeaturesVectors is the trackFeatures map from detector ID to trackFeatures
/// @param optionalCuts is the user defined optional cuts to be applied.
/// @param optionals is the user defined optional cuts to be applied.
/// @return a vector of scores for each track
template <TrackContainerFrontend track_container_t>
std::vector<double> ambiguityScore(
const track_container_t& tracks,
const std::vector<std::vector<TrackFeatures>>& trackFeaturesVectors,
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts = {}) const;
const Optionals<typename track_container_t::ConstTrackProxy>& optionals =
{}) const;

/// Rejects Tracks based on eta dependent cuts.
///
/// @param detector is the detector configuration object
/// @param trackFeatures is the trackFeatures object for a specific detector
/// @param eta is the eta of the track
/// @return true if the track is rejected, false otherwise
bool etaBasedCuts(const DetectorConfig& detector,
const TrackFeatures& trackFeatures,
const double& eta) const;

/// Remove hits that are not good enough for each track and removes tracks
/// that have a score below a certain threshold or not enough hits.
Expand Down Expand Up @@ -211,15 +227,15 @@ class ScoreBasedAmbiguityResolution {
/// @param tracks is the input track container
/// @param sourceLinkHash is the source links
/// @param sourceLinkEquality is the equality function for the source links
/// @param optionalCuts is the optional cuts to be applied
/// @param optionals are the optional cuts and score modifiers to be applied
/// @return a vector of IDs of the tracks we want to keep
template <TrackContainerFrontend track_container_t,
typename source_link_hash_t, typename source_link_equality_t>
std::vector<int> solveAmbiguity(
const track_container_t& tracks, source_link_hash_t sourceLinkHash,
source_link_equality_t sourceLinkEquality,
const OptionalCuts<typename track_container_t::ConstTrackProxy>&
optionalCuts = {}) const;
const Optionals<typename track_container_t::ConstTrackProxy>& optionals =
{}) const;

private:
Config m_cfg;
Expand Down
Loading

0 comments on commit ff2d659

Please sign in to comment.