ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ActsTrk::ActsToTrkConverterTool Class Reference

#include <ActsToTrkConverterTool.h>

Inheritance diagram for ActsTrk::ActsToTrkConverterTool:
Collaboration diagram for ActsTrk::ActsToTrkConverterTool:

Public Member Functions

virtual StatusCode initialize () override
 
 ActsToTrkConverterTool (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual const Trk::SurfaceactsSurfaceToTrkSurface (const Acts::Surface &actsSurface) const override
 Find the ATLAS surface corresponding to the Acts surface Only work if the Acts surface has an associated detector element (Pixel and SCT) More...
 
virtual const Acts::Surface & trkSurfaceToActsSurface (const Trk::Surface &atlasSurface) const override
 Find the Acts surface corresponding to the ATLAS surface Use a map associating ATLAS ID to Acts surfaces (Pixel and SCT) More...
 
virtual Acts::SourceLink trkMeasurementToSourceLink (const Acts::GeometryContext &gctx, const Trk::MeasurementBase &measurement) const override
 Create an SourceLink from an ATLAS measurment Works for 1 and 2D measurmenent. More...
 
virtual std::vector< Acts::SourceLink > trkTrackToSourceLinks (const Acts::GeometryContext &gctx, const Trk::Track &track) const override
 Transform an ATLAS track into a vector of SourceLink to be use in the avts tracking Transform both measurement and outliers. More...
 
virtual const Acts::BoundTrackParameters trkTrackParametersToActsParameters (const Trk::TrackParameters &atlasParameter, const Acts::GeometryContext &gctx, Trk::ParticleHypothesis=Trk::pion) const override
 Create Acts TrackParameter from ATLAS one. More...
 
virtual std::unique_ptr< Trk::TrackParametersactsTrackParametersToTrkParameters (const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext &gctx) const override
 Create ATLAS TrackParameter from Acts one. More...
 
virtual void trkTrackCollectionToActsTrackContainer (ActsTrk::MutableTrackContainer &tc, const TrackCollection &trackColl, const Acts::GeometryContext &gctx) const override
 Convert TrackCollection to Acts track container. More...
 
virtual const IActsTrackingGeometryTooltrackingGeometryTool () const override
 

Private Member Functions

bool actsTrackParameterPositionCheck (const Acts::BoundTrackParameters &actsParameter, const Trk::TrackParameters &tsos, const Acts::GeometryContext &gctx) const
 

Private Attributes

ToolHandle< IActsTrackingGeometryToolm_trackingGeometryTool
 
std::shared_ptr< const Acts::TrackingGeometry > m_trackingGeometry
 
std::map< Identifier, const Acts::Surface * > m_actsSurfaceMap
 
Gaudi::Property< bool > m_visualDebugOutput
 
Trk::PdgToParticleHypothesis m_pdgToParticleHypothesis
 
Gaudi::Property< bool > m_extractMuonSurfaces
 
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 

Detailed Description

Definition at line 30 of file ActsToTrkConverterTool.h.

Constructor & Destructor Documentation

◆ ActsToTrkConverterTool()

ActsTrk::ActsToTrkConverterTool::ActsToTrkConverterTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Definition at line 69 of file ActsToTrkConverterTool.cxx.

71  : base_class(type, name, parent) {}

Member Function Documentation

◆ actsSurfaceToTrkSurface()

const Trk::Surface & ActsTrk::ActsToTrkConverterTool::actsSurfaceToTrkSurface ( const Acts::Surface &  actsSurface) const
overridevirtual

Find the ATLAS surface corresponding to the Acts surface Only work if the Acts surface has an associated detector element (Pixel and SCT)

Definition at line 124 of file ActsToTrkConverterTool.cxx.

125  {
126 
127  const auto *actsElement = dynamic_cast<const ActsDetectorElement *>(
128  actsSurface.associatedDetectorElement());
129  if (actsElement) {
130  return actsElement->atlasSurface();
131  }
132  throw std::domain_error("No ATLAS surface corresponding to to the Acts one");
133 }

◆ actsTrackParameterPositionCheck()

bool ActsTrk::ActsToTrkConverterTool::actsTrackParameterPositionCheck ( const Acts::BoundTrackParameters &  actsParameter,
const Trk::TrackParameters tsos,
const Acts::GeometryContext &  gctx 
) const
private

Definition at line 568 of file ActsToTrkConverterTool.cxx.

571  {
572  auto actsPos = parameters.position(gctx);
573  // ATH_MSG_VERBOSE("Acts position: \n"
574  // << actsPos << " vs trk position: \n"
575  // << trkparameters.position());
576  // ATH_MSG_VERBOSE(parameters.referenceSurface().toString(gctx));
577  // ATH_MSG_VERBOSE("GeometryId "<<parameters.referenceSurface().geometryId().value());
578 
579  if (std::fabs(actsPos.x() - trkparameters.position().x()) >
580  0.1 ||
581  std::fabs(actsPos.y() - trkparameters.position().y()) >
582  0.1 ||
583  std::fabs(actsPos.z() - trkparameters.position().z()) >
584  0.1) {
585  ATH_MSG_WARNING("Parameter position mismatch. Acts \n"
586  << actsPos << " vs Trk \n"
587  << trkparameters.position());
588  ATH_MSG_WARNING("Acts surface:");
589  ATH_MSG_WARNING(parameters.referenceSurface().toString(gctx));
590  ATH_MSG_WARNING("Trk surface:");
591  ATH_MSG_WARNING(trkparameters.associatedSurface());
592  return false;
593  }
594  return true;
595 }

◆ actsTrackParametersToTrkParameters()

std::unique_ptr< Trk::TrackParameters > ActsTrk::ActsToTrkConverterTool::actsTrackParametersToTrkParameters ( const Acts::BoundTrackParameters &  actsParameter,
const Acts::GeometryContext &  gctx 
) const
overridevirtual

Create ATLAS TrackParameter from Acts one.

Take care of unit conversion between the two.

Definition at line 271 of file ActsToTrkConverterTool.cxx.

273  {
274 
275  using namespace Acts::UnitLiterals;
276  std::optional<AmgSymMatrix(5)> cov = std::nullopt;
277  if (actsParameter.covariance()) {
278  AmgSymMatrix(5)
279  newcov(actsParameter.covariance()->topLeftCorner<5, 5>());
280  // Convert the covariance matrix to GeV
281  for (int i = 0; i < newcov.rows(); i++) {
282  newcov(i, 4) = newcov(i, 4) * 1_MeV;
283  }
284  for (int i = 0; i < newcov.cols(); i++) {
285  newcov(4, i) = newcov(4, i) * 1_MeV;
286  }
287  cov = std::optional<AmgSymMatrix(5)>(newcov);
288  }
289 
290  const Acts::Surface &actsSurface = actsParameter.referenceSurface();
291 
292  switch (actsSurface.type()) {
293 
295  const Trk::ConeSurface &coneSurface =
296  dynamic_cast<const Trk::ConeSurface &>(
297  actsSurfaceToTrkSurface(actsSurface));
298  return std::make_unique<Trk::AtaCone>(
299  actsParameter.get<Acts::eBoundLoc0>(),
300  actsParameter.get<Acts::eBoundLoc1>(),
301  actsParameter.get<Acts::eBoundPhi>(),
302  actsParameter.get<Acts::eBoundTheta>(),
303  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, coneSurface, cov);
304 
305  break;
306  }
308  const Trk::CylinderSurface &cylSurface =
309  dynamic_cast<const Trk::CylinderSurface &>(
310  actsSurfaceToTrkSurface(actsSurface));
311  return std::make_unique<Trk::AtaCylinder>(
312  actsParameter.get<Acts::eBoundLoc0>(),
313  actsParameter.get<Acts::eBoundLoc1>(),
314  actsParameter.get<Acts::eBoundPhi>(),
315  actsParameter.get<Acts::eBoundTheta>(),
316  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cylSurface, cov);
317  break;
318  }
320  if (const auto *discSurface = dynamic_cast<const Trk::DiscSurface *>(
321  &actsSurfaceToTrkSurface(actsSurface));
322  discSurface != nullptr) {
323  return std::make_unique<Trk::AtaDisc>(
324  actsParameter.get<Acts::eBoundLoc0>(),
325  actsParameter.get<Acts::eBoundLoc1>(),
326  actsParameter.get<Acts::eBoundPhi>(),
327  actsParameter.get<Acts::eBoundTheta>(),
328  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, *discSurface, cov);
329  } else if (const auto *planeSurface =
330  dynamic_cast<const Trk::PlaneSurface *>(
331  &actsSurfaceToTrkSurface(actsSurface));
332  planeSurface != nullptr) {
333  // need to convert to plane position on plane surface (annulus bounds)
334  auto helperSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(
335  planeSurface->transform());
336 
337  auto covpc = actsParameter.covariance().value();
338 
339  Acts::FreeVector freePars =
340  Acts::transformBoundToFreeParameters(
341  actsSurface, gctx, actsParameter.parameters());
342 
343  Acts::BoundVector targetPars =
344  Acts::transformFreeToBoundParameters(freePars,
345  *helperSurface, gctx)
346  .value();
347 
348  Acts::FreeMatrix freeTransportJacobian = Acts::FreeMatrix::Identity();
349 
350  Acts::FreeVector freeToPathDerivatives = Acts::FreeVector::Zero();
351  freeToPathDerivatives.head<3>() = freePars.segment<3>(Acts::eFreeDir0);
352 
353  auto boundToFreeJacobian = actsSurface.boundToFreeJacobian(
354  gctx, freePars.segment<3>(Acts::eFreePos0),
355  freePars.segment<3>(Acts::eFreeDir0));
356 
357  Acts::BoundMatrix boundToBoundJac = Acts::detail::boundToBoundTransportJacobian(
358  gctx, freePars, boundToFreeJacobian, freeTransportJacobian,
359  freeToPathDerivatives, *helperSurface);
360 
361  Acts::BoundMatrix targetCov =
362  boundToBoundJac * covpc * boundToBoundJac.transpose();
363 
364  auto pars = std::make_unique<Trk::AtaPlane>(
365  targetPars[Acts::eBoundLoc0], targetPars[Acts::eBoundLoc1],
366  targetPars[Acts::eBoundPhi], targetPars[Acts::eBoundTheta],
367  targetPars[Acts::eBoundQOverP] * 1_MeV, *planeSurface,
368  targetCov.topLeftCorner<5, 5>());
369 
370  if (m_visualDebugOutput) {
371  ActsTrackParameterCheck(actsParameter, gctx, covpc, targetPars,
372  targetCov, planeSurface);
373  }
374 
375  return pars;
376 
377  } else {
378  throw std::runtime_error{
379  "Acts::DiscSurface is not associated with ATLAS disc or plane "
380  "surface"};
381  }
382  break;
383  }
384  case Acts::Surface::SurfaceType::Perigee: {
385  const Trk::PerigeeSurface perSurface(actsSurface.center(gctx));
386  return std::make_unique<Trk::Perigee>(
387  actsParameter.get<Acts::eBoundLoc0>(),
388  actsParameter.get<Acts::eBoundLoc1>(),
389  actsParameter.get<Acts::eBoundPhi>(),
390  actsParameter.get<Acts::eBoundTheta>(),
391  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, perSurface, cov);
392 
393  break;
394  }
396  const Trk::PlaneSurface &plaSurface =
397  dynamic_cast<const Trk::PlaneSurface &>(
398  actsSurfaceToTrkSurface(actsSurface));
399  return std::make_unique<Trk::AtaPlane>(
400  actsParameter.get<Acts::eBoundLoc0>(),
401  actsParameter.get<Acts::eBoundLoc1>(),
402  actsParameter.get<Acts::eBoundPhi>(),
403  actsParameter.get<Acts::eBoundTheta>(),
404  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, plaSurface, cov);
405  break;
406  }
408  const Trk::StraightLineSurface &lineSurface =
409  dynamic_cast<const Trk::StraightLineSurface &>(
410  actsSurfaceToTrkSurface(actsSurface));
411  return std::make_unique<Trk::AtaStraightLine>(
412  actsParameter.get<Acts::eBoundLoc0>(),
413  actsParameter.get<Acts::eBoundLoc1>(),
414  actsParameter.get<Acts::eBoundPhi>(),
415  actsParameter.get<Acts::eBoundTheta>(),
416  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, lineSurface, cov);
417  break;
418  }
420  return std::make_unique<Trk::CurvilinearParameters>(
421  actsParameter.position(gctx), actsParameter.get<Acts::eBoundPhi>(),
422  actsParameter.get<Acts::eBoundTheta>(),
423  actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cov);
424  break;
425  }
426  case Acts::Surface::SurfaceType::Other: {
427  break;
428  }
429  }
430 
431  throw std::domain_error("Surface type not found");
432 }

◆ initialize()

StatusCode ActsTrk::ActsToTrkConverterTool::initialize ( )
overridevirtual

Definition at line 73 of file ActsToTrkConverterTool.cxx.

73  {
74  ATH_MSG_VERBOSE("Initializing ACTS to ATLAS converter tool");
76  ATH_CHECK(m_idHelperSvc.retrieve());
77  }
78  if (!m_trackingGeometryTool.empty()) {
80  m_trackingGeometry = m_trackingGeometryTool->trackingGeometry();
81 
82  m_trackingGeometry->visitSurfaces([&](const Acts::Surface *surface) {
83  // find acts surface with the same detector element ID
84  if (!surface)
85  return;
86  const auto *actsElement = dynamic_cast<const ActsDetectorElement *>(
87  surface->associatedDetectorElement());
88  if (!actsElement)
89  return;
90  // Conversion from Acts to ATLAS surface impossible for the TRT so the TRT
91  // surfaces are not stored in this map
92  bool isTRT = (dynamic_cast<const InDetDD::TRT_BaseElement *>(
93  actsElement->upstreamDetectorElement()) != nullptr);
94  if (isTRT)
95  return;
96 
97  auto [it, ok] =
98  m_actsSurfaceMap.insert({actsElement->identify(), surface});
99  if (!ok) {
100  ATH_MSG_WARNING("ATLAS ID " << actsElement->identify()
101  << " has two ACTS surfaces: "
102  << it->second->geometryId() << " and "
103  << surface->geometryId());
104  }
105  });
106  }
107 
109  const MuonGMR4::MuonDetectorManager* muonMgr{nullptr};
110  ATH_CHECK(detStore()->retrieve(muonMgr));
111  unsigned int mapSize = m_actsSurfaceMap.size(); // For debugging message later
112  for (auto readoutElement : muonMgr->getAllReadoutElements()) {
113  std::vector<std::shared_ptr<Acts::Surface>> reSurfaces = readoutElement->getSurfaces();
114  for ( const auto& surf : reSurfaces) {
115  const Identifier id = static_cast<const ActsTrk::SurfaceCache*>(surf->associatedDetectorElement())->identify();
116  m_actsSurfaceMap.insert(std::make_pair(id, surf.get()));
117  }
118  }
119  ATH_MSG_VERBOSE("After adding muon surfaces, the map has grown from "<<mapSize<<" to "<<m_actsSurfaceMap.size());
120  }
121  return StatusCode::SUCCESS;
122 }

◆ trackingGeometryTool()

virtual const IActsTrackingGeometryTool* ActsTrk::ActsToTrkConverterTool::trackingGeometryTool ( ) const
inlineoverridevirtual

Definition at line 86 of file ActsToTrkConverterTool.h.

87  {
88  return m_trackingGeometryTool.get();
89  };

◆ trkMeasurementToSourceLink()

Acts::SourceLink ActsTrk::ActsToTrkConverterTool::trkMeasurementToSourceLink ( const Acts::GeometryContext &  gctx,
const Trk::MeasurementBase measurement 
) const
overridevirtual

Create an SourceLink from an ATLAS measurment Works for 1 and 2D measurmenent.

A pointer to the measurment is kept in the SourceLink

Definition at line 148 of file ActsToTrkConverterTool.cxx.

151 {
152  return Acts::SourceLink(&measurement);
153 }

◆ trkSurfaceToActsSurface()

const Acts::Surface & ActsTrk::ActsToTrkConverterTool::trkSurfaceToActsSurface ( const Trk::Surface atlasSurface) const
overridevirtual

Find the Acts surface corresponding to the ATLAS surface Use a map associating ATLAS ID to Acts surfaces (Pixel and SCT)

Definition at line 135 of file ActsToTrkConverterTool.cxx.

136  {
137 
138  Identifier atlasID = atlasSurface.associatedDetectorElementIdentifier();
139  auto it = m_actsSurfaceMap.find(atlasID);
140  if (it != m_actsSurfaceMap.end()) {
141  return *it->second;
142  }
143  ATH_MSG_ERROR("No Acts surface corresponding to this ATLAS surface:");
144  ATH_MSG_ERROR(atlasSurface);
145  throw std::domain_error("No Acts surface corresponding to the ATLAS one");
146 }

◆ trkTrackCollectionToActsTrackContainer()

void ActsTrk::ActsToTrkConverterTool::trkTrackCollectionToActsTrackContainer ( ActsTrk::MutableTrackContainer tc,
const TrackCollection trackColl,
const Acts::GeometryContext &  gctx 
) const
overridevirtual

Convert TrackCollection to Acts track container.

Parameters
tcThe track container to fill

Definition at line 434 of file ActsToTrkConverterTool.cxx.

437  {
438  ATH_MSG_VERBOSE("Calling trkTrackCollectionToActsTrackContainer with "
439  << trackColl.size() << " tracks.");
440  unsigned int trkCount = 0;
441  std::vector<Identifier> failedIds; // Keep track of Identifiers of failed conversions
442  for (auto trk : trackColl) {
443  // Do conversions!
444  const Trk::TrackStates *trackStates =
445  trk->trackStateOnSurfaces();
446  if (!trackStates) {
447  ATH_MSG_WARNING("No track states on surfaces found for this track.");
448  continue;
449  }
450 
451  auto actsTrack = tc.getTrack(tc.addTrack());
452  auto& trackStateContainer = tc.trackStateContainer();
453 
454  ATH_MSG_VERBOSE("Track "<<trkCount++<<" has " << trackStates->size()
455  << " track states on surfaces.");
456  // basic quantities copy
457  actsTrack.chi2() = trk->fitQuality()->chiSquared();
458  actsTrack.nDoF() = trk->fitQuality()->numberDoF();
459 
460  // loop over track states on surfaces, convert and add them to the ACTS
461  // container
462  bool first_tsos = true; // We need to handle the first one differently
463  int measurementsCount = 0;
464  for (auto tsos : *trackStates) {
465 
466  // Setup the mask
467  Acts::TrackStatePropMask mask = Acts::TrackStatePropMask::None;
468  if (tsos->measurementOnTrack()) {
469  mask |= Acts::TrackStatePropMask::Calibrated;
470  }
471  if (tsos->trackParameters()) {
472  mask |= Acts::TrackStatePropMask::Smoothed;
473  }
474 
475  // Setup the index of the trackstate
476  auto index = Acts::MultiTrajectoryTraits::kInvalid;
477  if (!first_tsos) {
478  index = actsTrack.tipIndex();
479  }
480  auto actsTSOS = trackStateContainer.getTrackState(
481  trackStateContainer.addTrackState(mask, index));
482  ATH_MSG_VERBOSE("TipIndex: " << actsTrack.tipIndex()
483  << " TSOS index within trajectory: "
484  << actsTSOS.index());
485  actsTrack.tipIndex() = actsTSOS.index();
486 
487  if (tsos->trackParameters()) {
488  // TODO This try/catch is temporary and should be removed once the sTGC problem is fixed.
489  try {
490  ATH_MSG_VERBOSE("Converting track parameters.");
491  // TODO - work out whether we should set predicted, filtered, smoothed
492  const Acts::BoundTrackParameters parameters =
493  trkTrackParametersToActsParameters(*(tsos->trackParameters()), gctx);
494  ATH_MSG_VERBOSE("Track parameters: " << parameters.parameters());
495  // Sanity check on positions
496  if (!actsTrackParameterPositionCheck(parameters, *(tsos->trackParameters()), gctx)){
497  failedIds.push_back(tsos->trackParameters()->associatedSurface().associatedDetectorElementIdentifier());
498  }
499 
500  if (first_tsos) {
501  // This is the first track state, so we need to set the track
502  // parameters
503  actsTrack.parameters() = parameters.parameters();
504  actsTrack.covariance() = *parameters.covariance();
505  actsTrack.setReferenceSurface(
506  parameters.referenceSurface().getSharedPtr());
507  first_tsos = false;
508  } else {
509  actsTSOS.setReferenceSurface(parameters.referenceSurface().getSharedPtr());
510  // Since we're converting final Trk::Tracks, let's assume they're smoothed
511  actsTSOS.smoothed() = parameters.parameters();
512  actsTSOS.smoothedCovariance() = *parameters.covariance();
513  // Not yet implemented in MultiTrajectory.icc
514  // actsTSOS.typeFlags() |= Acts::TrackStateFlag::ParameterFlag;
515  if (!(actsTSOS.hasSmoothed() && actsTSOS.hasReferenceSurface())) {
516  ATH_MSG_WARNING("TrackState does not have smoothed state ["
517  << actsTSOS.hasSmoothed()
518  << "] or reference surface ["
519  << actsTSOS.hasReferenceSurface() << "].");
520  } else {
521  ATH_MSG_VERBOSE("TrackState has smoothed state and reference surface.");
522  }
523  }
524  } catch (const std::exception& e){
525  ATH_MSG_ERROR("Unable to convert TrackParameter with exception ["<<e.what()<<"]. Will be missing from ACTS track."
526  <<(*tsos->trackParameters()));
527  }
528  }
529  if (tsos->measurementOnTrack()) {
530  auto &measurement = *(tsos->measurementOnTrack());
531 
532  measurementsCount++;
533  // const Acts::Surface &surface =
534  // trkSurfaceToActsSurface(measurement.associatedSurface());
535  // Commented for the moment because Surfaces not yet implemented in
536  // MultiTrajectory.icc
537 
538  int dim = measurement.localParameters().dimension();
539  actsTSOS.allocateCalibrated(dim);
540  if (dim == 1) {
541  actsTSOS.calibrated<1>() = measurement.localParameters();
542  actsTSOS.calibratedCovariance<1>() = measurement.localCovariance();
543  } else if (dim == 2) {
544  actsTSOS.calibrated<2>() = measurement.localParameters();
545  actsTSOS.calibratedCovariance<2>() = measurement.localCovariance();
546  } else {
547  throw std::domain_error("Cannot handle measurement dim>2");
548  }
549  actsTSOS.setUncalibratedSourceLink(Acts::SourceLink(static_cast<ActsTrk::ATLASSourceLink>(tsos->measurementOnTrack())));
550 
551  } // end if measurement
552  } // end loop over track states
553  actsTrack.nMeasurements() = measurementsCount;
554  ATH_MSG_VERBOSE("TrackProxy has " << actsTrack.nTrackStates()
555  << " track states on surfaces.");
556  }
557  ATH_MSG_VERBOSE("Finished converting " << trackColl.size() << " tracks.");
558 
559  if (!failedIds.empty()){
560  ATH_MSG_WARNING("Failed to convert "<<failedIds.size()<<" track parameters.");
561  for (auto id : failedIds){
562  ATH_MSG_WARNING("-> Failed for Identifier "<<m_idHelperSvc->toString(id));
563  }
564  }
565  ATH_MSG_VERBOSE("ACTS Track container has " << tc.size() << " tracks.");
566 }

◆ trkTrackParametersToActsParameters()

const Acts::BoundTrackParameters ActsTrk::ActsToTrkConverterTool::trkTrackParametersToActsParameters ( const Trk::TrackParameters atlasParameter,
const Acts::GeometryContext &  gctx,
Trk::ParticleHypothesis  hypothesis = Trk::pion 
) const
overridevirtual

Create Acts TrackParameter from ATLAS one.

Take care of unit conversion between the two.

Definition at line 176 of file ActsToTrkConverterTool.cxx.

177  {
178 
179  using namespace Acts::UnitLiterals;
180  std::shared_ptr<const Acts::Surface> actsSurface;
181  Acts::BoundVector params;
182 
183  // get the associated surface
184  if (atlasParameter.hasSurface() &&
185  atlasParameter.associatedSurface().owner() == Trk::SurfaceOwner::DetElOwn) {
186  try {
187  actsSurface = trkSurfaceToActsSurface(atlasParameter.associatedSurface())
188  .getSharedPtr();
189  } catch (const std::exception &e) {
190  ATH_MSG_ERROR("Could not find ACTS detector surface for this TrackParameter:");
191  ATH_MSG_ERROR(atlasParameter);
192  throw; // Nothing we can do, so just pass exception on...
193  }
194  }
195  // no associated surface create a perigee one
196  else {
198  "trkTrackParametersToActsParameters:: No associated surface found (owner: "<<atlasParameter.associatedSurface().owner()<<
199  "). Creating a free surface. Trk parameters:");
200  ATH_MSG_VERBOSE(atlasParameter);
201 
202  switch (atlasParameter.associatedSurface().type()){
204  actsSurface = Acts::Surface::makeShared<const Acts::PlaneSurface>(
205  atlasParameter.associatedSurface().transform());
206  break;
208  actsSurface = Acts::Surface::makeShared<const Acts::PerigeeSurface>(
209  atlasParameter.associatedSurface().transform());
210  break;
211  // TODO - implement the missing types?
212  default:
213  ATH_MSG_WARNING("No surface type found for this Trk::Surface. Creating a perigee surface.");
214  actsSurface = Acts::Surface::makeShared<const Acts::PerigeeSurface>(
215  atlasParameter.associatedSurface().center());
216  }
217  }
218 
219  // Construct track parameters
220  auto atlasParam = atlasParameter.parameters();
221  if (actsSurface->bounds().type() ==
222  Acts::SurfaceBounds::BoundsType::eAnnulus) {
223  // Annulus surfaces are constructed differently in Acts/Trk so we need to
224  // convert local coordinates
225  auto position = atlasParameter.position();
226  auto result =
227  actsSurface->globalToLocal(gctx, position, atlasParameter.momentum());
228  if (result.ok()) {
229  params << (*result)[0], (*result)[1], atlasParam[Trk::phi0],
230  atlasParam[Trk::theta],
231  atlasParameter.charge() / (atlasParameter.momentum().mag() * 1_MeV),
232  0.;
233  } else {
235  "Unable to convert annulus surface - globalToLocal failed");
236  }
237  } else {
238  params << atlasParam[Trk::locX], atlasParam[Trk::locY],
239  atlasParam[Trk::phi0], atlasParam[Trk::theta],
240  atlasParameter.charge() / (atlasParameter.momentum().mag() * 1_MeV), 0.;
241  }
242 
243  Acts::BoundSquareMatrix cov = Acts::BoundSquareMatrix::Identity();
244  if (atlasParameter.covariance()) {
245  cov.topLeftCorner(5, 5) = *atlasParameter.covariance();
246 
247  // Convert the covariance matrix from MeV
248  // FIXME: This needs to handle the annulus case as well - currently the cov
249  // is wrong for annulus surfaces
250  for (int i = 0; i < cov.rows(); i++) {
251  cov(i, 4) = cov(i, 4) / 1_MeV;
252  }
253  for (int i = 0; i < cov.cols(); i++) {
254  cov(4, i) = cov(4, i) / 1_MeV;
255  }
256  }
257 
258  // convert hypotheses
260  Acts::PdgParticle absPdg = Acts::makeAbsolutePdgParticle(
261  static_cast<Acts::PdgParticle>(
262  m_pdgToParticleHypothesis.convert(hypothesis, atlasParameter.charge())));
263  Acts::ParticleHypothesis actsHypothesis{
264  absPdg, mass, Acts::AnyCharge{std::abs(static_cast<float>(atlasParameter.charge()))}};
265 
266  return Acts::BoundTrackParameters(actsSurface, params,
267  cov, actsHypothesis);
268 }

◆ trkTrackToSourceLinks()

std::vector< Acts::SourceLink > ActsTrk::ActsToTrkConverterTool::trkTrackToSourceLinks ( const Acts::GeometryContext &  gctx,
const Trk::Track track 
) const
overridevirtual

Transform an ATLAS track into a vector of SourceLink to be use in the avts tracking Transform both measurement and outliers.

Definition at line 157 of file ActsToTrkConverterTool.cxx.

158  {
159  auto hits = track.measurementsOnTrack();
160  auto outliers = track.outliersOnTrack();
161 
162  std::vector<Acts::SourceLink> sourceLinks;
163  sourceLinks.reserve(hits->size() + outliers->size());
164 
165  for (auto it = hits->begin(); it != hits->end(); ++it) {
166  sourceLinks.push_back(trkMeasurementToSourceLink(gctx, **it));
167  }
168  for (auto it = outliers->begin(); it != outliers->end(); ++it) {
169  sourceLinks.push_back(trkMeasurementToSourceLink(gctx, **it));
170  }
171  return sourceLinks;
172 }

Member Data Documentation

◆ m_actsSurfaceMap

std::map<Identifier, const Acts::Surface*> ActsTrk::ActsToTrkConverterTool::m_actsSurfaceMap
private

Definition at line 99 of file ActsToTrkConverterTool.h.

◆ m_extractMuonSurfaces

Gaudi::Property<bool> ActsTrk::ActsToTrkConverterTool::m_extractMuonSurfaces
private
Initial value:
{
this, "ExtractMuonSurfaces", false,
"If True, use the MuonDetectorManager to extract the Muon surfaces"}

Definition at line 107 of file ActsToTrkConverterTool.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> ActsTrk::ActsToTrkConverterTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 110 of file ActsToTrkConverterTool.h.

◆ m_pdgToParticleHypothesis

Trk::PdgToParticleHypothesis ActsTrk::ActsToTrkConverterTool::m_pdgToParticleHypothesis
private

Definition at line 105 of file ActsToTrkConverterTool.h.

◆ m_trackingGeometry

std::shared_ptr<const Acts::TrackingGeometry> ActsTrk::ActsToTrkConverterTool::m_trackingGeometry
private

Definition at line 98 of file ActsToTrkConverterTool.h.

◆ m_trackingGeometryTool

ToolHandle<IActsTrackingGeometryTool> ActsTrk::ActsToTrkConverterTool::m_trackingGeometryTool
private
Initial value:
{
this, "TrackingGeometryTool", "ActsTrackingGeometryTool"}

Definition at line 96 of file ActsToTrkConverterTool.h.

◆ m_visualDebugOutput

Gaudi::Property<bool> ActsTrk::ActsToTrkConverterTool::m_visualDebugOutput
private
Initial value:
{
this, "VisualDebugOutput", false,
"Print additional output for debug plots"}

Definition at line 101 of file ActsToTrkConverterTool.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
ActsTrk::ActsToTrkConverterTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: ActsToTrkConverterTool.h:110
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
get_generator_info.result
result
Definition: get_generator_info.py:21
ActsTrk::ActsToTrkConverterTool::trkTrackParametersToActsParameters
virtual const Acts::BoundTrackParameters trkTrackParametersToActsParameters(const Trk::TrackParameters &atlasParameter, const Acts::GeometryContext &gctx, Trk::ParticleHypothesis=Trk::pion) const override
Create Acts TrackParameter from ATLAS one.
Definition: ActsToTrkConverterTool.cxx:176
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::ParametersBase::charge
double charge() const
Returns the charge.
Trk::PdgToParticleHypothesis::convert
Trk::ParticleHypothesis convert(int pdg, bool &stable, bool &exiting, double charge=1.) const
Converter method : PDG -> Particle Hyptothesis.
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
MuonGMR4::MuonDetectorManager
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/MuonDetectorManager.h:62
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
index
Definition: index.py:1
Trk::ParametersBase::associatedSurface
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
MuonGMR4::MuonReadoutElement::getSurfaces
std::vector< std::shared_ptr< Acts::Surface > > getSurfaces() const
Returns all surfaces that are associated with the active readout planes.
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/src/MuonReadoutElement.cxx:152
ActsTrk::ActsToTrkConverterTool::trkMeasurementToSourceLink
virtual Acts::SourceLink trkMeasurementToSourceLink(const Acts::GeometryContext &gctx, const Trk::MeasurementBase &measurement) const override
Create an SourceLink from an ATLAS measurment Works for 1 and 2D measurmenent.
Definition: ActsToTrkConverterTool.cxx:148
Trk::Surface::associatedDetectorElementIdentifier
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
ActsTrk::ActsToTrkConverterTool::m_pdgToParticleHypothesis
Trk::PdgToParticleHypothesis m_pdgToParticleHypothesis
Definition: ActsToTrkConverterTool.h:105
skel.it
it
Definition: skel.GENtoEVGEN.py:396
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
ActsTrk::ActsToTrkConverterTool::actsTrackParameterPositionCheck
bool actsTrackParameterPositionCheck(const Acts::BoundTrackParameters &actsParameter, const Trk::TrackParameters &tsos, const Acts::GeometryContext &gctx) const
Definition: ActsToTrkConverterTool.cxx:568
ActsTrk::ActsToTrkConverterTool::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition: ActsToTrkConverterTool.h:96
xAOD::identify
Identifier identify(const UncalibratedMeasurement *meas)
Returns the associated identifier.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:61
ActsTrk::SurfaceCache
: Helper class to connect the aligned transformations of each active sensor(layer) with the Acts::Sur...
Definition: Tracking/Acts/ActsGeoUtils/ActsGeoUtils/SurfaceCache.h:23
Trk::DiscSurface
Definition: DiscSurface.h:54
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ActsTrk::ActsToTrkConverterTool::trkSurfaceToActsSurface
virtual const Acts::Surface & trkSurfaceToActsSurface(const Trk::Surface &atlasSurface) const override
Find the Acts surface corresponding to the ATLAS surface Use a map associating ATLAS ID to Acts surfa...
Definition: ActsToTrkConverterTool.cxx:135
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
ActsTrk::ActsToTrkConverterTool::m_trackingGeometry
std::shared_ptr< const Acts::TrackingGeometry > m_trackingGeometry
Definition: ActsToTrkConverterTool.h:98
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
xAOD::Cone
@ Cone
Definition: TrackingPrimitives.h:552
Trk::Surface::owner
SurfaceOwner owner() const
return ownership
CaloCellPos2Ntuple.None
None
Definition: CaloCellPos2Ntuple.py:23
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::ParametersBase::hasSurface
virtual bool hasSurface() const override=0
Test to see if there's a not null surface ptr.
Trk::theta
@ theta
Definition: ParamDefs.h:66
Trk::CylinderSurface
Definition: CylinderSurface.h:55
ActsDetectorElement::atlasSurface
const Trk::Surface & atlasSurface() const
Return a shared pointer on the ATLAS surface associated with this identifier,.
Definition: ActsDetectorElement.cxx:259
calibdata.exception
exception
Definition: calibdata.py:496
ActsTrk::ActsToTrkConverterTool::m_visualDebugOutput
Gaudi::Property< bool > m_visualDebugOutput
Definition: ActsToTrkConverterTool.h:101
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::ActsToTrkConverterTool::m_actsSurfaceMap
std::map< Identifier, const Acts::Surface * > m_actsSurfaceMap
Definition: ActsToTrkConverterTool.h:99
xAOD::Disc
@ Disc
Definition: TrackingPrimitives.h:554
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::readoutElement
const MuonGMR4::MuonReadoutElement * readoutElement(const UncalibratedMeasurement *meas)
Returns the associated readout element to the measurement.
Definition: MuonSpectrometer/MuonPhaseII/Event/xAOD/xAODMuonPrepData/Root/UtilFunctions.cxx:42
beamspotnt.rows
list rows
Definition: bin/beamspotnt.py:1112
ActsDetectorElement
Definition: ActsDetectorElement.h:42
Trk::DetElOwn
@ DetElOwn
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:56
DataVector< const Trk::TrackStateOnSurface >
Trk::MeasurementBase
Definition: MeasurementBase.h:58
Trk::ParticleMasses::mass
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:53
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
Trk::SurfaceType::Perigee
@ Perigee
xAOD::Straw
@ Straw
Definition: TrackingPrimitives.h:557
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
xAOD::Cylinder
@ Cylinder
Definition: TrackingPrimitives.h:553
xAOD::Curvilinear
@ Curvilinear
Definition: TrackingPrimitives.h:558
xAOD::ParticleHypothesis
ParticleHypothesis
Definition: TrackingPrimitives.h:192
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::PlaneSurface
Definition: PlaneSurface.h:64
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
Trk::ConeSurface
Definition: ConeSurface.h:51
Trk::SurfaceType::Plane
@ Plane
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
xAOD::Plane
@ Plane
Definition: TrackingPrimitives.h:556
ActsTrk::ActsToTrkConverterTool::m_extractMuonSurfaces
Gaudi::Property< bool > m_extractMuonSurfaces
Definition: ActsToTrkConverterTool.h:107
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
ActsTrk::ActsToTrkConverterTool::actsSurfaceToTrkSurface
virtual const Trk::Surface & actsSurfaceToTrkSurface(const Acts::Surface &actsSurface) const override
Find the ATLAS surface corresponding to the Acts surface Only work if the Acts surface has an associa...
Definition: ActsToTrkConverterTool.cxx:124
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
InDetDD::TRT_BaseElement
Definition: TRT_BaseElement.h:57
Identifier
Definition: IdentifierFieldParser.cxx:14