ATLAS Offline Software
Loading...
Searching...
No Matches
ActsTrk::ActsToTrkConverterTool Class Reference

#include <ActsToTrkConverterTool.h>

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

Public Member Functions

virtual StatusCode initialize () override
virtual std::vector< Acts::SourceLink > trkTrackToSourceLinks (const Trk::Track &track) const override
 Converts the Trk measurement track states into a vector of Acts::Source links.
virtual std::unique_ptr< Trk::TrackconvertActsToTrk (const EventContext &ctx, const ActsTrack_t &actsTrack, const Trk::TrackInfo::TrackFitter fitAuthor) const override final
virtual std::unique_ptr< Trk::TrackconvertTrack (const EventContext &ctx, const ConstTrack_t &trackProxy) const override final
 Converts a const Acts::Track into.
virtual void convertTrkToActsContainer (const EventContext &ctx, const TrackCollection &trackColl, ActsTrk::MutableTrackContainer &outTrackcoll) const override
 Convert the Trk::Track in the passed TrackCollection into Acts tracks and appends the result to the passed mutable track container.
virtual std::unique_ptr< TrackCollectionconvertActsToTrkContainer (const EventContext &ctx, const ActsTrk::TrackContainer &trackCont) const override final
 Converts the Acts track container to a Trk::Track collection.

Private Types

using TrkTSOSMask = std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
 Abrivate the state mask for the TSOS.

Private Member Functions

template<typename Proxy_t>
std::unique_ptr< Trk::TrackconvertActsTrack (const EventContext &ctx, const Proxy_t &track, const Trk::TrackInfo::TrackFitter fitAuthor) const
 Helper function to convert a Acts TrackPoxy (which may be const or not) into a Trk::Track.
void appendMeasTSOS (const EventContext &ctx, const xAOD::UncalibratedMeasurement *meas, const TrkTSOSMask typePattern, Trk::FitQualityOnSurface &&quality, std::unique_ptr< Trk::TrackParameters > trkPars, Trk::TrackStates &states) const
 Append the translated TSOS at the beginning of the states container corresponding to the parsed measurement.
template<typename PrdType_t>
const Trk::PrepRawDatafetchPrd (const EventContext &ctx, const SG::ReadHandleKey< PrdType_t > &key, const Identifier &prdId, const IdentifierHash &hash) const
 Searches a Prd object from a collection according to the measurement's Identifier and the container's hash.
bool actsTrackParameterPositionCheck (const Acts::BoundTrackParameters &actsParameter, const Trk::TrackParameters &tsos, const Acts::GeometryContext &gctx) const

Private Attributes

PublicToolHandle< IGeometryRealmConvToolm_geometryConvTool {this, "GeometryRealmConvTool", ""}
ContextUtility m_ctxProvider {this}
 Utility to fetch the geometry, magnetic field and calibration context in the event.
ToolHandle< Trk::IExtendedTrackSummaryToolm_trkSummaryTool {this, "SummaryTool", "", "ToolHandle for track summary tool"}
 Tools needed to create Trk::Tracks from the ACts fit result.
ToolHandle< Trk::IRIO_OnTrackCreatorm_ROTcreator {this, "RotCreatorTool", ""}
Gaudi::Property< bool > m_convertHoles {this, "convertHoles", true }
 Flag to convert the hole states.
Gaudi::Property< bool > m_convertOutliers {this, "convertOutliers", true}
 Flag to convert the outlier states.
Gaudi::Property< bool > m_convertMaterial {this, "convertMaterial", false}
 Flag to convert the material states (non sensitive) Acts -> Trk conversion.
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadHandleKey< Muon::MdtPrepDataContainerm_keyMdt {this, "MdtKey", "MDT_DriftCircles"}
SG::ReadHandleKey< Muon::RpcPrepDataContainerm_keyRpc {this, "RpcKey", "RPC_Measurements"}
SG::ReadHandleKey< Muon::TgcPrepDataContainerm_keyTgc {this, "TgcKey", "TGC_MeasurementsAllBCs"}
SG::ReadHandleKey< Muon::MMPrepDataContainerm_keyMm {this, "MmKey", "MM_Measurements"}
SG::ReadHandleKey< Muon::sTgcPrepDataContainerm_keyStgc {this, "sTgcKey", "STGC_Measurements"}
SG::ReadHandleKey< InDet::PixelClusterContainer > m_pixelKey {this, "PixelKey", "ITkPixelClusters" }
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_sctKey {this, "SctKey", "ITkStripClusters" }
ToolHandle< Muon::IMuonCompetingClustersOnTrackCreatorm_compRotCreator {this, "CompetingRotCreator", ""}
detail::TrkMeasurementCalibrator m_measCalib {}
detail::TrkPrepRawDataCalibrator m_prdCalib {}
Trk::TrackInfo::TrackFitter m_fitAuthor {Trk::TrackInfo::TrackFitter::GlobalChi2Fitter}

Detailed Description

Definition at line 44 of file ActsToTrkConverterTool.h.

Member Typedef Documentation

◆ TrkTSOSMask

Abrivate the state mask for the TSOS.

Definition at line 80 of file ActsToTrkConverterTool.h.

Member Function Documentation

◆ actsTrackParameterPositionCheck()

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

Definition at line 230 of file ActsToTrkConverterTool.cxx.

233 {
234 auto actsPos = parameters.position(gctx);
235
236 if ( (actsPos - trkparameters.position()).mag() > 0.1) {
237 ATH_MSG_WARNING("Parameter position mismatch. Acts \n"
238 << actsPos << " vs Trk \n"
239 << trkparameters.position());
240 ATH_MSG_WARNING("Acts surface:");
241 ATH_MSG_WARNING(parameters.referenceSurface().toString(gctx));
242 ATH_MSG_WARNING("Trk surface:");
243 ATH_MSG_WARNING(trkparameters.associatedSurface());
244 return false;
245 }
246 return true;
247}
#define ATH_MSG_WARNING(x)

◆ appendMeasTSOS()

void ActsTrk::ActsToTrkConverterTool::appendMeasTSOS ( const EventContext & ctx,
const xAOD::UncalibratedMeasurement * meas,
const TrkTSOSMask typePattern,
Trk::FitQualityOnSurface && quality,
std::unique_ptr< Trk::TrackParameters > trkPars,
Trk::TrackStates & states ) const
private

Append the translated TSOS at the beginning of the states container corresponding to the parsed measurement.

Parameters
ctxEventContext to access the calibration conditions data needed for the Trk::RIO_OnTrack conversion and to access the PrepRawData
measPointer to the uncalibrated measurement for conversion
typePatternBit mask stating whether the measurement is on track or an outlier
qualityChi2 and nDOF contribution from the measurement
trkParsThe track parameters on the surface
statesOutput container into which the new TSOS is pushed

Dimension 0 measurements are combined measurements!

Todo
Check whether the phi surface is in front of the eta surface

Correct the ROT according to the surface

Definition at line 380 of file ActsToTrkConverterTool.cxx.

385 {
386 std::unique_ptr<Trk::MeasurementBase> rot{};
387 switch (meas->type()) {
388 using enum xAOD::UncalibMeasType;
389 case PixelClusterType: {
390 static const SG::AuxElement::ConstAccessor<ElementLink<InDet::PixelClusterCollection>> acc_prdLink("pixelClusterLink");
391 if (acc_prdLink.isAvailable(*meas) && acc_prdLink(*meas).isValid()) {
392 rot.reset(m_ROTcreator->correct(**acc_prdLink(*meas), *trkPars, ctx));
393 } else {
394 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - The pixel xAOD -> prd accessor is invalid");
395 }
396 break;
397 } case StripClusterType: {
398 static const SG::AuxElement::ConstAccessor<ElementLink<InDet::SCT_ClusterCollection>> acc_prdLink("sctClusterLink");
399 if (acc_prdLink.isAvailable(*meas) && acc_prdLink(*meas).isValid()) {
400 rot.reset(m_ROTcreator->correct(**acc_prdLink(*meas), *trkPars, ctx));
401 } else {
402 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - The strip xAOD -> prd accessor is invalid");
403 }
404 break;
405 } case MdtDriftCircleType:
406 case MMClusterType: {
407 const Identifier& id = static_cast<const xAOD::MuonMeasurement*>(meas)->identify();
408 const IdentifierHash modHash = m_idHelperSvc->moduleHash(id);
409 const auto* prd = meas->type() == MdtDriftCircleType ? fetchPrd(ctx, m_keyMdt, id, modHash)
410 : fetchPrd(ctx, m_keyMm, id, modHash);
411 assert(prd != nullptr);
412 rot.reset(m_ROTcreator->correct(*prd, *trkPars, ctx));
413 break;
414 } case TgcStripType:
415 case RpcStripType:
416 case sTgcStripType: {
417 const Identifier& id = static_cast<const xAOD::MuonMeasurement*>(meas)->identify();
418 const IdentifierHash modHash = m_idHelperSvc->moduleHash(id);
420 const Trk::PrepRawData* prd{nullptr}, *prd1{nullptr};
421
422 if (meas->numDimensions() == 0) {
423 const auto* muonMeas = static_cast<const xAOD::CombinedMuonStrip*>(meas);
424 if (meas->type() == RpcStripType) {
425 prd = fetchPrd(ctx, m_keyRpc, id, modHash);
426 prd1 = fetchPrd(ctx, m_keyRpc, muonMeas->secondaryStrip()->identify(), modHash);
427 } else if (meas->type() == TgcStripType) {
428 prd = fetchPrd(ctx, m_keyTgc, id, modHash);
429 prd1 = fetchPrd(ctx, m_keyTgc, muonMeas->secondaryStrip()->identify(), modHash);
430 } else {
431 prd = fetchPrd(ctx, m_keyStgc, id, modHash);
432 prd1 = fetchPrd(ctx, m_keyStgc, muonMeas->secondaryStrip()->identify(), modHash);
433 }
434 assert(prd != nullptr);
435 assert(prd1 != nullptr);
436
438 const Trk::Surface& phiSurface = prd1->detectorElement()->surface(prd1->identify());
439 auto phiPars = rotateParams(*trkPars, phiSurface);
440 assert(phiPars != nullptr);
441 std::unique_ptr<Trk::MeasurementBase> phiRot{};
442 if (meas->type() != sTgcStripType) {
443 phiRot = m_compRotCreator->createBroadCluster(std::list{prd1}, 1.);
444 rot = m_compRotCreator->createBroadCluster(std::list{prd}, 1.);
445 } else {
446 phiRot.reset(m_ROTcreator->correct(*prd1, *phiPars, ctx));
447 rot.reset(m_ROTcreator->correct(*prd, *trkPars, ctx));
448 }
449 assert(phiRot != nullptr);
450 states.insert(states.begin(),
451 std::make_unique<Trk::TrackStateOnSurface>(quality,
452 std::move(phiRot),
453 std::move(phiPars), nullptr, typePattern));
454 } else {
455 const auto* prd = meas->type() == RpcStripType ? fetchPrd(ctx, m_keyRpc, id, modHash)
456 :
457 meas->type() == TgcStripType ? fetchPrd(ctx, m_keyTgc, id, modHash)
458 : fetchPrd(ctx, m_keyStgc, id, modHash);
459 assert(prd != nullptr);
460 // Track parameter representation needs to change towards a phi surface
461 if (m_idHelperSvc->measuresPhi(id)) {
462 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Convert the track parameters "<<m_idHelperSvc->toString(id)
463 <<", "<<m_idHelperSvc->toStringDetEl(prd->detectorElement()->identify()));
464 const Trk::Surface& target = prd->detectorElement()->surface(id);
465 trkPars = rotateParams(*trkPars, target);
466 }
468 rot.reset(m_ROTcreator->correct(*prd, *trkPars, ctx));
469 }
470 break;
471 } default:
472 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - Measurement type "<<meas->type()<<" is not implemented");
473 return;
474 }
475 if (!rot) {
476 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - ROT creation failed.");
477 return;
478 }
479 assert(rot != nullptr);
480 assert(trkPars != nullptr);
481 states.insert(states.begin(),
482 std::make_unique<Trk::TrackStateOnSurface>(std::move(quality), std::move(rot),
483 std::move(trkPars), nullptr, typePattern));
484
485 }
#define ATH_MSG_VERBOSE(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_keyRpc
ToolHandle< Muon::IMuonCompetingClustersOnTrackCreator > m_compRotCreator
ToolHandle< Trk::IRIO_OnTrackCreator > m_ROTcreator
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_keyMm
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_keyMdt
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_keyTgc
const Trk::PrepRawData * fetchPrd(const EventContext &ctx, const SG::ReadHandleKey< PrdType_t > &key, const Identifier &prdId, const IdentifierHash &hash) const
Searches a Prd object from a collection according to the measurement's Identifier and the container's...
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_keyStgc
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
virtual Identifier identify() const =0
Identifier.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
virtual unsigned int numDimensions() const =0
Returns the number of dimensions of the measurement.
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
std::unique_ptr< Trk::TrackParameters > rotateParams(const Trk::TrackParameters &inPars, const Trk::Surface &target)
MuonMeasurement_v1 MuonMeasurement
UncalibMeasType
Define the type of the uncalibrated measurement.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
CombinedMuonStrip_v1 CombinedMuonStrip

◆ convertActsToTrk()

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkConverterTool::convertActsToTrk ( const EventContext & ctx,
const ActsTrack_t & actsTrack,
const Trk::TrackInfo::TrackFitter fitAuthor ) const
finaloverridevirtual


Definition at line 249 of file ActsToTrkConverterTool.cxx.

251 {
252 return convertActsTrack<ActsTrack_t>(ctx, actsTrack, fitAuthor);
253}
std::unique_ptr< Trk::Track > convertActsTrack(const EventContext &ctx, const Proxy_t &track, const Trk::TrackInfo::TrackFitter fitAuthor) const
Helper function to convert a Acts TrackPoxy (which may be const or not) into a Trk::Track.

◆ convertActsToTrkContainer()

std::unique_ptr< TrackCollection > ActsTrk::ActsToTrkConverterTool::convertActsToTrkContainer ( const EventContext & ctx,
const ActsTrk::TrackContainer & trackCont ) const
finaloverridevirtual

Converts the Acts track container to a Trk::Track collection.

Parameters
ctxEventContext to access the current conditions (alignment, calibration, etc.)
trackContReference to the track container for legacy converstion

Definition at line 372 of file ActsToTrkConverterTool.cxx.

373 {
374 auto outColl = std::make_unique<TrackCollection>();
375 for (const ActsTrk::TrackContainer::ConstTrackProxy trk : trackCont) {
376 outColl->push_back(convertActsTrack(ctx, trk, m_fitAuthor));
377 }
378 return outColl;
379 }
Trk::TrackInfo::TrackFitter m_fitAuthor

◆ convertActsTrack()

template<typename Proxy_t>
std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkConverterTool::convertActsTrack ( const EventContext & ctx,
const Proxy_t & track,
const Trk::TrackInfo::TrackFitter fitAuthor ) const
private

Helper function to convert a Acts TrackPoxy (which may be const or not) into a Trk::Track.

Parameters
ctxThe EventContext to access the current calibration constants
trackReference to the track state proxy for translation
fitAuthorAuthor that is written in the track summary info

Definition at line 260 of file ActsToTrkConverterTool.cxx.

262 {
263
264 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Check track "<<acts_track.tipIndex());
265 const Acts::CalibrationContext cctx{getCalibrationContext(ctx)};
266 const Acts::GeometryContext tgContext{m_ctxProvider.getGeometryContext(ctx)};
267
268 auto finalTrajectory = std::make_unique<Trk::TrackStates>();
269
270
271 // Loop over all the output state to create track state
272 acts_track.container().trackStateContainer().visitBackwards(acts_track.tipIndex(),
273 [&] (const auto &state) -> void {
274 if (!state.hasReferenceSurface()) {
275 return;
276 }
277 // First only consider state with an associated detector element
278 if (!m_convertMaterial && !state.referenceSurface().isSensitive()) {
279 return;
280 }
281 int nDoF{0};
282 double chi2{0};
283
284 if (!state.hasSmoothed() && !state.hasFiltered() && !state.hasPredicted()) {
285 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - State has no valid parameters (smoothed/filtered/predicted)");
286 return;
287 }
288
289 if (const auto* associatedDetEl = dynamic_cast<const ISurfacePlacement*>(
290 state.referenceSurface().surfacePlacement());
291 associatedDetEl != nullptr) {
292 ATH_MSG_VERBOSE("Associated det: "<<associatedDetEl->detectorType());
293 }
294
295 auto flag = state.typeFlags();
296
297 auto boundPars = acts_track.createParametersFromState(state);
298
299 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - "<<" hole: "<<flag.isHole()
300 <<", outlier: "<<flag.isOutlier()<<", measurement: "<<flag.isMeasurement()<<"/"
301 <<flag.hasMeasurement()<<", "<<m_convertOutliers<<", "<<m_convertHoles
302 <<", has SL: "<<state.hasUncalibratedSourceLink()
303 <<", parameters: "<<boundPars);
304
305 // We need to determine the type of state
306 TrkTSOSMask typePattern;
307
308 std::unique_ptr<Trk::TrackParameters> trkPars = m_geometryConvTool->convertTrackParametersToTrk(ctx, boundPars);
309 std::unique_ptr<Trk::MeasurementBase> trkMeasurement{};
310
311
312 // State is a hole (no associated measurement), use predicted parameters
313 if (flag.isHole()) {
314 if (!m_convertHoles) { return; }
315 typePattern.set(Trk::TrackStateOnSurface::Hole);
316 } if (flag.isOutlier()) {
317 if (!m_convertOutliers) { return; }
318 typePattern.set(Trk::TrackStateOnSurface::Outlier);
319 }
320 if (flag.hasMeasurement()) {
322 nDoF = state.calibratedSize();
323 chi2 = state.chi2();
324 const auto slType = detail::MeasurementCalibratorBase::getType(state.getUncalibratedSourceLink());
325 switch (slType) {
326 using enum detail::SourceLinkType;
327 case TrkMeasurement:
328 trkMeasurement = m_measCalib.unpack(state.getUncalibratedSourceLink())->uniqueClone();
329 break;
330 case TrkPrepRawData:
331 trkMeasurement = m_prdCalib.createROT(tgContext, cctx, state.getUncalibratedSourceLink(), state);
332 break;
333 case xAODUnCalibMeas:
334 appendMeasTSOS(ctx, detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink()),
335 typePattern, Trk::FitQualityOnSurface{chi2, nDoF},
336 std::move(trkPars), *finalTrajectory);
337 return;
338 default:
339 THROW_EXCEPTION("Invalid "<<slType<<" type parsed.");
340 }
341 }
342 auto perState = std::make_unique<Trk::TrackStateOnSurface>(Trk::FitQualityOnSurface{chi2, nDoF},
343 std::move(trkMeasurement),
344 std::move(trkPars), nullptr, typePattern);
345 // If a state was succesfully created add it to the trajectory
346 ATH_MSG_VERBOSE("State succesfully created, adding it to the trajectory");
347 finalTrajectory->insert(finalTrajectory->begin(), std::move(perState));
348 });
349
350 if (finalTrajectory->empty()) {
351 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" No measurements added to the track");
352 return nullptr;
353 }
354 // Convert the perigee state and add it to the trajectory
355 std::unique_ptr<Trk::TrackParameters> per = m_geometryConvTool->convertTrackParametersToTrk(ctx, acts_track.createParametersAtReference());
356 TrkTSOSMask typePattern;
357 typePattern.set(Trk::TrackStateOnSurface::Perigee);
358 finalTrajectory->insert(finalTrajectory->begin(),
359 std::make_unique<Trk::TrackStateOnSurface>(nullptr, std::move(per), nullptr, typePattern));
360 // Create the track using the states
361 Trk::TrackInfo newInfo{fitAuthor, ParticleHypothesis::convertTrk(acts_track.particleHypothesis())};
362 auto newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory),
363 std::make_unique<Trk::FitQuality>(static_cast<double>(acts_track.chi2()),
364 static_cast<int>(acts_track.nDoF())));
365 constexpr bool suppressHoleSearch = false;
366 m_trkSummaryTool->updateTrackSummary(ctx, *newtrack, suppressHoleSearch);
367 ATH_MSG_VERBOSE("Created new track "<<(*newtrack->trackSummary()));
368 return newtrack;
369 }
#define ATH_MSG_DEBUG(x)
if(pathvar)
std::bitset< Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes > TrkTSOSMask
Abrivate the state mask for the TSOS.
ContextUtility m_ctxProvider
Utility to fetch the geometry, magnetic field and calibration context in the event.
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trkSummaryTool
Tools needed to create Trk::Tracks from the ACts fit result.
Gaudi::Property< bool > m_convertOutliers
Flag to convert the outlier states.
PublicToolHandle< IGeometryRealmConvTool > m_geometryConvTool
detail::TrkPrepRawDataCalibrator m_prdCalib
Gaudi::Property< bool > m_convertHoles
Flag to convert the hole states.
detail::TrkMeasurementCalibrator m_measCalib
void appendMeasTSOS(const EventContext &ctx, const xAOD::UncalibratedMeasurement *meas, const TrkTSOSMask typePattern, Trk::FitQualityOnSurface &&quality, std::unique_ptr< Trk::TrackParameters > trkPars, Trk::TrackStates &states) const
Append the translated TSOS at the beginning of the states container corresponding to the parsed measu...
Gaudi::Property< bool > m_convertMaterial
Flag to convert the material states (non sensitive) Acts -> Trk conversion.
static SourceLinkType getType(const Acts::SourceLink &sl)
Returns the enumeration corresponding to the object type cached within the Acts::SourceLink.
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Hole
A hole on the track - this is defined in the following way.
double chi2(TH1 *h0, TH1 *h1)
Trk::ParticleHypothesis convertTrk(Acts::ParticleHypothesis h)
SourceLinkType
Enumeration to distinguish between the ATLAS EDM -> Acts::SourceLink variants.
@ xAODUnCalibMeas
UnCalibrated Trk::PrepRawData objects.
@ TrkPrepRawData
Calibrated Trk::MeasurementBase objects.
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
bool flag
Definition master.py:29
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ convertTrack()

std::unique_ptr< Trk::Track > ActsTrk::ActsToTrkConverterTool::convertTrack ( const EventContext & ctx,
const ConstTrack_t & trackProxy ) const
finaloverridevirtual

Converts a const Acts::Track into.

Parameters
ctxEventContext to access the current conditions (alignment, calibrations, etc.)
trackProxyThe acts track for conversion

Definition at line 254 of file ActsToTrkConverterTool.cxx.

255 {
256 return convertActsTrack(ctx, trackProxy, m_fitAuthor);
257}

◆ convertTrkToActsContainer()

void ActsTrk::ActsToTrkConverterTool::convertTrkToActsContainer ( const EventContext & ctx,
const TrackCollection & trackColl,
ActsTrk::MutableTrackContainer & outTrackcoll ) const
overridevirtual

Convert the Trk::Track in the passed TrackCollection into Acts tracks and appends the result to the passed mutable track container.

Parameters
ctxEventContext to access the current conditions (alignment, calibrations, etc.)
trackCollThe Trk::Track container to be converted
outTrackCollReference to the mutable track container to which the converted tracks are appended.

Definition at line 101 of file ActsToTrkConverterTool.cxx.

103 {
104 const Acts::GeometryContext tgContext = m_ctxProvider.getGeometryContext(ctx);
105 ATH_MSG_VERBOSE("Calling trkTrackCollectionToActsTrackContainer with "
106 << trackColl.size() << " tracks.");
107 unsigned int trkCount = 0;
108 std::vector<Identifier> failedIds; // Keep track of Identifiers of failed conversions
109 for (const Trk::Track* trk : trackColl) {
110 // Do conversions!
111 const Trk::TrackStates *trackStates = trk->trackStateOnSurfaces();
112
113 auto actsTrack = outTrackcoll.getTrack(outTrackcoll.addTrack());
114 auto& trackStateContainer = outTrackcoll.trackStateContainer();
115
116 ATH_MSG_VERBOSE("Track "<<trkCount++<<" has " << trackStates->size()
117 << " track states on surfaces.");
118 // basic quantities copy
119 actsTrack.chi2() = trk->fitQuality()->chiSquared();
120 actsTrack.nDoF() = trk->fitQuality()->numberDoF();
121
122 // loop over track states on surfaces, convert and add them to the ACTS
123 // container
124 bool first_tsos = true; // We need to handle the first one differently
125 int measurementsCount = 0;
126 for (const Trk::TrackStateOnSurface* tsos : *trackStates) {
127
128 // Setup the mask
129 Acts::TrackStatePropMask mask = Acts::TrackStatePropMask::None;
130 if (tsos->measurementOnTrack()) {
131 mask |= Acts::TrackStatePropMask::Calibrated;
132 }
133 if (tsos->trackParameters()) {
134 mask |= Acts::TrackStatePropMask::Smoothed;
135 }
136
137 // Setup the index of the trackstate
138 auto index = Acts::kTrackIndexInvalid;
139 if (!first_tsos) {
140 index = actsTrack.tipIndex();
141 }
142 auto actsTSOS = trackStateContainer.getTrackState(trackStateContainer.addTrackState(mask, index));
143 ATH_MSG_VERBOSE("TipIndex: " << actsTrack.tipIndex() << " TSOS index within trajectory: "<< actsTSOS.index());
144 actsTrack.tipIndex() = actsTSOS.index();
145
146 if (tsos->trackParameters()) {
147 // TODO This try/catch is temporary and should be removed once the sTGC problem is fixed.
148 try {
149 ATH_MSG_VERBOSE("Converting track parameters.");
150 // TODO - work out whether we should set predicted, filtered, smoothed
151 const Acts::BoundTrackParameters parameters = m_geometryConvTool->convertTrackParametersToActs(ctx, *tsos->trackParameters());
152 ATH_MSG_VERBOSE("Track parameters: " << parameters.parameters());
153 // Sanity check on positions
154 if (!actsTrackParameterPositionCheck(parameters, *(tsos->trackParameters()), tgContext)) {
155 failedIds.push_back(tsos->trackParameters()->associatedSurface().associatedDetectorElementIdentifier());
156 }
157
158 if (first_tsos) {
159 // This is the first track state, so we need to set the track
160 // parameters
161 actsTrack.parameters() = parameters.parameters();
162 actsTrack.covariance() = *parameters.covariance();
163 actsTrack.setReferenceSurface(parameters.referenceSurface().getSharedPtr());
164 first_tsos = false;
165 } else {
166 actsTSOS.setReferenceSurface(parameters.referenceSurface().getSharedPtr());
167 // Since we're converting final Trk::Tracks, let's assume they're smoothed
168 actsTSOS.smoothed() = parameters.parameters();
169 if (parameters.covariance().has_value()) {
170 actsTSOS.smoothedCovariance() = *parameters.covariance();
171 }
172 else {
173 actsTSOS.smoothedCovariance() = Acts::BoundMatrix::Zero();
174 }
175 // Not yet implemented in MultiTrajectory.icc
176 // actsTSOS.typeFlags().setHasParameters();
177 if (!(actsTSOS.hasSmoothed() && actsTSOS.hasReferenceSurface())) {
178 ATH_MSG_WARNING("TrackState does not have smoothed state ["
179 << actsTSOS.hasSmoothed()
180 << "] or reference surface ["
181 << actsTSOS.hasReferenceSurface() << "].");
182 } else {
183 ATH_MSG_VERBOSE("TrackState has smoothed state and reference surface.");
184 }
185 }
186 } catch (const std::exception& e){
187 ATH_MSG_ERROR("Unable to convert TrackParameter with exception ["<<e.what()<<"]. Will be missing from ACTS track."
188 <<(*tsos->trackParameters()));
189 }
190 }
191 if (tsos->measurementOnTrack()) {
192 auto &measurement = *(tsos->measurementOnTrack());
193 actsTSOS.typeFlags().setIsMeasurement();
194
195 measurementsCount++;
196 // const Acts::Surface &surface =
197 // convertSurfaceToActs(measurement.associatedSurface());
198 // Commented for the moment because Surfaces not yet implemented in
199 // MultiTrajectory.icc
200
201 int dim = measurement.localParameters().dimension();
202 actsTSOS.allocateCalibrated(dim);
203 if (dim == 1) {
204 actsTSOS.calibrated<1>() = measurement.localParameters();
205 actsTSOS.calibratedCovariance<1>() = measurement.localCovariance();
206 } else if (dim == 2) {
207 actsTSOS.calibrated<2>() = measurement.localParameters();
208 actsTSOS.calibratedCovariance<2>() = measurement.localCovariance();
209 } else {
210 throw std::domain_error("Cannot handle measurement dim>2");
211 }
212 actsTSOS.setUncalibratedSourceLink(detail::TrkMeasurementCalibrator::pack(tsos->measurementOnTrack()));
213
214 } // end if measurement
215 } // end loop over track states
216 actsTrack.nMeasurements() = measurementsCount;
217 ATH_MSG_VERBOSE("TrackProxy has " << actsTrack.nTrackStates()
218 << " track states on surfaces.");
219 }
220 ATH_MSG_VERBOSE("Finished converting " << trackColl.size() << " tracks.");
221
222 if (!failedIds.empty()){
223 ATH_MSG_WARNING("Failed to convert "<<failedIds.size()<<" track parameters.");
224 for (auto id : failedIds){
225 ATH_MSG_WARNING("-> Failed for Identifier "<<m_idHelperSvc->toString(id));
226 }
227 }
228 ATH_MSG_VERBOSE("ACTS Track container has " << outTrackcoll.size() << " tracks.");
229}
#define ATH_MSG_ERROR(x)
bool actsTrackParameterPositionCheck(const Acts::BoundTrackParameters &actsParameter, const Trk::TrackParameters &tsos, const Acts::GeometryContext &gctx) const
static Acts::SourceLink pack(const Ptr_t &measurement)
Pack the measurement type pointer to an Acts::SourceLink including the intermediate conversion into a...
size_type size() const noexcept
Returns the number of elements in the collection.
str index
Definition DeMoScan.py:362
DataVector< const Trk::TrackStateOnSurface > TrackStates

◆ fetchPrd()

template<typename PrdType_t>
const Trk::PrepRawData * ActsTrk::ActsToTrkConverterTool::fetchPrd ( const EventContext & ctx,
const SG::ReadHandleKey< PrdType_t > & key,
const Identifier & prdId,
const IdentifierHash & hash ) const
private

Searches a Prd object from a collection according to the measurement's Identifier and the container's hash.

Parameters
ctxEventContext to retrieve the container from StoreGate
keyReadHandleKey specifying which container is to be fetched
prdIdIdentifier of the measurement to retrieve
hashThe associated IdentifierHash to look-up the collection

Definition at line 487 of file ActsToTrkConverterTool.cxx.

490 {
491 const PrdType_t* container{nullptr};
492 if (key.empty() || !SG::get(container, key, ctx).isSuccess()) {
493 THROW_EXCEPTION("Failed to retrieve container "<<key.fullKey());
494 }
495 const auto* coll = container->indexFindPtr(hash);
496 if (coll == nullptr){
497 ATH_MSG_WARNING("fetchPrd() - Failed to find a valid collection for "<<prdId.getString()<<", key: "<<key.fullKey());
498 return nullptr;
499 }
500 for (const Trk::PrepRawData* prd : *coll) {
501 if (prd->identify() == prdId) {
502 return prd;
503 }
504 }
505 ATH_MSG_WARNING("fetchPrd() - Prep data object "<<prdId.getString()<<" is not in "<<key.fullKey());
506 return nullptr;
507 }
std::string getString() const
Provide a string form of the identifier - hexadecimal.
const SG::AuxVectorData * container() const
Return the container holding this element.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.

◆ initialize()

StatusCode ActsTrk::ActsToTrkConverterTool::initialize ( )
overridevirtual

Definition at line 68 of file ActsToTrkConverterTool.cxx.

68 {
69 ATH_MSG_DEBUG("Initializing ACTS to ATLAS converter tool");
70
71 ATH_CHECK(m_trkSummaryTool.retrieve());
72 ATH_CHECK(m_ROTcreator.retrieve());
73 ATH_CHECK(m_geometryConvTool.retrieve());
74 ATH_CHECK(m_ctxProvider.initialize());
75 m_prdCalib = detail::TrkPrepRawDataCalibrator{m_geometryConvTool.get(), m_ROTcreator.get()};
79 ATH_CHECK(m_keyMm.initialize(SG::AllowEmpty));
83
84 if (!m_keyMdt.empty() || !m_keyRpc.empty() || !m_keyTgc.empty() ||
85 !m_keyMm.empty() || !m_keyStgc.empty()) {
86 ATH_CHECK(m_idHelperSvc.retrieve());
87 }
88 ATH_CHECK(m_compRotCreator.retrieve(EnableTool{!m_keyRpc.empty() || !m_keyTgc.empty()}));
89 return StatusCode::SUCCESS;
90}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< InDet::PixelClusterContainer > m_pixelKey
SG::ReadHandleKey< InDet::SCT_ClusterContainer > m_sctKey

◆ trkTrackToSourceLinks()

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

Converts the Trk measurement track states into a vector of Acts::Source links.

The source links don't take ownership over the measurement states.

Parameters
trackReference to the track to convert

Definition at line 93 of file ActsToTrkConverterTool.cxx.

93 {
94 std::vector<Acts::SourceLink> sourceLinks{};
95 sourceLinks.reserve(track.measurementsOnTrack()->size() +
96 track.outliersOnTrack()->size());
97 detail::MeasurementCalibratorBase::pack(track.measurementsOnTrack()->stdcont(), sourceLinks);
98 detail::MeasurementCalibratorBase::pack(track.outliersOnTrack()->stdcont(), sourceLinks);
99 return sourceLinks;
100}

Member Data Documentation

◆ m_compRotCreator

ToolHandle<Muon::IMuonCompetingClustersOnTrackCreator> ActsTrk::ActsToTrkConverterTool::m_compRotCreator {this, "CompetingRotCreator", ""}
private

Definition at line 139 of file ActsToTrkConverterTool.h.

139{this, "CompetingRotCreator", ""}; //<! competing clusters rio ontrack creator

◆ m_convertHoles

Gaudi::Property<bool> ActsTrk::ActsToTrkConverterTool::m_convertHoles {this, "convertHoles", true }
private

Flag to convert the hole states.

Definition at line 123 of file ActsToTrkConverterTool.h.

123{this, "convertHoles", true };

◆ m_convertMaterial

Gaudi::Property<bool> ActsTrk::ActsToTrkConverterTool::m_convertMaterial {this, "convertMaterial", false}
private

Flag to convert the material states (non sensitive) Acts -> Trk conversion.

Definition at line 127 of file ActsToTrkConverterTool.h.

127{this, "convertMaterial", false};

◆ m_convertOutliers

Gaudi::Property<bool> ActsTrk::ActsToTrkConverterTool::m_convertOutliers {this, "convertOutliers", true}
private

Flag to convert the outlier states.

Definition at line 125 of file ActsToTrkConverterTool.h.

125{this, "convertOutliers", true};

◆ m_ctxProvider

ContextUtility ActsTrk::ActsToTrkConverterTool::m_ctxProvider {this}
private

Utility to fetch the geometry, magnetic field and calibration context in the event.

Definition at line 117 of file ActsToTrkConverterTool.h.

117{this};

◆ m_fitAuthor

Trk::TrackInfo::TrackFitter ActsTrk::ActsToTrkConverterTool::m_fitAuthor {Trk::TrackInfo::TrackFitter::GlobalChi2Fitter}
private

Definition at line 144 of file ActsToTrkConverterTool.h.

◆ m_geometryConvTool

PublicToolHandle<IGeometryRealmConvTool> ActsTrk::ActsToTrkConverterTool::m_geometryConvTool {this, "GeometryRealmConvTool", ""}
private

Definition at line 114 of file ActsToTrkConverterTool.h.

114{this, "GeometryRealmConvTool", ""};

◆ m_idHelperSvc

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

Definition at line 129 of file ActsToTrkConverterTool.h.

129{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_keyMdt

SG::ReadHandleKey<Muon::MdtPrepDataContainer> ActsTrk::ActsToTrkConverterTool::m_keyMdt {this, "MdtKey", "MDT_DriftCircles"}
private

Definition at line 131 of file ActsToTrkConverterTool.h.

131{this, "MdtKey", "MDT_DriftCircles"};

◆ m_keyMm

SG::ReadHandleKey<Muon::MMPrepDataContainer> ActsTrk::ActsToTrkConverterTool::m_keyMm {this, "MmKey", "MM_Measurements"}
private

Definition at line 134 of file ActsToTrkConverterTool.h.

134{this, "MmKey", "MM_Measurements"};

◆ m_keyRpc

SG::ReadHandleKey<Muon::RpcPrepDataContainer> ActsTrk::ActsToTrkConverterTool::m_keyRpc {this, "RpcKey", "RPC_Measurements"}
private

Definition at line 132 of file ActsToTrkConverterTool.h.

132{this, "RpcKey", "RPC_Measurements"};

◆ m_keyStgc

SG::ReadHandleKey<Muon::sTgcPrepDataContainer> ActsTrk::ActsToTrkConverterTool::m_keyStgc {this, "sTgcKey", "STGC_Measurements"}
private

Definition at line 135 of file ActsToTrkConverterTool.h.

135{this, "sTgcKey", "STGC_Measurements"};

◆ m_keyTgc

SG::ReadHandleKey<Muon::TgcPrepDataContainer> ActsTrk::ActsToTrkConverterTool::m_keyTgc {this, "TgcKey", "TGC_MeasurementsAllBCs"}
private

Definition at line 133 of file ActsToTrkConverterTool.h.

133{this, "TgcKey", "TGC_MeasurementsAllBCs"};

◆ m_measCalib

detail::TrkMeasurementCalibrator ActsTrk::ActsToTrkConverterTool::m_measCalib {}
private

Definition at line 141 of file ActsToTrkConverterTool.h.

141{};

◆ m_pixelKey

SG::ReadHandleKey<InDet::PixelClusterContainer> ActsTrk::ActsToTrkConverterTool::m_pixelKey {this, "PixelKey", "ITkPixelClusters" }
private

Definition at line 136 of file ActsToTrkConverterTool.h.

136{this, "PixelKey", "ITkPixelClusters" };

◆ m_prdCalib

detail::TrkPrepRawDataCalibrator ActsTrk::ActsToTrkConverterTool::m_prdCalib {}
private

Definition at line 142 of file ActsToTrkConverterTool.h.

142{};

◆ m_ROTcreator

ToolHandle<Trk::IRIO_OnTrackCreator> ActsTrk::ActsToTrkConverterTool::m_ROTcreator {this, "RotCreatorTool", ""}
private

Definition at line 120 of file ActsToTrkConverterTool.h.

120{this, "RotCreatorTool", ""};

◆ m_sctKey

SG::ReadHandleKey<InDet::SCT_ClusterContainer> ActsTrk::ActsToTrkConverterTool::m_sctKey {this, "SctKey", "ITkStripClusters" }
private

Definition at line 137 of file ActsToTrkConverterTool.h.

137{this, "SctKey", "ITkStripClusters" };

◆ m_trkSummaryTool

ToolHandle<Trk::IExtendedTrackSummaryTool> ActsTrk::ActsToTrkConverterTool::m_trkSummaryTool {this, "SummaryTool", "", "ToolHandle for track summary tool"}
private

Tools needed to create Trk::Tracks from the ACts fit result.

Definition at line 119 of file ActsToTrkConverterTool.h.

119{this, "SummaryTool", "", "ToolHandle for track summary tool"};

The documentation for this class was generated from the following files: