Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /juggler/JugTrack/src/components/CKFTracking.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck
0003 
0004 #ifndef JUGGLER_JUGRECO_CKFTracking_HH
0005 #define JUGGLER_JUGRECO_CKFTracking_HH
0006 
0007 #include <functional>
0008 #include <random>
0009 #include <stdexcept>
0010 #include <vector>
0011 
0012 #include "Gaudi/Property.h"
0013 #include "Gaudi/Algorithm.h"
0014 #include "GaudiKernel/ToolHandle.h"
0015 
0016 #include <k4FWCore/DataHandle.h>
0017 #include <k4Interface/IGeoSvc.h>
0018 #include "JugTrack/IActsGeoSvc.h"
0019 #include "JugTrack/DD4hepBField.h"
0020 #include "ActsExamples/EventData/GeometryContainers.hpp"
0021 #include "ActsExamples/EventData/Index.hpp"
0022 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0023 #include "ActsExamples/EventData/Measurement.hpp"
0024 #include "ActsExamples/EventData/Track.hpp"
0025 #include "ActsExamples/EventData/Trajectories.hpp"
0026 
0027 #include "edm4eic/TrackerHitCollection.h"
0028 
0029 #include "Acts/Definitions/Common.hpp"
0030 #include "Acts/Geometry/TrackingGeometry.hpp"
0031 #include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp"
0032 #include "Acts/TrackFinding/MeasurementSelector.hpp"
0033 
0034 namespace Jug::Reco {
0035 
0036 /** Fitting algorithm implmentation .
0037  *
0038  * \ingroup tracking
0039  */
0040 class CKFTracking : public Gaudi::Algorithm {
0041 public:
0042   /// Track finder function that takes input measurements, initial trackstate
0043   /// and track finder options and returns some track-finder-specific result.
0044 #if Acts_VERSION_MAJOR >= 39
0045   using TrackFinderOptions =
0046       Acts::CombinatorialKalmanFilterOptions<ActsExamples::TrackContainer>;
0047 #elif Acts_VERSION_MAJOR >= 36
0048   using TrackFinderOptions =
0049       Acts::CombinatorialKalmanFilterOptions<ActsExamples::IndexSourceLinkAccessor::Iterator,
0050                                              ActsExamples::TrackContainer>;
0051 #else
0052   using TrackFinderOptions =
0053       Acts::CombinatorialKalmanFilterOptions<ActsExamples::IndexSourceLinkAccessor::Iterator,
0054                                              Acts::VectorMultiTrajectory>;
0055 #endif
0056   using TrackFinderResult =
0057       Acts::Result<std::vector<ActsExamples::TrackContainer::TrackProxy>>;
0058 
0059   /// Find function that takes the above parameters
0060   /// @note This is separated into a virtual interface to keep compilation units
0061   /// small
0062   class CKFTrackingFunction {
0063    public:
0064     virtual ~CKFTrackingFunction() = default;
0065     virtual TrackFinderResult operator()(const ActsExamples::TrackParameters&,
0066                                          const TrackFinderOptions&,
0067                                          ActsExamples::TrackContainer&) const = 0;
0068   };
0069 
0070   /// Create the track finder function implementation.
0071   /// The magnetic field is intentionally given by-value since the variant
0072   /// contains shared_ptr anyways.
0073   static std::shared_ptr<CKFTrackingFunction> makeCKFTrackingFunction(
0074     std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
0075     std::shared_ptr<const Acts::MagneticFieldProvider> magneticField);
0076 
0077 public:
0078 #if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1)
0079   mutable DataHandle<ActsExamples::IndexSourceLinkContainer> m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this};
0080 #endif
0081   mutable DataHandle<ActsExamples::MeasurementContainer> m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this};
0082   mutable DataHandle<ActsExamples::TrackParametersContainer> m_inputInitialTrackParameters{"inputInitialTrackParameters",
0083                                                                      Gaudi::DataHandle::Reader, this};
0084   mutable DataHandle<ActsExamples::ConstTrackContainer> m_outputTracks{"outputTracks", Gaudi::DataHandle::Writer, this};
0085   mutable DataHandle<ActsExamples::TrajectoriesContainer> m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this};
0086 
0087   Gaudi::Property<std::vector<double>> m_etaBins{this, "etaBins", {}};
0088   Gaudi::Property<std::vector<double>> m_chi2CutOff{this, "chi2CutOff", {15.}};
0089   Gaudi::Property<std::vector<size_t>> m_numMeasurementsCutOff{this, "numMeasurementsCutOff", {10}};
0090 
0091   std::shared_ptr<CKFTrackingFunction> m_trackFinderFunc;
0092   SmartIF<IGeoSvc> m_geoSvc;
0093   SmartIF<IActsGeoSvc> m_actsGeoSvc;
0094 
0095   std::shared_ptr<const Jug::BField::DD4hepBField> m_BField = nullptr;
0096   Acts::GeometryContext m_geoctx;
0097   Acts::CalibrationContext m_calibctx;
0098   Acts::MagneticFieldContext m_fieldctx;
0099 
0100   Acts::MeasurementSelector::Config m_sourcelinkSelectorCfg;
0101   Acts::Logging::Level m_actsLoggingLevel = Acts::Logging::INFO;
0102 
0103   CKFTracking(const std::string& name, ISvcLocator* svcLoc);
0104 
0105   StatusCode initialize() override;
0106 
0107   StatusCode execute(const EventContext&) const override;
0108 };
0109 
0110 } // namespace Jug::Reco
0111 
0112 #endif