File indexing completed on 2024-11-16 10:01:27
0001
0002
0003
0004 #ifndef JUGGLER_JUGRECO_TrackFittingAlgorithm_HH
0005 #define JUGGLER_JUGRECO_TrackFittingAlgorithm_HH 1
0006
0007 #include <functional>
0008 #include <stdexcept>
0009 #include <vector>
0010 #include <random>
0011 #include <stdexcept>
0012
0013 #include "GaudiAlg/GaudiAlgorithm.h"
0014 #include "GaudiKernel/ToolHandle.h"
0015 #include "Gaudi/Property.h"
0016
0017 #include <k4FWCore/DataHandle.h>
0018 #include <k4Interface/IGeoSvc.h>
0019 #include <k4ActsTracking/IActsGeoSvc.h>
0020 #include "JugBase/BField/DD4hepBField.h"
0021 #include "ActsExamples/EventData/GeometryContainers.hpp"
0022 #include "ActsExamples/EventData/IndexSourceLink.hpp"
0023 #include "ActsExamples/EventData/Track.hpp"
0024 #include "ActsExamples/EventData/Measurement.hpp"
0025 #include "ActsExamples/EventData/Trajectories.hpp"
0026 #include "ActsExamples/EventData/ProtoTrack.hpp"
0027
0028 #include "edm4eic/TrackerHitCollection.h"
0029
0030 #include "Acts/Definitions/Common.hpp"
0031 #include "Acts/Geometry/TrackingGeometry.hpp"
0032 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
0033 #include "Acts/TrackFitting/KalmanFitter.hpp"
0034 #include "Acts/TrackFitting/GainMatrixSmoother.hpp"
0035 #include "Acts/TrackFitting/GainMatrixUpdater.hpp"
0036 #include "Acts/Geometry/TrackingGeometry.hpp"
0037 #include "Acts/Definitions/Common.hpp"
0038
0039
0040 namespace Jug::Reco {
0041
0042
0043
0044
0045
0046 class TrackFittingAlgorithm : public GaudiAlgorithm {
0047 public:
0048
0049
0050 using TrackFitterOptions =
0051 Acts::KalmanFitterOptions<Acts::VectorMultiTrajectory>;
0052
0053 using FitterResult =
0054 Acts::Result<Acts::KalmanFitterResult<Acts::VectorMultiTrajectory>>;
0055
0056
0057 using FitterFunction = std::function<FitterResult(
0058 const std::vector<ActsExamples::IndexSourceLink>&, const ActsExamples::TrackParameters&, const TrackFitterOptions&)>;
0059
0060 public:
0061 DataHandle<ActsExamples::IndexSourceLinkContainer> m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this};
0062 DataHandle<ActsExamples::TrackParametersContainer> m_initialTrackParameters{"initialTrackParameters", Gaudi::DataHandle::Reader, this};
0063 DataHandle<ActsExamples::MeasurementContainer> m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this};
0064 DataHandle<ActsExamples::ProtoTrackContainer> m_inputProtoTracks{"inputProtoTracks", Gaudi::DataHandle::Reader, this};
0065 DataHandle<ActsExamples::TrajectoriesContainer> m_foundTracks{"foundTracks", Gaudi::DataHandle::Reader, this};
0066 DataHandle<ActsExamples::TrajectoriesContainer> m_outputTrajectories{"outputTrajectories", Gaudi::DataHandle::Writer, this};
0067
0068 FitterFunction m_trackFittingFunc;
0069 SmartIF<IGeoSvc> m_geoSvc;
0070 SmartIF<IActsGeoSvc> m_actsGeoSvc;
0071 std::shared_ptr<const Jug::BField::DD4hepBField> m_BField = nullptr;
0072 Acts::GeometryContext m_geoctx;
0073 Acts::CalibrationContext m_calibctx;
0074 Acts::MagneticFieldContext m_fieldctx;
0075
0076
0077
0078 TrackFittingAlgorithm(const std::string& name, ISvcLocator* svcLoc);
0079
0080
0081
0082
0083
0084 static FitterFunction
0085 makeTrackFittingFunction(std::shared_ptr<const Acts::TrackingGeometry> trackingGeometry,
0086 std::shared_ptr<const Acts::MagneticFieldProvider> magneticField);
0087
0088 StatusCode initialize() override;
0089
0090 StatusCode execute() override;
0091 private:
0092
0093 FitterResult fitTrack(
0094 const std::vector<ActsExamples::IndexSourceLink>& sourceLinks,
0095 const ActsExamples::TrackParameters& initialParameters,
0096 const TrackFitterOptions& options
0097 ) const;
0098 };
0099
0100 inline TrackFittingAlgorithm::FitterResult
0101 TrackFittingAlgorithm::fitTrack(const std::vector<ActsExamples::IndexSourceLink>& sourceLinks,
0102 const ActsExamples::TrackParameters& initialParameters,
0103 const TrackFitterOptions& options) const
0104 {
0105 return m_trackFittingFunc(sourceLinks, initialParameters, options);
0106 }
0107
0108 }
0109
0110 #endif