ATLAS Offline Software
GaussianSumFitterTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // ATHENA
12 
13 // ACTS
14 #include "Acts/Propagator/MultiEigenStepperLoop.hpp"
15 #include "Acts/MagneticField/MagneticFieldContext.hpp"
16 #include "Acts/Surfaces/PerigeeSurface.hpp"
17 #include "Acts/Utilities/CalibrationContext.hpp"
18 #include "Acts/Definitions/TrackParametrization.hpp"
19 #include "Acts/Definitions/Units.hpp"
20 #include "Acts/Propagator/EigenStepper.hpp"
21 #include "Acts/Surfaces/Surface.hpp"
22 #include "Acts/TrackFitting/GsfMixtureReduction.hpp"
23 #include "Acts/Utilities/Helpers.hpp"
24 #include "Acts/EventData/VectorMultiTrajectory.hpp"
25 #include "Acts/EventData/VectorTrackContainer.hpp"
26 #include "Acts/EventData/TrackParameters.hpp"
27 #include "Acts/Utilities/Logger.hpp"
28 #include "Acts/Utilities/CalibrationContext.hpp"
30 
31 // PACKAGE
34 #include "ActsInterop/Logger.h"
37 #include "Acts/Propagator/DirectNavigator.hpp"
38 
39 // STL
40 #include <vector>
41 #include <bitset>
42 #include <type_traits>
43 #include <system_error>
44 
45 namespace ActsTrk {
46 
48  const std::string& n,
49  const IInterface* p) :
50  base_class(t,n,p)
51 {}
52 
54  ATH_MSG_DEBUG(name() << "::" << __FUNCTION__);
55 
57  ATH_CHECK(m_extrapolationTool.retrieve());
58  ATH_CHECK(m_ATLASConverterTool.retrieve());
59  if (!m_refitOnly) {
60  ATH_CHECK(m_trkSummaryTool.retrieve());
61  }else{
62  ATH_MSG_INFO("Running GSF without track summary");
63  }
64 
65  m_logger = makeActsAthenaLogger(this, "Acts Gaussian Sum Refit");
66 
67  auto field = std::make_shared<ATLASMagneticFieldWrapper>();
68  Acts::MultiEigenStepperLoop<> stepper(field);
69  Acts::Navigator navigator( Acts::Navigator::Config{ m_trackingGeometryTool->trackingGeometry() },
70  logger().cloneWithSuffix("Navigator") );
71  Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::Navigator> propagator(std::move(stepper),
72  std::move(navigator),
73  logger().cloneWithSuffix("Prop"));
74 
75  Acts::AtlasBetheHeitlerApprox<6, 5> bha = Acts::makeDefaultBetheHeitlerApprox();
76  m_fitter = std::make_unique<Fitter>(std::move(propagator), std::move(bha),
77  logger().cloneWithSuffix("GaussianSumFitter"));
78 
79  // Direct Fitter
81  Acts::DirectNavigator directNavigator( logger().cloneWithSuffix("DirectNavigator") );
82  Acts::MultiEigenStepperLoop<> stepperDirect(field);
83  Acts::Propagator<Acts::MultiEigenStepperLoop<>, Acts::DirectNavigator> directPropagator(std::move(stepperDirect),
84  std::move(directNavigator),
85  logger().cloneWithSuffix("DirectPropagator"));
86  Acts::AtlasBetheHeitlerApprox<6, 5> bhaDirect = Acts::makeDefaultBetheHeitlerApprox();
87  m_directFitter = std::make_unique<DirectFitter>(std::move(directPropagator),std::move(bhaDirect),
88  logger().cloneWithSuffix("DirectGaussianSumFitter"));
89 
90  }
91 
92  m_gsfExtensions.updater.connect<&ActsTrk::detail::FitterHelperFunctions::gainMatrixUpdate<ActsTrk::MutableTrackStateBackend>>();
93  m_calibrator = std::make_unique<ActsTrk::detail::TrkMeasurementCalibrator>(*m_ATLASConverterTool);
94  m_gsfExtensions.calibrator.connect<&ActsTrk::detail::TrkMeasurementCalibrator::calibrate<ActsTrk::MutableTrackStateBackend>>(m_calibrator.get());
95 
96  m_surfaceAccessor.m_converterTool = &(*m_ATLASConverterTool);
97  m_gsfExtensions.surfaceAccessor.connect<&ATLASSourceLinkSurfaceAccessor::operator()>(&m_surfaceAccessor);
98  m_gsfExtensions.mixtureReducer.connect<&Acts::reduceMixtureWithKLDistance>();
99 
101  m_gsfExtensions.outlierFinder.connect<&ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder::operator()<ActsTrk::MutableTrackStateBackend>>(&m_outlierFinder);
103  m_componentMergeMethod = Acts::ComponentMergeMethod::eMean;
104  else if(m_option_componentMergeMethod == "eMaxWeight" || m_option_componentMergeMethod == "maxWeight"){
105  m_componentMergeMethod = Acts::ComponentMergeMethod::eMaxWeight;
106  }else{
107  throw std::runtime_error("Unknown option for ComponentMergeMethod: " + m_option_componentMergeMethod.value());
108  }
109 
110  ATH_MSG_INFO("ACTS GSF direct nav " << m_useDirectNavigation.value());
111  ATH_MSG_INFO("ACTS GSF max cmps " << m_maxComponents.value());
112  ATH_MSG_INFO("ACTS GSF merge meth " << m_option_componentMergeMethod.value());
113  ATH_MSG_INFO("ACTS GSF weight ctf " << m_weightCutOff.value());
114  ATH_MSG_INFO("ACTS GSF outlier chi2 " << m_option_outlierChi2Cut.value());
115 
116  return StatusCode::SUCCESS;
117 }
118 
119 // refit a track
120 // -------------------------------------------------------
121 std::unique_ptr<Trk::Track>
122 GaussianSumFitterTool::fit(const EventContext& ctx,
123  const Trk::Track& inputTrack,
124  const Trk::RunOutlierRemoval /*runOutlier*/,
125  const Trk::ParticleHypothesis /*prtHypothesis*/) const
126 {
127 
128 
129  std::unique_ptr<Trk::Track> track = nullptr;
130  ATH_MSG_VERBOSE ("--> enter GaussianSumFitter::fit(Track,,) with Track from author = "
131  << inputTrack.info().dumpInfo());
132 
133  // protection against not having measurements on the input track
134  if (!inputTrack.measurementsOnTrack() || inputTrack.measurementsOnTrack()->size() < 2) {
135  ATH_MSG_DEBUG("called to refit empty track or track with too little information, reject fit");
136  return nullptr;
137  }
138 
139  // protection against not having track parameters on the input track
140  if (!inputTrack.trackParameters() || inputTrack.trackParameters()->empty()) {
141  ATH_MSG_DEBUG("input fails to provide track parameters for seeding the GSF, reject fit");
142  return nullptr;
143  }
144 
145  // Construct a perigee surface as the target surface
146  std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
147  Acts::Vector3{0., 0., 0.});
148 
149  Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
150  Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
151  // CalibrationContext converter not implemented yet.
152  Acts::CalibrationContext calContext{};
153 
154  // Set the GaussianSumFitter options
155  Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
156  gsfOptions = prepareOptions(tgContext,
157  mfContext,
158  calContext,
159  *pSurface);
160  gsfOptions.maxComponents = m_maxComponents;
161  gsfOptions.weightCutoff = m_weightCutOff;
162  gsfOptions.componentMergeMethod = m_componentMergeMethod;
163 
164 
165  std::vector<Acts::SourceLink> trackSourceLinks = m_ATLASConverterTool->trkTrackToSourceLinks(tgContext,inputTrack);
166  const auto& initialParams = m_ATLASConverterTool->trkTrackParametersToActsParameters((*inputTrack.perigeeParameters()), tgContext);
167 
168  return performFit(ctx,
169  tgContext,
170  gsfOptions,
171  trackSourceLinks,
172  initialParams);
173 }
174 
175 // fit a set of MeasurementBase objects
176 // --------------------------------
177 std::unique_ptr<Trk::Track>
178 GaussianSumFitterTool::fit(const EventContext& ctx,
179  const Trk::MeasurementSet& inputMeasSet,
180  const Trk::TrackParameters& estimatedStartParameters,
181  const Trk::RunOutlierRemoval /*runOutlier*/,
182  const Trk::ParticleHypothesis /*matEffects*/) const
183 {
184  std::unique_ptr<Trk::Track> track = nullptr;
185  // protection against not having measurements on the input track
186  if (inputMeasSet.size() < 2) {
187  ATH_MSG_DEBUG("called to refit empty measurement set or a measurement set with too little information, reject fit");
188  return nullptr;
189  }
190 
191  // Construct a perigee surface as the target surface
192  std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
193  Acts::Vector3{0., 0., 0.});
194 
195  Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
196  Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
197  // CalibrationContext converter not implemented yet.
198  Acts::CalibrationContext calContext{};
199 
200  // Set the GaussianSumFitter options
201  Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
202  gsfOptions = prepareOptions(tgContext,
203  mfContext,
204  calContext,
205  *pSurface);
206 
207  // Set abortOnError to false, else the refitting crashes if no forward propagation is done. Here, we just skip the event and continue.
208  gsfOptions.abortOnError = false;
209 
210  std::vector< Acts::SourceLink > trackSourceLinks;
211  trackSourceLinks.reserve(inputMeasSet.size());
212 
213  for (auto* measSet : inputMeasSet) {
214  trackSourceLinks.push_back(m_ATLASConverterTool->trkMeasurementToSourceLink(tgContext, *measSet));
215  }
216 
217  const auto& initialParams = m_ATLASConverterTool->trkTrackParametersToActsParameters(estimatedStartParameters, tgContext);
218 
220 
221  std::vector<const Acts::Surface*> surfaces;
222  surfaces.reserve(inputMeasSet.size());
223  for (auto* measSet : inputMeasSet) {
224  const auto& slink = m_ATLASConverterTool->trkMeasurementToSourceLink(tgContext, *measSet);
225  const auto& sl = slink.get<ATLASSourceLink>();
226  const auto& trkSrf = sl->associatedSurface();
227  const auto& actsSrf = m_ATLASConverterTool->trkSurfaceToActsSurface(trkSrf);
228  surfaces.push_back(&actsSrf);
229  }
230 
231  return performDirectFit(ctx,
232  tgContext,
233  gsfOptions,
234  trackSourceLinks,
235  initialParams,
236  surfaces);
237  }else{
238  return performFit(ctx,
239  tgContext,
240  gsfOptions,
241  trackSourceLinks,
242  initialParams);
243  }
244 }
245 
246 // fit a set of PrepRawData objects
247 // --------------------------------
248 std::unique_ptr<Trk::Track>
249 GaussianSumFitterTool::fit(const EventContext& /*ctx*/,
250  const Trk::PrepRawDataSet& /*inputPRDColl*/,
251  const Trk::TrackParameters& /*estimatedStartParameters*/,
252  const Trk::RunOutlierRemoval /*runOutlier*/,
253  const Trk::ParticleHypothesis /*prtHypothesis*/) const
254 {
255  ATH_MSG_DEBUG("Fit of PrepRawDataSet not yet implemented");
256  return nullptr;
257 }
258 
259 // extend a track fit to include an additional set of MeasurementBase objects
260 // re-implements the TrkFitterUtils/TrackFitter.cxx general code in a more
261 // mem efficient and stable way
262 // --------------------------------
263 std::unique_ptr<Trk::Track>
264 GaussianSumFitterTool::fit(const EventContext& ctx,
265  const Trk::Track& inputTrack,
266  const Trk::MeasurementSet& addMeasColl,
267  const Trk::RunOutlierRemoval /*runOutlier*/,
268  const Trk::ParticleHypothesis /*matEffects*/) const
269 {
270  ATH_MSG_VERBOSE ("--> enter GaussianSumFitter::fit(Track,Meas'BaseSet,,)");
271  ATH_MSG_VERBOSE (" with Track from author = " << inputTrack.info().dumpInfo());
272 
273  // protection, if empty MeasurementSet
274  if (addMeasColl.empty()) {
275  ATH_MSG_DEBUG( "client tries to add an empty MeasurementSet to the track fit." );
276  return fit(ctx,inputTrack);
277  }
278 
279  // protection against not having measurements on the input track
280  if (!inputTrack.measurementsOnTrack() || (inputTrack.measurementsOnTrack()->size() < 2 && addMeasColl.empty())) {
281  ATH_MSG_DEBUG("called to refit empty track or track with too little information, reject fit");
282  return nullptr;
283  }
284 
285  // protection against not having track parameters on the input track
286  if (!inputTrack.trackParameters() || inputTrack.trackParameters()->empty()) {
287  ATH_MSG_DEBUG("input fails to provide track parameters for seeding the GSF, reject fit");
288  return nullptr;
289  }
290 
291  std::unique_ptr<Trk::Track> track = nullptr;
292 
293  // Construct a perigee surface as the target surface
294  std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(Acts::Vector3{0., 0., 0.});
295 
296  Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
297  Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
298  // CalibrationContext converter not implemented yet.
299  Acts::CalibrationContext calContext{};
300 
301  // Set the GaussianSumFitter options
302  Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
303  gsfOptions = prepareOptions(tgContext,
304  mfContext,
305  calContext,
306  *pSurface);
307 
308  std::vector<Acts::SourceLink> trackSourceLinks = m_ATLASConverterTool->trkTrackToSourceLinks(tgContext, inputTrack);
309  const auto& initialParams = m_ATLASConverterTool->trkTrackParametersToActsParameters(*(inputTrack.perigeeParameters()), tgContext);
310 
311  for (auto* meas : addMeasColl) {
312  trackSourceLinks.push_back(m_ATLASConverterTool->trkMeasurementToSourceLink(tgContext, *meas));
313  }
314 
315  return performFit(ctx,
316  tgContext,
317  gsfOptions,
318  trackSourceLinks,
319  initialParams);
320 }
321 
322 // extend a track fit to include an additional set of PrepRawData objects
323 // --------------------------------
324 std::unique_ptr<Trk::Track>
325 GaussianSumFitterTool::fit(const EventContext& /*ctx*/,
326  const Trk::Track& /*inputTrack*/,
327  const Trk::PrepRawDataSet& /*addPrdColl*/,
328  const Trk::RunOutlierRemoval /*runOutlier*/,
329  const Trk::ParticleHypothesis /*matEffects*/) const
330 {
331 
332  ATH_MSG_DEBUG("Fit of Track with additional PrepRawDataSet not yet implemented");
333  return nullptr;
334 }
335 
336 // combined fit of two tracks
337 // --------------------------------
338 std::unique_ptr<Trk::Track>
339 GaussianSumFitterTool::fit(const EventContext& ctx,
340  const Trk::Track& intrk1,
341  const Trk::Track& intrk2,
342  const Trk::RunOutlierRemoval /*runOutlier*/,
343  const Trk::ParticleHypothesis /*matEffects*/) const
344 {
345  ATH_MSG_VERBOSE ("--> enter GaussianSumFitter::fit(Track,Track,)");
346  ATH_MSG_VERBOSE (" with Tracks from #1 = " << intrk1.info().dumpInfo()
347  << " and #2 = " << intrk2.info().dumpInfo());
348 
349  // protection, if empty track2
350  if (!intrk2.measurementsOnTrack()) {
351  ATH_MSG_DEBUG( "input #2 is empty try to fit track 1 alone" );
352  return fit(ctx,intrk1);
353  }
354 
355  // protection, if empty track1
356  if (!intrk1.measurementsOnTrack()) {
357  ATH_MSG_DEBUG( "input #1 is empty try to fit track 2 alone" );
358  return fit(ctx,intrk2);
359  }
360 
361  // protection against not having track parameters on the input track
362  if (!intrk1.trackParameters() || intrk1.trackParameters()->empty()) {
363  ATH_MSG_DEBUG("input #1 fails to provide track parameters for seeding the GSF, reject fit");
364  return nullptr;
365  }
366 
367  std::unique_ptr<Trk::Track> track = nullptr;
368 
369  // Construct a perigee surface as the target surface
370  std::shared_ptr<Acts::PerigeeSurface> pSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
371  Acts::Vector3{0., 0., 0.});
372 
373  Acts::GeometryContext tgContext = m_trackingGeometryTool->getGeometryContext(ctx).context();
374  Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
375  // CalibrationContext converter not implemented yet.
376  Acts::CalibrationContext calContext{};
377 
378  // Set the GaussianSumFitter options
379  Acts::GsfOptions<ActsTrk::MutableTrackStateBackend>
380  gsfOptions = prepareOptions(tgContext,
381  mfContext,
382  calContext,
383  *pSurface);
384 
385  std::vector<Acts::SourceLink> trackSourceLinks = m_ATLASConverterTool->trkTrackToSourceLinks(tgContext, intrk1);
386  std::vector<Acts::SourceLink> trackSourceLinks2 = m_ATLASConverterTool->trkTrackToSourceLinks(tgContext, intrk2);
387  trackSourceLinks.insert(trackSourceLinks.end(), trackSourceLinks2.begin(), trackSourceLinks2.end());
388  const auto &initialParams = m_ATLASConverterTool->trkTrackParametersToActsParameters(*(intrk1.perigeeParameters()), tgContext);
389 
390  return performFit(ctx,
391  tgContext,
392  gsfOptions,
393  trackSourceLinks,
394  initialParams);
395 }
396 
397 std::unique_ptr<Trk::Track>
398 GaussianSumFitterTool::makeTrack(const EventContext& ctx,
399  const Acts::GeometryContext& tgContext,
401  Acts::Result<typename ActsTrk::MutableTrackContainer::TrackProxy, std::error_code>& fitResult) const
402 {
403  if (not fitResult.ok())
404  return nullptr;
405 
406  std::unique_ptr<Trk::Track> newtrack = nullptr;
407  // Get the fit output object
408  const auto& acts_track = fitResult.value();
409  auto finalTrajectory = std::make_unique<Trk::TrackStates>();
410  // initialise the number of dead Pixel and Acts strip
411  int numberOfDeadPixel = 0;
412  int numberOfDeadSCT = 0;
413 
414  std::vector<std::unique_ptr<const Acts::BoundTrackParameters>> actsSmoothedParam;
415  // Loop over all the output state to create track state
416  tracks.trackStateContainer().visitBackwards(acts_track.tipIndex(),
417  [&] (const auto &state) -> void
418  {
419  // First only concider state with an associated detector element not in the TRT
420  auto flag = state.typeFlags();
421  const auto* associatedDetEl = state.referenceSurface().associatedDetectorElement();
422  if (not associatedDetEl)
423  return;
424 
425  const auto* actsElement = dynamic_cast<const ActsDetectorElement*>(associatedDetEl);
426  if (not actsElement)
427  return;
428 
429  const auto* upstreamDetEl = actsElement->upstreamDetectorElement();
430  if (not upstreamDetEl)
431  return;
432 
433  ATH_MSG_VERBOSE("Try casting to TRT for if");
434  if (dynamic_cast<const InDetDD::TRT_BaseElement*>(upstreamDetEl))
435  return;
436 
437  const auto* trkDetElem = dynamic_cast<const Trk::TrkDetElementBase*>(upstreamDetEl);
438  if (not trkDetElem)
439  return;
440 
441  ATH_MSG_VERBOSE("trkDetElem type: " << static_cast<std::underlying_type_t<Trk::DetectorElemType>>(trkDetElem->detectorType()));
442 
443  ATH_MSG_VERBOSE("Try casting to SiDetectorElement");
444  const auto* detElem = dynamic_cast<const InDetDD::SiDetectorElement*>(upstreamDetEl);
445  if (not detElem)
446  return;
447  ATH_MSG_VERBOSE("detElem = " << detElem);
448 
449  // We need to determine the type of state
450  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
451  std::unique_ptr<Trk::TrackParameters> parm;
452 
453  // State is a hole (no associated measurement), use predicted parameters
454  if (flag.test(Acts::TrackStateFlag::HoleFlag)){
455  ATH_MSG_VERBOSE("State is a hole (no associated measurement), use predicted parameters");
456  const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(),
457  state.predicted(),
458  state.predictedCovariance(),
459  acts_track.particleHypothesis());
460  parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
461  auto boundaryCheck = m_boundaryCheckTool->boundaryCheck(*parm);
462  // Check if this is a hole, a dead sensors or a state outside the sensor boundary
463  ATH_MSG_VERBOSE("Check if this is a hole, a dead sensors or a state outside the sensor boundary");
464  if(boundaryCheck == Trk::BoundaryCheckResult::DeadElement){
465  if (detElem->isPixel()) {
466  ++numberOfDeadPixel;
467  }
468  else if (detElem->isSCT()) {
469  ++numberOfDeadSCT;
470  }
471  // Dead sensors states are not stored
472  return;
473  } else if (boundaryCheck != Trk::BoundaryCheckResult::Candidate){
474  // States outside the sensor boundary are ignored
475  return;
476  }
477  typePattern.set(Trk::TrackStateOnSurface::Hole);
478  }
479  // The state was tagged as an outlier or was missed in the reverse filtering, use filtered parameters
480  else if (flag.test(Acts::TrackStateFlag::OutlierFlag) or not state.hasSmoothed()) {
481  ATH_MSG_VERBOSE("The state was tagged as an outlier or was missed in the reverse filtering, use filtered parameters");
482  const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(),
483  state.filtered(),
484  state.filteredCovariance(),
485  acts_track.particleHypothesis());
486  parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
487  typePattern.set(Trk::TrackStateOnSurface::Outlier);
488  }
489  // The state is a measurement state, use smoothed parameters
490  else{
491  ATH_MSG_VERBOSE("The state is a measurement state, use smoothed parameters");
492 
493  const Acts::BoundTrackParameters actsParam(state.referenceSurface().getSharedPtr(),
494  state.smoothed(),
495  state.smoothedCovariance(),
496  acts_track.particleHypothesis());
497 
498  actsSmoothedParam.push_back(std::make_unique<const Acts::BoundTrackParameters>(Acts::BoundTrackParameters(actsParam)));
499  parm = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsParam, tgContext);
500  typePattern.set(Trk::TrackStateOnSurface::Measurement);
501  }
502 
503  std::unique_ptr<Trk::MeasurementBase> measState;
504  if (state.hasUncalibratedSourceLink()){
505  auto sl = state.getUncalibratedSourceLink().template get<ATLASSourceLink>();
506  assert(sl);
507  measState = sl->uniqueClone();
508  }
509  double nDoF = state.calibratedSize();
510  auto quality =Trk::FitQualityOnSurface(state.chi2(), nDoF);
511  const Trk::TrackStateOnSurface *perState = new Trk::TrackStateOnSurface(quality, std::move(measState), std::move(parm), nullptr, typePattern);
512  // If a state was succesfully created add it to the trajectory
513  if (perState) {
514  ATH_MSG_VERBOSE("State succesfully creates, adding it to the trajectory");
515  finalTrajectory->insert(finalTrajectory->begin(), perState);
516  }
517  });
518 
519  // Convert the perigee state and add it to the trajectory
520  const Acts::BoundTrackParameters actsPer(acts_track.referenceSurface().getSharedPtr(),
521  acts_track.parameters(),
522  acts_track.covariance(),
523  acts_track.particleHypothesis());
524  std::unique_ptr<Trk::TrackParameters> per = m_ATLASConverterTool->actsTrackParametersToTrkParameters(actsPer, tgContext);
525  std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
526  typePattern.set(Trk::TrackStateOnSurface::Perigee);
527  const Trk::TrackStateOnSurface *perState = new Trk::TrackStateOnSurface(nullptr, std::move(per), nullptr, typePattern);
528  if (perState) finalTrajectory->insert(finalTrajectory->begin(), perState);
529 
530  // Create the track using the states
532  newInfo.setTrackFitter(Trk::TrackInfo::TrackFitter::GaussianSumFilter); //Mark the fitter as GaussianSumFilter
533  newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory), nullptr);
534  if (newtrack && !m_refitOnly) {
535  // Create the track summary and update the holes information
536  if (!newtrack->trackSummary()) {
537  newtrack->setTrackSummary(std::make_unique<Trk::TrackSummary>());
538  newtrack->trackSummary()->update(Trk::numberOfPixelHoles, 0);
539  newtrack->trackSummary()->update(Trk::numberOfSCTHoles, 0);
540  newtrack->trackSummary()->update(Trk::numberOfTRTHoles, 0);
541  newtrack->trackSummary()->update(Trk::numberOfPixelDeadSensors, numberOfDeadPixel);
542  newtrack->trackSummary()->update(Trk::numberOfSCTDeadSensors, numberOfDeadSCT);
543  }
544  m_trkSummaryTool->updateTrackSummary(ctx, *newtrack, true);
545  }
546 
547  return newtrack;
548 }
549 
550 const Acts::GsfExtensions<typename ActsTrk::MutableTrackStateBackend>&
551 GaussianSumFitterTool::getExtensions() const
552 {
553  return m_gsfExtensions;
554 }
555 
557 const Acts::Logger&
559 {
560  return *m_logger;
561 }
562 
563 Acts::GsfOptions<typename ActsTrk::MutableTrackStateBackend>
564 GaussianSumFitterTool::prepareOptions(const Acts::GeometryContext& tgContext,
565  const Acts::MagneticFieldContext& mfContext,
566  const Acts::CalibrationContext& calContext,
567  const Acts::PerigeeSurface& surface) const
568 {
569  Acts::PropagatorPlainOptions propagationOption(tgContext, mfContext);
570  propagationOption.maxSteps = m_option_maxPropagationStep;
571 
572  Acts::GsfOptions<typename ActsTrk::MutableTrackStateBackend> gsfOptions(tgContext, mfContext, calContext);
573  gsfOptions.extensions=m_gsfExtensions;
574  gsfOptions.propagatorPlainOptions=propagationOption;
575  gsfOptions.referenceSurface = &surface;
576 
577  // Set abortOnError to false, else the refitting crashes if no forward propagation is done. Here, we just skip the event and continue.
578  gsfOptions.abortOnError = false;
579  gsfOptions.maxComponents = m_maxComponents;
580  gsfOptions.weightCutoff = m_weightCutOff;
581  gsfOptions.componentMergeMethod = m_componentMergeMethod;
582 
583  return gsfOptions;
584 }
585 
586 }
Trk::noHypothesis
@ noHypothesis
Definition: ParticleHypothesis.h:37
Trk::TrackInfo
Contains information about the 'fitter' of this track.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:32
Trk::TrackStateOnSurface::Perigee
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
Definition: TrackStateOnSurface.h:117
Trk::PrepRawDataSet
std::vector< const PrepRawData * > PrepRawDataSet
vector of clusters and drift circles
Definition: FitterTypes.h:26
MeasurementBase.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
ActsGeometryContext.h
ActsTrk::GaussianSumFitterTool::prepareOptions
Acts::GsfOptions< ActsTrk::MutableTrackStateBackend > prepareOptions(const Acts::GeometryContext &tgContext, const Acts::MagneticFieldContext &mfContext, const Acts::CalibrationContext &calContext, const Acts::PerigeeSurface &surface) const
Definition: GaussianSumFitterTool.cxx:564
ActsTrk::GaussianSumFitterTool::m_trkSummaryTool
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trkSummaryTool
Definition: GaussianSumFitterTool.h:139
ActsTrk::detail::Navigator
Acts::Navigator Navigator
Definition: Tracking/Acts/ActsTrackReconstruction/src/detail/Definitions.h:31
Trk::numberOfSCTDeadSensors
@ numberOfSCTDeadSensors
number of TRT hits
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:76
Trk::Track::info
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
ActsTrk::GaussianSumFitterTool::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition: GaussianSumFitterTool.h:137
ATLASMagneticFieldWrapper.h
ActsTrk::GaussianSumFitterTool::initialize
virtual StatusCode initialize() override
Definition: GaussianSumFitterTool.cxx:53
ActsTrk::GaussianSumFitterTool::m_componentMergeMethod
Acts::ComponentMergeMethod m_componentMergeMethod
Definition: GaussianSumFitterTool.h:166
ActsTrk::GaussianSumFitterTool::performFit
std::unique_ptr< Trk::Track > performFit(const EventContext &ctx, const Acts::GeometryContext &tgContext, const Acts::GsfOptions< ActsTrk::MutableTrackStateBackend > &gsfOptions, const std::vector< Acts::SourceLink > &trackSourceLinks, const Acts::BoundTrackParameters &initialParams) const
Definition: GaussianSumFitterToolFullFit.cxx:20
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
GaussianSumFitterTool.h
Trk::numberOfSCTHoles
@ numberOfSCTHoles
number of Holes in both sides of a SCT module
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:73
Trk::numberOfTRTHoles
@ numberOfTRTHoles
number of TRT hits which pass the high threshold (only xenon counted) total number of TRT hits which ...
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:83
ActsTrk::GaussianSumFitterTool::GaussianSumFitterTool
GaussianSumFitterTool(const std::string &, const std::string &, const IInterface *)
Definition: GaussianSumFitterTool.cxx:47
Trk::RunOutlierRemoval
bool RunOutlierRemoval
switch to toggle quality processing after fit
Definition: FitterTypes.h:22
ActsTrk::GaussianSumFitterTool::m_logger
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Definition: GaussianSumFitterTool.h:188
makeActsAthenaLogger
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition: Tracking/Acts/ActsInterop/src/Logger.cxx:64
Trk::FitQualityOnSurface
Definition: FitQualityOnSurface.h:19
ActsTrk::GaussianSumFitterTool::m_maxComponents
Gaudi::Property< int > m_maxComponents
Definition: GaussianSumFitterTool.h:151
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
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ActsTrk::GaussianSumFitterTool::performDirectFit
std::unique_ptr< Trk::Track > performDirectFit(const EventContext &ctx, const Acts::GeometryContext &tgContext, const Acts::GsfOptions< ActsTrk::MutableTrackStateBackend > &gsfOptions, const std::vector< Acts::SourceLink > &trackSourceLinks, const Acts::BoundTrackParameters &initialParams, const std::vector< const Acts::Surface * > &surfaces) const
Definition: GaussianSumFitterToolDirectFit.cxx:23
ActsTrk::GaussianSumFitterTool::m_option_componentMergeMethod
Gaudi::Property< std::string > m_option_componentMergeMethod
Definition: GaussianSumFitterTool.h:163
ActsTrk::GaussianSumFitterTool::logger
const Acts::Logger & logger() const
Private access to the logger.
Definition: GaussianSumFitterTool.cxx:558
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ActsTrk::ATLASSourceLinkSurfaceAccessor::m_converterTool
const ActsTrk::IActsToTrkConverterTool * m_converterTool
Definition: ATLASSourceLinkSurfaceAccessor.h:21
xAOD::GaussianSumFilter
@ GaussianSumFilter
Tracks from Gaussian Sum Filter.
Definition: TrackingPrimitives.h:49
Trk::numberOfPixelDeadSensors
@ numberOfPixelDeadSensors
number of pixel hits with broad errors (width/sqrt(12))
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:65
master.flag
bool flag
Definition: master.py:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::GaussianSumFitterTool::m_outlierFinder
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder m_outlierFinder
Definition: GaussianSumFitterTool.h:185
TrackSummary.h
Trk::ParametersBase
Definition: ParametersBase.h:55
ActsDetectorElement.h
ActsTrk::GaussianSumFitterTool::m_surfaceAccessor
ATLASSourceLinkSurfaceAccessor m_surfaceAccessor
Definition: GaussianSumFitterTool.h:182
ActsTrk::GaussianSumFitterTool::m_gsfExtensions
Acts::GsfExtensions< ActsTrk::MutableTrackStateBackend > m_gsfExtensions
Definition: GaussianSumFitterTool.h:183
ActsTrk::GaussianSumFitterTool::m_useDirectNavigation
Gaudi::Property< bool > m_useDirectNavigation
Definition: GaussianSumFitterTool.h:154
ActsTrk::GaussianSumFitterTool::m_refitOnly
Gaudi::Property< bool > m_refitOnly
Definition: GaussianSumFitterTool.h:157
Trk::numberOfPixelHoles
@ numberOfPixelHoles
number of pixels which have a ganged ambiguity.
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:59
Trk::MeasurementSet
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
Definition: FitterTypes.h:30
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::Track::trackParameters
const DataVector< const TrackParameters > * trackParameters() const
Return a pointer to a vector of TrackParameters.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:97
TRT_BaseElement.h
ActsTrk::GaussianSumFitterTool::m_calibrator
std::unique_ptr< ActsTrk::detail::TrkMeasurementCalibrator > m_calibrator
Definition: GaussianSumFitterTool.h:173
Trk::Track::perigeeParameters
const Perigee * perigeeParameters() const
return Perigee.
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:163
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::MeasurementBase::associatedSurface
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
Trk::TrackInfo::dumpInfo
std::string dumpInfo() const
Returns a string with the name of the fitter of this track (i.e.
Definition: Tracking/TrkEvent/TrkTrack/src/TrackInfo.cxx:45
ActsTrk::GaussianSumFitterTool::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: GaussianSumFitterTool.cxx:122
ActsTrk::GaussianSumFitterTool::m_weightCutOff
Gaudi::Property< double > m_weightCutOff
Definition: GaussianSumFitterTool.h:160
ActsTrk::GaussianSumFitterTool::m_directFitter
std::unique_ptr< DirectFitter > m_directFitter
Definition: GaussianSumFitterTool.h:179
Trk::Track::measurementsOnTrack
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
Definition: Tracking/TrkEvent/TrkTrack/src/Track.cxx:178
ActsTrk::detail::FitterHelperFunctions::ATLASOutlierFinder::StateChiSquaredPerNumberDoFCut
double StateChiSquaredPerNumberDoFCut
Definition: FitterHelperFunctions.h:50
ActsTrk::GaussianSumFitterTool::m_ATLASConverterTool
ToolHandle< ActsTrk::IActsToTrkConverterTool > m_ATLASConverterTool
Definition: GaussianSumFitterTool.h:138
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
ActsTrk::GaussianSumFitterTool::m_fitter
std::unique_ptr< Fitter > m_fitter
Definition: GaussianSumFitterTool.h:174
ActsTrk::GaussianSumFitterTool::m_extrapolationTool
ToolHandle< IActsExtrapolationTool > m_extrapolationTool
Definition: GaussianSumFitterTool.h:136
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
ActsTrk::GaussianSumFitterTool::m_option_outlierChi2Cut
Gaudi::Property< double > m_option_outlierChi2Cut
Definition: GaussianSumFitterTool.h:146
Logger.h
ActsTrk::GaussianSumFitterTool::makeTrack
std::unique_ptr< Trk::Track > makeTrack(const EventContext &ctx, const Acts::GeometryContext &tgContext, ActsTrk::MutableTrackContainer &tracks, Acts::Result< typename ActsTrk::MutableTrackContainer::TrackProxy, std::error_code > &fitResult) const
Definition: GaussianSumFitterTool.cxx:398
ActsTrk::MutableTrackContainer
Definition: TrackContainer.h:122
TrackContainer.h
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14
TrackStateOnSurface.h