From fdc79ac42bf27b9000e2a9c752b5b9cfc6a85ba4 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 17 Nov 2023 14:24:31 -0600 Subject: [PATCH] feat: upgrade EICrecon to Acts v30 (#1072) ### Briefly, what does this PR introduce? This upgrades EICrecon to work with Acts v30.3.2. Because of the way changes to Acts are implemented, it is often beyond cumbersome to achieve backwards compatibility with preprocessor directives. While in a model of frequent updates this may be more achievable in the interest of regression testing, it is not a good use of anyone's time to implement this for large version jumps. TODO: - [ ] revert back to default jug_xl:nightly ### What kind of change does this PR introduce? - [ ] Bug fix (issue #__) - [x] New feature (issue #623) - [ ] Documentation update - [ ] Other: __ ### Please check if this PR fulfills the following: - [ ] Tests for the changes have been added - [ ] Documentation has been added / updated - [ ] Changes have been communicated to collaborators ### Does this PR introduce breaking changes? What changes might users need to make to their code? Yes. This will require Acts v30.0.0, compiled with examples (`ACTS_BUILD_EXAMPLES=ON`). ### Does this PR change default behavior? No changes in EICrecon which would result in different output were intentionally introduced. If there are logic changes (e.g. CKFTracking now fitting per seed), they were following changes in the upstream interfaces. --- .github/workflows/linux-eic-shell.yml | 40 +- cmake/jana_plugin.cmake | 5 + .../EventData/GeometryContainers.hpp | 189 --------- .../tracking/ActsExamples/EventData/Index.hpp | 55 --- .../EventData/IndexSourceLink.hpp | 70 ---- .../ActsExamples/EventData/Measurement.hpp | 57 --- .../tracking/ActsExamples/EventData/Track.hpp | 22 -- .../ActsExamples/EventData/Trajectories.hpp | 104 ----- .../ActsExamples/Geometry/MaterialWiper.hpp | 43 -- src/algorithms/tracking/ActsExamples/LICENSE | 373 ------------------ .../tracking/ActsExamples/README.md | 6 - .../ActsExamples/Utilities/GroupBy.hpp | 141 ------- .../ActsExamples/Utilities/Options.hpp | 76 ---- .../ActsExamples/Utilities/OptionsFwd.hpp | 23 -- .../tracking/ActsExamples/Utilities/Paths.hpp | 46 --- .../tracking/ActsExamples/Utilities/Range.hpp | 56 --- .../tracking/ActsGeometryProvider.cc | 13 +- src/algorithms/tracking/CKFTracking.cc | 339 ++++++++++------ src/algorithms/tracking/CKFTracking.h | 27 +- .../tracking/CKFTrackingFunction.cc | 31 +- src/algorithms/tracking/DD4hepBField.cc | 14 +- .../tracking/IterativeVertexFinder.cc | 17 +- .../tracking/OrthogonalTrackSeedingConfig.h | 1 - src/algorithms/tracking/TrackProjector.cc | 2 +- src/algorithms/tracking/TrackProjector.h | 2 +- src/algorithms/tracking/TrackPropagation.cc | 12 +- src/algorithms/tracking/TrackPropagation.h | 2 +- src/algorithms/tracking/TrackSeeding.cc | 48 ++- src/algorithms/tracking/TrackSeeding.h | 5 +- .../tracking/TrackerMeasurementFromHits.cc | 2 +- .../TRACKINGcheck/TRACKINGcheckProcessor.cc | 4 +- .../TrackingEfficiency_processor.cc | 5 +- src/detectors/DRICH/DRICH.cc | 2 +- src/extensions/spdlog/SpdlogToActs.h | 7 +- src/global/pid/RichTrack_factory.cc | 9 +- src/global/tracking/CKFTracking_factory.cc | 4 +- src/global/tracking/CKFTracking_factory.h | 5 +- .../tracking/IterativeVertexFinder_factory.cc | 5 +- .../tracking/IterativeVertexFinder_factory.h | 1 - src/global/tracking/TrackProjector_factory.cc | 7 +- src/global/tracking/TrackProjector_factory.h | 1 - .../tracking/TrackPropagation_factory.cc | 4 +- src/global/tracking/tracking.cc | 8 +- .../TrackPropagationTest_processor.cc | 2 +- .../TrackSeedingTest_processor.cc | 2 +- 45 files changed, 387 insertions(+), 1500 deletions(-) delete mode 100644 src/algorithms/tracking/ActsExamples/EventData/GeometryContainers.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/EventData/Index.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/EventData/IndexSourceLink.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/EventData/Measurement.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/EventData/Track.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/EventData/Trajectories.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/Geometry/MaterialWiper.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/LICENSE delete mode 100644 src/algorithms/tracking/ActsExamples/README.md delete mode 100644 src/algorithms/tracking/ActsExamples/Utilities/GroupBy.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/Utilities/Options.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/Utilities/OptionsFwd.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/Utilities/Paths.hpp delete mode 100644 src/algorithms/tracking/ActsExamples/Utilities/Range.hpp diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 9a957fb3a2..b8bcd2252c 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -16,13 +16,19 @@ on: default: 'jug_xl:nightly' required: false type: string + detector-version: + description: 'epic geometry version' + default: 'main' + required: false + type: string concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} cancel-in-progress: true env: - platform-release: ${{ inputs.platform-release || 'jug_xl:nightly' }} + platform-release: ${{ inputs.platform-release || 'jug_xl:23.12-alpha' }} + detector-version: ${{ inputs.detector-version || 'main' }} ASAN_OPTIONS: suppressions=${{ github.workspace }}/.github/asan.supp:malloc_context_size=20:detect_leaks=1:verify_asan_link_order=0:detect_stack_use_after_return=1:detect_odr_violation=1:new_delete_type_mismatch=0:intercept_tls_get_addr=0 LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan.supp UBSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/ubsan.supp:print_stacktrace=1 @@ -84,7 +90,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH for lib in lib/*.so lib/EICrecon/plugins/*.so ; do @@ -276,7 +282,7 @@ jobs: if: steps.retrieve_simulation_files.outputs.cache-hit != 'true' with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | npsim --compactFile ${DETECTOR_PATH}/${DETECTOR}_${{ matrix.detector_config }}.xml -G --random.seed 1 --gun.particle "${{ matrix.particle }}-" --gun.momentumMin "1*GeV" --gun.momentumMax "20*GeV" --gun.distribution "uniform" -N 100 --outputFile sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -v WARNING - uses: actions/upload-artifact@v3 @@ -309,7 +315,7 @@ jobs: if: steps.retrieve_simulation_files.outputs.cache-hit != 'true' with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | python src/tests/LUMISPECCAL_test/TwoElectronsTopCAL.py genParticles.hepmc npsim --compactFile ${DETECTOR_PATH}/${DETECTOR}_${{ matrix.detector_config }}.xml --inputFiles genParticles.hepmc --random.seed 1 --outputFile sim_${{ matrix.particle }}_EcalLumiSpec_${{ matrix.detector_config }}.edm4hep.root -N 100 -v WARNING @@ -346,7 +352,7 @@ jobs: if: steps.retrieve_simulation_files.outputs.cache-hit != 'true' with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | url=root://dtn-eic.jlab.org//work/eic2/EPIC/EVGEN/DIS/NC/${{matrix.beam}}/minQ2=${{matrix.minq2}}/pythia8NCDIS_${{matrix.beam}}_minQ2=${{matrix.minq2}}_beamEffects_xAngle=-0.025_hiDiv_1.hepmc3.tree.root npsim --compactFile ${DETECTOR_PATH}/${DETECTOR}_${{ matrix.detector_config }}.xml -N 100 --inputFiles ${url} --random.seed 1 --outputFile sim_dis_${{matrix.beam}}_minQ2=${{matrix.minq2}}_${{ matrix.detector_config }}.edm4hep.root -v WARNING @@ -380,7 +386,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -397,7 +403,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -433,7 +439,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -474,7 +480,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -509,7 +515,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH ldd -r lib/*.so lib/EICrecon/plugins/*.so @@ -517,7 +523,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -557,7 +563,7 @@ jobs: if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: platform-release: "${{ env.platform-release }}" - setup: "/opt/detector/setup.sh" + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | pip install 'pygithub>=2' 'bokeh>=3' export PYTHONPATH=$HOME/.local/lib/python3.10/site-packages:$PYTHONPATH @@ -591,7 +597,7 @@ jobs: if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | echo "::group::pip install" python3 -m pip install -r ${{ github.workspace }}/.github/requirements.txt @@ -622,7 +628,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -671,7 +677,7 @@ jobs: uses: eic/run-cvmfs-osg-eic-shell@main with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }} export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH @@ -706,7 +712,7 @@ jobs: if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: platform-release: "${{ env.platform-release }}" - setup: "/opt/detector/setup.sh" + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | pip install 'pygithub>=2' 'bokeh>=3' export PYTHONPATH=$HOME/.local/lib/python3.10/site-packages:$PYTHONPATH @@ -740,7 +746,7 @@ jobs: if: steps.download_previous_artifact.outputs.found_artifact == 'true' with: platform-release: "${{ env.platform-release }}" - setup: /opt/detector/setup.sh + setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh" run: | echo "::group::pip install" python3 -m pip install -r ${{ github.workspace }}/.github/requirements.txt diff --git a/cmake/jana_plugin.cmake b/cmake/jana_plugin.cmake index c7ceca3260..eb68cf32ea 100644 --- a/cmake/jana_plugin.cmake +++ b/cmake/jana_plugin.cmake @@ -233,6 +233,10 @@ macro(plugin_add_acts _name) endif() endif() + # Get ActsExamples base + get_target_property(ActsCore_LOCATION ActsCore LOCATION) + get_filename_component(ActsCore_PATH ${ActsCore_LOCATION} DIRECTORY) + # Add libraries (works same as target_include_directories) plugin_link_libraries(${PLUGIN_NAME} ActsCore @@ -240,6 +244,7 @@ macro(plugin_add_acts _name) ActsPluginTGeo ActsPluginJson ActsPluginDD4hep + ${ActsCore_PATH}/libActsExamplesFramework.so ) endmacro() diff --git a/src/algorithms/tracking/ActsExamples/EventData/GeometryContainers.hpp b/src/algorithms/tracking/ActsExamples/EventData/GeometryContainers.hpp deleted file mode 100644 index 25df448a2a..0000000000 --- a/src/algorithms/tracking/ActsExamples/EventData/GeometryContainers.hpp +++ /dev/null @@ -1,189 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017-2020 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 -#include - -#include "../Utilities/GroupBy.hpp" -#include "../Utilities/Range.hpp" -#include -#include - -#include -#include -#include - - -namespace ActsExamples { -namespace detail { -// extract the geometry identifier from a variety of types -struct GeometryIdGetter { - // explicit geometry identifier are just forwarded - constexpr Acts::GeometryIdentifier operator()(Acts::GeometryIdentifier geometryId) const { - return geometryId; - } - // encoded geometry ids are converted back to geometry identifiers. - constexpr Acts::GeometryIdentifier operator()(Acts::GeometryIdentifier::Value encoded) const { - return Acts::GeometryIdentifier(encoded); - } - // support elements in map-like structures. - template - constexpr Acts::GeometryIdentifier operator()( - const std::pair& mapItem) const { - return mapItem.first; - } - // support elements that implement `.geometryId()`. - template - inline auto operator()(const T& thing) const - -> decltype(thing.geometryId(), Acts::GeometryIdentifier()) { - return thing.geometryId(); - } - // support reference_wrappers around such types as well - template - inline auto operator()(std::reference_wrapper thing) const - -> decltype(thing.get().geometryId(), Acts::GeometryIdentifier()) { - return thing.get().geometryId(); - } -}; - -struct CompareGeometryId { - // indicate that comparisons between keys and full objects are allowed. - using is_transparent = void; - // compare two elements using the automatic key extraction. - template - constexpr bool operator()(Left&& lhs, Right&& rhs) const { - return GeometryIdGetter()(lhs) < GeometryIdGetter()(rhs); - } -}; -} // namespace detail - -/// Store elements that know their detector geometry id, e.g. simulation hits. -/// -/// @tparam T type to be stored, must be compatible with `CompareGeometryId` -/// -/// The container stores an arbitrary number of elements for any geometry -/// id. Elements can be retrieved via the geometry id; elements can be selected -/// for a specific geometry id or for a larger range, e.g. a volume or a layer -/// within the geometry hierarchy using the helper functions below. Elements can -/// also be accessed by index that uniquely identifies each element regardless -/// of geometry id. -template -using GeometryIdMultiset = - boost::container::flat_multiset; - -/// Store elements indexed by an geometry id. -/// -/// @tparam T type to be stored -/// -/// The behaviour is the same as for the `GeometryIdMultiset` except that the -/// stored elements do not know their geometry id themself. When iterating -/// the iterator elements behave as for the `std::map`, i.e. -/// -/// for (const auto& entry: elements) { -/// auto id = entry.first; // geometry id -/// const auto& el = entry.second; // stored element -/// } -/// -template -using GeometryIdMultimap = GeometryIdMultiset>; - -/// Select all elements within the given volume. -template -inline Range::const_iterator> selectVolume( - const GeometryIdMultiset& container, Acts::GeometryIdentifier::Value volume) { - auto cmp = Acts::GeometryIdentifier().setVolume(volume); - auto beg = std::lower_bound(container.begin(), container.end(), cmp, - detail::CompareGeometryId{}); - // WARNING overflows to volume==0 if the input volume is the last one - cmp = Acts::GeometryIdentifier().setVolume(volume + 1u); - // optimize search by using the lower bound as start point. also handles - // volume overflows since the geo id would be located before the start of - // the upper edge search window. - auto end = - std::lower_bound(beg, container.end(), cmp, detail::CompareGeometryId{}); - return makeRange(beg, end); -} -template -inline auto selectVolume(const GeometryIdMultiset& container, - Acts::GeometryIdentifier id) { - return selectVolume(container, id.volume()); -} - -/// Select all elements within the given layer. -template -inline Range::const_iterator> selectLayer( - const GeometryIdMultiset& container, Acts::GeometryIdentifier::Value volume, - Acts::GeometryIdentifier::Value layer) { - auto cmp = Acts::GeometryIdentifier().setVolume(volume).setLayer(layer); - auto beg = std::lower_bound(container.begin(), container.end(), cmp, - detail::CompareGeometryId{}); - // WARNING resets to layer==0 if the input layer is the last one - cmp = Acts::GeometryIdentifier().setVolume(volume).setLayer(layer + 1u); - // optimize search by using the lower bound as start point. also handles - // volume overflows since the geo id would be located before the start of - // the upper edge search window. - auto end = - std::lower_bound(beg, container.end(), cmp, detail::CompareGeometryId{}); - return makeRange(beg, end); -} -template -inline auto selectLayer(const GeometryIdMultiset& container, - Acts::GeometryIdentifier id) { - return selectLayer(container, id.volume(), id.layer()); -} - -/// Select all elements for the given module / sensitive surface. -template -inline Range::const_iterator> selectModule( - const GeometryIdMultiset& container, Acts::GeometryIdentifier geoId) { - // module is the lowest level and defines a single geometry id value - return makeRange(container.equal_range(geoId)); -} -template -inline auto selectModule(const GeometryIdMultiset& container, - Acts::GeometryIdentifier::Value volume, - Acts::GeometryIdentifier::Value layer, - Acts::GeometryIdentifier::Value module) { - return selectModule( - container, - Acts::GeometryIdentifier().setVolume(volume).setLayer(layer).setSensitive( - module)); -} - -/// Iterate over groups of elements belonging to each module/ sensitive surface. -template -inline GroupBy::const_iterator, - detail::GeometryIdGetter> -groupByModule(const GeometryIdMultiset& container) { - return makeGroupBy(container, detail::GeometryIdGetter()); -} - -/// The accessor for the GeometryIdMultiset container -/// -/// It wraps up a few lookup methods to be used in the Combinatorial Kalman -/// Filter -template -struct GeometryIdMultisetAccessor { - using Container = GeometryIdMultiset; - using Key = Acts::GeometryIdentifier; - using Value = typename GeometryIdMultiset::value_type; - using Iterator = typename GeometryIdMultiset::const_iterator; - - // pointer to the container - const Container* container = nullptr; - - // get the range of elements with requested geoId - std::pair range(const Acts::Surface& surface) const { - assert(container != nullptr); - return container->equal_range(surface.geometryId()); - } -}; - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/EventData/Index.hpp b/src/algorithms/tracking/ActsExamples/EventData/Index.hpp deleted file mode 100644 index 19bb58e015..0000000000 --- a/src/algorithms/tracking/ActsExamples/EventData/Index.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019-2020 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 - -#include - -namespace ActsExamples { - -/// Index type to reference elements in a container. -/// -/// We do not expect to have more than 2^32 elements in any given container so a -/// fixed sized integer type is sufficient. -using Index = uint32_t; - -/// Store elements that are identified by an index, e.g. in another container. -/// -/// Each index can have zero or more associated elements. A typical case could -/// be to store all generating particles for a hit where the hit is identified -/// by its index in the hit container. -template -using IndexMultimap = boost::container::flat_multimap; - -/// Invert the multimap, i.e. from a -> {b...} to b -> {a...}. -/// -/// @note This assumes that the value in the initial multimap is itself a -/// sortable index-like object, as would be the case when mapping e.g. -/// hit ids to particle ids/ barcodes. -template -inline boost::container::flat_multimap invertIndexMultimap( - const IndexMultimap& multimap) { - using InverseMultimap = boost::container::flat_multimap; - - // switch key-value without enforcing the new ordering (linear copy) - typename InverseMultimap::sequence_type unordered; - unordered.reserve(multimap.size()); - for (auto&& [index, value] : multimap) { - // value is now the key and the index is now the value - unordered.emplace_back(value, index); - } - - // adopting the unordered sequence will reestablish the correct order - InverseMultimap inverse; - inverse.adopt_sequence(std::move(unordered)); - return inverse; -} - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/EventData/IndexSourceLink.hpp b/src/algorithms/tracking/ActsExamples/EventData/IndexSourceLink.hpp deleted file mode 100644 index e08b8e1110..0000000000 --- a/src/algorithms/tracking/ActsExamples/EventData/IndexSourceLink.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 "GeometryContainers.hpp" -#include "Index.hpp" - -#include -#include - -#include - -namespace ActsExamples { - - /// A source link that stores just an index. - /// - /// This is intentionally kept as barebones as possible. The source link - /// is just a reference and will be copied, moved around, etc. often. - /// Keeping it small and separate from the actual, potentially large, - /// measurement data should result in better overall performance. - /// Using an index instead of e.g. a pointer, means source link and - /// measurement are decoupled and the measurement representation can be - /// easily changed without having to also change the source link. - class IndexSourceLink final : public Acts::SourceLink { - public: - /// Construct from geometry identifier and index. - constexpr IndexSourceLink(Acts::GeometryIdentifier gid, Index idx) : SourceLink(gid), m_index(idx) {} - - // Construct an invalid source link. Must be default constructible to - /// satisfy SourceLinkConcept. - IndexSourceLink() : SourceLink{Acts::GeometryIdentifier{}} {} - IndexSourceLink(const IndexSourceLink&) = default; - IndexSourceLink(IndexSourceLink&&) = default; - IndexSourceLink& operator=(const IndexSourceLink&) = default; - IndexSourceLink& operator=(IndexSourceLink&&) = default; - - /// Access the index. - constexpr Index index() const { return m_index; } - - public: - Index m_index; - - friend constexpr bool operator==(const IndexSourceLink& lhs, const IndexSourceLink& rhs) - { - return (lhs.geometryId() == rhs.geometryId()) and (lhs.m_index == rhs.m_index); - } - friend constexpr bool operator!=(const IndexSourceLink& lhs, const IndexSourceLink& rhs) { return not(lhs == rhs); } - }; - - /// Container of index source links. - /// - /// Since the source links provide a `.geometryId()` accessor, they can be - /// stored in an ordered geometry container. - using IndexSourceLinkContainer = - GeometryIdMultiset>; - - /// Accessor for the above source link container - /// - /// It wraps up a few lookup methods to be used in the Combinatorial Kalman - /// Filter - using IndexSourceLinkAccessor = - GeometryIdMultisetAccessor>; - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/EventData/Measurement.hpp b/src/algorithms/tracking/ActsExamples/EventData/Measurement.hpp deleted file mode 100644 index 353d69fbb0..0000000000 --- a/src/algorithms/tracking/ActsExamples/EventData/Measurement.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck - -#pragma once - -#include -#include -#include -#include -#include "IndexSourceLink.hpp" - -#include -#include -#include - -namespace ActsExamples { - - /// Variable measurement type that can contain all possible combinations. - using Measurement = ::Acts::BoundVariantMeasurement; - /// Container of measurements. - /// - /// In contrast to the source links, the measurements themself must not be - /// orderable. The source links stored in the measurements are treated - /// as opaque here and no ordering is enforced on the stored measurements. - using MeasurementContainer = std::vector; - - /// Calibrator to convert an index source link to a measurement. - class MeasurementCalibrator { - public: - /// Construct an invalid calibrator. Required to allow copying. - MeasurementCalibrator() = default; - /// Construct using a user-provided container to chose measurements from. - MeasurementCalibrator(const MeasurementContainer& measurements) : m_measurements(&measurements) {} - - /// Find the measurement corresponding to the source link. - /// - /// @tparam parameters_t Track parameters type - /// @param gctx The geometry context (unused) - /// @param trackState The track state to calibrate - void calibrate( - const Acts::GeometryContext& /*gctx*/, - Acts::MultiTrajectory::TrackStateProxy - trackState) const { - const auto& sourceLink = - static_cast(trackState.uncalibrated()); - - std::visit( - [&trackState](const auto& meas) { trackState.setCalibrated(meas); }, - (*m_measurements)[sourceLink.index()]); - } - - private: - // use pointer so the calibrator is copyable and default constructible. - const MeasurementContainer* m_measurements = nullptr; - }; - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/EventData/Track.hpp b/src/algorithms/tracking/ActsExamples/EventData/Track.hpp deleted file mode 100644 index e5df7129d4..0000000000 --- a/src/algorithms/tracking/ActsExamples/EventData/Track.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019-2020 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 - -#include - -namespace ActsExamples { - -/// (Reconstructed) track parameters e.g. close to the vertex. -using TrackParameters = ::Acts::BoundTrackParameters; -/// Container of reconstructed track states for multiple tracks. -using TrackParametersContainer = std::vector; - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/EventData/Trajectories.hpp b/src/algorithms/tracking/ActsExamples/EventData/Trajectories.hpp deleted file mode 100644 index a48f9799ff..0000000000 --- a/src/algorithms/tracking/ActsExamples/EventData/Trajectories.hpp +++ /dev/null @@ -1,104 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong - -#pragma once - -#include -#include -#include "IndexSourceLink.hpp" -#include "Track.hpp" - -#include -#include -#include - - -namespace ActsExamples { - -/// Store reconstructed trajectories from track finding/fitting. -/// -/// It contains a MultiTrajectory with a vector of entry indices for -/// individual trajectories, and a map of fitted parameters indexed by the -/// entry index. In case of track fitting, there is at most one trajectory -/// in the MultiTrajectory; In case of track finding, there could be -/// multiple trajectories in the MultiTrajectory. -struct Trajectories final { - public: - /// (Reconstructed) trajectory with multiple states. - using MultiTrajectory = Acts::VectorMultiTrajectory; - /// Fitted parameters identified by indices in the multi trajectory. - using IndexedParameters = - std::unordered_map; - - /// Default construct an empty object. Required for container compatibility - /// and to signal an error. - Trajectories() = default; - /// Construct from fitted multi trajectory and parameters. - /// - /// @param multiTraj The multi trajectory - /// @param tTips Tip indices that identify valid trajectories - /// @param parameters Fitted track parameters indexed by trajectory index - Trajectories(std::shared_ptr multiTraj, - const std::vector& tTips, - const IndexedParameters& parameters) - : m_multiTrajectory(std::move(multiTraj)), - m_trackTips(tTips), - m_trackParameters(parameters) {} - - /// Return true if there exists no valid trajectory. - bool empty() const { return m_trackTips.empty(); } - - /// Access the underlying multi trajectory. - const MultiTrajectory& multiTrajectory() const { return *m_multiTrajectory; } - - /// Access the tip indices that identify valid trajectories. - const std::vector& tips() const { - return m_trackTips; - } - - /// Check if a trajectory exists for the given index. - /// - /// @param entryIndex The trajectory entry index - /// @return Whether there is trajectory with provided entry index - bool hasTrajectory(Acts::MultiTrajectoryTraits::IndexType entryIndex) const { - return (0 < std::count(m_trackTips.begin(), m_trackTips.end(), entryIndex)); - } - - /// Check if fitted track parameters exists for the given index. - /// - /// @param entryIndex The trajectory entry index - /// @return Whether having fitted track parameters or not - bool hasTrackParameters( - Acts::MultiTrajectoryTraits::IndexType entryIndex) const { - return (0 < m_trackParameters.count(entryIndex)); - } - - /// Access the fitted track parameters for the given index. - /// - /// @param entryIndex The trajectory entry index - /// @return The fitted track parameters of the trajectory - const TrackParameters& trackParameters( - Acts::MultiTrajectoryTraits::IndexType entryIndex) const { - auto it = m_trackParameters.find(entryIndex); - if (it == m_trackParameters.end()) { - throw std::runtime_error( - "No fitted track parameters for trajectory with entry index = " + - std::to_string(entryIndex)); - } - return it->second; - } - - private: - // The multiTrajectory - std::shared_ptr m_multiTrajectory; - // The entry indices of trajectories stored in multiTrajectory - std::vector m_trackTips = {}; - // The fitted parameters at the provided surface for individual trajectories - IndexedParameters m_trackParameters = {}; -}; - -/// Container for multiple trajectories. -using TrajectoriesContainer = std::vector; - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/Geometry/MaterialWiper.hpp b/src/algorithms/tracking/ActsExamples/Geometry/MaterialWiper.hpp deleted file mode 100644 index 081d4572bc..0000000000 --- a/src/algorithms/tracking/ActsExamples/Geometry/MaterialWiper.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019 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/. - -/////////////////////////////////////////////////////////////////// -// MaterialWiper.hpp, Acts project -/////////////////////////////////////////////////////////////////// - -#pragma once - -#include -#include -#include - -// @note This file will go into the acts-core -namespace Acts { - -/// @class MaterialWiper -/// -/// This decorator sets the nulls-material -/// -class MaterialWiper : public IMaterialDecorator { - public: - /// Decorate a surface - /// - /// @param surface the non-cost surface that is decorated - void decorate(Surface& surface) const final { - surface.assignSurfaceMaterial(nullptr); - } - - /// Decorate a TrackingVolume - /// - /// @param volume the non-cost volume that is decorated - virtual void decorate(TrackingVolume& volume) const final { - volume.assignVolumeMaterial(nullptr); - } -}; - -} // namespace Acts diff --git a/src/algorithms/tracking/ActsExamples/LICENSE b/src/algorithms/tracking/ActsExamples/LICENSE deleted file mode 100644 index a612ad9813..0000000000 --- a/src/algorithms/tracking/ActsExamples/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - 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/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/src/algorithms/tracking/ActsExamples/README.md b/src/algorithms/tracking/ActsExamples/README.md deleted file mode 100644 index d7d9616b79..0000000000 --- a/src/algorithms/tracking/ActsExamples/README.md +++ /dev/null @@ -1,6 +0,0 @@ -The files in this directory are based on examples files distributed as part of -the Acts repository under directories `Examples/$1/$2/include/Acts/$1/$2`. -In order to simplify future maintenance, they are provided here with the same -name and in the same directory structure as in the Acts repository. Please do -consider carefully the future maintenance burden accepted when changing this -set of include files. diff --git a/src/algorithms/tracking/ActsExamples/Utilities/GroupBy.hpp b/src/algorithms/tracking/ActsExamples/Utilities/GroupBy.hpp deleted file mode 100644 index 07e0098250..0000000000 --- a/src/algorithms/tracking/ActsExamples/Utilities/GroupBy.hpp +++ /dev/null @@ -1,141 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2020 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 "Range.hpp" - -#include -#include -#include - -namespace ActsExamples { - -/// Proxy for iterating over groups of elements within a container. -/// -/// @note Each group will contain at least one element. -/// -/// Consecutive elements with the same key (as defined by the KeyGetter) are -/// placed in one group. The proxy should always be used as part of a -/// range-based for loop. In combination with structured bindings to reduce the -/// boilerplate, the group iteration can be written as -/// -/// for (auto&& [key, elements] : GroupBy<...>(...)) { -/// // do something with just the key -/// ... -/// -/// // iterate over the group elements -/// for (const auto& element : elements) { -/// ... -/// } -/// } -/// -template -class GroupBy { - public: - /// The key type that identifies elements within a group. - using Key = std::decay_t; - /// A Group is an iterator range with the associated key. - using Group = std::pair>; - /// Iterator type representing the end of the groups. - /// - /// The end iterator will not be dereferenced in C++17 range-based loops. It - /// can thus be a simpler type without the overhead of the full group iterator - /// below. - using GroupEndIterator = Iterator; - /// Iterator type representing a group of elements. - class GroupIterator { - public: - using iterator_category = std::input_iterator_tag; - using value_type = Group; - using difference_type = std::ptrdiff_t; - using pointer = Group*; - using reference = Group&; - - constexpr GroupIterator(const GroupBy& groupBy, Iterator groupBegin) - : m_groupBy(groupBy), - m_groupBegin(groupBegin), - m_groupEnd(groupBy.findEndOfGroup(groupBegin)) {} - /// Pre-increment operator to advance to the next group. - constexpr GroupIterator& operator++() { - // make the current end the new group beginning - std::swap(m_groupBegin, m_groupEnd); - // find the end of the next group starting from the new beginning - m_groupEnd = m_groupBy.findEndOfGroup(m_groupBegin); - return *this; - } - /// Post-increment operator to advance to the next group. - constexpr GroupIterator operator++(int) { - GroupIterator retval = *this; - ++(*this); - return retval; - } - /// Dereference operator that returns the pointed-to group of elements. - constexpr Group operator*() const { - const Key key = (m_groupBegin != m_groupEnd) - ? m_groupBy.m_keyGetter(*m_groupBegin) - : Key(); - return {key, makeRange(m_groupBegin, m_groupEnd)}; - } - - private: - const GroupBy& m_groupBy; - Iterator m_groupBegin; - Iterator m_groupEnd; - - friend constexpr bool operator==(const GroupIterator& lhs, - const GroupEndIterator& rhs) { - return lhs.m_groupBegin == rhs; - } - friend constexpr bool operator!=(const GroupIterator& lhs, - const GroupEndIterator& rhs) { - return not(lhs == rhs); - } - }; - - /// Construct the group-by proxy for an iterator range. - constexpr GroupBy(Iterator begin, Iterator end, - KeyGetter keyGetter = KeyGetter()) - : m_begin(begin), m_end(end), m_keyGetter(std::move(keyGetter)) {} - constexpr GroupIterator begin() const { - return GroupIterator(*this, m_begin); - } - constexpr GroupEndIterator end() const { return m_end; } - constexpr bool empty() const { return m_begin == m_end; } - - private: - Iterator m_begin; - Iterator m_end; - KeyGetter m_keyGetter; - - /// Find the end of the group that starts at the given position. - /// - /// This uses a linear search from the start position and thus has linear - /// complexity in the group size. It does not assume any ordering of the - /// underlying container and is a cache-friendly access pattern. - constexpr Iterator findEndOfGroup(Iterator start) const { - // check for end so we can safely dereference the start iterator. - if (start == m_end) { - return start; - } - // search the first element that does not share a key with the start. - return std::find_if_not(std::next(start), m_end, - [this, start](const auto& x) { - return m_keyGetter(x) == m_keyGetter(*start); - }); - } -}; - -/// Construct the group-by proxy for a container. -template -GroupBy makeGroupBy( - const Container& container, KeyGetter keyGetter) { - return {container.begin(), container.end(), std::move(keyGetter)}; -} - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/Utilities/Options.hpp b/src/algorithms/tracking/ActsExamples/Utilities/Options.hpp deleted file mode 100644 index 330891a024..0000000000 --- a/src/algorithms/tracking/ActsExamples/Utilities/Options.hpp +++ /dev/null @@ -1,76 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017 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 -#include -#include -#include -#include - -namespace ActsExamples { -namespace Options { - -/// Half open [lower,upper) interval type for user options. -/// -/// A missing limit represents an unbounded upper or lower limit. With just -/// one defined limit the interval is just a lower/upper bound; with both -/// limits undefined, the interval is unbounded everywhere and thus contains -/// all possible values. -/// -/// This is intended as a utility type for the user options and not as a -/// variable type for the configuration structs. Simple primitive types should -/// be preferred there. -struct Interval { - std::optional lower; - std::optional upper; -}; - -/// Extract an interval from an input of the form 'lower:upper'. -/// -/// An input of the form `lower:` or `:upper` sets just one of the limits. Any -/// other input leads to an unbounded interval. If the input is `:SECOND` the -/// -/// @note The more common range notation uses `lower-upper` but the `-` -/// separator complicates the parsing of negative values. -std::istream& operator>>(std::istream& is, Interval& interval); - -/// Print an interval as `lower:upper`. -std::ostream& operator<<(std::ostream& os, const Interval& interval); - -/// Extract an interval from an input of the form 'lower:upper'. -/// -/// An input of the form `lower:` or `:upper` sets just one of the limits. Any -/// other input leads to an unbounded interval. If the input is `:SECOND` the -/// -/// @note The more common range notation uses `lower-upper` but the `-` -/// separator complicates the parsing of negative values. -std::istream& operator>>(std::istream& is, std::vector& intervals); - -/// Print an interval as `lower:upper`. -std::ostream& operator<<(std::ostream& os, - const std::vector& intervals); - -} // namespace Options -} // namespace ActsExamples - -using read_series = std::vector; -using read_range = std::vector; -using read_strings = std::vector; - -// Overloads must exist in the `std` namespace so ADL-lookup can find them. -namespace std { - -std::ostream& operator<<(std::ostream& os, const read_series& vec); - -std::ostream& operator<<(std::ostream& os, const read_range& vec); - -std::ostream& operator<<(std::ostream& os, const read_strings& vec); - -} // namespace std diff --git a/src/algorithms/tracking/ActsExamples/Utilities/OptionsFwd.hpp b/src/algorithms/tracking/ActsExamples/Utilities/OptionsFwd.hpp deleted file mode 100644 index b97e61a34f..0000000000 --- a/src/algorithms/tracking/ActsExamples/Utilities/OptionsFwd.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019 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 - -namespace boost { -namespace program_options { -class options_description; -class variables_map; -} // namespace program_options -} // namespace boost - -namespace ActsExamples { -namespace Options { -using Description = ::boost::program_options::options_description; -using Variables = ::boost::program_options::variables_map; -} // namespace Options -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/Utilities/Paths.hpp b/src/algorithms/tracking/ActsExamples/Utilities/Paths.hpp deleted file mode 100644 index fb6226936d..0000000000 --- a/src/algorithms/tracking/ActsExamples/Utilities/Paths.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2017 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 -#include -#include - -namespace ActsExamples { - -/// Ensure that the given directory exists and is writable. -/// -/// @return Canonical path to the directory. -/// -/// Will create missing directories and throw on any error. -std::string ensureWritableDirectory(const std::string& dir); - -/// Join dir and name into one path with correct handling of empty dirs. -std::string joinPaths(const std::string& dir, const std::string& name); - -/// Construct a file path of the form `[/]event-`. -/// -/// @params dir output directory, current directory if empty -/// @params name basic filename -/// @params event event number -std::string perEventFilepath(const std::string& dir, const std::string& name, - size_t event); - -/// Determine the range of available events in a directory of per-event files. -/// -/// @params dir input directory, current directory if empty -/// @params name base filename -/// @return first and last+1 event number -/// @returns {0, 0} when no matching files could be found -/// -/// Event files must be named `[/]event-` to be considered -std::pair determineEventFilesRange(const std::string& dir, - const std::string& name); - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsExamples/Utilities/Range.hpp b/src/algorithms/tracking/ActsExamples/Utilities/Range.hpp deleted file mode 100644 index 2ce5db9684..0000000000 --- a/src/algorithms/tracking/ActsExamples/Utilities/Range.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2019 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 -#include - -namespace ActsExamples { - -/// A wrapper around a pair of iterators to simplify range-based loops. -/// -/// Some standard library algorithms return pairs of iterators to identify -/// a sub-range. This wrapper simplifies the iteration and should be used as -/// follows: -/// -/// for (auto x : makeRange(std::equal_range(...)) { -/// ... -/// } -/// -template -class Range { - public: - Range(Iterator b, Iterator e) : m_begin(b), m_end(e) {} - Range(Range&&) = default; - Range(const Range&) = default; - ~Range() = default; - Range& operator=(Range&&) = default; - Range& operator=(const Range&) = default; - - Iterator begin() const { return m_begin; } - Iterator end() const { return m_end; } - bool empty() const { return m_begin == m_end; } - std::size_t size() const { return std::distance(m_begin, m_end); } - - private: - Iterator m_begin; - Iterator m_end; -}; - -template -Range makeRange(Iterator begin, Iterator end) { - return Range(begin, end); -} - -template -Range makeRange(std::pair range) { - return Range(range.first, range.second); -} - -} // namespace ActsExamples diff --git a/src/algorithms/tracking/ActsGeometryProvider.cc b/src/algorithms/tracking/ActsGeometryProvider.cc index 97e979cc67..22e03ff974 100644 --- a/src/algorithms/tracking/ActsGeometryProvider.cc +++ b/src/algorithms/tracking/ActsGeometryProvider.cc @@ -133,11 +133,13 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, // Set up the converter first Acts::MaterialMapJsonConverter::Config jsonGeoConvConfig; // Set up the json-based decorator - materialDeco = std::make_shared(jsonGeoConvConfig, material_file,acts_init_log_level); + materialDeco = std::make_shared(jsonGeoConvConfig, material_file, acts_init_log_level); } // Geometry identifier hook to write detector ID to extra field - Acts::GeometryIdentifierHook geometryIdHook = [](Acts::GeometryIdentifier identifier, const Acts::Surface& surface) { + class ConvertDD4hepDetectorGeometryIdentifierHook: public Acts::GeometryIdentifierHook { + Acts::GeometryIdentifier decorateIdentifier( + Acts::GeometryIdentifier identifier, const Acts::Surface& surface) const { const auto* dd4hep_det_element = dynamic_cast(surface.associatedDetectorElement()); if (dd4hep_det_element == nullptr) { @@ -145,10 +147,13 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, } // set 8-bit extra field to 8-bit DD4hep detector ID return identifier.setExtra(0xff & dd4hep_det_element->identifier()); + }; }; + auto geometryIdHook = std::make_shared(); // Convert DD4hep geometry to ACTS m_init_log->info("Converting DD4Hep geometry to ACTS..."); + auto logger = eicrecon::getSpdlogLogger("CONV", m_log); Acts::BinningType bTypePhi = Acts::equidistant; Acts::BinningType bTypeR = Acts::equidistant; Acts::BinningType bTypeZ = Acts::equidistant; @@ -160,7 +165,7 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, try { m_trackingGeo = Acts::convertDD4hepDetector( m_dd4hepDetector->world(), - acts_init_log_level, + *logger, bTypePhi, bTypeR, bTypeZ, @@ -173,7 +178,7 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo, geometryIdHook); } catch(std::exception &ex) { - m_init_log->error("Error during DD4Hep -> ACTS geometry conversion. See error reason below..."); + m_init_log->error("Error during DD4Hep -> ACTS geometry conversion: {}", ex.what()); m_init_log->info ("Set parameter acts::InitLogLevel=trace to see conversion info and possibly identify failing geometry"); throw JException(ex.what()); } diff --git a/src/algorithms/tracking/CKFTracking.cc b/src/algorithms/tracking/CKFTracking.cc index bdacf6dcd3..f695a56292 100644 --- a/src/algorithms/tracking/CKFTracking.cc +++ b/src/algorithms/tracking/CKFTracking.cc @@ -6,11 +6,16 @@ #include #include #include +#include #include #include #include -#include +#include +#include +#include +#include #include +#include #include #include #include @@ -20,6 +25,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -38,10 +47,6 @@ #include #include -#include "ActsExamples/EventData/GeometryContainers.hpp" -#include "ActsExamples/EventData/IndexSourceLink.hpp" -#include "ActsExamples/EventData/Measurement.hpp" -#include "ActsExamples/EventData/Track.hpp" #include "ActsGeometryProvider.h" #include "DD4hepBField.h" #include "extensions/spdlog/SpdlogFormatters.h" // IWYU pragma: keep @@ -56,6 +61,7 @@ namespace eicrecon { void CKFTracking::init(std::shared_ptr geo_svc, std::shared_ptr log) { m_log = log; + m_acts_logger = eicrecon::getSpdlogLogger("CKF", m_log); m_geoSvc = geo_svc; @@ -70,13 +76,14 @@ namespace eicrecon { } }, }; - m_trackFinderFunc = CKFTracking::makeCKFTrackingFunction(m_geoSvc->trackingGeometry(), m_BField); + m_trackFinderFunc = CKFTracking::makeCKFTrackingFunction(m_geoSvc->trackingGeometry(), m_BField, logger()); } std::tuple< std::unique_ptr, std::unique_ptr, - std::vector + std::vector, + std::vector > CKFTracking::process(const edm4eic::Measurement2DCollection& meas2Ds, const edm4eic::TrackParametersCollection &init_trk_params) { @@ -109,12 +116,12 @@ namespace eicrecon { loc[Acts::eBoundLoc1] = meas2D.getLoc().b; - Acts::SymMatrix2 cov = Acts::SymMatrix2::Zero(); + Acts::SquareMatrix2 cov = Acts::SquareMatrix2::Zero(); cov(0, 0) = meas2D.getCovariance().xx; cov(1, 1) = meas2D.getCovariance().yy; cov(0, 1) = meas2D.getCovariance().xy; - auto measurement = Acts::makeMeasurement(sourceLink, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + auto measurement = Acts::makeMeasurement(Acts::SourceLink{sourceLink}, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); measurements->emplace_back(std::move(measurement)); hit_index++; @@ -133,7 +140,7 @@ namespace eicrecon { double charge = track_parameter.getCharge(); - Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + Acts::BoundSquareMatrix cov = Acts::BoundSquareMatrix::Zero(); cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = std::pow( track_parameter.getLocError().xx ,2)*Acts::UnitConstants::mm*Acts::UnitConstants::mm; cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = std::pow( track_parameter.getLocError().yy,2)*Acts::UnitConstants::mm*Acts::UnitConstants::mm; cov(Acts::eBoundTheta, Acts::eBoundTheta) = std::pow( track_parameter.getMomentumError().xx,2); @@ -145,31 +152,30 @@ namespace eicrecon { auto pSurface = Acts::Surface::makeShared(Acts::Vector3(0,0,0)); // Create parameters - acts_init_trk_params.emplace_back(pSurface, params, charge, cov); + acts_init_trk_params.emplace_back(pSurface, params, cov, Acts::ParticleHypothesis::pion()); } auto trajectories = std::make_unique(); auto track_parameters = std::make_unique(); - std::vector acts_trajectories; - acts_trajectories.reserve(init_trk_params.size()); - //// Construct a perigee surface as the target surface auto pSurface = Acts::Surface::makeShared(Acts::Vector3{0., 0., 0.}); - ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger(m_log, {"^No tracks found$"})); + ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger("CKF", m_log, {"^No tracks found$"})); Acts::PropagatorPlainOptions pOptions; pOptions.maxSteps = 10000; - ActsExamples::MeasurementCalibrator calibrator{*measurements}; + ActsExamples::PassThroughCalibrator pcalibrator; + ActsExamples::MeasurementCalibratorAdapter calibrator(pcalibrator, *measurements); Acts::GainMatrixUpdater kfUpdater; Acts::GainMatrixSmoother kfSmoother; Acts::MeasurementSelector measSel{m_sourcelinkSelectorCfg}; Acts::CombinatorialKalmanFilterExtensions extensions; - extensions.calibrator.connect<&ActsExamples::MeasurementCalibrator::calibrate>(&calibrator); + extensions.calibrator.connect<&ActsExamples::MeasurementCalibratorAdapter::calibrate>( + &calibrator); extensions.updater.connect< &Acts::GainMatrixUpdater::operator()>( &kfUpdater); @@ -189,149 +195,226 @@ namespace eicrecon { // Set the CombinatorialKalmanFilter options CKFTracking::TrackFinderOptions options( m_geoctx, m_fieldctx, m_calibctx, slAccessorDelegate, - extensions, Acts::LoggerWrapper{logger()}, pOptions, &(*pSurface)); + extensions, pOptions, &(*pSurface)); + + // Create track container + auto trackContainer = std::make_shared(); + auto trackStateContainer = std::make_shared(); + ActsExamples::TrackContainer tracks(trackContainer, trackStateContainer); - auto results = (*m_trackFinderFunc)(acts_init_trk_params, options); + // Add seed number column + tracks.addColumn("seed"); + Acts::TrackAccessor seedNumber("seed"); + // Loop over seeds for (std::size_t iseed = 0; iseed < acts_init_trk_params.size(); ++iseed) { + auto result = + (*m_trackFinderFunc)(acts_init_trk_params.at(iseed), options, tracks); - auto &result = results[iseed]; + if (!result.ok()) { + m_log->debug("Track finding failed for seed {} with error {}", iseed, result.error()); + continue; + } - if (result.ok()) { + // Set seed number for all found tracks + auto& tracksForSeed = result.value(); + for (auto& track : tracksForSeed) { + seedNumber(track) = iseed; + } + } - // Get the track finding output object - auto &trackFindingOutput = result.value(); - // Create a SimMultiTrajectory - auto* multiTrajectory = new ActsExamples::Trajectories( - std::move(trackFindingOutput.fittedStates), - std::move(trackFindingOutput.lastMeasurementIndices), - std::move(trackFindingOutput.fittedParameters) - ); + // Move track states and track container to const containers + // NOTE Using the non-const containers leads to references to + // implicitly converted temporaries inside the Trajectories. + auto constTrackStateContainer = + std::make_shared( + std::move(*trackStateContainer)); - // Get the entry index for the single trajectory - // The trajectory entry indices and the multiTrajectory - const auto& mj = multiTrajectory->multiTrajectory(); - const auto& trackTips = multiTrajectory->tips(); + auto constTrackContainer = + std::make_shared( + std::move(*trackContainer)); + // FIXME JANA2 std::vector requires wrapping ConstTrackContainer, instead of: + //ConstTrackContainer constTracks(constTrackContainer, constTrackStateContainer); + std::vector constTracks_v; + constTracks_v.push_back( + new ActsExamples::ConstTrackContainer( + constTrackContainer, + constTrackStateContainer)); + auto& constTracks = *(constTracks_v.front()); - if (trackTips.empty()) { - m_log->debug("Empty multiTrajectory."); - delete multiTrajectory; - continue; - } + // Seed number column accessor + const Acts::ConstTrackAccessor constSeedNumber("seed"); - const auto& trackTip = trackTips.front(); - // Collect the trajectory summary info - auto trajectoryState = Acts::MultiTrajectoryHelpers::trajectoryState(mj, trackTip); - - // Create trajectory - auto trajectory = trajectories->create(); + // Prepare the output data with MultiTrajectory, per seed + std::vector acts_trajectories; + acts_trajectories.reserve(init_trk_params.size()); - trajectory.setChi2(trajectoryState.chi2Sum); - trajectory.setNdf(trajectoryState.NDF); - trajectory.setNMeasurements(trajectoryState.nMeasurements); - trajectory.setNStates(trajectoryState.nStates); - trajectory.setNOutliers(trajectoryState.nOutliers); - trajectory.setNHoles(trajectoryState.nHoles); - trajectory.setNSharedHits(trajectoryState.nSharedHits); + ActsExamples::Trajectories::IndexedParameters parameters; + std::vector tips; + + std::optional lastSeed; + for (const auto& track : constTracks) { + if (!lastSeed) { + lastSeed = constSeedNumber(track); + } + + if (constSeedNumber(track) != lastSeed.value()) { + // make copies and clear vectors + acts_trajectories.push_back(new ActsExamples::Trajectories( + constTracks.trackStateContainer(), + tips, parameters)); + + tips.clear(); + parameters.clear(); + } + + lastSeed = constSeedNumber(track); + + tips.push_back(track.tipIndex()); + parameters.emplace( + std::pair{track.tipIndex(), + ActsExamples::TrackParameters{track.referenceSurface().getSharedPtr(), + track.parameters(), track.covariance(), + track.particleHypothesis()}}); + } - m_log->debug("trajectory state,measurement, outlier, hole: {} {} {} {}",trajectoryState.nStates,trajectoryState.nMeasurements,trajectoryState.nOutliers,trajectoryState.nHoles); + if (tips.empty()) { + m_log->info("Last trajectory is empty"); + } - for (const auto& measurementChi2 : trajectoryState.measurementChi2) { - trajectory.addToMeasurementChi2(measurementChi2); - } + // last entry: move vectors + acts_trajectories.push_back(new ActsExamples::Trajectories( + constTracks.trackStateContainer(), + std::move(tips), std::move(parameters))); + + + // Loop over trajectories + for (const auto* traj : acts_trajectories) { + // The trajectory entry indices and the multiTrajectory + const auto& trackTips = traj->tips(); + const auto& mj = traj->multiTrajectory(); + if (trackTips.empty()) { + m_log->warn("Empty multiTrajectory."); + continue; + } + + // Loop over all trajectories in a multiTrajectory + // FIXME: we only retain the first trackTips entry + for (auto trackTip : decltype(trackTips){trackTips.front()}) { + // Collect the trajectory summary info + auto trajectoryState = + Acts::MultiTrajectoryHelpers::trajectoryState(mj, trackTip); + + // Check if the reco track has fitted track parameters + if (not traj->hasTrackParameters(trackTip)) { + m_log->warn( + "No fitted track parameters for trajectory with entry index = {}", + trackTip); + continue; + } - for (const auto& outlierChi2 : trajectoryState.outlierChi2) { - trajectory.addToOutlierChi2(outlierChi2); - } + // Create trajectory + auto trajectory = trajectories->create(); + trajectory.setChi2(trajectoryState.chi2Sum); + trajectory.setNdf(trajectoryState.NDF); + trajectory.setNMeasurements(trajectoryState.nMeasurements); + trajectory.setNStates(trajectoryState.nStates); + trajectory.setNOutliers(trajectoryState.nOutliers); + trajectory.setNHoles(trajectoryState.nHoles); + trajectory.setNSharedHits(trajectoryState.nSharedHits); + + m_log->debug("trajectory state, measurement, outlier, hole: {} {} {} {}", + trajectoryState.nStates, + trajectoryState.nMeasurements, + trajectoryState.nOutliers, + trajectoryState.nHoles); + + for (const auto& measurementChi2 : trajectoryState.measurementChi2) { + trajectory.addToMeasurementChi2(measurementChi2); + } - // Get the fitted track parameter - // - if (multiTrajectory->hasTrackParameters(trackTip)) { - - const auto& boundParam = multiTrajectory->trackParameters(trackTip); - const auto& parameter = boundParam.parameters(); - const auto& covariance = *boundParam.covariance(); - - edm4eic::MutableTrackParameters pars{ - 0, // type: track head --> 0 - { - static_cast(parameter[Acts::eBoundLoc0]), - static_cast(parameter[Acts::eBoundLoc1]) - }, - { - static_cast(covariance(Acts::eBoundLoc0, Acts::eBoundLoc0)), - static_cast(covariance(Acts::eBoundLoc1, Acts::eBoundLoc1)), - static_cast(covariance(Acts::eBoundLoc0, Acts::eBoundLoc1)) - }, - static_cast(parameter[Acts::eBoundTheta]), - static_cast(parameter[Acts::eBoundPhi]), - static_cast(parameter[Acts::eBoundQOverP]), - { - static_cast(covariance(Acts::eBoundTheta, Acts::eBoundTheta)), - static_cast(covariance(Acts::eBoundPhi, Acts::eBoundPhi)), - static_cast(covariance(Acts::eBoundQOverP, Acts::eBoundQOverP)), - static_cast(covariance(Acts::eBoundTheta, Acts::eBoundPhi)), - static_cast(covariance(Acts::eBoundTheta, Acts::eBoundQOverP)), - static_cast(covariance(Acts::eBoundPhi, Acts::eBoundQOverP)) - }, - static_cast(parameter[Acts::eBoundTime]), - sqrt(static_cast(covariance(Acts::eBoundTime, Acts::eBoundTime))), - static_cast(boundParam.charge())}; - - track_parameters->push_back(pars); - trajectory.addToTrackParameters(pars); - } + for (const auto& outlierChi2 : trajectoryState.outlierChi2) { + trajectory.addToOutlierChi2(outlierChi2); + } - // save measurement2d to good measurements or outliers according to srclink index - // fix me: ideally, this should be integrated into multitrajectoryhelper - // fix me: should say "OutlierMeasurements" instead of "OutlierHits" etc - mj.visitBackwards(trackTip, [&](const auto& state){ + // Get the fitted track parameter + const auto& boundParam = traj->trackParameters(trackTip); + const auto& parameter = boundParam.parameters(); + const auto& covariance = *boundParam.covariance(); - auto geoID = state.referenceSurface().geometryId().value(); - auto typeFlags = state.typeFlags(); + edm4eic::MutableTrackParameters pars{ + 0, // type: track head --> 0 + { + static_cast(parameter[Acts::eBoundLoc0]), + static_cast(parameter[Acts::eBoundLoc1]) + }, + { + static_cast(covariance(Acts::eBoundLoc0, Acts::eBoundLoc0)), + static_cast(covariance(Acts::eBoundLoc1, Acts::eBoundLoc1)), + static_cast(covariance(Acts::eBoundLoc0, Acts::eBoundLoc1)) + }, + static_cast(parameter[Acts::eBoundTheta]), + static_cast(parameter[Acts::eBoundPhi]), + static_cast(parameter[Acts::eBoundQOverP]), + { + static_cast(covariance(Acts::eBoundTheta, Acts::eBoundTheta)), + static_cast(covariance(Acts::eBoundPhi, Acts::eBoundPhi)), + static_cast(covariance(Acts::eBoundQOverP, Acts::eBoundQOverP)), + static_cast(covariance(Acts::eBoundTheta, Acts::eBoundPhi)), + static_cast(covariance(Acts::eBoundTheta, Acts::eBoundQOverP)), + static_cast(covariance(Acts::eBoundPhi, Acts::eBoundQOverP)) + }, + static_cast(parameter[Acts::eBoundTime]), + sqrt(static_cast(covariance(Acts::eBoundTime, Acts::eBoundTime))), + static_cast(boundParam.charge())}; - // find the associated hit (2D measurement) with state sourcelink index - // fix me: calibrated or not? - if(state.hasUncalibrated()){ + track_parameters->push_back(pars); + trajectory.addToTrackParameters(pars); - std::size_t srclink_index = static_cast(state.uncalibrated()).index(); + // save measurement2d to good measurements or outliers according to srclink index + // fix me: ideally, this should be integrated into multitrajectoryhelper + // fix me: should say "OutlierMeasurements" instead of "OutlierHits" etc + mj.visitBackwards(trackTip, [&](const auto& state) { - // no hit on this state/surface, skip - if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) { - m_log->debug("No hit found on geo id={}", geoID); + auto geoID = state.referenceSurface().geometryId().value(); + auto typeFlags = state.typeFlags(); - }else{ - auto meas2D = meas2Ds[srclink_index]; - if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) { - trajectory.addToMeasurementHits(meas2D); - m_log->debug("Measurement on geo id={}, index={}, loc={},{}", - geoID, srclink_index, meas2D.getLoc().a, meas2D.getLoc().b); + // find the associated hit (2D measurement) with state sourcelink index + // fix me: calibrated or not? + if (state.hasUncalibratedSourceLink()) { - } - else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) { - trajectory.addToOutlierHits(meas2D); - m_log->debug("Outlier on geo id={}, index={}, loc={},{}", - geoID, srclink_index, meas2D.getLoc().a, meas2D.getLoc().b); + std::size_t srclink_index = state.getUncalibratedSourceLink().template get().index(); - } - } - } + // no hit on this state/surface, skip + if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) { + m_log->debug("No hit found on geo id={}", geoID); - }); - acts_trajectories.push_back(std::move(multiTrajectory)); + } else { + auto meas2D = meas2Ds[srclink_index]; + if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) { + trajectory.addToMeasurementHits(meas2D); + m_log->debug("Measurement on geo id={}, index={}, loc={},{}", + geoID, srclink_index, meas2D.getLoc().a, meas2D.getLoc().b); - }else { + } + else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) { + trajectory.addToOutlierHits(meas2D); + m_log->debug("Outlier on geo id={}, index={}, loc={},{}", + geoID, srclink_index, meas2D.getLoc().a, meas2D.getLoc().b); - m_log->debug("Track finding failed for truth seed {} with error: {}", iseed, result.error()); + } + } + } - } + }); + } } - return std::make_tuple(std::move(trajectories), std::move(track_parameters), std::move(acts_trajectories)); + return std::make_tuple(std::move(trajectories), std::move(track_parameters), std::move(acts_trajectories), std::move(constTracks_v)); } } // namespace eicrecon diff --git a/src/algorithms/tracking/CKFTracking.h b/src/algorithms/tracking/CKFTracking.h index 247370f7f9..a4778ec0d9 100644 --- a/src/algorithms/tracking/CKFTracking.h +++ b/src/algorithms/tracking/CKFTracking.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include #include @@ -11,7 +12,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include #include @@ -20,9 +25,6 @@ #include #include -#include "ActsExamples/EventData/IndexSourceLink.hpp" -#include "ActsExamples/EventData/Track.hpp" -#include "ActsExamples/EventData/Trajectories.hpp" #include "CKFTrackingConfig.h" #include "DD4hepBField.h" #include "algorithms/interfaces/WithPodConfig.h" @@ -43,8 +45,8 @@ namespace eicrecon { using TrackFinderOptions = Acts::CombinatorialKalmanFilterOptions; - using TrackFinderResult = std::vector>>; + using TrackFinderResult = + Acts::Result>; /// Find function that takes the above parameters /// @note This is separated into a virtual interface to keep compilation units @@ -53,8 +55,9 @@ namespace eicrecon { public: virtual ~CKFTrackingFunction() = default; - virtual TrackFinderResult operator()(const ActsExamples::TrackParametersContainer &, - const TrackFinderOptions &) const = 0; + virtual TrackFinderResult operator()(const ActsExamples::TrackParameters&, + const TrackFinderOptions&, + ActsExamples::TrackContainer&) const = 0; }; /// Create the track finder function implementation. @@ -62,7 +65,8 @@ namespace eicrecon { /// contains shared_ptr anyways. static std::shared_ptr makeCKFTrackingFunction( std::shared_ptr trackingGeometry, - std::shared_ptr magneticField); + std::shared_ptr magneticField, + const Acts::Logger& logger); CKFTracking(); @@ -71,13 +75,15 @@ namespace eicrecon { std::tuple< std::unique_ptr, std::unique_ptr, - std::vector + std::vector, + std::vector > process(const edm4eic::Measurement2DCollection& meas2Ds, const edm4eic::TrackParametersCollection &init_trk_params); private: std::shared_ptr m_log; + std::shared_ptr m_acts_logger{nullptr}; std::shared_ptr m_trackFinderFunc; std::shared_ptr m_geoSvc; @@ -87,6 +93,9 @@ namespace eicrecon { Acts::MagneticFieldContext m_fieldctx; Acts::MeasurementSelector::Config m_sourcelinkSelectorCfg; + + /// Private access to the logging instance + const Acts::Logger& logger() const { return *m_acts_logger; } }; } // namespace eicrecon::Reco diff --git a/src/algorithms/tracking/CKFTrackingFunction.cc b/src/algorithms/tracking/CKFTrackingFunction.cc index 408da47981..121864ed42 100644 --- a/src/algorithms/tracking/CKFTrackingFunction.cc +++ b/src/algorithms/tracking/CKFTrackingFunction.cc @@ -1,7 +1,10 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck, Sylvester Joosten +#include +#include #include +#include #include #include #include @@ -10,40 +13,47 @@ #include #include #include -#include +#include +#include #include #include #include +#include #include "ActsExamples/EventData/Track.hpp" #include "CKFTracking.h" namespace eicrecon{ + using Updater = Acts::GainMatrixUpdater; using Smoother = Acts::GainMatrixSmoother; using Stepper = Acts::EigenStepper<>; using Navigator = Acts::Navigator; using Propagator = Acts::Propagator; + using CKF = Acts::CombinatorialKalmanFilter; + using TrackContainer = + Acts::TrackContainer; + /** Finder implementation . * * \ingroup track */ struct CKFTrackingFunctionImpl -: public eicrecon::CKFTracking::CKFTrackingFunction { + : public eicrecon::CKFTracking::CKFTrackingFunction { CKF trackFinder; CKFTrackingFunctionImpl(CKF&& f) : trackFinder(std::move(f)) {} - eicrecon::CKFTracking::TrackFinderResult - operator()(const ActsExamples::TrackParametersContainer& initialParameters, - const eicrecon::CKFTracking::TrackFinderOptions& options) - const override - { - return trackFinder.findTracks(initialParameters, options); + eicrecon::CKFTracking::TrackFinderResult operator()( + const ActsExamples::TrackParameters& initialParameters, + const eicrecon::CKFTracking::TrackFinderOptions& options, + TrackContainer& tracks) const override { + return trackFinder.findTracks(initialParameters, options, tracks); }; }; @@ -54,7 +64,8 @@ namespace eicrecon { std::shared_ptr CKFTracking::makeCKFTrackingFunction( std::shared_ptr trackingGeometry, - std::shared_ptr magneticField) + std::shared_ptr magneticField, + const Acts::Logger& logger) { Stepper stepper(std::move(magneticField)); Navigator::Config cfg{trackingGeometry}; @@ -64,7 +75,7 @@ namespace eicrecon { Navigator navigator(cfg); Propagator propagator(std::move(stepper), std::move(navigator)); - CKF trackFinder(std::move(propagator)); + CKF trackFinder(std::move(propagator), logger.cloneWithSuffix("CKF")); // build the track finder functions. owns the track finder object. return std::make_shared(std::move(trackFinder)); diff --git a/src/algorithms/tracking/DD4hepBField.cc b/src/algorithms/tracking/DD4hepBField.cc index 6011186663..b473b66599 100644 --- a/src/algorithms/tracking/DD4hepBField.cc +++ b/src/algorithms/tracking/DD4hepBField.cc @@ -10,6 +10,7 @@ #include #include #include +#include namespace eicrecon::BField { @@ -23,7 +24,18 @@ namespace eicrecon::BField { auto fieldObj = m_det->field(); auto field = fieldObj.magneticField(pos) * (Acts::UnitConstants::T / dd4hep::tesla); - return Acts::Result::success({field.x(), field.y(),field.z()}); + + // FIXME Acts doesn't seem to like exact zero components + if (field.x() * field.y() * field.z() == 0) { + static dd4hep::Direction epsilon{ + std::numeric_limits::epsilon(), + std::numeric_limits::epsilon(), + std::numeric_limits::epsilon() + }; + field += epsilon; + } + + return Acts::Result::success({field.x(), field.y(), field.z()}); } Acts::Result DD4hepBField::getFieldGradient(const Acts::Vector3& position, diff --git a/src/algorithms/tracking/IterativeVertexFinder.cc b/src/algorithms/tracking/IterativeVertexFinder.cc index f965fa331d..52f2971994 100644 --- a/src/algorithms/tracking/IterativeVertexFinder.cc +++ b/src/algorithms/tracking/IterativeVertexFinder.cc @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -18,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -51,25 +54,29 @@ std::unique_ptr eicrecon::IterativeVertexFinder::prod using VertexFinder = Acts::IterativeVertexFinder; using VertexFinderOptions = Acts::VertexingOptions; + ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger("IVF", m_log)); + Acts::EigenStepper<> stepper(m_BField); - auto propagator = std::make_shared(stepper); - ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger(m_log)); - Acts::PropagatorOptions opts(m_geoctx, m_fieldctx, Acts::LoggerWrapper{logger()}); + // Set up propagator with void navigator + auto propagator = std::make_shared( + stepper, Acts::detail::VoidNavigator{}, logger().cloneWithSuffix("Prop")); + Acts::PropagatorOptions opts(m_geoctx, m_fieldctx); // Setup the vertex fitter VertexFitter::Config vertexFitterCfg; VertexFitter vertexFitter(vertexFitterCfg); // Setup the track linearizer Linearizer::Config linearizerCfg(m_BField, propagator); - Linearizer linearizer(linearizerCfg); + Linearizer linearizer(linearizerCfg, logger().cloneWithSuffix("HelLin")); // Setup the seed finder ImpactPointEstimator::Config ipEstCfg(m_BField, propagator); ImpactPointEstimator ipEst(ipEstCfg); VertexSeeder::Config seederCfg(ipEst); VertexSeeder seeder(seederCfg); // Set up the actual vertex finder - VertexFinder::Config finderCfg(vertexFitter, linearizer, std::move(seeder), ipEst); + VertexFinder::Config finderCfg(vertexFitter, std::move(linearizer), + std::move(seeder), ipEst); finderCfg.maxVertices = m_cfg.m_maxVertices; finderCfg.reassignTracksAfterFirstFit = m_cfg.m_reassignTracksAfterFirstFit; VertexFinder finder(finderCfg); diff --git a/src/algorithms/tracking/OrthogonalTrackSeedingConfig.h b/src/algorithms/tracking/OrthogonalTrackSeedingConfig.h index 84e74a8d5b..848a5561b6 100644 --- a/src/algorithms/tracking/OrthogonalTrackSeedingConfig.h +++ b/src/algorithms/tracking/OrthogonalTrackSeedingConfig.h @@ -54,7 +54,6 @@ namespace eicrecon { float m_zOriginWeightFactor = 1.; float m_compatSeedWeight = 200.; size_t m_compatSeedLimit = 2; - bool m_curvatureSortingInFilter = false; float m_seedWeightIncrement = 0; /////////////////////////////////////// diff --git a/src/algorithms/tracking/TrackProjector.cc b/src/algorithms/tracking/TrackProjector.cc index e3775c9392..ca99b96919 100644 --- a/src/algorithms/tracking/TrackProjector.cc +++ b/src/algorithms/tracking/TrackProjector.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include #include -#include "ActsExamples/EventData/Trajectories.hpp" #include "TrackProjector.h" #include "extensions/spdlog/SpdlogFormatters.h" // IWYU pragma: keep diff --git a/src/algorithms/tracking/TrackProjector.h b/src/algorithms/tracking/TrackProjector.h index c4d3f34291..771a5f27ff 100644 --- a/src/algorithms/tracking/TrackProjector.h +++ b/src/algorithms/tracking/TrackProjector.h @@ -4,12 +4,12 @@ #pragma once +#include #include #include #include #include -#include "ActsExamples/EventData/Trajectories.hpp" #include "ActsGeometryProvider.h" #include "TrackProjectorConfig.h" #include "algorithms/interfaces/WithPodConfig.h" diff --git a/src/algorithms/tracking/TrackPropagation.cc b/src/algorithms/tracking/TrackPropagation.cc index d453a5b1c2..d5b86fb883 100644 --- a/src/algorithms/tracking/TrackPropagation.cc +++ b/src/algorithms/tracking/TrackPropagation.cc @@ -2,15 +2,17 @@ // Copyright (C) 2022, 2023 Wenqing Fan, Barak Schmookler, Whitney Armstrong, Sylvester Joosten, Dmitry Romanov, Christopher Dilks #include +#include #include -#include -#include #include #include #include #include #include +#include #include +#include +#include #include #include #include @@ -26,8 +28,6 @@ #include #include -#include "ActsExamples/EventData/Track.hpp" -#include "ActsExamples/EventData/Trajectories.hpp" #include "ActsGeometryProvider.h" #include "TrackPropagation.h" #include "extensions/spdlog/SpdlogToActs.h" @@ -203,9 +203,9 @@ namespace eicrecon { Stepper stepper(magneticField); Propagator propagator(stepper); - ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger(m_log)); + ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger("PROP", m_log)); - Acts::PropagatorOptions<> options(m_geoContext, m_fieldContext, Acts::LoggerWrapper{logger()}); + Acts::PropagatorOptions<> options(m_geoContext, m_fieldContext); auto result = propagator.propagate(initial_bound_parameters, *targetSurf, options); diff --git a/src/algorithms/tracking/TrackPropagation.h b/src/algorithms/tracking/TrackPropagation.h index 3f268713b5..3220ee7f7c 100644 --- a/src/algorithms/tracking/TrackPropagation.h +++ b/src/algorithms/tracking/TrackPropagation.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -16,7 +17,6 @@ #include #include -#include "ActsExamples/EventData/Trajectories.hpp" #include "ActsGeometryProvider.h" diff --git a/src/algorithms/tracking/TrackSeeding.cc b/src/algorithms/tracking/TrackSeeding.cc index bd3c195a6e..e7a7f72761 100644 --- a/src/algorithms/tracking/TrackSeeding.cc +++ b/src/algorithms/tracking/TrackSeeding.cc @@ -4,23 +4,23 @@ #include "TrackSeeding.h" -#include // IWYU pragma: keep FIXME KDTree missing in SeedFinderOrthogonal.hpp until Acts v23.0.0 - #include -#include #include #include #include #include +#include #include #include #include #include +#include // IWYU pragma: keep FIXME KDTree missing in SeedFinderOrthogonal.hpp until Acts v23.0.0 #include #include #include #include #include +#include #include #include #include @@ -56,7 +56,6 @@ void eicrecon::TrackSeeding::configure() { m_seedFilterConfig.zOriginWeightFactor = m_cfg.m_zOriginWeightFactor; m_seedFilterConfig.compatSeedWeight = m_cfg.m_compatSeedWeight; m_seedFilterConfig.compatSeedLimit = m_cfg.m_compatSeedLimit; - m_seedFilterConfig.curvatureSortingInFilter = m_cfg.m_curvatureSortingInFilter; m_seedFilterConfig.seedWeightIncrement = m_cfg.m_seedWeightIncrement; m_seedFilterConfig.centralSeedConfirmationRange = Acts::SeedConfirmationRangeConfig{ @@ -81,6 +80,8 @@ void eicrecon::TrackSeeding::configure() { m_cfg.m_minImpactSeedConf_forw }; + m_seedFilterConfig = m_seedFilterConfig.toInternalUnits(); + // Finder parameters m_seedFinderConfig.seedFilter = std::make_unique>(Acts::SeedFilter(m_seedFilterConfig)); m_seedFinderConfig.rMax = m_cfg.m_rMax; @@ -97,38 +98,35 @@ void eicrecon::TrackSeeding::configure() { m_seedFinderConfig.sigmaScattering = m_cfg.m_sigmaScattering; m_seedFinderConfig.radLengthPerSeed = m_cfg.m_radLengthPerSeed; m_seedFinderConfig.minPt = m_cfg.m_minPt; - m_seedFinderConfig.bFieldInZ = m_cfg.m_bFieldInZ; - m_seedFinderConfig.beamPos = Acts::Vector2(m_cfg.m_beamPosX, m_cfg.m_beamPosY); m_seedFinderConfig.impactMax = m_cfg.m_impactMax; m_seedFinderConfig.rMinMiddle = m_cfg.m_rMinMiddle; m_seedFinderConfig.rMaxMiddle = m_cfg.m_rMaxMiddle; - // Taken from SeedingOrthogonalAlgorithm.cpp, e.g. - // calculation of scattering using the highland formula - // convert pT to p once theta angle is known - m_seedFinderConfig.highland = - (13.6 * Acts::UnitConstants::MeV) * std::sqrt(m_seedFinderConfig.radLengthPerSeed) * - (1 + 0.038 * std::log(m_seedFinderConfig.radLengthPerSeed)); - float maxScatteringAngle = m_seedFinderConfig.highland / m_seedFinderConfig.minPt; - m_seedFinderConfig.maxScatteringAngle2 = maxScatteringAngle * maxScatteringAngle; + m_seedFinderOptions.beamPos = Acts::Vector2(m_cfg.m_beamPosX, m_cfg.m_beamPosY); + m_seedFinderOptions.bFieldInZ = m_cfg.m_bFieldInZ; - // Helix radius in homogeneous magnetic field - // in ACTS Units of GeV, mm, and GeV/(e*mm) - m_seedFinderConfig.pTPerHelixRadius = m_seedFinderConfig.bFieldInZ; - - m_seedFinderConfig.minHelixDiameter2 = - std::pow(m_seedFinderConfig.minPt * 2 / m_seedFinderConfig.pTPerHelixRadius,2); - - m_seedFinderConfig.pT2perRadius = - std::pow(m_seedFinderConfig.highland / m_seedFinderConfig.pTPerHelixRadius,2); + m_seedFinderConfig = + m_seedFinderConfig.toInternalUnits().calculateDerivedQuantities(); + m_seedFinderOptions = + m_seedFinderOptions.toInternalUnits().calculateDerivedQuantities( + m_seedFinderConfig); } std::unique_ptr eicrecon::TrackSeeding::produce(const edm4eic::TrackerHitCollection& trk_hits) { std::vector spacePoints = getSpacePoints(trk_hits); - Acts::SeedFinderOrthogonal finder(m_seedFinderConfig); - eicrecon::SeedContainer seeds = finder.createSeeds(spacePoints); + Acts::SeedFinderOrthogonal finder(m_seedFinderConfig); // FIXME move into class scope + + std::function( + const eicrecon::SpacePoint *sp)> + create_coordinates = [](const eicrecon::SpacePoint *sp) { + Acts::Vector3 position(sp->x(), sp->y(), sp->z()); + Acts::Vector2 variance(sp->varianceR(), sp->varianceZ()); + return std::make_pair(position, variance); + }; + + eicrecon::SeedContainer seeds = finder.createSeeds(m_seedFinderOptions, spacePoints, create_coordinates); std::unique_ptr trackparams = makeTrackParams(seeds); diff --git a/src/algorithms/tracking/TrackSeeding.h b/src/algorithms/tracking/TrackSeeding.h index 16871d7cd2..165c4b01b7 100644 --- a/src/algorithms/tracking/TrackSeeding.h +++ b/src/algorithms/tracking/TrackSeeding.h @@ -4,14 +4,14 @@ #pragma once -#include // IWYU pragma: keep FIXME size_t missing in SeedConfirmationRangeConfig.hpp until Acts 27.2.0 (maybe even later) - #include #include +#include #include #include #include #include +#include // IWYU pragma: keep FIXME size_t missing in SeedConfirmationRangeConfig.hpp until Acts 27.2.0 (maybe even later) #include #include #include @@ -41,6 +41,7 @@ namespace eicrecon { Acts::MagneticFieldContext m_fieldctx; Acts::SeedFilterConfig m_seedFilterConfig; + Acts::SeedFinderOptions m_seedFinderOptions; Acts::SeedFinderOrthogonalConfig m_seedFinderConfig; int determineCharge(std::vector>& positions) const; diff --git a/src/algorithms/tracking/TrackerMeasurementFromHits.cc b/src/algorithms/tracking/TrackerMeasurementFromHits.cc index 9b288be4cb..a1abdeacb5 100644 --- a/src/algorithms/tracking/TrackerMeasurementFromHits.cc +++ b/src/algorithms/tracking/TrackerMeasurementFromHits.cc @@ -58,7 +58,7 @@ namespace eicrecon { // For now, one hit = one measurement. for (const auto *hit: trk_hits) { - Acts::SymMatrix2 cov = Acts::SymMatrix2::Zero(); + Acts::SquareMatrix2 cov = Acts::SquareMatrix2::Zero(); cov(0, 0) = hit->getPositionError().xx * mm_acts * mm_acts; // note mm = 1 (Acts) cov(1, 1) = hit->getPositionError().yy * mm_acts * mm_acts; cov(0, 1) = 0.0; diff --git a/src/benchmarks/reconstruction/TRACKINGcheck/TRACKINGcheckProcessor.cc b/src/benchmarks/reconstruction/TRACKINGcheck/TRACKINGcheckProcessor.cc index 1dfb586a47..334063a817 100644 --- a/src/benchmarks/reconstruction/TRACKINGcheck/TRACKINGcheckProcessor.cc +++ b/src/benchmarks/reconstruction/TRACKINGcheck/TRACKINGcheckProcessor.cc @@ -3,15 +3,15 @@ // Template for this file generated with eicmkplugin.py // -#include +#include #include +#include #include #include #include #include #include "TRACKINGcheckProcessor.h" -#include "algorithms/tracking/ActsExamples/EventData/Trajectories.hpp" #include "services/rootfile/RootFile_service.h" //------------------------------------------- diff --git a/src/benchmarks/reconstruction/tracking_efficiency/TrackingEfficiency_processor.cc b/src/benchmarks/reconstruction/tracking_efficiency/TrackingEfficiency_processor.cc index 8c9461e67b..85a484e1d4 100644 --- a/src/benchmarks/reconstruction/tracking_efficiency/TrackingEfficiency_processor.cc +++ b/src/benchmarks/reconstruction/tracking_efficiency/TrackingEfficiency_processor.cc @@ -1,9 +1,9 @@ #include "TrackingEfficiency_processor.h" #include +#include #include -#include -#include +#include #include #include #include @@ -26,7 +26,6 @@ #include #include -#include "algorithms/tracking/ActsExamples/EventData/Trajectories.hpp" #include "extensions/spdlog/SpdlogExtensions.h" #include "services/log/Log_service.h" #include "services/rootfile/RootFile_service.h" diff --git a/src/detectors/DRICH/DRICH.cc b/src/detectors/DRICH/DRICH.cc index 36b2358fa1..83df4a7816 100644 --- a/src/detectors/DRICH/DRICH.cc +++ b/src/detectors/DRICH/DRICH.cc @@ -113,7 +113,7 @@ extern "C" { // charged particle tracks app->Add(new JChainMultifactoryGeneratorT( "DRICHTracks", - {"CentralCKFActsTrajectories"}, + {"CentralCKFActsTrajectories", "CentralCKFActsTracks"}, {"DRICHAerogelTracks", "DRICHGasTracks"}, track_cfg, app diff --git a/src/extensions/spdlog/SpdlogToActs.h b/src/extensions/spdlog/SpdlogToActs.h index fa98311e12..b3b5216e21 100644 --- a/src/extensions/spdlog/SpdlogToActs.h +++ b/src/extensions/spdlog/SpdlogToActs.h @@ -106,7 +106,6 @@ class SpdlogPrintPolicy final : public Acts::Logging::OutputPrintPolicy { } } - #if 0 // name() and clone() require Acts 22.0.0, https://github.com/acts-project/acts/commit/85b4b292c980f358ed6ba3ce19cdcee361c8ea5b /// Fulfill @c OutputPrintPolicy interface. This policy doesn't actually have a /// name, so the assumption is that somewhere in the decorator hierarchy, /// there is something that returns a name without delegating to a wrappee, @@ -127,7 +126,6 @@ class SpdlogPrintPolicy final : public Acts::Logging::OutputPrintPolicy { (void)name; return std::make_unique(m_out); }; - #endif private: /// pointer to destination output stream @@ -138,11 +136,14 @@ class SpdlogPrintPolicy final : public Acts::Logging::OutputPrintPolicy { }; inline std::unique_ptr getSpdlogLogger( + const std::string& name, std::shared_ptr log, std::vector suppressions = {}) { const Acts::Logging::Level lvl = SpdlogToActsLevel(log->level()); - auto output = std::make_unique(log, suppressions); + auto output = std::make_unique( + std::make_unique(log, suppressions), + name); auto print = std::make_unique(lvl); return std::make_unique(std::move(output), std::move(print)); } diff --git a/src/global/pid/RichTrack_factory.cc b/src/global/pid/RichTrack_factory.cc index 5e1f6e6795..2e22893962 100644 --- a/src/global/pid/RichTrack_factory.cc +++ b/src/global/pid/RichTrack_factory.cc @@ -3,6 +3,7 @@ #include "RichTrack_factory.h" +#include #include #include #include @@ -71,9 +72,15 @@ void eicrecon::RichTrack_factory::BeginRun(const std::shared_ptr & //----------------------------------------------------------------------------- void eicrecon::RichTrack_factory::Process(const std::shared_ptr &event) { + auto input_tags = GetInputTags(); + + // collect tracks from first input tag + auto tracks = event->Get(GetInputTags().back()); + input_tags.pop_back(); + // collect all trajectories from all input tags std::vector trajectories; - for(const auto& input_tag : GetInputTags()) { + for(const auto& input_tag : input_tags) { try { for(const auto traj : event->Get(input_tag)) trajectories.push_back(traj); diff --git a/src/global/tracking/CKFTracking_factory.cc b/src/global/tracking/CKFTracking_factory.cc index 07d76a9f9f..ba91fa4083 100644 --- a/src/global/tracking/CKFTracking_factory.cc +++ b/src/global/tracking/CKFTracking_factory.cc @@ -4,6 +4,7 @@ #include "CKFTracking_factory.h" +#include #include #include #include @@ -54,7 +55,7 @@ void eicrecon::CKFTracking_factory::Process(const std::shared_ptr try { // RUN TRACKING ALGORITHM - auto [trajectories, track_parameters, acts_trajectories] = m_tracking_algo.process( + auto [trajectories, track_parameters, acts_trajectories, acts_tracks] = m_tracking_algo.process( *meas2Ds, *seed_track_parameters); @@ -62,6 +63,7 @@ void eicrecon::CKFTracking_factory::Process(const std::shared_ptr SetCollection(GetOutputTags()[0], std::move(trajectories)); SetCollection(GetOutputTags()[1], std::move(track_parameters)); SetData(GetOutputTags()[2], std::move(acts_trajectories)); + SetData(GetOutputTags()[3], std::move(acts_tracks)); } catch(std::exception &e) { throw JException(e.what()); diff --git a/src/global/tracking/CKFTracking_factory.h b/src/global/tracking/CKFTracking_factory.h index bb1e435624..117f7442fd 100644 --- a/src/global/tracking/CKFTracking_factory.h +++ b/src/global/tracking/CKFTracking_factory.h @@ -4,14 +4,12 @@ #pragma once +#include #include #include #include -#include -#include #include #include -#include #include #include @@ -39,6 +37,7 @@ namespace eicrecon { DeclarePodioOutput(GetOutputTags()[0]); DeclarePodioOutput(GetOutputTags()[1]); DeclareOutput(GetOutputTags()[2]); + DeclareOutput(GetOutputTags()[3]); } diff --git a/src/global/tracking/IterativeVertexFinder_factory.cc b/src/global/tracking/IterativeVertexFinder_factory.cc index c2ac69f9fd..07faf48033 100644 --- a/src/global/tracking/IterativeVertexFinder_factory.cc +++ b/src/global/tracking/IterativeVertexFinder_factory.cc @@ -2,6 +2,7 @@ // Subject to the terms in the LICENSE file found in the top-level directory. // +#include #include #include #include @@ -54,8 +55,8 @@ void eicrecon::IterativeVertexFinder_factory::ChangeRun( void eicrecon::IterativeVertexFinder_factory::Process(const std::shared_ptr& event) { - std::string input_tag = GetInputTags()[0]; - auto trajectories = event->Get(input_tag); + auto trajectories = event->Get(GetInputTags()[0]); + auto tracks = event->Get(GetInputTags()[1]); m_log->debug("Process method"); diff --git a/src/global/tracking/IterativeVertexFinder_factory.h b/src/global/tracking/IterativeVertexFinder_factory.h index 3b4aa1eac4..3c58bfa949 100644 --- a/src/global/tracking/IterativeVertexFinder_factory.h +++ b/src/global/tracking/IterativeVertexFinder_factory.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/global/tracking/TrackProjector_factory.cc b/src/global/tracking/TrackProjector_factory.cc index 58fd1f4874..716861ba7f 100644 --- a/src/global/tracking/TrackProjector_factory.cc +++ b/src/global/tracking/TrackProjector_factory.cc @@ -2,6 +2,8 @@ // Subject to the terms in the LICENSE file found in the top-level directory. // +#include +#include #include #include #include @@ -10,7 +12,6 @@ #include "TrackProjector.h" #include "TrackProjector_factory.h" -#include "algorithms/tracking/ActsExamples/EventData/Trajectories.hpp" #include "services/geometry/acts/ACTSGeo_service.h" #include "services/io/podio/JFactoryPodioT.h" @@ -37,8 +38,8 @@ namespace eicrecon { void TrackProjector_factory::Process(const std::shared_ptr &event) { // Now we check that user provided an input names - std::string input_tag = GetInputTags()[0]; - auto trajectories = event->Get(input_tag); + auto trajectories = event->Get(GetInputTags()[0]); + auto tracks = event->Get(GetInputTags()[1]); try { auto track_segments = m_track_projector_algo.execute(trajectories); diff --git a/src/global/tracking/TrackProjector_factory.h b/src/global/tracking/TrackProjector_factory.h index e48dcaad14..21b48590dc 100644 --- a/src/global/tracking/TrackProjector_factory.h +++ b/src/global/tracking/TrackProjector_factory.h @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/global/tracking/TrackPropagation_factory.cc b/src/global/tracking/TrackPropagation_factory.cc index a510404e4b..d53a2860c6 100644 --- a/src/global/tracking/TrackPropagation_factory.cc +++ b/src/global/tracking/TrackPropagation_factory.cc @@ -9,11 +9,12 @@ #include #include #include +#include +#include #include #include #include #include -#include #include #include #include @@ -52,6 +53,7 @@ void eicrecon::TrackPropagation_factory::Init() { void eicrecon::TrackPropagation_factory::Process(const std::shared_ptr &event) { auto trajectories = event->Get(GetInputTags()[0]); + auto tracks = event->Get(GetInputTags()[1]); edm4eic::TrackSegmentCollection propagated_tracks; diff --git a/src/global/tracking/tracking.cc b/src/global/tracking/tracking.cc index 490881f869..b5260f4cb5 100644 --- a/src/global/tracking/tracking.cc +++ b/src/global/tracking/tracking.cc @@ -60,6 +60,7 @@ void InitPlugin(JApplication *app) { "CentralCKFTrajectories", "CentralCKFTrackParameters", "CentralCKFActsTrajectories", + "CentralCKFActsTracks", }, app )); @@ -77,19 +78,20 @@ void InitPlugin(JApplication *app) { "CentralCKFSeededTrajectories", "CentralCKFSeededTrackParameters", "CentralCKFSeededActsTrajectories", + "CentralCKFSeededActsTracks", }, app )); app->Add(new JChainFactoryGeneratorT( - {"CentralCKFActsTrajectories"}, "CentralTrackSegments")); + {"CentralCKFActsTrajectories", "CentralCKFSeededActsTracks"}, "CentralTrackSegments")); app->Add(new JChainFactoryGeneratorT( - {"CentralCKFActsTrajectories"}, "CentralTrackVertices")); + {"CentralCKFActsTrajectories", "CentralCKFSeededActsTracks"}, "CentralTrackVertices")); app->Add(new JChainMultifactoryGeneratorT( "CalorimeterTrackPropagator", - {"CentralCKFActsTrajectories"}, + {"CentralCKFActsTrajectories", "CentralCKFSeededActsTracks"}, {"CalorimeterTrackProjections"}, app )); diff --git a/src/tests/track_propagation_test/TrackPropagationTest_processor.cc b/src/tests/track_propagation_test/TrackPropagationTest_processor.cc index b8ae562a2e..2e5037b02a 100644 --- a/src/tests/track_propagation_test/TrackPropagationTest_processor.cc +++ b/src/tests/track_propagation_test/TrackPropagationTest_processor.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ #include #include "TrackPropagationTest_processor.h" -#include "algorithms/tracking/ActsExamples/EventData/Trajectories.hpp" #include "services/geometry/acts/ACTSGeo_service.h" #include "services/rootfile/RootFile_service.h" diff --git a/src/tests/track_seeding_test/TrackSeedingTest_processor.cc b/src/tests/track_seeding_test/TrackSeedingTest_processor.cc index a25ebe4c97..9259c05e75 100644 --- a/src/tests/track_seeding_test/TrackSeedingTest_processor.cc +++ b/src/tests/track_seeding_test/TrackSeedingTest_processor.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include "TrackSeedingTest_processor.h" -#include "algorithms/tracking/ActsExamples/EventData/Trajectories.hpp" #include "services/geometry/acts/ACTSGeo_service.h" #include "services/rootfile/RootFile_service.h"