ATLAS Offline Software
GlobalChiSquareFitterTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSGEOMETRY_GLOBALCHISQUAREFITTERTOOL_H
6 #define ACTSGEOMETRY_GLOBALCHISQUAREFITTERTOOL_H
7 
9 #include "GaudiKernel/EventContext.h"
10 #include "GaudiKernel/ToolHandle.h"
18 
19 // ACTS
20 #include "Acts/EventData/TrackParameters.hpp"
21 #include "Acts/EventData/TrackProxy.hpp"
22 #include "Acts/EventData/VectorTrackContainer.hpp"
23 #include "Acts/Geometry/GeometryIdentifier.hpp"
24 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
25 #include "Acts/Propagator/Navigator.hpp"
26 #include "Acts/Propagator/Propagator.hpp"
27 #include "Acts/Propagator/SympyStepper.hpp"
28 #include "Acts/TrackFitting/GlobalChiSquareFitter.hpp"
29 
30 // PACKAGE
36 
37 // STL
38 #include <cmath> //std::abs
39 #include <limits> //for numeric_limits
40 #include <memory> //unique_ptr
41 #include <string>
42 
44 
45 class EventContext;
46 
47 namespace Trk {
48 class Track;
49 class PrepRawData;
50 } // namespace Trk
51 
52 namespace ActsTrk {
53 
54 // TODO: those are defined in KalmanFitter.h -> make more general?
56  const Trk::PrepRawData* prd{nullptr};
57 };
58 
60  template <typename trajectory_t>
61  void calibrate(const Acts::GeometryContext& gctx,
62  const Acts::CalibrationContext& cctx,
63  const Acts::SourceLink& sl,
64  typename trajectory_t::TrackStateProxy trackState) const;
65 
69 };
70 
73 
74  const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const;
75 };
76 
78  : public extends<AthAlgTool, Trk::ITrackFitter, ActsTrk::IFitterTool> {
79  public:
80  GlobalChiSquareFitterTool(const std::string&, const std::string&,
81  const IInterface*);
82  virtual ~GlobalChiSquareFitterTool() = default;
83 
84  // standard Athena methods
85  virtual StatusCode initialize() override;
86 
88  virtual std::unique_ptr<Trk::Track> fit(
89  const EventContext& ctx, const Trk::Track&,
90  const Trk::RunOutlierRemoval runOutlier = false,
91  const Trk::ParticleHypothesis matEffects =
92  Trk::nonInteracting) const override;
93 
95  virtual std::unique_ptr<Trk::Track> fit(
96  const EventContext& ctx, const Trk::PrepRawDataSet&,
97  const Trk::TrackParameters&,
98  const Trk::RunOutlierRemoval runOutlier = false,
99  const Trk::ParticleHypothesis matEffects =
100  Trk::nonInteracting) const override;
101 
103  virtual std::unique_ptr<Trk::Track> fit(
104  const EventContext& ctx, const Trk::MeasurementSet&,
105  const Trk::TrackParameters&,
106  const Trk::RunOutlierRemoval runOutlier = false,
107  const Trk::ParticleHypothesis matEffects =
108  Trk::nonInteracting) const override;
109 
111  virtual std::unique_ptr<Trk::Track> fit(
112  const EventContext& ctx, const Trk::Track&, const Trk::PrepRawDataSet&,
113  const Trk::RunOutlierRemoval runOutlier = false,
114  const Trk::ParticleHypothesis matEffects =
115  Trk::nonInteracting) const override;
116 
118  virtual std::unique_ptr<ActsTrk::MutableTrackContainer> fit(
119  const EventContext& ctx,
120  const std::vector<ActsTrk::ATLASUncalibSourceLink>& clusterList,
121  const Acts::BoundTrackParameters& initialParams,
122  const Acts::GeometryContext& tgContext,
123  const Acts::MagneticFieldContext& mfContext,
124  const Acts::CalibrationContext& calContext,
125  const DetectorElementToActsGeometryIdMap& detectorElementToGeometryIdMap,
126  const Acts::Surface* targetSurface =
127  nullptr // optional target surface - defaults to perigee in global
128  // origin
129  ) const override;
130 
132  virtual std::unique_ptr<Trk::Track> fit(
133  const EventContext& ctx, const Trk::Track&, const Trk::MeasurementSet&,
134  const Trk::RunOutlierRemoval runOutlier = false,
135  const Trk::ParticleHypothesis matEffects =
136  Trk::nonInteracting) const override;
137 
139  virtual std::unique_ptr<Trk::Track> fit(
140  const EventContext& ctx, const Trk::Track& intrk1,
141  const Trk::Track& intrk2, const Trk::RunOutlierRemoval runOutlier = false,
142  const Trk::ParticleHypothesis matEffects =
143  Trk::nonInteracting) const override;
144 
146  virtual std::unique_ptr<ActsTrk::MutableTrackContainer> fit(
147  const EventContext& ctx, const ActsTrk::Seed& seed,
148  const Acts::BoundTrackParameters& initialParams,
149  const Acts::GeometryContext& tgContext,
150  const Acts::MagneticFieldContext& mfContext,
151  const Acts::CalibrationContext& calContext,
152  const DetectorElementToActsGeometryIdMap& detectorElementToGeometryIdMap)
153  const override;
154 
156  // Private methods:
158  private:
159  // Create a track from the fitter result
160  std::unique_ptr<Trk::Track> makeTrack(
161  const EventContext& ctx, Acts::GeometryContext& tgContext,
163  Acts::Result<ActsTrk::MutableTrackContainer::TrackProxy, std::error_code>&
164  fitResult,
165  bool SourceLinkType = false) const;
166  // parameter (bool) SourceLinkType to distinguish between ATLASSourceLink and
167  // PRDSourceLink implementation. bool SourceLinkType = false for
168  // ATLASSourceLink bool SourceLinkType = true for PRDSourceLink
169 
170  ToolHandle<IActsExtrapolationTool> m_extrapolationTool{
171  this, "ExtrapolationTool", ""};
172  ToolHandle<IActsTrackingGeometryTool> m_trackingGeometryTool{
173  this, "TrackingGeometryTool", ""};
174  ToolHandle<ActsTrk::IActsToTrkConverterTool> m_ATLASConverterTool{
175  this, "ATLASConverterTool", ""};
176  ToolHandle<Trk::IExtendedTrackSummaryTool> m_trkSummaryTool{
177  this, "SummaryTool", "", "ToolHandle for track summary tool"};
178  ToolHandle<Trk::IBoundaryCheckTool> m_boundaryCheckTool{
179  this, "BoundaryCheckTool", "",
180  "Boundary checking tool for detector sensitivities"};
181 
182  // the settable job options
183  Gaudi::Property<double> m_option_outlierChi2Cut{
184  this, "OutlierChi2Cut", 12.5, "Chi2 cut used by the outlier finder"};
185  Gaudi::Property<int> m_option_maxPropagationStep{
186  this, "MaxPropagationStep", 5000,
187  "Maximum number of steps for one propagate call"};
188  Gaudi::Property<double> m_option_seedCovarianceScale{
189  this, "SeedCovarianceScale", 100.,
190  "Scale factor for the input seed covariance when doing refitting"};
191 
192  std::unique_ptr<ActsTrk::detail::TrkMeasurementCalibrator> m_calibrator{
193  nullptr};
194 
196  using Fitter = Acts::Experimental::Gx2Fitter<
197  Acts::Propagator<Acts::SympyStepper, Acts::Navigator>,
199  std::unique_ptr<Fitter> m_fitter{nullptr};
200 
201  Acts::Experimental::Gx2FitterExtensions<ActsTrk::MutableTrackStateBackend>
203 
205 
207  const Acts::Logger& logger() const { return *m_logger; }
208 
210  std::unique_ptr<const Acts::Logger> m_logger;
211 
212  ToolHandle<Trk::IRIO_OnTrackCreator> m_broadROTcreator{
213  this, "BroadRotCreatorTool", ""};
214  ToolHandle<Trk::IRIO_OnTrackCreator> m_ROTcreator{this, "RotCreatorTool", ""};
215  // Gaudi Property to choose from PRD or ROT measurement ReFit
216  Gaudi::Property<bool> m_doReFitFromPRD{this, "DoReFitFromPRD", false,
217  "Do Refit From PRD instead of ROT"};
218 };
219 
220 } // namespace ActsTrk
221 #endif
ActsTrk::GlobalChiSquareFitterTool::Fitter
Acts::Experimental::Gx2Fitter< Acts::Propagator< Acts::SympyStepper, Acts::Navigator >, ActsTrk::MutableTrackStateBackend > Fitter
Type erased track fitter function.
Definition: GlobalChiSquareFitterTool.h:198
ActsTrk::GlobalChiSquareFitterTool::m_doReFitFromPRD
Gaudi::Property< bool > m_doReFitFromPRD
Definition: GlobalChiSquareFitterTool.h:216
ActsTrk::PRDSourceLinkCalibratorGX2F::calibrate
void calibrate(const Acts::GeometryContext &gctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &sl, typename trajectory_t::TrackStateProxy trackState) const
The following is the implementation of the PRDSourceLinkCalibratorGX2F.
Definition: GlobalChiSquareFitterTool.cxx:57
Trk::PrepRawDataSet
std::vector< const PrepRawData * > PrepRawDataSet
vector of clusters and drift circles
Definition: FitterTypes.h:26
ActsTrk::DetectorElementToActsGeometryIdMap
Definition: DetectorElementToActsGeometryIdMap.h:31
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
ActsTrk::GlobalChiSquareFitterTool::~GlobalChiSquareFitterTool
virtual ~GlobalChiSquareFitterTool()=default
ActsTrk::GlobalChiSquareFitterTool::m_extrapolationTool
ToolHandle< IActsExtrapolationTool > m_extrapolationTool
Definition: GlobalChiSquareFitterTool.h:170
IRIO_OnTrackCreator.h
ActsTrk::GlobalChiSquareFitterTool::m_logger
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Definition: GlobalChiSquareFitterTool.h:210
ActsTrk::PRDSourceLinkCalibratorGX2F
Definition: GlobalChiSquareFitterTool.h:59
ActsTrk::GlobalChiSquareFitterTool::logger
const Acts::Logger & logger() const
Private access to the logger.
Definition: GlobalChiSquareFitterTool.h:207
ActsTrk::GlobalChiSquareFitterTool::GlobalChiSquareFitterTool
GlobalChiSquareFitterTool(const std::string &, const std::string &, const IInterface *)
Definition: GlobalChiSquareFitterTool.cxx:160
ActsTrk::GlobalChiSquareFitterTool::fit
virtual std::unique_ptr< Trk::Track > fit(const EventContext &ctx, const Trk::Track &, const Trk::RunOutlierRemoval runOutlier=false, const Trk::ParticleHypothesis matEffects=Trk::nonInteracting) const override
refit a track
Definition: GlobalChiSquareFitterTool.cxx:211
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder
Outlier finder using a Chi2 cut.
Definition: FitterHelperFunctions.h:49
PdgToParticleHypothesis.h
ActsTrk::GlobalChiSquareFitterTool::m_option_outlierChi2Cut
Gaudi::Property< double > m_option_outlierChi2Cut
Definition: GlobalChiSquareFitterTool.h:183
PrepRawData.h
Trk::RunOutlierRemoval
bool RunOutlierRemoval
switch to toggle quality processing after fit
Definition: FitterTypes.h:22
ActsTrk::PRDSourceLinkCalibratorGX2F::rotCreator
const Trk::IRIO_OnTrackCreator * rotCreator
Definition: GlobalChiSquareFitterTool.h:66
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
ActsTrk::MutableMultiTrajectory
Athena implementation of ACTS::MultiTrajectory (ReadWrite version) The data is stored in 4 external b...
Definition: MultiTrajectory.h:81
ActsTrk::PRDSourceLinkSurfaceAccessorGX2F::operator()
const Acts::Surface * operator()(const Acts::SourceLink &sourceLink) const
Definition: GlobalChiSquareFitterTool.cxx:152
ActsTrk::GlobalChiSquareFitterTool::m_boundaryCheckTool
ToolHandle< Trk::IBoundaryCheckTool > m_boundaryCheckTool
Definition: GlobalChiSquareFitterTool.h:178
ActsTrk::GlobalChiSquareFitterTool::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition: GlobalChiSquareFitterTool.h:172
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ActsTrk::GlobalChiSquareFitterTool::m_calibrator
std::unique_ptr< ActsTrk::detail::TrkMeasurementCalibrator > m_calibrator
Definition: GlobalChiSquareFitterTool.h:192
ActsTrk::IActsToTrkConverterTool
Definition: IActsToTrkConverterTool.h:43
AthAlgTool.h
ActsTrk::GlobalChiSquareFitterTool::m_ATLASConverterTool
ToolHandle< ActsTrk::IActsToTrkConverterTool > m_ATLASConverterTool
Definition: GlobalChiSquareFitterTool.h:174
ActsTrk::PRDSourceLinkCalibratorGX2F::converterTool
const ActsTrk::IActsToTrkConverterTool * converterTool
Definition: GlobalChiSquareFitterTool.h:68
ActsTrk::GlobalChiSquareFitterTool
Definition: GlobalChiSquareFitterTool.h:78
ActsTrk::Seed
Acts::Seed< xAOD::SpacePoint, 3ul > Seed
Definition: Seed.h:12
Trk::ParametersBase
Definition: ParametersBase.h:55
ActsTrk::GlobalChiSquareFitterTool::makeTrack
std::unique_ptr< Trk::Track > makeTrack(const EventContext &ctx, Acts::GeometryContext &tgContext, ActsTrk::MutableTrackContainer &tracks, Acts::Result< ActsTrk::MutableTrackContainer::TrackProxy, std::error_code > &fitResult, bool SourceLinkType=false) const
Definition: GlobalChiSquareFitterTool.cxx:661
ActsTrk::PRDSourceLinkSurfaceAccessorGX2F
Definition: GlobalChiSquareFitterTool.h:71
ActsTrk::GlobalChiSquareFitterTool::m_gx2fExtensions
Acts::Experimental::Gx2FitterExtensions< ActsTrk::MutableTrackStateBackend > m_gx2fExtensions
Definition: GlobalChiSquareFitterTool.h:202
Trk::MeasurementSet
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
Definition: FitterTypes.h:30
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
ActsTrk::GlobalChiSquareFitterTool::initialize
virtual StatusCode initialize() override
Definition: GlobalChiSquareFitterTool.cxx:165
ActsTrk::GlobalChiSquareFitterTool::m_ROTcreator
ToolHandle< Trk::IRIO_OnTrackCreator > m_ROTcreator
Definition: GlobalChiSquareFitterTool.h:214
Trk::nonInteracting
@ nonInteracting
Definition: ParticleHypothesis.h:25
IFitterTool.h
ActsTrk::GlobalChiSquareFitterTool::m_option_seedCovarianceScale
Gaudi::Property< double > m_option_seedCovarianceScale
Definition: GlobalChiSquareFitterTool.h:188
ActsTrk::PRDSourceLinkGX2F::prd
const Trk::PrepRawData * prd
Definition: GlobalChiSquareFitterTool.h:56
ActsTrk::PRDSourceLinkGX2F
Definition: GlobalChiSquareFitterTool.h:55
ActsTrk::GlobalChiSquareFitterTool::m_broadROTcreator
ToolHandle< Trk::IRIO_OnTrackCreator > m_broadROTcreator
Definition: GlobalChiSquareFitterTool.h:212
FitterHelperFunctions.h
ActsTrk::PRDSourceLinkSurfaceAccessorGX2F::converterTool
const ActsTrk::IActsToTrkConverterTool * converterTool
Definition: GlobalChiSquareFitterTool.h:72
IExtendedTrackSummaryTool.h
IBoundaryCheckTool.h
TrkMeasurementCalibrator.h
ActsTrk::GlobalChiSquareFitterTool::m_fitter
std::unique_ptr< Fitter > m_fitter
Definition: GlobalChiSquareFitterTool.h:199
ActsTrk::PRDSourceLinkCalibratorGX2F::broadRotCreator
const Trk::IRIO_OnTrackCreator * broadRotCreator
Definition: GlobalChiSquareFitterTool.h:67
IActsToTrkConverterTool.h
ActsTrk::GlobalChiSquareFitterTool::m_trkSummaryTool
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trkSummaryTool
Definition: GlobalChiSquareFitterTool.h:176
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
Trk::IRIO_OnTrackCreator
Interface class for transforming Trk::PrepRawData to Trk::RIO_OnTrack using a local track hypothesis.
Definition: IRIO_OnTrackCreator.h:33
ActsTrk::GlobalChiSquareFitterTool::m_outlierFinder
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder m_outlierFinder
Definition: GlobalChiSquareFitterTool.h:204
ActsTrk::MutableTrackContainer
Definition: TrackContainer.h:122
ITrackFitter.h
TrackContainer.h
IActsTrackingGeometryTool.h
ActsTrk::GlobalChiSquareFitterTool::m_option_maxPropagationStep
Gaudi::Property< int > m_option_maxPropagationStep
Definition: GlobalChiSquareFitterTool.h:185
IActsExtrapolationTool.h