Skip to content

Commit

Permalink
Merge branch 'main' into fix-straw-layer-range
Browse files Browse the repository at this point in the history
  • Loading branch information
asalzburger authored Jul 29, 2024
2 parents 7bbb68c + 5cf4581 commit 3203308
Show file tree
Hide file tree
Showing 22 changed files with 376 additions and 210 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ jobs:
INSTALL_DIR: ${{ github.workspace }}/install_acts
DEPENDENCY_DIR: ${{ github.workspace }}/install
ACTS_LOG_FAILURE_THRESHOLD: WARNING
DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/macOS/cmake/deps.8e12bbf.tar.zst
DEPENDENCY_URL: https://acts.web.cern.ch/ACTS/ci/macOS/cmake/deps.8a95213.tar.zst
# Works around an issue where root's RPATH is wrong for tbb, thus won't find it
DYLD_LIBRARY_PATH: "${{ github.workspace }}/install/tbb/2021.11.0/lib"
steps:
Expand All @@ -352,11 +352,9 @@ jobs:
brew install cmake ninja ccache xerces-c
&& wget --verbose --progress=dot:giga --continue --retry-connrefused --tries=5 --timeout=2 -O deps.tar.zst ${{ env.DEPENDENCY_URL }}
&& mkdir ${{ env.DEPENDENCY_DIR }}
&& ls ${{ env.DEPENDENCY_DIR }}
&& tar -xf deps.tar.zst -C ${{ env.DEPENDENCY_DIR }}
&& ls ${{ env.DEPENDENCY_DIR }}
&& ls ${{ env.DEPENDENCY_DIR }}/python
&& ${{ env.DEPENDENCY_DIR }}/python/3.12.2/bin/python3 -m pip install pyyaml jinja2
&& PATH="${{ env.DEPENDENCY_DIR }}/bin:$PATH"
&& python3 -m pip install pyyaml jinja2
- name: Restore ccache
uses: actions/cache/restore@v4
Expand All @@ -373,17 +371,17 @@ jobs:
# versions such as the one installed via homebrew
run: >
ccache -z
&& source ${{ env.DEPENDENCY_DIR }}/setup.sh
&& PATH="${{ env.DEPENDENCY_DIR }}/bin:$PATH"
&& cmake -B build -S .
-GNinja
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DPython_EXECUTABLE=${{ env.DEPENDENCY_DIR }}/python/3.12.2/bin/python3
-DCMAKE_PREFIX_PATH="${{ env.DEPENDENCY_DIR }}"
-DPython_EXECUTABLE=${{ env.DEPENDENCY_DIR }}/bin/python3
-DDD4HEP_DEBUG_CMAKE=ON
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CXX_FLAGS=-Werror
-DCMAKE_CXX_STANDARD=20
-DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_DIR }}"
-DCMAKE_PREFIX_PATH=/usr/local/acts
-DACTS_BUILD_EVERYTHING=ON
-DACTS_BUILD_EXAMPLES_UNITTESTS=ON
-DACTS_BUILD_ODD=ON
Expand Down Expand Up @@ -413,7 +411,7 @@ jobs:
path: ${{ env.INSTALL_DIR }}
- name: Downstream configure
run: >
source ${{ env.DEPENDENCY_DIR }}/setup.sh
PATH="${{ env.DEPENDENCY_DIR }}/bin:$PATH"
&& cmake -B build-downstream -S Tests/DownstreamProject
-GNinja
-DCMAKE_BUILD_TYPE=Release
Expand All @@ -423,7 +421,6 @@ jobs:
- name: Downstream build
run: cmake --build build-downstream
- name: Downstream run
run: |
source ${{ env.DEPENDENCY_DIR }}/setup.sh
source ${{ env.DEPENDENCY_DIR}}/dd4hep/*/bin/thisdd4hep.sh
./build-downstream/bin/ShowActsVersion
run: >
PATH="${{ env.DEPENDENCY_DIR }}/bin:$PATH"
&& ./build-downstream/bin/ShowActsVersion
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,22 @@ ScoreBasedAmbiguityResolution::computeInitialState(
}
auto detectorId = volume_it->second;

if (ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
if (ts.typeFlags().test(Acts::TrackStateFlag::HoleFlag)) {
ACTS_DEBUG("Track state type is HoleFlag");
trackFeaturesVector[detectorId].nHoles++;
} else if (ts.typeFlags().test(Acts::TrackStateFlag::OutlierFlag)) {
Acts::SourceLink sourceLink = ts.getUncalibratedSourceLink();
ACTS_DEBUG("Track state type is OutlierFlag");
trackFeaturesVector[detectorId].nOutliers++;

// assign a new measurement index if the source link was not seen yet
auto emplace = MeasurementIndexMap.try_emplace(
sourceLink, MeasurementIndexMap.size());

bool isOutliner = true;

measurements.push_back({emplace.first->second, detectorId, isOutliner});
} else if (ts.typeFlags().test(Acts::TrackStateFlag::MeasurementFlag)) {
Acts::SourceLink sourceLink = ts.getUncalibratedSourceLink();
ACTS_DEBUG("Track state type is MeasurementFlag");

Expand All @@ -74,21 +89,6 @@ ScoreBasedAmbiguityResolution::computeInitialState(
bool isoutliner = false;

measurements.push_back({emplace.first->second, detectorId, isoutliner});
} else if (ts.typeFlags().test(Acts::TrackStateFlag::OutlierFlag)) {
Acts::SourceLink sourceLink = ts.getUncalibratedSourceLink();
ACTS_DEBUG("Track state type is OutlierFlag");
trackFeaturesVector[detectorId].nOutliers++;

// assign a new measurement index if the source link was not seen yet
auto emplace = MeasurementIndexMap.try_emplace(
sourceLink, MeasurementIndexMap.size());

bool isOutliner = true;

measurements.push_back({emplace.first->second, detectorId, isOutliner});
} else if (ts.typeFlags().test(Acts::TrackStateFlag::HoleFlag)) {
ACTS_DEBUG("Track state type is HoleFlag");
trackFeaturesVector[detectorId].nHoles++;
}
}
measurementsPerTrack.push_back(std::move(measurements));
Expand Down
48 changes: 24 additions & 24 deletions Core/include/Acts/EventData/MultiTrajectoryHelpers.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// This file is part of the Acts project.
//
// Copyright (C) 2020 CERN for the benefit of the Acts project
// Copyright (C) 2020-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/EventData/MultiTrajectory.hpp"
#include "Acts/EventData/TrackContainer.hpp"
#include "Acts/EventData/TransformationHelpers.hpp"
Expand Down Expand Up @@ -44,21 +45,27 @@ using VolumeTrajectoryStateContainer =
/// @brief Getter for global trajectory info
///
/// @param multiTraj The MultiTrajectory object
/// @param entryIndex The entry index of trajectory to investigate
/// @param tipIndex The entry index of trajectory to investigate
///
/// @return The trajectory summary info
template <typename traj_t>
TrajectoryState trajectoryState(const traj_t& multiTraj,
std::size_t entryIndex) {
TrajectoryState trajectoryState(const traj_t& multiTraj, std::size_t tipIndex) {
TrajectoryState trajState;
multiTraj.visitBackwards(entryIndex, [&](const auto& state) {
multiTraj.visitBackwards(tipIndex, [&](const auto& state) {
// Get the volume Id of this surface
const auto& geoID = state.referenceSurface().geometryId();
const auto& volume = geoID.volume();
const auto& layer = geoID.layer();
trajState.nStates++;
auto typeFlags = state.typeFlags();
if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
trajState.nHoles++;
} else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
trajState.nOutliers++;
trajState.outlierChi2.push_back(state.chi2());
trajState.outlierVolume.push_back(volume);
trajState.outlierLayer.push_back(layer);
} else if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) {
trajState.nSharedHits++;
}
Expand All @@ -68,13 +75,6 @@ TrajectoryState trajectoryState(const traj_t& multiTraj,
trajState.measurementLayer.push_back(layer);
trajState.chi2Sum += state.chi2();
trajState.NDF += state.calibratedSize();
} else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
trajState.nOutliers++;
trajState.outlierChi2.push_back(state.chi2());
trajState.outlierVolume.push_back(volume);
trajState.outlierLayer.push_back(layer);
} else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
trajState.nHoles++;
}
});
return trajState;
Expand All @@ -85,18 +85,18 @@ TrajectoryState trajectoryState(const traj_t& multiTraj,
/// @tparam source_link_t Type of source link
///
/// @param multiTraj The MultiTrajectory object
/// @param entryIndex The entry index of trajectory to investigate
/// @param tipIndex The entry index of trajectory to investigate
/// track states at different sub-detectors.
/// @param volumeIds The container for sub-detector Ids
///
/// @return The trajectory summary info at different sub-detectors (i.e.
/// different volumes)
template <typename traj_t>
VolumeTrajectoryStateContainer trajectoryState(
const traj_t& multiTraj, std::size_t entryIndex,
const traj_t& multiTraj, std::size_t tipIndex,
const std::vector<GeometryIdentifier::Value>& volumeIds) {
VolumeTrajectoryStateContainer trajStateContainer;
multiTraj.visitBackwards(entryIndex, [&](const auto& state) {
multiTraj.visitBackwards(tipIndex, [&](const auto& state) {
// Get the volume Id of this surface
const auto& geoID = state.referenceSurface().geometryId();
const auto& volume = geoID.volume();
Expand All @@ -111,7 +111,14 @@ VolumeTrajectoryStateContainer trajectoryState(
trajState.nStates++;
trajState.NDF += state.calibratedSize();
auto typeFlags = state.typeFlags();
if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
trajState.nHoles++;
} else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
trajState.nOutliers++;
trajState.outlierChi2.push_back(state.chi2());
trajState.outlierVolume.push_back(volume);
trajState.outlierLayer.push_back(layer);
} else if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) {
trajState.nSharedHits++;
}
Expand All @@ -120,13 +127,6 @@ VolumeTrajectoryStateContainer trajectoryState(
trajState.measurementVolume.push_back(volume);
trajState.measurementLayer.push_back(layer);
trajState.chi2Sum += state.chi2();
} else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
trajState.nOutliers++;
trajState.outlierChi2.push_back(state.chi2());
trajState.outlierVolume.push_back(volume);
trajState.outlierLayer.push_back(layer);
} else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
trajState.nHoles++;
}
return true;
});
Expand Down
55 changes: 14 additions & 41 deletions Core/include/Acts/EventData/TrackHelpers.hpp
Original file line number Diff line number Diff line change
@@ -1,54 +1,27 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
// Copyright (C) 2023-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/EventData/MultiTrajectory.hpp"
#include "Acts/EventData/TrackContainer.hpp"
// This header is deprecated and will be removed in the future.
// Please use the new header instead:
#include "Acts/Utilities/TrackHelpers.hpp"

namespace Acts {

/// Helper function to calculate a number of track level quantities and store
/// them on the track itself
/// @note The input track needs to be mutable, so @c ReadOnly=false
/// @tparam track_container_t the track container backend
/// @tparam track_state_container_t the track state container backend
/// @tparam holder_t the holder type for the track container backends
/// @param track A mutable track proxy to operate on
template <typename track_container_t, typename track_state_container_t,
template <typename> class holder_t>
void calculateTrackQuantities(
Acts::TrackProxy<track_container_t, track_state_container_t, holder_t,
false>
track) {
track.chi2() = 0;
track.nDoF() = 0;

track.nHoles() = 0;
track.nMeasurements() = 0;
track.nSharedHits() = 0;
track.nOutliers() = 0;

for (const auto& trackState : track.trackStatesReversed()) {
auto typeFlags = trackState.typeFlags();

if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) {
track.nSharedHits()++;
}
// Funny header deprecation strategy
namespace {
[[deprecated(
"This header is deprecated - use "
"Acts/Utilities/TrackHelpers.hpp")]] constexpr static int
utilities_trackhelpers_hpp_is_deprecated = 0;
constexpr static int please_dont_use_utilities_trackhelpers_hpp =
utilities_trackhelpers_hpp_is_deprecated;
} // namespace

track.nMeasurements()++;
track.chi2() += trackState.chi2();
track.nDoF() += trackState.calibratedSize();
} else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
track.nOutliers()++;
} else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
track.nHoles()++;
}
}
}
} // namespace Acts
Loading

0 comments on commit 3203308

Please sign in to comment.