From 4c322744b0f75529fe039f0060f2d268834e3c73 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 17 Nov 2023 21:10:13 +0000 Subject: [PATCH] fix: migration to Acts 30.3.2 --- CMakeLists.txt | 3 + JugAlgo/src/components/AlgoServiceSvc.cpp | 6 +- JugBase/JugBase/ACTSLogger.h | 30 ++- JugBase/JugBase/Acts/MaterialWiper.hpp | 43 ---- JugBase/src/ACTSLogger.cpp | 3 +- JugBase/src/components/GeoSvc.cpp | 7 +- .../src/components/CalorimeterBirksCorr.cpp | 1 + JugDigi/src/components/CalorimeterHitDigi.cpp | 3 +- .../src/components/PhotoMultiplierDigi.cpp | 1 + JugDigi/src/components/SiliconTrackerDigi.cpp | 1 + .../src/components/CalorimeterHitsMerger.cpp | 2 +- JugReco/src/components/ImagingClusterReco.cpp | 8 +- JugTrack/CMakeLists.txt | 1 + JugTrack/JugTrack/GeometryContainers.hpp | 188 ------------------ JugTrack/JugTrack/Index.hpp | 55 ----- JugTrack/JugTrack/IndexContainers.hpp | 47 ----- JugTrack/JugTrack/IndexSourceLink.hpp | 70 ------- JugTrack/JugTrack/Measurement.hpp | 58 ------ JugTrack/JugTrack/ProtoTrack.hpp | 19 -- JugTrack/JugTrack/SourceLinks.h | 95 --------- JugTrack/JugTrack/Track.hpp | 22 -- JugTrack/JugTrack/Trajectories.hpp | 105 ---------- JugTrack/JugTrack/Utilities/GroupBy.hpp | 141 ------------- JugTrack/JugTrack/Utilities/Helpers.hpp | 126 ------------ JugTrack/JugTrack/Utilities/Options.hpp | 76 ------- JugTrack/JugTrack/Utilities/OptionsFwd.hpp | 23 --- JugTrack/JugTrack/Utilities/Paths.hpp | 46 ----- JugTrack/JugTrack/Utilities/Range.hpp | 56 ------ JugTrack/src/components/CKFTracking.cpp | 128 +++++++++--- JugTrack/src/components/CKFTracking.h | 33 +-- .../src/components/CKFTrackingFunction.cpp | 16 +- .../components/ConformalXYPeakProtoTracks.cpp | 8 +- .../src/components/FinderAlgoTemplate.cpp | 6 +- .../components/HoughTransformProtoTracks.cpp | 6 +- .../src/components/ParticlesFromTrackFit.cpp | 8 +- .../src/components/ProtoTrackMatching.cpp | 10 +- .../components/SingleTrackSourceLinker.cpp | 28 +-- .../src/components/TrackParamACTSSeeding.cpp | 97 ++++----- .../src/components/TrackParamClusterInit.cpp | 12 +- .../TrackParamImagingClusterInit.cpp | 12 +- .../src/components/TrackParamTruthInit.cpp | 8 +- .../TrackParamVertexClusterInit.cpp | 15 +- JugTrack/src/components/TrackProjector.cpp | 8 +- .../src/components/TrackerSourceLinker.cpp | 21 +- JugTrack/src/components/TruthTrackSeeding.cpp | 2 +- .../{ => disabled}/TrackFittingAlgorithm.cpp | 25 ++- .../{ => disabled}/TrackFittingAlgorithm.h | 34 ++-- .../{ => disabled}/TrackFittingFunction.cpp | 4 +- .../calorimetry/src/ClusterRecoCoG.cpp | 2 +- 49 files changed, 315 insertions(+), 1404 deletions(-) delete mode 100644 JugBase/JugBase/Acts/MaterialWiper.hpp delete mode 100644 JugTrack/JugTrack/GeometryContainers.hpp delete mode 100644 JugTrack/JugTrack/Index.hpp delete mode 100644 JugTrack/JugTrack/IndexContainers.hpp delete mode 100644 JugTrack/JugTrack/IndexSourceLink.hpp delete mode 100644 JugTrack/JugTrack/Measurement.hpp delete mode 100644 JugTrack/JugTrack/ProtoTrack.hpp delete mode 100644 JugTrack/JugTrack/SourceLinks.h delete mode 100644 JugTrack/JugTrack/Track.hpp delete mode 100644 JugTrack/JugTrack/Trajectories.hpp delete mode 100644 JugTrack/JugTrack/Utilities/GroupBy.hpp delete mode 100644 JugTrack/JugTrack/Utilities/Helpers.hpp delete mode 100644 JugTrack/JugTrack/Utilities/Options.hpp delete mode 100644 JugTrack/JugTrack/Utilities/OptionsFwd.hpp delete mode 100644 JugTrack/JugTrack/Utilities/Paths.hpp delete mode 100644 JugTrack/JugTrack/Utilities/Range.hpp rename JugTrack/src/components/{ => disabled}/TrackFittingAlgorithm.cpp (89%) rename JugTrack/src/components/{ => disabled}/TrackFittingAlgorithm.h (65%) rename JugTrack/src/components/{ => disabled}/TrackFittingFunction.cpp (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfd1ceba..23c78f52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,9 @@ endif() add_definitions("-DActs_VERSION_MAJOR=${Acts_VERSION_MAJOR}") add_definitions("-DActs_VERSION_MINOR=${Acts_VERSION_MINOR}") add_definitions("-DActs_VERSION_PATCH=${Acts_VERSION_PATCH}") +# Get ActsCore path for ActsExamples include +get_target_property(ActsCore_LOCATION ActsCore LOCATION) +get_filename_component(ActsCore_PATH ${ActsCore_LOCATION} DIRECTORY) ## algorithms dependency option(USE_SYSTEM_ALGORITHMS "Use system-provided algorithms" OFF) diff --git a/JugAlgo/src/components/AlgoServiceSvc.cpp b/JugAlgo/src/components/AlgoServiceSvc.cpp index 4c571fca..51f917b2 100644 --- a/JugAlgo/src/components/AlgoServiceSvc.cpp +++ b/JugAlgo/src/components/AlgoServiceSvc.cpp @@ -46,7 +46,7 @@ StatusCode AlgoServiceSvc::initialize() { static_cast(msgLevel() > 0 ? msgLevel() - 1 : 0)}; info() << "Setting up algorithms::LogSvc with default level " << algorithms::logLevelName(level) << endmsg; - serviceSvc.setInit([=](auto&& logger) { + serviceSvc.setInit([this,level](auto&& logger) { this->info() << "Initializing the algorithms::LogSvc using the Gaudi logger" << endmsg; logger.defaultLevel(level); logger.init( @@ -75,7 +75,7 @@ StatusCode AlgoServiceSvc::initialize() { << "Make sure you have GeoSvc in the right order in the configuration." << endmsg; return StatusCode::FAILURE; } - serviceSvc.setInit([=](auto&& g) { + serviceSvc.setInit([this](auto&& g) { this->info() << "Initializing algorithms::RandomSvc with the Juggler GeoSvc" << endmsg; g.init(m_geoSvc->detector()); }); @@ -83,7 +83,7 @@ StatusCode AlgoServiceSvc::initialize() { info() << "Setting up algorithms::RandomSvc\n" << " --> using internal STL 64-bit MT engine\n" << " --> seed set to" << m_randomSeed << endmsg; - serviceSvc.setInit([=](auto&& r) { + serviceSvc.setInit([this](auto&& r) { this->info() << "Initializing the algorithms::RandomSvc" << endmsg; r.setProperty("seed", m_randomSeed); r.init(); diff --git a/JugBase/JugBase/ACTSLogger.h b/JugBase/JugBase/ACTSLogger.h index 9c1b0bae..3c1471c3 100644 --- a/JugBase/JugBase/ACTSLogger.h +++ b/JugBase/JugBase/ACTSLogger.h @@ -15,7 +15,7 @@ */ class GaudiFilterPolicy : public Acts::Logging::OutputFilterPolicy { public: - GaudiFilterPolicy(IMessageSvc* owner) : m_owner(owner) {} + GaudiFilterPolicy(IMessageSvc* owner, const Acts::Logging::Level& lvl) : m_owner(owner), m_level(lvl) {} bool doPrint(const Acts::Logging::Level& lvl) const { @@ -47,17 +47,41 @@ class GaudiFilterPolicy : public Acts::Logging::OutputFilterPolicy { return l >= m_owner->outputLevel(); } + /// Get the level of this filter policy + /// @return the levele + Acts::Logging::Level level() const override { return m_level; } + + /// Make a copy of this filter policy with a new level + /// @param level the new level + /// @return the new copy + std::unique_ptr clone(Acts::Logging::Level level) const override { + return std::make_unique(m_owner, level); + } + private: IMessageSvc* m_owner; + Acts::Logging::Level m_level; }; class GaudiPrintPolicy : public Acts::Logging::OutputPrintPolicy { public: - GaudiPrintPolicy(IMessageSvc* owner) : m_messenger(owner) {} + GaudiPrintPolicy(IMessageSvc* owner) : m_owner(owner),m_messenger(owner) {} + + const std::string& name() const override { + return m_name; + }; + + /// Make a copy of this print policy with a new name + /// @param name the new name + /// @return the copy + std::unique_ptr clone( + const std::string& name) const override { + (void)name; + return std::make_unique(m_owner); + }; void setName(std::string name) { m_name = name; - } void flush(const Acts::Logging::Level& lvl, const std::string& input) { diff --git a/JugBase/JugBase/Acts/MaterialWiper.hpp b/JugBase/JugBase/Acts/MaterialWiper.hpp deleted file mode 100644 index 9b5eec2a..00000000 --- a/JugBase/JugBase/Acts/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 "Acts/Geometry/TrackingVolume.hpp" -#include "Acts/Material/IMaterialDecorator.hpp" -#include "Acts/Surfaces/Surface.hpp" - -// @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/JugBase/src/ACTSLogger.cpp b/JugBase/src/ACTSLogger.cpp index 9e52dfce..f62c65b0 100644 --- a/JugBase/src/ACTSLogger.cpp +++ b/JugBase/src/ACTSLogger.cpp @@ -9,12 +9,11 @@ namespace Acts { std::unique_ptr getDefaultLogger(const std::string& name, const Logging::Level& lvl, std::ostream* /* unused */) { using namespace Logging; - //ServiceHandle* msgSvc = new ServiceHandle("MessageSvc", name); ServiceHandle msgSvc("MessageSvc", name); msgSvc->setOutputLevel(lvl + 1); auto printPol = std::make_unique(&(*msgSvc)); printPol->setName(name); return std::make_unique(std::move(printPol), - std::make_unique(&(*msgSvc))); + std::make_unique(&(*msgSvc), lvl)); } } diff --git a/JugBase/src/components/GeoSvc.cpp b/JugBase/src/components/GeoSvc.cpp index c6d3554e..f65a2042 100644 --- a/JugBase/src/components/GeoSvc.cpp +++ b/JugBase/src/components/GeoSvc.cpp @@ -9,7 +9,6 @@ #include "DD4hep/Printout.h" #include "JugBase/ACTSLogger.h" -#include "JugBase/Acts/MaterialWiper.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Plugins/DD4hep/ConvertDD4hepDetector.hpp" @@ -113,12 +112,10 @@ StatusCode GeoSvc::initialize() { // Set up the json-based decorator m_materialDeco = std::make_shared( jsonGeoConvConfig, m_jsonFileName, m_actsLoggingLevel); - } else { - m_log << MSG::WARNING << "no ACTS materials map has been loaded" << endmsg; - m_materialDeco = std::make_shared(); } // Convert DD4hep geometry to ACTS + auto logger = Acts::getDefaultLogger("CONV", m_actsLoggingLevel); Acts::BinningType bTypePhi = Acts::equidistant; Acts::BinningType bTypeR = Acts::equidistant; Acts::BinningType bTypeZ = Acts::equidistant; @@ -128,7 +125,7 @@ StatusCode GeoSvc::initialize() { using Acts::sortDetElementsByID; m_trackingGeo = Acts::convertDD4hepDetector( m_dd4hepGeo->world(), - m_actsLoggingLevel, + *logger, bTypePhi, bTypeR, bTypeZ, diff --git a/JugDigi/src/components/CalorimeterBirksCorr.cpp b/JugDigi/src/components/CalorimeterBirksCorr.cpp index 392f1bfe..379c1de9 100644 --- a/JugDigi/src/components/CalorimeterBirksCorr.cpp +++ b/JugDigi/src/components/CalorimeterBirksCorr.cpp @@ -10,6 +10,7 @@ #include #include +#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiAlg/GaudiTool.h" #include "GaudiAlg/Transformer.h" #include "GaudiKernel/PhysicalConstants.h" diff --git a/JugDigi/src/components/CalorimeterHitDigi.cpp b/JugDigi/src/components/CalorimeterHitDigi.cpp index a108d765..988a95ec 100644 --- a/JugDigi/src/components/CalorimeterHitDigi.cpp +++ b/JugDigi/src/components/CalorimeterHitDigi.cpp @@ -14,6 +14,7 @@ #include #include +#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiAlg/GaudiTool.h" #include "GaudiAlg/Transformer.h" #include "GaudiKernel/PhysicalConstants.h" @@ -147,7 +148,7 @@ namespace Jug::Digi { return StatusCode::FAILURE; } id_mask = ~id_mask; - info() << fmt::format("ID mask in {:s}: {:#064b}", m_readout, id_mask) << endmsg; + info() << fmt::format("ID mask in {:s}: {:#064b}", m_readout.value(), id_mask) << endmsg; return StatusCode::SUCCESS; } diff --git a/JugDigi/src/components/PhotoMultiplierDigi.cpp b/JugDigi/src/components/PhotoMultiplierDigi.cpp index 4a5abee9..73c3c21e 100644 --- a/JugDigi/src/components/PhotoMultiplierDigi.cpp +++ b/JugDigi/src/components/PhotoMultiplierDigi.cpp @@ -15,6 +15,7 @@ #include #include +#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiAlg/Transformer.h" #include "GaudiAlg/GaudiTool.h" #include "GaudiKernel/RndmGenerators.h" diff --git a/JugDigi/src/components/SiliconTrackerDigi.cpp b/JugDigi/src/components/SiliconTrackerDigi.cpp index d37bfec3..b69b0852 100644 --- a/JugDigi/src/components/SiliconTrackerDigi.cpp +++ b/JugDigi/src/components/SiliconTrackerDigi.cpp @@ -5,6 +5,7 @@ #include #include "Gaudi/Property.h" +#include "GaudiAlg/GaudiAlgorithm.h" #include "GaudiAlg/GaudiTool.h" #include "GaudiAlg/Transformer.h" #include "GaudiKernel/PhysicalConstants.h" diff --git a/JugReco/src/components/CalorimeterHitsMerger.cpp b/JugReco/src/components/CalorimeterHitsMerger.cpp index db0beccd..2f8e3240 100644 --- a/JugReco/src/components/CalorimeterHitsMerger.cpp +++ b/JugReco/src/components/CalorimeterHitsMerger.cpp @@ -100,7 +100,7 @@ class CalorimeterHitsMerger : public GaudiAlgorithm { return StatusCode::FAILURE; } id_mask = ~id_mask; - info() << fmt::format("ID mask in {:s}: {:#064b}", m_readout, id_mask) << endmsg; + info() << fmt::format("ID mask in {:s}: {:#064b}", m_readout.value(), id_mask) << endmsg; return StatusCode::SUCCESS; } diff --git a/JugReco/src/components/ImagingClusterReco.cpp b/JugReco/src/components/ImagingClusterReco.cpp index 75673f81..514f418f 100644 --- a/JugReco/src/components/ImagingClusterReco.cpp +++ b/JugReco/src/components/ImagingClusterReco.cpp @@ -8,7 +8,10 @@ * Author: Chao Peng (ANL), 06/02/2021 */ #include "fmt/format.h" +#pragma GCC diagnostic push // save the actual diag context +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // disable maybe warnings #include +#pragma GCC diagnostic pop // restore previous diag context #include #include "Gaudi/Property.h" @@ -38,7 +41,6 @@ #include "edm4hep/utils/vector_utils.h" using namespace Gaudi::Units; -using namespace Eigen; namespace Jug::Reco { @@ -329,7 +331,7 @@ class ImagingClusterReco : public GaudiAlgorithm { mean_pos = mean_pos / nrows; // fill position data - MatrixXd pos(nrows, 3); + Eigen::MatrixXd pos(nrows, 3); int ir = 0; for (const auto& layer : layers) { if ((layer.getNhits() > 0) && (layer.getHits(0).getLayer() <= m_trackStopLayer)) { @@ -341,7 +343,7 @@ class ImagingClusterReco : public GaudiAlgorithm { } } - JacobiSVD svd(pos, ComputeThinU | ComputeThinV); + Eigen::JacobiSVD svd(pos, Eigen::ComputeThinU | Eigen::ComputeThinV); const auto dir = svd.matrixV().col(0); // theta and phi return {std::acos(dir(2)), std::atan2(dir(1), dir(0))}; diff --git a/JugTrack/CMakeLists.txt b/JugTrack/CMakeLists.txt index 47a3bebc..d8114245 100644 --- a/JugTrack/CMakeLists.txt +++ b/JugTrack/CMakeLists.txt @@ -17,6 +17,7 @@ gaudi_add_module(JugTrackPlugins EDM4EIC::edm4eic DD4hep::DDRec ActsCore + ${ActsCore_PATH}/libActsExamplesFramework.so ) target_include_directories(JugTrackPlugins PUBLIC diff --git a/JugTrack/JugTrack/GeometryContainers.hpp b/JugTrack/JugTrack/GeometryContainers.hpp deleted file mode 100644 index 9ccb0f81..00000000 --- a/JugTrack/JugTrack/GeometryContainers.hpp +++ /dev/null @@ -1,188 +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 "JugTrack/Utilities/GroupBy.hpp" -#include "JugTrack/Utilities/Range.hpp" -#include "Acts/Geometry/GeometryIdentifier.hpp" -#include "Acts/Surfaces/Surface.hpp" - -#include -#include -#include - -#include -#include - -namespace Jug { -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 hierachy 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 FW diff --git a/JugTrack/JugTrack/Index.hpp b/JugTrack/JugTrack/Index.hpp deleted file mode 100644 index cb4eed81..00000000 --- a/JugTrack/JugTrack/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 Jug { - -/// 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/JugTrack/JugTrack/IndexContainers.hpp b/JugTrack/JugTrack/IndexContainers.hpp deleted file mode 100644 index f42ff044..00000000 --- a/JugTrack/JugTrack/IndexContainers.hpp +++ /dev/null @@ -1,47 +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 - -#include - -namespace FW { - -/// 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 IndexMultimap invertIndexMultimap( - const IndexMultimap& multimap) { - // switch key-value without enforcing the new ordering (linear copy) - typename IndexMultimap::sequence_type unordered; - unordered.reserve(multimap.size()); - for (const auto& keyValue : multimap) { - // value is now the key and the key is now the value - unordered.emplace_back(keyValue.second, keyValue.first); - } - // adopting the unordered sequence will reestablish the correct order - IndexMultimap inverse; - inverse.adopt_sequence(std::move(unordered)); - return inverse; -} - -} // namespace FW diff --git a/JugTrack/JugTrack/IndexSourceLink.hpp b/JugTrack/JugTrack/IndexSourceLink.hpp deleted file mode 100644 index aebc1ee5..00000000 --- a/JugTrack/JugTrack/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 "JugTrack/GeometryContainers.hpp" -#include "JugTrack/Index.hpp" - -#include "Acts/EventData/SourceLink.hpp" -#include "Acts/Surfaces/Surface.hpp" - -#include - -namespace Jug { - - /// 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 represenation 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 Jug diff --git a/JugTrack/JugTrack/Measurement.hpp b/JugTrack/JugTrack/Measurement.hpp deleted file mode 100644 index 48c28b7f..00000000 --- a/JugTrack/JugTrack/Measurement.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck - -#ifndef JugTrack_Measurement_HH -#define JugTrack_Measurement_HH - -#include "Acts/EventData/Measurement.hpp" -#include "Acts/EventData/MultiTrajectory.hpp" -#include "Acts/EventData/SourceLink.hpp" -#include "Acts/EventData/VectorMultiTrajectory.hpp" -#include "JugTrack/IndexSourceLink.hpp" - -#include -#include - -namespace Jug { - - /// 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 Jug - -#endif diff --git a/JugTrack/JugTrack/ProtoTrack.hpp b/JugTrack/JugTrack/ProtoTrack.hpp deleted file mode 100644 index 4cb86fc5..00000000 --- a/JugTrack/JugTrack/ProtoTrack.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong - -#ifndef JugTrack_ProtoTrack_HH -#define JugTrack_ProtoTrack_HH - -#include -#include - -namespace Jug { - -/// A proto track is a collection of hits identified by their indices. -using ProtoTrack = std::vector; -/// Container of proto tracks. Each proto track is identified by its index. -using ProtoTrackContainer = std::vector; - -} // namespace FW - -#endif diff --git a/JugTrack/JugTrack/SourceLinks.h b/JugTrack/JugTrack/SourceLinks.h deleted file mode 100644 index 0598edac..00000000 --- a/JugTrack/JugTrack/SourceLinks.h +++ /dev/null @@ -1,95 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong - -#ifndef JUG_RECO_SourceLinks_HH -#define JUG_RECO_SourceLinks_HH - -#include "Acts/EventData/Measurement.hpp" -#include "JugTrack/GeometryContainers.hpp" - -#include -#include - -#include "edm4eic/TrackerHitCollection.h" - - -namespace Jug { - -/** Source Link for simulation in the acts-framework. - * - * https://github.com/acts-project/acts/blob/master/Core/include/Acts/EventData/SourceLinkConcept.hpp - * The source link stores the measuremts, surface, and the associated simulated - * truth hit. - * - */ -class SourceLink { - - private: - Acts::BoundVector m_values; - Acts::BoundMatrix m_cov; - size_t m_dim = 2; - // store geo id copy to avoid indirection via truth hit - int32_t m_index; - Acts::GeometryIdentifier m_geometryId; - // need to store pointers to make the object copyable - const Acts::Surface* m_surface; - //const ActsFatras::Hit* m_truthHit; - const edm4eic::TrackerHit* m_Hit ; - - public: - SourceLink(const Acts::Surface& surface, //const ActsFatras::Hit& truthHit, - size_t dim, int32_t index, Acts::BoundVector values, Acts::BoundMatrix cov) - : m_values(values), - m_cov(cov), - m_dim(dim), - m_index(index), - m_geometryId(0),//truthHit.geometryId()), - m_surface(&surface){} - //m_truthHit(&truthHit) {} - /// Must be default_constructible to satisfy SourceLinkConcept. - SourceLink() = default; - SourceLink(SourceLink&&) = default; - SourceLink(const SourceLink&) = default; - SourceLink& operator=(SourceLink&&) = default; - SourceLink& operator=(const SourceLink&) = default; - - constexpr Acts::GeometryIdentifier geometryId() const { return m_geometryId; } - constexpr const Acts::Surface& referenceSurface() const { return *m_surface; } - //constexpr const ActsFatras::Hit& truthHit() const { return *m_truthHit; } - - Acts::FittableMeasurement operator*() const { - if (m_dim == 0) { - throw std::runtime_error("Cannot create dim 0 measurement"); - } else if (m_dim == 1) { - return Acts::Measurement{ - m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<1, 1>(), - m_values[0]}; - } else if (m_dim == 2) { - return Acts::Measurement{ - m_surface->getSharedPtr(), *this, m_cov.topLeftCorner<2, 2>(), - m_values[0], m_values[1]}; - } else { - throw std::runtime_error("Dim " + std::to_string(m_dim) + - " currently not supported."); - } - } - - friend constexpr bool operator==(const SourceLink& lhs, - const SourceLink& rhs) { - - return (lhs.geometryId() == rhs.geometryId()) && (lhs.m_index == rhs.m_index); - //lhs.m_truthHit == rhs.m_truthHit; - } - friend constexpr bool operator!=(const SourceLink& lhs, - const SourceLink& rhs) { - return not(lhs == rhs); - } -}; - -/// Store source links ordered by geometry identifier. -using SourceLinkContainer = GeometryIdMultiset; -} // namespace Jug - -#endif diff --git a/JugTrack/JugTrack/Track.hpp b/JugTrack/JugTrack/Track.hpp deleted file mode 100644 index ec1ee629..00000000 --- a/JugTrack/JugTrack/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 "Acts/EventData/TrackParameters.hpp" - -#include - -namespace Jug { - -/// (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/JugTrack/JugTrack/Trajectories.hpp b/JugTrack/JugTrack/Trajectories.hpp deleted file mode 100644 index 0a0a9931..00000000 --- a/JugTrack/JugTrack/Trajectories.hpp +++ /dev/null @@ -1,105 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (C) 2022 Whitney Armstrong - -#ifndef JugTrack_Trajectories_HH -#define JugTrack_Trajectories_HH - -#include "Acts/EventData/MultiTrajectory.hpp" -#include "Acts/EventData/VectorMultiTrajectory.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Track.hpp" - -#include -#include -#include - -namespace Jug { - -/// 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 Jug -#endif diff --git a/JugTrack/JugTrack/Utilities/GroupBy.hpp b/JugTrack/JugTrack/Utilities/GroupBy.hpp deleted file mode 100644 index 6f651de9..00000000 --- a/JugTrack/JugTrack/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 "JugTrack/Utilities/Range.hpp" - -#include -#include -#include - -namespace Jug { - -/// 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; - } - /// Derefence 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 FW diff --git a/JugTrack/JugTrack/Utilities/Helpers.hpp b/JugTrack/JugTrack/Utilities/Helpers.hpp deleted file mode 100644 index 73a0473f..00000000 --- a/JugTrack/JugTrack/Utilities/Helpers.hpp +++ /dev/null @@ -1,126 +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 "TEfficiency.h" -#include "TFitResult.h" -#include "TFitResultPtr.h" -#include "TH1F.h" -#include "TH2F.h" -#include "TProfile.h" -#include "TROOT.h" - -namespace Jug { - -namespace PlotHelpers { -/// @brief Nested binning struct for booking plots -struct Binning { - Binning(){}; - - Binning(std::string bTitle, int bins, float bMin, float bMax) - : title(bTitle), nBins(bins), min(bMin), max(bMax){}; - - std::string title; ///< title to be displayed - int nBins; ///< number of bins - float min; ///< minimum value - float max; ///< maximum value -}; - -/// @brief book a 1D histogram -/// @param histName the name of histogram -/// @param histTitle the title of histogram -/// @param varBinning the binning info of variable -/// @return histogram pointer -TH1F* bookHisto(const char* histName, const char* histTitle, - const Binning& varBinning); - -/// @brief book a 2D histogram -/// @param histName the name of histogram -/// @param histTitle the title of histogram -/// @param varXBinning the binning info of variable at x axis -/// @param varYBinning the binning info of variable at y axis -/// @return histogram pointer -TH2F* bookHisto(const char* histName, const char* histTitle, - const Binning& varXBinning, const Binning& varYBinning); - -/// @brief fill a 1D histogram -/// @param hist histogram to fill -/// @param value value to fill -/// @param weight weight to fill -void fillHisto(TH1F* hist, float value, float weight = 1.0); - -/// @brief fill a 2D histogram -/// @param hist histogram to fill -/// @param xValue x value to fill -/// @param yValue y value to fill -/// @param weight weight to fill -void fillHisto(TH2F* hist, float xValue, float yValue, float weight = 1.0); - -/// @brief extract details, i.e. mean and width of a 1D histogram and fill -/// them into histograms -/// @param inputHist histogram to investigate -/// @param j which bin number of meanHist and widthHist to fill -/// @param meanHist histogram to fill the mean value of inputHist -/// @param widthHist histogram to fill the width value of inputHist -/// -/// @todo write specialized helper class to extract details of hists -void anaHisto(TH1D* inputHist, int j, TH1F* meanHist, TH1F* widthHist); - -/// @brief book a 1D efficiency plot -/// @param effName the name of plot -/// @param effTitle the title of plot -/// @param varBinning the binning info of variable -/// @return TEfficiency pointer -TEfficiency* bookEff(const char* effName, const char* effTitle, - const Binning& varBinning); - -/// @brief book a 2D efficiency plot -/// @param effName the name of plot -/// @param effTitle the title of plot -/// @param varXBinning the binning info of variable at x axis -/// @param varYBinning the binning info of variable at y axis -/// @return TEfficiency pointer -TEfficiency* bookEff(const char* effName, const char* effTitle, - const Binning& varXBinning, const Binning& varYBinning); - -/// @brief fill a 1D efficiency plot -/// @param efficiency plot to fill -/// @param value value to fill -/// @param status bool to denote passed or not -void fillEff(TEfficiency* efficiency, float value, bool status); - -/// @brief fill a 2D efficiency plot -/// @param efficiency plot to fill -/// @param xValue x value to fill -/// @param yValue y value to fill -/// @param status bool to denote passed or not -void fillEff(TEfficiency* efficiency, float xValue, float yValue, bool status); - -/// @brief book a TProfile plot -/// @param profName the name of plot -/// @param profTitle the title of plot -/// @param varXBinning the binning info of variable at x axis -/// @param varYBinning the binning info of variable at y axis -/// @return TProfile pointer -TProfile* bookProf(const char* profName, const char* profTitle, - const Binning& varXBinning, const Binning& varYBinning); - -/// @brief fill a TProfile plot -/// @param profile plot to fill -/// @param xValue xvalue to fill -/// @param yValue yvalue to fill -/// @param weight weight to fill -void fillProf(TProfile* profile, float xValue, float yValue, - float weight = 1.0); - -} // namespace PlotHelpers - -} // namespace FW diff --git a/JugTrack/JugTrack/Utilities/Options.hpp b/JugTrack/JugTrack/Utilities/Options.hpp deleted file mode 100644 index c2cb1a18..00000000 --- a/JugTrack/JugTrack/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 FW { -//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 FW -// -//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/JugTrack/JugTrack/Utilities/OptionsFwd.hpp b/JugTrack/JugTrack/Utilities/OptionsFwd.hpp deleted file mode 100644 index f9fe295c..00000000 --- a/JugTrack/JugTrack/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 FW { -namespace Options { -using Description = ::boost::program_options::options_description; -using Variables = ::boost::program_options::variables_map; -} // namespace Options -} // namespace FW diff --git a/JugTrack/JugTrack/Utilities/Paths.hpp b/JugTrack/JugTrack/Utilities/Paths.hpp deleted file mode 100644 index 3cba59c0..00000000 --- a/JugTrack/JugTrack/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 Jug { - -/// 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 FW diff --git a/JugTrack/JugTrack/Utilities/Range.hpp b/JugTrack/JugTrack/Utilities/Range.hpp deleted file mode 100644 index 6ffc599a..00000000 --- a/JugTrack/JugTrack/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 Jug { - -/// 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 FW diff --git a/JugTrack/src/components/CKFTracking.cpp b/JugTrack/src/components/CKFTracking.cpp index d680496e..de811aae 100644 --- a/JugTrack/src/components/CKFTracking.cpp +++ b/JugTrack/src/components/CKFTracking.cpp @@ -19,6 +19,7 @@ #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" +#include "Acts/TrackFinding/SourceLinkAccessorConcept.hpp" #include "Acts/TrackFitting/GainMatrixSmoother.hpp" #include "Acts/TrackFitting/GainMatrixUpdater.hpp" #include "Acts/Propagator/EigenStepper.hpp" @@ -33,21 +34,27 @@ #include "JugBase/IGeoSvc.h" #include "JugBase/BField/DD4hepBField.h" -#include "JugTrack/GeometryContainers.hpp" -#include "JugTrack/Measurement.hpp" -#include "JugTrack/Index.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" +#include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/MeasurementCalibration.hpp" +#include "ActsExamples/EventData/Index.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include +#include #include "edm4eic/TrackerHitCollection.h" #include #include +#include +#include #include #include #include +template<> struct fmt::formatter : fmt::ostream_formatter {}; static const std::map s_msgMap = { {MSG::DEBUG, Acts::Logging::DEBUG}, @@ -68,6 +75,7 @@ namespace Jug::Reco { declareProperty("inputSourceLinks", m_inputSourceLinks, ""); declareProperty("inputMeasurements", m_inputMeasurements, ""); declareProperty("inputInitialTrackParameters", m_inputInitialTrackParameters, ""); + declareProperty("outputTracks", m_outputTracks, ""); declareProperty("outputTrajectories", m_outputTrajectories, ""); } @@ -110,9 +118,8 @@ namespace Jug::Reco { const auto* const measurements = m_inputMeasurements.get(); //// Prepare the output data with MultiTrajectory - // TrajectoryContainer trajectories; - auto* trajectories = m_outputTrajectories.createAndPut(); - trajectories->reserve(init_trk_params->size()); + auto* acts_trajectories = m_outputTrajectories.createAndPut(); + 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.}); @@ -122,14 +129,17 @@ namespace Jug::Reco { Acts::PropagatorPlainOptions pOptions; pOptions.maxSteps = 10000; - 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<&MeasurementCalibrator::calibrate>(&calibrator); + extensions.calibrator.connect< + &ActsExamples::MeasurementCalibratorAdapter::calibrate>( + &calibrator); extensions.updater.connect< &Acts::GainMatrixUpdater::operator()>( &kfUpdater); @@ -140,37 +150,101 @@ namespace Jug::Reco { .connect<&Acts::MeasurementSelector::select>( &measSel); - IndexSourceLinkAccessor slAccessor; + ActsExamples::IndexSourceLinkAccessor slAccessor; slAccessor.container = src_links; - Acts::SourceLinkAccessorDelegate + Acts::SourceLinkAccessorDelegate slAccessorDelegate; - slAccessorDelegate.connect<&IndexSourceLinkAccessor::range>(&slAccessor); + slAccessorDelegate.connect<&ActsExamples::IndexSourceLinkAccessor::range>(&slAccessor); // Set the CombinatorialKalmanFilter options CKFTracking::TrackFinderOptions options( m_geoctx, m_fieldctx, m_calibctx, slAccessorDelegate, - extensions, Acts::LoggerWrapper{logger()}, pOptions, &(*pSurface)); + extensions, pOptions, &(*pSurface)); - auto results = (*m_trackFinderFunc)(*init_trk_params, options); + // Create track container + auto trackContainer = std::make_shared(); + auto trackStateContainer = std::make_shared(); + ActsExamples::TrackContainer tracks(trackContainer, trackStateContainer); + // Add seed number column + tracks.addColumn("seed"); + Acts::TrackAccessor seedNumber("seed"); + + // Loop over seeds for (std::size_t iseed = 0; iseed < init_trk_params->size(); ++iseed) { + auto result = + (*m_trackFinderFunc)(init_trk_params->at(iseed), options, tracks); + + if (!result.ok()) { + debug() << fmt::format("Track finding failed for seed {} with error {}", iseed, result.error()) << endmsg; + continue; + } - auto& result = results[iseed]; - - if (result.ok()) { - // Get the track finding output object - auto& trackFindingOutput = result.value(); - // Create a SimMultiTrajectory - trajectories->emplace_back(std::move(trackFindingOutput.fittedStates), - std::move(trackFindingOutput.lastMeasurementIndices), - std::move(trackFindingOutput.fittedParameters)); - } else { - if (msgLevel(MSG::DEBUG)) { - debug() << "Track finding failed for truth seed " << iseed << "with error: " << result.error() << endmsg; + // Set seed number for all found tracks + auto& tracksForSeed = result.value(); + for (auto& track : tracksForSeed) { + seedNumber(track) = iseed; } + } + + // 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)); + + auto constTrackContainer = + std::make_shared( + std::move(*trackContainer)); + + auto* constTracks = m_outputTracks.put( + std::make_unique(constTrackContainer, constTrackStateContainer) + ); + + // Seed number column accessor + const Acts::ConstTrackAccessor constSeedNumber("seed"); + + + // Prepare the output data with MultiTrajectory, per seed + 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->emplace_back( + 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()}}); + } + + if (tips.empty()) { + info() << fmt::format("Last trajectory is empty") << endmsg; } + // last entry: move vectors + acts_trajectories->emplace_back( + constTracks->trackStateContainer(), + std::move(tips), std::move(parameters)); + return StatusCode::SUCCESS; } diff --git a/JugTrack/src/components/CKFTracking.h b/JugTrack/src/components/CKFTracking.h index 8f64d28e..04537966 100644 --- a/JugTrack/src/components/CKFTracking.h +++ b/JugTrack/src/components/CKFTracking.h @@ -16,12 +16,12 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" #include "JugBase/BField/DD4hepBField.h" -#include "JugTrack/GeometryContainers.hpp" -#include "JugTrack/Index.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Measurement.hpp" -#include "JugTrack/Track.hpp" -#include "JugTrack/Trajectories.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" +#include "ActsExamples/EventData/Index.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/EventData/Trajectories.hpp" #include "edm4eic/TrackerHitCollection.h" @@ -41,18 +41,20 @@ class CKFTracking : public GaudiAlgorithm { /// Track finder function that takes input measurements, initial trackstate /// and track finder options and returns some track-finder-specific result. 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 /// small class CKFTrackingFunction { public: virtual ~CKFTrackingFunction() = default; - virtual TrackFinderResult operator()(const TrackParametersContainer&, - const TrackFinderOptions&) const = 0; + virtual TrackFinderResult operator()(const ActsExamples::TrackParameters&, + const TrackFinderOptions&, + ActsExamples::TrackContainer&) const = 0; }; /// Create the track finder function implementation. @@ -63,11 +65,12 @@ class CKFTracking : public GaudiAlgorithm { std::shared_ptr magneticField); public: - DataHandle m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this}; - DataHandle m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this}; - DataHandle m_inputInitialTrackParameters{"inputInitialTrackParameters", + DataHandle m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputInitialTrackParameters{"inputInitialTrackParameters", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputTracks{"outputTracks", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this}; Gaudi::Property> m_etaBins{this, "etaBins", {}}; Gaudi::Property> m_chi2CutOff{this, "chi2CutOff", {15.}}; diff --git a/JugTrack/src/components/CKFTrackingFunction.cpp b/JugTrack/src/components/CKFTrackingFunction.cpp index 36de5a2c..eb092565 100644 --- a/JugTrack/src/components/CKFTrackingFunction.cpp +++ b/JugTrack/src/components/CKFTrackingFunction.cpp @@ -1,6 +1,9 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck, Sylvester Joosten +#include "Acts/EventData/TrackContainer.hpp" +#include "Acts/EventData/VectorMultiTrajectory.hpp" +#include "Acts/EventData/VectorTrackContainer.hpp" #include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/Navigator.hpp" @@ -34,6 +37,10 @@ namespace { using CKF = Acts::CombinatorialKalmanFilter; + using TrackContainer = + Acts::TrackContainer; + /** Finder implmentation . * * \ingroup track @@ -45,11 +52,10 @@ namespace { CKFTrackingFunctionImpl(CKF&& f) : trackFinder(std::move(f)) {} Jug::Reco::CKFTracking::TrackFinderResult - operator()(const Jug::TrackParametersContainer& initialParameters, - const Jug::Reco::CKFTracking::TrackFinderOptions& options) - const override - { - return trackFinder.findTracks(initialParameters, options); + operator()(const ActsExamples::TrackParameters& initialParameters, + const Jug::Reco::CKFTracking::TrackFinderOptions& options, + TrackContainer& tracks) const override { + return trackFinder.findTracks(initialParameters, options, tracks); }; }; diff --git a/JugTrack/src/components/ConformalXYPeakProtoTracks.cpp b/JugTrack/src/components/ConformalXYPeakProtoTracks.cpp index 94a9da2f..05685de5 100644 --- a/JugTrack/src/components/ConformalXYPeakProtoTracks.cpp +++ b/JugTrack/src/components/ConformalXYPeakProtoTracks.cpp @@ -11,8 +11,8 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/ProtoTrack.hpp" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/ProtoTrack.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "TH1F.h" #include "Math/Vector3D.h" @@ -31,7 +31,7 @@ namespace Jug::Reco { class ConformalXYPeakProtoTracks : public GaudiAlgorithm { private: DataHandle m_inputTrackerHits{"inputTrackerHits", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; DataHandle m_nProtoTracks{"nProtoTracks", Gaudi::DataHandle::Writer, this}; Gaudi::Property m_nPhiBins{this, "nPhiBins", 100}; @@ -91,7 +91,7 @@ class ConformalXYPeakProtoTracks : public GaudiAlgorithm { } // 4. Group hits peaked in phi for(auto b : max_bins) { - Jug::ProtoTrack proto_track; // this is just a std::vector + ActsExamples::ProtoTrack proto_track; // this is just a std::vector for(size_t ihit = 0 ; ihit< hits->size() ; ihit++) { double phi = conformal_hits[ihit].phi(); double bin_phi = h_phi.GetXaxis()->GetBinCenter(b); diff --git a/JugTrack/src/components/FinderAlgoTemplate.cpp b/JugTrack/src/components/FinderAlgoTemplate.cpp index c2238d4b..099ccce9 100644 --- a/JugTrack/src/components/FinderAlgoTemplate.cpp +++ b/JugTrack/src/components/FinderAlgoTemplate.cpp @@ -11,8 +11,8 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/ProtoTrack.hpp" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/ProtoTrack.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "Math/Vector3D.h" @@ -27,7 +27,7 @@ namespace Jug::Reco { class FinderAlgoTemplate : public GaudiAlgorithm { private: DataHandle m_inputTrackerHits{"inputTrackerHits", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; public: FinderAlgoTemplate(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { diff --git a/JugTrack/src/components/HoughTransformProtoTracks.cpp b/JugTrack/src/components/HoughTransformProtoTracks.cpp index 04eac00b..4086be5c 100644 --- a/JugTrack/src/components/HoughTransformProtoTracks.cpp +++ b/JugTrack/src/components/HoughTransformProtoTracks.cpp @@ -11,8 +11,8 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/ProtoTrack.hpp" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/ProtoTrack.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "Math/Vector3D.h" @@ -27,7 +27,7 @@ namespace Jug::Reco { class HoughTransformProtoTracks : public GaudiAlgorithm { private: DataHandle m_inputTrackerHits{"inputTrackerHits", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; public: HoughTransformProtoTracks(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { diff --git a/JugTrack/src/components/ParticlesFromTrackFit.cpp b/JugTrack/src/components/ParticlesFromTrackFit.cpp index e0dbbec2..43e205d6 100644 --- a/JugTrack/src/components/ParticlesFromTrackFit.cpp +++ b/JugTrack/src/components/ParticlesFromTrackFit.cpp @@ -25,9 +25,9 @@ #include "edm4eic/ReconstructedParticleCollection.h" #include "edm4eic/TrackerHitCollection.h" #include "edm4eic/TrackParametersCollection.h" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Track.hpp" -#include "JugTrack/Trajectories.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/EventData/Trajectories.hpp" #include "Acts/Utilities/Helpers.hpp" @@ -43,7 +43,7 @@ namespace Jug::Reco { */ class ParticlesFromTrackFit : public GaudiAlgorithm { private: - DataHandle m_inputTrajectories{"inputTrajectories", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputTrajectories{"inputTrajectories", Gaudi::DataHandle::Reader, this}; DataHandle m_outputParticles{"outputParticles", Gaudi::DataHandle::Writer, this}; DataHandle m_outputTrackParameters{"outputTrackParameters", Gaudi::DataHandle::Writer, this}; diff --git a/JugTrack/src/components/ProtoTrackMatching.cpp b/JugTrack/src/components/ProtoTrackMatching.cpp index 5d4e3d90..a6e505c3 100644 --- a/JugTrack/src/components/ProtoTrackMatching.cpp +++ b/JugTrack/src/components/ProtoTrackMatching.cpp @@ -11,8 +11,8 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/ProtoTrack.hpp" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/ProtoTrack.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "Math/Vector3D.h" @@ -27,9 +27,9 @@ namespace Jug::Reco { class ProtoTrackMatching : public GaudiAlgorithm { private: DataHandle m_inputTrackerHits{"inputTrackerHits", Gaudi::DataHandle::Reader, this}; - DataHandle m_initialTrackParameters{"initialTrackParameters", Gaudi::DataHandle::Reader, this}; - DataHandle m_inputProtoTracks{"inputProtoTracks", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputProtoTracks{"matchedProtoTracks", Gaudi::DataHandle::Writer, this}; + DataHandle m_initialTrackParameters{"initialTrackParameters", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputProtoTracks{"inputProtoTracks", Gaudi::DataHandle::Reader, this}; + DataHandle m_outputProtoTracks{"matchedProtoTracks", Gaudi::DataHandle::Writer, this}; public: ProtoTrackMatching(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { diff --git a/JugTrack/src/components/SingleTrackSourceLinker.cpp b/JugTrack/src/components/SingleTrackSourceLinker.cpp index 24fab9c7..96647772 100644 --- a/JugTrack/src/components/SingleTrackSourceLinker.cpp +++ b/JugTrack/src/components/SingleTrackSourceLinker.cpp @@ -24,11 +24,11 @@ #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "JugTrack/GeometryContainers.hpp" -#include "JugTrack/Index.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Measurement.hpp" -#include "JugTrack/ProtoTrack.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" +#include "ActsExamples/EventData/Index.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/ProtoTrack.hpp" #include "edm4eic/TrackerHitCollection.h" @@ -43,10 +43,10 @@ namespace Jug::Reco { class SingleTrackSourceLinker : public GaudiAlgorithm { private: DataHandle m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this}; - DataHandle> m_sourceLinkStorage{"sourceLinkStorage", Gaudi::DataHandle::Writer, this}; - DataHandle m_outputSourceLinks{"outputSourceLinks", Gaudi::DataHandle::Writer, this}; - DataHandle m_outputMeasurements{"outputMeasurements", Gaudi::DataHandle::Writer, this}; - DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; + DataHandle> m_sourceLinkStorage{"sourceLinkStorage", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputSourceLinks{"outputSourceLinks", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputMeasurements{"outputMeasurements", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputProtoTracks{"outputProtoTracks", Gaudi::DataHandle::Writer, this}; /// Pointer to the geometry service SmartIF m_geoSvc; @@ -86,7 +86,7 @@ class SingleTrackSourceLinker : public GaudiAlgorithm { measurements->reserve(hits->size()); // assume single track --> one ProtoTrack - ProtoTrack track; + ActsExamples::ProtoTrack track; track.reserve((*hits).size()); if (msgLevel(MSG::DEBUG)) { @@ -137,21 +137,21 @@ class SingleTrackSourceLinker : public GaudiAlgorithm { Acts::Vector2 pos(acts_pos.x(), acts_pos.y()); // construct the covariance matrix - Acts::SymMatrix2 cov = Acts::SymMatrix2::Zero(); + Acts::SquareMatrix2 cov = Acts::SquareMatrix2::Zero(); cov(0, 0) = ahit.getPositionError().xx * Acts::UnitConstants::mm * Acts::UnitConstants::mm; cov(1, 1) = ahit.getPositionError().yy * Acts::UnitConstants::mm * Acts::UnitConstants::mm; // Above we only consider the two position coordinates the comment below shows how to add time // which we will probably want to try later. // - // Acts::SymMatrix3 cov; + // Acts::SquareMatrix3 cov; // cov << 0.05, 0., 0., 0., 0.05, 0., 0., 0., 900. * Acts::UnitConstants::ps * Acts::UnitConstants::ps; // Acts::Vector3 par(localX, localY, simHit.time()); linkStorage->emplace_back(surface->geometryId(), ihit); - IndexSourceLink& sourceLink = linkStorage->back(); + ActsExamples::IndexSourceLink& sourceLink = linkStorage->back(); auto meas = - Acts::makeMeasurement(sourceLink, pos, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); //, Acts::eBoundTime); + Acts::makeMeasurement(Acts::SourceLink{sourceLink}, pos, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); // add to output containers. since the input is already geometry-order, // new elements in geometry containers can just be appended at the end. diff --git a/JugTrack/src/components/TrackParamACTSSeeding.cpp b/JugTrack/src/components/TrackParamACTSSeeding.cpp index 8c25a3a5..bed8b6fc 100644 --- a/JugTrack/src/components/TrackParamACTSSeeding.cpp +++ b/JugTrack/src/components/TrackParamACTSSeeding.cpp @@ -13,19 +13,8 @@ #include "Acts/Seeding/SeedFilter.hpp" #include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" -#if Acts_VERSION_MAJOR >= 21 #include "Acts/Seeding/SeedFinderConfig.hpp" #include "Acts/Seeding/SeedFinder.hpp" -#else -#include "Acts/Seeding/SeedfinderConfig.hpp" -#include "Acts/Seeding/Seedfinder.hpp" -namespace Acts { - template - using SeedFinder = Seedfinder; - template - using SeedFinderConfig = SeedfinderConfig; -} -#endif // Gaudi #include "GaudiAlg/GaudiAlgorithm.h" @@ -38,8 +27,9 @@ namespace Acts { #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" #include "JugBase/BField/DD4hepBField.h" -#include "JugTrack/Measurement.hpp" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/Index.hpp" +#include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "DDRec/CellIDPositionConverter.h" @@ -71,7 +61,7 @@ namespace Jug::Reco { DataHandle m_inputHitCollection { "inputHitCollection", Gaudi::DataHandle::Reader, this }; - DataHandle + DataHandle m_outputInitialTrackParameters { "outputInitialTrackParameters", Gaudi::DataHandle::Writer, this }; @@ -166,7 +156,7 @@ namespace Jug::Reco { /// A proto track is a collection of hits identified by their /// indices. - using ProtoTrack = std::vector; + using ProtoTrack = std::vector; /// Container of proto tracks. Each proto track is identified by /// its index. using ProtoTrackContainer = std::vector; @@ -187,7 +177,6 @@ namespace Jug::Reco { /// Output proto track collection. std::string outputProtoTracks; - float bFieldInZ = 1.7 * Acts::UnitConstants::T; float cotThetaMax = std::sinh(4.01); float minPt = 100 * Acts::UnitConstants::MeV / cotThetaMax; float rMax = 440 * Acts::UnitConstants::mm; @@ -201,9 +190,11 @@ namespace Jug::Reco { float maxSeedsPerSpM = 2; float sigmaScattering = 5; float radLengthPerSeed = 0.1; + float impactMax = 3 * Acts::UnitConstants::mm; + // + float bFieldInZ = 1.7 * Acts::UnitConstants::T; float beamPosX = 0 * Acts::UnitConstants::mm; float beamPosY = 0 * Acts::UnitConstants::mm; - float impactMax = 3 * Acts::UnitConstants::mm; /// The minimum magnetic field to trigger the track /// parameters estimation @@ -232,11 +223,13 @@ namespace Jug::Reco { std::vector > zBinNeighborsBottom; } m_cfg; Acts::SpacePointGridConfig m_gridCfg; + Acts::SpacePointGridOptions m_gridOpt; Acts::SeedFinderConfig m_finderCfg; + Acts::SeedFinderOptions m_finderOpt; /// The track parameters covariance (assumed to be the same /// for all estimated track parameters for the moment) - Acts::BoundSymMatrix m_covariance = - Acts::BoundSymMatrix::Zero(); + Acts::BoundSquareMatrix m_covariance = + Acts::BoundSquareMatrix::Zero(); public: TrackParamACTSSeeding(const std::string &name, @@ -272,7 +265,6 @@ namespace Jug::Reco { m_geoSvc->getFieldProvider()); m_fieldContext = Jug::BField::BFieldVariant(m_BField); - m_gridCfg.bFieldInZ = m_cfg.bFieldInZ; m_gridCfg.minPt = m_cfg.minPt; m_gridCfg.rMax = m_cfg.rMax; m_gridCfg.zMax = m_cfg.zMax; @@ -300,11 +292,18 @@ namespace Jug::Reco { m_finderCfg.sigmaScattering = m_cfg.sigmaScattering; m_finderCfg.radLengthPerSeed = m_cfg.radLengthPerSeed; m_finderCfg.minPt = m_cfg.minPt; - m_finderCfg.bFieldInZ = m_cfg.bFieldInZ; - m_finderCfg.beamPos = - Acts::Vector2(m_cfg.beamPosX, m_cfg.beamPosY); m_finderCfg.impactMax = m_cfg.impactMax; + m_finderOpt.bFieldInZ = m_cfg.bFieldInZ; + m_finderOpt.beamPos = + Acts::Vector2(m_cfg.beamPosX, m_cfg.beamPosY); + + m_finderCfg = + m_finderCfg.toInternalUnits().calculateDerivedQuantities(); + m_finderOpt = + m_finderOpt.toInternalUnits().calculateDerivedQuantities( + m_finderCfg); + // Set up the track parameters covariance (the same for all // tracks) m_covariance(Acts::eBoundLoc0, Acts::eBoundLoc0) = @@ -332,20 +331,12 @@ namespace Jug::Reco { m_outputInitialTrackParameters.createAndPut(); static SeedContainer seeds; -#if Acts_VERSION_MAJOR >= 21 static Acts::SeedFinder::SeedingState state; -#else - static Acts::SeedFinder::State state; -#endif // Sadly, eic::TrackerHit and eic::TrackerHitData are // non-polymorphic std::vector spacePoint; std::vector spacePointPtrs; -#if Acts_VERSION_MAJOR < 21 - // extent used to store r range for middle spacepoint - Acts::Extent rRangeSPExtent; -#endif std::shared_ptr trackingGeometry = m_geoSvc->trackingGeometry(); @@ -417,11 +408,6 @@ namespace Jug::Reco { << ' ' << spacePointPtrs.back()->measurementIndex() << ' ' << spacePointPtrs.back()->isOnSurface() << endmsg; -#if Acts_VERSION_MAJOR < 21 - rRangeSPExtent.extend({ spacePoint.back().x(), - spacePoint.back().y(), - spacePoint.back().z() }); -#endif } } #endif // USE_LOCAL_COORD @@ -441,10 +427,8 @@ namespace Jug::Reco { debug() << __FILE__ << ':' << __LINE__ << ": " << endmsg; } -#if Acts_VERSION_MAJOR >= 21 // extent used to store r range for middle spacepoint Acts::Extent rRangeSPExtent; -#endif auto bottomBinFinder = std::make_shared>( @@ -461,10 +445,10 @@ namespace Jug::Reco { debug() << __FILE__ << ':' << __LINE__ << ": " << endmsg; } - const float bFieldInZSave = m_gridCfg.bFieldInZ; + const float bFieldInZSave = m_gridOpt.bFieldInZ; const float minPtSave = m_gridCfg.minPt; m_gridCfg.minPt = 400 * Acts::UnitConstants::MeV; - m_gridCfg.bFieldInZ = + m_gridOpt.bFieldInZ = (m_gridCfg.minPt / Acts::UnitConstants::MeV) / (150.0 * (1.0 + FLT_EPSILON) * (m_gridCfg.rMax / Acts::UnitConstants::mm)) * @@ -473,13 +457,13 @@ namespace Jug::Reco { debug() << "createGrid() with temporary minPt = " << m_gridCfg.minPt / Acts::UnitConstants::MeV << " MeV, bFieldInZ = " - << m_gridCfg.bFieldInZ / (1000 * Acts::UnitConstants::T) + << m_gridOpt.bFieldInZ / (1000 * Acts::UnitConstants::T) << " kT" << endmsg; } auto grid = Acts::SpacePointGridCreator::createGrid( - m_gridCfg); - m_gridCfg.bFieldInZ = bFieldInZSave; + m_gridCfg, m_gridOpt); + m_gridOpt.bFieldInZ = bFieldInZSave; m_gridCfg.minPt = minPtSave; if (msgLevel(MSG::DEBUG)) { debug() << "phiBins = " @@ -493,10 +477,8 @@ namespace Jug::Reco { spacePointPtrs.begin(), spacePointPtrs.end(), extractGlobalQuantities, bottomBinFinder, topBinFinder, std::move(grid), -#if Acts_VERSION_MAJOR >= 21 rRangeSPExtent, -#endif - m_finderCfg); + m_finderCfg, m_finderOpt); auto finder = Acts::SeedFinder(m_finderCfg); if (msgLevel(MSG::DEBUG)) { @@ -505,28 +487,19 @@ namespace Jug::Reco { << spacePointsGrouping.size() << endmsg; } -#if Acts_VERSION_MAJOR >= 21 const Acts::Range1D rMiddleSPRange( std::floor(rRangeSPExtent.min(Acts::binR) / 2) * 2 + m_cfg.deltaRMiddleMinSPRange, std::floor(rRangeSPExtent.max(Acts::binR) / 2) * 2 - m_cfg.deltaRMiddleMaxSPRange); -#endif // Run the seeding seeds.clear(); - auto group = spacePointsGrouping.begin(); - auto groupEnd = spacePointsGrouping.end(); - for (; !(group == groupEnd); ++group) { + for (const auto [bottom, middle, top] : spacePointsGrouping) { finder.createSeedsForGroup( - state, std::back_inserter(seeds), - group.bottom(), group.middle(), group.top(), -#if Acts_VERSION_MAJOR >= 21 - rMiddleSPRange -#else - rRangeSPExtent -#endif + m_finderOpt, state, spacePointsGrouping.grid(), + std::back_inserter(seeds), bottom, middle, top, rMiddleSPRange ); } @@ -534,7 +507,7 @@ namespace Jug::Reco { debug() << "seeds.size() = " << seeds.size() << endmsg; } - TrackParametersContainer trackParameters; + ActsExamples::TrackParametersContainer trackParameters; ProtoTrackContainer tracks; trackParameters.reserve(seeds.size()); tracks.reserve(seeds.size()); @@ -600,11 +573,9 @@ namespace Jug::Reco { spTaken[seed.sp()[1]->measurementIndex()] || spTaken[seed.sp()[2]->measurementIndex()])) { const auto& params = optParams.value(); - const double charge = - std::copysign(1, params[Acts::eBoundQOverP]); initTrackParameters->emplace_back( - surface->getSharedPtr(), params, charge, - m_covariance); + surface->getSharedPtr(), params, + m_covariance, Acts::ParticleHypothesis::pion()); // Activate/deactivate for unique seed filtering #if 0 spTaken[seed.sp()[0]->measurementIndex()] = true; diff --git a/JugTrack/src/components/TrackParamClusterInit.cpp b/JugTrack/src/components/TrackParamClusterInit.cpp index e7030e41..45772b6b 100644 --- a/JugTrack/src/components/TrackParamClusterInit.cpp +++ b/JugTrack/src/components/TrackParamClusterInit.cpp @@ -14,7 +14,7 @@ #include "Acts/Definitions/Units.hpp" #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "edm4eic/ClusterCollection.h" #include "edm4eic/TrackerHitCollection.h" @@ -44,10 +44,8 @@ namespace Jug::Reco { */ class TrackParamClusterInit : public GaudiAlgorithm { private: - using Clusters = edm4eic::ClusterCollection; - - DataHandle m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", + DataHandle m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this}; + DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", Gaudi::DataHandle::Writer, this}; public: @@ -102,7 +100,7 @@ class TrackParamClusterInit : public GaudiAlgorithm { } // add both charges to the track candidate... - init_trk_params->push_back({pSurface, params, 1}); + init_trk_params->push_back({pSurface, params, {}, Acts::ParticleHypothesis::pion()}); Acts::BoundVector params2; params2(Acts::eBoundLoc0) = 0.0 * mm; @@ -111,7 +109,7 @@ class TrackParamClusterInit : public GaudiAlgorithm { params2(Acts::eBoundTheta) = edm4hep::utils::anglePolar(momentum); params2(Acts::eBoundQOverP) = -1 / p; params2(Acts::eBoundTime) = 0 * ns; - init_trk_params->push_back({pSurface, params2, -1}); + init_trk_params->push_back({pSurface, params2, {}, Acts::ParticleHypothesis::pion()}); // acts v1.2.0: // init_trk_params->emplace_back(Acts::Vector4(0 * mm, 0 * mm, 0 * mm, 0), diff --git a/JugTrack/src/components/TrackParamImagingClusterInit.cpp b/JugTrack/src/components/TrackParamImagingClusterInit.cpp index 3293e76e..baed1c24 100644 --- a/JugTrack/src/components/TrackParamImagingClusterInit.cpp +++ b/JugTrack/src/components/TrackParamImagingClusterInit.cpp @@ -12,7 +12,7 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/Definitions/Common.hpp" @@ -44,10 +44,8 @@ namespace Jug::Reco { */ class TrackParamImagingClusterInit : public GaudiAlgorithm { private: - using ImagingClusters = edm4eic::ClusterCollection; - - DataHandle m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", + DataHandle m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this}; + DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", Gaudi::DataHandle::Writer, this}; public: @@ -102,7 +100,7 @@ namespace Jug::Reco { debug() << "Invoke track finding seeded by truth particle with p = " << p/GeV << " GeV" << endmsg; // add both charges to the track candidate... - init_trk_params->push_back({pSurface, params, 1}); + init_trk_params->push_back({pSurface, params, {}, Acts::ParticleHypothesis::pion()}); Acts::BoundVector params2; params2(Acts::eBoundLoc0) = 0.0 * mm ; @@ -111,7 +109,7 @@ namespace Jug::Reco { params2(Acts::eBoundTheta) = theta; params2(Acts::eBoundQOverP) = -1/p; params2(Acts::eBoundTime) = 0 * ns; - init_trk_params->push_back({pSurface, params2, -1}); + init_trk_params->push_back({pSurface, params2, {}, Acts::ParticleHypothesis::pion()}); } return StatusCode::SUCCESS; diff --git a/JugTrack/src/components/TrackParamTruthInit.cpp b/JugTrack/src/components/TrackParamTruthInit.cpp index a07bd652..a71a304c 100644 --- a/JugTrack/src/components/TrackParamTruthInit.cpp +++ b/JugTrack/src/components/TrackParamTruthInit.cpp @@ -14,7 +14,7 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" #include "JugBase/IParticleSvc.h" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/Definitions/Common.hpp" @@ -47,7 +47,7 @@ namespace Jug::Reco { private: DataHandle m_inputMCParticles{"inputMCParticles", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", + DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", Gaudi::DataHandle::Writer, this}; // selection settings @@ -150,7 +150,7 @@ namespace Jug::Reco { using Acts::UnitConstants::ns; // build some track cov matrix - Acts::BoundSymMatrix cov = Acts::BoundSymMatrix::Zero(); + Acts::BoundSquareMatrix cov = Acts::BoundSquareMatrix::Zero(); cov(Acts::eBoundLoc0, Acts::eBoundLoc0) = 1000*um*1000*um; cov(Acts::eBoundLoc1, Acts::eBoundLoc1) = 1000*um*1000*um; cov(Acts::eBoundPhi, Acts::eBoundPhi) = 0.05*0.05; @@ -171,7 +171,7 @@ namespace Jug::Reco { Acts::Vector3{part.getVertex().x * mm, part.getVertex().y * mm, part.getVertex().z * mm}); //params(Acts::eBoundQOverP) = charge/p; - init_trk_params->push_back({pSurface, params, charge,cov}); + init_trk_params->push_back({pSurface, params, cov, Acts::ParticleHypothesis::pion()}); // std::make_optional(std::move(cov)) if (msgLevel(MSG::DEBUG)) { diff --git a/JugTrack/src/components/TrackParamVertexClusterInit.cpp b/JugTrack/src/components/TrackParamVertexClusterInit.cpp index c83fe1c1..387027c5 100644 --- a/JugTrack/src/components/TrackParamVertexClusterInit.cpp +++ b/JugTrack/src/components/TrackParamVertexClusterInit.cpp @@ -16,7 +16,7 @@ #include "Acts/Definitions/Units.hpp" #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/Track.hpp" #include "Acts/Surfaces/PerigeeSurface.hpp" #include "edm4eic/ClusterCollection.h" @@ -37,12 +37,9 @@ namespace Jug::Reco { */ class TrackParamVertexClusterInit : public GaudiAlgorithm { private: - using Clusters = edm4eic::ClusterCollection; - using VertexHits = edm4eic::TrackerHitCollection; - - DataHandle m_inputVertexHits{"inputVertexHits", Gaudi::DataHandle::Reader, this}; - DataHandle m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", + DataHandle m_inputVertexHits{"inputVertexHits", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputClusters{"inputClusters", Gaudi::DataHandle::Reader, this}; + DataHandle m_outputInitialTrackParameters{"outputInitialTrackParameters", Gaudi::DataHandle::Writer, this}; Gaudi::Property m_maxHitRadius{this, "maxHitRadius", 40.0 * mm}; @@ -109,7 +106,7 @@ class TrackParamVertexClusterInit : public GaudiAlgorithm { // debug() << "Invoke track finding seeded by truth particle with p = " << p / GeV << " GeV" << endmsg; // add both charges to the track candidate... - init_trk_params->push_back({pSurface, params, 1}); + init_trk_params->push_back({pSurface, params, {}, Acts::ParticleHypothesis::pion()}); Acts::BoundVector params2; params2(Acts::eBoundLoc0) = 0.0 * mm; @@ -118,7 +115,7 @@ class TrackParamVertexClusterInit : public GaudiAlgorithm { params2(Acts::eBoundTheta) = edm4hep::utils::anglePolar(momentum); params2(Acts::eBoundQOverP) = -1 / p_cluster; params2(Acts::eBoundTime) = 0 * ns; - init_trk_params->push_back({pSurface, params2, -1}); + init_trk_params->push_back({pSurface, params2, {}, Acts::ParticleHypothesis::pion()}); } // init_trk_params->emplace_back(Acts::Vector4(0 * mm, 0 * mm, 0 * mm, 0), // Acts::Vector3(c.x() * p / len, c.y() * p / len, c.z() * p / len), p, 1, diff --git a/JugTrack/src/components/TrackProjector.cpp b/JugTrack/src/components/TrackProjector.cpp index 4471728b..d97a159d 100644 --- a/JugTrack/src/components/TrackProjector.cpp +++ b/JugTrack/src/components/TrackProjector.cpp @@ -27,9 +27,9 @@ #include "edm4eic/TrackParametersCollection.h" #include "edm4eic/TrajectoryCollection.h" #include "edm4eic/TrackSegmentCollection.h" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Track.hpp" -#include "JugTrack/Trajectories.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/EventData/Trajectories.hpp" #include "Acts/Utilities/Helpers.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" @@ -50,7 +50,7 @@ namespace Jug::Reco { */ class TrackProjector : public GaudiAlgorithm { private: - DataHandle m_inputTrajectories{"inputTrajectories", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputTrajectories{"inputTrajectories", Gaudi::DataHandle::Reader, this}; DataHandle m_outputTrackSegments{"outputTrackSegments", Gaudi::DataHandle::Writer, this}; Gaudi::Property m_firstInVolumeID{this, "firstInVolumeID", 0}; diff --git a/JugTrack/src/components/TrackerSourceLinker.cpp b/JugTrack/src/components/TrackerSourceLinker.cpp index 3833d383..62d69e3d 100644 --- a/JugTrack/src/components/TrackerSourceLinker.cpp +++ b/JugTrack/src/components/TrackerSourceLinker.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck -#include "JugTrack/GeometryContainers.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" // Gaudi #include "Gaudi/Property.h" @@ -25,10 +25,11 @@ #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Surfaces/Surface.hpp" +#include -#include "JugTrack/Index.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Measurement.hpp" +#include "ActsExamples/EventData/Index.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Measurement.hpp" #include "edm4eic/TrackerHitCollection.h" @@ -45,9 +46,9 @@ namespace Jug::Reco { class TrackerSourceLinker : public GaudiAlgorithm { private: DataHandle m_inputHitCollection{"inputHitCollection", Gaudi::DataHandle::Reader, this}; - DataHandle> m_sourceLinkStorage{"sourceLinkStorage", Gaudi::DataHandle::Writer, this}; - DataHandle m_outputSourceLinks{"outputSourceLinks", Gaudi::DataHandle::Writer, this}; - DataHandle m_outputMeasurements{"outputMeasurements", Gaudi::DataHandle::Writer, this}; + DataHandle> m_sourceLinkStorage{"sourceLinkStorage", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputSourceLinks{"outputSourceLinks", Gaudi::DataHandle::Writer, this}; + DataHandle m_outputMeasurements{"outputMeasurements", Gaudi::DataHandle::Writer, this}; /// Pointer to the geometry service SmartIF m_geoSvc; @@ -92,7 +93,7 @@ class TrackerSourceLinker : public GaudiAlgorithm { int ihit = 0; for (const auto& ahit : *hits) { - Acts::SymMatrix2 cov = Acts::SymMatrix2::Zero(); + Acts::SquareMatrix2 cov = Acts::SquareMatrix2::Zero(); cov(0, 0) = ahit.getPositionError().xx * mm_acts * mm_acts; // note mm = 1 (Acts) cov(1, 1) = ahit.getPositionError().yy * mm_acts * mm_acts; if (msgLevel(MSG::DEBUG)) { @@ -144,8 +145,8 @@ class TrackerSourceLinker : public GaudiAlgorithm { // variable hitIdx not used anywhere // Index hitIdx = measurements->size(); linkStorage->emplace_back(surface->geometryId(), ihit); - IndexSourceLink& sourceLink = linkStorage->back(); - auto meas = Acts::makeMeasurement(sourceLink, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + ActsExamples::IndexSourceLink& sourceLink = linkStorage->back(); + auto meas = Acts::makeMeasurement(Acts::SourceLink{sourceLink}, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); // add to output containers. since the input is already geometry-order, // new elements in geometry containers can just be appended at the end. diff --git a/JugTrack/src/components/TruthTrackSeeding.cpp b/JugTrack/src/components/TruthTrackSeeding.cpp index 4a68a3a5..1b57972a 100644 --- a/JugTrack/src/components/TruthTrackSeeding.cpp +++ b/JugTrack/src/components/TruthTrackSeeding.cpp @@ -13,7 +13,7 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" #include "JugBase/IParticleSvc.h" -#include "JugTrack/Track.hpp" +#include "ActsExamples/EventData/Track.hpp" //#include "Acts/Definitions/Units.hpp" //#include "Acts/Definitions/Common.hpp" diff --git a/JugTrack/src/components/TrackFittingAlgorithm.cpp b/JugTrack/src/components/disabled/TrackFittingAlgorithm.cpp similarity index 89% rename from JugTrack/src/components/TrackFittingAlgorithm.cpp rename to JugTrack/src/components/disabled/TrackFittingAlgorithm.cpp index 00de02db..545952e0 100644 --- a/JugTrack/src/components/TrackFittingAlgorithm.cpp +++ b/JugTrack/src/components/disabled/TrackFittingAlgorithm.cpp @@ -31,10 +31,11 @@ #include "JugBase/IGeoSvc.h" #include "JugBase/BField/DD4hepBField.h" -#include "JugTrack/GeometryContainers.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Track.hpp" -#include "JugTrack/Measurement.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/MeasurementCalibration.hpp" #include "edm4eic/TrackerHitCollection.h" @@ -105,8 +106,10 @@ namespace Jug::Reco { // kfOptions.energyLoss = m_cfg.energyLoss; Acts::KalmanFitterExtensions extensions; - MeasurementCalibrator calibrator{*measurements}; - extensions.calibrator.connect<&MeasurementCalibrator::calibrate>(&calibrator); + ActsExamples::PassThroughCalibrator pcalibrator; + ActsExamples::MeasurementCalibratorAdapter calibrator(pcalibrator, *measurements); + extensions.calibrator.connect<&ActsExamples::MeasurementCalibratorAdapter::calibrate>( + &calibrator); Acts::GainMatrixUpdater kfUpdater; Acts::GainMatrixSmoother kfSmoother; extensions.updater.connect<&Acts::GainMatrixUpdater::operator()>( @@ -116,11 +119,11 @@ namespace Jug::Reco { Acts::KalmanFitterOptions kfOptions( m_geoctx, m_fieldctx, m_calibctx, extensions, - Acts::LoggerWrapper{logger()}, Acts::PropagatorPlainOptions(), + Acts::PropagatorPlainOptions(), &(*pSurface)); // used for processing the data - std::vector trackSourceLinks; + std::vector trackSourceLinks; std::vector surfSequence; if (msgLevel(MSG::DEBUG)) { @@ -147,7 +150,7 @@ namespace Jug::Reco { for (auto hitIndex : protoTrack) { if (auto it = sourceLinks->nth(hitIndex); it != sourceLinks->end()) { - const IndexSourceLink& sourceLink = *it; + const ActsExamples::IndexSourceLink& sourceLink = *it; trackSourceLinks.push_back(std::cref(sourceLink)); } else { ACTS_FATAL("Proto track " << itrack << " contains invalid hit index" @@ -172,7 +175,7 @@ namespace Jug::Reco { trackTips.reserve(1); trackTips.emplace_back(fitOutput.lastMeasurementIndex); // The fitted parameters container. One element (at most) here. - Trajectories::IndexedParameters indexedParams; + ActsExamples::Trajectories::IndexedParameters indexedParams; if (fitOutput.fittedParameters) { const auto& params = fitOutput.fittedParameters.value(); ACTS_VERBOSE("Fitted paramemeters for track " << itrack); @@ -189,7 +192,7 @@ namespace Jug::Reco { ACTS_WARNING("Fit failed for track " << itrack << " with error" << result.error()); // Fit failed. Add an empty result so the output container has // the same number of entries as the input. - trajectories->push_back(Trajectories()); + trajectories->push_back(ActsExamples::Trajectories()); } } diff --git a/JugTrack/src/components/TrackFittingAlgorithm.h b/JugTrack/src/components/disabled/TrackFittingAlgorithm.h similarity index 65% rename from JugTrack/src/components/TrackFittingAlgorithm.h rename to JugTrack/src/components/disabled/TrackFittingAlgorithm.h index 64dcfeb4..440b05e1 100644 --- a/JugTrack/src/components/TrackFittingAlgorithm.h +++ b/JugTrack/src/components/disabled/TrackFittingAlgorithm.h @@ -17,12 +17,12 @@ #include "JugBase/DataHandle.h" #include "JugBase/IGeoSvc.h" #include "JugBase/BField/DD4hepBField.h" -#include "JugTrack/GeometryContainers.hpp" -#include "JugTrack/IndexSourceLink.hpp" -#include "JugTrack/Track.hpp" -#include "JugTrack/Measurement.hpp" -#include "JugTrack/Trajectories.hpp" -#include "JugTrack/ProtoTrack.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" +#include "ActsExamples/EventData/IndexSourceLink.hpp" +#include "ActsExamples/EventData/Track.hpp" +#include "ActsExamples/EventData/Measurement.hpp" +#include "ActsExamples/EventData/Trajectories.hpp" +#include "ActsExamples/EventData/ProtoTrack.hpp" #include "edm4eic/TrackerHitCollection.h" @@ -54,15 +54,15 @@ namespace Jug::Reco { /// Fit function that takes input measurements, initial trackstate and fitter using FitterFunction = std::function&, const TrackParameters&, const TrackFitterOptions&)>; + const std::vector&, const ActsExamples::TrackParameters&, const TrackFitterOptions&)>; public: - DataHandle m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this}; - DataHandle m_initialTrackParameters{"initialTrackParameters", Gaudi::DataHandle::Reader, this}; - DataHandle m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this}; - DataHandle m_inputProtoTracks{"inputProtoTracks", Gaudi::DataHandle::Reader, this}; - DataHandle m_foundTracks{"foundTracks", Gaudi::DataHandle::Reader, this}; - DataHandle m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this}; + DataHandle m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this}; + DataHandle m_initialTrackParameters{"initialTrackParameters", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this}; + DataHandle m_inputProtoTracks{"inputProtoTracks", Gaudi::DataHandle::Reader, this}; + DataHandle m_foundTracks{"foundTracks", Gaudi::DataHandle::Reader, this}; + DataHandle m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this}; FitterFunction m_trackFittingFunc; SmartIF m_geoSvc; @@ -89,15 +89,15 @@ namespace Jug::Reco { private: /// Helper function to call correct FitterFunction FitterResult fitTrack( - const std::vector& sourceLinks, - const TrackParameters& initialParameters, + const std::vector& sourceLinks, + const ActsExamples::TrackParameters& initialParameters, const TrackFitterOptions& options ) const; }; inline TrackFittingAlgorithm::FitterResult - TrackFittingAlgorithm::fitTrack(const std::vector& sourceLinks, - const TrackParameters& initialParameters, + TrackFittingAlgorithm::fitTrack(const std::vector& sourceLinks, + const ActsExamples::TrackParameters& initialParameters, const TrackFitterOptions& options) const { return m_trackFittingFunc(sourceLinks, initialParameters, options); diff --git a/JugTrack/src/components/TrackFittingFunction.cpp b/JugTrack/src/components/disabled/TrackFittingFunction.cpp similarity index 93% rename from JugTrack/src/components/TrackFittingFunction.cpp rename to JugTrack/src/components/disabled/TrackFittingFunction.cpp index b2f13f24..756b71e7 100644 --- a/JugTrack/src/components/TrackFittingFunction.cpp +++ b/JugTrack/src/components/disabled/TrackFittingFunction.cpp @@ -36,8 +36,8 @@ namespace { TrackFitterFunctionImpl(track_fitter_t&& f) : trackFitter(std::move(f)) {} Jug::Reco::TrackFittingAlgorithm::FitterResult - operator()(const std::vector& sourceLinks, - const Jug::TrackParameters& initialParameters, + operator()(const std::vector& sourceLinks, + const ActsExamples::TrackParameters& initialParameters, const Jug::Reco::TrackFittingAlgorithm::TrackFitterOptions& options) const { return trackFitter.fit(sourceLinks.begin(), sourceLinks.end(), initialParameters, options); diff --git a/external/algorithms/calorimetry/src/ClusterRecoCoG.cpp b/external/algorithms/calorimetry/src/ClusterRecoCoG.cpp index c4dc3723..52601151 100644 --- a/external/algorithms/calorimetry/src/ClusterRecoCoG.cpp +++ b/external/algorithms/calorimetry/src/ClusterRecoCoG.cpp @@ -46,7 +46,7 @@ void ClusterRecoCoG::init() { std::vector keys; std::transform(weightMethods.begin(), weightMethods.end(), std::back_inserter(keys), [](const auto& keyvalue) { return keyvalue.first; }); - raise(fmt::format("Cannot find energy weighting method {}, choose one from {}", m_energyWeight, + raise(fmt::format("Cannot find energy weighting method {}, choose one from {}", m_energyWeight.value(), keys)); } m_weightFunc = weightMethods.at(ew);